SelectVendorSetSmallForm.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. namespace LYFZ.Software.MainBusiness.InitialSet.SetSmallForm
  10. {
  11. public partial class SelectVendorSetSmallForm : LYFZ.Software.UI.InitialSet.SetSmallForm.SelectVendorSetSmallForm
  12. {
  13. LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
  14. public SelectVendorSetSmallForm()
  15. {
  16. this.Load += SelectSupplierSetSmallForm_Load;
  17. this.Shown += SelectSupplierSetSmallForm_Shown;
  18. this.btnAdded.Click += btnAdded_Click;
  19. this.btnRemove.Click += btnRemove_Click;
  20. this.listViewData_Source.MouseDoubleClick += listViewData_Source_MouseDoubleClick;
  21. this.listViewData_Selected.MouseDoubleClick += listViewData_Selected_MouseDoubleClick;
  22. this.btnOK.Click += btnOK_Click;
  23. }
  24. /// <summary>
  25. /// 是否保存
  26. /// </summary>
  27. public bool IsSaveed = false;
  28. /// <summary>
  29. /// 选择的供应商
  30. /// </summary>
  31. public string StrSelectedValue = "";
  32. /// <summary>
  33. /// 提供的供应商(即提供源)
  34. /// </summary>
  35. public string StrProvideValue = "";
  36. /// <summary>
  37. /// 窗体加载事件
  38. /// </summary>
  39. /// <param name="sender"></param>
  40. /// <param name="e"></param>
  41. void SelectSupplierSetSmallForm_Load(object sender, EventArgs e)
  42. {
  43. this.listViewData_Source.View = View.Details;
  44. this.listViewData_Source.GridLines = true;
  45. ImageList imgList = new ImageList();
  46. imgList.ImageSize = new Size(1, 25);
  47. this.listViewData_Source.SmallImageList = imgList;
  48. string[] StrColumns = "供应商,联系电话,地址".Split(',');
  49. int SurplusCount = 90 + 85 + 23;
  50. for (int i = 0; i < StrColumns.Length; i++)
  51. {
  52. ColumnHeader ch = new ColumnHeader();
  53. ch.Text = StrColumns[i].Trim();
  54. ch.TextAlign = HorizontalAlignment.Left;
  55. if (i == 0)
  56. { ch.Width = this.listViewData_Source.Width - SurplusCount; }
  57. else if (i == StrColumns.Length - 1)
  58. { ch.Width = 90; }
  59. else
  60. { ch.Width = 85; }
  61. ch.TextAlign = HorizontalAlignment.Center;
  62. this.listViewData_Source.Columns.Add(ch);
  63. }
  64. this.listViewData_Selected.View = View.Details;
  65. this.listViewData_Selected.GridLines = true;
  66. this.listViewData_Selected.SmallImageList = imgList;
  67. for (int i = 0; i < StrColumns.Length; i++)
  68. {
  69. ColumnHeader ch = new ColumnHeader();
  70. ch.Text = StrColumns[i].Trim();
  71. ch.TextAlign = HorizontalAlignment.Left;
  72. if (i == 0)
  73. { ch.Width = this.listViewData_Selected.Width - SurplusCount; }
  74. else if (i == StrColumns.Length - 1)
  75. { ch.Width = 90; }
  76. else
  77. { ch.Width = 85; }
  78. ch.TextAlign = HorizontalAlignment.Center;
  79. this.listViewData_Selected.Columns.Add(ch);
  80. }
  81. }
  82. /// <summary>
  83. /// 窗体加载事件
  84. /// </summary>
  85. /// <param name="sender"></param>
  86. /// <param name="e"></param>
  87. void SelectSupplierSetSmallForm_Shown(object sender, EventArgs e)
  88. {
  89. List<string> ListValue = StrProvideValue.Trim().Split(',').ToList();
  90. DataTable dt = orbll.GetView_Custom("tb_ErpVendor", StrWhere: "", ShowColumnName: "Vd_Name,Vd_Telephone,Vd_Address").Tables[0];
  91. if (dt.Rows.Count > 0)
  92. {
  93. for (int i = 0; i < dt.Rows.Count; i++)
  94. {
  95. if (ListValue.Count > 0)
  96. {
  97. for (int j = 0; j < ListValue.Count; j++)
  98. {
  99. if (!string.IsNullOrEmpty(ListValue[j].Trim()))
  100. {
  101. if (dt.Rows[i]["Vd_Name"].ToString().Trim() == ListValue[j].Trim())
  102. {
  103. ListViewItem lvItem2 = new ListViewItem();
  104. lvItem2.Tag = dt.Rows[i]["Vd_Name"].ToString().Trim();
  105. lvItem2.Text = dt.Rows[i]["Vd_Name"].ToString().Trim();
  106. ListViewItem.ListViewSubItem ListSubItem2 = new ListViewItem.ListViewSubItem();
  107. ListSubItem2.Name = "联系电话";
  108. ListSubItem2.Text = dt.Rows[i]["Vd_Name"].ToString().Trim();
  109. lvItem2.SubItems.Add(ListSubItem2);
  110. ListSubItem2 = new ListViewItem.ListViewSubItem();
  111. ListSubItem2.Name = "地址";
  112. ListSubItem2.Text = dt.Rows[i]["Vd_Name"].ToString().Trim();
  113. lvItem2.SubItems.Add(ListSubItem2);
  114. this.listViewData_Selected.Items.Add(lvItem2);
  115. ListValue.Remove(ListValue[j]);
  116. }
  117. }
  118. }
  119. }
  120. ListViewItem lvItem = new ListViewItem();
  121. lvItem.Tag = dt.Rows[i]["Vd_Name"].ToString().Trim();
  122. lvItem.Text = dt.Rows[i]["Vd_Name"].ToString().Trim();
  123. ListViewItem.ListViewSubItem ListSubItem = new ListViewItem.ListViewSubItem();
  124. ListSubItem.Name = "联系电话";
  125. ListSubItem.Text = dt.Rows[i]["Vd_Telephone"].ToString().Trim();
  126. lvItem.SubItems.Add(ListSubItem);
  127. ListSubItem = new ListViewItem.ListViewSubItem();
  128. ListSubItem.Name = "地址";
  129. ListSubItem.Text = dt.Rows[i]["Vd_Address"].ToString().Trim();
  130. lvItem.SubItems.Add(ListSubItem);
  131. this.listViewData_Source.Items.Add(lvItem);
  132. }
  133. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.ListViewDrawSingleOrDoubleRows(this.listViewData_Source);
  134. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.ListViewDrawSingleOrDoubleRows(this.listViewData_Selected);
  135. }
  136. }
  137. /// <summary>
  138. /// 添加
  139. /// </summary>
  140. /// <param name="sender"></param>
  141. /// <param name="e"></param>
  142. void btnAdded_Click(object sender, EventArgs e)
  143. {
  144. if (this.listViewData_Source.Items.Count > 0 && this.listViewData_Source.SelectedItems.Count > 0)
  145. {
  146. for (int j = 0; j < this.listViewData_Source.SelectedItems.Count; j++)
  147. {
  148. ListViewItem SelectItem = this.listViewData_Source.SelectedItems[j];
  149. for (int i = 0; i < this.listViewData_Selected.Items.Count; i++)
  150. {
  151. if (this.listViewData_Selected.Items[i].Text.Trim() == SelectItem.Text.Trim())
  152. { return; }
  153. }
  154. ListViewItem lvItem = new ListViewItem();
  155. lvItem.Tag = SelectItem.Text.Trim();
  156. lvItem.Text = SelectItem.Tag.ToString().Trim();
  157. ListViewItem.ListViewSubItem ListSubItem = new ListViewItem.ListViewSubItem();
  158. ListSubItem.Name = "联系电话";
  159. ListSubItem.Text = SelectItem.SubItems[0].Text.Trim();
  160. lvItem.SubItems.Add(ListSubItem);
  161. ListSubItem = new ListViewItem.ListViewSubItem();
  162. ListSubItem.Name = "地址";
  163. ListSubItem.Text = SelectItem.SubItems[1].Text.Trim();
  164. lvItem.SubItems.Add(ListSubItem);
  165. if ((this.listViewData_Selected.Items.Count % 2) > 0)
  166. { lvItem.BackColor = System.Drawing.Color.PapayaWhip; }
  167. else
  168. { lvItem.BackColor = System.Drawing.Color.PowderBlue; }
  169. this.listViewData_Selected.Items.Add(lvItem);
  170. }
  171. }
  172. }
  173. /// <summary>
  174. /// 移除
  175. /// </summary>
  176. /// <param name="sender"></param>
  177. /// <param name="e"></param>
  178. void btnRemove_Click(object sender, EventArgs e)
  179. {
  180. if (this.listViewData_Selected.Items.Count > 0 && this.listViewData_Selected.SelectedItems.Count > 0)
  181. {
  182. List<ListViewItem> delList = new List<ListViewItem>();
  183. for (int i = 0; i < this.listViewData_Selected.SelectedItems.Count; i++)
  184. { delList.Add(this.listViewData_Selected.SelectedItems[i]); }
  185. for (int i = 0; i < delList.Count; i++)
  186. { this.listViewData_Selected.Items.Remove(delList[i]); }
  187. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.ListViewDrawSingleOrDoubleRows(this.listViewData_Selected);
  188. }
  189. }
  190. /// <summary>
  191. /// 源供应商双击添加
  192. /// </summary>
  193. /// <param name="sender"></param>
  194. /// <param name="e"></param>
  195. void listViewData_Source_MouseDoubleClick(object sender, MouseEventArgs e)
  196. {
  197. if (this.listViewData_Source.Items.Count > 0 && this.listViewData_Source.SelectedItems.Count > 0)
  198. {
  199. ListViewItem SelectItem = this.listViewData_Source.SelectedItems[0];
  200. for (int i = 0; i < this.listViewData_Selected.Items.Count; i++)
  201. {
  202. if (this.listViewData_Selected.Items[i].Text.Trim() == SelectItem.Text.Trim())
  203. { return; }
  204. }
  205. ListViewItem lvItem = new ListViewItem();
  206. lvItem.Tag = SelectItem.Text.Trim();
  207. lvItem.Text = SelectItem.Tag.ToString().Trim();
  208. ListViewItem.ListViewSubItem ListSubItem = new ListViewItem.ListViewSubItem();
  209. ListSubItem.Name = "联系电话";
  210. ListSubItem.Text = SelectItem.SubItems[0].Text.Trim();
  211. lvItem.SubItems.Add(ListSubItem);
  212. ListSubItem = new ListViewItem.ListViewSubItem();
  213. ListSubItem.Name = "地址";
  214. ListSubItem.Text = SelectItem.SubItems[1].Text.Trim();
  215. lvItem.SubItems.Add(ListSubItem);
  216. if ((this.listViewData_Selected.Items.Count % 2) > 0)
  217. { lvItem.BackColor = System.Drawing.Color.PapayaWhip; }
  218. else
  219. { lvItem.BackColor = System.Drawing.Color.PowderBlue; }
  220. this.listViewData_Selected.Items.Add(lvItem);
  221. }
  222. }
  223. /// <summary>
  224. /// 已选择供应商双击移除
  225. /// </summary>
  226. /// <param name="sender"></param>
  227. /// <param name="e"></param>
  228. void listViewData_Selected_MouseDoubleClick(object sender, MouseEventArgs e)
  229. {
  230. if (this.listViewData_Selected.Items.Count > 0 && this.listViewData_Selected.SelectedItems.Count > 0)
  231. {
  232. this.listViewData_Selected.Items.Remove(this.listViewData_Selected.SelectedItems[0]);
  233. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.ListViewDrawSingleOrDoubleRows(this.listViewData_Selected);
  234. }
  235. }
  236. /// <summary>
  237. /// 确定
  238. /// </summary>
  239. /// <param name="sender"></param>
  240. /// <param name="e"></param>
  241. void btnOK_Click(object sender, EventArgs e)
  242. {
  243. string strItemText = "";
  244. for (int i = 0; i < this.listViewData_Selected.Items.Count; i++)
  245. { strItemText += this.listViewData_Selected.Items[i].Text.Trim() + ","; }
  246. this.StrSelectedValue = strItemText.TrimEnd(',');
  247. this.IsSaveed = true;
  248. this.Close();
  249. }
  250. }
  251. }