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

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