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

234 lines
8.5 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 FormICSAQLAdd : DevExpress.XtraEditors.XtraForm
  23. {
  24. String guid = "";
  25. int flag;
  26. FormICSAQLUIModel aqlmodel;
  27. #region 构造函数
  28. public FormICSAQLAdd()
  29. {
  30. InitializeComponent();
  31. flag = 0;
  32. chargeFormState("Add");
  33. txtmuser.Text = AppConfig.UserName;
  34. txttime.Text = Convert.ToString(DateTime.Now);
  35. }
  36. public FormICSAQLAdd(string aqlid, string time)
  37. {
  38. InitializeComponent();
  39. flag = 1;
  40. chargeFormState("Edit");
  41. txtmuser.Text = AppConfig.UserName;
  42. txttime.Text = time;
  43. guid = aqlid;
  44. SearchAQLInfo(aqlid);
  45. }
  46. #endregion
  47. private void chargeFormState(string state)
  48. {
  49. switch (state)
  50. {
  51. case "Add":
  52. txtAQLSEQ.Properties.ReadOnly = false;
  53. txtAQLLEVEL.Properties.ReadOnly = false;
  54. break;
  55. case "Edit":
  56. txtAQLSEQ.Properties.ReadOnly = true;
  57. txtAQLLEVEL.Properties.ReadOnly = true;
  58. break;
  59. }
  60. }
  61. private void SearchAQLInfo(string aqlid)
  62. {
  63. aqlmodel = ICSAQLBLL.SearchAQLInfoByID(aqlid, AppConfig.AppConnectString);
  64. txtAQLSEQ.Text = Convert.ToString(aqlmodel.AQLSEQ);
  65. txtAQLLEVEL.Text = aqlmodel.AQLLEVEL;
  66. txtLOTSIZEMIN.Text = Convert.ToString(aqlmodel.LOTSIZEMIN);
  67. txtLOTSIZEMAX.Text = Convert.ToString(aqlmodel.LOTSIZEMAX);
  68. txtSampleSize.Text = Convert.ToString(aqlmodel.SampleSize);
  69. txtRejectSize.Text = Convert.ToString(aqlmodel.RejectSize);
  70. }
  71. #region 关闭 退出
  72. private void btnClose_Click(object sender, EventArgs e)
  73. {
  74. this.Close();
  75. }
  76. #endregion
  77. #region 移动窗体
  78. private const int WM_NCHITTEST = 0x84;
  79. private const int HTCLIENT = 0x1;
  80. private const int HTCAPTION = 0x2;
  81. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  82. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  83. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  84. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  85. //重写窗体,使窗体可以不通过自带标题栏实现移动
  86. protected override void WndProc(ref Message m)
  87. {
  88. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  89. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  90. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  91. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  92. switch (m.Msg)
  93. {
  94. case WM_NCHITTEST:
  95. base.WndProc(ref m);
  96. if ((int)m.Result == HTCLIENT)
  97. m.Result = (IntPtr)HTCAPTION;
  98. return;
  99. }
  100. //拦截双击标题栏、移动窗体的系统消息
  101. if (m.Msg != 0xA3)
  102. {
  103. base.WndProc(ref m);
  104. }
  105. }
  106. #endregion
  107. #region 新增 修改
  108. private void save_Click(object sender, EventArgs e)
  109. {
  110. try
  111. {
  112. #region 判断是否为空
  113. if (txtAQLSEQ.Text.Trim() == "" || Convert.ToInt32(txtAQLSEQ.Text.Trim()) <= 0)
  114. {
  115. ICSBaseSimpleCode.AppshowMessageBox("序号不能为空且要大于0");
  116. return;
  117. }
  118. if (txtAQLLEVEL.Text.Trim() == "")
  119. {
  120. ICSBaseSimpleCode.AppshowMessageBox("检验标准不能为空");
  121. return;
  122. }
  123. if (txtLOTSIZEMIN.Text.Trim() == "" || Convert.ToInt32(txtLOTSIZEMIN.Text.Trim()) <= 0)
  124. {
  125. ICSBaseSimpleCode.AppshowMessageBox("批量起始数量不能为空且要大于0");
  126. return;
  127. }
  128. if (txtLOTSIZEMAX.Text.Trim() == "" || Convert.ToInt32(txtLOTSIZEMAX.Text.Trim()) <= 0)
  129. {
  130. ICSBaseSimpleCode.AppshowMessageBox("批量截止数量不能为空且要大于0");
  131. return;
  132. }
  133. if (txtSampleSize.Text.Trim() == "" || Convert.ToInt32(txtSampleSize.Text.Trim()) <= 0)
  134. {
  135. ICSBaseSimpleCode.AppshowMessageBox("样本数量不能为空且要大于0");
  136. return;
  137. }
  138. if (txtRejectSize.Text.Trim() == "" || Convert.ToInt32(txtRejectSize.Text.Trim()) < 0)
  139. {
  140. ICSBaseSimpleCode.AppshowMessageBox("判退数量不能为空且要大于等于0");
  141. return;
  142. }
  143. #endregion
  144. #region 判断大小
  145. if (Convert.ToInt32(txtLOTSIZEMIN.Text.Trim()) >= Convert.ToInt32(txtLOTSIZEMAX.Text.Trim()))
  146. {
  147. ICSBaseSimpleCode.AppshowMessageBox("批量起始数量应小于批量截止数量");
  148. return;
  149. }
  150. #endregion
  151. if (flag == 0)
  152. {
  153. bool b = ICSAQLBLL.IsIncluding(Convert.ToInt32(txtAQLSEQ.Text.Trim()), txtAQLLEVEL.Text.Trim(), AppConfig.WorkPointCode, AppConfig.AppConnectString);
  154. if (!b)
  155. {
  156. ICSBaseSimpleCode.AppshowMessageBox("已经存在");
  157. return;
  158. }
  159. }
  160. int min = Convert.ToInt32(txtLOTSIZEMIN.Text.Trim());
  161. int max = Convert.ToInt32(txtLOTSIZEMAX.Text.Trim());
  162. List <FormICSAQLUIModel> aqllist= ICSAQLBLL.SearchAQLInfoByLevel(txtAQLLEVEL.Text.Trim(), AppConfig.AppConnectString);
  163. if(aqllist!=null)
  164. {
  165. foreach (FormICSAQLUIModel aqlinfo in aqllist)
  166. {
  167. if (!(max < aqlinfo.LOTSIZEMIN || min > aqlinfo.LOTSIZEMAX))
  168. {
  169. ICSBaseSimpleCode.AppshowMessageBox("起始数量和截止数量不正确");
  170. return;
  171. }
  172. }
  173. }
  174. FormICSAQLUIModel aqlInfo = new FormICSAQLUIModel();
  175. aqlInfo.ID = guid;
  176. aqlInfo.AQLSEQ = Convert.ToInt32(txtAQLSEQ.Text);
  177. aqlInfo.AQLLEVEL = txtAQLLEVEL.Text;
  178. aqlInfo.LOTSIZEMIN = Convert.ToInt32(txtLOTSIZEMIN.Text);
  179. aqlInfo.LOTSIZEMAX = Convert.ToInt32(txtLOTSIZEMAX.Text);
  180. aqlInfo.SampleSize = Convert.ToInt32(txtSampleSize.Text);
  181. aqlInfo.RejectSize = Convert.ToInt32(txtRejectSize.Text);
  182. ICSAQLBLL.Add(aqlInfo, AppConfig.AppConnectString);
  183. if (flag == 0)
  184. {
  185. ICSBaseSimpleCode.AppshowMessageBox("增加成功");
  186. }
  187. else if (flag == 1)
  188. {
  189. ICSBaseSimpleCode.AppshowMessageBox("修改成功");
  190. }
  191. }
  192. catch (Exception ex)
  193. {
  194. MessageBox.Show(ex.Message);
  195. }
  196. this.Close();
  197. this.DialogResult = DialogResult.Yes;
  198. }
  199. #endregion
  200. #region 取消
  201. private void can_Click(object sender, EventArgs e)
  202. {
  203. this.Close();
  204. }
  205. #endregion
  206. }
  207. }