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

425 lines
17 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 FormICSInvTransferDetailAdd : DevExpress.XtraEditors.XtraForm
  23. {
  24. string guid = "";
  25. string invtransferid="";
  26. string invtrasferno="";
  27. string invtransferstatus="";
  28. string invfromstorgecode="";
  29. string invtostoragecode="";
  30. int flag;
  31. FormICSInvTransferDetailUIModel model;
  32. public FormICSInvTransferDetailAdd()
  33. {
  34. InitializeComponent();
  35. }
  36. #region 构造函数
  37. public FormICSInvTransferDetailAdd(string transferid, string trasferno, string transferstatus, string fromstorgecode, string tostoragecode)
  38. {
  39. InitializeComponent();
  40. flag = 0;
  41. invtransferid = transferid;
  42. invtrasferno = trasferno;
  43. invtransferstatus = transferstatus;
  44. invfromstorgecode = fromstorgecode;
  45. invtostoragecode = tostoragecode;
  46. chargeFormState("Add");
  47. }
  48. public FormICSInvTransferDetailAdd(String id)
  49. {
  50. InitializeComponent();
  51. flag = 1;
  52. chargeFormState("Edit");
  53. SearchInfo(id);
  54. }
  55. #endregion
  56. private void chargeFormState(string state)
  57. {
  58. switch (state)
  59. {
  60. case "Add":
  61. txtTransferSTATUS.Text = "新建";
  62. txtTransferNO.Text = invtrasferno;
  63. txtTransferSTATUS.Text = invtransferstatus;
  64. txtFROMStorageCode.Text = invfromstorgecode;
  65. txtTOStorageCode.Text = invtostoragecode;
  66. txtTransferNO.Properties.ReadOnly = true;
  67. txtTransferSTATUS.Properties.ReadOnly = true;
  68. txtFROMStorageCode.Properties.ReadOnly = true;
  69. txtTOStorageCode.Properties.ReadOnly = true;
  70. txtMUSERName.Text = AppConfig.UserName;
  71. txtMTIME.Text = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss").ToString();
  72. txtMUSERName.Properties.ReadOnly = true;
  73. txtMTIME.Properties.ReadOnly = true;
  74. break;
  75. case "Edit":
  76. txtTransferNO.Properties.ReadOnly = true;
  77. txtTransferSTATUS.Properties.ReadOnly = true;
  78. txtFROMStorageCode.Properties.ReadOnly = true;
  79. txtTOStorageCode.Properties.ReadOnly = true;
  80. txtTransferNO.Properties.ReadOnly = true;
  81. txtMUSERName.Properties.ReadOnly = true;
  82. txtMTIME.Properties.ReadOnly = true;
  83. break;
  84. }
  85. }
  86. private void SearchInfo(string id)
  87. {
  88. model = ICSInvTransferDetailBLL.SearchInfoByID(id, AppConfig.AppConnectString);
  89. guid = model.ID;
  90. txtTransferNO.Text = model.invtransfer.TransferNO;
  91. txtTransferLine.Text = model.TransferLine.ToString();
  92. txtORDERNO.Text = model.ORDERNO;
  93. txtORDERLINE.Text = model.ORDERLINE.ToString();
  94. txtTransferSTATUS.Text = model.invtransfer.TransferSTATUS;
  95. txtMEMO.Text = model.MEMO;
  96. txtITEMCODE.Text = model.inventory.INVCODE;
  97. txtMOCODE.Text = model.mo.MOCODE;
  98. txtPLANQTY.Text = model.PLANQTY.ToString();
  99. txtACTQTY.Text = model.ACTQTY.ToString();
  100. txtCUSTOMERNAME.Text = model.CUSTOMERNAME;
  101. txtFROMStorageCode.Text = model.storage1.StorageCode;
  102. txtFROMStackCode.Text = model.stack1.StackCode;
  103. txtTOStorageCode.Text = model.storage2.StorageCode;
  104. txtTOStackCode.Text = model.stack2.StackCode;
  105. txtRECEIVE.Text = model.RECEIVE;
  106. txtRECEIVELINE.Text = model.RECEIVELINE;
  107. txtTransferTIME.Text = model.TransferTIME.ToString();
  108. txtTransferUSER.Text = model.TransferUSER;
  109. txtMUSERName.Text = model.MUSERName;
  110. txtMTIME.Text = model.MTIME.ToString();
  111. txtTransferNO.Properties.ReadOnly = true;
  112. }
  113. #region 关闭 退出
  114. private void btnClose_Click(object sender, EventArgs e)
  115. {
  116. this.Close();
  117. }
  118. #endregion
  119. #region 移动窗体
  120. private const int WM_NCHITTEST = 0x84;
  121. private const int HTCLIENT = 0x1;
  122. private const int HTCAPTION = 0x2;
  123. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  124. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  125. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  126. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  127. //重写窗体,使窗体可以不通过自带标题栏实现移动
  128. protected override void WndProc(ref Message m)
  129. {
  130. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  131. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  132. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  133. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  134. switch (m.Msg)
  135. {
  136. case WM_NCHITTEST:
  137. base.WndProc(ref m);
  138. if ((int)m.Result == HTCLIENT)
  139. m.Result = (IntPtr)HTCAPTION;
  140. return;
  141. }
  142. //拦截双击标题栏、移动窗体的系统消息
  143. if (m.Msg != 0xA3)
  144. {
  145. base.WndProc(ref m);
  146. }
  147. }
  148. #endregion
  149. #region 新增 修改
  150. private void save_Click(object sender, EventArgs e)
  151. {
  152. try
  153. {
  154. if (txtTransferNO.Text.Trim() == "")
  155. {
  156. ICSBaseSimpleCode.AppshowMessageBox("移转单号不能为空");
  157. return;
  158. }
  159. if (txtTransferSTATUS.Text.Trim() == "")
  160. {
  161. ICSBaseSimpleCode.AppshowMessageBox("转移单类型不能为空");
  162. return;
  163. }
  164. if (txtTransferLine.Text.Trim() == "")
  165. {
  166. ICSBaseSimpleCode.AppshowMessageBox("单行号不能为空");
  167. return;
  168. }
  169. //if (txtFROMStorageCode.Text.Trim() == "")
  170. //{
  171. // ICSBaseSimpleCode.AppshowMessageBox("源库别代码不能为空");
  172. // return;
  173. //}
  174. //if (txtTOStorageCode.Text.Trim() == "")
  175. //{
  176. // ICSBaseSimpleCode.AppshowMessageBox("目标库别代码不能为空");
  177. // return;
  178. //}
  179. if (txtITEMCODE.Text.Trim() == "")
  180. {
  181. ICSBaseSimpleCode.AppshowMessageBox("物料代码不能为空");
  182. return;
  183. }
  184. if (txtPLANQTY.Text.Trim() == "")
  185. {
  186. ICSBaseSimpleCode.AppshowMessageBox("计划数量不能为空");
  187. return;
  188. }
  189. //if (txtFROMStorageCode.Text.Trim() == txtTOStorageCode.Text.Trim())
  190. //{
  191. // ICSBaseSimpleCode.AppshowMessageBox("源库别代码与目标库别代码相同请重新选择!");
  192. // return;
  193. //}
  194. FormICSInvTransferDetailUIModel invtransfer = new FormICSInvTransferDetailUIModel();
  195. invtransfer.ID = guid;
  196. invtransfer.TransferID = invtransferid;
  197. invtransfer.TransferNO = txtTransferNO.Text;
  198. //DataTable dt = ICSSoft.Frame.Data.BLL.ICSInvTransferBLL.SelectFRMStorageId(txtFROMStorageCode.Text, AppConfig.WorkPointCode);
  199. //if (dt != null && dt.Rows.Count > 0)
  200. //{
  201. // invtransfer.FRMStorageID = dt.Rows[0][0].ToString();
  202. //}
  203. //DataTable dt1 = ICSSoft.Frame.Data.BLL.ICSInvTransferBLL.TOStorageId(txtTOStorageCode.Text, AppConfig.WorkPointCode);
  204. //if (dt1 != null && dt1.Rows.Count > 0)
  205. //{
  206. // invtransfer.TOStorageID = dt1.Rows[0][0].ToString();
  207. //}
  208. invtransfer.TransferLine = int.Parse(txtTransferLine.Text);
  209. invtransfer.ORDERNO = txtORDERNO.Text;
  210. if (!string.IsNullOrEmpty(txtORDERLINE.Text))
  211. {
  212. invtransfer.ORDERLINE = int.Parse(txtORDERLINE.Text);
  213. }
  214. invtransfer.TransferSTATUS = txtTransferSTATUS.Text;
  215. invtransfer.MEMO = txtMEMO.Text;
  216. invtransfer.ITEMCODE = txtITEMCODE.Text;
  217. invtransfer.MOCODE = txtMOCODE.Text;
  218. invtransfer.PLANQTY =Convert.ToDecimal(txtPLANQTY.Text);
  219. if (!string.IsNullOrEmpty(txtACTQTY.Text))
  220. {
  221. invtransfer.ACTQTY = Convert.ToDecimal(txtACTQTY.Text);
  222. }
  223. invtransfer.CustomerCode = "";
  224. invtransfer.CUSTOMERNAME = txtCUSTOMERNAME.Text;
  225. invtransfer.FROMStorageCode = txtFROMStorageCode.Text;
  226. invtransfer.FROMStackCode = txtFROMStackCode.Text;
  227. invtransfer.TOStorageCode = txtTOStorageCode.Text;
  228. invtransfer.TOStackCode = txtTOStackCode.Text;
  229. invtransfer.RECEIVE = txtRECEIVE.Text;
  230. invtransfer.RECEIVELINE = txtRECEIVELINE.Text;
  231. invtransfer.TransferTIME =Convert.ToDateTime(txtTransferTIME.Text);
  232. invtransfer.TransferUSER = txtTransferUSER.Text;
  233. invtransfer.MUSER = AppConfig.UserId;
  234. invtransfer.MUSERName = AppConfig.UserName;
  235. invtransfer.MTIME = System.DateTime.Parse(txtMTIME.Text);
  236. invtransfer.WorkPoint = AppConfig.WorkPointCode;
  237. invtransfer.EATTRIBUTE1 = null;
  238. ICSInvTransferDetailBLL.AddandEdit(invtransfer, AppConfig.AppConnectString);
  239. if (flag == 0)
  240. {
  241. ICSBaseSimpleCode.AppshowMessageBox("新增成功");
  242. }
  243. else if (flag == 1)
  244. {
  245. ICSBaseSimpleCode.AppshowMessageBox("修改成功");
  246. }
  247. }
  248. catch (Exception ex)
  249. {
  250. MessageBox.Show(ex.Message);
  251. }
  252. this.Close();
  253. this.DialogResult = DialogResult.Yes;
  254. }
  255. #endregion
  256. #region 取消
  257. private void can_Click(object sender, EventArgs e)
  258. {
  259. this.Close();
  260. }
  261. #endregion
  262. #region 物料代码按钮
  263. private void txtITEMCODE_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  264. {
  265. DataTable dt = ICSInvTransferDetailBLL.SearchItemInfoList(AppConfig.AppConnectString);
  266. FormDataRefer reForm = new FormDataRefer();
  267. reForm.FormTitle = "物料";
  268. reForm.DataSource = dt;
  269. reForm.MSelectFlag = false;
  270. reForm.RowIndexWidth = 35;
  271. reForm.HideCols.Add("guid");
  272. reForm.FormWidth = 500;
  273. reForm.FormHeight = 500;
  274. if (reForm.ShowDialog() == DialogResult.OK)
  275. {
  276. DataTable retData = reForm.ReturnData;
  277. foreach (DataRow dr in retData.Rows)
  278. {
  279. FormICSINVENTORYUIModel Item = new FormICSINVENTORYUIModel();
  280. Item.ID = dr["guid"].ToString();
  281. Item.INVCODE = dr["存货编码"].ToString();
  282. Item.INVNAME = dr["存货名称"].ToString();
  283. Item.INVDESC = dr["规格型号"].ToString();
  284. txtITEMCODE.Text = Item.INVCODE;
  285. txtITEMCODE.Tag = Item;
  286. break;
  287. }
  288. }
  289. }
  290. #endregion
  291. #region 生产订单号按钮
  292. private void txtMOCODE_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  293. {
  294. DataTable dt = ICSInvTransferDetailBLL.SearchMOInfoList(AppConfig.AppConnectString);
  295. FormDataRefer reForm = new FormDataRefer();
  296. reForm.FormTitle = "工单";
  297. reForm.DataSource = dt;
  298. reForm.MSelectFlag = false;
  299. reForm.RowIndexWidth = 35;
  300. reForm.HideCols.Add("guid");
  301. reForm.FormWidth = 500;
  302. reForm.FormHeight = 500;
  303. if (reForm.ShowDialog() == DialogResult.OK)
  304. {
  305. DataTable retData = reForm.ReturnData;
  306. foreach (DataRow dr in retData.Rows)
  307. {
  308. FormICSMOUIModel Item = new FormICSMOUIModel();
  309. Item.ID = dr["guid"].ToString();
  310. Item.MOCODE = dr["生产订单号"].ToString();
  311. Item.MOMEMO = dr["工单备注"].ToString();
  312. txtMOCODE.Text = Item.MOCODE;
  313. txtMOCODE.Tag = Item;
  314. break;
  315. }
  316. }
  317. }
  318. #endregion
  319. #region 源库位代码按钮
  320. private void txtFROMStackCode_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  321. {
  322. string storageid="";
  323. DataTable dt1 = ICSSoft.Frame.Data.BLL.ICSInvTransferDetailBLL.SelectStorageID(txtFROMStorageCode.Text);
  324. if (dt1 != null && dt1.Rows.Count > 0)
  325. {
  326. storageid = dt1.Rows[0][0].ToString();
  327. }
  328. DataTable dt = ICSInvTransferDetailBLL.SearchStackInfoList(storageid,AppConfig.AppConnectString);
  329. FormDataRefer reForm = new FormDataRefer();
  330. reForm.FormTitle = "库位";
  331. reForm.DataSource = dt;
  332. reForm.MSelectFlag = false;
  333. reForm.RowIndexWidth = 35;
  334. reForm.HideCols.Add("guid");
  335. reForm.FormWidth = 500;
  336. reForm.FormHeight = 500;
  337. if (reForm.ShowDialog() == DialogResult.OK)
  338. {
  339. DataTable retData = reForm.ReturnData;
  340. foreach (DataRow dr in retData.Rows)
  341. {
  342. FormICSStackUIModel Item = new FormICSStackUIModel();
  343. Item.Serial = dr["guid"].ToString();
  344. Item.StackCode = dr["库位代码"].ToString();
  345. Item.StackName = dr["库位名称"].ToString();
  346. txtFROMStackCode.Text = Item.StackCode;
  347. txtFROMStackCode.Tag = Item;
  348. break;
  349. }
  350. }
  351. }
  352. #endregion
  353. #region 目的库位代码按钮
  354. private void txtTOStackCode_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  355. {
  356. string storageid = "";
  357. DataTable dt1 = ICSSoft.Frame.Data.BLL.ICSInvTransferDetailBLL.SelectStorageID(txtTOStorageCode.Text);
  358. if (dt1 != null && dt1.Rows.Count > 0)
  359. {
  360. storageid = dt1.Rows[0][0].ToString();
  361. }
  362. DataTable dt = ICSInvTransferDetailBLL.SearchStackInfoList(storageid, AppConfig.AppConnectString);
  363. FormDataRefer reForm = new FormDataRefer();
  364. reForm.FormTitle = "库位";
  365. reForm.DataSource = dt;
  366. reForm.MSelectFlag = false;
  367. reForm.RowIndexWidth = 35;
  368. reForm.HideCols.Add("guid");
  369. reForm.FormWidth = 500;
  370. reForm.FormHeight = 500;
  371. if (reForm.ShowDialog() == DialogResult.OK)
  372. {
  373. DataTable retData = reForm.ReturnData;
  374. foreach (DataRow dr in retData.Rows)
  375. {
  376. FormICSStackUIModel Item = new FormICSStackUIModel();
  377. Item.Serial = dr["guid"].ToString();
  378. Item.StackCode = dr["库位代码"].ToString();
  379. Item.StackName = dr["库位名称"].ToString();
  380. txtTOStackCode.Text = Item.StackCode;
  381. txtTOStackCode.Tag = Item;
  382. break;
  383. }
  384. }
  385. }
  386. #endregion
  387. }
  388. }