123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256 |
- 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;
- }
- /// <summary>
- /// 客户编号
- /// </summary>
- public string StrClientNumber;
- /// <summary>
- /// 相片集合
- /// </summary>
- ImageList mlistImage = new ImageList();
- /// <summary>
- /// 用于排序的类
- /// </summary>
- LYFZ.ComponentLibrary.ListViewColumnSorter lvwColumnSorter;
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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();
- }
- /// <summary>
- /// 回车查询
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void txtkeyword_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- { this.PublicFunctionRows(); }
- }
- /// <summary>
- /// 查询
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnSlect_Click(object sender, EventArgs e)
- { this.PublicFunctionRows(); }
- /// <summary>
- /// 确定
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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();
- }
- /// <summary>
- /// 关闭
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnclose_Click(object sender, EventArgs e)
- { this.Close(); }
- /// <summary>
- /// 点击排序
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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);
- }
- /// <summary>
- /// 双击选中
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void listViewData_MouseDoubleClick(object sender, MouseEventArgs e)
- {
- if (this.listViewData.Items.Count > 0 && this.listViewData.SelectedItems.Count > 0)
- { this.btnOK_Click(this, null); }
- }
- /// <summary>
- /// 创建行
- /// </summary>
- void PublicFunctionRows()
- {
- this.ucPagerEx1.PageCurrent = 1;
- this.ucPagerEx1.PageSize = 100;
- this.ucPagerEx1.Bind();
- }
- /// <summary>
- /// 画分页
- /// </summary>
- /// <param name="e"></param>
- /// <returns></returns>
- 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;
- }
- }
- }
|