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

186 lines
6.2 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.Frame.User.BLL;
  10. using ICSSoft.Base.Language.Tool;
  11. using ICSSoft.Base.UserControl.MessageControl;
  12. using System.Data.SqlClient;
  13. using ICSSoft.Base.Config.AppConfig;
  14. using ICSSoft.Base.Report.Filter;
  15. using ICSSoft.Base.Config.DBHelper;
  16. using ICSSoft.Base.UserControl.FormControl;
  17. using ICSSoft.Base.ReferForm.AppReferForm;
  18. using ICSSoft.Base.Lable.PrintTool;
  19. using ICSSoft.Frame.Data.DAL;
  20. using ICSSoft.Frame.Data.BLL;
  21. using ICSSoft.Frame.Data.Entity;
  22. namespace ICSSoft.Frame.APP
  23. {
  24. public partial class FormICSPalletAdd : DevExpress.XtraEditors.XtraForm
  25. {
  26. String guid = "";
  27. int flag;
  28. string opid;
  29. string username;
  30. FormICSPalletModel model;
  31. #region 构造函数
  32. public FormICSPalletAdd()
  33. {
  34. InitializeComponent();
  35. flag = 0;
  36. chargeFormState("Add");
  37. }
  38. #endregion
  39. private void chargeFormState(string state)
  40. {
  41. string NewCartonNo = "ZY" + AppConfig.GetSeverDateTime("yyyy-MM-dd").ToString("yyyyMMdd");
  42. NewCartonNo = AppConfig.GetSerialCode(AppConfig.FrameConnectString, "ICSSecDoc","" ,"SecDocNO", NewCartonNo, 2);
  43. txtPalletCode.Text = NewCartonNo;
  44. switch (state)
  45. {
  46. case "Add":
  47. txtPalletCode.Properties.ReadOnly = false;
  48. txtMUSERName.Text = AppConfig.UserName;
  49. txtMTIME.Text = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss").ToString();
  50. txtMUSERName.Properties.ReadOnly = true;
  51. txtMTIME.Properties.ReadOnly = true;
  52. break;
  53. case "Edit":
  54. txtPalletCode.Properties.ReadOnly = true;
  55. txtMUSERName.Text = AppConfig.UserName;
  56. txtMTIME.Text = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss").ToString();
  57. txtMUSERName.Properties.ReadOnly = true;
  58. txtMTIME.Properties.ReadOnly = true;
  59. break;
  60. }
  61. }
  62. #region 关闭 退出
  63. private void btnClose_Click(object sender, EventArgs e)
  64. {
  65. this.Close();
  66. }
  67. #endregion
  68. #region 移动窗体
  69. private const int WM_NCHITTEST = 0x84;
  70. private const int HTCLIENT = 0x1;
  71. private const int HTCAPTION = 0x2;
  72. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  73. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  74. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  75. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  76. //重写窗体,使窗体可以不通过自带标题栏实现移动
  77. protected override void WndProc(ref Message m)
  78. {
  79. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  80. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  81. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  82. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  83. switch (m.Msg)
  84. {
  85. case WM_NCHITTEST:
  86. base.WndProc(ref m);
  87. if ((int)m.Result == HTCLIENT)
  88. m.Result = (IntPtr)HTCAPTION;
  89. return;
  90. }
  91. //拦截双击标题栏、移动窗体的系统消息
  92. if (m.Msg != 0xA3)
  93. {
  94. base.WndProc(ref m);
  95. }
  96. }
  97. #endregion
  98. #region 新增 修改
  99. private void save_Click(object sender, EventArgs e)
  100. {
  101. try
  102. {
  103. FormICSPalletModel test = new FormICSPalletModel();
  104. test.MUSERCODE = AppConfig.UserCode;
  105. test.MUSERName = AppConfig.UserName;
  106. test.MTIME = DateTime.Now;
  107. test.WorkPoint = AppConfig.WorkPointCode;
  108. test.EATTRIBUTE1 = "";
  109. test.PalletCode = txtPalletCode.Text.Trim();
  110. ICSPalletBLL.Add(test, AppConfig.AppConnectString);
  111. ICSBaseSimpleCode.AppshowMessageBox("操作成功");
  112. }
  113. catch (Exception ex)
  114. {
  115. MessageBox.Show(ex.Message);
  116. }
  117. this.Close();
  118. this.DialogResult = DialogResult.Yes;
  119. }
  120. #endregion
  121. #region 删除批次
  122. public FormICSPalletAdd(string Pallet2Code, string LotNO, string MuserCode)
  123. {
  124. try
  125. {
  126. SqlConnection conn = new SqlConnection(AppConfig.AppConnectString);
  127. conn.Open();
  128. SqlCommand cmd = new SqlCommand();
  129. SqlTransaction trans = conn.BeginTransaction();
  130. cmd.Transaction = trans;
  131. cmd.Connection = conn;
  132. try
  133. {
  134. string sqls = @"delete ICSPalletLotNO where PalletCode = '" + Pallet2Code + "' and LotNO = '" + LotNO + "' and MuserCode = '" + MuserCode + "'";
  135. cmd.CommandType = CommandType.Text;
  136. cmd.CommandText = sqls;
  137. cmd.ExecuteNonQuery();
  138. trans.Commit();
  139. }
  140. catch (Exception ex)
  141. {
  142. trans.Rollback();
  143. throw ex;
  144. }
  145. }
  146. catch (Exception ex)
  147. {
  148. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  149. }
  150. }
  151. #endregion
  152. #region 取消
  153. private void can_Click(object sender, EventArgs e)
  154. {
  155. this.Close();
  156. }
  157. #endregion
  158. }
  159. }