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

813 lines
32 KiB

5 months ago
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Data.Linq;
  6. using System.Linq;
  7. using System.Drawing;
  8. using System.Text;
  9. using System.Windows.Forms;
  10. using DevExpress.XtraEditors;
  11. using DevExpress.XtraGrid.Views.BandedGrid;
  12. using DevExpress.XtraGrid.Columns;
  13. using DevExpress.XtraGrid;
  14. using System.IO;
  15. using System.Threading;
  16. using ICSSoft.Base.Language.Tool;
  17. using ICSSoft.Base.Config.AppConfig;
  18. using ICSSoft.Base.UserControl.MessageControl;
  19. using ICSSoft.Base.Config.DBHelper;
  20. using ICSSoft.Base.Report.Filter;
  21. using ICSSoft.Base.UserControl.FormControl;
  22. using ICSSoft.Base.Report.GridReport;
  23. using ICSSoft.Base.ReferForm.AppReferForm;
  24. using ICSSoft.Frame.Data.BLL;
  25. using DevExpress.XtraEditors;
  26. using ICSSoft.Frame.Data.Entity;
  27. using ICSSoft.Frame.Data.BLL;
  28. using ICSSoft.Base.Config.AppConfig;
  29. using ICSSoft.Base.Config.DBHelper;
  30. using ICSSoft.Base.ReferForm.AppReferForm;
  31. using System.Text.RegularExpressions;
  32. namespace ICSSoft.Frame.APP
  33. {
  34. public partial class FormICSASNIQCDETAIL : DevExpress.XtraEditors.XtraForm
  35. {
  36. private string sqlconn = "";
  37. String id = "";
  38. String guid = "";
  39. ICSASNIQCDETAIL entity = new ICSASNIQCDETAIL();
  40. #region 构造函数
  41. public FormICSASNIQCDETAIL()
  42. {
  43. InitializeComponent();
  44. this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  45. this.WindowState = FormWindowState.Maximized;
  46. }
  47. public FormICSASNIQCDETAIL(String id)
  48. {
  49. guid = id;
  50. InitializeComponent();
  51. this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  52. this.WindowState = FormWindowState.Maximized;
  53. FormICSCREW_Load(null, null);
  54. string stdstatus = "";
  55. for (int i = 0; i < grvDetail.RowCount; i++)
  56. {
  57. stdstatus = grvDetail.GetRowCellValue(i, STDSTATUS).ToString();
  58. id = grvDetail.GetRowCellValue(i, MID).ToString();
  59. }
  60. if (stdstatus != "待检" && stdstatus != "CheckUnStorage" && stdstatus != "已检未入库")
  61. {
  62. ICSBaseSimpleCode.AppshowMessageBox("数据为[待检][已检未入库]状态才可以维护!");
  63. return;
  64. }
  65. NewValue(id);
  66. }
  67. #endregion
  68. #region 操作权限
  69. public DataTable RightOfExute()
  70. {
  71. DataTable rData = new DataTable();
  72. rData.Columns.Add("BtnName");
  73. rData.Columns.Add("ActionName");
  74. //查看权限(必须有)
  75. DataRow seeRow = rData.NewRow();
  76. seeRow["BtnName"] = "see";
  77. seeRow["ActionName"] = "查看";
  78. rData.Rows.Add(seeRow);
  79. List<Control> ControlList = new List<Control>();
  80. ControlList.Add(btnOutPut);
  81. foreach (Control ctr in ControlList)
  82. {
  83. if (ctr.GetType() == typeof(SimpleButton))
  84. {
  85. DataRow dr = rData.NewRow();
  86. dr["BtnName"] = ctr.Name;
  87. dr["ActionName"] = ctr.Text;
  88. rData.Rows.Add(dr);
  89. }
  90. }
  91. rData.AcceptChanges();
  92. return rData;
  93. }
  94. public DataTable RightOfData()// 数据权限
  95. {
  96. DataTable rData = new DataTable();
  97. rData.Columns.Add("BodyName");
  98. rData.Columns.Add("ControlName");
  99. rData.Columns.Add("ControlCaption");
  100. rData.AcceptChanges();
  101. return rData;
  102. }
  103. #endregion
  104. #region 退出
  105. private void btnClose_Click(object sender, EventArgs e)
  106. {
  107. AppConfig.CloseFormShow(this.Text);
  108. this.Close();
  109. }
  110. private void btnExit_Click(object sender, EventArgs e)
  111. {
  112. AppConfig.CloseFormShow(this.Text);
  113. this.Close();
  114. }
  115. #endregion
  116. #region 移动窗体
  117. private const int WM_NCHITTEST = 0x84;
  118. private const int HTCLIENT = 0x1;
  119. private const int HTCAPTION = 0x2;
  120. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  121. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  122. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  123. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  124. //重写窗体,使窗体可以不通过自带标题栏实现移动
  125. protected override void WndProc(ref Message m)
  126. {
  127. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  128. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  129. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  130. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  131. switch (m.Msg)
  132. {
  133. case WM_NCHITTEST:
  134. base.WndProc(ref m);
  135. if ((int)m.Result == HTCLIENT)
  136. m.Result = (IntPtr)HTCAPTION;
  137. return;
  138. }
  139. //拦截双击标题栏、移动窗体的系统消息
  140. if (m.Msg != 0xA3)
  141. {
  142. base.WndProc(ref m);
  143. }
  144. }
  145. #endregion
  146. #region 列表
  147. private void grvDetail_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
  148. {
  149. if (e.Info.IsRowIndicator && e.RowHandle >= 0)
  150. e.Info.DisplayText = (e.RowHandle + 1).ToString();
  151. }
  152. #endregion
  153. #region 刷新
  154. private void btnRefresh_Click(object sender, EventArgs e)
  155. {
  156. if (sqlconn == null || sqlconn == "")
  157. {
  158. return;
  159. }
  160. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在查找...请稍等...");
  161. try
  162. {
  163. _wait.Show();
  164. FormICSCREW_Load(null,null);
  165. _wait.Close();
  166. }
  167. catch (Exception ex)
  168. {
  169. MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  170. _wait.Close();
  171. }
  172. }
  173. #endregion
  174. #region 页面加载
  175. private void grdDetail_Load(object sender, EventArgs e)
  176. {
  177. FormICSCREW_Load(null, null);
  178. }
  179. private void FormICSCREW_Load(object sender, EventArgs e)
  180. {
  181. try
  182. {
  183. string sql = "select a.ID as MID,a.*,b.INVDESC,b.INVCONTROLTYPE from ICSASNIQCDETAIL as a,ICSINVENTORY as b where a.ITEMCODE=b.INVCODE and a.WorkPoint='" + AppConfig.WorkPointCode + "' and b.WorkPoint='" + AppConfig.WorkPointCode + "' and a.IQCID='" + guid + "'";
  184. DataTable ddf = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  185. grdDetail.DataSource = ddf;
  186. }
  187. catch (Exception ex)
  188. {
  189. MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  190. }
  191. }
  192. #endregion
  193. #region 导出
  194. private void btnOutPut_Click_1(object sender, EventArgs e)
  195. {
  196. FormOutExcel foe = new FormOutExcel(this.Tag.ToString(), grdDetail);
  197. foe.ShowDialog();
  198. }
  199. #endregion
  200. #region 赋初始值NewValue
  201. public void NewValue(string id)
  202. {
  203. string sql = "select * from ICSASNIQCDETAIL where ID='" + id + "' and WorkPoint='" + AppConfig.WorkPointCode + "'";
  204. DataTable dtn = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  205. foreach (DataRow dr in dtn.Rows)
  206. {
  207. txtCODE.Text=dr["IQCNO"].ToString();
  208. }
  209. string st = "select * from ICSINVENTORY where INVCODE='" + dtn.Rows[0][5].ToString() + "' and WorkPoint='" + AppConfig.WorkPointCode + "'";
  210. DataTable dm = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, st).Tables[0];
  211. foreach (DataRow dd in dm.Rows)
  212. {
  213. if (dd["INVCONTROLTYPE"] == null)
  214. {
  215. comCONTROLTYPE.Items.Clear();
  216. comCONTROLTYPE.Items.Add("批次管控");
  217. comCONTROLTYPE.Items.Add("单件管控");
  218. comCONTROLTYPE.Items.Add("不管控");
  219. }
  220. else
  221. {
  222. comCONTROLTYPE.Text = dd["INVCONTROLTYPE"].ToString();
  223. comCONTROLTYPE.Items.Clear();
  224. comCONTROLTYPE.Items.Add("批次管控");
  225. comCONTROLTYPE.Items.Add("单件管控");
  226. comCONTROLTYPE.Items.Add("不管控");
  227. }
  228. }
  229. //赋值
  230. txtMUSER.Text = AppConfig.UserCode;
  231. txtMTIME.Text = DateTime.Now.ToString();
  232. txtID.Text = id;
  233. foreach (DataRow dr in dtn.Rows)
  234. {
  235. //采购订单号
  236. //entity.ORDERNO =
  237. //采购订单行
  238. //entity.ORDERLINE =
  239. if (dr["INSType"].ToString() == "全检")
  240. {
  241. radALLCHECK.Checked = true;
  242. }
  243. else if(dr["INSType"].ToString() == "抽检")
  244. {
  245. radPARTCHECK.Checked = true;
  246. }
  247. if (dr["CHECKSTATUS"].ToString() == "合格")
  248. {
  249. radQUA.Checked = true;
  250. }
  251. else if (dr["CHECKSTATUS"].ToString() == "不合格")
  252. {
  253. radNOTQUA.Checked = true;
  254. }
  255. //采购备注
  256. //entity.PurchaseMEMO=
  257. rDESC.Text = dr["MEMO"].ToString();
  258. txtQUADESC.Text = dr["MEMOEX"].ToString();
  259. comSAMPLE.Text = dr["isSample"].ToString();
  260. txtECG.Text = dr["TSErrorCodeGroup"].ToString();
  261. btnEC.Text = dr["TSErrorCode"].ToString();
  262. comACCWAY.Text = dr["TYPE"].ToString();
  263. comAQLNORM.Text = dr["AQL"].ToString();
  264. if (dr["SAMPLEQTY"].ToString()!="")
  265. {
  266. txtPARTAMOUNT.Text = Convert.ToInt32(double.Parse(dr["SAMPLEQTY"].ToString())).ToString();
  267. }
  268. txtITEMCODE.Text = dr["CheckGroup"].ToString();
  269. txtVALUEMIN.Text=dr["PIC"].ToString();
  270. //if (comAQLNORM.Text != "")
  271. //{
  272. // txtPARTAMOUNT_TextChanged(null, null);
  273. //}
  274. if (dr["NGQTY"].ToString()!="")
  275. {
  276. txtECNUM.Text = Convert.ToInt32(double.Parse(dr["NGQTY"].ToString())).ToString();
  277. }
  278. rSTEPDESC.Text = dr["ACTION"].ToString();
  279. if (dr["concessionStatus"].ToString() == "是")
  280. {
  281. cheACC.Checked = true;
  282. }
  283. else
  284. {
  285. cheACC.Checked = false; ;
  286. }
  287. cheACC_CheckedChanged(null,null);
  288. if (dr["concessionQTY"].ToString()!="")
  289. {
  290. txtACCAMOUNT.Text = Convert.ToInt32(double.Parse(dr["concessionQTY"].ToString())).ToString();
  291. }
  292. txtACCNUM.Text=dr["concessionNO"].ToString();
  293. rACCDESC.Text=dr["concessionMemo"].ToString();
  294. txtDUTYPER.Text = dr["IQCDepartment"].ToString();
  295. txtTESTPER.Text=dr["DINSPECTOR"].ToString();
  296. dTESTTIME.Text=dr["DINSPDATE"].ToString();
  297. }
  298. txtECG.Enabled = false;
  299. txtACCAMOUNT.Enabled = false;
  300. txtACCNUM.Enabled = false;
  301. rACCDESC.Enabled = false;
  302. if (radQUA.Checked == true)
  303. {
  304. //txtSAMAMOUNT.Enabled = false;//样本数量
  305. //txtPARTAMOUNT.Enabled = false;//抽样数
  306. cheACC.Enabled = false;
  307. txtQUADESC.Enabled = false;//不合格说明
  308. btnEC.Enabled = false;
  309. }
  310. if (radNOTQUA.Checked == true)
  311. {
  312. cheACC.Enabled = true;
  313. if (cheACC.Checked == true)
  314. {
  315. txtACCAMOUNT.Enabled = true;
  316. txtACCNUM.Enabled = true;
  317. rACCDESC.Enabled = true;
  318. }
  319. }
  320. comSAMPLE.Items.Clear();
  321. comSAMPLE.Items.Add("是");
  322. comSAMPLE.Items.Add("否");
  323. comACCWAY.Items.Clear();
  324. comACCWAY.Items.Add("正常");
  325. comACCWAY.Items.Add("特采");
  326. comACCWAY.Items.Add("代用");
  327. string str = "select DISTINCT AQLLEVEL from ICSAQL where WorkPoint='" + AppConfig.WorkPointCode + "'";
  328. DataTable ddf = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, str).Tables[0];
  329. comAQLNORM.Items.Clear();
  330. if (ddf.Rows.Count != 0)
  331. {
  332. foreach (DataRow dk in ddf.Rows)
  333. {
  334. comAQLNORM.Items.Add(dk[0].ToString());
  335. }
  336. }
  337. if (comAQLNORM.Text != "")
  338. {
  339. comAQLNORM_SelectedIndexChanged(null,null);
  340. }
  341. }
  342. #endregion
  343. #region 新增 修改
  344. private void save_Click(object sender, EventArgs e)
  345. {
  346. int f = 0;
  347. string stq = "select RECEIVEQTY from dbo.ICSASNIQCDETAIL where ID='" + txtID.Text + "' and WorkPoint='" + AppConfig.WorkPointCode + "'";
  348. DataTable dmq = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, stq).Tables[0];
  349. if (dmq.Rows.Count > 0)
  350. {
  351. f = int.Parse(dmq.Rows[0][0].ToString().Split('.')[0]);
  352. }
  353. Regex rex = new Regex(@"^\d+$|^\d+\.\d+$");
  354. int i = 0;
  355. int j = 0;
  356. if (cheACC.Checked == true)
  357. {
  358. if (txtACCAMOUNT.Text == "" || txtACCNUM.Text=="")
  359. {
  360. i++;
  361. }
  362. j++;
  363. }
  364. if (txtCODE.Text.Trim() == "")
  365. {
  366. ICSBaseSimpleCode.AppshowMessageBox("[送检运单号]不可为空!");
  367. }
  368. else if(radALLCHECK.Checked==false&&radPARTCHECK.Checked==false)
  369. {
  370. ICSBaseSimpleCode.AppshowMessageBox("[全检抽检]不可为空!");
  371. }
  372. else if(radQUA.Checked==false&&radNOTQUA.Checked==false)
  373. {
  374. ICSBaseSimpleCode.AppshowMessageBox("[合格不合格]不可为空!");
  375. }
  376. else if (comACCWAY.Text == "")
  377. {
  378. ICSBaseSimpleCode.AppshowMessageBox("[接收方式]不可为空!");
  379. }
  380. else if (comAQLNORM.Text == "")
  381. {
  382. ICSBaseSimpleCode.AppshowMessageBox("[AQL标准]不可为空!");
  383. }
  384. else if (txtPARTAMOUNT.Text == "")
  385. {
  386. ICSBaseSimpleCode.AppshowMessageBox("[抽样数]不可为空!");
  387. }
  388. else if (txtECNUM.Text == "")
  389. {
  390. ICSBaseSimpleCode.AppshowMessageBox("[不良数]不可为空!");
  391. }
  392. else if (txtITEMCODE.Text == "")
  393. {
  394. ICSBaseSimpleCode.AppshowMessageBox("[测试项目组]不可为空!");
  395. }
  396. else if (comCONTROLTYPE.Text=="")
  397. {
  398. ICSBaseSimpleCode.AppshowMessageBox("[管控类型]不可为空!");
  399. }
  400. else if (txtECNUM.Text=="")
  401. {
  402. ICSBaseSimpleCode.AppshowMessageBox("[不良数]不可为空!");
  403. }
  404. else if(i!=0)
  405. {
  406. ICSBaseSimpleCode.AppshowMessageBox("让步接收时[数量][号码]必填!");
  407. }
  408. else if (!rex.Match(txtPARTAMOUNT.Text).Success && txtPARTAMOUNT.Text!="")
  409. {
  410. ICSBaseSimpleCode.AppshowMessageBox("[抽样数]为空或正整数!");
  411. }
  412. else if (!rex.Match(txtSAMAMOUNT.Text).Success && txtSAMAMOUNT.Text != "")
  413. {
  414. ICSBaseSimpleCode.AppshowMessageBox("[样本数量]为空或正整数!");
  415. }
  416. else if (!rex.Match(txtECNUM.Text).Success && txtECNUM.Text != "")
  417. {
  418. ICSBaseSimpleCode.AppshowMessageBox("[不良数]为正整数!");
  419. }
  420. else if (!rex.Match(txtACCAMOUNT.Text).Success && txtACCAMOUNT.Text != "" && j != 0)
  421. {
  422. ICSBaseSimpleCode.AppshowMessageBox("[让步接收数量]为空或正整数!");
  423. }
  424. else if (int.Parse(txtECNUM.Text) >= int.Parse(txtPARTAMOUNT.Text))
  425. {
  426. ICSBaseSimpleCode.AppshowMessageBox("[不良数]不能大于等于[样本数量]!");
  427. }
  428. else if (txtACCAMOUNT.Text!="" && int.Parse(txtACCAMOUNT.Text)>f)
  429. {
  430. ICSBaseSimpleCode.AppshowMessageBox("[让步接收数量]不能大于[收货数量]!");
  431. }
  432. else if (int.Parse(txtPARTAMOUNT.Text)>f)
  433. {
  434. ICSBaseSimpleCode.AppshowMessageBox("[样本数量]不能大于[收货数量]");
  435. }
  436. else
  437. {
  438. try
  439. {
  440. ICSASNIQC asn = new ICSASNIQC();
  441. string sql = "select a.*,b.PLANQTY from ICSASNIQCDETAIL as a,ICSINVReceiptDetail as b where a.ID='" + txtID.Text + "' and b.ReceiptNO=a.STNO and a.STLINE=b.ReceiptLine and a.WorkPoint='" + AppConfig.WorkPointCode + "' and b.WorkPoint='" + AppConfig.WorkPointCode + "'";
  442. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  443. foreach (DataRow dr in dt.Rows)
  444. {
  445. string st = "select * from ICSINVENTORY where INVCODE='" + dr["ITEMCODE"] + "' and WorkPoint='" + AppConfig.WorkPointCode + "'";
  446. DataTable dm = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, st).Tables[0];
  447. entity.ID = txtID.Text;
  448. entity.IQCID=dr["IQCID"].ToString();
  449. entity.IQCNO = dr["IQCNO"].ToString();
  450. entity.STNO = dr["STNO"].ToString();
  451. if (dr["STLINE"].ToString()!="")
  452. {
  453. entity.STLINE = int.Parse(dr["STLINE"].ToString());
  454. }
  455. entity.ITEMCODE = dr["ITEMCODE"].ToString();
  456. //采购订单号
  457. //entity.ORDERNO =
  458. //采购订单行
  459. //entity.ORDERLINE =
  460. entity.STDSTATUS = "已检未入库";
  461. if (dr["PLANQTY"].ToString() != "")
  462. {
  463. entity.RECEIVEQTY = int.Parse(double.Parse(dr["PLANQTY"].ToString()).ToString());
  464. }
  465. if (radQUA.Checked == true)
  466. {
  467. entity.CHECKSTATUS = "合格";
  468. }
  469. else
  470. {
  471. entity.CHECKSTATUS = "不合格";
  472. }
  473. entity.UNIT=dm.Rows[0][4].ToString();
  474. //采购备注
  475. //entity.PurchaseMEMO=
  476. entity.MEMO = rDESC.Text;
  477. entity.MEMOEX = txtQUADESC.Text;
  478. if (txtPARTAMOUNT.Text != "")
  479. {
  480. entity.SAMPLEQTY = int.Parse(txtPARTAMOUNT.Text);
  481. }
  482. if (txtECNUM.Text != "")
  483. {
  484. entity.NGQTY = int.Parse(txtECNUM.Text);
  485. }
  486. entity.PIC = txtVALUEMIN.Text;
  487. entity.ACTION = rSTEPDESC.Text;
  488. if (radALLCHECK.Checked == true)
  489. {
  490. entity.INSType = "全检";
  491. }
  492. else
  493. {
  494. entity.INSType = "抽检";
  495. }
  496. if (dTESTTIME.Text != "")
  497. {
  498. entity.DINSPDATE = DateTime.Parse(dTESTTIME.Text);
  499. }
  500. entity.DINSPECTOR = txtTESTPER.Text;
  501. entity.ATTRIBUTE = "正常";
  502. entity.Type = comACCWAY.Text;
  503. entity.StorageID = dr["StorageID"].ToString();
  504. if (cheACC.Checked == true)
  505. {
  506. entity.concessionStatus = "是";
  507. }
  508. else
  509. {
  510. entity.concessionStatus = "否";
  511. }
  512. entity.IQCDepartment = txtDUTYPER.Text;
  513. if (txtACCAMOUNT.Text!="")
  514. {
  515. entity.concessionQTY = int.Parse(txtACCAMOUNT.Text);
  516. }
  517. entity.concessionNO = txtACCNUM.Text;
  518. entity.concessionMemo = rACCDESC.Text;
  519. entity.WORKPOINT = AppConfig.WorkPointCode;
  520. entity.MUSER = txtMUSER.Text;
  521. entity.MUSERNAME = AppConfig.UserName;
  522. if (txtMTIME.Text!="")
  523. {
  524. entity.MTIME =Convert.ToDateTime(txtMTIME.Text);
  525. }
  526. entity.isSample=comSAMPLE.Text;
  527. entity.AQL=comAQLNORM.Text;
  528. entity.CheckGroup=txtITEMCODE.Text;
  529. entity.TSErrorCodeGroup=txtECG.Text;
  530. entity.TSErrorCode=btnEC.Text;
  531. entity.IQCDepartment = txtDUTYPER.Text;
  532. ICSASNIQCDETAILBLL.AddAndEdit(entity, AppConfig.AppConnectString);
  533. //检验完成后,修改入库单检验结果 修改合格数量
  534. double qualify = 0;
  535. if (entity.CHECKSTATUS == "合格")
  536. {
  537. qualify = double.Parse(entity.RECEIVEQTY.ToString().Split('.')[0].ToString()) - double.Parse(entity.NGQTY.ToString());
  538. }
  539. ICSASNIQCDETAILBLL.UpdateICSINVReceiptDetailState(entity.CHECKSTATUS, qualify, txtCODE.Text);
  540. //所有子表检验完成,修改主表状态
  541. int m=ICSASNIQCDETAILBLL.SelectCount(entity.IQCNO);
  542. if (m == 0)
  543. {
  544. ICSASNIQCDETAILBLL.Set(entity.IQCNO);
  545. }
  546. }
  547. ICSBaseSimpleCode.AppshowMessageBox("操作成功!");
  548. FormICSCREW_Load(null, null);
  549. }
  550. catch (Exception ex)
  551. {
  552. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  553. }
  554. }
  555. }
  556. #endregion
  557. #region 取消
  558. private void can_Click(object sender, EventArgs e)
  559. {
  560. this.Close();
  561. }
  562. #endregion
  563. #region 不良代码
  564. private void btnEC_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  565. {
  566. btnEC.Text = "";
  567. ButtonEdit btn = (ButtonEdit)sender;
  568. string sql = @"select a.ECODE as [不良代码],b.ECDESC as [描述]
  569. from dbo.ICSECG2EC as a,ICSEC as b
  570. where a.ECGCODE='" + txtECG.Text + "' and b.ID=a.ECID and a.WorkPoint='" + AppConfig.WorkPointCode + "' and b.WorkPoint='" + AppConfig.WorkPointCode + "'";
  571. sql = string.Format(sql);
  572. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  573. FormDataRefer reForm = new FormDataRefer();
  574. reForm.FormTitle = "不良代码信息";
  575. DataTable menuData = data;
  576. reForm.DataSource = menuData;
  577. reForm.MSelectFlag = false;
  578. reForm.RowIndexWidth = 35;
  579. reForm.HideCols.Add("ID");
  580. reForm.FormWidth = 800;
  581. reForm.FormHeight = 600;
  582. reForm.FilterKey = btn.Text; //grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, grvDetail.FocusedColumn).ToString().Trim();
  583. if (reForm.ShowDialog() == DialogResult.OK)
  584. {
  585. DataTable retData = reForm.ReturnData;
  586. foreach (DataRow dr in retData.Rows)
  587. {
  588. btnEC.Text = dr["不良代码"].ToString();
  589. }
  590. }
  591. }
  592. #endregion
  593. #region 测试项目组 按钮点击事件
  594. private void txtITEMCODE_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  595. {
  596. txtITEMCODE.Text = "";
  597. ButtonEdit btn = (ButtonEdit)sender;
  598. string sql = @"select CKGROUP as [检验项目组],ID as [ID],CKGROUPDESC as [描述]
  599. from ICSOQCCKGROUP
  600. where WorkPoint='" + AppConfig.WorkPointCode + "'";
  601. sql = string.Format(sql);
  602. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  603. FormDataRefer reForm = new FormDataRefer();
  604. reForm.FormTitle = "检验项目信息";
  605. DataTable menuData = data;
  606. reForm.DataSource = menuData;
  607. reForm.MSelectFlag = false;
  608. reForm.RowIndexWidth = 35;
  609. reForm.HideCols.Add("ID");
  610. reForm.FormWidth = 800;
  611. reForm.FormHeight = 600;
  612. reForm.FilterKey = btn.Text; //grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, grvDetail.FocusedColumn).ToString().Trim();
  613. if (reForm.ShowDialog() == DialogResult.OK)
  614. {
  615. DataTable retData = reForm.ReturnData;
  616. foreach (DataRow dr in retData.Rows)
  617. {
  618. txtITEMCODE.Text = dr["检验项目组"].ToString();
  619. }
  620. }
  621. }
  622. #endregion
  623. #region AQL标准 下拉框值 改变事件
  624. private void comAQLNORM_SelectedIndexChanged(object sender, EventArgs e)
  625. {
  626. if (comAQLNORM.Text != "" && txtPARTAMOUNT.Text != "")
  627. {
  628. try
  629. {
  630. string code = "";
  631. string s = "select SampleSize,LOTSIZEMIN,LOTSIZEMAX from ICSAQL where AQLLEVEL='" + comAQLNORM.Text + "' and WorkPoint='" + AppConfig.WorkPointCode + "'";
  632. DataTable dy = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, s).Tables[0];
  633. string st = "select RECEIVEQTY from ICSASNIQCDETAIL where IQCNO='"+txtCODE.Text+"'";
  634. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, st).Tables[0];
  635. if(dt.Rows.Count!=0)
  636. {
  637. code=dt.Rows[0][0].ToString().Split('.')[0].ToString();
  638. }
  639. if (dy.Rows.Count != 0)
  640. {
  641. foreach (DataRow dr in dy.Rows)
  642. {
  643. if (int.Parse(code) <= int.Parse(dr["LOTSIZEMAX"].ToString()) && int.Parse(code) >= int.Parse(dr["LOTSIZEMIN"].ToString()))
  644. {
  645. txtSAMAMOUNT.Text = dr["SampleSize"].ToString();
  646. }
  647. }
  648. }
  649. }
  650. catch(Exception ex)
  651. {
  652. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  653. }
  654. }
  655. }
  656. #endregion
  657. #region 让步接收 按钮值 改变时
  658. private void cheACC_CheckedChanged(object sender, EventArgs e)
  659. {
  660. if (cheACC.Checked == true)
  661. {
  662. txtACCAMOUNT.Enabled = true;
  663. txtACCNUM.Enabled = true;
  664. rACCDESC.Enabled = true;
  665. }
  666. else if (cheACC.Checked == false)
  667. {
  668. txtACCAMOUNT.Enabled = false;
  669. txtACCNUM.Enabled = false;
  670. rACCDESC.Enabled = false;
  671. }
  672. }
  673. #endregion
  674. #region 合格 按钮值 合格时
  675. private void radQUA_CheckedChanged(object sender, EventArgs e)
  676. {
  677. if (radQUA.Checked == true)
  678. {
  679. txtQUADESC.Text = "";
  680. txtECG.Text = "";
  681. btnEC.Text = "";
  682. cheACC.Text = "";
  683. if (cheACC.Checked == true)
  684. {
  685. cheACC.Checked = false;
  686. txtACCAMOUNT.Text="";
  687. txtACCNUM.Text="";
  688. rACCDESC.Text = "";
  689. }
  690. txtQUADESC.Enabled = false;
  691. txtECG.Enabled = false;
  692. btnEC.Enabled = false;
  693. cheACC.Enabled = false;
  694. }
  695. else
  696. {
  697. txtQUADESC.Enabled = true;
  698. txtECG.Enabled = true;
  699. txtECNUM.Enabled = true;
  700. txtSAMAMOUNT.Enabled = true;
  701. txtPARTAMOUNT.Enabled = true;
  702. btnEC.Enabled = true;
  703. cheACC.Enabled = true;
  704. comAQLNORM.Enabled = true;
  705. }
  706. }
  707. #endregion
  708. #region 不合格按钮值 改变时
  709. private void radNOTQUA_CheckedChanged(object sender, EventArgs e)
  710. {
  711. if (radNOTQUA.Checked == true)
  712. {
  713. string s = "select ECGCODE from ICSECG as a,ICSASNIQCDETAIL as b where b.ID='" + guid + "' and b.ITEMCODE=a.RESCODE and a.WorkPoint='" + AppConfig.WorkPointCode + "' and b.WorkPoint='" + AppConfig.WorkPointCode + "'";
  714. DataTable dy = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, s).Tables[0];
  715. if (dy.Rows.Count!=0)
  716. {
  717. txtECG.Text = dy.Rows[0][0].ToString();
  718. }
  719. }
  720. else
  721. {
  722. txtECG.Text = "";
  723. }
  724. }
  725. #endregion
  726. #region 检验项目
  727. private void btnSERVER_Click(object sender, EventArgs e)
  728. {
  729. if (txtITEMCODE.Text == "")
  730. {
  731. ICSBaseSimpleCode.AppshowMessageBox("[测试项目组]的值无效!");
  732. }
  733. else
  734. {
  735. //FormLISTAdd add = new FormLISTAdd(txtITEMCODE.Text);
  736. FormLISTAdd add = new FormLISTAdd(txtCODE.Text,txtITEMCODE.Text);
  737. add.ShowDialog();
  738. }
  739. }
  740. #endregion
  741. }
  742. }