123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269 |
- 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.InitialSet.SetSmallForm
- {
- public partial class SelectVendorSetSmallForm : LYFZ.Software.UI.InitialSet.SetSmallForm.SelectVendorSetSmallForm
- {
- LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
- public SelectVendorSetSmallForm()
- {
- this.Load += SelectSupplierSetSmallForm_Load;
- this.Shown += SelectSupplierSetSmallForm_Shown;
- this.btnAdded.Click += btnAdded_Click;
- this.btnRemove.Click += btnRemove_Click;
- this.listViewData_Source.MouseDoubleClick += listViewData_Source_MouseDoubleClick;
- this.listViewData_Selected.MouseDoubleClick += listViewData_Selected_MouseDoubleClick;
- this.btnOK.Click += btnOK_Click;
- }
- /// <summary>
- /// 是否保存
- /// </summary>
- public bool IsSaveed = false;
- /// <summary>
- /// 选择的供应商
- /// </summary>
- public string StrSelectedValue = "";
- /// <summary>
- /// 提供的供应商(即提供源)
- /// </summary>
- public string StrProvideValue = "";
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void SelectSupplierSetSmallForm_Load(object sender, EventArgs e)
- {
- this.listViewData_Source.View = View.Details;
- this.listViewData_Source.GridLines = true;
- ImageList imgList = new ImageList();
- imgList.ImageSize = new Size(1, 25);
- this.listViewData_Source.SmallImageList = imgList;
- string[] StrColumns = "供应商,联系电话,地址".Split(',');
- int SurplusCount = 90 + 85 + 23;
- for (int i = 0; i < StrColumns.Length; i++)
- {
- ColumnHeader ch = new ColumnHeader();
- ch.Text = StrColumns[i].Trim();
- ch.TextAlign = HorizontalAlignment.Left;
- if (i == 0)
- { ch.Width = this.listViewData_Source.Width - SurplusCount; }
- else if (i == StrColumns.Length - 1)
- { ch.Width = 90; }
- else
- { ch.Width = 85; }
- ch.TextAlign = HorizontalAlignment.Center;
- this.listViewData_Source.Columns.Add(ch);
- }
- this.listViewData_Selected.View = View.Details;
- this.listViewData_Selected.GridLines = true;
- this.listViewData_Selected.SmallImageList = imgList;
- for (int i = 0; i < StrColumns.Length; i++)
- {
- ColumnHeader ch = new ColumnHeader();
- ch.Text = StrColumns[i].Trim();
- ch.TextAlign = HorizontalAlignment.Left;
- if (i == 0)
- { ch.Width = this.listViewData_Selected.Width - SurplusCount; }
- else if (i == StrColumns.Length - 1)
- { ch.Width = 90; }
- else
- { ch.Width = 85; }
- ch.TextAlign = HorizontalAlignment.Center;
- this.listViewData_Selected.Columns.Add(ch);
- }
- }
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void SelectSupplierSetSmallForm_Shown(object sender, EventArgs e)
- {
- List<string> ListValue = StrProvideValue.Trim().Split(',').ToList();
- DataTable dt = orbll.GetView_Custom("tb_ErpVendor", StrWhere: "", ShowColumnName: "Vd_Name,Vd_Telephone,Vd_Address").Tables[0];
- if (dt.Rows.Count > 0)
- {
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- if (ListValue.Count > 0)
- {
- for (int j = 0; j < ListValue.Count; j++)
- {
- if (!string.IsNullOrEmpty(ListValue[j].Trim()))
- {
- if (dt.Rows[i]["Vd_Name"].ToString().Trim() == ListValue[j].Trim())
- {
- ListViewItem lvItem2 = new ListViewItem();
- lvItem2.Tag = dt.Rows[i]["Vd_Name"].ToString().Trim();
- lvItem2.Text = dt.Rows[i]["Vd_Name"].ToString().Trim();
- ListViewItem.ListViewSubItem ListSubItem2 = new ListViewItem.ListViewSubItem();
- ListSubItem2.Name = "联系电话";
- ListSubItem2.Text = dt.Rows[i]["Vd_Name"].ToString().Trim();
- lvItem2.SubItems.Add(ListSubItem2);
- ListSubItem2 = new ListViewItem.ListViewSubItem();
- ListSubItem2.Name = "地址";
- ListSubItem2.Text = dt.Rows[i]["Vd_Name"].ToString().Trim();
- lvItem2.SubItems.Add(ListSubItem2);
- this.listViewData_Selected.Items.Add(lvItem2);
- ListValue.Remove(ListValue[j]);
- }
- }
- }
- }
- ListViewItem lvItem = new ListViewItem();
- lvItem.Tag = dt.Rows[i]["Vd_Name"].ToString().Trim();
- lvItem.Text = dt.Rows[i]["Vd_Name"].ToString().Trim();
- ListViewItem.ListViewSubItem ListSubItem = new ListViewItem.ListViewSubItem();
- ListSubItem.Name = "联系电话";
- ListSubItem.Text = dt.Rows[i]["Vd_Telephone"].ToString().Trim();
- lvItem.SubItems.Add(ListSubItem);
- ListSubItem = new ListViewItem.ListViewSubItem();
- ListSubItem.Name = "地址";
- ListSubItem.Text = dt.Rows[i]["Vd_Address"].ToString().Trim();
- lvItem.SubItems.Add(ListSubItem);
- this.listViewData_Source.Items.Add(lvItem);
- }
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.ListViewDrawSingleOrDoubleRows(this.listViewData_Source);
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.ListViewDrawSingleOrDoubleRows(this.listViewData_Selected);
- }
- }
- /// <summary>
- /// 添加
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnAdded_Click(object sender, EventArgs e)
- {
- if (this.listViewData_Source.Items.Count > 0 && this.listViewData_Source.SelectedItems.Count > 0)
- {
- for (int j = 0; j < this.listViewData_Source.SelectedItems.Count; j++)
- {
- ListViewItem SelectItem = this.listViewData_Source.SelectedItems[j];
- for (int i = 0; i < this.listViewData_Selected.Items.Count; i++)
- {
- if (this.listViewData_Selected.Items[i].Text.Trim() == SelectItem.Text.Trim())
- { return; }
- }
- ListViewItem lvItem = new ListViewItem();
- lvItem.Tag = SelectItem.Text.Trim();
- lvItem.Text = SelectItem.Tag.ToString().Trim();
- ListViewItem.ListViewSubItem ListSubItem = new ListViewItem.ListViewSubItem();
- ListSubItem.Name = "联系电话";
- ListSubItem.Text = SelectItem.SubItems[0].Text.Trim();
- lvItem.SubItems.Add(ListSubItem);
- ListSubItem = new ListViewItem.ListViewSubItem();
- ListSubItem.Name = "地址";
- ListSubItem.Text = SelectItem.SubItems[1].Text.Trim();
- lvItem.SubItems.Add(ListSubItem);
- if ((this.listViewData_Selected.Items.Count % 2) > 0)
- { lvItem.BackColor = System.Drawing.Color.PapayaWhip; }
- else
- { lvItem.BackColor = System.Drawing.Color.PowderBlue; }
- this.listViewData_Selected.Items.Add(lvItem);
- }
- }
- }
- /// <summary>
- /// 移除
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnRemove_Click(object sender, EventArgs e)
- {
- if (this.listViewData_Selected.Items.Count > 0 && this.listViewData_Selected.SelectedItems.Count > 0)
- {
- List<ListViewItem> delList = new List<ListViewItem>();
- for (int i = 0; i < this.listViewData_Selected.SelectedItems.Count; i++)
- { delList.Add(this.listViewData_Selected.SelectedItems[i]); }
- for (int i = 0; i < delList.Count; i++)
- { this.listViewData_Selected.Items.Remove(delList[i]); }
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.ListViewDrawSingleOrDoubleRows(this.listViewData_Selected);
- }
- }
- /// <summary>
- /// 源供应商双击添加
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void listViewData_Source_MouseDoubleClick(object sender, MouseEventArgs e)
- {
- if (this.listViewData_Source.Items.Count > 0 && this.listViewData_Source.SelectedItems.Count > 0)
- {
- ListViewItem SelectItem = this.listViewData_Source.SelectedItems[0];
- for (int i = 0; i < this.listViewData_Selected.Items.Count; i++)
- {
- if (this.listViewData_Selected.Items[i].Text.Trim() == SelectItem.Text.Trim())
- { return; }
- }
- ListViewItem lvItem = new ListViewItem();
- lvItem.Tag = SelectItem.Text.Trim();
- lvItem.Text = SelectItem.Tag.ToString().Trim();
- ListViewItem.ListViewSubItem ListSubItem = new ListViewItem.ListViewSubItem();
- ListSubItem.Name = "联系电话";
- ListSubItem.Text = SelectItem.SubItems[0].Text.Trim();
- lvItem.SubItems.Add(ListSubItem);
- ListSubItem = new ListViewItem.ListViewSubItem();
- ListSubItem.Name = "地址";
- ListSubItem.Text = SelectItem.SubItems[1].Text.Trim();
- lvItem.SubItems.Add(ListSubItem);
- if ((this.listViewData_Selected.Items.Count % 2) > 0)
- { lvItem.BackColor = System.Drawing.Color.PapayaWhip; }
- else
- { lvItem.BackColor = System.Drawing.Color.PowderBlue; }
- this.listViewData_Selected.Items.Add(lvItem);
- }
- }
- /// <summary>
- /// 已选择供应商双击移除
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void listViewData_Selected_MouseDoubleClick(object sender, MouseEventArgs e)
- {
- if (this.listViewData_Selected.Items.Count > 0 && this.listViewData_Selected.SelectedItems.Count > 0)
- {
- this.listViewData_Selected.Items.Remove(this.listViewData_Selected.SelectedItems[0]);
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.ListViewDrawSingleOrDoubleRows(this.listViewData_Selected);
- }
- }
- /// <summary>
- /// 确定
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnOK_Click(object sender, EventArgs e)
- {
- string strItemText = "";
- for (int i = 0; i < this.listViewData_Selected.Items.Count; i++)
- { strItemText += this.listViewData_Selected.Items[i].Text.Trim() + ","; }
- this.StrSelectedValue = strItemText.TrimEnd(',');
- this.IsSaveed = true;
- this.Close();
- }
- }
- }
|