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

176 lines
5.7 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. using ICSSoft.Frame.DataConnect;
  21. namespace ICSSoft.Frame.APP
  22. {
  23. public partial class FormICSTSScrap : DevExpress.XtraEditors.XtraForm
  24. {
  25. string mocode = "";
  26. #region 构造函数
  27. public FormICSTSScrap()
  28. {
  29. InitializeComponent();
  30. }
  31. public FormICSTSScrap(string rcard,string MOCODE)
  32. {
  33. InitializeComponent();
  34. //txtBackflow.Checked = true;
  35. txtRCARD.Text = rcard;
  36. mocode = MOCODE;
  37. }
  38. #endregion
  39. #region 关闭 退出
  40. private void btnClose_Click(object sender, EventArgs e)
  41. {
  42. this.Close();
  43. }
  44. #endregion
  45. #region 移动窗体
  46. private const int WM_NCHITTEST = 0x84;
  47. private const int HTCLIENT = 0x1;
  48. private const int HTCAPTION = 0x2;
  49. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  50. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  51. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  52. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  53. //重写窗体,使窗体可以不通过自带标题栏实现移动
  54. protected override void WndProc(ref System.Windows.Forms.Message m)
  55. {
  56. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  57. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  58. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  59. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  60. switch (m.Msg)
  61. {
  62. case WM_NCHITTEST:
  63. base.WndProc(ref m);
  64. if ((int)m.Result == HTCLIENT)
  65. m.Result = (IntPtr)HTCAPTION;
  66. return;
  67. }
  68. //拦截双击标题栏、移动窗体的系统消息
  69. if (m.Msg != 0xA3)
  70. {
  71. base.WndProc(ref m);
  72. }
  73. }
  74. #endregion
  75. #region 新增 修改
  76. private void save_Click(object sender, EventArgs e)
  77. {
  78. if (txtRCARD.Text.Trim() == "")
  79. {
  80. ICSBaseSimpleCode.AppshowMessageBox("产品序列号不能为空!");
  81. return;
  82. }
  83. if (txtSCRAPCAUSE.Text.Trim() == "")
  84. {
  85. ICSBaseSimpleCode.AppshowMessageBox("报废原因不能为空!");
  86. return;
  87. }
  88. FramDataContext db = new FramDataContext(AppConfig.AppConnectString);
  89. db.Connection.Open();
  90. db.Transaction = db.Connection.BeginTransaction();
  91. try
  92. {
  93. ICSTS ts = db.ICSTS.SingleOrDefault(a=> a.RCARD == txtRCARD.Text);
  94. #region 报废
  95. if (ts.TSSTATUS == TSStatus.TSStatus_TS)
  96. {
  97. ts.TSSTATUS = TSStatus.TSStatus_Scrap;
  98. ts.SCRAPCAUSE = this.txtSCRAPCAUSE.Text.Trim();
  99. }
  100. ICSSimulation simulation = db.ICSSimulation.SingleOrDefault(a => a.RCARD == txtRCARD.Text);
  101. if (simulation != null)
  102. {
  103. simulation.ISCOM = "1";
  104. simulation.EATTRIBUTE1 = "SCRAP";
  105. simulation.PRODUCTSTATUS = "SCRAP";
  106. simulation.MUSER = AppConfig.UserCode;
  107. simulation.MTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
  108. }
  109. ICSSimulationReport simulationReport = db.ICSSimulationReport.SingleOrDefault(a => a.RCARD == txtRCARD.Text);
  110. if (simulationReport != null)
  111. {
  112. simulationReport.ISCOM = "1";
  113. simulationReport.EATTRIBUTE1 = "SCRAP";
  114. simulationReport.PRODUCTSTATUS = "SCRAP";
  115. simulationReport.MUSER = AppConfig.UserCode;
  116. simulationReport.MTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
  117. }
  118. ICSMO mo = db.ICSMO.SingleOrDefault(a => a.MOCODE == mocode);
  119. if (mo != null)
  120. {
  121. mo.MOSCRAPQTY = mo.MOSCRAPQTY + 1;
  122. }
  123. db.SubmitChanges();
  124. db.Transaction.Commit();
  125. #endregion
  126. }
  127. catch (Exception ex)
  128. {
  129. MessageBox.Show(ex.Message);
  130. }
  131. this.Close();
  132. this.DialogResult = DialogResult.Yes;
  133. }
  134. #endregion
  135. #region 取消
  136. private void can_Click(object sender, EventArgs e)
  137. {
  138. this.Close();
  139. }
  140. #endregion
  141. }
  142. }