SelectDressSuperSmallForm.cs 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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.CameraControlBook.SuperSmallForm
  10. {
  11. public partial class SelectDressSuperSmallForm : LYFZ.Software.UI.CameraControlBook.SuperSmallForm.SelectDressSuperSmallForm
  12. {
  13. LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
  14. public SelectDressSuperSmallForm()
  15. {
  16. this.Shown += SelectDressSuperSmallForm_Shown;
  17. this.btnQuery.Click += btnQuery_Click;
  18. this.txtQuery.KeyDown += txtQuery_KeyDown;
  19. this.cmbtreevCategory.ComboBoxTree_NodeMouseClick += cmbtreevCategory_ComboBoxTree_NodeMouseClick;
  20. this.btnSaveed.Click += btnSaveed_Click;
  21. this.btnCancel.Click += btnCancel_Click;
  22. this.dgvData.CellMouseDoubleClick += dgvData_CellMouseDoubleClick;
  23. this.dgvData2.CellMouseDoubleClick += dgvData2_CellMouseDoubleClick;
  24. }
  25. public bool IsSaveed = false;
  26. public string StrValue;
  27. /// <summary>
  28. /// 窗体加载事件
  29. /// </summary>
  30. /// <param name="sender"></param>
  31. /// <param name="e"></param>
  32. void SelectDressSuperSmallForm_Shown(object sender, EventArgs e)
  33. {
  34. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("BEAJBGADDCBAHFFA", this.cmbtreevCategory, IsFirstNodeNull: true);
  35. this.dgvData.DataColumns("礼服编号,礼服类别,礼服名称,礼服品牌,礼服尺寸,摆放区域,礼服说明");
  36. this.dgvData2.DataColumns("礼服编号,礼服名称");
  37. this.PublicFunctionRows();
  38. this.PublicFunctionRows2();
  39. }
  40. /// <summary>
  41. /// 查询
  42. /// </summary>
  43. /// <param name="sender"></param>
  44. /// <param name="e"></param>
  45. void btnQuery_Click(object sender, EventArgs e)
  46. {
  47. this.PublicFunctionRows();
  48. }
  49. /// <summary>
  50. /// 回车查询
  51. /// </summary>
  52. /// <param name="sender"></param>
  53. /// <param name="e"></param>
  54. void txtQuery_KeyDown(object sender, KeyEventArgs e)
  55. {
  56. if (e.KeyCode == Keys.Enter)
  57. { this.PublicFunctionRows(); }
  58. }
  59. /// <summary>
  60. /// 选择类别查询
  61. /// </summary>
  62. /// <param name="sender"></param>
  63. /// <param name="e"></param>
  64. void cmbtreevCategory_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
  65. {
  66. this.PublicFunctionRows();
  67. }
  68. /// <summary>
  69. /// 确定
  70. /// </summary>
  71. /// <param name="sender"></param>
  72. /// <param name="e"></param>
  73. void btnSaveed_Click(object sender, EventArgs e)
  74. {
  75. string strDataRows = "";
  76. for (int i = 0; i < this.dgvData2.Rows.Count; i++)
  77. { strDataRows += this.dgvData2.Rows[i].Cells["礼服编号"].Value.ToString().Trim() + ","; }
  78. this.StrValue = strDataRows.TrimEnd(',');
  79. this.IsSaveed = true;
  80. this.Close();
  81. }
  82. /// <summary>
  83. /// 双击选中
  84. /// </summary>
  85. /// <param name="sender"></param>
  86. /// <param name="e"></param>
  87. void dgvData_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
  88. {
  89. if (e.ColumnIndex >= 0 && e.RowIndex >= 0)
  90. {
  91. if (this.dgvData.Rows.Count > 0)
  92. {
  93. DataGridViewRow dgvr = new DataGridViewRow();
  94. DataGridViewCell cell = null;
  95. cell = new DataGridViewTextBoxCell();
  96. cell.Value = this.dgvData.Rows[e.RowIndex].Cells["礼服编号"].Value.ToString().Trim();
  97. dgvr.Cells.Add(cell);
  98. cell = new DataGridViewTextBoxCell();
  99. cell.Value = this.dgvData.Rows[e.RowIndex].Cells["礼服名称"].Value.ToString().Trim();
  100. dgvr.Cells.Add(cell);
  101. this.dgvData2.Rows.Add(dgvr);
  102. }
  103. }
  104. }
  105. /// <summary>
  106. /// 双击移除
  107. /// </summary>
  108. /// <param name="sender"></param>
  109. /// <param name="e"></param>
  110. void dgvData2_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
  111. {
  112. if (e.ColumnIndex >= 0 && e.RowIndex >= 0)
  113. {
  114. if (this.dgvData.Rows.Count > 0)
  115. {
  116. this.dgvData2.Rows.RemoveAt(e.RowIndex);
  117. }
  118. }
  119. }
  120. /// <summary>
  121. /// 取消
  122. /// </summary>
  123. /// <param name="sender"></param>
  124. /// <param name="e"></param>
  125. void btnCancel_Click(object sender, EventArgs e)
  126. {
  127. this.Close();
  128. }
  129. /// <summary>
  130. ///
  131. /// </summary>
  132. private void PublicFunctionRows()
  133. {
  134. this.dgvData.Rows.Clear();
  135. string strWhere = "";
  136. if (!string.IsNullOrEmpty(this.txtQuery.Text.Trim()))
  137. { strWhere += " And (Dsfm_DressNumber like '%" + this.txtQuery.Text.Trim() + "%' Or Dsfm_DressName like '%" + this.txtQuery.Text.Trim() + "%')"; }
  138. if (!string.IsNullOrEmpty(this.cmbtreevCategory.Text.Trim()))
  139. { strWhere += " And Dsfm_DressType = '" + this.cmbtreevCategory.Tag.ToString().Trim() + "'"; }
  140. DataTable tbl = orbll.GetView_Custom("tb_ErpDressFrom left Join tb_ErpSystemCategory AS SystemDressType on Dsfm_DressType = SystemDressType.Sc_ClassCode left Join tb_ErpSystemCategory AS SystemPlacedRegion on Dsfm_PlacedRegion = SystemPlacedRegion.Sc_ClassCode", StrWhere: "Dsfm_IsEnabled = '1'" + strWhere, ShowColumnName: "Dsfm_DressNumber AS 礼服编号,SystemDressType.Sc_ClassName AS 礼服类别,Dsfm_DressName AS 礼服名称,Dsfm_DressBrand AS 礼服品牌,Dsfm_DressSize AS 礼服尺寸,SystemPlacedRegion.Sc_ClassName AS 摆放区域,Dsfm_DressRemark AS 礼服说明,Dsfm_PicturePath").Tables[0];
  141. for (int i = 0; i < tbl.Rows.Count; i++)
  142. {
  143. DataGridViewRow dgvr = new DataGridViewRow();
  144. DataGridViewCell cell = null;
  145. cell = new DataGridViewTextBoxCell();
  146. cell.Value = tbl.Rows[i]["礼服编号"].ToString().Trim();
  147. dgvr.Cells.Add(cell);
  148. cell = new DataGridViewTextBoxCell();
  149. cell.Value = tbl.Rows[i]["礼服类别"].ToString().Trim();
  150. dgvr.Cells.Add(cell);
  151. cell = new DataGridViewTextBoxCell();
  152. cell.Value = tbl.Rows[i]["礼服名称"].ToString().Trim();
  153. dgvr.Cells.Add(cell);
  154. cell = new DataGridViewTextBoxCell();
  155. cell.Value = tbl.Rows[i]["礼服品牌"].ToString().Trim();
  156. dgvr.Cells.Add(cell);
  157. cell = new DataGridViewTextBoxCell();
  158. cell.Value = tbl.Rows[i]["礼服尺寸"].ToString().Trim();
  159. dgvr.Cells.Add(cell);
  160. cell = new DataGridViewTextBoxCell();
  161. cell.Value = tbl.Rows[i]["摆放区域"].ToString().Trim();
  162. dgvr.Cells.Add(cell);
  163. cell = new DataGridViewTextBoxCell();
  164. cell.Value = tbl.Rows[i]["礼服说明"].ToString().Trim();
  165. dgvr.Cells.Add(cell);
  166. this.dgvData.Rows.Add(dgvr);
  167. }
  168. this.dgvData.Columns["礼服编号"].Frozen = true;
  169. }
  170. /// <summary>
  171. ///
  172. /// </summary>
  173. private void PublicFunctionRows2()
  174. {
  175. if (!string.IsNullOrEmpty(this.StrValue))
  176. {
  177. string StrWhere = this.StrValue.Replace(",", "','");
  178. StrWhere = " Dsfm_DressNumber in ('" + StrWhere + "') ";
  179. DataTable tbl = orbll.GetView_Custom("tb_ErpDressFrom", StrWhere: StrWhere, ShowColumnName: "Dsfm_DressNumber AS 礼服编号,Dsfm_DressName AS 礼服名称").Tables[0];
  180. tbl.PrimaryKey = new DataColumn[] { tbl.Columns["礼服编号"] };
  181. string[] strArray = StrValue.Trim().Split(',');
  182. for (int i = 0; i < strArray.Length; i++)
  183. {
  184. DataRow dtRow = tbl.Rows.Find(strArray[i].Trim());
  185. if (dtRow != null)
  186. {
  187. DataGridViewRow dgvr = new DataGridViewRow();
  188. DataGridViewCell cell = null;
  189. cell = new DataGridViewTextBoxCell();
  190. cell.Value = dtRow["礼服编号"].ToString().Trim();
  191. dgvr.Cells.Add(cell);
  192. cell = new DataGridViewTextBoxCell();
  193. cell.Value = dtRow["礼服名称"].ToString().Trim();
  194. dgvr.Cells.Add(cell);
  195. this.dgvData2.Rows.Add(dgvr);
  196. }
  197. }
  198. }
  199. }
  200. }
  201. }