锐腾搅拌上料功能
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.

296 lines
11 KiB

5 months ago
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Data.Linq;
  6. using System.Linq;
  7. using System.Drawing;
  8. using System.Text;
  9. using System.Windows.Forms;
  10. using DevExpress.XtraEditors;
  11. using DevExpress.XtraGrid.Views.BandedGrid;
  12. using DevExpress.XtraGrid.Columns;
  13. using DevExpress.XtraGrid;
  14. using System.IO;
  15. using System.Threading;
  16. using ICSSoft.Base.Language.Tool;
  17. using ICSSoft.Base.Config.AppConfig;
  18. using ICSSoft.Base.UserControl.MessageControl;
  19. using ICSSoft.Base.Config.DBHelper;
  20. using ICSSoft.Base.Report.Filter;
  21. using ICSSoft.Base.UserControl.FormControl;
  22. using ICSSoft.Base.Report.GridReport;
  23. using ICSSoft.Base.ReferForm.AppReferForm;
  24. using ICSSoft.Frame.Data.BLL;
  25. using ICSSoft.Frame.Data.Entity;
  26. namespace ICSSoft.Frame.APP
  27. {
  28. public partial class FormPhysicalInventoryCheck : DevExpress.XtraEditors.XtraForm
  29. {
  30. private decimal lotqty = 0;
  31. #region 构造函数
  32. public FormPhysicalInventoryCheck()
  33. {
  34. InitializeComponent();
  35. }
  36. #endregion
  37. #region 关闭 退出
  38. private void btnClose_Click(object sender, EventArgs e)
  39. {
  40. this.Close();
  41. }
  42. #endregion
  43. #region 移动窗体
  44. private const int WM_NCHITTEST = 0x84;
  45. private const int HTCLIENT = 0x1;
  46. private const int HTCAPTION = 0x2;
  47. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  48. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  49. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  50. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  51. //重写窗体,使窗体可以不通过自带标题栏实现移动
  52. protected override void WndProc(ref Message m)
  53. {
  54. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  55. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  56. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  57. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  58. switch (m.Msg)
  59. {
  60. case WM_NCHITTEST:
  61. base.WndProc(ref m);
  62. if ((int)m.Result == HTCLIENT)
  63. m.Result = (IntPtr)HTCAPTION;
  64. return;
  65. }
  66. //拦截双击标题栏、移动窗体的系统消息
  67. if (m.Msg != 0xA3)
  68. {
  69. base.WndProc(ref m);
  70. }
  71. }
  72. #endregion
  73. private void FormStackOut_Shown(object sender, EventArgs e)
  74. {
  75. this.txtCheckNo.Focus();
  76. }
  77. private void FormStackOut_KeyPress(object sender, KeyPressEventArgs e)
  78. {
  79. if (e.KeyChar != 13)
  80. {
  81. return;
  82. }
  83. try
  84. {
  85. string code = txtBarCode.Text.Trim();
  86. if (code != "")
  87. {
  88. DataTable check = FormPhysicalInventoryBLL.CheckNo(code, AppConfig.AppConnectString);
  89. if (check == null || check.Rows.Count == 0)
  90. {
  91. ICSBaseSimpleCode.AppshowMessageBox("库存信息中不存在该批次!!");
  92. txtBarCode.Focus();
  93. txtBarCode.Text = "";
  94. return;
  95. }
  96. else
  97. {
  98. string CheckNo = txtCheckNo.Text.Trim();
  99. string whcode = CheckNo.Substring(CheckNo.Length - 2);
  100. if (check.Rows[0]["WHCode"].ToString() != whcode)
  101. {
  102. ICSBaseSimpleCode.AppshowMessageBox("条码所在仓库必须与盘点单所属仓库相同!!");
  103. txtBarCode.Focus();
  104. txtBarCode.SelectAll();
  105. return;
  106. }
  107. }
  108. string sql = @"SELECT Serial,ISNULL(BarCodeActualQty,0) AS BarCodeActualQty FROM dbo.ICSToChecks WHERE BarCode ='" + txtBarCode.Text.Trim() + @"'
  109. and ToCheckNO='" + txtCheckNo.Text.Trim() + "'";
  110. DataTable lotdt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  111. if (lotdt.Rows.Count != 0)
  112. {
  113. txtLotQTY.Text = lotdt.Rows[0]["BarCodeActualQty"].ToString();
  114. txtLotQTY.Properties.ReadOnly = false;
  115. txtLotQTY.Focus();
  116. txtLotQTY.SelectAll();
  117. }
  118. DataTable dt = FormPhysicalInventoryBLL.Check(code, txtCheckNo.Text.Trim(), AppConfig.AppConnectString);
  119. if (dt == null || dt.Rows.Count == 0)
  120. {
  121. ICSBaseSimpleCode.AppshowMessageBox("该条码没有创建盘点计划!!");
  122. txtBarCode.Focus();
  123. txtBarCode.Text = "";
  124. return;
  125. }
  126. sql = @"select LotQty from ICSWareHouseLotInfo
  127. where LotNO = '" + code + "'";
  128. DataTable qtydt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  129. if (qtydt.Rows.Count == 0)
  130. {
  131. ICSBaseSimpleCode.AppshowMessageBox("条码不存在!!");
  132. txtBarCode.Focus();
  133. txtBarCode.Text = "";
  134. return;
  135. }
  136. {
  137. if (lotdt.Rows.Count == 0)
  138. {
  139. lotqty = Convert.ToDecimal(qtydt.Rows[0]["LotQty"].ToString());
  140. txtLotQTY.Text = qtydt.Rows[0]["LotQty"].ToString();
  141. }
  142. else
  143. {
  144. lotqty = Convert.ToDecimal(qtydt.Rows[0]["LotQty"].ToString());
  145. txtLotQTY.Text = lotdt.Rows[0]["BarCodeActualQty"].ToString();
  146. }
  147. }
  148. //FormPhysicalInventoryBLL.CheckIn(code, AppConfig.AppConnectString);
  149. //txtBarCode.Text = "";
  150. //txtBarCode.Focus();
  151. //label1.Visible = true;
  152. Thread t = new Thread(new ParameterizedThreadStart(f));
  153. t.Start();
  154. }
  155. else
  156. {
  157. ICSBaseSimpleCode.AppshowMessageBox("请输入条码!!");
  158. txtBarCode.Focus();
  159. return;
  160. }
  161. }
  162. catch (Exception ex)
  163. {
  164. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  165. txtBarCode.Text = "";
  166. txtBarCode.Focus();
  167. }
  168. }
  169. delegate void df(object o);
  170. public void f(object o)
  171. {
  172. Thread.Sleep(500);
  173. if (InvokeRequired)
  174. {
  175. Invoke(new df(f), o);
  176. }
  177. else
  178. {
  179. label1.Visible = false;
  180. }
  181. }
  182. private void save_Click(object sender, EventArgs e)
  183. {
  184. try
  185. {
  186. string Sql = @"SELECT Serial,BarCodeActualQty FROM dbo.ICSToChecks WHERE BarCode ='" + txtBarCode.Text.Trim() + @"'
  187. and ToCheckNO='" + txtCheckNo.Text.Trim() + "'";
  188. DataTable lotdt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, Sql).Tables[0];
  189. if (lotdt.Rows.Count != 0)
  190. {
  191. if (ICSBaseSimpleCode.AppshowMessageBoxRepose("该条码已经扫描,确定修改条码盘点数量吗?") != DialogResult.OK)
  192. {
  193. txtBarCode.Focus();
  194. txtBarCode.SelectAll();
  195. txtLotQTY.Text = "";
  196. return;
  197. }
  198. FormPhysicalInventoryBLL.CheckIn(txtCheckNo.Text.Trim(), txtBarCode.Text.Trim(), txtLotQTY.Text.Trim(),AppConfig.AppConnectString);
  199. label1.Text = "盘点成功";
  200. label1.Visible = true;
  201. txtBarCode.Text = "";
  202. txtLotQTY.Text = "";
  203. txtBarCode.Focus();
  204. }
  205. else
  206. {
  207. //if (lotqty < Convert.ToDecimal(txtLotQTY.Text.Trim()))
  208. //{
  209. // ICSBaseSimpleCode.AppshowMessageBox("实盘数量不能大于库存数量!!");
  210. // txtLotQTY.Text="";
  211. // txtLotQTY.Focus();
  212. // return;
  213. //}
  214. FormPhysicalInventoryBLL.CheckIn(txtCheckNo.Text.Trim(), txtBarCode.Text.Trim(), txtLotQTY.Text.Trim(), AppConfig.AppConnectString);
  215. label1.Text = "盘点成功";
  216. label1.Visible = true;
  217. txtBarCode.Text = "";
  218. txtLotQTY.Text = "";
  219. txtBarCode.Focus();
  220. }
  221. }
  222. catch (Exception ex)
  223. {
  224. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  225. txtBarCode.Text = "";
  226. txtLotQTY.Text = "";
  227. txtBarCode.Focus();
  228. }
  229. }
  230. private void txtCheckNo_KeyDown(object sender, KeyEventArgs e)
  231. {
  232. }
  233. private void txtCheckNo_KeyPress(object sender, KeyPressEventArgs e)
  234. {
  235. if (e.KeyChar != 13)
  236. {
  237. return;
  238. }
  239. try
  240. {
  241. string code = txtCheckNo.Text.Trim();
  242. if (code != "")
  243. {
  244. string Sql = @"select * from ICSToCheck where ToCheckNO='" + code + "'";
  245. DataTable lotdt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, Sql).Tables[0];
  246. if (lotdt.Rows.Count == 0)
  247. {
  248. ICSBaseSimpleCode.AppshowMessageBox("盘点单号不存在!!");
  249. txtCheckNo.Focus();
  250. txtCheckNo.Text = "";
  251. return;
  252. }
  253. else
  254. {
  255. txtBarCode.Focus();
  256. label1.Text = "盘点单号扫描成功!!";
  257. label1.Visible = true;
  258. }
  259. }
  260. else
  261. {
  262. ICSBaseSimpleCode.AppshowMessageBox("请输入盘点单号!!");
  263. txtCheckNo.Focus();
  264. return;
  265. }
  266. }
  267. catch (Exception ex)
  268. {
  269. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  270. txtBarCode.Text = "";
  271. txtBarCode.Focus();
  272. }
  273. }
  274. }
  275. }