123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- using LYFZ.ComponentLibrary;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Windows.Forms;
- using System.Data;
- using System.Data.OleDb;
- namespace LYFZ.Software.MainBusiness.Customers
- {
- public class Customer
- {
- //public DataGridViewEx dgv2 = null;
- //public DataGridViewEx dgv = null;
- #region Excel操作
- public bool istime(string str)
- {
- return LYFZ.WinAPI.CustomPublicMethod.IsTime(str);
- }
- ///// <summary>
- ///// 创建列标题
- ///// </summary>
- ///// <param name="dgv1"></param>
- //public void Pu_column(DataGridViewEx dgvCurrent, ref DataGridViewEx dgvNew)
- //{
- // if (dgvNew == null)
- // { dgvNew = new DataGridViewEx(); }
- // if (dgvCurrent != null)
- // {
- // dgvNew.Columns.Clear();
- // for (int dg = 0; dg < dgvCurrent.Columns.Count; dg++)
- // {
- // DataGridViewTextBoxColumn com = new DataGridViewTextBoxColumn();
- // com.HeaderText = dgvCurrent.Columns[dg].HeaderText;
- // dgvNew.Columns.Add(com);
- // }
- // }
- //}
- ///// <summary>
- ///// 检查手机在Excel是否重复
- ///// </summary>
- ///// <param name="sj">手机号</param>
- ///// <param name="dgv1">dgv</param>
- ///// <param name="lie">列名</param>
- ///// <param name="index">本行索引</param>
- //public bool Pu_check(string sj, DataGridViewEx dgvCurrent, DataGridViewEx dgvNew, string lie, int index)
- //{
- // bool Isok = false;
- // if (dgvNew != null)
- // {
- // List<int> shouji = new List<int>();
- // bool Is = false;
- // for (int i = dgvCurrent.Rows.Count - 1; i >= 0; i--)
- // {
- // if (i != index)
- // {
- // if (dgvCurrent.Rows[i].Cells[lie].Value.ToString().Trim() == sj)
- // {
- // shouji.Add(i);
- // Is = true;
- // }
- // }
- // } if (Is)
- // { shouji.Add(index); }
- // if (shouji.Count > 0)
- // {
- // foreach (int i in shouji)
- // {
- // DataGridViewCell cell = null;
- // DataGridViewRow dgvr = new DataGridViewRow();
- // foreach (DataGridViewColumn item in dgvCurrent.Columns)
- // {
- // cell = new DataGridViewTextBoxCell();
- // cell.Value = dgvCurrent.Rows[i].Cells[item.HeaderText].Value.ToString().Trim();
- // dgvr.Cells.Add(cell);
- // }
- // dgvNew.Rows.Add(dgvr);
- // dgvCurrent.Rows.RemoveAt(i);
- // }
- // Isok = true;
- // }
- // }
- // return Isok;
- //}
- ///// <summary>
- ///// 检查到错误数据判断
- ///// </summary>
- ///// <param name="index"></param>
- ///// <param name="dgv1"></param>
- //public void Pu_delete(int index, DataGridViewEx dgvCurrent, DataGridViewEx dgvNew)
- //{
- // if (dgvNew != null)
- // {
- // DataGridViewCell cell = null;
- // DataGridViewRow dgvr = new DataGridViewRow();
- // foreach (DataGridViewColumn item in dgvNew.Columns)
- // {
- // cell = new DataGridViewTextBoxCell();
- // cell.Value = dgvCurrent.Rows[index].Cells[item.HeaderText].Value.ToString().Trim();
- // dgvr.Cells.Add(cell);
- // }
- // dgvNew.Rows.Add(dgvr);
- // dgvCurrent.Rows.RemoveAt(index);
- // }
- //}
- /// <summary>
- /// 导出Excel
- /// </summary>
- /// <param name="dgvNew"></param>
- public void DataToExcel(DataGridView dgvNew, string type, string Url)
- {
- if (dgvNew.Rows.Count > 0)
- {
- string FileName = Url + type + "错误资料.xls";
- LYFZ.WinAPI.CustomPublicMethod.DataGridViewToExcel(FileName,dgvNew);
- }
- }
- /// <summary>
- /// 导出Excel
- /// </summary>
- /// <param name="dgvNew"></param>
- public void DataToExcel(System.Data.DataTable dtError, string type, string Url)
- {
- if (dtError.Rows.Count > 0)
- {
- string FileName = Url + type + "错误资料.xls";
- LYFZ.WinAPI.CustomPublicMethod.DataGridViewToExcel(FileName, dtError);
- }
- }
- }
- #endregion
- }
|