华恒Mes鼎捷代码
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.

2000 lines
90 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 System.Data.SqlClient;
  10. using System.Windows.Forms;
  11. using DevExpress.XtraEditors;
  12. using DevExpress.XtraGrid.Views.BandedGrid;
  13. using DevExpress.XtraGrid.Columns;
  14. using DevExpress.XtraGrid;
  15. using System.IO;
  16. using System.Threading;
  17. using ICSSoft.Base.Language.Tool;
  18. using ICSSoft.Base.Config.AppConfig;
  19. using ICSSoft.Base.UserControl.MessageControl;
  20. using ICSSoft.Base.Config.DBHelper;
  21. using ICSSoft.Base.Report.Filter;
  22. using ICSSoft.Base.UserControl.FormControl;
  23. using ICSSoft.Base.Report.GridReport;
  24. using ICSSoft.Base.ReferForm.AppReferForm;
  25. using ICSSoft.Frame.Data.BLL;
  26. using System.Collections;
  27. using ICSSoft.Frame.Data.Entity;
  28. using ICSSoft.Frame.Common;
  29. namespace ICSSoft.Frame.APP
  30. {
  31. public partial class FormICSLLAGV : DevExpress.XtraEditors.XtraForm
  32. {
  33. //ZHCSoft.AntiwearValveExpanded.Forms.UserControlAdds.UserControlLL UserControlLL;
  34. //ZHCSoft.AntiwearValveExpanded.Forms.UserControlAdds.UserControlLLNew UserControlLLNew;
  35. public DataTable dt;
  36. private string WGCode = ""; //外观
  37. private string CCCode = ""; //尺寸
  38. private string LHCode = ""; //理化
  39. public int GXOrWW = 0;
  40. private string CKType = "工序检验";
  41. public string ItemCode = string.Empty;
  42. public string LotNo = string.Empty;
  43. public string OPCode = string.Empty;
  44. public string MOCode = string.Empty;
  45. public string MOPLANQTY = string.Empty;
  46. public string INVDESC = string.Empty;
  47. public string ItemCode_ = string.Empty;
  48. public string LotNo_ = string.Empty;
  49. public string OPCode_ = string.Empty;
  50. public string MOCode_ = string.Empty;
  51. public string MOPLANQTY_ = string.Empty;
  52. public string INVDESC_ = string.Empty;
  53. public string LOTQTY_ = string.Empty;
  54. #region 构造函数
  55. //public FormICSLL()
  56. //{
  57. // InitializeComponent();
  58. // this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  59. // this.WindowState = FormWindowState.Maximized;
  60. // GetJianYan();
  61. //}
  62. #endregion
  63. #region 获取 外观,尺寸,理化 编号
  64. private void GetJianYan()
  65. {
  66. string sql = @"
  67. select Enumvalue,EnumText from Sys_EnumValues
  68. where EnumKey='005' and EnumText=''
  69. select Enumvalue,EnumText from Sys_EnumValues
  70. where EnumKey='005' and EnumText=''
  71. select Enumvalue,EnumText from Sys_EnumValues
  72. where EnumKey='005' and EnumText='' ";
  73. DataSet ds = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql);
  74. if (ds != null && ds.Tables.Count == 3)
  75. {
  76. if (ds.Tables[0].Rows.Count > 0)
  77. {
  78. WGCode = ds.Tables[0].Rows[0]["Enumvalue"].ToString();
  79. }
  80. else
  81. {
  82. MessageBox.Show("自定义档案:质量一级分类中未维护外观检验,请先维护");
  83. }
  84. if (ds.Tables[1].Rows.Count > 0)
  85. {
  86. CCCode = ds.Tables[1].Rows[0]["Enumvalue"].ToString();
  87. }
  88. else
  89. {
  90. MessageBox.Show("自定义档案:质量一级分类中未维护尺寸检验,请先维护");
  91. }
  92. if (ds.Tables[2].Rows.Count > 0)
  93. {
  94. LHCode = ds.Tables[2].Rows[0]["Enumvalue"].ToString();
  95. }
  96. else
  97. {
  98. MessageBox.Show("自定义档案:质量一级分类中未维护理化检验,请先维护");
  99. }
  100. }
  101. else
  102. {
  103. MessageBox.Show("自定义档案:质量一级分类中未维护外观检验,尺寸检验,理化检验,请先维护。");
  104. }
  105. }
  106. #endregion
  107. //public FormICSLL(ZHCSoft.AntiwearValveExpanded.Forms.UserControlAdds.UserControlLL userControlLL)
  108. public FormICSLLAGV(int IsWW)
  109. {
  110. InitializeComponent();
  111. this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  112. this.WindowState = FormWindowState.Maximized;
  113. this.ActiveControl = this.txtLotNo;
  114. //GetJianYan();
  115. //UserControlLL = userControlLL;
  116. cboStatus.Items.Add("已检测");
  117. cboStatus.Items.Add("未检测");
  118. cboStatus.Items.Add("所有");
  119. cboStatus.SelectedIndex =1;
  120. //SearchSource(IsWW);
  121. GXOrWW = IsWW;
  122. //ItemCode = ItemCode_; LotNo = LotNo_; OPCode = OPCode_;
  123. //MOCode = MOCode_; MOPLANQTY = MOPLANQTY_; INVDESC = INVDESC_;
  124. btnSearch_Click(null, null);
  125. foreach (GridColumn column in grvDetail.Columns) {
  126. if (column.Name != colisSelect.Name && column.Name != colDown.Name && column.Name != colSend.Name)
  127. column.OptionsColumn.AllowEdit = false;
  128. }
  129. }
  130. //public FormICSLL(ZHCSoft.AntiwearValveExpanded.Forms.UserControlAdds.UserControlLLNew userControlLLNew)
  131. public FormICSLLAGV()
  132. {
  133. InitializeComponent();
  134. this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  135. this.WindowState = FormWindowState.Maximized;
  136. this.ActiveControl = this.txtLotNo;
  137. //GetJianYan();
  138. //txtFW.Checked = true;
  139. cboStatus.Items.Add("已检测");
  140. cboStatus.Items.Add("未检测");
  141. cboStatus.Items.Add("所有");
  142. cboStatus.SelectedIndex =1;
  143. btnSearch_Click(null, null);
  144. this.grvDetail.BestFitColumns();
  145. foreach (GridColumn column in grvDetail.Columns)
  146. {
  147. if (column.Name != colisSelect.Name&& column.Name != colDown.Name&& column.Name != colSend.Name)
  148. column.OptionsColumn.AllowEdit = false;
  149. }
  150. }
  151. //--LEFT JOIN ICSMO2User rr ON 备注栏位1是委外,备注栏位0是自制,
  152. private DataTable SearchSource(string whereStr)
  153. {
  154. string sql = @"SELECT DISTINCT
  155. CAST ( 0 AS BIT ) AS isSelect,--e.ID,
  156. a.MOCODE,a.MOSEQ,a.LOTNO,a.LOTQTY,c.MOPLANQTY,a.ITEMCODE,b.INVNAME INVDESC,b.INVSTD,a.UserCodeEnd,a.MTIME,a.EQPCODE,f.EQPDESC,a.OPCODE,d.OPDESC,
  157. e.ckusercode as ,E.MTIME AS ,
  158. CASE WHEN e.CKResult = '1' THEN '' WHEN e.CKResult = '0' THEN '' ELSE '' END AS Result,
  159. CASE WHEN ISNULL( e.CKResult , '' ) = '' THEN '' ELSE '' END AS [Status]
  160. FROM ICSLOTONWIP a
  161. LEFT JOIN ICSINVENTORY b ON a.ITEMCODE=b.INVCODE
  162. LEFT JOIN ICSMO c ON a.MOCODE=c.MOCODE AND a.MOSEQ=c.MOSEQ
  163. LEFT JOIN ICSOP d ON a.OPCODE=d.OPCODE
  164. LEFT JOIN ICSQualityCKDATA e ON e.LOTNO=a.LOTNO AND e.OPCode=a.OPCODE
  165. LEFT JOIN ICSEquipment f ON a.EQPCODE=f.EQPCode
  166. LEFT JOIN ICSMO2User rr ON rr.LOTNO=a.LOTNO AND rr.OPCODE=a.OPCODE
  167. WHERE a.WorkPoint='{0}' AND b.WorkPoint='{0}' AND c.WorkPoint='{0}' AND d.WorkPoint='{0}' AND a.ACTIONRESULT='COLLECT_END' and a.EATTRIBUTE1 is null and not exists(select id from ICSNCRDoc where LOTNO=A.LOTNO AND OPCODE=A.OPCODE AND NGQTY>0 AND ERRORTYPE='') and c.mostatus<>'' {1} ORDER BY a.LOTNO,a.MOSEQ ";
  168. sql = string.Format(sql, AppConfig.WorkPointCode, whereStr);
  169. dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  170. //txtCount.Text = dt.Rows.Count.ToString();
  171. //DataRow[] drsChecked = dt.Select("Status='已检测'");
  172. //txtChecked.Text = drsChecked.Length.ToString();
  173. //DataRow[] drsUnChecked = dt.Select("Status='未检测'");
  174. //txtUnchecked.Text = drsUnChecked.Length.ToString();
  175. //DataRow[] drstDisqualification = dt.Select("Result='不合格'");
  176. //txtdisqualification.Text = drstDisqualification.Length.ToString();
  177. return dt;
  178. }
  179. private DataTable SearchSourceWW(string whereStr)
  180. {
  181. //ICSLOTONWIP 还要加上这张表串联20120712
  182. string sql = @"SELECT DISTINCT
  183. CAST (0 AS BIT) AS isSelect,--e.ID,
  184. rr.MOCODE, ff.LOTQTY,
  185. a.UserCodeEnd,a.MTIME,
  186. rr.MOSEQ,
  187. rr.LOTNO,
  188. c.MOPLANQTY,
  189. c.ITEMCODE,
  190. b.INVName INVDESC,
  191. b.INVSTD,
  192. rr.OPCODE,
  193. d.OPDESC,
  194. e.ckusercode as ,E.MTIME AS ,
  195. CASE WHEN e.CKResult = '1' THEN '' WHEN e.CKResult = '0' THEN '' ELSE '' END AS Result,
  196. CASE WHEN ISNULL(e.CKResult, '') = '' THEN '' ELSE '' END AS [Status]
  197. FROM
  198. ICSLOTONWIP a
  199. left join icsmo2user rr on rr.lotno=a.lotno and a.opcode=rr.opcode
  200. LEFT JOIN ICSITEMLot ff ON rr.LOTNO=ff.LotNO
  201. LEFT JOIN ICSMO c ON rr.MOCODE = c.MOCODE AND rr.MOSEQ = c.MOSEQ
  202. LEFT JOIN ICSINVENTORY b ON c.ITEMCODE = b.INVCODE
  203. LEFT JOIN ICSOP d ON rr.OPCODE = d.OPCODE
  204. LEFT JOIN ICSQualityCKDATA e ON e.LOTNO = rr.LOTNO AND e.OPCode = rr.OPCODE
  205. WHERE rr.WorkPoint='{0}' AND b.WorkPoint='{0}' AND c.WorkPoint='{0}' AND d.WorkPoint='{0}' AND rr.EATTRIBUTE1 = '1' and a.actionresult='COLLECT_END' and a.EATTRIBUTE1 is null {1} and c.mostatus<>'' ORDER BY rr.LOTNO,rr.MOSEQ ";
  206. sql = string.Format(sql, AppConfig.WorkPointCode, whereStr);
  207. dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  208. return dt;
  209. }
  210. #region 移动窗体
  211. private const int WM_NCHITTEST = 0x84;
  212. private const int HTCLIENT = 0x1;
  213. private const int HTCAPTION = 0x2;
  214. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  215. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  216. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  217. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  218. //重写窗体,使窗体可以不通过自带标题栏实现移动
  219. protected override void WndProc(ref Message m)
  220. {
  221. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  222. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  223. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  224. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  225. switch (m.Msg)
  226. {
  227. case WM_NCHITTEST:
  228. base.WndProc(ref m);
  229. if ((int)m.Result == HTCLIENT)
  230. m.Result = (IntPtr)HTCAPTION;
  231. return;
  232. }
  233. //拦截双击标题栏、移动窗体的系统消息
  234. if (m.Msg != 0xA3)
  235. {
  236. base.WndProc(ref m);
  237. }
  238. }
  239. #endregion
  240. #region SystemOptition
  241. /// <summary>
  242. /// 操作权限
  243. /// </summary>
  244. /// <returns></returns>
  245. public DataTable RightOfExute()
  246. {
  247. DataTable rData = new DataTable();
  248. rData.Columns.Add("BtnName");
  249. rData.Columns.Add("ActionName");
  250. //查看权限(必须有)
  251. DataRow seeRow = rData.NewRow();
  252. seeRow["BtnName"] = "see";
  253. seeRow["ActionName"] = "查看";
  254. rData.Rows.Add(seeRow);
  255. List<Control> ControlList = new List<Control>();
  256. //ControlList.Add(btnDelLable);
  257. foreach (Control ctr in ControlList)
  258. {
  259. if (ctr.GetType() == typeof(SimpleButton))
  260. {
  261. DataRow dr = rData.NewRow();
  262. dr["BtnName"] = ctr.Name;
  263. dr["ActionName"] = ctr.Text;
  264. rData.Rows.Add(dr);
  265. }
  266. }
  267. rData.AcceptChanges();
  268. return rData;
  269. }
  270. /// <summary>
  271. /// 数据权限
  272. /// </summary>
  273. /// <returns></returns>
  274. public DataTable RightOfData()
  275. {
  276. DataTable rData = new DataTable();
  277. rData.Columns.Add("BodyName");
  278. rData.Columns.Add("ControlName");
  279. rData.Columns.Add("ControlCaption");
  280. rData.AcceptChanges();
  281. return rData;
  282. }
  283. #endregion
  284. #region 退出
  285. private void btnClose_Click(object sender, EventArgs e)
  286. {
  287. AppConfig.CloseFormShow(this.Text);
  288. this.Close();
  289. }
  290. private void btnExit_Click(object sender, EventArgs e)
  291. {
  292. AppConfig.CloseFormShow(this.Text);
  293. this.Close();
  294. }
  295. #endregion
  296. #region 列表
  297. private void grvDetail_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
  298. {
  299. if (e.Info.IsRowIndicator && e.RowHandle >= 0)
  300. e.Info.DisplayText = (e.RowHandle + 1).ToString();
  301. }
  302. #endregion
  303. #region 双击选择
  304. private void grvDetail_DoubleClick(object sender, EventArgs e)
  305. {
  306. if (grvDetail.FocusedRowHandle < 0)
  307. {
  308. return;
  309. }
  310. //UserControlLL.LotNo = grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colLOTNO).ToString();
  311. //UserControlLL.participant = grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colparticipant).ToString();
  312. //UserControlLLNew.LotNo = grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colLOTNO).ToString();
  313. string __LotNo = grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colLOTNO).ToString();
  314. string __OPCode = grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colOPCODE).ToString();
  315. string __ItemCode = grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colITEMCODE).ToString();
  316. string __MOCode = grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colMOCode).ToString();
  317. string __MOPLANQTY = grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colMOPLANQTY).ToString();
  318. string __INVDESC = grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colINVDESC).ToString();
  319. string __LOTQTY = grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colLOTQTY).ToString();
  320. ItemCode_ = __ItemCode; LotNo_ = __LotNo; OPCode_ = __OPCode;
  321. INVDESC_ = __INVDESC; MOCode_ = __MOCode; MOPLANQTY_ = __MOPLANQTY;
  322. LOTQTY_ = __LOTQTY;
  323. this.Close();
  324. //FormICSIPQC form = new FormICSIPQC(ItemCode, LotNo, OPCode);
  325. //form.ShowDialog();
  326. }
  327. //质检 即双击
  328. //private void but_ZhiJIan_Click(object sender, EventArgs e)
  329. //{
  330. //int SelectIndex = -1;
  331. //int Selectcount = 0;
  332. //for (int i = 0; i < grvDetail.RowCount; i++)
  333. //{
  334. // string isselect = grvDetail.GetRowCellValue(i, colisSelect).ToString();
  335. // if (isselect == "True")
  336. // {
  337. // SelectIndex = i;
  338. // Selectcount++;
  339. // }
  340. //}
  341. //if (Selectcount == 1)
  342. //{
  343. // //UserControlLLNew.LotNo = grvDetail.GetRowCellValue(SelectIndex, colLOTNO).ToString();
  344. // this.Close();
  345. //}
  346. //else
  347. //{
  348. // MessageBox.Show("有且只能选择一行进行质检");
  349. //}
  350. //}
  351. #endregion
  352. #region 行背景色
  353. private void grvDetail_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
  354. {
  355. if (e.RowHandle < 0)
  356. return;
  357. string result = grvDetail.GetRowCellValue(e.RowHandle, colResult).ToString();
  358. if (result.Equals("合格"))
  359. {
  360. e.Appearance.BackColor = Color.Green;
  361. }
  362. if (result.Equals("不合格"))
  363. {
  364. e.Appearance.BackColor = Color.Red;
  365. }
  366. string status = grvDetail.GetRowCellValue(e.RowHandle, colState).ToString();
  367. //string remainingTime = grvDetail.GetRowCellValue(e.RowHandle, colremainingTime).ToString();
  368. //if (status == "未检测" && remainingTime == "00:00")
  369. if (status == "未检测")
  370. {
  371. if (cboStatus.SelectedIndex == 1)
  372. {
  373. if (e.RowHandle % 2 == 0)
  374. e.Appearance.BackColor = Color.White;
  375. else
  376. e.Appearance.BackColor = Color.FromArgb(235, 248, 255);
  377. }
  378. else {
  379. e.Appearance.BackColor = Color.FromArgb(235, 248, 255);
  380. }
  381. }
  382. }
  383. #endregion
  384. private void btnSearch_Click(object sender, EventArgs e)
  385. {
  386. string whereStr = "";
  387. //if (GXOrWW == 0)
  388. //{
  389. // whereStr += " AND (a.SHIFTTYPECODE= '' or a.SHIFTTYPECODE is null) ";
  390. //}
  391. //else
  392. //{
  393. // whereStr += " AND a.SHIFTTYPECODE= 'WW' ";
  394. //}
  395. if (GXOrWW == 0)
  396. {
  397. whereStr += " AND (a.SHIFTTYPECODE= '' or a.SHIFTTYPECODE is null) AND rr.EATTRIBUTE1='0' ";
  398. }
  399. else
  400. {
  401. //whereStr += " AND a.SHIFTTYPECODE= 'WW' AND rr.EATTRIBUTE1='1' ";
  402. whereStr += " AND rr.EATTRIBUTE1='1' ";
  403. }
  404. if (!string.IsNullOrWhiteSpace(txtMOCode.Text.Trim()))
  405. {
  406. if (GXOrWW == 0) {
  407. whereStr += " AND a.MOCODE LIKE '%" + txtMOCode.Text.Trim() + "%' ";
  408. //whereStr1 = " AND LOTNO LIKE '%" + txtMOCode.Text.Trim() + "%' ";
  409. }
  410. else {
  411. whereStr += " AND rr.MOCODE LIKE '%" + txtMOCode.Text.Trim() + "%' ";
  412. }
  413. }
  414. if (txtFW.Checked) {
  415. whereStr += " AND a.mtime BETWEEN " + "'" + Convert.ToDateTime(txtDateBegin.Text).ToString("yyyy-MM-dd") + "'" + " AND " + "'" + Convert.ToDateTime(txtDateEnd.Text).ToString("yyyy-MM-dd") + "'";
  416. }
  417. if (!string.IsNullOrEmpty(txtOPName.Text.Trim())){
  418. whereStr += " AND d.OPDESC LIKE '%" + txtOPName.Text.Trim() + "%' ";
  419. }
  420. if (!string.IsNullOrEmpty(txtItemName.Text.Trim()))
  421. {
  422. whereStr += " AND b.INVName LIKE '%" + txtItemName.Text.Trim() + "%' ";
  423. }
  424. if (GXOrWW == 0)
  425. {
  426. if (!string.IsNullOrWhiteSpace(this.txtLotNo.Text.Trim()))
  427. {
  428. whereStr += " AND a.LOTNO LIKE '%" + txtLotNo.Text.Trim() + "%' ";
  429. }
  430. }
  431. else
  432. {
  433. if (!string.IsNullOrWhiteSpace(this.txtLotNo.Text.Trim()))
  434. {
  435. whereStr += " AND rr.LOTNO LIKE '%" + txtLotNo.Text.Trim() + "%' ";
  436. }
  437. }
  438. if (!string.IsNullOrWhiteSpace(txtItemCode.Text.Trim()))
  439. {
  440. if (GXOrWW == 0)
  441. {
  442. whereStr += " AND a.ITEMCODE LIKE '%" + txtItemCode.Text.Trim() + "%' ";
  443. //whereStr1 += " AND ItemName LIKE '%" + txtItemCode.Text.Trim() + "%' ";
  444. }
  445. else {
  446. whereStr += " AND c.ITEMCODE LIKE '%" + txtItemCode.Text.Trim() + "%' ";
  447. }
  448. }
  449. if (!string.IsNullOrWhiteSpace(this.txtOPCode.Text.Trim()))
  450. {
  451. if (GXOrWW == 0)
  452. {
  453. whereStr += " AND a.OPCODE LIKE '%" + txtOPCode.Text.Trim() + "%' ";
  454. //whereStr1 += " AND ItemName LIKE '%" + txtItemCode.Text.Trim() + "%' ";
  455. }
  456. else {
  457. whereStr += " AND rr.OPCODE LIKE '%" + txtOPCode.Text.Trim() + "%' ";
  458. }
  459. }
  460. if (!string.IsNullOrWhiteSpace(cboStatus.Text.Trim()))
  461. {
  462. switch (cboStatus.Text.Trim())
  463. {
  464. case "所有":
  465. break;
  466. case "未检测":
  467. whereStr += " AND ISNULL( e.CKResult , '' ) = '' ";
  468. break;
  469. case "已检测":
  470. whereStr += " AND ISNULL( e.CKResult , '' )<>'' ";
  471. break;
  472. }
  473. }
  474. if (GXOrWW == 1)
  475. {
  476. grdDetail.DataSource = SearchSourceWW(whereStr);
  477. }
  478. else
  479. {
  480. grdDetail.DataSource = SearchSource(whereStr);
  481. }
  482. grvDetail.BestFitColumns();
  483. //grvDetail.BestFitColumns();
  484. //grdDetail.MainView.PopulateColumns();
  485. //grdDetail.RefreshDataSource();
  486. //grdDetail.Refresh();
  487. //grvDetail.RefreshData();
  488. //DataView dv1 = dt.Copy().DefaultView;
  489. //dv1.RowFilter = whereStr1.Substring(whereStr1.IndexOf("AND") + 3);
  490. //DataTable dt1 = dv1.ToTable().Copy();
  491. //string docNo = "";
  492. //int count = 0;
  493. //int checkCount = 0;
  494. //int unCheckCount = 0;
  495. //int sisqualificationCount = 0;
  496. //foreach (DataRow dr in dt1.Rows)
  497. //{
  498. // if (docNo != dr["LOTNO"].ToString())
  499. // {
  500. // count++;
  501. // docNo = dr["LOTNO"].ToString();
  502. // if (dr["Result"].ToString() == "不合格")
  503. // {
  504. // sisqualificationCount++;
  505. // }
  506. // if (dr["Status"].ToString() == "已检测")
  507. // {
  508. // checkCount++;
  509. // }
  510. // else if (dr["Status"].ToString() == "未检测")
  511. // {
  512. // unCheckCount++;
  513. // }
  514. // }
  515. //}
  516. //txtCount.Text = count.ToString();
  517. //txtChecked.Text = checkCount.ToString();
  518. //txtUnchecked.Text = unCheckCount.ToString();
  519. //txtdisqualification.Text = sisqualificationCount.ToString();
  520. }
  521. #region 页面加载
  522. private void FormICSLL_Load(object sender, EventArgs e)
  523. {
  524. //colWGQty.Caption = "外观抽\r\n检数量";
  525. //colCCQty.Caption = "尺寸抽\r\n检数量";
  526. //colLHQty.Caption = "理化抽\r\n检数量";
  527. //colWGRequireQty.Caption = "外观抽\r\n检数量";
  528. //colCCRequireQty.Caption = "尺寸抽\r\n检数量";
  529. //colLHRequireQty.Caption = "理化抽\r\n检数量";
  530. }
  531. #endregion
  532. private void repositoryItemButtonEdit1_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  533. {
  534. //try
  535. //{
  536. // DevExpress.XtraGrid.Views.Grid.GridView view = ((DevExpress.XtraGrid.Views.Grid.GridView)(grdDetail.MainView));
  537. // int rowhandle = view.FocusedRowHandle;
  538. // DataRow dr = view.GetDataRow(rowhandle);
  539. // if (dr["LOTNO"].ToString() == "")
  540. // {
  541. // ICSBaseSimpleCode.AppshowMessageBox("批次条码不能为空!");
  542. // return;
  543. // }
  544. // List<ICSQualityCKDATA> codeList = new List<ICSQualityCKDATA>();
  545. // ICSQualityCKDATA ckData = new ICSQualityCKDATA();
  546. // ckData.LOTNO = dr["LOTNO"].ToString();
  547. // codeList.Add(ckData);
  548. // ICSQualityCKDATABLL.AddThrough(codeList, AppConfig.AppConnectString);
  549. // ICSBaseSimpleCode.AppshowMessageBox(0, "放行成功!");
  550. // btnSearch_Click(null, null);
  551. //}
  552. //catch (Exception ex)
  553. //{
  554. // MessageBox.Show(ex.Message);
  555. //}
  556. }
  557. private void cboStatus_SelectedValueChanged(object sender, EventArgs e)
  558. {
  559. if (cboStatus.Text == "已检测")
  560. {
  561. // grvDetail.Columns["isSelect"].Visible = false;
  562. grvDetail.Columns["isSelect"].Visible = true;//modify on 20190722
  563. }
  564. if (cboStatus.Text == "未检测")
  565. {
  566. grvDetail.Columns["isSelect"].Visible = true;
  567. }
  568. //dt = SearchSource();
  569. //btnSearch_Click(null, null);
  570. }
  571. #region 批量放行
  572. //private void btnOK_Click(object sender, EventArgs e)
  573. //{
  574. // try
  575. // {
  576. // List<string> ht = new List<string>();
  577. // List<string> UnCKLotno = new List<string>();
  578. // List<string> UnCKRCV = new List<string>();
  579. // List<string> IsCKedCK = new List<string>();
  580. // List<ICSQualityCKDATA> codeList = new List<ICSQualityCKDATA>();
  581. // List<WMSICSINSPECTIONModel> InsList = new List<WMSICSINSPECTIONModel>();
  582. // List<ICSLLDisposeInFoAgain> modelList = new List<ICSLLDisposeInFoAgain>();
  583. // for (int i = 0; i < grvDetail.RowCount; i++)
  584. // {
  585. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "True")
  586. // {
  587. // //string docNo = grvDetail.GetRowCellValue(i, colRcvDocNo).ToString();
  588. // string lotno = grvDetail.GetRowCellValue(i, colLOTNO).ToString(); ;
  589. // string MOCode = grvDetail.GetRowCellValue(i, colMOCode).ToString(); ;
  590. // //string IsCanCK = grvDetail.GetRowCellValue(i, colIsCanCK).ToString();
  591. // //string WGCK = grvDetail.GetRowCellValue(i, colIsCKWG).ToString();
  592. // //string CCCK = grvDetail.GetRowCellValue(i, colIsCKCC).ToString();
  593. // //string LHCK = grvDetail.GetRowCellValue(i, colIsCKLH).ToString();
  594. // //if (IsCanCK != "OK")
  595. // //{
  596. // //if (!UnCKRCV.Contains(docNo))
  597. // //{
  598. // // UnCKRCV.Add(docNo);
  599. // //}
  600. // //}
  601. // //else if (WGCK == "N" || CCCK == "N" || LHCK == "N")
  602. // //{
  603. // // if (!UnCKLotno.Contains(lotno))
  604. // // {
  605. // // UnCKLotno.Add(lotno);
  606. // // }
  607. // //}
  608. // //else
  609. // //{
  610. // //bool IsCK = ICSQualityCKDATABLL.IsLLCKByLotNo(lotno);
  611. // //if (IsCK)
  612. // //{
  613. // // IsCKedCK.Add(lotno);
  614. // //}
  615. // //else
  616. // //{
  617. // ICSQualityCKDATA ckData = new ICSQualityCKDATA();
  618. // ckData.LOTNO = lotno;
  619. // ckData.MOCODE = MOCode;
  620. // if (!string.IsNullOrWhiteSpace(grvDetail.GetRowCellValue(i, colOPCODE).ToString()))
  621. // {
  622. // ckData.OPCode = grvDetail.GetRowCellValue(i, colOPCODE).ToString();
  623. // }
  624. // codeList.Add(ckData);
  625. // //string lineNo = grvDetail.GetRowCellValue(i, colRcvLineNo).ToString();
  626. // //if (ht.Contains(docNo + "_" + lineNo))
  627. // //{
  628. // // ht.Add(docNo + "_" + lineNo);
  629. // //}
  630. // ICSLLDisposeInFoAgain model = new ICSLLDisposeInFoAgain();
  631. // //物料条码
  632. // model.LOTNO = lotno;
  633. // //物料编码
  634. // model.ItemCode = grvDetail.GetRowCellValue(i, colITEMCODE).ToString();
  635. // //物料名称
  636. // model.ItemName = grvDetail.GetRowCellValue(i, colINVDESC).ToString();
  637. // //条码数量
  638. // model.BarCodeQty = Convert.ToDecimal(grvDetail.GetRowCellValue(i, colLOTQTY).ToString());
  639. // //处理数量
  640. // model.DisposeInQty = Convert.ToDecimal(grvDetail.GetRowCellValue(i, colLOTQTY).ToString());
  641. // //采购订单号
  642. // //model.DocNo = grvDetail.GetRowCellValue(i, colPoDocNo).ToString();
  643. // model.MUSER = AppConfig.UserId;
  644. // model.MUSERName = AppConfig.UserName;
  645. // model.MTIME = DateTime.Now;
  646. // model.WorkPoint = AppConfig.WorkPointCode;
  647. // model.EATTRIBUTE1 = "制程";
  648. // modelList.Add(model);
  649. // WMSICSINSPECTIONModel ins = new WMSICSINSPECTIONModel();
  650. // ins.LotNO = lotno;
  651. // ins.INVCODE = grvDetail.GetRowCellValue(i, colITEMCODE).ToString();
  652. // ins.VENDORITEMCODE = grvDetail.GetRowCellValue(i, colITEMCODE).ToString();
  653. // ins.LOTQTY = Convert.ToDecimal(grvDetail.GetRowCellValue(i, colLOTQTY).ToString());
  654. // ins.YLOTQTY = Convert.ToDecimal(grvDetail.GetRowCellValue(i, colLOTQTY).ToString());
  655. // //ins.TransNO = grvDetail.GetRowCellValue(i, colPOCode).ToString();
  656. // //ins.TransLine = grvDetail.GetRowCellValue(i, colPoLineNo).ToString();
  657. // ins.TYPE = "采购入库";
  658. // InsList.Add(ins);
  659. // //}
  660. // //}
  661. // }
  662. // }
  663. // //if (codeList.Count == 0 && UnCKRCV.Count == 0 && UnCKLotno.Count == 0 && IsCKedCK.Count == 0)
  664. // if (codeList.Count == 0)
  665. // {
  666. // ICSBaseSimpleCode.AppshowMessageBox("请选择需要放行的批次条码!");
  667. // return;
  668. // }
  669. // //提示
  670. // string Mess = "";
  671. // if (UnCKRCV.Count != 0)
  672. // {
  673. // Mess += "以下到货单未达到抽检比例,不能放行:" + string.Join(",", UnCKRCV.ToArray()) + Environment.NewLine;
  674. // }
  675. // if (UnCKLotno.Count != 0)
  676. // {
  677. // Mess += "以下批次质检不合格,不能放行,只能判退:" + string.Join(",", UnCKLotno.ToArray()) + Environment.NewLine;
  678. // }
  679. // if (IsCKedCK.Count != 0)
  680. // {
  681. // Mess += "以下批次已放行/判退,不能再次放行:" + string.Join(",", IsCKedCK.ToArray()) + Environment.NewLine;
  682. // }
  683. // if (Mess != "")
  684. // {
  685. // ICSBaseSimpleCode.AppshowMessageBox(Mess);
  686. // }
  687. // if (codeList.Count != 0)
  688. // {
  689. // ICSQualityCKDATABLL.AddThrough(codeList, AppConfig.AppConnectString);
  690. // //待定,需要看无锡自控代码
  691. // //等于来料日志,放行日志
  692. // ICSLLDisposeInFoBLL.LLDisposeAgainEditByLOTNO(modelList, AppConfig.AppConnectString);
  693. // //SRM用到的,可以注释
  694. // //ICSQualityCKDATABLL.InsertICSINSPECTION(InsList);
  695. // ICSBaseSimpleCode.AppshowMessageBox(0, "放行成功!");
  696. // }
  697. // //判断是否全部检查完毕
  698. // foreach (string str in ht)
  699. // {
  700. // string docNo = str.Split('_')[0];
  701. // string lineNo = str.Split('_')[1];
  702. // if (ICSQualityCKDATABLL.ISAllCheck(docNo, lineNo, AppConfig.AppConnectString))
  703. // {
  704. // DataTable dt1 = GetNGCKData(docNo, lineNo);
  705. // string ItemCode = dt1.Rows[0]["RcvLineItemMasterCode"].ToString();
  706. // string ItemName = dt1.Rows[0]["RcvLineItemMasterName"].ToString();
  707. // string ProjectCode = dt1.Rows[0]["RcvLineProjectCode"].ToString();
  708. // string LotFurnace = dt1.Rows[0]["RcvLineInvLotFurnace"].ToString();
  709. // decimal QTY = Convert.ToDecimal(dt1.Rows[0]["BarCodeQty"].ToString());
  710. // if (dt1 != null && dt1.Rows.Count > 0)
  711. // {
  712. // string strResult = "";
  713. // foreach (DataRow dr in dt1.Rows)
  714. // {
  715. // strResult += dr["LotNo"].ToString() + ":";
  716. // if (dr["Type"].ToString() == WGCode)
  717. // {
  718. // strResult += "外观检验项:" + dr["CKITEMDESC"].ToString() + "不良 检测值为" + dr["CKValue"].ToString() + "\r\n";
  719. // }
  720. // else if (dr["Type"].ToString() == CCCode)
  721. // {
  722. // strResult += "尺寸检验项:" + dr["CKITEMCODE"].ToString() + " " + dr["CKITEMDESC"].ToString() + "不良,系统要求最小值" + dr["SetValueMin"].ToString()
  723. // + "最大值" + dr["SetValueMax"].ToString() + "检测值为" + dr["CKValue"].ToString() + "\r\n";
  724. // }
  725. // else if (dr["Type"].ToString() == LHCode)
  726. // {
  727. // strResult += "理化检验项:" + dr["CKITEMCODE"].ToString() + " " + dr["CKITEMDESC"].ToString() + "不良,系统要求最小值" + dr["SetValueMin"].ToString()
  728. // + "最大值" + dr["SetValueMax"].ToString() + "检测值为" + dr["CKValue"].ToString() + "\r\n";
  729. // }
  730. // }
  731. // //SendNCR(strResult, docNo + "_" + lineNo, ItemCode, ItemName, ProjectCode, QTY);
  732. // }
  733. // DBHelper.ExecuteNonQuery(AppConfig.AppConnectString, CommandType.Text, " Update WM_RCVShip set RcvDocStatus = '10' where [RcvDocNo] = '" + docNo + "' And RcvLineNo = " + lineNo);
  734. // }
  735. // }
  736. // btnSearch_Click(null, null);
  737. // }
  738. // catch (Exception ex)
  739. // {
  740. // MessageBox.Show(ex.Message);
  741. // }
  742. //}
  743. #region 批量放行
  744. private void btnOK_Click(object sender, EventArgs e)
  745. {
  746. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在处理...请稍等...");
  747. try
  748. {
  749. List<string> codeList = new List<string>();
  750. List<string> moList = new List<string>();
  751. List<string> opList = new List<string>();
  752. String complete_Status = "";
  753. List<string> opaddList = new List<string>();
  754. List<ICSQualityCKDATA> dataList = new List<ICSQualityCKDATA>();
  755. List<ICSQualityCKDATA> dataList1 = new List<ICSQualityCKDATA>();
  756. for (int i = 0; i < grvDetail.RowCount; i++)
  757. {
  758. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "True")
  759. {
  760. ICSQualityCKDATA ckData = new ICSQualityCKDATA();
  761. ckData.LOTNO = grvDetail.GetRowCellValue(i, colLOTNO).ToString();
  762. ckData.MOCODE = grvDetail.GetRowCellValue(i, colMOCode).ToString();
  763. ckData.OPCode = grvDetail.GetRowCellValue(i, colOPCODE).ToString();
  764. //ckData.ID = grvDetail.GetRowCellValue(i, colID).ToString();
  765. string sql = "select max(opseq) as opseq from icsitemroute2oplot a where lotno='"+ckData.LOTNO+ "' and opseq<(select opseq from icsitemroute2oplot b where b.lotno='" + ckData.LOTNO + "' and b.opcode='"+ckData.OPCode+"' )";
  766. DataTable lastop = DBHelper.ExecuteDataset(AppConfig.AppConnectString,CommandType.Text,sql).Tables[0];
  767. if (lastop.Rows.Count > 0 && !string.IsNullOrEmpty(lastop.Rows[0]["opseq"].ToString()))
  768. {
  769. bool isOK = CheckIsOK(Convert.ToInt32(lastop.Rows[0]["opseq"]));
  770. if (!isOK)
  771. {
  772. _wait.Close();
  773. ICSBaseSimpleCode.AppshowMessageBox("上道工序未检验或检验结果不合格,不能判定!");
  774. return;
  775. }
  776. }
  777. dataList.Add(ckData);
  778. if (GXOrWW == 0)
  779. {
  780. #region 20210709下道工序开工,上道工序质量检验就不能判退或者放行,提示下道工序已开工
  781. string sqlCheck = @"SELECT b.OPSEQ FROM
  782. ICSITEMROUTE2OPLot b
  783. LEFT JOIN ICSLOTONWIP a ON b.OPCODE=a.OPCODE AND b.lotno=a.lotno
  784. WHERE a.LOTNO='" + ckData.LOTNO + "' and b.OPCODE='" + ckData.OPCode + "' ORDER BY OPSEQ";
  785. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sqlCheck).Tables[0];
  786. if (data != null && data.Rows.Count > 0)
  787. {
  788. int _OPSEQ = 0;
  789. string OPSEQ = data.Rows[0][0].ToString();
  790. // if (!string.IsNullOrWhiteSpace(OPSEQ))
  791. // {
  792. // _OPSEQ = Int32.Parse(OPSEQ) + 10;
  793. // }
  794. // string sqlDownOP = @"SELECT a.ACTIONRESULT,b.OPCODE,b.OPSEQ FROM
  795. // ICSROUTE2OP b
  796. // LEFT JOIN ICSLOTONWIP a ON b.OPCODE=a.OPCODE AND b.ROUTECODE=a.RouteCode
  797. // WHERE a.LOTNO='" + ckData.LOTNO + "' AND b.OPSEQ='" + _OPSEQ + "' ORDER BY OPSEQ";
  798. string sqlDownOP = @"SELECT a.ACTIONRESULT,b.OPCODE,b.OPSEQ FROM
  799. ICSITEMROUTE2OPLot b
  800. LEFT JOIN ICSLOTONWIP a ON b.OPCODE=a.OPCODE AND b.lotno=a.lotno
  801. WHERE a.LOTNO='" + ckData.LOTNO + "' AND b.OPSEQ>'" + OPSEQ + "' ORDER BY OPSEQ";
  802. DataTable _data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sqlDownOP).Tables[0];
  803. if (_data != null && _data.Rows.Count > 0)
  804. {
  805. _wait.Close();
  806. MessageBox.Show("下道工序已开工,不能执行放行,请核对!");
  807. return;
  808. }
  809. }
  810. else
  811. {
  812. _wait.Close();
  813. MessageBox.Show("当前工序没开工工序,不能执行放行,请核对!");
  814. return;
  815. }
  816. #endregion
  817. }
  818. string Status = grvDetail.GetRowCellValue(i, colState).ToString();
  819. if (Status == "已检测")
  820. {
  821. _wait.Close();
  822. ICSBaseSimpleCode.AppshowMessageBox("当前批次:" + ckData.LOTNO + ",工单:" + ckData.MOCODE + ",工序:" + ckData.OPCode + "已经检测,不能继续放行!");
  823. return;
  824. }
  825. codeList.Add(grvDetail.GetRowCellValue(i, colLOTNO).ToString());
  826. moList.Add(grvDetail.GetRowCellValue(i, colMOCode).ToString());
  827. opList.Add(grvDetail.GetRowCellValue(i, colOPCODE).ToString());
  828. String opadd = "";
  829. for (int j = 0; j < grvDetail.RowCount; j++)
  830. {
  831. if (grvDetail.GetRowCellValue(i, colLOTNO).ToString() == grvDetail.GetRowCellValue(j, colLOTNO).ToString() &&
  832. grvDetail.GetRowCellValue(i, colOPCODE).ToString() != grvDetail.GetRowCellValue(j, colOPCODE).ToString())
  833. {
  834. if (opadd == "")
  835. {
  836. opadd += "" + grvDetail.GetRowCellValue(j, colOPCODE).ToString();
  837. }
  838. else
  839. {
  840. opadd += "," + grvDetail.GetRowCellValue(j, colOPCODE).ToString();
  841. }
  842. }
  843. }
  844. opaddList.Add(opadd);
  845. bool status = LotComplete_New(grvDetail.GetRowCellValue(i, colLOTNO).ToString(), grvDetail.GetRowCellValue(i, colOPCODE).ToString(), grvDetail.GetRowCellValue(i, colMOCode).ToString());
  846. #region 20210818
  847. string sqlCheckICSLOTONWIP = @"SELECT COUNT(*) FROM ICSLOTONWIP WHERE LOTNO='" + ckData.LOTNO + "' AND OPCODE='" + ckData.OPCode + "' and ACTIONRESULT='COLLECT_END' ";
  848. DataTable dtCheckICSLOTONWIP = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sqlCheckICSLOTONWIP).Tables[0];
  849. if (dtCheckICSLOTONWIP != null && dtCheckICSLOTONWIP.Rows.Count > 0)
  850. {
  851. if (dtCheckICSLOTONWIP.Rows[0][0].ToString() == "0")
  852. {
  853. _wait.Close();
  854. ICSBaseSimpleCode.AppshowMessageBox("当前批次:" + ckData.LOTNO + ",工单:" + ckData.MOCODE + ",工序:" + ckData.OPCode + ",ICSLOTONWIP表中没有完工记录,请核对!");
  855. return;
  856. }
  857. }
  858. else
  859. {
  860. _wait.Close();
  861. ICSBaseSimpleCode.AppshowMessageBox("当前批次:" + ckData.LOTNO + ",工单:" + ckData.MOCODE + ",工序:" + ckData.OPCode + ",ICSLOTONWIP表中没有完工记录,请核对!");
  862. return;
  863. }
  864. #endregion
  865. }
  866. }
  867. if (codeList.Count == 0)
  868. {
  869. _wait.Close();
  870. ICSBaseSimpleCode.AppshowMessageBox("请选择需要放行的批次条码!");
  871. return;
  872. }
  873. //CKDATA_WX(codeList, moList, opList, opaddList);//20191114
  874. ICSQualityCKDATABLL.AddThroughOP(dataList, AppConfig.AppConnectString, GXOrWW);
  875. //判断是否最后一道工序
  876. //ICSQualityCKDATABLL.AddThroughZC(dataList1, AppConfig.AppConnectString);
  877. if (complete_Status != "")
  878. {
  879. ICSBaseSimpleCode.AppshowMessageBox(0, complete_Status);
  880. }
  881. _wait.Close();
  882. ICSBaseSimpleCode.AppshowMessageBox(0, "放行成功!");
  883. #region AGV调用
  884. StringBuilder errores = new StringBuilder("");
  885. foreach (var ckdata in dataList)
  886. {
  887. if (ICSAGVBLL.IsCanToAGV(ckdata.LOTNO, ckdata.OPCode, "AGV是否开启", AppConfig.AppConnectString, AppConfig.WorkPointCode))
  888. {
  889. try
  890. {
  891. ICSAGVTASKLOG Log = new ICSAGVTASKLOG();
  892. Log.ID = AppConfig.GetGuid();
  893. Log.Lotno = ckdata.LOTNO;
  894. Log.Opcode = ckdata.OPCode;
  895. bool Islastop = ICSAGVBLL.IsLastOP(Log.Lotno, Log.Opcode, AppConfig.AppConnectString, AppConfig.WorkPointCode);
  896. bool NextOpIsWW = ICSAGVBLL.NextOPisWW(Log.Lotno, Log.Opcode, AppConfig.AppConnectString, AppConfig.WorkPointCode);
  897. bool NextOpIsWG = ICSAGVBLL.NextOPisWG(Log.Lotno, Log.Opcode, AppConfig.AppConnectString, AppConfig.WorkPointCode);
  898. string Area = "";
  899. string CArea = "";
  900. //需要注意连续委外逻辑,当前工序和下道工序为连续委外,当前工序不触发AGV
  901. if (!(NextOpIsWW && GXOrWW == 1 && NextOpIsWG))
  902. {
  903. if (Islastop)
  904. {
  905. FormICSAGVAreaChoose Choose = new FormICSAGVAreaChoose();
  906. Choose.ShowDialog();
  907. Area = ICSAGVBLL.GetAreaCode("00088", "4", AppConfig.AppConnectString, AppConfig.WorkPointCode);
  908. CArea = Choose.AreaCode;
  909. if (string.IsNullOrEmpty(CArea))
  910. continue;
  911. Log.TaskType = "成品检合格";
  912. }
  913. else if (NextOpIsWW)
  914. {
  915. Area = ICSAGVBLL.GetAreaCode("00088", "6", AppConfig.AppConnectString, AppConfig.WorkPointCode);
  916. Log.TaskType = "质检合格下工序委外";
  917. }
  918. else
  919. {
  920. Area = ICSAGVBLL.GetAreaCode("00088", "2", AppConfig.AppConnectString, AppConfig.WorkPointCode);
  921. Log.TaskType = "质检合格";
  922. }
  923. string BeginArea = Area.Split('@')[0].Split(':')[0];
  924. string EndArea = "";
  925. if (Islastop)
  926. EndArea = CArea;
  927. else
  928. EndArea = Area.Split('@')[1].Split(':')[0];
  929. AgvAreaToAreaModel Model = new AgvAreaToAreaModel();
  930. Model.trackingNumber = ckdata.LOTNO;
  931. Model.area = EndArea;
  932. Log.Area = BeginArea;
  933. Log.EndArea = EndArea;
  934. Log.Mtime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  935. Log.MuserName = AppConfig.UserName;
  936. ICSAGVBLL.AgvAreaToArea(Model, Log, AppConfig.AppConnectString, AppConfig.WorkPointCode);
  937. }
  938. }
  939. catch (Exception ex)
  940. {
  941. errores.Append("AGV任务异常:" + ex.Message + "已跳过\r\n");
  942. continue;
  943. }
  944. }
  945. }
  946. if (!string.IsNullOrEmpty(errores.ToString()))
  947. {
  948. ICSBaseSimpleCode.AppshowMessageBox(errores.ToString());
  949. }
  950. #endregion
  951. btnSearch_Click(null, null);
  952. txtLotNo.Focus();
  953. txtLotNo.SelectAll();
  954. }
  955. catch (Exception ex)
  956. {
  957. _wait.Close();
  958. MessageBox.Show(ex.Message);
  959. }
  960. }
  961. #endregion
  962. #endregion
  963. private bool CheckIsOK(int OPSEQ)
  964. {
  965. bool isfalse = false;
  966. string _OQCSql = @"SELECT DISTINCT ACTION,CC.RESULT FROM ICSLOTONWIP bb WITH (nolock)
  967. LEFT JOIN ICSLOTONWIPCHECK CC ON BB.ID=CC.ONWIPID
  968. INNER JOIN ICSITEMROUTE2OPLot a WITH (nolock) ON bb.lotno=a.lotno and bb.opcode=a.opcode
  969. WHERE bb.LotNo='" + txtLotNo.Text + "' AND a.OPSEQ='" + OPSEQ + "' AND ISNULL(CC.RESULT,'')<>''";
  970. DataTable _OQCdt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, _OQCSql).Tables[0];
  971. if (_OQCdt != null && _OQCdt.Rows.Count > 0)
  972. {
  973. isfalse = false;
  974. }
  975. else
  976. {
  977. isfalse = true;
  978. }
  979. return isfalse;
  980. }
  981. //
  982. //已经放行的还能判退吗???
  983. //自控的判退,放行是没有工序管控的,只到批次,现在是否需要工序纬度
  984. private void btnReturn_Click_bak(object sender, EventArgs e)
  985. {
  986. string id = "";
  987. List<string> editList = new List<string>();
  988. for (int i = 0; i < grvDetail.RowCount; i++)
  989. {
  990. //if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  991. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "True")
  992. {
  993. //id = grvDetail.GetRowCellValue(i, colID).ToString();
  994. string lotno = grvDetail.GetRowCellValue(i, colLOTNO).ToString();
  995. editList.Add(lotno);
  996. }
  997. }
  998. if (editList.Count == 0)
  999. {
  1000. MessageBox.Show("请选择数据");
  1001. return;
  1002. }
  1003. if (string.IsNullOrEmpty(this.txtReturn.Text.Trim()))
  1004. {
  1005. MessageBox.Show("请填写判退原因");
  1006. return;
  1007. }
  1008. string strResult = "";
  1009. try
  1010. {
  1011. List<string> codeList = new List<string>();
  1012. List<ICSQualityCKDATA> modelList = new List<ICSQualityCKDATA>();
  1013. List<string> UnCKRCV = new List<string>();
  1014. List<string> IsCKedCK = new List<string>();
  1015. List<WMSICSINSPECTIONModel> InsList = new List<WMSICSINSPECTIONModel>();
  1016. string docNo = "";
  1017. string docLine = "";
  1018. decimal QTY = 0;
  1019. string itemcode = "";
  1020. string Luhao = "";
  1021. bool IsFirst = true;
  1022. for (int i = 0; i < grvDetail.RowCount; i++)
  1023. {
  1024. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "True")
  1025. {
  1026. ICSQualityCKDATA model = new ICSQualityCKDATA();
  1027. //string IsCanCK = grvDetail.GetRowCellValue(i, colIsCanCK).ToString();
  1028. string lotno = grvDetail.GetRowCellValue(i, colLOTNO).ToString();
  1029. model.LOTNO = grvDetail.GetRowCellValue(i, colLOTNO).ToString();
  1030. model.OPCode = grvDetail.GetRowCellValue(i, colOPCODE).ToString();
  1031. model.MOCODE = grvDetail.GetRowCellValue(i, colMOCode).ToString();
  1032. model.SEQ = Int32.Parse(grvDetail.GetRowCellValue(i, colMOSEQ).ToString());
  1033. model.CKResult = "0";
  1034. docNo = model.MOCODE;
  1035. docLine = model.SEQ.ToString();
  1036. itemcode = grvDetail.GetRowCellValue(i, colITEMCODE).ToString();
  1037. QTY = Decimal.Parse(grvDetail.GetRowCellValue(i, colLOTQTY).ToString());
  1038. modelList.Add(model);
  1039. //if (IsCanCK != "OK")
  1040. //{
  1041. //if (!UnCKRCV.Contains(docNo))
  1042. //{
  1043. // UnCKRCV.Add(docNo);
  1044. //}
  1045. //}
  1046. //else
  1047. //{
  1048. bool Isck = ICSQualityCKDATABLL.IsLLCKByLotNo(lotno);
  1049. if (Isck)
  1050. {
  1051. IsCKedCK.Add(lotno);
  1052. }
  1053. else
  1054. {
  1055. codeList.Add(lotno);
  1056. QTY += Convert.ToDecimal(grvDetail.GetRowCellValue(i, colLOTQTY).ToString());
  1057. strResult += grvDetail.GetRowCellValue(i, colLOTNO).ToString() + ",";
  1058. WMSICSINSPECTIONModel ins = new WMSICSINSPECTIONModel();
  1059. ins.LotNO = lotno;
  1060. ins.INVCODE = grvDetail.GetRowCellValue(i, colITEMCODE).ToString();
  1061. ins.VENDORITEMCODE = grvDetail.GetRowCellValue(i, colITEMCODE).ToString();
  1062. ins.LOTQTY = Convert.ToDecimal(grvDetail.GetRowCellValue(i, colLOTQTY).ToString());
  1063. ins.NLOTQTY = Convert.ToDecimal(grvDetail.GetRowCellValue(i, colLOTQTY).ToString());
  1064. ins.BadCause = this.txtReturn.Text.Trim();
  1065. //ins.TransNO = grvDetail.GetRowCellValue(i, colPOCode).ToString();
  1066. //ins.TransLine = grvDetail.GetRowCellValue(i, colPoLineNo).ToString();
  1067. ins.TYPE = "采购入库";
  1068. InsList.Add(ins);
  1069. //}
  1070. }
  1071. //判断是否有相同的炉号,报检单号,料号,行号
  1072. if (IsFirst)
  1073. {
  1074. IsFirst = false;
  1075. //docNo = grvDetail.GetRowCellValue(i, colRcvDocNo).ToString();
  1076. itemcode = grvDetail.GetRowCellValue(i, colITEMCODE).ToString();
  1077. //Luhao = grvDetail.GetRowCellValue(i, colRcvLineInvLotFurnace).ToString();
  1078. //docLine = grvDetail.GetRowCellValue(i, colRcvLineNo).ToString();
  1079. }
  1080. else
  1081. {
  1082. //if (docNo != grvDetail.GetRowCellValue(i, colRcvDocNo).ToString() ||
  1083. // itemcode != grvDetail.GetRowCellValue(i, colItemCode).ToString() ||
  1084. // Luhao != grvDetail.GetRowCellValue(i, colRcvLineInvLotFurnace).ToString() ||
  1085. // docLine != grvDetail.GetRowCellValue(i, colRcvLineNo).ToString())
  1086. if (itemcode != grvDetail.GetRowCellValue(i, colITEMCODE).ToString())
  1087. {
  1088. ICSBaseSimpleCode.AppshowMessageBox("请选择相同料号,报检单号,行号,炉号的批次条码!");
  1089. return;
  1090. }
  1091. }
  1092. }
  1093. }
  1094. if (codeList.Count == 0 && UnCKRCV.Count == 0 && IsCKedCK.Count == 0)
  1095. {
  1096. ICSBaseSimpleCode.AppshowMessageBox("请选择需要判退的批次条码!");
  1097. return;
  1098. }
  1099. string mess = "";
  1100. //if (UnCKRCV.Count != 0)
  1101. //{
  1102. // mess += "以下到货单未达到抽检比例,不能放行:" + string.Join(",", UnCKRCV.ToArray());
  1103. //}colIsSendNCR
  1104. if (IsCKedCK.Count != 0)
  1105. {
  1106. mess += "以下批次已经放行或判退,不能判退:" + string.Join(",", IsCKedCK.ToArray());
  1107. }
  1108. if (!string.IsNullOrEmpty(mess))
  1109. {
  1110. ICSBaseSimpleCode.AppshowMessageBox(mess);
  1111. }
  1112. if (codeList.Count != 0)
  1113. {
  1114. ICSQualityCKDATABLL.AddReturn(modelList, AppConfig.AppConnectString, this.txtReturn.Text.Trim());
  1115. //SRM用的,可以注释
  1116. //ICSQualityCKDATABLL.InsertICSINSPECTION(InsList);
  1117. //这里需要
  1118. SendNCR(codeList, this.txtReturn.Text.Trim(), docNo, docLine, QTY, Luhao, itemcode);
  1119. ICSBaseSimpleCode.AppshowMessageBox(0, "判退成功!");
  1120. btnSearch_Click(null, null);
  1121. }
  1122. this.txtReturn.Text = "";
  1123. }
  1124. catch (Exception ex)
  1125. {
  1126. MessageBox.Show(ex.Message);
  1127. }
  1128. }
  1129. private void btnReturn_Click(object sender, EventArgs e)
  1130. {
  1131. if (string.IsNullOrEmpty(this.txtReturn.Text.Trim()))
  1132. {
  1133. MessageBox.Show("请填写判退原因");
  1134. return;
  1135. }
  1136. string strResult = "";
  1137. try
  1138. {
  1139. List<ICSQualityCKDATA> ckList = new List<ICSQualityCKDATA>();//工序检验
  1140. List<string> codeList = new List<string>();
  1141. string MOCODE = "";
  1142. decimal QTY = 0;
  1143. string itemcode = "";
  1144. String OPCODE = "";
  1145. bool IsFirst = true;
  1146. for (int i = 0; i < grvDetail.RowCount; i++)
  1147. {
  1148. ICSQualityCKDATA item = new ICSQualityCKDATA();//工序检验
  1149. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "True")
  1150. {
  1151. string lot = grvDetail.GetRowCellValue(i, colLOTNO).ToString();
  1152. string opcode = grvDetail.GetRowCellValue(i, colOPCODE).ToString();
  1153. string mocode = grvDetail.GetRowCellValue(i, colMOCode).ToString();
  1154. //string ID = grvDetail.GetRowCellValue(i, colID).ToString();
  1155. string sql = "select max(opseq) as opseq from icsitemroute2oplot a where lotno='" + lot + "' and opseq<(select opseq from icsitemroute2oplot b where b.lotno='" + lot + "' and b.opcode='" + opcode + "' )";
  1156. DataTable lastop = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  1157. if (lastop.Rows.Count > 0&&!string.IsNullOrEmpty(lastop.Rows[0]["opseq"].ToString()))
  1158. {
  1159. bool isOK = CheckIsOK(Convert.ToInt32(lastop.Rows[0]["opseq"]));
  1160. if (!isOK)
  1161. {
  1162. ICSBaseSimpleCode.AppshowMessageBox("上道工序未检验或检验结果不合格,不能判定!");
  1163. return;
  1164. }
  1165. }
  1166. string Status = grvDetail.GetRowCellValue(i, colState).ToString();
  1167. if (Status == "已检测")
  1168. {
  1169. ICSBaseSimpleCode.AppshowMessageBox("当前批次:" + lot + ",工单:" + mocode + ",工序:" + opcode + "已经检测,不能继续判退!");
  1170. return;
  1171. }
  1172. item.LOTNO = lot;
  1173. item.OPCode = opcode;
  1174. item.MOCODE = mocode;
  1175. item.CKResult = "0";
  1176. //item.ID = ID;
  1177. if (!ckList.Contains(item))
  1178. {
  1179. ckList.Add(item);
  1180. }
  1181. if (!codeList.Contains(lot))
  1182. {
  1183. strResult += lot + ",";
  1184. codeList.Add(lot);
  1185. }
  1186. QTY += Convert.ToDecimal(grvDetail.GetRowCellValue(i, colLOTQTY).ToString());
  1187. if (string.IsNullOrEmpty(itemcode))
  1188. {
  1189. itemcode = grvDetail.GetRowCellValue(i, colITEMCODE).ToString();
  1190. }
  1191. //判断是否有相同的 工单
  1192. if (IsFirst)
  1193. {
  1194. IsFirst = false;
  1195. MOCODE = mocode;
  1196. OPCODE = opcode;
  1197. }
  1198. else
  1199. {
  1200. if (MOCODE != mocode)
  1201. {
  1202. ICSBaseSimpleCode.AppshowMessageBox("请选择相同工单号的批次条码!");
  1203. return;
  1204. }
  1205. if (OPCODE != opcode)
  1206. {
  1207. ICSBaseSimpleCode.AppshowMessageBox("请选择相同工序的批次条码!");
  1208. return;
  1209. }
  1210. }
  1211. if (GXOrWW == 0)
  1212. {
  1213. #region 20210709下道工序开工,上道工序质量检验就不能判退或者放行,提示下道工序已开工
  1214. string sqlCheck = @"SELECT b.OPSEQ FROM
  1215. ICSITEMROUTE2OPLot b
  1216. LEFT JOIN ICSLOTONWIP a ON b.OPCODE=a.OPCODE AND b.lotno=a.lotno
  1217. WHERE a.LOTNO='" + lot + "' and b.OPCODE='" + opcode + "' ORDER BY OPSEQ";
  1218. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sqlCheck).Tables[0];
  1219. if (data != null && data.Rows.Count > 0)
  1220. {
  1221. int _OPSEQ = 0;
  1222. string OPSEQ = data.Rows[0][0].ToString();
  1223. //if (!string.IsNullOrWhiteSpace(OPSEQ))
  1224. //{
  1225. // _OPSEQ = Int32.Parse(OPSEQ) + 10;
  1226. //}
  1227. // string sqlDownOP = @"SELECT a.ACTIONRESULT,b.OPCODE,b.OPSEQ FROM
  1228. // ICSROUTE2OP b
  1229. // LEFT JOIN ICSLOTONWIP a ON b.OPCODE=a.OPCODE AND b.ROUTECODE=a.RouteCode
  1230. // WHERE a.LOTNO='" + lot + "' AND b.OPSEQ='" + _OPSEQ + "' ORDER BY OPSEQ";
  1231. string sqlDownOP = @"SELECT b.OPSEQ FROM
  1232. ICSITEMROUTE2OPLot b
  1233. LEFT JOIN ICSLOTONWIP a ON b.OPCODE=a.OPCODE AND b.lotno=a.lotno
  1234. WHERE a.LOTNO='" + lot + "' AND b.OPSEQ>'" + OPSEQ + "' ORDER BY OPSEQ";
  1235. DataTable _data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sqlDownOP).Tables[0];
  1236. if (_data != null && _data.Rows.Count > 0)
  1237. {
  1238. MessageBox.Show("下道工序已开工,不能执行判退,请核对!");
  1239. return;
  1240. }
  1241. }
  1242. else
  1243. {
  1244. MessageBox.Show("当前工序没开工工序,不能执行判退,请核对!");
  1245. return;
  1246. }
  1247. #endregion
  1248. }
  1249. }
  1250. }
  1251. if (codeList.Count == 0)
  1252. {
  1253. ICSBaseSimpleCode.AppshowMessageBox("请选择需要判退的批次条码!");
  1254. return;
  1255. }
  1256. strResult=strResult.Trim(',');
  1257. ICSQualityCKDATABLL.AddCK_GXJY(ckList, AppConfig.AppConnectString, this.txtReturn.Text.Trim(), GXOrWW);
  1258. SendNCR(codeList, strResult + this.txtReturn.Text.Trim(), QTY, itemcode, MOCODE, OPCODE);
  1259. ICSBaseSimpleCode.AppshowMessageBox(0, "判退成功!");
  1260. #region AGV调用
  1261. StringBuilder errores = new StringBuilder("");
  1262. foreach (var ckdata in ckList)
  1263. {
  1264. if (ICSAGVBLL.IsCanToAGV(ckdata.LOTNO, ckdata.OPCode, "AGV是否开启", AppConfig.AppConnectString, AppConfig.WorkPointCode))
  1265. {
  1266. try
  1267. {
  1268. ICSAGVTASKLOG Log = new ICSAGVTASKLOG();
  1269. Log.ID = AppConfig.GetGuid();
  1270. Log.Lotno = ckdata.LOTNO;
  1271. Log.Opcode = ckdata.OPCode;
  1272. bool Islastop = ICSAGVBLL.IsLastOP(Log.Lotno, Log.Opcode, AppConfig.AppConnectString, AppConfig.WorkPointCode);
  1273. bool NextOpIsWW = ICSAGVBLL.NextOPisWW(Log.Lotno, Log.Opcode, AppConfig.AppConnectString, AppConfig.WorkPointCode);
  1274. bool NextOpIsWG = ICSAGVBLL.NextOPisWG(Log.Lotno, Log.Opcode, AppConfig.AppConnectString, AppConfig.WorkPointCode);
  1275. string Area = "";
  1276. if (!(NextOpIsWW && GXOrWW == 1 && NextOpIsWG))
  1277. {
  1278. Area = ICSAGVBLL.GetAreaCode("00088", "3", AppConfig.AppConnectString, AppConfig.WorkPointCode);
  1279. Log.TaskType = "质检不合格";
  1280. string BeginArea = Area.Split('@')[0].Split(':')[0];
  1281. string EndArea = Area.Split('@')[1].Split(':')[0];
  1282. AgvAreaToAreaModel Model = new AgvAreaToAreaModel();
  1283. Model.trackingNumber = ckdata.LOTNO;
  1284. Model.area = EndArea;
  1285. Log.Area = BeginArea;
  1286. Log.EndArea = EndArea;
  1287. Log.Mtime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  1288. Log.MuserName = AppConfig.UserName;
  1289. ICSAGVBLL.AgvAreaToArea(Model, Log, AppConfig.AppConnectString, AppConfig.WorkPointCode);
  1290. }
  1291. }
  1292. catch (Exception ex)
  1293. {
  1294. errores.Append("AGV任务异常:" + ex.Message + "已跳过\r\n");
  1295. continue;
  1296. }
  1297. }
  1298. }
  1299. if (!string.IsNullOrEmpty(errores.ToString()))
  1300. {
  1301. ICSBaseSimpleCode.AppshowMessageBox(errores.ToString());
  1302. }
  1303. #endregion
  1304. this.txtReturn.Text = "";
  1305. btnSearch_Click(null, null);
  1306. }
  1307. catch (Exception ex)
  1308. {
  1309. MessageBox.Show(ex.Message);
  1310. }
  1311. }
  1312. #region 提交时选择工序对前面所有工序自动开工完工
  1313. public bool LotComplete_New(string LotNo, string OPCODE, String MoCode)
  1314. { //查询此条码正在进行工序--当前工序
  1315. string seqSql = string.Format(@"SELECT f.CollectStatus
  1316. FROM ICSLOTSIMULATION f
  1317. WHERE f.LOTNO='{0}' and f.OPCODE='{1}' ", LotNo, OPCODE);
  1318. DataTable seqDt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, seqSql).Tables[0];
  1319. //BatchStartServer.BatchStartClient StartClientResult = new BatchStartServer.BatchStartClient();
  1320. //BatchStartServer.OperationResult _StartResult = new BatchStartServer.OperationResult();
  1321. //BatchEndServer.BatchEndClient EndClientResult = new BatchEndServer.BatchEndClient();
  1322. //BatchEndServer.OperationResult _EndResult = new BatchEndServer.OperationResult();
  1323. if (seqDt != null && seqDt.Rows.Count > 0)
  1324. {
  1325. if (seqDt.Rows[0]["CollectStatus"].ToString() == "COLLECT_BEGIN")//此条码当前工序已开工,需自动完工
  1326. {
  1327. //ZHCSoft.AntiwearValveExpanded.Forms.BatchEndServer.FormICSOQCOPCKDATAUIModel[] ICSOQCOPCKDATAArray = new BatchEndServer.FormICSOQCOPCKDATAUIModel[0];
  1328. //ZHCSoft.AntiwearValveExpanded.Forms.BatchEndServer.ICSECG2EC[] ICSOQCOPCKDATA = new ZHCSoft.AntiwearValveExpanded.Forms.BatchEndServer.ICSECG2EC[0];
  1329. //_EndResult = EndClientResult.GetBatchEnd_Message(true, ICSOQCOPCKDATAArray, ICSOQCOPCKDATA, LotNo, MoCode, OPCODE, "admin", AppConfig.WorkPointCode);
  1330. //if (!_EndResult.IsSuccess)
  1331. //{
  1332. // ICSBaseSimpleCode.AppshowMessageBox(LotNo + "完工失败! " + _EndResult.MESSAGE);
  1333. // return false;
  1334. //}
  1335. }
  1336. else if (seqDt.Rows[0]["CollectStatus"].ToString() == "")//自动开工完工
  1337. {
  1338. //自动开工
  1339. //_StartResult = StartClientResult.GetBatchStart_Message(LotNo, MoCode, OPCODE, "admin", AppConfig.WorkPointCode);
  1340. //if (_StartResult.IsSuccess)//自动开工成功
  1341. //{
  1342. // ZHCSoft.AntiwearValveExpanded.Forms.BatchEndServer.FormICSOQCOPCKDATAUIModel[] ICSOQCOPCKDATAArray = new BatchEndServer.FormICSOQCOPCKDATAUIModel[0];
  1343. // ZHCSoft.AntiwearValveExpanded.Forms.BatchEndServer.ICSECG2EC[] ICSOQCOPCKDATA = new ZHCSoft.AntiwearValveExpanded.Forms.BatchEndServer.ICSECG2EC[0];
  1344. // _EndResult = EndClientResult.GetBatchEnd_Message(true, ICSOQCOPCKDATAArray, ICSOQCOPCKDATA, LotNo, MoCode, OPCODE, "admin", AppConfig.WorkPointCode);
  1345. // if (!_EndResult.IsSuccess)
  1346. // {
  1347. // ICSBaseSimpleCode.AppshowMessageBox(LotNo + ":完工失败! " + _EndResult.MESSAGE);
  1348. // return false;
  1349. // }
  1350. //}
  1351. //else
  1352. //{
  1353. // ICSBaseSimpleCode.AppshowMessageBox(LotNo + "开工失败!" + _StartResult.MESSAGE);
  1354. // return false;
  1355. //}
  1356. }
  1357. }
  1358. else
  1359. {
  1360. //ZHCSoft.AntiwearValveExpanded.Forms.BatchEndServer.FormICSOQCOPCKDATAUIModel[] ICSOQCOPCKDATAArray = new BatchEndServer.FormICSOQCOPCKDATAUIModel[0];
  1361. //ZHCSoft.AntiwearValveExpanded.Forms.BatchEndServer.ICSECG2EC[] ICSOQCOPCKDATA = new ZHCSoft.AntiwearValveExpanded.Forms.BatchEndServer.ICSECG2EC[0];
  1362. //_EndResult = EndClientResult.GetBatchEnd_Message(true, ICSOQCOPCKDATAArray, ICSOQCOPCKDATA, LotNo, MoCode, OPCODE, "admin", AppConfig.WorkPointCode);
  1363. //if (!_EndResult.IsSuccess)
  1364. //{
  1365. // ICSBaseSimpleCode.AppshowMessageBox(LotNo + "完工失败! " + _EndResult.MESSAGE);
  1366. // return false;
  1367. //}
  1368. }
  1369. return true;
  1370. }
  1371. #endregion
  1372. #region 20210602
  1373. private void SendNCR(List<string> codeList, string strResult, string DocNo, string DocLine, decimal QTY, string luhao, string itemcode)
  1374. {
  1375. try
  1376. {
  1377. string codeStr = "";
  1378. foreach (string str in codeList)
  1379. {
  1380. codeStr += str + ",";
  1381. }
  1382. codeStr = codeStr.TrimEnd(',');
  1383. string NewCartonNo = "NCR" + AppConfig.GetSeverDateTime("yyyy-MM-dd").ToString("yyyyMMdd");
  1384. NewCartonNo = GetSerialCode(AppConfig.FrameConnectString, "ICSNCRDoc", "SecDocNO", NewCartonNo, 3);
  1385. ICSSecDocType secDocType = ICSSecDocTypeBLL.select("QC_Collect", AppConfig.FrameConnectString);
  1386. //获取对应的接收人和抄送人
  1387. ICSSecDocTypeStep docTypeStep = ICSSecDocTypeStepBLL.selectStepBySeq(secDocType.guid, "1", AppConfig.FrameConnectString);
  1388. string ToUserList = "";
  1389. //ToUserList = ICSNCRDocBLL.QualityEngineer(UserControlLLNew.GetUserCode, AppConfig.AppConnectString);
  1390. ToUserList = ICSNCRDocBLL.QualityEngineer("", AppConfig.AppConnectString);
  1391. if (string.IsNullOrEmpty(ToUserList))
  1392. {
  1393. ToUserList = ICSNCRDocBLL.QualityEngineer("来料", AppConfig.AppConnectString);
  1394. }
  1395. string CCUserList = ICSNCRDocBLL.QualityEngineer("经理", AppConfig.AppConnectString);
  1396. ICSNCRDoc SecDoc = new ICSNCRDoc();
  1397. SecDoc.SecDocNO = NewCartonNo;
  1398. SecDoc.SecDocType = secDocType.guid;
  1399. SecDoc.SecDocStatus = "已发送";
  1400. SecDoc.SecDocSeq = 1;
  1401. //SecDoc.SecDocCreateUser = UserControlLLNew.GetUserCode;
  1402. //SecDoc.SecDocCreateUserName = UserControlLLNew.GetUserName;
  1403. SecDoc.SecDocCreateUser = AppConfig.UserCode;
  1404. SecDoc.SecDocCreateUserName = AppConfig.UserName;
  1405. SecDoc.SecDocCreateTime = AppConfig.GetSeverDateTime("");
  1406. SecDoc.ErrorType = "来料";
  1407. SecDoc.EQPCode = "";
  1408. SecDoc.ItemCode = itemcode;
  1409. SecDoc.ProjectCode = "";
  1410. SecDoc.TimeLimit = "1";
  1411. SecDoc.ContentDesc = strResult;
  1412. SecDoc.EATTRIBUTE1 = codeStr;
  1413. SecDoc.ToUserList = ToUserList;
  1414. SecDoc.CCUserList = CCUserList;
  1415. SecDoc.LOTNO = DocNo;
  1416. SecDoc.OPCode = DocLine;
  1417. SecDoc.SecDocOKTime = Convert.ToDateTime("1990-01-01");
  1418. SecDoc.Qty = QTY;
  1419. SecDoc.SrcDocInfo = codeStr;
  1420. SecDoc.Furnace = luhao;
  1421. ICSNCRDocDoDetail SecDocDoDetail = new ICSNCRDocDoDetail();
  1422. SecDocDoDetail.DepCode = docTypeStep.DocTypeTo;
  1423. ICSNCRDoc NCR = new ICSNCRDoc();
  1424. NCR = null;//modify on 20200418
  1425. if (NCR == null)
  1426. {
  1427. ICSNCRDocBLL.CreateNCR(SecDoc, AppConfig.AppConnectString);
  1428. }
  1429. else
  1430. {
  1431. MessageBox.Show(codeStr + "已产生NCR单号:" + NCR.SecDocNO + ",不能新增NCR单");
  1432. }
  1433. }
  1434. catch (Exception ex)
  1435. {
  1436. throw new Exception(ex.Message);
  1437. }
  1438. }
  1439. private void SendNCR(string strResult, string RcvDocNo, string ItemCode, string ItemName, string ProjectCode, decimal QTY)
  1440. {
  1441. try
  1442. {
  1443. string NewCartonNo = "NCR" + AppConfig.GetSeverDateTime("yyyy-MM-dd").ToString("yyyyMMdd");
  1444. NewCartonNo = GetSerialCode(AppConfig.FrameConnectString, "ICSNCRDoc", "SecDocNO", NewCartonNo, 3);
  1445. ICSSecDocType secDocType = ICSSecDocTypeBLL.select("QC_Collect", AppConfig.FrameConnectString);
  1446. //获取对应的接收人和抄送人
  1447. ICSSecDocTypeStep docTypeStep = ICSSecDocTypeStepBLL.selectStepBySeq(secDocType.guid, "1", AppConfig.FrameConnectString);
  1448. string ToUserList = "";
  1449. ToUserList = ICSNCRDocBLL.QualityEngineer(AppConfig.UserCode, AppConfig.AppConnectString);
  1450. if (string.IsNullOrEmpty(ToUserList))
  1451. {
  1452. ToUserList = ICSNCRDocBLL.QualityEngineer("来料", AppConfig.AppConnectString);
  1453. }
  1454. string CCUserList = ICSNCRDocBLL.QualityEngineer("经理", AppConfig.AppConnectString);
  1455. ICSNCRDoc SecDoc = new ICSNCRDoc();
  1456. SecDoc.SecDocNO = NewCartonNo;
  1457. SecDoc.SecDocType = secDocType.guid;
  1458. SecDoc.SecDocStatus = "已发送";
  1459. SecDoc.SecDocSeq = 1;
  1460. SecDoc.SecDocCreateUser = AppConfig.UserCode;
  1461. SecDoc.SecDocCreateUserName = AppConfig.UserName;
  1462. SecDoc.SecDocCreateTime = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
  1463. SecDoc.ErrorType = "来料";
  1464. SecDoc.EQPCode = "";
  1465. SecDoc.ItemCode = ItemCode;
  1466. SecDoc.ProjectCode = ProjectCode;
  1467. SecDoc.TimeLimit = "1";
  1468. SecDoc.ContentDesc = strResult;
  1469. SecDoc.ToUserList = ToUserList;
  1470. SecDoc.CCUserList = CCUserList;
  1471. SecDoc.LOTNO = RcvDocNo.Split('_')[0];
  1472. SecDoc.OPCode = RcvDocNo.Split('_')[1];
  1473. SecDoc.SecDocOKTime = Convert.ToDateTime("1990-01-01");
  1474. SecDoc.SrcDocInfo = RcvDocNo.Split('_')[0];
  1475. SecDoc.Qty = QTY;
  1476. ICSNCRDoc NCR = new ICSNCRDoc();
  1477. NCR = null;//modify on 20200418
  1478. if (NCR == null)
  1479. {
  1480. ICSNCRDocBLL.CreateNCR(SecDoc, AppConfig.AppConnectString);
  1481. }
  1482. else
  1483. {
  1484. MessageBox.Show(RcvDocNo.Split('_')[0] + "已产生NCR单号:" + NCR.SecDocNO + ",不能新增NCR单");
  1485. }
  1486. }
  1487. catch (Exception ex)
  1488. {
  1489. throw new Exception(ex.Message);
  1490. }
  1491. }
  1492. private void SendNCR(List<string> codeList, string strResult, decimal QTY, string itemcode, string mocode, string OPCODE)
  1493. {//
  1494. try
  1495. {
  1496. string codeStr = "";
  1497. foreach (string str in codeList)
  1498. {
  1499. codeStr += str + ",";
  1500. }
  1501. codeStr = codeStr.TrimEnd(',');
  1502. string NewCartonNo = "NCR" + AppConfig.GetSeverDateTime("yyyy-MM-dd").ToString("yyyyMMdd");
  1503. NewCartonNo = GetSerialCode(AppConfig.FrameConnectString, "ICSNCRDoc", "SecDocNO", NewCartonNo, 3);
  1504. ICSSecDocType secDocType = ICSSecDocTypeBLL.select("QC_Collect", AppConfig.FrameConnectString);
  1505. #region 20210816
  1506. //获取对应的接收人和抄送人
  1507. //ICSSecDocTypeStep docTypeStep = ICSSecDocTypeStepBLL.selectStepBySeq(secDocType.guid, "1", AppConfig.FrameConnectString);
  1508. //string ToUserList = "";
  1509. //ToUserList = ICSNCRDocBLL.QualityEngineer(CKType, AppConfig.AppConnectString);
  1510. #endregion
  1511. //string CCUserList = ICSNCRDocBLL.QualityEngineer("经理", AppConfig.AppConnectString);
  1512. //string sql = @"SELECT a.ProjectCode FROM ICSMO a WHERE a.MOCODE='{0}'";
  1513. //sql = string.Format(sql, mocode);
  1514. //DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  1515. string ProjectCode = "";
  1516. //if (dt != null && dt.Rows.Count > 0)
  1517. //{
  1518. // ProjectCode = dt.Rows[0]["ProjectCode"].ToString();
  1519. //}
  1520. ICSNCRDoc SecDoc = new ICSNCRDoc();
  1521. SecDoc.SecDocNO = NewCartonNo;
  1522. SecDoc.SecDocType = secDocType.guid;
  1523. SecDoc.SecDocStatus = "已发送";
  1524. SecDoc.SecDocSeq = 1;
  1525. SecDoc.SecDocCreateUser = AppConfig.UserCode;
  1526. SecDoc.SecDocCreateUserName = AppConfig.UserName;
  1527. SecDoc.SecDocCreateTime = AppConfig.GetSeverDateTime("");
  1528. //SecDoc.ErrorType = CKType;
  1529. SecDoc.ErrorType = "工序检验";//modify on 20201202 NCRtype修改
  1530. SecDoc.EQPCode = "";
  1531. SecDoc.ItemCode = itemcode;
  1532. SecDoc.ProjectCode = ProjectCode;
  1533. SecDoc.TimeLimit = "1";
  1534. SecDoc.ContentDesc = strResult;
  1535. SecDoc.EATTRIBUTE2 = CKType;
  1536. //SecDoc.ToUserList = ToUserList;
  1537. //SecDoc.CCUserList = CCUserList;
  1538. //SecDoc.ToUserList = ToUserList;
  1539. //SecDoc.CCUserList = CCUserList;
  1540. SecDoc.LOTNO = "";
  1541. SecDoc.OPCode = OPCODE;
  1542. SecDoc.SecDocOKTime = Convert.ToDateTime("1990-01-01");
  1543. SecDoc.Qty = QTY;
  1544. SecDoc.SrcDocInfo = codeStr;
  1545. ICSNCRDoc NCR = new ICSNCRDoc();
  1546. // NCR = ICSNCRDocBLL.selectBySrcDocInfo(codeStr, AppConfig.AppConnectString);
  1547. NCR = null;//modify on 20200418
  1548. if (NCR == null)
  1549. {
  1550. ICSNCRDocBLL.CreateNCR(SecDoc, AppConfig.AppConnectString);
  1551. }
  1552. else
  1553. {
  1554. MessageBox.Show(codeStr + "已产生NCR单号:" + NCR.SecDocNO + ",不能新增NCR单");
  1555. }
  1556. }
  1557. catch (Exception ex)
  1558. {
  1559. throw new Exception(ex.Message);
  1560. }
  1561. }
  1562. #endregion
  1563. private DataTable GetNGCKData(string RcvDocNo, string LineNo)
  1564. {
  1565. string sql = @"select a.RcvDocNo,a.RcvLineNo,a.RcvLineItemMasterCode,a.RcvLineItemMasterName, a.RcvLineProjectCode,
  1566. a.RcvLineInvLotFurnace, C.LotNo, e.CKITEMCODE,e.CKITEMDESC,SetValueMax,SetValueMin,d.[CKValue] ,b.BarCodeQty
  1567. from [dbo].[WM_RCVShip] a
  1568. inner join [dbo].[WM_BarCode] b on a.[guid] = b.Srcguid And b.SrcType = 'WM_RCVShip'
  1569. inner join ( select * from (select ROW_NUMBER()over(partition by LOTNO order by mtime desc) rowId,*
  1570. from ICSQualityCKDATA ck where type='' ) as AuctionRecords
  1571. where rowId=1) c on b.BarCodeNo = c.LotNo And c.CKResult = '0'
  1572. inner join [dbo].[ICSQualityCKDATADetail] d on d.DataID = c.ID And d.[CKResult] = '0' And [DECKResult] = '0'
  1573. inner join [dbo].[ICSQualityCKItem] e on d.CKItemID = e.ID
  1574. where a.[RcvDocNo] = '" + RcvDocNo + "' And a.[RcvLineNo]='" + LineNo + "' order by a.RcvDocNo,a.RcvLineNo";
  1575. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  1576. return dt;
  1577. }
  1578. private void btnSelectAll_Click(object sender, EventArgs e)
  1579. {
  1580. if (ICSBaseSimpleCode.AppshowMessageBoxRepose("确定全选吗?") != DialogResult.OK)
  1581. return;
  1582. grvDetail.PostEditor();
  1583. this.Validate();
  1584. for (int i = 0; i < grvDetail.RowCount; i++)
  1585. {
  1586. grvDetail.SetRowCellValue(i, colisSelect, true);
  1587. }
  1588. }
  1589. private void btnUnSelectAll_Click(object sender, EventArgs e)
  1590. {
  1591. grvDetail.PostEditor();
  1592. this.Validate();
  1593. for (int i = 0; i < grvDetail.RowCount; i++)
  1594. {
  1595. grvDetail.SetRowCellValue(i, colisSelect, false);
  1596. }
  1597. }
  1598. private void btnDisposeIn_Click(object sender, EventArgs e)
  1599. {
  1600. //FormICSLLDispose add = new FormICSLLDispose();
  1601. //add.ShowDialog();
  1602. }
  1603. private void grvDetail_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
  1604. {
  1605. int hand = e.RowHandle;
  1606. if (hand < 0)
  1607. return;
  1608. DataRow dr = this.grvDetail.GetDataRow(hand);
  1609. if (dr == null)
  1610. return;
  1611. if (grvDetail.FocusedColumn.FieldName == "SecDocNO")
  1612. {
  1613. string userCode = AppConfig.UserCode;
  1614. string DocNo = grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colSecDocNO).ToString();
  1615. if (!string.IsNullOrWhiteSpace(DocNo))
  1616. {
  1617. if (!string.IsNullOrWhiteSpace(DocNo))
  1618. {
  1619. List<string> list = new List<string>(DocNo.Split(','));
  1620. //FormICSNCR ff = new FormICSNCR(list, 0);
  1621. //ff.Show();
  1622. }
  1623. }
  1624. }
  1625. }
  1626. private void repositoryItemHyperLinkEdit1_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  1627. {
  1628. }
  1629. private void timer1_Tick(object sender, EventArgs e)
  1630. {
  1631. //btnSearch_Click(null, null);
  1632. }
  1633. private void simpleBut_Min_Click(object sender, EventArgs e)
  1634. {
  1635. this.WindowState = FormWindowState.Minimized;
  1636. this.FormBorderStyle = FormBorderStyle.Sizable;
  1637. }
  1638. private void FormICSLL_SizeChanged(object sender, EventArgs e)
  1639. {
  1640. if (this.WindowState == FormWindowState.Minimized)
  1641. {
  1642. this.FormBorderStyle = FormBorderStyle.Sizable;
  1643. }
  1644. else
  1645. {
  1646. this.FormBorderStyle = FormBorderStyle.None;
  1647. }
  1648. }
  1649. /// <summary>
  1650. /// 获取单据号
  1651. /// </summary>
  1652. /// <param name="tbName"></param>
  1653. /// <param name="colName"></param>
  1654. /// <param name="Pre"></param>
  1655. /// <param name="numLen"></param>
  1656. /// <returns></returns>
  1657. public static string GetSerialCode(string connectString, string tbName, string colName, string Pre, int numLen)
  1658. {
  1659. string sql = "EXEC Addins_GetSerialCode '{0}','{1}','{2}','{3}',{4}";
  1660. sql = string.Format(sql, new object[] { "",tbName, colName, Pre, numLen });
  1661. return DBHelper.ExecuteScalar(connectString, CommandType.Text, sql).ToString();
  1662. }
  1663. private void grdDetail_Click(object sender, EventArgs e)
  1664. {
  1665. }
  1666. private void txtLotNo_KeyDown(object sender, KeyEventArgs e)
  1667. {
  1668. if (e.KeyCode == Keys.Enter) {
  1669. btnSearch_Click(null, null);
  1670. }
  1671. }
  1672. /// <summary>
  1673. /// 撤销功能:防止误判 1.委外检验无法撤销,判退无法撤销,下到工序已开工无法撤销
  1674. /// </summary>
  1675. /// <param name="sender"></param>
  1676. /// <param name="e"></param>
  1677. private void button1_Click(object sender, EventArgs e)
  1678. {
  1679. try
  1680. {
  1681. if (GXOrWW == 1)
  1682. throw new Exception("委外检验无法撤销!");
  1683. List<ICSQualityCKDATA> codeList = new List<ICSQualityCKDATA>();
  1684. for (int i = 0; i < grvDetail.RowCount; i++)
  1685. {
  1686. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "True")
  1687. {
  1688. string Lotno = grvDetail.GetRowCellValue(i, colLOTNO).ToString();
  1689. string opcode = grvDetail.GetRowCellValue(i, colOPCODE).ToString();
  1690. string opcodeSimu = GetSimuOp(Lotno);
  1691. if (grvDetail.GetRowCellValue(i, colResult).ToString() == "不合格")
  1692. throw new Exception("条码:" + Lotno + ",工序:" + opcode + " 已判退无法撤销!");
  1693. if (grvDetail.GetRowCellValue(i, colResult).ToString() == "未检测")
  1694. throw new Exception("条码:" + Lotno + ",工序:" + opcode + " 未检测无法撤销!");
  1695. if (opcode != opcodeSimu)
  1696. {
  1697. throw new Exception("条码:" + Lotno + "当前在制工序:" + opcodeSimu + "已开工,工序:" + opcode + "无法回撤!");
  1698. }
  1699. ICSQualityCKDATA ckdata = new ICSQualityCKDATA();
  1700. ckdata.LOTNO = Lotno;
  1701. ckdata.OPCode = opcode;
  1702. codeList.Add(ckdata);
  1703. }
  1704. }
  1705. if (codeList.Count == 0)
  1706. {
  1707. ICSBaseSimpleCode.AppshowMessageBox("请选择需要撤回判定的批次条码!");
  1708. return;
  1709. }
  1710. ICSQualityCKDATABLL.BackThroughOP(codeList, AppConfig.AppConnectString);
  1711. ICSBaseSimpleCode.AppshowMessageBox("撤回成功!");
  1712. btnSearch_Click(null, null);
  1713. }
  1714. catch (Exception EX)
  1715. {
  1716. ICSBaseSimpleCode.AppshowMessageBox(EX.Message);
  1717. }
  1718. }
  1719. public string GetSimuOp(string Lotno) {
  1720. string sql = "select Opcode from icslotsimulation where lotno='{0}'";
  1721. sql = string.Format(sql, Lotno);
  1722. return DBHelper.ExecuteDataset(AppConfig.AppConnectString,CommandType.Text,sql).Tables[0].Rows[0]["Opcode"].ToString();
  1723. }
  1724. }
  1725. }