锐腾搅拌上料功能
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

217 lines
7.2 KiB

5 months ago
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using DevExpress.XtraEditors;
  9. using ICSSoft.Base.Language.Tool;
  10. using ICSSoft.Base.UserControl.MessageControl;
  11. using ICSSoft.Base.Config.AppConfig;
  12. using ICSSoft.Base.Config.DBHelper;
  13. using ICSSoft.Base.Report.Filter;
  14. using ICSSoft.Base.UserControl.FormControl;
  15. using ICSSoft.Base.ReferForm.AppReferForm;
  16. namespace ICSSoft.Frame.APP
  17. {
  18. public partial class FormStockBarCodeSelect : DevExpress.XtraEditors.XtraForm
  19. {
  20. public List<Dictionary<string, object>> Rows = new List<Dictionary<string, object>>();
  21. public FormStockBarCodeSelect()
  22. {
  23. InitializeComponent();
  24. }
  25. public static string searchSQl()
  26. {
  27. string sql = @" SELECT CAST ('' AS NVARCHAR(50)) AS 选择,a.cCode+CAST(a.Free1 AS NVARCHAR(50)) AS Code,
  28. d.cVenName,e.cDepName,a.cWhCode,a.cInvCode,f.INVNAME,f.INVSTD,f.INVUOM,c.cCode,a.ERPAutoid,
  29. a.iQuantity,a.PackQty,0 as 'BarCodeCount',0 as 'BarCodeqty','' as BatchCode,Free1 as row,a.cCode as poCode
  30. FROM [dbo].[ICSPOArrive] a
  31. left join {0}.dbo.PU_ArrivalVouchs b on a.ERPAutoid = b.Autoid
  32. left join {0}.dbo.PU_ArrivalVouch c on b.ID = c.ID
  33. LEFT JOIN {0}.dbo.Vendor d ON a.cVenCode = d.cVenCode
  34. LEFT JOIN {0}.dbo.Department e ON a.cDepCode = e.cDepCode
  35. LEFT JOIN dbo.ICSINVENTORY f ON a.cInvCode = f.INVCODE
  36. WHERE a.iQuantity > PackQty ";
  37. sql = string.Format(sql, ICSBaseSimpleCode.GetWorkPointErpData());
  38. return sql;
  39. }
  40. #region 移动窗体
  41. private const int WM_NCHITTEST = 0x84;
  42. private const int HTCLIENT = 0x1;
  43. private const int HTCAPTION = 0x2;
  44. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  45. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  46. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  47. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  48. //重写窗体,使窗体可以不通过自带标题栏实现移动
  49. protected override void WndProc(ref Message m)
  50. {
  51. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  52. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  53. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  54. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  55. switch (m.Msg)
  56. {
  57. case WM_NCHITTEST:
  58. base.WndProc(ref m);
  59. if ((int)m.Result == HTCLIENT)
  60. m.Result = (IntPtr)HTCAPTION;
  61. return;
  62. }
  63. //拦截双击标题栏、移动窗体的系统消息
  64. if (m.Msg != 0xA3)
  65. {
  66. base.WndProc(ref m);
  67. }
  68. }
  69. #endregion
  70. private void btnClose_Click(object sender, EventArgs e)
  71. {
  72. this.DialogResult = DialogResult.Cancel;
  73. }
  74. private void grvDetail_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
  75. {
  76. if (e.Info.IsRowIndicator && e.RowHandle >= 0)
  77. e.Info.DisplayText = (e.RowHandle + 1).ToString();
  78. }
  79. private void btnDel_Click(object sender, EventArgs e)
  80. {
  81. grvDetail.PostEditor();
  82. this.Validate();
  83. if (grvDetail.FocusedRowHandle < 0)
  84. {
  85. return;
  86. }
  87. grvDetail.DeleteRow(grvDetail.FocusedRowHandle);
  88. }
  89. private void grvDetail_DoubleClick(object sender, EventArgs e)
  90. {
  91. if(grvDetail.RowCount==0)
  92. {
  93. return;
  94. }
  95. if (grvDetail.FocusedRowHandle < 0)
  96. {
  97. return;
  98. }
  99. if (grvDetail.FocusedColumn == colisSelect)
  100. {
  101. for (int i = 0; i < grvDetail.RowCount; i++)
  102. {
  103. grvDetail.SetRowCellValue(i, colisSelect, "");
  104. }
  105. grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colisSelect, "Y");
  106. }
  107. }
  108. private void btnSearch_Click(object sender, EventArgs e)
  109. {
  110. string sql = searchSQl();
  111. if (txtInvfrom.Text.Trim() != "")
  112. {
  113. sql += " and a.cInvCode >= '" + txtInvfrom.Text.Trim() + "' ";
  114. }
  115. if (txtInvto.Text.Trim() != "")
  116. {
  117. sql += " and a.cInvCode <= '" + txtInvto.Text.Trim() + "' ";
  118. }
  119. if (txtInvName.Text != "")
  120. {
  121. sql += " and f.INVNAME like '%" + txtInvName.Text.Trim() + "%'";
  122. }
  123. if (txtBatch.Text.Trim() != "")
  124. {
  125. sql += " and a.Free2 like '%" + txtBatch.Text.Trim() + "%' ";
  126. }
  127. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  128. grdDetail.DataSource = data;
  129. grvDetail.BestFitColumns();
  130. }
  131. private void btnSelectAll_Click(object sender, EventArgs e)
  132. {
  133. for (int i = 0; i < grvDetail.RowCount; i++)
  134. {
  135. grvDetail.SetRowCellValue(i, colisSelect, "Y");
  136. }
  137. }
  138. private void btnCancelSelect_Click(object sender, EventArgs e)
  139. {
  140. for (int i = 0; i < grvDetail.RowCount; i++)
  141. {
  142. grvDetail.SetRowCellValue(i, colisSelect, "");
  143. }
  144. }
  145. private void btnOk_Click(object sender, EventArgs e)
  146. {
  147. for (int i = 0; i < grvDetail.RowCount;i++ )
  148. {
  149. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  150. {
  151. string ID = grvDetail.GetRowCellValue(i, ERPAutoid).ToString();
  152. string cCode = grvDetail.GetRowCellValue(i, poCode).ToString();
  153. FormStockBarCodeCreates creates = new FormStockBarCodeCreates(ID, cCode);
  154. creates.ShowDialog();
  155. btnSearch_Click(null, null);
  156. //if (creates.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  157. //{
  158. // this.DialogResult = DialogResult.OK;
  159. //}
  160. //else
  161. //{
  162. // this.DialogResult = DialogResult.Cancel;
  163. //}
  164. }
  165. }
  166. }
  167. private void btncancle_Click(object sender, EventArgs e)
  168. {
  169. this.DialogResult = DialogResult.Cancel;
  170. this.Close();
  171. }
  172. private void FormCartonProtectSelect_Load(object sender, EventArgs e)
  173. {
  174. LanguageConvert.ChangeLanguage(this, "1");
  175. }
  176. }
  177. }