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

314 lines
10 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.Config.AppConfig;
  10. using System.Data.Linq;
  11. using System.Linq;
  12. using ICSSoft.Base.Language.Tool;
  13. using System.Reflection;
  14. using ICSSoft.Base.Config.DBHelper;
  15. using ICSSoft.Base.ReferForm;
  16. using ICSSoft.Base.Report;
  17. using ICSSoft.Base.ReferForm.AppReferForm;
  18. using ICSSoft.Frame.Data.Entity;
  19. using ICSSoft.Frame.Data.BLL;
  20. namespace ICSSoft.Frame.APP
  21. {
  22. public partial class FormICSINVReceiptDetailAdd : DevExpress.XtraEditors.XtraForm
  23. {
  24. String guid = "";
  25. string Rid;
  26. string Rno;
  27. int flag;
  28. FormICSINVReceiptDetailUIModel model;
  29. #region 构造函数
  30. public FormICSINVReceiptDetailAdd()
  31. {
  32. InitializeComponent();
  33. }
  34. public FormICSINVReceiptDetailAdd(string Receiptid, string ReceiptNO)
  35. {
  36. InitializeComponent();
  37. Rid = Receiptid;
  38. Rno = ReceiptNO;
  39. flag = 0;
  40. chargeFormState("Add");
  41. }
  42. public FormICSINVReceiptDetailAdd(string dID, string RECSTATUS, string test)
  43. {
  44. InitializeComponent();
  45. guid = dID;
  46. flag = 1;
  47. chargeFormState("Edit");
  48. SearchInfo(dID);
  49. }
  50. #endregion
  51. private void SearchInfo(string dID)
  52. {
  53. model = ICSINVReceiptDetailBLL.SearchInfoByID(dID, AppConfig.AppConnectString);
  54. txtReceiptLine.Text = Convert.ToString(model.ReceiptLine);
  55. txtORDERNO.Text = model.ORDERNO;
  56. txtORDERLINE.Text = Convert.ToString(model.ORDERLINE);
  57. txtMEMO.Text = model.MEMO;
  58. txtITEMCODE.Tag = model.inv as FormICSINVENTORYUIModel;
  59. txtITEMCODE.Text = model.inv.INVNAME;
  60. txtPLANQTY.Text=Convert.ToString(model.PLANQTY);
  61. //txtVenderLotNO.Text = model.VenderLotNO;
  62. }
  63. private void chargeFormState(string state)
  64. {
  65. switch (state)
  66. {
  67. case "Add":
  68. txtReceiptLine.Properties.ReadOnly = false;
  69. break;
  70. case "Edit":
  71. txtReceiptLine.Properties.ReadOnly = true;
  72. break;
  73. }
  74. }
  75. #region 关闭 退出
  76. private void btnClose_Click(object sender, EventArgs e)
  77. {
  78. this.Close();
  79. }
  80. #endregion
  81. #region 移动窗体
  82. private const int WM_NCHITTEST = 0x84;
  83. private const int HTCLIENT = 0x1;
  84. private const int HTCAPTION = 0x2;
  85. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  86. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  87. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  88. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  89. //重写窗体,使窗体可以不通过自带标题栏实现移动
  90. protected override void WndProc(ref Message m)
  91. {
  92. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  93. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  94. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  95. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  96. switch (m.Msg)
  97. {
  98. case WM_NCHITTEST:
  99. base.WndProc(ref m);
  100. if ((int)m.Result == HTCLIENT)
  101. m.Result = (IntPtr)HTCAPTION;
  102. return;
  103. }
  104. //拦截双击标题栏、移动窗体的系统消息
  105. if (m.Msg != 0xA3)
  106. {
  107. base.WndProc(ref m);
  108. }
  109. }
  110. #endregion
  111. #region 新增 修改
  112. private void save_Click(object sender, EventArgs e)
  113. {
  114. try
  115. {
  116. #region 判断是否为空
  117. if (txtReceiptLine.Text.Trim() == "")
  118. {
  119. ICSBaseSimpleCode.AppshowMessageBox("入库单行号不能为空");
  120. return;
  121. }
  122. if (txtITEMCODE.Text.Trim() == "")
  123. {
  124. ICSBaseSimpleCode.AppshowMessageBox("物料不能为空");
  125. return;
  126. }
  127. if (txtPLANQTY.Text.Trim() == "")
  128. {
  129. ICSBaseSimpleCode.AppshowMessageBox("计划数量不能为空");
  130. return;
  131. }
  132. #endregion
  133. if (flag == 0)
  134. {
  135. bool b = ICSINVReceiptDetailBLL.IsIncluding(Rid, Convert.ToInt32(txtReceiptLine.Text), AppConfig.WorkPointCode,AppConfig.AppConnectString);
  136. if (!b)
  137. {
  138. ICSBaseSimpleCode.AppshowMessageBox("到货单行号已经存在");
  139. return;
  140. }
  141. }
  142. FormICSINVReceiptDetailUIModel detailInfo = new FormICSINVReceiptDetailUIModel();
  143. detailInfo.ID = guid;
  144. detailInfo.ReceiptID = Rid;
  145. detailInfo.ReceiptNO = Rno;
  146. detailInfo.ReceiptLine = Convert.ToInt32(txtReceiptLine.Text);
  147. detailInfo.ORDERNO = txtORDERNO.Text;
  148. detailInfo.ORDERLINE = Convert.ToInt32(txtORDERLINE.Text.Equals("") ? "0" : txtORDERLINE.Text);
  149. detailInfo.MEMO = txtMEMO.Text;
  150. detailInfo.inv = new FormICSINVENTORYUIModel();
  151. detailInfo.inv = txtITEMCODE.Tag as FormICSINVENTORYUIModel;
  152. detailInfo.PLANQTY = Convert.ToDecimal(txtPLANQTY.Text);
  153. detailInfo.VenderLotNO = "";
  154. ICSINVReceiptDetailBLL.Add(detailInfo,AppConfig.AppConnectString);
  155. if (flag == 0)
  156. {
  157. ICSBaseSimpleCode.AppshowMessageBox("增加成功");
  158. }
  159. else
  160. {
  161. ICSBaseSimpleCode.AppshowMessageBox("修改成功");
  162. }
  163. }
  164. catch (Exception ex)
  165. {
  166. MessageBox.Show(ex.Message);
  167. }
  168. this.Close();
  169. this.DialogResult = DialogResult.Yes;
  170. }
  171. #endregion
  172. #region 取消
  173. private void can_Click(object sender, EventArgs e)
  174. {
  175. this.Close();
  176. }
  177. #endregion
  178. private void FormICSINVReceiptDetailAdd_Load(object sender, EventArgs e)
  179. {
  180. }
  181. private void txtITEMCODE_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  182. {
  183. DataTable dt = ICSINVReceiptDetailBLL.SearchItemInfoList(AppConfig.AppConnectString);
  184. FormDataRefer reForm = new FormDataRefer();
  185. reForm.FormTitle = "产品";
  186. reForm.DataSource = dt;
  187. reForm.MSelectFlag = false;
  188. reForm.RowIndexWidth = 35;
  189. reForm.HideCols.Add("guid");
  190. reForm.FormWidth = 500;
  191. reForm.FormHeight = 500;
  192. if (reForm.ShowDialog() == DialogResult.OK)
  193. {
  194. DataTable retData = reForm.ReturnData;
  195. foreach (DataRow dr in retData.Rows)
  196. {
  197. FormICSINVENTORYUIModel Item = new FormICSINVENTORYUIModel();
  198. Item.ID = dr["guid"].ToString();
  199. Item.INVCODE = dr["存货编码"].ToString();
  200. Item.INVNAME = dr["存货名称"].ToString();
  201. Item.INVDESC = dr["规格型号"].ToString();
  202. txtITEMCODE.Text = Item.INVCODE;
  203. txtITEMCODE.Tag = Item;
  204. break;
  205. }
  206. }
  207. }
  208. //private void txtMOCODE_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  209. //{
  210. // DataTable dt = ICSINVReceiptDetailBLL.SearchMOInfoList(AppConfig.AppConnectString);
  211. // FormDataRefer reForm = new FormDataRefer();
  212. // reForm.FormTitle = "工单";
  213. // reForm.DataSource = dt;
  214. // reForm.MSelectFlag = false;
  215. // reForm.RowIndexWidth = 35;
  216. // reForm.HideCols.Add("guid");
  217. // reForm.FormWidth = 500;
  218. // reForm.FormHeight = 500;
  219. // if (reForm.ShowDialog() == DialogResult.OK)
  220. // {
  221. // DataTable retData = reForm.ReturnData;
  222. // foreach (DataRow dr in retData.Rows)
  223. // {
  224. // FormICSMOUIModel mo = new FormICSMOUIModel();
  225. // mo.ID = dr["guid"].ToString();
  226. // mo.MOCODE = dr["生产订单号"].ToString();
  227. // mo.MODESC = dr["工单描述"].ToString();
  228. // txtMOCODE.Text = mo.MODESC;
  229. // txtMOCODE.Tag = mo;
  230. // break;
  231. // }
  232. // }
  233. //}
  234. private void txtITEMCODE_KeyDown(object sender, KeyEventArgs e)
  235. {
  236. this.txtITEMCODE.Text = "";
  237. this.txtITEMCODE.Tag = null;
  238. }
  239. private void txtITEMCODE_KeyPress(object sender, KeyPressEventArgs e)
  240. {
  241. if (e.KeyChar != (char)Keys.Back)
  242. {
  243. e.Handled = true;
  244. }
  245. }
  246. private void panelControl1_Paint(object sender, PaintEventArgs e)
  247. {
  248. }
  249. ////private void txtMOCODE_KeyDown(object sender, KeyEventArgs e)
  250. //{
  251. // this.txtMOCODE.Text = "";
  252. // this.txtMOCODE.Tag = null;
  253. //}
  254. //private void txtMOCODE_KeyPress(object sender, KeyPressEventArgs e)
  255. //{
  256. // if (e.KeyChar != (char)Keys.Back)
  257. // {
  258. // e.Handled = true;
  259. // }
  260. //}
  261. }
  262. }