using LYFZ.ComponentLibrary; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace LYFZ.Software.MainBusiness.Dresses.DressManagement { public partial class FrmCusSelect : LYFZ.Software.UI.Dresses.DressManagement.FrmCusSelect { public FrmCusSelect() { this.Shown+=FrmCusSelect_Shown; this.txtkeyword.KeyDown += txtkeyword_KeyDown; this.btnSlect.Click += btnSlect_Click; this.btnOK.Click += btnOK_Click; this.btnclose.Click += btnclose_Click; this.listViewData.ColumnClick += listViewData_ColumnClick; this.listViewData.MouseDoubleClick += listViewData_MouseDoubleClick; this.ucPagerEx1.EventPaging += ucPagerEx1_EventPaging; } /// /// 客户编号 /// public string StrClientNumber; /// /// 相片集合 /// ImageList mlistImage = new ImageList(); /// /// 用于排序的类 /// LYFZ.ComponentLibrary.ListViewColumnSorter lvwColumnSorter; /// /// 窗体加载事件 /// /// /// void FrmCusSelect_Shown(object sender, EventArgs e) { this.listViewData.View = View.Details; this.listViewData.GridLines = true; string[] StrColumns = "客户姓名,客户电话,客户性别,客户生日,客户婚期,客户QQ,客户微信,客户地址".Split(','); for (int i = 0; i < StrColumns.Length; i++) { ColumnHeader ch = new ColumnHeader(); ch.Text = StrColumns[i].Trim(); ch.TextAlign = HorizontalAlignment.Left; switch (StrColumns[i].Trim()) { case "客户生日": case "客户婚期": ch.Width = 120; break; default: ch.Width = 100; break; } this.listViewData.Columns.Add(ch); } this.mlistImage.ImageSize = new Size(1, 27); this.mlistImage.ColorDepth = ColorDepth.Depth32Bit; this.listViewData.SmallImageList = mlistImage; this.lvwColumnSorter = new ComponentLibrary.ListViewColumnSorter(); this.listViewData.ListViewItemSorter = this.lvwColumnSorter; this.PublicFunctionRows(); } /// /// 回车查询 /// /// /// void txtkeyword_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { this.PublicFunctionRows(); } } /// /// 查询 /// /// /// void btnSlect_Click(object sender, EventArgs e) { this.PublicFunctionRows(); } /// /// 确定 /// /// /// void btnOK_Click(object sender, EventArgs e) { if (this.listViewData.SelectedItems.Count == 0) { MessageBoxCustom.Show("请选中你要的客户!"); return; } this.StrClientNumber = this.listViewData.SelectedItems[0].Tag.ToString().Trim(); this.Close(); } /// /// 关闭 /// /// /// void btnclose_Click(object sender, EventArgs e) { this.Close(); } /// /// 点击排序 /// /// /// void listViewData_ColumnClick(object sender, ColumnClickEventArgs e) { // 检查点击的列是不是现在的排序列. if (e.Column == lvwColumnSorter.SortColumn) { // 重新设置此列的排序方法. if (lvwColumnSorter.Order == SortOrder.Ascending) { lvwColumnSorter.Order = SortOrder.Descending; } else { lvwColumnSorter.Order = SortOrder.Ascending; } } else { // 设置排序列,默认为正向排序 lvwColumnSorter.SortColumn = e.Column; lvwColumnSorter.Order = SortOrder.Ascending; } // 用新的排序方法对ListView排序 this.listViewData.Sort(); LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.ListViewDrawSingleOrDoubleRows(this.listViewData); } /// /// 双击选中 /// /// /// void listViewData_MouseDoubleClick(object sender, MouseEventArgs e) { if (this.listViewData.Items.Count > 0 && this.listViewData.SelectedItems.Count > 0) { this.btnOK_Click(this, null); } } /// /// 创建行 /// void PublicFunctionRows() { this.ucPagerEx1.PageCurrent = 1; this.ucPagerEx1.PageSize = 100; this.ucPagerEx1.Bind(); } /// /// 画分页 /// /// /// private int ucPagerEx1_EventPaging(UCPager.EventPagingArg e) { this.listViewData.Items.Clear(); string StrWhere = "Cus_Type!='儿童'"; DataTable dt = new DataTable(); if (!string.IsNullOrEmpty(this.txtkeyword.Text)) { StrWhere += " and (Cus_Name like '%" + this.txtkeyword.Text + "%' or Cus_Telephone like '%" + this.txtkeyword.Text + "%' or Cus_NamePinyin like '" + this.txtkeyword.Text + "')"; } LYFZ.UCPager.PageData pageData = new LYFZ.UCPager.PageData(); LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker) { pageData.TableName = "tb_ErpCustomer"; pageData.PageIndex = this.ucPagerEx1.PageCurrent; pageData.PageSize = this.ucPagerEx1.PageSize; pageData.QueryCondition = StrWhere.ToString(); pageData.QueryFieldName = "Cus_CustomerNumber,Cus_Name,Cus_Telephone,Cus_Sex,Cus_Birthday,Cus_BirthdayLunar,Cus_DayForMarriage,Cus_DayForMarriageLunar,Cus_QQ,Cus_MicroSignal,Cus_Address"; pageData.OrderStr = "ID desc"; pageData.OrderType = 1; DataSet da = pageData.QueryDataTable(); dt = da.Tables[0]; if (dt.Rows.Count > 0) { this.Invoke(new LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.UpdateControl(delegate() { #region for (int t = 0; t < dt.Rows.Count; t++) { ListViewItem lvItem = new ListViewItem(); lvItem.Tag = dt.Rows[t]["Cus_CustomerNumber"].ToString().Trim(); lvItem.Text = dt.Rows[t]["Cus_Name"].ToString().Trim(); ListViewItem.ListViewSubItem ListSubItem = new ListViewItem.ListViewSubItem(); ListSubItem.Name = "客户电话"; ListSubItem.Text = dt.Rows[t]["Cus_Telephone"].ToString().Trim(); lvItem.SubItems.Add(ListSubItem); ListSubItem = new ListViewItem.ListViewSubItem(); ListSubItem.Name = "客户性别"; ListSubItem.Text = dt.Rows[t]["Cus_Sex"].ToString().Trim() == "0" ? "男" : "女"; lvItem.SubItems.Add(ListSubItem); ListSubItem = new ListViewItem.ListViewSubItem(); ListSubItem.Name = "客户生日"; string StrBirthday = ""; if (!string.IsNullOrEmpty(dt.Rows[t]["Cus_Birthday"].ToString().Trim())) { StrBirthday = dt.Rows[t]["Cus_Birthday"].ToString().Trim(); if (dt.Rows[t]["Cus_BirthdayLunar"].ToString().Trim() == "1") { StrBirthday += "_农历"; } } ListSubItem.Text = StrBirthday; lvItem.SubItems.Add(ListSubItem); ListSubItem = new ListViewItem.ListViewSubItem(); ListSubItem.Name = "客户婚期"; string StrDayForMarriage = ""; if (!string.IsNullOrEmpty(dt.Rows[t]["Cus_DayForMarriage"].ToString().Trim())) { StrDayForMarriage = dt.Rows[t]["Cus_DayForMarriage"].ToString().Trim(); if (dt.Rows[t]["Cus_DayForMarriageLunar"].ToString().Trim() == "1") { StrDayForMarriage += "_农历"; } } ListSubItem.Text = StrDayForMarriage; lvItem.SubItems.Add(ListSubItem); ListSubItem = new ListViewItem.ListViewSubItem(); ListSubItem.Name = "客户QQ"; ListSubItem.Text = dt.Rows[t]["Cus_QQ"].ToString().Trim(); lvItem.SubItems.Add(ListSubItem); ListSubItem = new ListViewItem.ListViewSubItem(); ListSubItem.Name = "客户微信"; ListSubItem.Text = dt.Rows[t]["Cus_MicroSignal"].ToString().Trim(); lvItem.SubItems.Add(ListSubItem); ListSubItem = new ListViewItem.ListViewSubItem(); ListSubItem.Name = "客户地址"; ListSubItem.Text = dt.Rows[t]["Cus_Address"].ToString().Trim(); lvItem.SubItems.Add(ListSubItem); if ((this.listViewData.Items.Count % 2) > 0) { lvItem.BackColor = System.Drawing.Color.PapayaWhip; } else { lvItem.BackColor = System.Drawing.Color.PowderBlue; } this.listViewData.Items.Add(lvItem); } #endregion })); } }); try { this.ucPagerEx1.TbDataSource = dt; } catch { } return pageData.TotalCount; } } }