Customer.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. using LYFZ.ComponentLibrary;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Text.RegularExpressions;
  8. using System.Windows.Forms;
  9. using System.Data;
  10. using System.Data.OleDb;
  11. namespace LYFZ.Software.MainBusiness.Customers
  12. {
  13. public class Customer
  14. {
  15. //public DataGridViewEx dgv2 = null;
  16. //public DataGridViewEx dgv = null;
  17. #region Excel操作
  18. public bool istime(string str)
  19. {
  20. return LYFZ.WinAPI.CustomPublicMethod.IsTime(str);
  21. }
  22. ///// <summary>
  23. ///// 创建列标题
  24. ///// </summary>
  25. ///// <param name="dgv1"></param>
  26. //public void Pu_column(DataGridViewEx dgvCurrent, ref DataGridViewEx dgvNew)
  27. //{
  28. // if (dgvNew == null)
  29. // { dgvNew = new DataGridViewEx(); }
  30. // if (dgvCurrent != null)
  31. // {
  32. // dgvNew.Columns.Clear();
  33. // for (int dg = 0; dg < dgvCurrent.Columns.Count; dg++)
  34. // {
  35. // DataGridViewTextBoxColumn com = new DataGridViewTextBoxColumn();
  36. // com.HeaderText = dgvCurrent.Columns[dg].HeaderText;
  37. // dgvNew.Columns.Add(com);
  38. // }
  39. // }
  40. //}
  41. ///// <summary>
  42. ///// 检查手机在Excel是否重复
  43. ///// </summary>
  44. ///// <param name="sj">手机号</param>
  45. ///// <param name="dgv1">dgv</param>
  46. ///// <param name="lie">列名</param>
  47. ///// <param name="index">本行索引</param>
  48. //public bool Pu_check(string sj, DataGridViewEx dgvCurrent, DataGridViewEx dgvNew, string lie, int index)
  49. //{
  50. // bool Isok = false;
  51. // if (dgvNew != null)
  52. // {
  53. // List<int> shouji = new List<int>();
  54. // bool Is = false;
  55. // for (int i = dgvCurrent.Rows.Count - 1; i >= 0; i--)
  56. // {
  57. // if (i != index)
  58. // {
  59. // if (dgvCurrent.Rows[i].Cells[lie].Value.ToString().Trim() == sj)
  60. // {
  61. // shouji.Add(i);
  62. // Is = true;
  63. // }
  64. // }
  65. // } if (Is)
  66. // { shouji.Add(index); }
  67. // if (shouji.Count > 0)
  68. // {
  69. // foreach (int i in shouji)
  70. // {
  71. // DataGridViewCell cell = null;
  72. // DataGridViewRow dgvr = new DataGridViewRow();
  73. // foreach (DataGridViewColumn item in dgvCurrent.Columns)
  74. // {
  75. // cell = new DataGridViewTextBoxCell();
  76. // cell.Value = dgvCurrent.Rows[i].Cells[item.HeaderText].Value.ToString().Trim();
  77. // dgvr.Cells.Add(cell);
  78. // }
  79. // dgvNew.Rows.Add(dgvr);
  80. // dgvCurrent.Rows.RemoveAt(i);
  81. // }
  82. // Isok = true;
  83. // }
  84. // }
  85. // return Isok;
  86. //}
  87. ///// <summary>
  88. ///// 检查到错误数据判断
  89. ///// </summary>
  90. ///// <param name="index"></param>
  91. ///// <param name="dgv1"></param>
  92. //public void Pu_delete(int index, DataGridViewEx dgvCurrent, DataGridViewEx dgvNew)
  93. //{
  94. // if (dgvNew != null)
  95. // {
  96. // DataGridViewCell cell = null;
  97. // DataGridViewRow dgvr = new DataGridViewRow();
  98. // foreach (DataGridViewColumn item in dgvNew.Columns)
  99. // {
  100. // cell = new DataGridViewTextBoxCell();
  101. // cell.Value = dgvCurrent.Rows[index].Cells[item.HeaderText].Value.ToString().Trim();
  102. // dgvr.Cells.Add(cell);
  103. // }
  104. // dgvNew.Rows.Add(dgvr);
  105. // dgvCurrent.Rows.RemoveAt(index);
  106. // }
  107. //}
  108. /// <summary>
  109. /// 导出Excel
  110. /// </summary>
  111. /// <param name="dgvNew"></param>
  112. public void DataToExcel(DataGridView dgvNew, string type, string Url)
  113. {
  114. if (dgvNew.Rows.Count > 0)
  115. {
  116. string FileName = Url + type + "错误资料.xls";
  117. LYFZ.WinAPI.CustomPublicMethod.DataGridViewToExcel(FileName,dgvNew);
  118. }
  119. }
  120. /// <summary>
  121. /// 导出Excel
  122. /// </summary>
  123. /// <param name="dgvNew"></param>
  124. public void DataToExcel(System.Data.DataTable dtError, string type, string Url)
  125. {
  126. if (dtError.Rows.Count > 0)
  127. {
  128. string FileName = Url + type + "错误资料.xls";
  129. LYFZ.WinAPI.CustomPublicMethod.DataGridViewToExcel(FileName, dtError);
  130. }
  131. }
  132. }
  133. #endregion
  134. }