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

200 lines
9.3 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. using ICSSoft.Frame.Data.DAL;
  27. namespace ICSSoft.Frame.APP
  28. {
  29. public partial class FormPhysicalAdd : DevExpress.XtraEditors.XtraForm
  30. {
  31. DataRow rows;
  32. #region 构造函数
  33. public FormPhysicalAdd()
  34. {
  35. InitializeComponent();
  36. }
  37. #endregion
  38. #region 关闭 退出
  39. private void btnClose_Click(object sender, EventArgs e)
  40. {
  41. this.DialogResult = DialogResult.Cancel;
  42. }
  43. private void can_Click(object sender, EventArgs e)
  44. {
  45. this.DialogResult = DialogResult.Cancel;
  46. }
  47. #endregion
  48. #region 移动窗体
  49. private const int WM_NCHITTEST = 0x84;
  50. private const int HTCLIENT = 0x1;
  51. private const int HTCAPTION = 0x2;
  52. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  53. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  54. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  55. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  56. //重写窗体,使窗体可以不通过自带标题栏实现移动
  57. protected override void WndProc(ref Message m)
  58. {
  59. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  60. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  61. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  62. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  63. switch (m.Msg)
  64. {
  65. case WM_NCHITTEST:
  66. base.WndProc(ref m);
  67. if ((int)m.Result == HTCLIENT)
  68. m.Result = (IntPtr)HTCAPTION;
  69. return;
  70. }
  71. //拦截双击标题栏、移动窗体的系统消息
  72. if (m.Msg != 0xA3)
  73. {
  74. base.WndProc(ref m);
  75. }
  76. }
  77. #endregion
  78. private void save_Click(object sender, EventArgs e)
  79. {
  80. if (txtBatchCode.Text.Trim() == "")
  81. {
  82. ICSBaseSimpleCode.AppshowMessageBox("批次不可为空!");
  83. return;
  84. }
  85. if (txtBatchQty.Text.Trim() == "")
  86. {
  87. ICSBaseSimpleCode.AppshowMessageBox("本次批次数量不可为空!");
  88. return;
  89. }
  90. ICSSoft.Frame.Data.DAL.ICSMODAL.MoContext context = new ICSSoft.Frame.Data.DAL.ICSMODAL.MoContext();
  91. context.cInvCode = txtItemCode.Text.Trim();
  92. context.cInvName = txtItemName.Text.Trim();
  93. context.cInvStd = txtItemStd.Text.Trim();
  94. context.AuxQty = txtBatchQty.Text.Trim();
  95. context.ChangeRate = txtChange.Text.Trim();
  96. context.AuxUnitCode = txtChange.Tag.ToString();
  97. context.Free1 = txtFree1.Text.Trim();
  98. context.free2 = txtFree2.Text.Trim();
  99. context.Free3 = txtFree3.Text.Trim();
  100. context.Free4 = txtFree4.Text.Trim();
  101. context.Qty = (decimal.Parse(txtBatchQty.Text.Trim()) * decimal.Parse(txtChange.Text.Trim())).ToString();
  102. context.cComUnitName1 = "";
  103. context.MoCode = "";
  104. context.MoDId = "";
  105. context.MDeptCode = "";
  106. context.cComUnitName2 = txtUnits.Text.Trim();
  107. context.BatchCode = txtBatchCode.Text.Trim();
  108. context.Whcode = txtItemCode.Tag.ToString();
  109. ICSMODAL.BeginningSave(context);
  110. ICSBaseSimpleCode.AppshowMessageBox("修改成功!!");
  111. this.Close();
  112. }
  113. private void FormPurchasingAdd_Load(object sender, EventArgs e)
  114. {
  115. // string sql = @"SELECT ItemCode,ItemName,ItemStd,ComUnit,AssComUnit,AuxQty,BatchCode
  116. // FROM dbo.ICSMO WHERE Serial = '" + MOSerial + "'";
  117. // DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  118. // if (dt == null || dt.Rows.Count == 0)
  119. // {
  120. // return;
  121. // }
  122. // txtItemCode.Text = dt.Rows[0]["ItemCode"].ToString();
  123. // txtItemName.Text = dt.Rows[0]["ItemName"].ToString();
  124. // txtItemsStd.Text = dt.Rows[0]["ItemStd"].ToString();
  125. // txtUNIT.Text = dt.Rows[0]["ComUnit"].ToString();
  126. // txtUnits.Text = dt.Rows[0]["AssComUnit"].ToString();
  127. // txtFqty.Text = dt.Rows[0]["AuxQty"].ToString();
  128. // txtBatchCode.Text = dt.Rows[0]["BatchCode"].ToString();
  129. // if (txtItemCode.Text.Trim().Substring(0, 2) == "05")
  130. // {
  131. // txtBatchCode.Properties.ReadOnly = false;
  132. // }
  133. }
  134. private void txtItemName_Properties_Leave(object sender, EventArgs e)
  135. {
  136. if (txtItemName.Text.Trim() == "") return;
  137. #region 产品别
  138. string sql = @"SELECT a.cWhCode as 仓库,a.cInvCode AS 存货编码,b.cInvName AS 存货名称,
  139. b.cInvStd AS ,convert(decimal(18,2),a.iQuantity/ISNULL(c.iChangRate,1)) AS ERP数量,a.cFree1 AS ,
  140. a.cFree2 AS ,a.cFree3 AS ,a.cFree4 AS ,
  141. c.cComUnitName AS ,c.iChangRate AS ,a.autoid as ID
  142. FROM {0}.dbo.CurrentStock a
  143. INNER JOIN {0}.dbo.Inventory b ON a.cInvCode = b.cInvCode
  144. LEFT JOIN {0}.dbo.ComputationUnit c ON b.cSTComUnitCode = c.cComunitCode
  145. WHERE b.cInvName = '{1}' and a.iQuantity>0";
  146. sql = string.Format(sql,ICSBaseSimpleCode.GetWorkPointErpData(),txtItemName.Text.Trim());
  147. DataTable classDt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  148. txtItemStd.Properties.ValueMember = "现存量ID";
  149. txtItemStd.Properties.DisplayMember = "规格型号";
  150. txtItemStd.Properties.DataSource = classDt;
  151. txtItemStd.Properties.NullText = "";//空时的值
  152. txtItemStd.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
  153. txtItemStd.Properties.ValidateOnEnterKey = true;//回车确认
  154. txtItemStd.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
  155. txtItemStd.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
  156. //自适应宽度
  157. txtItemStd.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
  158. #endregion
  159. }
  160. private void txtItemStd_EditValueChanged(object sender, EventArgs e)
  161. {
  162. if (txtItemStd.Text.Trim() != "")
  163. {
  164. string sql = @"SELECT a.cWhCode as 仓库,a.cInvCode AS 存货编码,
  165. CONVERT(decimal(18,2),a.iQuantity/ISNULL(c.iChangRate,1)) AS ERP数量,a.cFree1 AS ,
  166. a.cFree2 AS ,a.cFree3 AS ,a.cFree4 AS ,c.cComunitCode,
  167. c.cComUnitName AS ,c.iChangRate AS
  168. FROM {0}.dbo.CurrentStock a
  169. INNER JOIN {0}.dbo.Inventory b ON a.cInvCode = b.cInvCode
  170. LEFT JOIN {0}.dbo.ComputationUnit c ON b.cSTComUnitCode = c.cComunitCode
  171. WHERE a.AutoID = '{1}'";
  172. sql = string.Format(sql,ICSBaseSimpleCode.GetWorkPointErpData(),txtItemStd.EditValue.ToString());
  173. DataTable Dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  174. txtItemCode.Text = Dt.Rows[0]["存货编码"].ToString();
  175. txtItemCode.Tag = Dt.Rows[0]["仓库"].ToString();
  176. txtFree1.Text = Dt.Rows[0]["上膜"].ToString();
  177. txtFree2.Text = Dt.Rows[0]["下膜"].ToString();
  178. txtFree3.Text = Dt.Rows[0]["定制"].ToString();
  179. txtFree4.Text = Dt.Rows[0]["不良原因"].ToString();
  180. txtERPqty.Text = Dt.Rows[0]["ERP数量"].ToString();
  181. txtUnits.Text = Dt.Rows[0]["辅计量单位"].ToString();
  182. txtChange.Text = Dt.Rows[0]["转换率"].ToString();
  183. txtChange.Tag = Dt.Rows[0]["cComunitCode"].ToString();
  184. }
  185. }
  186. }
  187. }