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

207 lines
9.7 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 FormMOBeginningAdd : DevExpress.XtraEditors.XtraForm
  30. {
  31. DataRow rows;
  32. #region 构造函数
  33. public FormMOBeginningAdd()
  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() == "" ? "0" : txtChange.Text.Trim())).ToString();
  102. context.cComUnitName1 = txtUnits.Tag.ToString();
  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. try {
  110. ICSMODAL.BeginningSave(context);
  111. ICSBaseSimpleCode.AppshowMessageBox("修改成功!!");
  112. this.Close();
  113. }catch(Exception ex){
  114. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  115. }
  116. }
  117. private void FormPurchasingAdd_Load(object sender, EventArgs e)
  118. {
  119. // string sql = @"SELECT ItemCode,ItemName,ItemStd,ComUnit,AssComUnit,AuxQty,BatchCode
  120. // FROM dbo.ICSMO WHERE Serial = '" + MOSerial + "'";
  121. // DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  122. // if (dt == null || dt.Rows.Count == 0)
  123. // {
  124. // return;
  125. // }
  126. // txtItemCode.Text = dt.Rows[0]["ItemCode"].ToString();
  127. // txtItemName.Text = dt.Rows[0]["ItemName"].ToString();
  128. // txtItemsStd.Text = dt.Rows[0]["ItemStd"].ToString();
  129. // txtUNIT.Text = dt.Rows[0]["ComUnit"].ToString();
  130. // txtUnits.Text = dt.Rows[0]["AssComUnit"].ToString();
  131. // txtFqty.Text = dt.Rows[0]["AuxQty"].ToString();
  132. // txtBatchCode.Text = dt.Rows[0]["BatchCode"].ToString();
  133. // if (txtItemCode.Text.Trim().Substring(0, 2) == "05")
  134. // {
  135. // txtBatchCode.Properties.ReadOnly = false;
  136. // }
  137. }
  138. private void txtItemName_Properties_Leave(object sender, EventArgs e)
  139. {
  140. if (txtItemName.Text.Trim() == "") return;
  141. #region 产品别
  142. string sql = @"SELECT a.cWhCode as 仓库,a.cInvCode AS 存货编码,b.cInvName AS 存货名称,
  143. b.cInvStd AS ,convert(decimal(18,2),a.iQuantity/ISNULL(c.iChangRate,1)) AS ERP数量,a.cFree1 AS ,
  144. a.cFree2 AS ,a.cFree3 AS ,a.cFree4 AS ,
  145. c.cComUnitName AS ,c.iChangRate AS ,a.autoid as ID
  146. FROM {0}.dbo.CurrentStock a
  147. INNER JOIN {0}.dbo.Inventory b ON a.cInvCode = b.cInvCode
  148. LEFT JOIN {0}.dbo.ComputationUnit c ON b.cSTComUnitCode = c.cComunitCode
  149. WHERE b.cInvName = '{1}' and a.iQuantity>0";
  150. sql = string.Format(sql,ICSBaseSimpleCode.GetWorkPointErpData(),txtItemName.Text.Trim());
  151. DataTable classDt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  152. txtItemStd.Properties.ValueMember = "现存量ID";
  153. txtItemStd.Properties.DisplayMember = "规格型号";
  154. txtItemStd.Properties.DataSource = classDt;
  155. txtItemStd.Properties.NullText = "";//空时的值
  156. txtItemStd.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
  157. txtItemStd.Properties.ValidateOnEnterKey = true;//回车确认
  158. txtItemStd.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
  159. txtItemStd.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
  160. //自适应宽度
  161. txtItemStd.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
  162. #endregion
  163. }
  164. private void txtItemStd_EditValueChanged(object sender, EventArgs e)
  165. {
  166. if (txtItemStd.Text.Trim() != "")
  167. {
  168. string sql = @"SELECT a.cWhCode as 仓库,a.cInvCode AS 存货编码,
  169. CONVERT(decimal(18,2),a.iQuantity/ISNULL(c.iChangRate,1)) AS ERP数量,a.cFree1 AS ,
  170. a.cFree2 AS ,a.cFree3 AS ,a.cFree4 AS ,c.cComunitCode,d.cComUnitName as ,
  171. c.cComUnitName AS ,c.iChangRate AS
  172. FROM {0}.dbo.CurrentStock a
  173. INNER JOIN {0}.dbo.Inventory b ON a.cInvCode = b.cInvCode
  174. LEFT JOIN {0}.dbo.ComputationUnit c ON b.cSTComUnitCode = c.cComunitCode
  175. LEFT JOIN {0}.dbo.ComputationUnit d ON b.cComUnitCode = d.cComunitCode
  176. WHERE a.AutoID = '{1}'";
  177. sql = string.Format(sql,ICSBaseSimpleCode.GetWorkPointErpData(),txtItemStd.EditValue.ToString());
  178. DataTable Dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  179. txtItemCode.Text = Dt.Rows[0]["存货编码"].ToString();
  180. txtItemCode.Tag = Dt.Rows[0]["仓库"].ToString();
  181. txtFree1.Text = Dt.Rows[0]["上膜"].ToString();
  182. txtFree2.Text = Dt.Rows[0]["下膜"].ToString();
  183. txtFree3.Text = Dt.Rows[0]["定制"].ToString();
  184. txtFree4.Text = Dt.Rows[0]["不良原因"].ToString();
  185. txtERPqty.Text = Dt.Rows[0]["ERP数量"].ToString();
  186. txtUnits.Text = Dt.Rows[0]["辅计量单位"].ToString();
  187. txtUnits.Tag = Dt.Rows[0]["主计量单位"].ToString();
  188. txtChange.Text = Dt.Rows[0]["转换率"].ToString();
  189. txtChange.Tag = Dt.Rows[0]["cComunitCode"].ToString();
  190. }
  191. }
  192. }
  193. }