华恒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.

2024 lines
91 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 FormICSLLAGVHH : 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 FormICSLLAGVHH(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 FormICSLLAGVHH()
  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. string itemcode = "";
  757. string itemname = "";
  758. int qty = 0;
  759. for (int i = 0; i < grvDetail.RowCount; i++)
  760. {
  761. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "True")
  762. {
  763. ICSQualityCKDATA ckData = new ICSQualityCKDATA();
  764. ckData.LOTNO = grvDetail.GetRowCellValue(i, colLOTNO).ToString();
  765. ckData.MOCODE = grvDetail.GetRowCellValue(i, colMOCode).ToString();
  766. ckData.OPCode = grvDetail.GetRowCellValue(i, colOPCODE).ToString();
  767. itemcode = grvDetail.GetRowCellValue(i, colITEMCODE).ToString();
  768. itemname = grvDetail.GetRowCellValue(i, colINVDESC).ToString();
  769. qty = Convert.ToInt32(grvDetail.GetRowCellValue(i, colLOTQTY));
  770. //ckData.ID = grvDetail.GetRowCellValue(i, colID).ToString();
  771. 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+"' )";
  772. DataTable lastop = DBHelper.ExecuteDataset(AppConfig.AppConnectString,CommandType.Text,sql).Tables[0];
  773. if (lastop.Rows.Count > 0 && !string.IsNullOrEmpty(lastop.Rows[0]["opseq"].ToString()))
  774. {
  775. bool isOK = CheckIsOK(Convert.ToInt32(lastop.Rows[0]["opseq"]));
  776. if (!isOK)
  777. {
  778. _wait.Close();
  779. ICSBaseSimpleCode.AppshowMessageBox("上道工序未检验或检验结果不合格,不能判定!");
  780. return;
  781. }
  782. }
  783. dataList.Add(ckData);
  784. if (GXOrWW == 0)
  785. {
  786. #region 20210709下道工序开工,上道工序质量检验就不能判退或者放行,提示下道工序已开工
  787. string sqlCheck = @"SELECT b.OPSEQ FROM
  788. ICSITEMROUTE2OPLot b
  789. LEFT JOIN ICSLOTONWIP a ON b.OPCODE=a.OPCODE AND b.lotno=a.lotno
  790. WHERE a.LOTNO='" + ckData.LOTNO + "' and b.OPCODE='" + ckData.OPCode + "' ORDER BY OPSEQ";
  791. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sqlCheck).Tables[0];
  792. if (data != null && data.Rows.Count > 0)
  793. {
  794. int _OPSEQ = 0;
  795. string OPSEQ = data.Rows[0][0].ToString();
  796. // if (!string.IsNullOrWhiteSpace(OPSEQ))
  797. // {
  798. // _OPSEQ = Int32.Parse(OPSEQ) + 10;
  799. // }
  800. // string sqlDownOP = @"SELECT a.ACTIONRESULT,b.OPCODE,b.OPSEQ FROM
  801. // ICSROUTE2OP b
  802. // LEFT JOIN ICSLOTONWIP a ON b.OPCODE=a.OPCODE AND b.ROUTECODE=a.RouteCode
  803. // WHERE a.LOTNO='" + ckData.LOTNO + "' AND b.OPSEQ='" + _OPSEQ + "' ORDER BY OPSEQ";
  804. string sqlDownOP = @"SELECT a.ACTIONRESULT,b.OPCODE,b.OPSEQ FROM
  805. ICSITEMROUTE2OPLot b
  806. LEFT JOIN ICSLOTONWIP a ON b.OPCODE=a.OPCODE AND b.lotno=a.lotno
  807. WHERE a.LOTNO='" + ckData.LOTNO + "' AND b.OPSEQ>'" + OPSEQ + "' ORDER BY OPSEQ";
  808. DataTable _data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sqlDownOP).Tables[0];
  809. if (_data != null && _data.Rows.Count > 0)
  810. {
  811. _wait.Close();
  812. MessageBox.Show("下道工序已开工,不能执行放行,请核对!");
  813. return;
  814. }
  815. }
  816. else
  817. {
  818. _wait.Close();
  819. MessageBox.Show("当前工序没开工工序,不能执行放行,请核对!");
  820. return;
  821. }
  822. #endregion
  823. }
  824. string Status = grvDetail.GetRowCellValue(i, colState).ToString();
  825. if (Status == "已检测")
  826. {
  827. _wait.Close();
  828. ICSBaseSimpleCode.AppshowMessageBox("当前批次:" + ckData.LOTNO + ",工单:" + ckData.MOCODE + ",工序:" + ckData.OPCode + "已经检测,不能继续放行!");
  829. return;
  830. }
  831. codeList.Add(grvDetail.GetRowCellValue(i, colLOTNO).ToString());
  832. moList.Add(grvDetail.GetRowCellValue(i, colMOCode).ToString());
  833. opList.Add(grvDetail.GetRowCellValue(i, colOPCODE).ToString());
  834. String opadd = "";
  835. for (int j = 0; j < grvDetail.RowCount; j++)
  836. {
  837. if (grvDetail.GetRowCellValue(i, colLOTNO).ToString() == grvDetail.GetRowCellValue(j, colLOTNO).ToString() &&
  838. grvDetail.GetRowCellValue(i, colOPCODE).ToString() != grvDetail.GetRowCellValue(j, colOPCODE).ToString())
  839. {
  840. if (opadd == "")
  841. {
  842. opadd += "" + grvDetail.GetRowCellValue(j, colOPCODE).ToString();
  843. }
  844. else
  845. {
  846. opadd += "," + grvDetail.GetRowCellValue(j, colOPCODE).ToString();
  847. }
  848. }
  849. }
  850. opaddList.Add(opadd);
  851. bool status = LotComplete_New(grvDetail.GetRowCellValue(i, colLOTNO).ToString(), grvDetail.GetRowCellValue(i, colOPCODE).ToString(), grvDetail.GetRowCellValue(i, colMOCode).ToString());
  852. #region 20210818
  853. string sqlCheckICSLOTONWIP = @"SELECT COUNT(*) FROM ICSLOTONWIP WHERE LOTNO='" + ckData.LOTNO + "' AND OPCODE='" + ckData.OPCode + "' and ACTIONRESULT='COLLECT_END' ";
  854. DataTable dtCheckICSLOTONWIP = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sqlCheckICSLOTONWIP).Tables[0];
  855. if (dtCheckICSLOTONWIP != null && dtCheckICSLOTONWIP.Rows.Count > 0)
  856. {
  857. if (dtCheckICSLOTONWIP.Rows[0][0].ToString() == "0")
  858. {
  859. _wait.Close();
  860. ICSBaseSimpleCode.AppshowMessageBox("当前批次:" + ckData.LOTNO + ",工单:" + ckData.MOCODE + ",工序:" + ckData.OPCode + ",ICSLOTONWIP表中没有完工记录,请核对!");
  861. return;
  862. }
  863. }
  864. else
  865. {
  866. _wait.Close();
  867. ICSBaseSimpleCode.AppshowMessageBox("当前批次:" + ckData.LOTNO + ",工单:" + ckData.MOCODE + ",工序:" + ckData.OPCode + ",ICSLOTONWIP表中没有完工记录,请核对!");
  868. return;
  869. }
  870. #endregion
  871. }
  872. }
  873. if (codeList.Count!=1)
  874. {
  875. _wait.Close();
  876. ICSBaseSimpleCode.AppshowMessageBox("请选择需要放行的条码且只能放行一条!");
  877. return;
  878. }
  879. //CKDATA_WX(codeList, moList, opList, opaddList);//20191114
  880. ICSQualityCKDATABLL.AddThroughOP(dataList, AppConfig.AppConnectString, GXOrWW);
  881. //判断是否最后一道工序
  882. //ICSQualityCKDATABLL.AddThroughZC(dataList1, AppConfig.AppConnectString);
  883. if (complete_Status != "")
  884. {
  885. ICSBaseSimpleCode.AppshowMessageBox(0, complete_Status);
  886. }
  887. _wait.Close();
  888. ICSBaseSimpleCode.AppshowMessageBox(0, "放行成功!");
  889. #region AGV调用
  890. StringBuilder errores = new StringBuilder("");
  891. foreach (var ckdata in dataList)
  892. {
  893. bool Islastop = ICSAGVBLL.IsLastOP(ckdata.LOTNO, ckdata.OPCode, AppConfig.AppConnectString, AppConfig.WorkPointCode);
  894. if (ICSAGVBLL.IsCanToAGV(ckdata.LOTNO, ckdata.OPCode, "AGV是否开启", AppConfig.AppConnectString, AppConfig.WorkPointCode)&&!Islastop)
  895. {
  896. try
  897. {
  898. ICSAGVTASKLOG Log = new ICSAGVTASKLOG();
  899. Log.ID = AppConfig.GetGuid();
  900. Log.Lotno = ckdata.LOTNO;
  901. Log.Opcode = ckdata.OPCode;
  902. bool NextOpIsWW = ICSAGVBLL.NextOPisWW(Log.Lotno, Log.Opcode, AppConfig.AppConnectString, AppConfig.WorkPointCode);
  903. bool NextOpIsWG = ICSAGVBLL.NextOPisWG(Log.Lotno, Log.Opcode, AppConfig.AppConnectString, AppConfig.WorkPointCode);
  904. string Area = "";
  905. //需要注意连续委外逻辑,当前工序和下道工序为连续委外,当前工序不触发AGV
  906. if (!(NextOpIsWW && GXOrWW == 1 && NextOpIsWG))
  907. {
  908. //FormICSAGVAreaChoose Choose = new FormICSAGVAreaChoose(true);
  909. //Choose.ShowDialog();
  910. //Area = ICSAGVBLL.GetAreaCode("00088", "4", AppConfig.AppConnectString, AppConfig.WorkPointCode);
  911. //CArea = Choose.AreaCode;
  912. //Log.TaskType = "成品检合格HH";
  913. if (NextOpIsWW)
  914. {
  915. Area = ICSAGVBLL.GetAreaCode("00088", "6", AppConfig.AppConnectString, AppConfig.WorkPointCode);
  916. Log.TaskType = "质检合格下工序委外HH";
  917. }
  918. else
  919. {
  920. Area = ICSAGVBLL.GetAreaCode("00088", "2", AppConfig.AppConnectString, AppConfig.WorkPointCode);
  921. Log.TaskType = "质检合格HH";
  922. }
  923. string BeginArea = Area.Split('@')[0].Split(':')[0];
  924. string EndArea = Area.Split('@')[1].Split(':')[0];
  925. AGVCreateTaskModel model = new AGVCreateTaskModel();
  926. model.area = EndArea.Split(':')[0];
  927. model.qty = qty;
  928. //model.station = BeginArea.Split(':')[0];
  929. model.type = "false";
  930. model.materialCode = itemcode;
  931. model.materialName = itemname;
  932. model.trackingNumber = Log.Lotno;
  933. model.orderCode = ckdata.MOCODE;
  934. model.warehouseCode = "KS0001";
  935. Log.LocationCode = BeginArea;
  936. Log.EndArea = EndArea;
  937. Log.Mtime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  938. Log.MuserName = AppConfig.UserName;
  939. FormICSAGVContainer contain = new FormICSAGVContainer(model,Log);
  940. contain.ShowDialog();
  941. }
  942. }
  943. catch (Exception ex)
  944. {
  945. errores.Append("AGV任务异常:"+ex.Message+"");
  946. continue;
  947. }
  948. }
  949. }
  950. if (!string.IsNullOrEmpty(errores.ToString()))
  951. {
  952. ICSBaseSimpleCode.AppshowMessageBox(errores.ToString());
  953. }
  954. #endregion
  955. btnSearch_Click(null, null);
  956. txtLotNo.Focus();
  957. txtLotNo.SelectAll();
  958. }
  959. catch (Exception ex)
  960. {
  961. _wait.Close();
  962. MessageBox.Show(ex.Message);
  963. }
  964. }
  965. #endregion
  966. #endregion
  967. private bool CheckIsOK(int OPSEQ)
  968. {
  969. bool isfalse = false;
  970. string _OQCSql = @"SELECT DISTINCT ACTION,CC.RESULT FROM ICSLOTONWIP bb WITH (nolock)
  971. LEFT JOIN ICSLOTONWIPCHECK CC ON BB.ID=CC.ONWIPID
  972. INNER JOIN ICSITEMROUTE2OPLot a WITH (nolock) ON bb.lotno=a.lotno and bb.opcode=a.opcode
  973. WHERE bb.LotNo='" + txtLotNo.Text + "' AND a.OPSEQ='" + OPSEQ + "' AND ISNULL(CC.RESULT,'')<>''";
  974. DataTable _OQCdt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, _OQCSql).Tables[0];
  975. if (_OQCdt != null && _OQCdt.Rows.Count > 0)
  976. {
  977. isfalse = false;
  978. }
  979. else
  980. {
  981. isfalse = true;
  982. }
  983. return isfalse;
  984. }
  985. //
  986. //已经放行的还能判退吗???
  987. //自控的判退,放行是没有工序管控的,只到批次,现在是否需要工序纬度
  988. private void btnReturn_Click_bak(object sender, EventArgs e)
  989. {
  990. string id = "";
  991. List<string> editList = new List<string>();
  992. for (int i = 0; i < grvDetail.RowCount; i++)
  993. {
  994. //if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  995. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "True")
  996. {
  997. //id = grvDetail.GetRowCellValue(i, colID).ToString();
  998. string lotno = grvDetail.GetRowCellValue(i, colLOTNO).ToString();
  999. editList.Add(lotno);
  1000. }
  1001. }
  1002. if (editList.Count == 0)
  1003. {
  1004. MessageBox.Show("请选择数据");
  1005. return;
  1006. }
  1007. if (string.IsNullOrEmpty(this.txtReturn.Text.Trim()))
  1008. {
  1009. MessageBox.Show("请填写判退原因");
  1010. return;
  1011. }
  1012. string strResult = "";
  1013. try
  1014. {
  1015. List<string> codeList = new List<string>();
  1016. List<ICSQualityCKDATA> modelList = new List<ICSQualityCKDATA>();
  1017. List<string> UnCKRCV = new List<string>();
  1018. List<string> IsCKedCK = new List<string>();
  1019. List<WMSICSINSPECTIONModel> InsList = new List<WMSICSINSPECTIONModel>();
  1020. string docNo = "";
  1021. string docLine = "";
  1022. decimal QTY = 0;
  1023. string itemcode = "";
  1024. string Luhao = "";
  1025. bool IsFirst = true;
  1026. for (int i = 0; i < grvDetail.RowCount; i++)
  1027. {
  1028. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "True")
  1029. {
  1030. ICSQualityCKDATA model = new ICSQualityCKDATA();
  1031. //string IsCanCK = grvDetail.GetRowCellValue(i, colIsCanCK).ToString();
  1032. string lotno = grvDetail.GetRowCellValue(i, colLOTNO).ToString();
  1033. model.LOTNO = grvDetail.GetRowCellValue(i, colLOTNO).ToString();
  1034. model.OPCode = grvDetail.GetRowCellValue(i, colOPCODE).ToString();
  1035. model.MOCODE = grvDetail.GetRowCellValue(i, colMOCode).ToString();
  1036. model.SEQ = Int32.Parse(grvDetail.GetRowCellValue(i, colMOSEQ).ToString());
  1037. model.CKResult = "0";
  1038. docNo = model.MOCODE;
  1039. docLine = model.SEQ.ToString();
  1040. itemcode = grvDetail.GetRowCellValue(i, colITEMCODE).ToString();
  1041. QTY = Decimal.Parse(grvDetail.GetRowCellValue(i, colLOTQTY).ToString());
  1042. modelList.Add(model);
  1043. //if (IsCanCK != "OK")
  1044. //{
  1045. //if (!UnCKRCV.Contains(docNo))
  1046. //{
  1047. // UnCKRCV.Add(docNo);
  1048. //}
  1049. //}
  1050. //else
  1051. //{
  1052. bool Isck = ICSQualityCKDATABLL.IsLLCKByLotNo(lotno);
  1053. if (Isck)
  1054. {
  1055. IsCKedCK.Add(lotno);
  1056. }
  1057. else
  1058. {
  1059. codeList.Add(lotno);
  1060. QTY += Convert.ToDecimal(grvDetail.GetRowCellValue(i, colLOTQTY).ToString());
  1061. strResult += grvDetail.GetRowCellValue(i, colLOTNO).ToString() + ",";
  1062. WMSICSINSPECTIONModel ins = new WMSICSINSPECTIONModel();
  1063. ins.LotNO = lotno;
  1064. ins.INVCODE = grvDetail.GetRowCellValue(i, colITEMCODE).ToString();
  1065. ins.VENDORITEMCODE = grvDetail.GetRowCellValue(i, colITEMCODE).ToString();
  1066. ins.LOTQTY = Convert.ToDecimal(grvDetail.GetRowCellValue(i, colLOTQTY).ToString());
  1067. ins.NLOTQTY = Convert.ToDecimal(grvDetail.GetRowCellValue(i, colLOTQTY).ToString());
  1068. ins.BadCause = this.txtReturn.Text.Trim();
  1069. //ins.TransNO = grvDetail.GetRowCellValue(i, colPOCode).ToString();
  1070. //ins.TransLine = grvDetail.GetRowCellValue(i, colPoLineNo).ToString();
  1071. ins.TYPE = "采购入库";
  1072. InsList.Add(ins);
  1073. //}
  1074. }
  1075. //判断是否有相同的炉号,报检单号,料号,行号
  1076. if (IsFirst)
  1077. {
  1078. IsFirst = false;
  1079. //docNo = grvDetail.GetRowCellValue(i, colRcvDocNo).ToString();
  1080. itemcode = grvDetail.GetRowCellValue(i, colITEMCODE).ToString();
  1081. //Luhao = grvDetail.GetRowCellValue(i, colRcvLineInvLotFurnace).ToString();
  1082. //docLine = grvDetail.GetRowCellValue(i, colRcvLineNo).ToString();
  1083. }
  1084. else
  1085. {
  1086. //if (docNo != grvDetail.GetRowCellValue(i, colRcvDocNo).ToString() ||
  1087. // itemcode != grvDetail.GetRowCellValue(i, colItemCode).ToString() ||
  1088. // Luhao != grvDetail.GetRowCellValue(i, colRcvLineInvLotFurnace).ToString() ||
  1089. // docLine != grvDetail.GetRowCellValue(i, colRcvLineNo).ToString())
  1090. if (itemcode != grvDetail.GetRowCellValue(i, colITEMCODE).ToString())
  1091. {
  1092. ICSBaseSimpleCode.AppshowMessageBox("请选择相同料号,报检单号,行号,炉号的批次条码!");
  1093. return;
  1094. }
  1095. }
  1096. }
  1097. }
  1098. if (codeList.Count == 0 && UnCKRCV.Count == 0 && IsCKedCK.Count == 0)
  1099. {
  1100. ICSBaseSimpleCode.AppshowMessageBox("请选择需要判退的批次条码!");
  1101. return;
  1102. }
  1103. string mess = "";
  1104. //if (UnCKRCV.Count != 0)
  1105. //{
  1106. // mess += "以下到货单未达到抽检比例,不能放行:" + string.Join(",", UnCKRCV.ToArray());
  1107. //}colIsSendNCR
  1108. if (IsCKedCK.Count != 0)
  1109. {
  1110. mess += "以下批次已经放行或判退,不能判退:" + string.Join(",", IsCKedCK.ToArray());
  1111. }
  1112. if (!string.IsNullOrEmpty(mess))
  1113. {
  1114. ICSBaseSimpleCode.AppshowMessageBox(mess);
  1115. }
  1116. if (codeList.Count != 0)
  1117. {
  1118. ICSQualityCKDATABLL.AddReturn(modelList, AppConfig.AppConnectString, this.txtReturn.Text.Trim());
  1119. //SRM用的,可以注释
  1120. //ICSQualityCKDATABLL.InsertICSINSPECTION(InsList);
  1121. //这里需要
  1122. SendNCR(codeList, this.txtReturn.Text.Trim(), docNo, docLine, QTY, Luhao, itemcode);
  1123. ICSBaseSimpleCode.AppshowMessageBox(0, "判退成功!");
  1124. btnSearch_Click(null, null);
  1125. }
  1126. this.txtReturn.Text = "";
  1127. }
  1128. catch (Exception ex)
  1129. {
  1130. MessageBox.Show(ex.Message);
  1131. }
  1132. }
  1133. private void btnReturn_Click(object sender, EventArgs e)
  1134. {
  1135. if (string.IsNullOrEmpty(this.txtReturn.Text.Trim()))
  1136. {
  1137. MessageBox.Show("请填写判退原因");
  1138. return;
  1139. }
  1140. string strResult = "";
  1141. try
  1142. {
  1143. List<ICSQualityCKDATA> ckList = new List<ICSQualityCKDATA>();//工序检验
  1144. List<string> codeList = new List<string>();
  1145. string MOCODE = "";
  1146. decimal QTY = 0;
  1147. string itemcode = "";
  1148. string itemname = "";
  1149. String OPCODE = "";
  1150. bool IsFirst = true;
  1151. for (int i = 0; i < grvDetail.RowCount; i++)
  1152. {
  1153. ICSQualityCKDATA item = new ICSQualityCKDATA();//工序检验
  1154. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "True")
  1155. {
  1156. string lot = grvDetail.GetRowCellValue(i, colLOTNO).ToString();
  1157. string opcode = grvDetail.GetRowCellValue(i, colOPCODE).ToString();
  1158. string mocode = grvDetail.GetRowCellValue(i, colMOCode).ToString();
  1159. itemname = grvDetail.GetRowCellValue(i, colINVDESC).ToString();
  1160. //string ID = grvDetail.GetRowCellValue(i, colID).ToString();
  1161. 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 + "' )";
  1162. DataTable lastop = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  1163. if (lastop.Rows.Count > 0&&!string.IsNullOrEmpty(lastop.Rows[0]["opseq"].ToString()))
  1164. {
  1165. bool isOK = CheckIsOK(Convert.ToInt32(lastop.Rows[0]["opseq"]));
  1166. if (!isOK)
  1167. {
  1168. ICSBaseSimpleCode.AppshowMessageBox("上道工序未检验或检验结果不合格,不能判定!");
  1169. return;
  1170. }
  1171. }
  1172. string Status = grvDetail.GetRowCellValue(i, colState).ToString();
  1173. if (Status == "已检测")
  1174. {
  1175. ICSBaseSimpleCode.AppshowMessageBox("当前批次:" + lot + ",工单:" + mocode + ",工序:" + opcode + "已经检测,不能继续判退!");
  1176. return;
  1177. }
  1178. item.LOTNO = lot;
  1179. item.OPCode = opcode;
  1180. item.MOCODE = mocode;
  1181. item.CKResult = "0";
  1182. //item.ID = ID;
  1183. if (!ckList.Contains(item))
  1184. {
  1185. ckList.Add(item);
  1186. }
  1187. if (!codeList.Contains(lot))
  1188. {
  1189. strResult += lot + ",";
  1190. codeList.Add(lot);
  1191. }
  1192. QTY += Convert.ToDecimal(grvDetail.GetRowCellValue(i, colLOTQTY).ToString());
  1193. if (string.IsNullOrEmpty(itemcode))
  1194. {
  1195. itemcode = grvDetail.GetRowCellValue(i, colITEMCODE).ToString();
  1196. }
  1197. //判断是否有相同的 工单
  1198. if (IsFirst)
  1199. {
  1200. IsFirst = false;
  1201. MOCODE = mocode;
  1202. OPCODE = opcode;
  1203. }
  1204. else
  1205. {
  1206. if (MOCODE != mocode)
  1207. {
  1208. ICSBaseSimpleCode.AppshowMessageBox("请选择相同工单号的批次条码!");
  1209. return;
  1210. }
  1211. if (OPCODE != opcode)
  1212. {
  1213. ICSBaseSimpleCode.AppshowMessageBox("请选择相同工序的批次条码!");
  1214. return;
  1215. }
  1216. }
  1217. if (GXOrWW == 0)
  1218. {
  1219. #region 20210709下道工序开工,上道工序质量检验就不能判退或者放行,提示下道工序已开工
  1220. string sqlCheck = @"SELECT b.OPSEQ FROM
  1221. ICSITEMROUTE2OPLot b
  1222. LEFT JOIN ICSLOTONWIP a ON b.OPCODE=a.OPCODE AND b.lotno=a.lotno
  1223. WHERE a.LOTNO='" + lot + "' and b.OPCODE='" + opcode + "' ORDER BY OPSEQ";
  1224. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sqlCheck).Tables[0];
  1225. if (data != null && data.Rows.Count > 0)
  1226. {
  1227. int _OPSEQ = 0;
  1228. string OPSEQ = data.Rows[0][0].ToString();
  1229. //if (!string.IsNullOrWhiteSpace(OPSEQ))
  1230. //{
  1231. // _OPSEQ = Int32.Parse(OPSEQ) + 10;
  1232. //}
  1233. // string sqlDownOP = @"SELECT a.ACTIONRESULT,b.OPCODE,b.OPSEQ FROM
  1234. // ICSROUTE2OP b
  1235. // LEFT JOIN ICSLOTONWIP a ON b.OPCODE=a.OPCODE AND b.ROUTECODE=a.RouteCode
  1236. // WHERE a.LOTNO='" + lot + "' AND b.OPSEQ='" + _OPSEQ + "' ORDER BY OPSEQ";
  1237. string sqlDownOP = @"SELECT b.OPSEQ FROM
  1238. ICSITEMROUTE2OPLot b
  1239. LEFT JOIN ICSLOTONWIP a ON b.OPCODE=a.OPCODE AND b.lotno=a.lotno
  1240. WHERE a.LOTNO='" + lot + "' AND b.OPSEQ>'" + OPSEQ + "' ORDER BY OPSEQ";
  1241. DataTable _data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sqlDownOP).Tables[0];
  1242. if (_data != null && _data.Rows.Count > 0)
  1243. {
  1244. MessageBox.Show("下道工序已开工,不能执行判退,请核对!");
  1245. return;
  1246. }
  1247. }
  1248. else
  1249. {
  1250. MessageBox.Show("当前工序没开工工序,不能执行判退,请核对!");
  1251. return;
  1252. }
  1253. #endregion
  1254. }
  1255. }
  1256. }
  1257. if (codeList.Count!=1)
  1258. {
  1259. ICSBaseSimpleCode.AppshowMessageBox("请选择需要判退的批次条码且只能选中一条!");
  1260. return;
  1261. }
  1262. strResult=strResult.Trim(',');
  1263. ICSQualityCKDATABLL.AddCK_GXJY(ckList, AppConfig.AppConnectString, this.txtReturn.Text.Trim(), GXOrWW);
  1264. SendNCR(codeList, strResult + this.txtReturn.Text.Trim(), QTY, itemcode, MOCODE, OPCODE);
  1265. ICSBaseSimpleCode.AppshowMessageBox(0, "判退成功!");
  1266. #region AGV调用 不合格暂时不调用
  1267. // StringBuilder errores = new StringBuilder("");
  1268. // foreach (var ckdata in ckList)
  1269. // {
  1270. // if (ICSAGVBLL.IsCanToAGV(ckdata.LOTNO, ckdata.OPCode, "AGV是否开启", AppConfig.AppConnectString, AppConfig.WorkPointCode))
  1271. // {
  1272. // try
  1273. // {
  1274. // ICSAGVTASKLOG Log = new ICSAGVTASKLOG();
  1275. // Log.ID = AppConfig.GetGuid();
  1276. // Log.Lotno = ckdata.LOTNO;
  1277. // Log.Opcode = ckdata.OPCode;
  1278. // bool Islastop = ICSAGVBLL.IsLastOP(Log.Lotno, Log.Opcode, AppConfig.AppConnectString, AppConfig.WorkPointCode);
  1279. // bool NextOpIsWW = ICSAGVBLL.NextOPisWW(Log.Lotno, Log.Opcode, AppConfig.AppConnectString, AppConfig.WorkPointCode);
  1280. // bool NextOpIsWG = ICSAGVBLL.NextOPisWG(Log.Lotno, Log.Opcode, AppConfig.AppConnectString, AppConfig.WorkPointCode);
  1281. // string Area = "";
  1282. // if (!(NextOpIsWW && GXOrWW == 1 && NextOpIsWG))
  1283. // {
  1284. // Area = ICSAGVBLL.GetAreaCode("00088", "3", AppConfig.AppConnectString, AppConfig.WorkPointCode);
  1285. // Log.TaskType = "质检不合格HH";
  1286. // string BeginArea = Area.Split('@')[0].Split(':')[0];
  1287. // string EndArea = Area.Split('@')[1].Split(':')[0];
  1288. // AGVCreateTaskModel model = new AGVCreateTaskModel();
  1289. // model.area = EndArea.Split(':')[0];
  1290. // model.qty =Convert.ToInt32(QTY);
  1291. // model.station = BeginArea.Split(':')[0];
  1292. // model.type = "false";
  1293. // model.materialCode = itemcode;
  1294. // model.materialName = itemname;
  1295. // model.trackingNumber = Log.Lotno;
  1296. // model.orderCode = ckdata.MOCODE;
  1297. // model.warehouseCode = "KS0001";
  1298. // Log.LocationCode = BeginArea;
  1299. // Log.EndArea = EndArea;
  1300. // Log.Mtime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  1301. // Log.MuserName = AppConfig.UserName;
  1302. // FormICSAGVContainer contain = new FormICSAGVContainer(model, Log);
  1303. // contain.ShowDialog();
  1304. // }
  1305. // }
  1306. // catch (Exception ex)
  1307. // {
  1308. // errores.Append("AGV任务异常:" + ex.Message + "");
  1309. // continue;
  1310. // }
  1311. // }
  1312. //}
  1313. // if (!string.IsNullOrEmpty(errores.ToString()))
  1314. // {
  1315. // ICSBaseSimpleCode.AppshowMessageBox(errores.ToString());
  1316. // }
  1317. #endregion
  1318. this.txtReturn.Text = "";
  1319. btnSearch_Click(null, null);
  1320. }
  1321. catch (Exception ex)
  1322. {
  1323. MessageBox.Show(ex.Message);
  1324. }
  1325. }
  1326. #region 提交时选择工序对前面所有工序自动开工完工
  1327. public bool LotComplete_New(string LotNo, string OPCODE, String MoCode)
  1328. { //查询此条码正在进行工序--当前工序
  1329. string seqSql = string.Format(@"SELECT f.CollectStatus
  1330. FROM ICSLOTSIMULATION f
  1331. WHERE f.LOTNO='{0}' and f.OPCODE='{1}' ", LotNo, OPCODE);
  1332. DataTable seqDt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, seqSql).Tables[0];
  1333. //BatchStartServer.BatchStartClient StartClientResult = new BatchStartServer.BatchStartClient();
  1334. //BatchStartServer.OperationResult _StartResult = new BatchStartServer.OperationResult();
  1335. //BatchEndServer.BatchEndClient EndClientResult = new BatchEndServer.BatchEndClient();
  1336. //BatchEndServer.OperationResult _EndResult = new BatchEndServer.OperationResult();
  1337. if (seqDt != null && seqDt.Rows.Count > 0)
  1338. {
  1339. if (seqDt.Rows[0]["CollectStatus"].ToString() == "COLLECT_BEGIN")//此条码当前工序已开工,需自动完工
  1340. {
  1341. //ZHCSoft.AntiwearValveExpanded.Forms.BatchEndServer.FormICSOQCOPCKDATAUIModel[] ICSOQCOPCKDATAArray = new BatchEndServer.FormICSOQCOPCKDATAUIModel[0];
  1342. //ZHCSoft.AntiwearValveExpanded.Forms.BatchEndServer.ICSECG2EC[] ICSOQCOPCKDATA = new ZHCSoft.AntiwearValveExpanded.Forms.BatchEndServer.ICSECG2EC[0];
  1343. //_EndResult = EndClientResult.GetBatchEnd_Message(true, ICSOQCOPCKDATAArray, ICSOQCOPCKDATA, LotNo, MoCode, OPCODE, "admin", AppConfig.WorkPointCode);
  1344. //if (!_EndResult.IsSuccess)
  1345. //{
  1346. // ICSBaseSimpleCode.AppshowMessageBox(LotNo + "完工失败! " + _EndResult.MESSAGE);
  1347. // return false;
  1348. //}
  1349. }
  1350. else if (seqDt.Rows[0]["CollectStatus"].ToString() == "")//自动开工完工
  1351. {
  1352. //自动开工
  1353. //_StartResult = StartClientResult.GetBatchStart_Message(LotNo, MoCode, OPCODE, "admin", AppConfig.WorkPointCode);
  1354. //if (_StartResult.IsSuccess)//自动开工成功
  1355. //{
  1356. // ZHCSoft.AntiwearValveExpanded.Forms.BatchEndServer.FormICSOQCOPCKDATAUIModel[] ICSOQCOPCKDATAArray = new BatchEndServer.FormICSOQCOPCKDATAUIModel[0];
  1357. // ZHCSoft.AntiwearValveExpanded.Forms.BatchEndServer.ICSECG2EC[] ICSOQCOPCKDATA = new ZHCSoft.AntiwearValveExpanded.Forms.BatchEndServer.ICSECG2EC[0];
  1358. // _EndResult = EndClientResult.GetBatchEnd_Message(true, ICSOQCOPCKDATAArray, ICSOQCOPCKDATA, LotNo, MoCode, OPCODE, "admin", AppConfig.WorkPointCode);
  1359. // if (!_EndResult.IsSuccess)
  1360. // {
  1361. // ICSBaseSimpleCode.AppshowMessageBox(LotNo + ":完工失败! " + _EndResult.MESSAGE);
  1362. // return false;
  1363. // }
  1364. //}
  1365. //else
  1366. //{
  1367. // ICSBaseSimpleCode.AppshowMessageBox(LotNo + "开工失败!" + _StartResult.MESSAGE);
  1368. // return false;
  1369. //}
  1370. }
  1371. }
  1372. else
  1373. {
  1374. //ZHCSoft.AntiwearValveExpanded.Forms.BatchEndServer.FormICSOQCOPCKDATAUIModel[] ICSOQCOPCKDATAArray = new BatchEndServer.FormICSOQCOPCKDATAUIModel[0];
  1375. //ZHCSoft.AntiwearValveExpanded.Forms.BatchEndServer.ICSECG2EC[] ICSOQCOPCKDATA = new ZHCSoft.AntiwearValveExpanded.Forms.BatchEndServer.ICSECG2EC[0];
  1376. //_EndResult = EndClientResult.GetBatchEnd_Message(true, ICSOQCOPCKDATAArray, ICSOQCOPCKDATA, LotNo, MoCode, OPCODE, "admin", AppConfig.WorkPointCode);
  1377. //if (!_EndResult.IsSuccess)
  1378. //{
  1379. // ICSBaseSimpleCode.AppshowMessageBox(LotNo + "完工失败! " + _EndResult.MESSAGE);
  1380. // return false;
  1381. //}
  1382. }
  1383. return true;
  1384. }
  1385. #endregion
  1386. #region 20210602
  1387. private void SendNCR(List<string> codeList, string strResult, string DocNo, string DocLine, decimal QTY, string luhao, string itemcode)
  1388. {
  1389. try
  1390. {
  1391. string codeStr = "";
  1392. foreach (string str in codeList)
  1393. {
  1394. codeStr += str + ",";
  1395. }
  1396. codeStr = codeStr.TrimEnd(',');
  1397. string NewCartonNo = "NCR" + AppConfig.GetSeverDateTime("yyyy-MM-dd").ToString("yyyyMMdd");
  1398. NewCartonNo = GetSerialCode(AppConfig.FrameConnectString, "ICSNCRDoc", "SecDocNO", NewCartonNo, 3);
  1399. ICSSecDocType secDocType = ICSSecDocTypeBLL.select("QC_Collect", AppConfig.FrameConnectString);
  1400. //获取对应的接收人和抄送人
  1401. ICSSecDocTypeStep docTypeStep = ICSSecDocTypeStepBLL.selectStepBySeq(secDocType.guid, "1", AppConfig.FrameConnectString);
  1402. string ToUserList = "";
  1403. //ToUserList = ICSNCRDocBLL.QualityEngineer(UserControlLLNew.GetUserCode, AppConfig.AppConnectString);
  1404. ToUserList = ICSNCRDocBLL.QualityEngineer("", AppConfig.AppConnectString);
  1405. if (string.IsNullOrEmpty(ToUserList))
  1406. {
  1407. ToUserList = ICSNCRDocBLL.QualityEngineer("来料", AppConfig.AppConnectString);
  1408. }
  1409. string CCUserList = ICSNCRDocBLL.QualityEngineer("经理", AppConfig.AppConnectString);
  1410. ICSNCRDoc SecDoc = new ICSNCRDoc();
  1411. SecDoc.SecDocNO = NewCartonNo;
  1412. SecDoc.SecDocType = secDocType.guid;
  1413. SecDoc.SecDocStatus = "已发送";
  1414. SecDoc.SecDocSeq = 1;
  1415. //SecDoc.SecDocCreateUser = UserControlLLNew.GetUserCode;
  1416. //SecDoc.SecDocCreateUserName = UserControlLLNew.GetUserName;
  1417. SecDoc.SecDocCreateUser = AppConfig.UserCode;
  1418. SecDoc.SecDocCreateUserName = AppConfig.UserName;
  1419. SecDoc.SecDocCreateTime = AppConfig.GetSeverDateTime("");
  1420. SecDoc.ErrorType = "来料";
  1421. SecDoc.EQPCode = "";
  1422. SecDoc.ItemCode = itemcode;
  1423. SecDoc.ProjectCode = "";
  1424. SecDoc.TimeLimit = "1";
  1425. SecDoc.ContentDesc = strResult;
  1426. SecDoc.EATTRIBUTE1 = codeStr;
  1427. SecDoc.ToUserList = ToUserList;
  1428. SecDoc.CCUserList = CCUserList;
  1429. SecDoc.LOTNO = DocNo;
  1430. SecDoc.OPCode = DocLine;
  1431. SecDoc.SecDocOKTime = Convert.ToDateTime("1990-01-01");
  1432. SecDoc.Qty = QTY;
  1433. SecDoc.SrcDocInfo = codeStr;
  1434. SecDoc.Furnace = luhao;
  1435. ICSNCRDocDoDetail SecDocDoDetail = new ICSNCRDocDoDetail();
  1436. SecDocDoDetail.DepCode = docTypeStep.DocTypeTo;
  1437. ICSNCRDoc NCR = new ICSNCRDoc();
  1438. NCR = null;//modify on 20200418
  1439. if (NCR == null)
  1440. {
  1441. ICSNCRDocBLL.CreateNCR(SecDoc, AppConfig.AppConnectString);
  1442. }
  1443. else
  1444. {
  1445. MessageBox.Show(codeStr + "已产生NCR单号:" + NCR.SecDocNO + ",不能新增NCR单");
  1446. }
  1447. }
  1448. catch (Exception ex)
  1449. {
  1450. throw new Exception(ex.Message);
  1451. }
  1452. }
  1453. private void SendNCR(string strResult, string RcvDocNo, string ItemCode, string ItemName, string ProjectCode, decimal QTY)
  1454. {
  1455. try
  1456. {
  1457. string NewCartonNo = "NCR" + AppConfig.GetSeverDateTime("yyyy-MM-dd").ToString("yyyyMMdd");
  1458. NewCartonNo = GetSerialCode(AppConfig.FrameConnectString, "ICSNCRDoc", "SecDocNO", NewCartonNo, 3);
  1459. ICSSecDocType secDocType = ICSSecDocTypeBLL.select("QC_Collect", AppConfig.FrameConnectString);
  1460. //获取对应的接收人和抄送人
  1461. ICSSecDocTypeStep docTypeStep = ICSSecDocTypeStepBLL.selectStepBySeq(secDocType.guid, "1", AppConfig.FrameConnectString);
  1462. string ToUserList = "";
  1463. ToUserList = ICSNCRDocBLL.QualityEngineer(AppConfig.UserCode, AppConfig.AppConnectString);
  1464. if (string.IsNullOrEmpty(ToUserList))
  1465. {
  1466. ToUserList = ICSNCRDocBLL.QualityEngineer("来料", AppConfig.AppConnectString);
  1467. }
  1468. string CCUserList = ICSNCRDocBLL.QualityEngineer("经理", AppConfig.AppConnectString);
  1469. ICSNCRDoc SecDoc = new ICSNCRDoc();
  1470. SecDoc.SecDocNO = NewCartonNo;
  1471. SecDoc.SecDocType = secDocType.guid;
  1472. SecDoc.SecDocStatus = "已发送";
  1473. SecDoc.SecDocSeq = 1;
  1474. SecDoc.SecDocCreateUser = AppConfig.UserCode;
  1475. SecDoc.SecDocCreateUserName = AppConfig.UserName;
  1476. SecDoc.SecDocCreateTime = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
  1477. SecDoc.ErrorType = "来料";
  1478. SecDoc.EQPCode = "";
  1479. SecDoc.ItemCode = ItemCode;
  1480. SecDoc.ProjectCode = ProjectCode;
  1481. SecDoc.TimeLimit = "1";
  1482. SecDoc.ContentDesc = strResult;
  1483. SecDoc.ToUserList = ToUserList;
  1484. SecDoc.CCUserList = CCUserList;
  1485. SecDoc.LOTNO = RcvDocNo.Split('_')[0];
  1486. SecDoc.OPCode = RcvDocNo.Split('_')[1];
  1487. SecDoc.SecDocOKTime = Convert.ToDateTime("1990-01-01");
  1488. SecDoc.SrcDocInfo = RcvDocNo.Split('_')[0];
  1489. SecDoc.Qty = QTY;
  1490. ICSNCRDoc NCR = new ICSNCRDoc();
  1491. NCR = null;//modify on 20200418
  1492. if (NCR == null)
  1493. {
  1494. ICSNCRDocBLL.CreateNCR(SecDoc, AppConfig.AppConnectString);
  1495. }
  1496. else
  1497. {
  1498. MessageBox.Show(RcvDocNo.Split('_')[0] + "已产生NCR单号:" + NCR.SecDocNO + ",不能新增NCR单");
  1499. }
  1500. }
  1501. catch (Exception ex)
  1502. {
  1503. throw new Exception(ex.Message);
  1504. }
  1505. }
  1506. private void SendNCR(List<string> codeList, string strResult, decimal QTY, string itemcode, string mocode, string OPCODE)
  1507. {//
  1508. try
  1509. {
  1510. string codeStr = "";
  1511. foreach (string str in codeList)
  1512. {
  1513. codeStr += str + ",";
  1514. }
  1515. codeStr = codeStr.TrimEnd(',');
  1516. string NewCartonNo = "NCR" + AppConfig.GetSeverDateTime("yyyy-MM-dd").ToString("yyyyMMdd");
  1517. NewCartonNo = GetSerialCode(AppConfig.FrameConnectString, "ICSNCRDoc", "SecDocNO", NewCartonNo, 3);
  1518. ICSSecDocType secDocType = ICSSecDocTypeBLL.select("QC_Collect", AppConfig.FrameConnectString);
  1519. #region 20210816
  1520. //获取对应的接收人和抄送人
  1521. //ICSSecDocTypeStep docTypeStep = ICSSecDocTypeStepBLL.selectStepBySeq(secDocType.guid, "1", AppConfig.FrameConnectString);
  1522. //string ToUserList = "";
  1523. //ToUserList = ICSNCRDocBLL.QualityEngineer(CKType, AppConfig.AppConnectString);
  1524. #endregion
  1525. //string CCUserList = ICSNCRDocBLL.QualityEngineer("经理", AppConfig.AppConnectString);
  1526. //string sql = @"SELECT a.ProjectCode FROM ICSMO a WHERE a.MOCODE='{0}'";
  1527. //sql = string.Format(sql, mocode);
  1528. //DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  1529. string ProjectCode = "";
  1530. //if (dt != null && dt.Rows.Count > 0)
  1531. //{
  1532. // ProjectCode = dt.Rows[0]["ProjectCode"].ToString();
  1533. //}
  1534. ICSNCRDoc SecDoc = new ICSNCRDoc();
  1535. SecDoc.SecDocNO = NewCartonNo;
  1536. SecDoc.SecDocType = secDocType.guid;
  1537. SecDoc.SecDocStatus = "已发送";
  1538. SecDoc.SecDocSeq = 1;
  1539. SecDoc.SecDocCreateUser = AppConfig.UserCode;
  1540. SecDoc.SecDocCreateUserName = AppConfig.UserName;
  1541. SecDoc.SecDocCreateTime = AppConfig.GetSeverDateTime("");
  1542. //SecDoc.ErrorType = CKType;
  1543. SecDoc.ErrorType = "工序检验";//modify on 20201202 NCRtype修改
  1544. SecDoc.EQPCode = "";
  1545. SecDoc.ItemCode = itemcode;
  1546. SecDoc.ProjectCode = ProjectCode;
  1547. SecDoc.TimeLimit = "1";
  1548. SecDoc.ContentDesc = strResult;
  1549. SecDoc.EATTRIBUTE2 = CKType;
  1550. //SecDoc.ToUserList = ToUserList;
  1551. //SecDoc.CCUserList = CCUserList;
  1552. //SecDoc.ToUserList = ToUserList;
  1553. //SecDoc.CCUserList = CCUserList;
  1554. SecDoc.LOTNO = "";
  1555. SecDoc.OPCode = OPCODE;
  1556. SecDoc.SecDocOKTime = Convert.ToDateTime("1990-01-01");
  1557. SecDoc.Qty = QTY;
  1558. SecDoc.SrcDocInfo = codeStr;
  1559. ICSNCRDoc NCR = new ICSNCRDoc();
  1560. // NCR = ICSNCRDocBLL.selectBySrcDocInfo(codeStr, AppConfig.AppConnectString);
  1561. NCR = null;//modify on 20200418
  1562. if (NCR == null)
  1563. {
  1564. ICSNCRDocBLL.CreateNCR(SecDoc, AppConfig.AppConnectString);
  1565. }
  1566. else
  1567. {
  1568. MessageBox.Show(codeStr + "已产生NCR单号:" + NCR.SecDocNO + ",不能新增NCR单");
  1569. }
  1570. }
  1571. catch (Exception ex)
  1572. {
  1573. throw new Exception(ex.Message);
  1574. }
  1575. }
  1576. #endregion
  1577. private DataTable GetNGCKData(string RcvDocNo, string LineNo)
  1578. {
  1579. string sql = @"select a.RcvDocNo,a.RcvLineNo,a.RcvLineItemMasterCode,a.RcvLineItemMasterName, a.RcvLineProjectCode,
  1580. a.RcvLineInvLotFurnace, C.LotNo, e.CKITEMCODE,e.CKITEMDESC,SetValueMax,SetValueMin,d.[CKValue] ,b.BarCodeQty
  1581. from [dbo].[WM_RCVShip] a
  1582. inner join [dbo].[WM_BarCode] b on a.[guid] = b.Srcguid And b.SrcType = 'WM_RCVShip'
  1583. inner join ( select * from (select ROW_NUMBER()over(partition by LOTNO order by mtime desc) rowId,*
  1584. from ICSQualityCKDATA ck where type='' ) as AuctionRecords
  1585. where rowId=1) c on b.BarCodeNo = c.LotNo And c.CKResult = '0'
  1586. inner join [dbo].[ICSQualityCKDATADetail] d on d.DataID = c.ID And d.[CKResult] = '0' And [DECKResult] = '0'
  1587. inner join [dbo].[ICSQualityCKItem] e on d.CKItemID = e.ID
  1588. where a.[RcvDocNo] = '" + RcvDocNo + "' And a.[RcvLineNo]='" + LineNo + "' order by a.RcvDocNo,a.RcvLineNo";
  1589. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  1590. return dt;
  1591. }
  1592. private void btnSelectAll_Click(object sender, EventArgs e)
  1593. {
  1594. if (ICSBaseSimpleCode.AppshowMessageBoxRepose("确定全选吗?") != DialogResult.OK)
  1595. return;
  1596. grvDetail.PostEditor();
  1597. this.Validate();
  1598. for (int i = 0; i < grvDetail.RowCount; i++)
  1599. {
  1600. grvDetail.SetRowCellValue(i, colisSelect, true);
  1601. }
  1602. }
  1603. private void btnUnSelectAll_Click(object sender, EventArgs e)
  1604. {
  1605. grvDetail.PostEditor();
  1606. this.Validate();
  1607. for (int i = 0; i < grvDetail.RowCount; i++)
  1608. {
  1609. grvDetail.SetRowCellValue(i, colisSelect, false);
  1610. }
  1611. }
  1612. private void btnDisposeIn_Click(object sender, EventArgs e)
  1613. {
  1614. //FormICSLLDispose add = new FormICSLLDispose();
  1615. //add.ShowDialog();
  1616. }
  1617. private void grvDetail_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
  1618. {
  1619. int hand = e.RowHandle;
  1620. if (hand < 0)
  1621. return;
  1622. DataRow dr = this.grvDetail.GetDataRow(hand);
  1623. if (dr == null)
  1624. return;
  1625. if (grvDetail.FocusedColumn.FieldName == "SecDocNO")
  1626. {
  1627. string userCode = AppConfig.UserCode;
  1628. string DocNo = grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colSecDocNO).ToString();
  1629. if (!string.IsNullOrWhiteSpace(DocNo))
  1630. {
  1631. if (!string.IsNullOrWhiteSpace(DocNo))
  1632. {
  1633. List<string> list = new List<string>(DocNo.Split(','));
  1634. //FormICSNCR ff = new FormICSNCR(list, 0);
  1635. //ff.Show();
  1636. }
  1637. }
  1638. }
  1639. }
  1640. private void repositoryItemHyperLinkEdit1_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  1641. {
  1642. }
  1643. private void timer1_Tick(object sender, EventArgs e)
  1644. {
  1645. //btnSearch_Click(null, null);
  1646. }
  1647. private void simpleBut_Min_Click(object sender, EventArgs e)
  1648. {
  1649. this.WindowState = FormWindowState.Minimized;
  1650. this.FormBorderStyle = FormBorderStyle.Sizable;
  1651. }
  1652. private void FormICSLL_SizeChanged(object sender, EventArgs e)
  1653. {
  1654. if (this.WindowState == FormWindowState.Minimized)
  1655. {
  1656. this.FormBorderStyle = FormBorderStyle.Sizable;
  1657. }
  1658. else
  1659. {
  1660. this.FormBorderStyle = FormBorderStyle.None;
  1661. }
  1662. }
  1663. /// <summary>
  1664. /// 获取单据号
  1665. /// </summary>
  1666. /// <param name="tbName"></param>
  1667. /// <param name="colName"></param>
  1668. /// <param name="Pre"></param>
  1669. /// <param name="numLen"></param>
  1670. /// <returns></returns>
  1671. public static string GetSerialCode(string connectString, string tbName, string colName, string Pre, int numLen)
  1672. {
  1673. string sql = "EXEC Addins_GetSerialCode '{0}','{1}','{2}','{3}',{4}";
  1674. sql = string.Format(sql, new object[] { "",tbName, colName, Pre, numLen });
  1675. return DBHelper.ExecuteScalar(connectString, CommandType.Text, sql).ToString();
  1676. }
  1677. private void grdDetail_Click(object sender, EventArgs e)
  1678. {
  1679. }
  1680. private void txtLotNo_KeyDown(object sender, KeyEventArgs e)
  1681. {
  1682. if (e.KeyCode == Keys.Enter) {
  1683. btnSearch_Click(null, null);
  1684. }
  1685. }
  1686. /// <summary>
  1687. /// 撤销功能:防止误判 1.委外检验无法撤销,判退无法撤销,下到工序已开工无法撤销
  1688. /// </summary>
  1689. /// <param name="sender"></param>
  1690. /// <param name="e"></param>
  1691. private void button1_Click(object sender, EventArgs e)
  1692. {
  1693. try
  1694. {
  1695. if (GXOrWW == 1)
  1696. throw new Exception("委外检验无法撤销!");
  1697. List<ICSQualityCKDATA> codeList = new List<ICSQualityCKDATA>();
  1698. for (int i = 0; i < grvDetail.RowCount; i++)
  1699. {
  1700. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "True")
  1701. {
  1702. string Lotno = grvDetail.GetRowCellValue(i, colLOTNO).ToString();
  1703. string opcode = grvDetail.GetRowCellValue(i, colOPCODE).ToString();
  1704. string opcodeSimu = GetSimuOp(Lotno);
  1705. if (grvDetail.GetRowCellValue(i, colResult).ToString() == "不合格")
  1706. throw new Exception("条码:" + Lotno + ",工序:" + opcode + " 已判退无法撤销!");
  1707. if (grvDetail.GetRowCellValue(i, colResult).ToString() == "未检测")
  1708. throw new Exception("条码:" + Lotno + ",工序:" + opcode + " 未检测无法撤销!");
  1709. if (opcode != opcodeSimu)
  1710. {
  1711. throw new Exception("条码:" + Lotno + "当前在制工序:" + opcodeSimu + "已开工,工序:" + opcode + "无法回撤!");
  1712. }
  1713. ICSQualityCKDATA ckdata = new ICSQualityCKDATA();
  1714. ckdata.LOTNO = Lotno;
  1715. ckdata.OPCode = opcode;
  1716. codeList.Add(ckdata);
  1717. }
  1718. }
  1719. if (codeList.Count == 0)
  1720. {
  1721. ICSBaseSimpleCode.AppshowMessageBox("请选择需要撤回判定的批次条码!");
  1722. return;
  1723. }
  1724. ICSQualityCKDATABLL.BackThroughOP(codeList, AppConfig.AppConnectString);
  1725. ICSBaseSimpleCode.AppshowMessageBox("撤回成功!");
  1726. btnSearch_Click(null, null);
  1727. }
  1728. catch (Exception EX)
  1729. {
  1730. ICSBaseSimpleCode.AppshowMessageBox(EX.Message);
  1731. }
  1732. }
  1733. public string GetSimuOp(string Lotno) {
  1734. string sql = "select Opcode from icslotsimulation where lotno='{0}'";
  1735. sql = string.Format(sql, Lotno);
  1736. return DBHelper.ExecuteDataset(AppConfig.AppConnectString,CommandType.Text,sql).Tables[0].Rows[0]["Opcode"].ToString();
  1737. }
  1738. }
  1739. }