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

3950 lines
164 KiB

5 months ago
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Data.Linq;
  6. using System.Linq;
  7. using System.Drawing;
  8. using System.Text;
  9. using System.Windows.Forms;
  10. using DevExpress.XtraEditors;
  11. using DevExpress.XtraGrid.Views.BandedGrid;
  12. using DevExpress.XtraGrid.Columns;
  13. using DevExpress.XtraGrid;
  14. using System.IO;
  15. using System.Threading;
  16. using ICSSoft.Base.Language.Tool;
  17. using ICSSoft.Base.Config.AppConfig;
  18. using ICSSoft.Base.UserControl.MessageControl;
  19. using ICSSoft.Base.Config.DBHelper;
  20. using ICSSoft.Base.Report.Filter;
  21. using ICSSoft.Base.UserControl.FormControl;
  22. using ICSSoft.Base.Report.GridReport;
  23. using ICSSoft.Base.ReferForm.AppReferForm;
  24. using ICSSoft.Frame.Data.BLL;
  25. using ICSSoft.Frame.Data.Entity;
  26. using Newtonsoft.Json;
  27. using Newtonsoft.Json.Linq;
  28. using ICSSoft.Frame.Common;
  29. namespace ICSSoft.Frame.APP
  30. {
  31. public partial class FormICSIPQCAGVHH : DevExpress.XtraEditors.XtraForm
  32. {
  33. private string sqltxt = "";
  34. private string sqlconn = "";
  35. private string CCNCRresult = "";
  36. private string WGNCRresult = "";
  37. String guid = AppConfig.GetGuid();
  38. private DataTable dataSource = null;
  39. //string ID = "";
  40. string ItemCode = string.Empty;
  41. string ItemName = string.Empty; string INVDESC = string.Empty; string RCVCode = string.Empty; string LotNo = string.Empty;
  42. string RouteCode = "";
  43. string opseq = "";
  44. Decimal TotalQty = 0;
  45. Decimal YLOTQTY = 0; Decimal UYLOTQTY = 0;
  46. string OPCode = string.Empty;
  47. //0906
  48. string status1 = "";
  49. string status2 = "";
  50. #region 构造函数
  51. public FormICSIPQCAGVHH()
  52. {
  53. InitializeComponent();
  54. this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  55. this.WindowState = FormWindowState.Maximized;
  56. checkboxGX.Checked = true;
  57. }
  58. #endregion
  59. #region 构造函数
  60. public FormICSIPQCAGVHH(string _ItemCode, string _ItemName, string _INVDESC, string _RCVCode, string _LotNo, Decimal _TotalQty, Decimal _YLOTQTY, Decimal _UYLOTQTY)
  61. {
  62. InitializeComponent();
  63. this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  64. this.WindowState = FormWindowState.Maximized;
  65. txtUserName.Text = ItemCode = _ItemCode;
  66. //txtItemName.Text = ItemName = _ItemName;
  67. txtLotNo.Text = LotNo = _LotNo;
  68. //txtItemINVDESC.Text = INVDESC = _INVDESC;
  69. //txtTotalQty.Text = _TotalQty.ToString();
  70. txtProductCode.Text = _ItemCode;
  71. txtPriductName.Text = _ItemName;
  72. txtMOCode.Text = "";
  73. TotalQty = _TotalQty;
  74. RCVCode = _RCVCode;
  75. Decimal YLOTQTY = _YLOTQTY; Decimal UYLOTQTY = _UYLOTQTY;
  76. init();
  77. BandData(ItemCode, LotNo, OPCode);
  78. }
  79. public FormICSIPQCAGVHH(string _ItemCode, string _LotNo, string OPCode)
  80. {
  81. InitializeComponent();
  82. this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  83. this.WindowState = FormWindowState.Maximized;
  84. txtUserName.Text = ItemCode = _ItemCode;
  85. txtLotNo.Text = LotNo = _LotNo;
  86. //txtItemINVDESC.Text = INVDESC = _INVDESC;
  87. //txtTotalQty.Text = _TotalQty.ToString();
  88. txtProductCode.Text = _ItemCode;
  89. //txtPriductName.Text = _ItemName;
  90. //txtMOCode.Text = "";
  91. //TotalQty = _TotalQty;
  92. //RCVCode = _RCVCode;
  93. //Decimal YLOTQTY = _YLOTQTY; Decimal UYLOTQTY = _UYLOTQTY;
  94. init();
  95. BandData(ItemCode, LotNo, OPCode);
  96. initCheck();
  97. }
  98. #endregion
  99. #region 初始化查询条件
  100. private void init()
  101. {
  102. #region
  103. string sql = @"SELECT DISTINCT b.CKGROUPDESC,a.InspectionStandard CKGROUPDNAME, a.CKListCode CKGROUPCode,a.VALUEMAX SetValueMax,a.VALUEMIN SetValueMin,a.CheckResultValue CheckResult,a.IsOK,a.CCorWGResult FROM ICSOQCCKGROUP2LISTCheckResult a
  104. LEFT JOIN ICSOQCCKGROUP b ON a.CKListCode=b.CKGROUP
  105. WHERE a.LOTNO='" + txtLotNo.Text + "' AND a.OPCode='" + txtOPCode.Text + "' and CheckoutAttribute='' ";
  106. sql = string.Format(sql, AppConfig.WorkPointCode);
  107. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  108. if (dt != null && dt.Rows.Count > 0)
  109. {
  110. gridControlcc.DataSource = dt;
  111. if (dt != null && dt.Rows.Count > 0)
  112. {
  113. bool istrue = false;
  114. foreach (DataRow item in dt.Rows)
  115. {
  116. string resultCC = item["CCorWGResult"].ToString();
  117. if (resultCC == "NG")
  118. {
  119. istrue = false;
  120. break;
  121. }
  122. if (resultCC == "OK")
  123. {
  124. istrue = true;
  125. }
  126. }
  127. if (istrue)
  128. {
  129. this.txtCCResult.Text = "OK";
  130. this.txtCCResult.BackColor = Color.Blue;
  131. }
  132. else
  133. {
  134. this.txtCCResult.Text = "NG";
  135. this.txtCCResult.BackColor = Color.Red;
  136. }
  137. }
  138. }
  139. else
  140. {
  141. string _OQCSql = @"SELECT DISTINCT a.SetValueMax,a.SetValueMin,a.CKGROUPCode,b.CKGROUPDESC,b.CKGROUPDNAME,a.EATTRIBUTE1 Remark,'' CheckResult FROM ICSOQCCKLIST a
  142. LEFT JOIN ICSOQCCKGROUP b ON a.CKGROUPCode=b.CKGROUP
  143. WHERE INVCode='" + txtProductCode.Text + "' AND a.CKGROUPATTR='' and a.ISREF='是' AND a.OPCode='" + this.txtOPCode.Text + "' and a.CKGROUPMETH ='' ";//0906
  144. DataTable _OQCdt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, _OQCSql).Tables[0];
  145. gridControlcc.DataSource = _OQCdt;
  146. }
  147. //}
  148. #endregion
  149. string sql2 = @"SELECT DISTINCT b.CKGROUPDESC CKGROUPDESC1,a.InspectionStandard CKGROUPMETH,a.AQL CKGROUPATTR, a.CKListCode CKGROUPCode1,a.CheckResultValue,
  150. CAST (ISNULL(a.IsOK, 0) AS BIT) AS OK
  151. FROM ICSOQCCKGROUP2LISTCheckResult a
  152. LEFT JOIN ICSOQCCKGROUP b ON a.CKListCode=b.CKGROUP
  153. WHERE a.LOTNO='" + txtLotNo.Text + "' AND a.OPCode='" + txtOPCode.Text + "' and CheckoutAttribute='' AND a.InspectionStandard ='' ";
  154. sql2 = string.Format(sql2, AppConfig.WorkPointCode);
  155. DataTable dt2 = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql2).Tables[0];
  156. if (dt2 != null && dt2.Rows.Count > 0)
  157. {
  158. gridControl2.DataSource = dt2;
  159. if (dt2 != null && dt2.Rows.Count > 0)
  160. {
  161. bool istrue = false;
  162. foreach (DataRow item in dt2.Rows)
  163. {
  164. //string resultCC = item["CCorWGResult"].ToString();
  165. string resultCC = item["OK"].ToString();
  166. //if (resultCC == "NG")
  167. if (resultCC == "False")
  168. {
  169. istrue = false;
  170. break;
  171. }
  172. //if (resultCC == "OK")
  173. if (resultCC == "True")
  174. {
  175. istrue = true;
  176. }
  177. }
  178. if (istrue)
  179. {
  180. this.txtWGResult.Text = "OK";
  181. this.txtWGResult.BackColor = Color.Blue;
  182. }
  183. else
  184. {
  185. this.txtWGResult.Text = "NG";
  186. this.txtWGResult.BackColor = Color.Red;
  187. }
  188. }
  189. }
  190. else
  191. {
  192. string _OQCWGSql = @"SELECT DISTINCT a.CKGROUPATTR,a.CKGROUPMETH,a.CKGROUPCode CKGROUPCode1,b.CKGROUPDESC CKGROUPDESC1,b.CKGROUPDNAME,a.EATTRIBUTE1 Remark1,CAST (ISNULL(0, 0) AS BIT) AS OK ,
  193. CAST (ISNULL(0, 0) AS BIT) AS NG FROM ICSOQCCKLIST a
  194. LEFT JOIN ICSOQCCKGROUP b ON a.CKGROUPCode=b.CKGROUP
  195. WHERE INVCode='" + txtProductCode.Text + "' AND a.CKGROUPATTR='' and a.ISREF='是' AND a.OPCode='" + txtOPCode.Text + "' and a.CKGROUPMETH='' ";//0906
  196. DataTable _OQCWGdt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, _OQCWGSql).Tables[0];
  197. gridControl2.DataSource = _OQCWGdt;
  198. }
  199. }
  200. // private void initCheck()
  201. // {
  202. // string _OQCSql = @"SELECT a.SetValueMax,a.SetValueMin,a.CKGROUPCode,b.CKGROUPDESC,b.CKGROUPDNAME,a.EATTRIBUTE1 Remark,'' CheckResult FROM ICSOQCCKLIST a
  203. //LEFT JOIN ICSOQCCKGROUP b ON a.CKGROUPCode=b.CKGROUP
  204. //WHERE INVCode='" + ItemCode + "' AND a.CKGROUPATTR='量化' and a.ISREF='是' AND a.OPCode='" + txtOPCode.Text + "' and a.CKGROUPMETH!='自主检验' ";//
  205. // DataTable _OQCdt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, _OQCSql).Tables[0];
  206. // gridControlcc.DataSource = _OQCdt;
  207. // string _OQCWGSql = @"SELECT a.CKGROUPATTR,a.CKGROUPMETH,a.CKGROUPCode CKGROUPCode1,b.CKGROUPDESC CKGROUPDESC1,b.CKGROUPDNAME,a.EATTRIBUTE1 Remark1,CAST (ISNULL(0, 0) AS BIT) AS OK ,
  208. //CAST (ISNULL(0, 0) AS BIT) AS NG FROM ICSOQCCKLIST a
  209. //LEFT JOIN ICSOQCCKGROUP b ON a.CKGROUPCode=b.CKGROUP
  210. //WHERE INVCode='" + ItemCode + "' AND a.CKGROUPATTR='外观' and a.ISREF='是' AND a.OPCode='" + txtOPCode.Text + "' and a.CKGROUPMETH!='自主检验' ";//
  211. // DataTable _OQCWGdt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, _OQCWGSql).Tables[0];
  212. // gridControl2.DataSource = _OQCWGdt;
  213. // }
  214. private void init_()
  215. {
  216. #region
  217. string sql = @"SELECT a.CKListCode ,
  218. b.CKITENAME ,
  219. a.CKGROUP,
  220. a.CKITEMCODE,
  221. a.VALUEMAX ,
  222. a.VALUEMIN ,
  223. a.UNIT,
  224. a.AQL,
  225. a.InspectionStandard
  226. FROM ICSOQCCKGROUP2LIST a
  227. LEFT JOIN ICSOQCCKLIST b ON a.CKListCode = b.CKITEMCODE
  228. WHERE a.CKITEMCODE = '" + ItemCode + "' AND a.IsUse = '1' AND a.CheckoutAttribute = ''";
  229. sql = string.Format(sql, AppConfig.WorkPointCode);
  230. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  231. gridControlcc.DataSource = dt;
  232. #endregion
  233. string sql2 = @"SELECT a.CKListCode CKListCode1 ,
  234. b.CKITENAME CKITENAME1 ,
  235. a.CKGROUP,
  236. a.CKITEMCODE,
  237. a.VALUEMAX ,
  238. a.VALUEMIN ,
  239. a.UNIT,
  240. a.AQL ,
  241. a.InspectionStandard
  242. FROM ICSOQCCKGROUP2LIST a
  243. LEFT JOIN ICSOQCCKLIST b ON a.CKListCode = b.CKITEMCODE
  244. WHERE a.CKITEMCODE = '" + ItemCode + "' AND a.IsUse = '1' AND a.CheckoutAttribute = ''";
  245. sql2 = string.Format(sql2, AppConfig.WorkPointCode);
  246. DataTable dt2 = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql2).Tables[0];
  247. gridControl2.DataSource = dt2;
  248. }
  249. #endregion
  250. #region 根据存货编码查询列表信息
  251. private void BandData(string itemCode, string LotNo, string OPCode)
  252. {
  253. try
  254. {
  255. string sql = @"SELECT EnumName FROM Sys_EnumKey WHERE EnumKey='00006'";
  256. //sql = string.Format(sql, itemCode);
  257. string connectionString = AppConfig.FrameConnectString; // AppConfig.GetDataBaseConnectStringByKey("[DB.PLM]");
  258. if (string.IsNullOrWhiteSpace(connectionString))
  259. return;
  260. object name = DBHelper.ExecuteScalar(connectionString, CommandType.Text, sql);
  261. if (name == null || string.IsNullOrWhiteSpace(name.ToString()))
  262. return;
  263. //string fileName = name.ToString() + itemCode + "\\" + RouteCode + "\\" + itemCode + OpCode + ".pdf";
  264. string fileName = name.ToString() + itemCode + "\\" + itemCode + LotNo + OPCode + ".pdf";
  265. if (!string.IsNullOrEmpty(fileName))
  266. {
  267. axAcroPDFTZ.LoadFile(fileName);
  268. axAcroPDFTZ.setShowToolbar(false);
  269. axAcroPDFTZ.setShowScrollbars(false);
  270. axAcroPDFTZ.setPageMode("thumbs");
  271. axAcroPDFTZ.setLayoutMode("SinglePage");
  272. axAcroPDFTZ.setView("Fit");
  273. axAcroPDFTZ.Show();
  274. }
  275. }
  276. catch (Exception ex)
  277. {
  278. MessageBox.Show(ex.Message);
  279. }
  280. }
  281. #endregion
  282. #region 操作权限
  283. public DataTable RightOfExute()
  284. {
  285. DataTable rData = new DataTable();
  286. rData.Columns.Add("BtnName");
  287. rData.Columns.Add("ActionName");
  288. //查看权限(必须有)
  289. DataRow seeRow = rData.NewRow();
  290. seeRow["BtnName"] = "see";
  291. seeRow["ActionName"] = "查看";
  292. rData.Rows.Add(seeRow);
  293. List<Control> ControlList = new List<Control>();
  294. //ControlList.Add(simpleButton2);
  295. //ControlList.Add(simpleButton3);
  296. //ControlList.Add(btnOutPut);
  297. foreach (Control ctr in ControlList)
  298. {
  299. if (ctr.GetType() == typeof(SimpleButton))
  300. {
  301. DataRow dr = rData.NewRow();
  302. dr["BtnName"] = ctr.Name;
  303. dr["ActionName"] = ctr.Text;
  304. rData.Rows.Add(dr);
  305. }
  306. }
  307. rData.AcceptChanges();
  308. return rData;
  309. }
  310. public DataTable RightOfData()// 数据权限
  311. {
  312. DataTable rData = new DataTable();
  313. rData.Columns.Add("BodyName");
  314. rData.Columns.Add("ControlName");
  315. rData.Columns.Add("ControlCaption");
  316. rData.AcceptChanges();
  317. return rData;
  318. }
  319. #endregion
  320. #region 退出
  321. private void btnClose_Click(object sender, EventArgs e)
  322. {
  323. AppConfig.CloseFormShow(this.Text);
  324. this.Close();
  325. }
  326. private void btnExit_Click(object sender, EventArgs e)
  327. {
  328. AppConfig.CloseFormShow(this.Text);
  329. this.Close();
  330. }
  331. #endregion
  332. #region 移动窗体
  333. private const int WM_NCHITTEST = 0x84;
  334. private const int HTCLIENT = 0x1;
  335. private const int HTCAPTION = 0x2;
  336. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  337. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  338. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  339. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  340. //重写窗体,使窗体可以不通过自带标题栏实现移动
  341. protected override void WndProc(ref Message m)
  342. {
  343. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  344. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  345. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  346. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  347. switch (m.Msg)
  348. {
  349. case WM_NCHITTEST:
  350. base.WndProc(ref m);
  351. if ((int)m.Result == HTCLIENT)
  352. m.Result = (IntPtr)HTCAPTION;
  353. return;
  354. }
  355. //拦截双击标题栏、移动窗体的系统消息
  356. if (m.Msg != 0xA3)
  357. {
  358. base.WndProc(ref m);
  359. }
  360. }
  361. #endregion
  362. #region 列表
  363. private void grvDetail_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
  364. {
  365. if (e.Info.IsRowIndicator && e.RowHandle >= 0)
  366. e.Info.DisplayText = (e.RowHandle + 1).ToString();
  367. }
  368. #endregion
  369. #region 过滤
  370. //private string tempTableName = "";
  371. //private void btnFilter_Click(object sender, EventArgs e)
  372. //{
  373. // FormFilter filter = new FormFilter(AppConfig.GetSourceId(this.Tag.ToString(), btnConfig.Name));
  374. // filter.OldTempTableName = tempTableName;
  375. // if (filter.ShowDialog() == DialogResult.OK)
  376. // {
  377. // DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在查找...请稍等...");
  378. // try
  379. // {
  380. // _wait.Show();
  381. // tempTableName = filter.NewTempTableName;
  382. // sqltxt = filter.SqlText;
  383. // sqlconn = filter.FilterConnectString;
  384. // dataSource = filter.FilterData.Tables[0];
  385. // grdDetail.DataSource = dataSource;
  386. // grvDetail.BestFitColumns();
  387. // rptPage.RecordNum = dataSource.Rows.Count;
  388. // rptPage.PageSize = 499;
  389. // rptPage.PageIndex = 1;
  390. // rptPage.ReLoad();
  391. // rptPage.PageSize = 500;
  392. // rptPage.PageIndex = 1;
  393. // rptPage.ReLoad();
  394. // _wait.Close();
  395. // }
  396. // catch (Exception ex)
  397. // {
  398. // MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  399. // _wait.Close();
  400. // }
  401. // }
  402. //}
  403. #endregion
  404. #region 绑定数据源
  405. private void btnConfig_Click(object sender, EventArgs e)
  406. {
  407. //if (AppConfig.UserCode.ToLower() != "demo")
  408. //{
  409. // ICSBaseSimpleCode.AppshowMessageBox("您没有权限设置数据源,请联系软件提供商!");
  410. // return;
  411. //}
  412. //FormDataSource fdata = new FormDataSource(AppConfig.GetMenuId(this.Tag.ToString()), btnConfig.Name);
  413. //fdata.ShowDialog();
  414. }
  415. #endregion
  416. #region 分页
  417. private void rptPage_PageIndexChanged(object Sender, EventArgs e)
  418. {
  419. //DataTable data = AppConfig.GetPageData(dataSource, rptPage.PageIndex, rptPage.PageSize).Copy();
  420. ////DataTable data = AppConfig.GetPageDataByDb(tempTableName, "pagerowindex", rptPage.PageSize, rptPage.PageIndex, dataSource.Rows.Count);
  421. //grdDetail.DataSource = data;
  422. }
  423. #endregion
  424. #region 过滤方法
  425. private void FormContainerManager_FormClosing(object sender, FormClosingEventArgs e)
  426. {
  427. //AppConfig.DropTemTable(tempTableName);
  428. }
  429. #endregion
  430. #region 全选
  431. private void btnSelectAll_Click(object sender, EventArgs e)
  432. {
  433. //grvDetail.PostEditor();
  434. //this.Validate();
  435. //for (int i = 0; i < grvDetail.RowCount; i++)
  436. //{
  437. // grvDetail.SetRowCellValue(i, colisSelect, "Y");
  438. //}
  439. }
  440. #endregion
  441. #region 全消
  442. private void btnCancelAll_Click(object sender, EventArgs e)
  443. {
  444. //grvDetail.PostEditor();
  445. //this.Validate();
  446. //for (int i = 0; i < grvDetail.RowCount; i++)
  447. //{
  448. // grvDetail.SetRowCellValue(i, colisSelect, "");
  449. //}
  450. }
  451. #endregion
  452. #region 刷新
  453. private void btnFalsh_Click(object sender, EventArgs e)
  454. {
  455. //FormICSCREW_Load(null, null);
  456. txtUserName.Text = ItemCode;
  457. //txtItemName.Text = ItemName;
  458. txtLotNo.Text = LotNo;
  459. //txtItemINVDESC.Text = INVDESC;
  460. //txtTotalQty.Text = TotalQty.ToString();
  461. //init_();
  462. }
  463. #endregion
  464. //private void ICSItemLot_FormClosing(object sender, FormClosingEventArgs e)
  465. //{
  466. // AppConfig.DropTemTable(tempTableName);
  467. //}
  468. #region 页面加载
  469. private void FormICSCREW_Load(object sender, EventArgs e)
  470. {
  471. //btnFilter_Click(sender, e);
  472. }
  473. #endregion
  474. //private void simpleButton1_Click(object sender, EventArgs e)
  475. //{
  476. // string id = "";
  477. // List<string> editList = new List<string>();
  478. // for (int i = 0; i < grvDetail.RowCount; i++)
  479. // {
  480. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  481. // {
  482. // id = grvDetail.GetRowCellValue(i, colID).ToString();
  483. // editList.Add(id);
  484. // }
  485. // }
  486. // if (editList.Count != 1)
  487. // {
  488. // ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  489. // return;
  490. // }
  491. // try
  492. // {
  493. // FormICSOQCCKGROUP2LISTAdd add = new FormICSOQCCKGROUP2LISTAdd(id);
  494. // add.ShowDialog();
  495. // btnRefresh_Click(null, null);
  496. // }
  497. // catch (Exception ex)
  498. // {
  499. // ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  500. // }
  501. //}
  502. #region 导入模板下载
  503. private void btnImportMould_Click(object sender, EventArgs e)
  504. {
  505. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm();
  506. _wait.Hide();
  507. string anjianExcelFileName = Environment.CommandLine.Substring(1, Environment.CommandLine.LastIndexOf("\\")) + "Output\\";
  508. try
  509. {
  510. _wait.Show();
  511. _wait.Caption = "模板下载中......";
  512. SaveFileDialog dlgSaveFileDialog = new SaveFileDialog(); //弹框提示保存
  513. dlgSaveFileDialog.InitialDirectory = anjianExcelFileName; //默认打开目录
  514. dlgSaveFileDialog.FilterIndex = 1;
  515. dlgSaveFileDialog.RestoreDirectory = true;
  516. dlgSaveFileDialog.FileName = "IQC检验关联导入模板.xlsx"; //默认保存名称
  517. dlgSaveFileDialog.Filter = "Excel文件(*.xlsx)|*.xlsx";
  518. if (dlgSaveFileDialog.ShowDialog() == DialogResult.OK)
  519. {
  520. string fileName = dlgSaveFileDialog.FileName; //获取弹出框选择或填写的文件名称
  521. List<FormReadExcelUIModelColumns> colNameList = new List<FormReadExcelUIModelColumns>();
  522. colNameList.Add(new FormReadExcelUIModelColumns("物料遍码", true));
  523. colNameList.Add(new FormReadExcelUIModelColumns("检验项目组编码", false));
  524. colNameList.Add(new FormReadExcelUIModelColumns("检验项目编码", false));
  525. colNameList.Add(new FormReadExcelUIModelColumns("抽样标准", false));
  526. colNameList.Add(new FormReadExcelUIModelColumns("检验属性", false));
  527. colNameList.Add(new FormReadExcelUIModelColumns("检验标准", false));
  528. colNameList.Add(new FormReadExcelUIModelColumns("最大值", false));
  529. colNameList.Add(new FormReadExcelUIModelColumns("最小值", false));
  530. colNameList.Add(new FormReadExcelUIModelColumns("单位", false));
  531. colNameList.Add(new FormReadExcelUIModelColumns("是否使用", false));
  532. colNameList.Add(new FormReadExcelUIModelColumns("检验方式", false));
  533. colNameList.Add(new FormReadExcelUIModelColumns("工序编码", false));
  534. colNameList.Add(new FormReadExcelUIModelColumns("首检是否必检", false));
  535. FileUtil.exportToExcelFile(fileName, colNameList);
  536. _wait.Close();
  537. ICSBaseSimpleCode.AppshowMessageBox("模板下载成功!");
  538. }
  539. _wait.Close();
  540. }
  541. catch (Exception ex)
  542. {
  543. _wait.Close();
  544. ICSBaseSimpleCode.AppshowMessageBox("模板下载失败:" + ex.Message);
  545. }
  546. }
  547. #endregion
  548. #region 导入
  549. private void btnImportData_Click(object sender, EventArgs e)
  550. {
  551. SimpleButton btntemp = (SimpleButton)sender;
  552. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  553. {
  554. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  555. return;
  556. }
  557. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm();
  558. _wait.Hide();
  559. try
  560. {
  561. FormReadExcel fre = new FormReadExcel();
  562. if (fre.ShowDialog() != DialogResult.OK)
  563. {
  564. return;
  565. }
  566. DataTable dataSource = fre._excelData;
  567. if (dataSource == null)
  568. {
  569. throw new Exception("excel数据取得失败");
  570. }
  571. _wait.Show();
  572. _wait.Caption = "判断模版是否正确......";
  573. #region 判断模版是否正确
  574. List<FormReadExcelUIModelColumns> colNameList = new List<FormReadExcelUIModelColumns>();
  575. colNameList.Add(new FormReadExcelUIModelColumns("物料遍码", true));
  576. colNameList.Add(new FormReadExcelUIModelColumns("检验项目组编码", false));
  577. colNameList.Add(new FormReadExcelUIModelColumns("检验项目编码", false));
  578. colNameList.Add(new FormReadExcelUIModelColumns("抽样标准", false));
  579. colNameList.Add(new FormReadExcelUIModelColumns("检验属性", false));
  580. colNameList.Add(new FormReadExcelUIModelColumns("检验标准", false));
  581. colNameList.Add(new FormReadExcelUIModelColumns("最大值", false));
  582. colNameList.Add(new FormReadExcelUIModelColumns("最小值", false));
  583. colNameList.Add(new FormReadExcelUIModelColumns("单位", false));
  584. colNameList.Add(new FormReadExcelUIModelColumns("是否使用", false));
  585. colNameList.Add(new FormReadExcelUIModelColumns("检验方式", false));
  586. colNameList.Add(new FormReadExcelUIModelColumns("工序编码", false));
  587. colNameList.Add(new FormReadExcelUIModelColumns("首检是否必检", false));
  588. foreach (FormReadExcelUIModelColumns columnsName in colNameList)
  589. {
  590. if (!dataSource.Columns.Contains(columnsName.columnsName))
  591. {
  592. throw new Exception("模版不正确,缺少列" + columnsName.columnsName);
  593. }
  594. }
  595. #endregion
  596. _wait.Caption = "数据整理中......";
  597. List<ICSIPQCKGROUP2LIST> InfoList = new List<ICSIPQCKGROUP2LIST>();
  598. foreach (DataRow dr in dataSource.Rows)
  599. {
  600. ///判断必输项目是否为空
  601. foreach (FormReadExcelUIModelColumns columnsName in colNameList)
  602. {
  603. if (string.IsNullOrWhiteSpace(dr[columnsName.columnsName].ToString()) == true && columnsName.NotNull == true)
  604. {
  605. throw new Exception("列" + columnsName.columnsName + "没有输入值");
  606. }
  607. }
  608. ICSIPQCKGROUP2LIST Info = new ICSIPQCKGROUP2LIST();
  609. Info.CKITEMCODE = dr["物料遍码"].ToString();
  610. Info.CKListCode = dr["检验项目编码"].ToString();
  611. Info.CKGROUP = dr["检验项目组编码"].ToString();
  612. Info.InspectionStandard = dr["检验标准"].ToString();
  613. Info.AQL = dr["抽样标准"].ToString();
  614. Info.CheckoutAttribute = dr["检验属性"].ToString();
  615. Info.UNIT = dr["单位"].ToString();
  616. if (!string.IsNullOrWhiteSpace(dr["最大值"].ToString()))
  617. {
  618. Info.VALUEMAX = Decimal.Parse(dr["最大值"].ToString());
  619. }
  620. if (!string.IsNullOrWhiteSpace(dr["最小值"].ToString()))
  621. {
  622. Info.VALUEMIN = Decimal.Parse(dr["最小值"].ToString());
  623. }
  624. if (!string.IsNullOrWhiteSpace(dr["是否使用"].ToString()))
  625. {
  626. if (dr["是否使用"].ToString().Length > 2)
  627. {
  628. Info.IsUse = 0;
  629. }
  630. else
  631. {
  632. Info.IsUse = 1;
  633. }
  634. }
  635. Info.CKWay = dr["检验方式"].ToString();
  636. Info.OPCode = dr["工序编码"].ToString();
  637. if (!string.IsNullOrWhiteSpace(dr["首检是否必检"].ToString()))
  638. {
  639. if (dr["首检是否必检"].ToString().Length > 2)
  640. {
  641. Info.IsUse = 0;
  642. }
  643. else
  644. {
  645. Info.IsUse = 1;
  646. }
  647. }
  648. Info.MUSER = AppConfig.UserCode;
  649. Info.MUSERName = AppConfig.UserName;
  650. Info.WorkPoint = AppConfig.WorkPointCode;
  651. Info.MTIME = Convert.ToDateTime(AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss").ToString());
  652. InfoList.Add(Info);
  653. }
  654. _wait.Caption = "导入数据......";
  655. ICSIPQCKGROUP2LISTBLL.AddAndEditList(InfoList, AppConfig.AppConnectString);
  656. _wait.Close();
  657. ICSBaseSimpleCode.AppshowMessageBox("导入成功!");
  658. //btnRefresh_Click(null, null);
  659. }
  660. catch (Exception ex)
  661. {
  662. _wait.Close();
  663. ICSBaseSimpleCode.AppshowMessageBox("数据导入失败:" + ex.Message);
  664. }
  665. }
  666. #endregion
  667. /// 0906获取单据号
  668. public static string GetSerialCode(string connectString, string tbName, string colName, string Pre, int numLen)
  669. {
  670. string sql = "EXEC Addins_GetSerialCode '{0}','{1}','{2}','{3}',{4}";
  671. sql = string.Format(sql, new object[] { "", tbName, colName, Pre, numLen });
  672. return DBHelper.ExecuteScalar(connectString, CommandType.Text, sql).ToString();
  673. }
  674. //0906 不合格传入NCR
  675. private void SendNCR(List<string> codeList, string strResult, decimal QTY, string itemcode, string mocode, string OPCODE, string LotNo)
  676. {//
  677. try
  678. {
  679. string codeStr = "";
  680. foreach (string str in codeList)
  681. {
  682. codeStr += str + ",";
  683. }
  684. codeStr = codeStr.TrimEnd(',');
  685. string NewCartonNo = "NCR" + AppConfig.GetSeverDateTime("yyyy-MM-dd").ToString("yyyyMMdd");
  686. NewCartonNo = GetSerialCode(AppConfig.FrameConnectString, "ICSNCRDoc", "SecDocNO", NewCartonNo, 3);
  687. ICSSecDocType secDocType = ICSSecDocTypeBLL.select("QC_Collect", AppConfig.FrameConnectString);
  688. #region 20210816
  689. //获取对应的接收人和抄送人
  690. //ICSSecDocTypeStep docTypeStep = ICSSecDocTypeStepBLL.selectStepBySeq(secDocType.guid, "1", AppConfig.FrameConnectString);
  691. //string ToUserList = "";
  692. //ToUserList = ICSNCRDocBLL.QualityEngineer(CKType, AppConfig.AppConnectString);
  693. #endregion
  694. //string CCUserList = ICSNCRDocBLL.QualityEngineer("经理", AppConfig.AppConnectString);
  695. //string sql = @"SELECT a.ProjectCode FROM ICSMO a WHERE a.MOCODE='{0}'";
  696. //sql = string.Format(sql, mocode);
  697. //DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  698. string ProjectCode = "";
  699. //if (dt != null && dt.Rows.Count > 0)
  700. //{
  701. // ProjectCode = dt.Rows[0]["ProjectCode"].ToString();
  702. //}
  703. ICSNCRDoc SecDoc = new ICSNCRDoc();
  704. SecDoc.SecDocNO = NewCartonNo;
  705. SecDoc.SecDocType = secDocType.guid;
  706. SecDoc.SecDocStatus = "已发送";
  707. SecDoc.SecDocSeq = 1;
  708. SecDoc.SecDocCreateUser = AppConfig.UserCode;
  709. SecDoc.SecDocCreateUserName = AppConfig.UserName;
  710. SecDoc.SecDocCreateTime = AppConfig.GetSeverDateTime("");
  711. //SecDoc.ErrorType = CKType;
  712. SecDoc.ErrorType = "工序检验";//modify on 20201202 NCRtype修改
  713. SecDoc.EQPCode = "";
  714. SecDoc.ItemCode = itemcode;
  715. SecDoc.ProjectCode = ProjectCode;
  716. SecDoc.TimeLimit = "1";
  717. SecDoc.ContentDesc = strResult;
  718. // SecDoc.EATTRIBUTE2 = CKType;
  719. //SecDoc.ToUserList = ToUserList;
  720. //SecDoc.CCUserList = CCUserList;
  721. //SecDoc.ToUserList = ToUserList;
  722. //SecDoc.CCUserList = CCUserList;
  723. //产品跟踪码0910
  724. SecDoc.LOTNO = LotNo;
  725. SecDoc.OPCode = OPCODE;
  726. SecDoc.SecDocOKTime = Convert.ToDateTime("1990-01-01");
  727. SecDoc.Qty = QTY;
  728. SecDoc.SrcDocInfo = LotNo;
  729. ICSNCRDoc NCR = new ICSNCRDoc();
  730. // NCR = ICSNCRDocBLL.selectBySrcDocInfo(codeStr, AppConfig.AppConnectString);
  731. NCR = null;//modify on 20200418
  732. if (NCR == null)
  733. {
  734. ICSNCRDocBLL.CreateNCR(SecDoc, AppConfig.AppConnectString);
  735. }
  736. else
  737. {
  738. MessageBox.Show(codeStr + "已产生NCR单号:" + NCR.SecDocNO + ",不能新增NCR单");
  739. }
  740. }
  741. catch (Exception ex)
  742. {
  743. throw new Exception(ex.Message);
  744. }
  745. }
  746. #region IPQC保存
  747. private void btnTempSave_Click(object sender, EventArgs e)
  748. {
  749. try
  750. {
  751. //0906
  752. List<string> codeList = new List<string>();
  753. string strResult = "";
  754. decimal QTY = 1;//批次数量
  755. #region
  756. if (checkboxGX.Checked == false && checkboxWW.Checked == false)
  757. {
  758. SetMessage("请选择工序检验或者委外检验!!!!", Color.Red);
  759. return;
  760. }
  761. #endregion
  762. //if (gridViewCC == null || gridViewCC.RowCount == 0 || gridView2 == null || gridView2.RowCount == 0)
  763. //{
  764. // SetMessage("当前工序没有检验的基础信息!", Color.Red);
  765. // return;
  766. //}
  767. List<ICSQualityCKDATADetail> InfoList = new List<ICSQualityCKDATADetail>();
  768. for (int k = 0; k < gridViewCC.RowCount; k++)
  769. {
  770. if (gridViewCC.RowCount > 0)
  771. {
  772. if (string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, StandResult).ToString()))
  773. {
  774. SetMessage("存在未填写的标准检测值!请确认!", Color.Red);
  775. return;
  776. }
  777. string ok = gridViewCC.GetRowCellValue(k, CCOK).ToString();
  778. string ng = gridViewCC.GetRowCellValue(k, CCNG).ToString();
  779. if ((string.IsNullOrEmpty(ok) && string.IsNullOrEmpty(ng) || (ok == "False" && ng == "False")))
  780. {
  781. SetMessage("存在检验项目未勾选合格或不合格!请确认!", Color.Red);
  782. return;
  783. }
  784. //update 保存尺寸检验信息 zhuqy 2023-11-16
  785. string CKGROUPCode = gridViewCC.GetRowCellValue(k, colCKGROUPCode).ToString();
  786. string Result = "";
  787. if (!string.IsNullOrEmpty(ok))
  788. {
  789. Result = "OK";
  790. }
  791. else
  792. {
  793. Result = "NG";
  794. }
  795. ICSQualityCKDATADetail CCInfo = new ICSQualityCKDATADetail();
  796. CCInfo.EATTRIBUTE2 = CKGROUPCode;
  797. CCInfo.CKResult = Result;
  798. CCInfo.DECKResult = Result;
  799. InfoList.Add(CCInfo);
  800. }
  801. }
  802. //update 保存外观检验信息 zhuqy 2023-11-16
  803. for (int k = 0; k < gridView2.RowCount; k++)
  804. {
  805. if (gridView2.RowCount > 0)
  806. {
  807. string CKGROUPCode = gridView2.GetRowCellValue(k, colCKGROUPCode1).ToString();
  808. string ok = gridView2.GetRowCellValue(k, colOK).ToString();
  809. string ng = gridView2.GetRowCellValue(k, colNotOK).ToString();
  810. if ((string.IsNullOrEmpty(ok) && string.IsNullOrEmpty(ng) || (ok == "False" && ng == "False")))
  811. {
  812. SetMessage("存在检验项目未勾选合格或不合格!请确认!", Color.Red);
  813. return;
  814. }
  815. string Result = "";
  816. if (!string.IsNullOrEmpty(ok))
  817. {
  818. Result = "OK";
  819. }
  820. else
  821. {
  822. Result = "NG";
  823. }
  824. ICSQualityCKDATADetail WGInfo = new ICSQualityCKDATADetail();
  825. WGInfo.EATTRIBUTE2 = CKGROUPCode;
  826. WGInfo.CKResult = Result;
  827. WGInfo.DECKResult = Result;
  828. InfoList.Add(WGInfo);
  829. }
  830. }
  831. string sql1 = "select * from ICSLOTSIMULATION where lotno='" + txtLotNo.Text.Trim() + "' and LOTSTATUS='暂停'";
  832. DataTable tbale = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql1).Tables[0];
  833. if (tbale.Rows.Count > 0)
  834. {
  835. ICSBaseSimpleCode.AppshowMessageBox("该追踪单号对应工序完工检验信息不合格!无法进行质量检验!");
  836. return;
  837. }
  838. // string sql = @"SELECT DISTINCT a.OPCode,c.CCorWGResult,
  839. // b.RouteCode,f.OPSEQ,d.LOTStatus,
  840. // CASE d.CollectStatus
  841. // WHEN 'COLLECT_BEGIN' THEN 'WG'
  842. // WHEN 'COLLECT_END' THEN 'KG'
  843. // ELSE '' END AS Status
  844. // FROM ICSOP a WITH (nolock)
  845. // LEFT JOIN ICSMO2User b WITH (nolock) ON a.OPCODE = b.OPCODE
  846. // LEFT JOIN ICSLOTSIMULATION d WITH (nolock) ON b.LOTNO = d.LOTNO AND b.OPCODE = d.OPCODE
  847. // LEFT JOIN ICSITEMROUTE2OPLot f ON f.lotno = b.lotno
  848. // AND f.OPCODE = a.OPCODE
  849. // LEFT JOIN ICSOQCCKGROUP2LISTCheckResult c ON c.LotNo=b.LOTNO AND c.OPCode=b.OPCODE
  850. // WHERE b.LOTNO = '" + txtLotNo.Text + "' order by f.OPSEQ ";
  851. // DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  852. // int _OPSEQ = 0;
  853. // if (data.Rows.Count > 0)
  854. // {
  855. // foreach (DataRow dr in data.Rows)
  856. // {
  857. // if (txtOPCode.Text == dr["OPCODE"].ToString())
  858. // {
  859. // string OPSEQ = dr["OPSEQ"].ToString();
  860. // _OPSEQ = Int32.Parse(OPSEQ) - 10;
  861. // }
  862. // }
  863. // }
  864. //查询上一道工序是否检验 20240612
  865. string sql = @"SELECT TOP 1 ROUTECODE, OPCODE, OPSEQ
  866. FROM ICSITEMROUTE2OPLot
  867. WHERE LOTNO = '{0}' AND OPSEQ<(
  868. SELECT OPSEQ FROM ICSITEMROUTE2OPLot
  869. WHERE LOTNO = '{0}' AND OPCode='{1}')
  870. ORDER BY OPSEQ DESC";
  871. sql = string.Format(sql, txtLotNo.Text, txtOPCode.Text);
  872. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  873. int _OPSEQ = 0;
  874. if (data.Rows.Count > 0)
  875. {
  876. _OPSEQ = Int32.Parse(data.Rows[0]["OPSEQ"].ToString());
  877. }
  878. bool isOK = CheckIsOK(_OPSEQ);
  879. if (!isOK)
  880. {
  881. SetMessage("上道工序检验结果不合格,不能开工!", Color.Red);
  882. return;
  883. }
  884. #region
  885. #region 20210707新增当前工序是否已经报工,没有报工不允许检验
  886. string checkSQL = @"SELECT DISTINCT
  887. CASE d.ACTIONRESULT
  888. WHEN 'COLLECT_BEGIN' THEN 'WG'
  889. WHEN 'COLLECT_END' THEN 'KG'
  890. ELSE '' END AS Status
  891. FROM ICSOP a WITH (nolock)
  892. LEFT JOIN ICSMO2User b WITH (nolock) ON a.OPCODE = b.OPCODE
  893. LEFT JOIN ICSLOTONWIP d WITH (nolock) ON b.LOTNO = d.LOTNO AND b.OPCODE = d.OPCODE
  894. LEFT JOIN ICSITEMROUTE2OPLot f ON f.lotno = b.lotno
  895. AND f.OPCODE = a.OPCODE
  896. LEFT JOIN ICSOQCCKGROUP2LISTCheckResult c ON c.LotNo=b.LOTNO AND c.OPCode=b.OPCODE
  897. WHERE b.LOTNO = '" + txtLotNo.Text + "' and a.OPCode='" + txtOPCode.Text + "' ";
  898. DataTable Checkdata = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, checkSQL).Tables[0];
  899. if (Checkdata != null && Checkdata.Rows.Count > 0)
  900. {
  901. string Status = Checkdata.Rows[0]["Status"].ToString();
  902. if (Status != "KG")
  903. {
  904. SetMessage("当前工序还没有完工,不能检验!", Color.Red);
  905. return;
  906. }
  907. }
  908. else
  909. {
  910. SetMessage("当前工序还没有开工,不能检验!", Color.Red);
  911. return;
  912. }
  913. #endregion
  914. ICSQualityCKDATA QualityCKDATA = new ICSQualityCKDATA();
  915. QualityCKDATA.EATTRIBUTE3 = "";//参与人
  916. QualityCKDATA.LOTNO = LotNo;
  917. QualityCKDATA.SEQ = _OPSEQ + 10;
  918. QualityCKDATA.OPCode = this.txtOPCode.Text.Trim();
  919. QualityCKDATA.MOCODE = txtMOCode.Text.Trim();
  920. QualityCKDATA.CKUserCode = txtUserCode.Text.Trim();
  921. ICSLOTONWIPCheck ICSLOTONWIPCheck = new ICSLOTONWIPCheck();
  922. if (checkboxGX.Checked)
  923. {
  924. QualityCKDATA.Type = "GX";
  925. }
  926. if (checkboxWW.Checked)
  927. {
  928. QualityCKDATA.Type = "WW";
  929. }
  930. if ((txtCCResult.Text == "OK" || string.IsNullOrEmpty(txtCCResult.Text)) && (txtWGResult.Text == "OK" || string.IsNullOrEmpty(txtWGResult.Text)))
  931. {
  932. QualityCKDATA.CKResult = "1";
  933. //9月18号添ICSLOTONWIPCheck表格
  934. ICSLOTONWIPCheck.Result = "合格";
  935. }
  936. else
  937. {
  938. QualityCKDATA.CKResult = "0";
  939. //9月18号添ICSLOTONWIPCheck表格
  940. ICSLOTONWIPCheck.Result = "不合格";
  941. //0906判退到NCR
  942. if (!codeList.Contains(LotNo))
  943. {
  944. strResult += "产品追踪单:" + LotNo + " " + CCNCRMes() + " " + WWNCRMes();
  945. codeList.Add(LotNo);
  946. }
  947. string itemcode = txtProductCode.Text;
  948. string OPCODE = txtOPCode.Text;
  949. string MOCODE = txtMOCode.Text;
  950. LotNo = txtLotNo.Text;
  951. // LotNo = "";
  952. QTY = Convert.ToDecimal(txtLotQty.Text);
  953. SendNCR(codeList, strResult, QTY, itemcode, MOCODE, OPCODE, LotNo);
  954. }
  955. List<ICSOQCCKGROUP2LISTCheckResult> entityList = new List<ICSOQCCKGROUP2LISTCheckResult>();
  956. for (int k = 0; k < gridViewCC.RowCount; k++)
  957. {
  958. ICSOQCCKGROUP2LISTCheckResult entity = new ICSOQCCKGROUP2LISTCheckResult();
  959. #region MyRegion
  960. Decimal OKQty = 0; Decimal NGQty = 0;
  961. if (gridViewCC.RowCount > 0)
  962. {
  963. if (string.IsNullOrWhiteSpace(txtCCResult.Text))
  964. {
  965. SetMessage("尺寸还没有检验,请核对!!!!", Color.Red);
  966. return;
  967. }
  968. }
  969. //entity.CKITEMCODE = txtUserName.Text;// gridViewCC.GetRowCellValue(k, colCKITEMCODE).ToString();
  970. entity.CKListCode = gridViewCC.GetRowCellValue(k, colCKGROUPCode).ToString();
  971. entity.RCVCode = RCVCode;
  972. entity.LotNo = LotNo;
  973. entity.CKITEMCODE = ItemCode;
  974. entity.INVDESC = INVDESC;
  975. entity.CheckoutAttribute = "量化";
  976. entity.VALUEMAX = Decimal.Parse(gridViewCC.GetRowCellValue(k, colSetValueMax).ToString());
  977. entity.VALUEMIN = Decimal.Parse(gridViewCC.GetRowCellValue(k, colSetValueMin).ToString());
  978. entity.CheckResultValue = gridViewCC.GetRowCellValue(k, colCheckResult).ToString();
  979. if (txtCCResult.Text == "OK")
  980. {
  981. entity.Qualified = Decimal.Parse(txtLotQty.Text);//合格数
  982. }
  983. else
  984. {
  985. entity.UnQualified = Decimal.Parse(txtLotQty.Text); ;//不合格数
  986. }
  987. if (this.checkboxGX.Checked == true)
  988. {
  989. entity.GXorWWCheck = "GX";
  990. }
  991. else
  992. {
  993. entity.GXorWWCheck = "WW";
  994. }
  995. entity.CCorWGResult = txtCCResult.Text;
  996. entity.LotNo = txtLotNo.Text;
  997. entity.UserCode = this.txtUserCode.Text;
  998. entity.MOCode = this.txtMOCode.Text;
  999. entity.OPCode = this.txtOPCode.Text;
  1000. entityList.Add(entity);
  1001. }
  1002. for (int k = 0; k < gridView2.RowCount; k++)
  1003. {
  1004. ICSOQCCKGROUP2LISTCheckResult entity = new ICSOQCCKGROUP2LISTCheckResult();
  1005. #region MyRegion
  1006. if (gridView2.RowCount > 0)
  1007. {
  1008. if (string.IsNullOrWhiteSpace(txtWGResult.Text))
  1009. {
  1010. SetMessage("外观还没有检验,请核对!!!!", Color.Red);
  1011. return;
  1012. }
  1013. }
  1014. #endregion
  1015. //entity.CKITEMCODE = txtUserName.Text;// gridViewCC.GetRowCellValue(k, colCKITEMCODE).ToString();
  1016. entity.CKListCode = gridView2.GetRowCellValue(k, colCKGROUPCode1).ToString();
  1017. entity.RCVCode = RCVCode;
  1018. entity.LotNo = LotNo;
  1019. entity.CKITEMCODE = ItemCode;
  1020. entity.INVDESC = INVDESC;
  1021. entity.CheckoutAttribute = "外观";
  1022. entity.CCorWGResult = txtWGResult.Text;
  1023. entity.AQL = gridView2.GetRowCellValue(k, colCKGROUPATTR).ToString();
  1024. entity.InspectionStandard = gridView2.GetRowCellValue(k, colCKGROUPMETH).ToString();
  1025. if (this.checkboxGX.Checked == true)
  1026. {
  1027. entity.GXorWWCheck = "GX";
  1028. }
  1029. else
  1030. {
  1031. entity.GXorWWCheck = "WW";
  1032. }
  1033. if (gridView2.GetRowCellValue(k, colOK).ToString() == "True")
  1034. {
  1035. entity.IsOK = 1;
  1036. }
  1037. else
  1038. {
  1039. entity.IsOK = 0;
  1040. }
  1041. if (txtWGResult.Text == "OK")
  1042. {
  1043. entity.Qualified = Decimal.Parse(txtLotQty.Text);//合格数
  1044. }
  1045. else
  1046. {
  1047. entity.UnQualified = Decimal.Parse(txtLotQty.Text); ;//不合格数
  1048. }
  1049. entity.LotNo = txtLotNo.Text;
  1050. entity.UserCode = this.txtUserCode.Text;
  1051. entity.MOCode = this.txtMOCode.Text;
  1052. entity.OPCode = this.txtOPCode.Text;
  1053. entityList.Add(entity);
  1054. #endregion
  1055. }
  1056. #endregion
  1057. try
  1058. {
  1059. //ICSIPQCBLL.AddAndEditList(entityList, AppConfig.AppConnectString);
  1060. //if (entityList != null && entityList.Count > 0)
  1061. //{
  1062. //}
  1063. FramDataContext db = ICSDataCollectionBLL.AddAndEditList(QualityCKDATA, entityList, InfoList, AppConfig.AppConnectString, true);
  1064. //9.18新增
  1065. ICSDataCollectionBLL.save2ICSLOTONWIPCheck(ICSLOTONWIPCheck, QualityCKDATA, AppConfig.AppConnectString, db);
  1066. //this.Close();
  1067. //ICSBaseSimpleCode.AppshowMessageBox("保存成功");
  1068. bool Islastop = ICSAGVBLL.IsLastOP(LotNo, this.txtOPCode.Text.Trim(), AppConfig.AppConnectString, AppConfig.WorkPointCode);
  1069. if (ICSAGVBLL.IsCanToAGV(LotNo, this.txtOPCode.Text.Trim(), "AGV是否开启", AppConfig.AppConnectString, AppConfig.WorkPointCode) && !Islastop && ICSLOTONWIPCheck.Result == "合格")
  1070. {
  1071. try
  1072. {
  1073. ICSAGVTASKLOG Log = new ICSAGVTASKLOG();
  1074. Log.ID = AppConfig.GetGuid();
  1075. Log.Lotno = LotNo;
  1076. Log.Opcode = this.txtOPCode.Text.Trim(); ;
  1077. Log.Itemcode = ItemCode;
  1078. bool NextOpIsWW = ICSAGVBLL.NextOPisWW(LotNo, Log.Opcode, AppConfig.AppConnectString, AppConfig.WorkPointCode);
  1079. bool NextOpIsWG = ICSAGVBLL.NextOPisWG(LotNo, Log.Opcode, AppConfig.AppConnectString, AppConfig.WorkPointCode);
  1080. string Area = "";
  1081. string CArea = "";
  1082. if (!(NextOpIsWW && checkboxWW.Checked && NextOpIsWG))
  1083. {
  1084. if (ICSLOTONWIPCheck.Result == "合格")
  1085. {
  1086. //if (Islastop)
  1087. //{
  1088. // FormICSAGVAreaChoose Choose = new FormICSAGVAreaChoose(true);
  1089. // Choose.ShowDialog();
  1090. // Area = ICSAGVBLL.GetAreaCode("00088", "4", AppConfig.AppConnectString, AppConfig.WorkPointCode);
  1091. // CArea = Choose.AreaCode;
  1092. // Log.TaskType = "成品检合格HH";
  1093. //}
  1094. //需要注意连续委外逻辑,当前工序和下道工序为连续委外,当前工序不触发AGV
  1095. if (NextOpIsWW)
  1096. {
  1097. Area = ICSAGVBLL.GetAreaCode("00088", "6", AppConfig.AppConnectString, AppConfig.WorkPointCode);
  1098. Log.TaskType = "质检合格下工序委外HH";
  1099. }
  1100. else
  1101. {
  1102. Area = ICSAGVBLL.GetAreaCode("00088", "2", AppConfig.AppConnectString, AppConfig.WorkPointCode);
  1103. Log.TaskType = "质检合格HH";
  1104. }
  1105. }
  1106. else
  1107. {
  1108. Area = ICSAGVBLL.GetAreaCode("00088", "3", AppConfig.AppConnectString, AppConfig.WorkPointCode);
  1109. Log.TaskType = "质检不合格HH";
  1110. }
  1111. string BeginArea = Area.Split('@')[0].Split(':')[0];
  1112. string EndArea = Area.Split('@')[1].Split(':')[0];
  1113. AGVCreateTaskModel model = new AGVCreateTaskModel();
  1114. model.area = EndArea.Split(':')[0];
  1115. model.qty = (int)Convert.ToDecimal(txtLotQty.Text);
  1116. //model.station = BeginArea.Split(':')[0];
  1117. model.type = "false";
  1118. model.materialCode = ItemCode;
  1119. model.materialName = txtPriductName.Text;
  1120. model.trackingNumber = Log.Lotno;
  1121. model.orderCode = txtMOCode.Text;
  1122. model.warehouseCode = "KS0001";
  1123. Log.LocationCode = BeginArea;
  1124. Log.EndArea = EndArea;
  1125. Log.Mtime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  1126. Log.MuserName = AppConfig.UserName;
  1127. FormICSAGVContainer container = new FormICSAGVContainer(model, Log);
  1128. container.ShowDialog();
  1129. }
  1130. }
  1131. catch (Exception ex)
  1132. {
  1133. ICSBaseSimpleCode.AppshowMessageBox("AGV任务异常:" + ex.Message);
  1134. }
  1135. }
  1136. SetMessage("保存成功!!!!", Color.Blue);
  1137. Clear(true);
  1138. return;
  1139. }
  1140. catch (Exception ex)
  1141. {
  1142. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  1143. }
  1144. }
  1145. catch (Exception ex)
  1146. {
  1147. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  1148. }
  1149. }
  1150. #endregion
  1151. private bool CheckIsOK(int OPSEQ)
  1152. {
  1153. bool isfalse = false;
  1154. string _OQCSql = @"SELECT DISTINCT ACTION FROM ICSLOTONWIP bb WITH (nolock)
  1155. LEFT JOIN ICSLOTONWIPCHECK CC ON BB.ID=CC.ONWIPID
  1156. INNER JOIN ICSITEMROUTE2OPLot a WITH (nolock) ON bb.lotno=a.lotno and bb.opcode=a.opcode
  1157. WHERE bb.LotNo='" + txtLotNo.Text + "' AND a.OPSEQ='" + OPSEQ + "' AND isnull(CC.RESULT,'')<>'' ";
  1158. DataTable _OQCdt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, _OQCSql).Tables[0];
  1159. if (_OQCdt != null && _OQCdt.Rows.Count > 0)
  1160. {
  1161. isfalse = false;
  1162. }
  1163. else
  1164. {
  1165. isfalse = true;
  1166. }
  1167. return isfalse;
  1168. }
  1169. private bool CheckIsDecmil(string KeyValue)
  1170. {
  1171. try
  1172. {
  1173. Decimal.Parse(KeyValue);
  1174. return true;
  1175. }
  1176. catch (Exception ex)
  1177. {
  1178. return false;
  1179. }
  1180. }
  1181. private void gridViewCC_KeyUp(object sender, KeyEventArgs e)
  1182. {
  1183. }
  1184. private void gridView2_KeyUp(object sender, KeyEventArgs e)
  1185. {
  1186. #region
  1187. try
  1188. {
  1189. if (e.KeyCode == Keys.Enter)
  1190. {
  1191. if (gridView2.FocusedRowHandle < 0)
  1192. {
  1193. return;
  1194. }
  1195. #region colS1
  1196. int SNo = gridView2.FocusedRowHandle;
  1197. int SNoCC = gridView2.RowCount;
  1198. for (int i = SNo; i <= SNo; i++)
  1199. {
  1200. SendKeys.Send("{Down}");
  1201. if (SNo == SNoCC - 1)
  1202. {
  1203. for (int j = 0; j <= SNoCC - 1; j++)
  1204. {
  1205. SendKeys.Send("{Up}");
  1206. }
  1207. SendKeys.Send("{RIGHT}");
  1208. }
  1209. bool istrue = false;
  1210. for (int k = 0; k < gridView2.RowCount; k++)
  1211. {
  1212. #region MyRegion
  1213. bool _S1 = false;
  1214. if (gridView2.GetRowCellValue(k, colOK) != null)
  1215. {
  1216. if (!string.IsNullOrWhiteSpace(gridView2.GetRowCellValue(k, colOK).ToString()))
  1217. {
  1218. if (gridView2.GetRowCellValue(k, colOK).ToString() == "True")
  1219. {
  1220. _S1 = true;
  1221. }
  1222. }
  1223. }
  1224. if (_S1 && gridView2.FocusedColumn.Caption == "合格")
  1225. {
  1226. istrue = true;
  1227. }
  1228. else
  1229. {
  1230. istrue = false;
  1231. break;
  1232. }
  1233. #endregion
  1234. }
  1235. if (istrue)
  1236. {
  1237. this.txtWGResult.Text = "OK";
  1238. this.txtWGResult.BackColor = Color.Blue;
  1239. }
  1240. else
  1241. {
  1242. this.txtWGResult.Text = "NG";
  1243. this.txtWGResult.BackColor = Color.Red;
  1244. }
  1245. }
  1246. #endregion
  1247. }
  1248. }
  1249. catch (Exception ex)
  1250. {
  1251. throw new Exception(ex.ToString());
  1252. }
  1253. #endregion
  1254. }
  1255. private void txtUserCode_KeyPress(object sender, KeyPressEventArgs e)
  1256. {
  1257. if (e.KeyChar == (char)Keys.Enter)
  1258. {
  1259. string UserCode = txtUserCode.Text.Trim();
  1260. string sql = @"select UserName from Sys_User
  1261. where UserCode='{0}'";
  1262. sql = string.Format(sql, UserCode);
  1263. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  1264. if (dt.Rows.Count == 0)
  1265. {
  1266. SetMessage("员工条码不存在,请确认后重新输入!", Color.Red);
  1267. return;
  1268. }
  1269. else
  1270. {
  1271. txtUserName.Text = dt.Rows[0][0].ToString();
  1272. }
  1273. SetMessage("员工条码扫描成功!", Color.Blue);
  1274. return;
  1275. }
  1276. }
  1277. //消息提示
  1278. private void SetMessage(string Msg, Color color)
  1279. {
  1280. txtMessage.Text = Msg;
  1281. txtMessage.ForeColor = color;
  1282. }
  1283. //2.2. 工序条码:扫描完产品跟踪单后才能选择;下拉,只能选择到该产品跟踪单下对应的工序信息;
  1284. //批次条码的对应的关系
  1285. //物料条码
  1286. private void txtLotNo_KeyPress_1(object sender, KeyPressEventArgs e)
  1287. {
  1288. try
  1289. {
  1290. #region`
  1291. if (e.KeyChar == (char)Keys.Enter)
  1292. {
  1293. #region
  1294. string chksql = @"select a.LotNO,a.MCODE ItemCODE,b.INVNAME,a.LOTQTY ,a.TransNO,c.MOPLANQTY from ICSITEMLot a WITH (nolock)
  1295. LEFT JOIN ICSINVENTORY b WITH (nolock) ON a.MCODE = b.INVCODE
  1296. LEFT JOIN ICSMO c WITH (nolock) ON a.TransNO = c.MOCODE AND a.TransLine=c.MOSEQ
  1297. where a.LotNO='{0}' AND a.WorkPoint='{1}'";
  1298. chksql = string.Format(chksql, txtLotNo.Text.Trim(), AppConfig.WorkPointCode);
  1299. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, chksql).Tables[0];
  1300. if (dt.Rows.Count == 0)
  1301. {
  1302. ICSBaseSimpleCode.AppshowMessageBox("产品跟踪码不存在!!");
  1303. return;
  1304. }
  1305. else
  1306. {
  1307. if (dt.Rows[0]["LotNO"].ToString() == "")
  1308. {
  1309. ICSBaseSimpleCode.AppshowMessageBox("产品跟踪单号未绑定零件号,请先绑定再发料!!");
  1310. return;
  1311. }
  1312. txtProductCode.Text = dt.Rows[0]["ItemCODE"].ToString();
  1313. string itemCode = dt.Rows[0]["ItemCODE"].ToString();
  1314. txtPriductName.Text = dt.Rows[0]["INVNAME"].ToString();
  1315. txtLotQty.Text = dt.Rows[0]["LOTQTY"].ToString();
  1316. LotNo = dt.Rows[0]["LotNO"].ToString();
  1317. txtMOCode.Text = dt.Rows[0]["TransNO"].ToString();
  1318. txtMOQty.Text = dt.Rows[0]["MOPLANQTY"].ToString();
  1319. #region 工序
  1320. string __sql = @"SELECT b.OPCODE 工序编码,c.OPDESC 工序名称 FROM ICSITEM2ROUTE a
  1321. INNER JOIN ICSROUTE2OP b ON b.ROUTECODE=a.ROUTECODE
  1322. INNER JOIN ICSOP c ON b.OPCODE=c.OPCODE
  1323. WHERE a.ITEMCODE='" + itemCode + "' AND a.WorkPoint='{0}' ORDER BY b.OPSEQ";
  1324. __sql = string.Format(__sql, AppConfig.WorkPointCode);
  1325. DataTable __dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, __sql).Tables[0];
  1326. txtOPCode_.Properties.ValueMember = "工序编码";
  1327. txtOPCode_.Properties.DisplayMember = "工序编码";
  1328. txtOPCode_.Properties.DataSource = __dt;
  1329. txtOPCode_.Properties.NullText = "";//空时的值
  1330. txtOPCode_.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
  1331. txtOPCode_.Properties.ValidateOnEnterKey = true;//回车确认
  1332. txtOPCode_.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
  1333. txtOPCode_.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
  1334. txtOPCode_.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
  1335. #endregion
  1336. //if (__dt != null && __dt.Rows.Count > 0)
  1337. //{
  1338. // foreach (DataRow item in __dt.Rows)
  1339. // {
  1340. //this.txtOPCode_.Items.Add(item["OPCODE"].ToString());
  1341. // }
  1342. //}
  1343. }
  1344. #endregion
  1345. }
  1346. #endregion
  1347. }
  1348. catch (Exception ex)
  1349. {
  1350. SetMessage(ex.Message, Color.Red);
  1351. }
  1352. }
  1353. private void txtOPCode_TextChanged(object sender, EventArgs e)
  1354. {
  1355. try
  1356. {
  1357. string itemCode = this.txtProductCode.Text;
  1358. string OpCode = this.txtOPCode_.Text;
  1359. string sql = @"SELECT EnumName FROM Sys_EnumKey WHERE EnumKey='00006'";
  1360. string connectionString = AppConfig.FrameConnectString; // AppConfig.GetDataBaseConnectStringByKey("[DB.PLM]");
  1361. if (string.IsNullOrWhiteSpace(connectionString))
  1362. return;
  1363. object name = DBHelper.ExecuteScalar(connectionString, CommandType.Text, sql);
  1364. if (name == null || string.IsNullOrWhiteSpace(name.ToString()))
  1365. return;
  1366. string fileName = name.ToString() + "\\" + itemCode + LotNo + this.txtOPCode_.Text + ".pdf";
  1367. //string sql = @"SELECT SOPDrawing from ICSITEMROUTE2OP WHERE ITEMCODE='" + itemCode + "' AND ROUTECODE='" + RouteCode + "' AND OPCODE='" + OpCode + "' ";
  1368. //string connectionString = AppConfig.FrameConnectString; // AppConfig.GetDataBaseConnectStringByKey("[DB.PLM]");
  1369. //string connectionString = AppConfig.GetDataBaseConnectStringByKey("[DB.FTP2]");
  1370. if (string.IsNullOrWhiteSpace(connectionString))
  1371. return;
  1372. name = "123";
  1373. if (name == null || string.IsNullOrWhiteSpace(name.ToString()))
  1374. return;
  1375. //fileName = "E:\\PDF\\20201015.pdf";
  1376. //string fileName = name.ToString() + itemCode + "\\" + RouteCode + "\\" + OpCode + ".pdf";
  1377. //string fileName = name.ToString() + ".pdf";
  1378. if (!string.IsNullOrEmpty(fileName))
  1379. {
  1380. axAcroPDFTZ.LoadFile(fileName);
  1381. axAcroPDFTZ.setShowToolbar(false);
  1382. axAcroPDFTZ.setShowScrollbars(false);
  1383. axAcroPDFTZ.setPageMode("thumbs");
  1384. axAcroPDFTZ.setLayoutMode("SinglePage");
  1385. axAcroPDFTZ.setView("Fit");
  1386. axAcroPDFTZ.Show();
  1387. }
  1388. }
  1389. catch (Exception ex)
  1390. {
  1391. MessageBox.Show(ex.Message);
  1392. }
  1393. }
  1394. #region 选中工序委外
  1395. private void checkboxGX_CheckedChanged(object sender, EventArgs e)
  1396. {
  1397. if (this.checkboxGX.Checked == true)
  1398. {
  1399. this.checkboxWW.Checked = false;
  1400. }
  1401. }
  1402. #endregion
  1403. #region 委外检验
  1404. private void checkboxWW_CheckedChanged(object sender, EventArgs e)
  1405. {
  1406. if (this.checkboxWW.Checked == true)
  1407. {
  1408. this.checkboxGX.Checked = false;
  1409. }
  1410. }
  1411. #endregion
  1412. private void txtOPCode_SelectedIndexChanged(object sender, EventArgs e)
  1413. {
  1414. initCheck();
  1415. }
  1416. private void initCheck()
  1417. {
  1418. string _OQCSql = @"SELECT a.SetValueMax,a.SetValueMin,a.CKGROUPCode,b.CKGROUPDESC,b.CKGROUPDNAME,'' Remark,'' CheckResult,a.standvalue as standresult,CAST (ISNULL(0, 0) AS BIT) AS OK,CAST (ISNULL(0, 0) AS BIT) AS NG,ptype, a.id,'' as bgcheckcc,'' as bgcheckresultcc FROM ICSOQCCKLIST a
  1419. LEFT JOIN ICSOQCCKGROUP b ON a.CKGROUPCode=b.CKGROUP
  1420. WHERE INVCode='" + txtProductCode.Text + "' AND a.CKGROUPATTR='' and a.ISREF='是' AND a.OPCode='" + txtOPCode.Text + @"' and a.CKGROUPMETH=''
  1421. select cklistcode,checkresultvalue ,ccorwgresult,CheckoutAttribute from ICSOQCCKGROUP2LISTCheckResult where GXorWWCheck='GX' AND LOTNO='" + txtLotNo.Text + @"' AND OPCODE='" + txtOPCode.Text + @"'
  1422. ";//0906
  1423. DataSet set = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, _OQCSql);
  1424. DataTable _OQCdt = set.Tables[0];
  1425. DataTable ZZLOG = set.Tables[1];
  1426. _OQCdt.PrimaryKey = new DataColumn[] { _OQCdt.Columns["id"] };
  1427. List<DataRow> list = _OQCdt.AsEnumerable().Where(a => Convert.ToDecimal(a["ptype"]) > 1).ToList();
  1428. if (list.Count > 0)
  1429. {
  1430. foreach (DataRow row in list)
  1431. {
  1432. int num = Convert.ToInt32(row["ptype"]);
  1433. List<DataRow> rowlist = ZZLOG.AsEnumerable().Where(a => a["cklistcode"].ToString() == row["CKGROUPCode"].ToString() && a["CheckoutAttribute"].ToString() == "量化").ToList();
  1434. for (int i = 0; i < num; i++)
  1435. {
  1436. DataRow newrow = _OQCdt.NewRow();
  1437. newrow["SetValueMax"] = row["SetValueMax"];
  1438. newrow["SetValueMin"] = row["SetValueMin"];
  1439. newrow["CKGROUPCode"] = row["CKGROUPCode"];
  1440. newrow["CKGROUPDESC"] = row["CKGROUPDESC"];
  1441. newrow["CKGROUPDNAME"] = row["CKGROUPDNAME"];
  1442. newrow["Remark"] = row["Remark"];
  1443. newrow["CheckResult"] = row["CheckResult"];
  1444. newrow["standresult"] = row["standresult"];
  1445. newrow["OK"] = row["OK"];
  1446. newrow["NG"] = row["NG"];
  1447. newrow["ptype"] = "1";
  1448. if (rowlist.Count >= i + 1)
  1449. {
  1450. newrow["bgcheckcc"] = rowlist[i]["checkresultvalue"].ToString();
  1451. newrow["bgcheckresultcc"] = rowlist[i]["ccorwgresult"].ToString();
  1452. }
  1453. newrow["id"] = AppConfig.GetGuid();
  1454. _OQCdt.Rows.Add(newrow);
  1455. }
  1456. _OQCdt.Rows.Remove(row);
  1457. }
  1458. }
  1459. //else
  1460. //{
  1461. // DataRow newrow = _OQCdt.NewRow();
  1462. // newrow["id"] = AppConfig.GetGuid();
  1463. // _OQCdt.Rows.Add(newrow);
  1464. //}
  1465. foreach (DataRow rowcc in _OQCdt.Rows)
  1466. {
  1467. if (!string.IsNullOrEmpty(rowcc["bgcheckcc"].ToString()))
  1468. continue;
  1469. DataRow row = ZZLOG.AsEnumerable().Where(a => a["cklistcode"].ToString() == rowcc["CKGROUPCode"].ToString() && a["CheckoutAttribute"].ToString() == "量化").FirstOrDefault();
  1470. if (row != null)
  1471. {
  1472. rowcc["bgcheckcc"] = row["checkresultvalue"].ToString();
  1473. rowcc["bgcheckresultcc"] = row["ccorwgresult"].ToString();
  1474. }
  1475. }
  1476. gridControlcc.DataSource = _OQCdt;
  1477. string _OQCWGSql = @"SELECT a.CKGROUPATTR,a.CKGROUPMETH,a.CKGROUPCode CKGROUPCode1,b.CKGROUPDESC CKGROUPDESC1,b.CKGROUPDNAME,'' Remark1,CAST (ISNULL(0, 0) AS BIT) AS OK,CAST (ISNULL(0, 0) AS BIT) AS NG,ptype,a.id,'' as bgcheckwg,'' as bgcheckresultwg FROM ICSOQCCKLIST a
  1478. LEFT JOIN ICSOQCCKGROUP b ON a.CKGROUPCode=b.CKGROUP
  1479. WHERE INVCode='" + txtProductCode.Text + "' AND a.CKGROUPATTR='' and a.ISREF='是' AND a.OPCode='" + txtOPCode.Text + "' and a.CKGROUPMETH=''";//0906
  1480. DataSet set2 = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, _OQCWGSql);
  1481. DataTable _OQCWGdt = set2.Tables[0];
  1482. _OQCWGdt.PrimaryKey = new DataColumn[] { _OQCWGdt.Columns["id"] };
  1483. list = _OQCWGdt.AsEnumerable().Where(a => Convert.ToDecimal(a["ptype"]) > 1).ToList();
  1484. if (list.Count > 0)
  1485. {
  1486. foreach (DataRow row in list)
  1487. {
  1488. int num = Convert.ToInt32(row["ptype"]);
  1489. List<DataRow> rowlist = ZZLOG.AsEnumerable().Where(a => a["cklistcode"].ToString() == row["CKGROUPCode1"].ToString() && a["CheckoutAttribute"].ToString() == "外观").ToList();
  1490. for (int i = 0; i < num; i++)
  1491. {
  1492. DataRow newrow = _OQCWGdt.NewRow();
  1493. newrow["CKGROUPATTR"] = row["CKGROUPATTR"];
  1494. newrow["CKGROUPMETH"] = row["CKGROUPMETH"];
  1495. newrow["CKGROUPCode1"] = row["CKGROUPCode1"];
  1496. newrow["CKGROUPDESC1"] = row["CKGROUPDESC1"];
  1497. newrow["CKGROUPDNAME"] = row["CKGROUPDNAME"];
  1498. newrow["Remark1"] = row["Remark1"];
  1499. newrow["OK"] = row["OK"];
  1500. newrow["NG"] = row["NG"];
  1501. newrow["ptype"] = "1";
  1502. newrow["id"] = AppConfig.GetGuid();
  1503. if (rowlist.Count >= i + 1)
  1504. {
  1505. newrow["bgcheckwg"] = rowlist[i]["checkresultvalue"].ToString();
  1506. newrow["bgcheckresultwg"] = rowlist[i]["ccorwgresult"].ToString();
  1507. }
  1508. _OQCWGdt.Rows.Add(newrow);
  1509. }
  1510. _OQCWGdt.Rows.Remove(row);
  1511. }
  1512. }
  1513. //else
  1514. //{
  1515. // DataRow newWGrow = _OQCWGdt.NewRow();
  1516. // newWGrow["id"] = AppConfig.GetGuid();
  1517. // _OQCWGdt.Rows.Add(newWGrow);
  1518. //}
  1519. foreach (DataRow rowcc in _OQCWGdt.Rows)
  1520. {
  1521. if (!string.IsNullOrEmpty(rowcc["bgcheckwg"].ToString()))
  1522. continue;
  1523. DataRow row = ZZLOG.AsEnumerable().Where(a => a["cklistcode"].ToString() == rowcc["CKGROUPCode1"].ToString() && a["CheckoutAttribute"].ToString() == "外观").FirstOrDefault();
  1524. if (row != null)
  1525. {
  1526. rowcc["bgcheckwg"] = row["checkresultvalue"].ToString();
  1527. rowcc["bgcheckresultwg"] = row["ccorwgresult"].ToString();
  1528. }
  1529. }
  1530. gridControl2.DataSource = _OQCWGdt;
  1531. LoadGroup();
  1532. }
  1533. private void txtOPCode_EditValueChanged(object sender, EventArgs e)
  1534. {
  1535. }
  1536. private string CCNCRMes()
  1537. {
  1538. string result = "";
  1539. for (int k = 0; k < gridViewCC.RowCount; k++)
  1540. {
  1541. //Decimal _VALUEMAX = 0; Decimal _VALUEMIN = 0; Decimal _S1 = 0;
  1542. //if (gridViewCC.GetRowCellValue(k, colSetValueMax) != null)
  1543. //{
  1544. // if (!string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, colSetValueMax).ToString()))
  1545. // {
  1546. // _VALUEMAX = Decimal.Parse(gridViewCC.GetRowCellValue(k, colSetValueMax).ToString());
  1547. // }
  1548. //}
  1549. //if (gridViewCC.GetRowCellValue(k, colSetValueMin) != null)
  1550. //{
  1551. // if (!string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, colSetValueMin).ToString()))
  1552. // {
  1553. // _VALUEMIN = Decimal.Parse(gridViewCC.GetRowCellValue(k, colSetValueMin).ToString());
  1554. // }
  1555. //}
  1556. //if (gridViewCC.GetRowCellValue(k, colCheckResult) != null)
  1557. //{
  1558. // if (!string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, colCheckResult).ToString()))
  1559. // {
  1560. // _S1 = Decimal.Parse(gridViewCC.GetRowCellValue(k, colCheckResult).ToString());
  1561. // }
  1562. //}
  1563. if (gridViewCC.GetRowCellValue(k, CCNG).ToString() == "True")
  1564. {
  1565. result += "在尺寸检验,检验项目:" + gridViewCC.GetRowCellValue(k, colCKGROUPDESC) + " 发生不良:实测值:" + gridViewCC.GetRowCellValue(k, colCheckResult).ToString() + ",不良原因:" + gridViewCC.GetRowCellValue(k, colRemark).ToString() + "";
  1566. }
  1567. }
  1568. return result;
  1569. }
  1570. private void gridView2_KeyUp_1(object sender, KeyEventArgs e)
  1571. {
  1572. #region
  1573. try
  1574. {
  1575. if (e.KeyCode == Keys.Enter)
  1576. {
  1577. if (gridView2.FocusedRowHandle < 0)
  1578. {
  1579. return;
  1580. }
  1581. #region colS1
  1582. int SNo = gridView2.FocusedRowHandle;
  1583. int SNoCC = gridView2.RowCount;
  1584. for (int i = SNo; i <= SNo; i++)
  1585. {
  1586. SendKeys.Send("{Down}");
  1587. if (SNo == SNoCC - 1)
  1588. {
  1589. for (int j = 0; j <= SNoCC - 1; j++)
  1590. {
  1591. SendKeys.Send("{Up}");
  1592. }
  1593. SendKeys.Send("{RIGHT}");
  1594. }
  1595. bool istrue = false;
  1596. for (int k = 0; k < gridView2.RowCount; k++)
  1597. {
  1598. if (gridView2.GetRowCellValue(k, colCKGROUPCode1) == null)
  1599. {
  1600. gridView2.SetRowCellValue(gridView2.FocusedRowHandle, colOK, false);
  1601. gridView2.SetRowCellValue(gridView2.FocusedRowHandle, colOK, false);
  1602. }
  1603. #region MyRegion
  1604. bool _S1 = false;
  1605. if (gridView2.GetRowCellValue(k, colOK) != null)
  1606. {
  1607. if (!string.IsNullOrWhiteSpace(gridView2.GetRowCellValue(k, colOK).ToString()))
  1608. {
  1609. if (gridView2.GetRowCellValue(k, colOK).ToString() == "True")
  1610. {
  1611. _S1 = true;
  1612. }
  1613. }
  1614. }
  1615. if (_S1 && gridView2.FocusedColumn.Caption == "合格")
  1616. {
  1617. istrue = true;
  1618. }
  1619. else
  1620. {
  1621. istrue = false;
  1622. break;
  1623. }
  1624. #endregion
  1625. }
  1626. if (istrue)
  1627. {
  1628. this.txtWGResult.Text = "OK";
  1629. this.txtWGResult.BackColor = Color.Blue;
  1630. }
  1631. else
  1632. {
  1633. this.txtWGResult.Text = "NG";
  1634. this.txtWGResult.BackColor = Color.Red; WGNCRresult += "";
  1635. }
  1636. }
  1637. #endregion
  1638. }
  1639. }
  1640. catch (Exception ex)
  1641. {
  1642. throw new Exception(ex.ToString());
  1643. }
  1644. #endregion
  1645. }
  1646. private string WWNCRMes()
  1647. {
  1648. string result = "";
  1649. for (int k = 0; k < gridView2.RowCount; k++)
  1650. {
  1651. bool _S1 = false;
  1652. if (gridView2.GetRowCellValue(k, colOK) != null)
  1653. {
  1654. if (!string.IsNullOrWhiteSpace(gridView2.GetRowCellValue(k, colOK).ToString()))
  1655. {
  1656. if (gridView2.GetRowCellValue(k, colOK).ToString() == "True")
  1657. {
  1658. _S1 = true;
  1659. }
  1660. }
  1661. }
  1662. if (!_S1)
  1663. {
  1664. result += "在外观检验,检验项目:" + gridView2.GetRowCellValue(k, colCKGROUPDESC1) + "发生不良";
  1665. }
  1666. }
  1667. return result;
  1668. }
  1669. private void txtLotNo_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  1670. {
  1671. try
  1672. {
  1673. if (checkboxGX.Checked == false && checkboxWW.Checked == false)
  1674. {
  1675. ICSBaseSimpleCode.AppshowMessageBox("请选择工序检验还是委外检验!!");
  1676. return;
  1677. }
  1678. int Type = 0;
  1679. if (checkboxGX.Checked)
  1680. {
  1681. Type = 0;
  1682. }
  1683. if (checkboxWW.Checked)
  1684. {
  1685. Type = 1;
  1686. }
  1687. FormICSLLAGVHH form = new FormICSLLAGVHH(Type);
  1688. form.ShowDialog();
  1689. txtLotNo.Text = form.LotNo_;
  1690. KeyPressEventArgs eves = new KeyPressEventArgs((Char)Keys.Enter);
  1691. if (!string.IsNullOrEmpty(form.LotNo_))
  1692. txtLotNo_KeyPress(null, eves);
  1693. KeyEventArgs eve = new KeyEventArgs(Keys.Enter);
  1694. txtProductCode.Text = form.ItemCode_;
  1695. txtOPCode.Text = form.OPCode_;
  1696. if (!string.IsNullOrEmpty(form.OPCode_))
  1697. txtOPCode_KeyDown(null, eve);
  1698. this.txtMOCode.Text = form.MOCode_;
  1699. this.txtMOQty.Text = form.MOPLANQTY_;
  1700. txtPriductName.Text = form.INVDESC_;
  1701. txtLotQty.Text = form.LOTQTY_;
  1702. //LotNoChanged();
  1703. }
  1704. catch (Exception ex)
  1705. {
  1706. MessageBox.Show(ex.Message);
  1707. }
  1708. }
  1709. private void LotNoChanged()
  1710. {
  1711. try
  1712. {
  1713. #region
  1714. string chksql = @"select a.LotNO,a.MCODE ItemCODE,b.INVNAME,a.LOTQTY ,a.TransNO,c.MOPLANQTY from ICSITEMLot a WITH (nolock)
  1715. LEFT JOIN ICSINVENTORY b WITH (nolock) ON a.MCODE = b.INVCODE
  1716. LEFT JOIN ICSMO c WITH (nolock) ON a.TransNO = c.MOCODE AND a.TransLine=c.MOSEQ
  1717. where a.LotNO='{0}' AND a.WorkPoint='{1}'";
  1718. chksql = string.Format(chksql, txtLotNo.Text.Trim(), AppConfig.WorkPointCode);
  1719. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, chksql).Tables[0];
  1720. if (dt.Rows.Count == 0)
  1721. {
  1722. ICSBaseSimpleCode.AppshowMessageBox("产品跟踪码不存在!!");
  1723. return;
  1724. }
  1725. else
  1726. {
  1727. if (dt.Rows[0]["LotNO"].ToString() == "")
  1728. {
  1729. ICSBaseSimpleCode.AppshowMessageBox("产品跟踪单号未绑定零件号,请先绑定再发料!!");
  1730. return;
  1731. }
  1732. txtProductCode.Text = dt.Rows[0]["ItemCODE"].ToString();
  1733. string itemCode = dt.Rows[0]["ItemCODE"].ToString();
  1734. txtPriductName.Text = dt.Rows[0]["INVNAME"].ToString();
  1735. txtLotQty.Text = dt.Rows[0]["LOTQTY"].ToString();
  1736. LotNo = dt.Rows[0]["LotNO"].ToString();
  1737. txtMOCode.Text = dt.Rows[0]["TransNO"].ToString();
  1738. txtMOQty.Text = dt.Rows[0]["MOPLANQTY"].ToString();
  1739. #region 工序
  1740. string __sql = @"SELECT b.OPCODE 工序编码,c.OPDESC 工序名称 FROM ICSITEM2ROUTE a
  1741. INNER JOIN ICSROUTE2OP b ON b.ROUTECODE=a.ROUTECODE
  1742. INNER JOIN ICSOP c ON b.OPCODE=c.OPCODE
  1743. WHERE a.ITEMCODE='" + itemCode + "' AND a.WorkPoint='{0}' ORDER BY b.OPSEQ";
  1744. __sql = string.Format(__sql, AppConfig.WorkPointCode);
  1745. DataTable __dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, __sql).Tables[0];
  1746. txtOPCode_.Properties.ValueMember = "工序编码";
  1747. txtOPCode_.Properties.DisplayMember = "工序编码";
  1748. txtOPCode_.Properties.DataSource = __dt;
  1749. txtOPCode_.Properties.NullText = "";//空时的值
  1750. txtOPCode_.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
  1751. txtOPCode_.Properties.ValidateOnEnterKey = true;//回车确认
  1752. txtOPCode_.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
  1753. txtOPCode_.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
  1754. txtOPCode_.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
  1755. #endregion
  1756. }
  1757. #endregion
  1758. }
  1759. catch (Exception ex)
  1760. {
  1761. SetMessage(ex.Message, Color.Red);
  1762. }
  1763. }
  1764. private void txtLotNo_KeyPress(object sender, KeyPressEventArgs e)
  1765. {
  1766. try
  1767. {
  1768. #region`
  1769. if (e.KeyChar == (char)Keys.Enter)
  1770. {
  1771. if (checkboxGX.Checked == false && checkboxWW.Checked == false)
  1772. {
  1773. ICSBaseSimpleCode.AppshowMessageBox("请选择工序检验还是委外检验!!");
  1774. return;
  1775. }
  1776. #region
  1777. string chksql = @"select a.LotNO,a.MCODE ItemCODE,b.INVNAME,a.LOTQTY ,a.TransNO,c.MOPLANQTY,ROUTECODE,c.ORDERNO from ICSITEMLot a WITH (nolock)
  1778. LEFT JOIN ICSINVENTORY b WITH (nolock) ON a.MCODE = b.INVCODE
  1779. LEFT JOIN ICSMO c WITH (nolock) ON a.TransNO = c.MOCODE AND a.TransLine=c.MOSEQ
  1780. LEFT JOIN (SELECT LOTNO,ROUTECODE FROM ICSMO2USER GROUP BY LOTNO,ROUTECODE) D ON D.LOTNO=A.LOTNO
  1781. where a.LotNO='{0}' AND a.WorkPoint='{1}'";
  1782. chksql = string.Format(chksql, txtLotNo.Text.Trim(), AppConfig.WorkPointCode);
  1783. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, chksql).Tables[0];
  1784. if (dt.Rows.Count == 0)
  1785. {
  1786. ICSBaseSimpleCode.AppshowMessageBox("产品跟踪码不存在!!");
  1787. return;
  1788. }
  1789. else
  1790. {
  1791. if (dt.Rows[0]["LotNO"].ToString() == "")
  1792. {
  1793. ICSBaseSimpleCode.AppshowMessageBox("产品跟踪单号未绑定零件号,请先绑定再发料!!");
  1794. return;
  1795. }
  1796. Clear(false);
  1797. txtProductCode.Text = dt.Rows[0]["ItemCODE"].ToString();
  1798. ItemCode = dt.Rows[0]["ItemCODE"].ToString();
  1799. txtPriductName.Text = dt.Rows[0]["INVNAME"].ToString();
  1800. txtLotQty.Text = dt.Rows[0]["LOTQTY"].ToString();
  1801. RouteCode = dt.Rows[0]["ROUTECODE"].ToString();
  1802. LotNo = dt.Rows[0]["LotNO"].ToString();
  1803. txtMOCode.Text = dt.Rows[0]["TransNO"].ToString();
  1804. txtMOQty.Text = dt.Rows[0]["MOPLANQTY"].ToString();
  1805. txtOrderNo.Text= dt.Rows[0]["ORDERNO"].ToString();
  1806. #region 工序
  1807. //string __sql = @"SELECT b.OPCODE 工序编码,c.OPDESC 工序名称 FROM ICSITEM2ROUTE a
  1808. // INNER JOIN ICSROUTE2OP b ON b.ROUTECODE=a.ROUTECODE
  1809. // INNER JOIN ICSOP c ON b.OPCODE=c.OPCODE
  1810. // WHERE a.ITEMCODE='" + itemCode + "' AND a.WorkPoint='{0}' ORDER BY b.OPSEQ";
  1811. string __sql = @"SELECT a.OPCODE 工序编码,c.OPDESC 工序名称 FROM ICSITEMROUTE2OPLot a
  1812. INNER JOIN ICSOP c ON c.OPCODE=a.OPCODE
  1813. WHERE a.lotno='" + LotNo + "' AND a.WorkPoint='{0}' ORDER BY a.OPSEQ";
  1814. __sql = string.Format(__sql, AppConfig.WorkPointCode);
  1815. DataTable __dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, __sql).Tables[0];
  1816. txtOPCode_.Properties.ValueMember = "工序编码";
  1817. txtOPCode_.Properties.DisplayMember = "工序编码";
  1818. txtOPCode_.Properties.DataSource = __dt;
  1819. txtOPCode_.Properties.NullText = "";//空时的值
  1820. txtOPCode_.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
  1821. txtOPCode_.Properties.ValidateOnEnterKey = true;//回车确认
  1822. txtOPCode_.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
  1823. txtOPCode_.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
  1824. txtOPCode_.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
  1825. #endregion
  1826. //if (__dt != null && __dt.Rows.Count > 0)
  1827. //{
  1828. // foreach (DataRow item in __dt.Rows)
  1829. // {
  1830. //this.txtOPCode_.Items.Add(item["OPCODE"].ToString());
  1831. // }
  1832. //}
  1833. txtOPCode.SelectAll();
  1834. txtOPCode.Focus();
  1835. }
  1836. #endregion
  1837. }
  1838. #endregion
  1839. }
  1840. catch (Exception ex)
  1841. {
  1842. SetMessage(ex.Message, Color.Red);
  1843. }
  1844. }
  1845. private void txtOPCode_TextChanged_1(object sender, EventArgs e)
  1846. {
  1847. }
  1848. private void txtLotNo_EditValueChanged(object sender, EventArgs e)
  1849. {
  1850. }
  1851. private void txtMessage_MouseMove(object sender, MouseEventArgs e)
  1852. {
  1853. }
  1854. private void BtnDesignMap_MouseMove_1(object sender, MouseEventArgs e)
  1855. {
  1856. BtnDesignMap.BackColor = System.Drawing.Color.DeepSkyBlue;
  1857. }
  1858. private void BtnDesignMap_MouseLeave_1(object sender, EventArgs e)
  1859. {
  1860. BtnDesignMap.BackColor = System.Drawing.Color.FromArgb(207, 221, 255);
  1861. }
  1862. private void BrnOPMap_MouseMove_1(object sender, MouseEventArgs e)
  1863. {
  1864. BrnOPMap.BackColor = System.Drawing.Color.DeepSkyBlue;
  1865. }
  1866. private void BrnOPMap_MouseLeave_1(object sender, EventArgs e)
  1867. {
  1868. BrnOPMap.BackColor = System.Drawing.Color.FromArgb(207, 221, 255);
  1869. }
  1870. private void BtnCheckBookMap_MouseMove_1(object sender, MouseEventArgs e)
  1871. {
  1872. BtnCheckBookMap.BackColor = System.Drawing.Color.DeepSkyBlue;
  1873. }
  1874. private void BtnCheckBookMap_MouseLeave_1(object sender, EventArgs e)
  1875. {
  1876. BtnCheckBookMap.BackColor = System.Drawing.Color.FromArgb(207, 221, 255);
  1877. }
  1878. private void btnTempSave_MouseMove(object sender, MouseEventArgs e)
  1879. {
  1880. }
  1881. private void btnTempSave_MouseLeave(object sender, EventArgs e)
  1882. {
  1883. }
  1884. private void gridViewCC_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
  1885. {
  1886. #region
  1887. //try
  1888. //{
  1889. // if (gridViewCC.FocusedRowHandle < 0)
  1890. // {
  1891. // return;
  1892. // }
  1893. // #region colS1
  1894. // int SNo = gridViewCC.FocusedRowHandle;
  1895. // int SNoCC = gridViewCC.RowCount;
  1896. // for (int i = SNo; i <= SNo; i++)
  1897. // {
  1898. // SendKeys.Send("{Down}");
  1899. // if (SNo == SNoCC - 1)
  1900. // {
  1901. // for (int j = 0; j <= SNoCC - 1; j++)
  1902. // {
  1903. // SendKeys.Send("{Up}");
  1904. // }
  1905. // SendKeys.Send("{RIGHT}");
  1906. // }
  1907. // bool istrue = false;
  1908. // for (int k = 0; k < gridViewCC.RowCount; k++)
  1909. // {
  1910. // #region MyRegion
  1911. // Decimal _VALUEMAX = 0; Decimal _VALUEMIN = 0; Decimal _S1 = 0;
  1912. // if (gridViewCC.GetRowCellValue(k, colSetValueMax) != null)
  1913. // {
  1914. // if (!string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, colSetValueMax).ToString()))
  1915. // {
  1916. // _VALUEMAX = Decimal.Parse(gridViewCC.GetRowCellValue(k, colSetValueMax).ToString());
  1917. // }
  1918. // }
  1919. // if (gridViewCC.GetRowCellValue(k, colSetValueMin) != null)
  1920. // {
  1921. // if (!string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, colSetValueMin).ToString()))
  1922. // {
  1923. // _VALUEMIN = Decimal.Parse(gridViewCC.GetRowCellValue(k, colSetValueMin).ToString());
  1924. // }
  1925. // }
  1926. // if (gridViewCC.GetRowCellValue(k, colCheckResult) != null)
  1927. // {
  1928. // if (!string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, colCheckResult).ToString()))
  1929. // {
  1930. // _S1 = Decimal.Parse(gridViewCC.GetRowCellValue(k, colCheckResult).ToString());
  1931. // }
  1932. // }
  1933. // if ((_S1 < _VALUEMIN || _S1 > _VALUEMAX) && gridViewCC.FocusedColumn.Caption == "检验值" && !string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, colCheckResult).ToString()))
  1934. // {
  1935. // istrue = false;
  1936. // break;
  1937. // }
  1938. // else
  1939. // {
  1940. // istrue = true;
  1941. // }
  1942. // #endregion
  1943. // }
  1944. // if (istrue)
  1945. // {
  1946. // this.txtCCResult.Text = "OK";
  1947. // this.txtCCResult.BackColor = Color.Blue;
  1948. // }
  1949. // else
  1950. // {
  1951. // this.txtCCResult.Text = "NG";
  1952. // this.txtCCResult.BackColor = Color.Red;
  1953. // }
  1954. // }
  1955. // #endregion
  1956. //}
  1957. //catch (Exception ex)
  1958. //{
  1959. // throw new Exception(ex.ToString());
  1960. //}
  1961. #endregion
  1962. #region
  1963. //try
  1964. //{
  1965. // if (gridViewCC.FocusedRowHandle < 0)
  1966. // {
  1967. // return;
  1968. // }
  1969. // #region colS1
  1970. // int SNo = gridViewCC.FocusedRowHandle;
  1971. // int SNoCC = gridViewCC.RowCount;
  1972. // for (int i = SNo; i <= SNo; i++)
  1973. // {
  1974. // bool istrue = false;
  1975. // for (int k = 0; k < gridViewCC.RowCount; k++)
  1976. // {
  1977. // #region MyRegion
  1978. // bool _S1 = false;
  1979. // if (gridViewCC.GetRowCellValue(k, CCOK) != null)
  1980. // {
  1981. // if (!string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, CCOK).ToString()))
  1982. // {
  1983. // if (gridViewCC.GetRowCellValue(k, CCOK).ToString() == "True")
  1984. // {
  1985. // _S1 = true;
  1986. // }
  1987. // else
  1988. // _S1 = false;
  1989. // }
  1990. // }
  1991. // if (_S1)
  1992. // {
  1993. // istrue = true;
  1994. // }
  1995. // else
  1996. // {
  1997. // istrue = false;
  1998. // break;
  1999. // }
  2000. // #endregion
  2001. // }
  2002. // if (istrue)
  2003. // {
  2004. // this.txtCCResult.Text = "OK";
  2005. // this.txtCCResult.BackColor = Color.Blue;
  2006. // }
  2007. // else
  2008. // {
  2009. // this.txtCCResult.Text = "NG";
  2010. // this.txtCCResult.BackColor = Color.Red;
  2011. // }
  2012. // }
  2013. // #endregion
  2014. //}
  2015. //catch (Exception ex)
  2016. //{
  2017. // throw new Exception(ex.ToString());
  2018. //}
  2019. #endregion
  2020. #region
  2021. try
  2022. {
  2023. if (gridViewCC.FocusedRowHandle < 0)
  2024. {
  2025. return;
  2026. }
  2027. #region
  2028. int SNo = gridViewCC.FocusedRowHandle;
  2029. int SNoCC = gridViewCC.RowCount;
  2030. for (int i = SNo; i <= SNo; i++)
  2031. {
  2032. SendKeys.Send("{Down}");
  2033. if (SNo == SNoCC - 1)
  2034. {
  2035. for (int j = 0; j <= SNoCC - 1; j++)
  2036. {
  2037. SendKeys.Send("{Up}");
  2038. }
  2039. SendKeys.Send("{RIGHT}");
  2040. }
  2041. //for (int k = 0; k < gridViewCC.RowCount; k++)
  2042. //{
  2043. Decimal _VALUEMAX = 0; Decimal _VALUEMIN = 0; Decimal _S1 = 0;
  2044. if (gridViewCC.GetRowCellValue(gridViewCC.FocusedRowHandle, colSetValueMax) != null)
  2045. {
  2046. if (!string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(gridViewCC.FocusedRowHandle, colSetValueMax).ToString()))
  2047. {
  2048. _VALUEMAX = Decimal.Parse(gridViewCC.GetRowCellValue(gridViewCC.FocusedRowHandle, colSetValueMax).ToString());
  2049. }
  2050. }
  2051. if (gridViewCC.GetRowCellValue(gridViewCC.FocusedRowHandle, colSetValueMin) != null)
  2052. {
  2053. if (!string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(gridViewCC.FocusedRowHandle, colSetValueMin).ToString()))
  2054. {
  2055. _VALUEMIN = Decimal.Parse(gridViewCC.GetRowCellValue(gridViewCC.FocusedRowHandle, colSetValueMin).ToString());
  2056. }
  2057. }
  2058. if (gridViewCC.FocusedColumn.Caption == "检验值" && !string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(gridViewCC.FocusedRowHandle, colCheckResult).ToString()))
  2059. {
  2060. #region MyRegion
  2061. //判断检验值是否是数字
  2062. if (!IsNum(gridViewCC.GetRowCellValue(gridViewCC.FocusedRowHandle, colCheckResult).ToString()))
  2063. {
  2064. //gridViewCC.SetRowCellValue(gridViewCC.FocusedRowHandle, colCheckResult, 0);
  2065. SetMessage("检验值请填写数字!", Color.Red);
  2066. return;
  2067. }
  2068. else
  2069. {
  2070. if (gridViewCC.GetRowCellValue(gridViewCC.FocusedRowHandle, colCheckResult) != null)
  2071. {
  2072. if (!string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(gridViewCC.FocusedRowHandle, colCheckResult).ToString()))
  2073. {
  2074. _S1 = Decimal.Parse(gridViewCC.GetRowCellValue(gridViewCC.FocusedRowHandle, colCheckResult).ToString());
  2075. }
  2076. }
  2077. //string OK = gridViewCC.GetRowCellValue(k, CCOK).ToString();
  2078. //string NG = gridViewCC.GetRowCellValue(k, CCNG).ToString();
  2079. //if ((OK == "False" && NG == "False") || (OK == "" && NG == ""))
  2080. //{
  2081. if ((_S1 < _VALUEMIN || _S1 > _VALUEMAX))
  2082. {
  2083. if (status1 != "true")
  2084. {
  2085. status1 = "true";
  2086. gridViewCC.SetRowCellValue(gridViewCC.FocusedRowHandle, CCNG, true);
  2087. status1 = "";
  2088. }
  2089. else if (status2 != "true")
  2090. {
  2091. status2 = "true";
  2092. gridViewCC.SetRowCellValue(gridViewCC.FocusedRowHandle, CCOK, false);
  2093. status2 = "";
  2094. }
  2095. //break;
  2096. }
  2097. else if ((_S1 >= _VALUEMIN || _S1 <= _VALUEMAX))
  2098. {
  2099. if (status1 != "true")
  2100. {
  2101. status1 = "true";
  2102. gridViewCC.SetRowCellValue(gridViewCC.FocusedRowHandle, CCOK, true);
  2103. status1 = "";
  2104. }
  2105. else if (status2 != "true")
  2106. {
  2107. status2 = "true";
  2108. gridViewCC.SetRowCellValue(gridViewCC.FocusedRowHandle, CCNG, false);
  2109. status2 = "";
  2110. }
  2111. //break;
  2112. }
  2113. //}
  2114. }
  2115. #endregion
  2116. }
  2117. else if (gridViewCC.FocusedColumn.Caption == "标准检测值" && !string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(gridViewCC.FocusedRowHandle, StandResult).ToString()))
  2118. {
  2119. //判断检验值是否是数字
  2120. if (!IsNum(gridViewCC.GetRowCellValue(gridViewCC.FocusedRowHandle, StandResult).ToString()))
  2121. {
  2122. gridViewCC.SetRowCellValue(gridViewCC.FocusedRowHandle, StandResult, 0);
  2123. SetMessage("标准检测值请填写数字!", Color.Red);
  2124. return;
  2125. }
  2126. }
  2127. else if (gridViewCC.FocusedColumn.Caption == "标准下限" && !string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(gridViewCC.FocusedRowHandle, colSetValueMin).ToString()))
  2128. {
  2129. if (_VALUEMAX < _VALUEMIN)
  2130. {
  2131. //gridViewCC.SetRowCellValue(gridViewCC.FocusedRowHandle, colSetValueMin, 0);
  2132. SetMessage("标准下限值不能大于标准上限值,请确认!", Color.Red);
  2133. return;
  2134. }
  2135. }
  2136. CheckResult();
  2137. }
  2138. #endregion
  2139. }
  2140. catch (Exception ex)
  2141. {
  2142. throw new Exception(ex.ToString());
  2143. }
  2144. #endregion
  2145. }
  2146. //判断是否全为数字
  2147. public static bool IsNum(string str)
  2148. {
  2149. char[] ch = new char[str.Length];
  2150. ch = str.ToCharArray();
  2151. for (int i = 0; i < ch.Length; i++)
  2152. {
  2153. if (!(ch[i] >= 0x0030 && ch[i] <= 0x0039) && ch[i].ToString() != ".")
  2154. return false;
  2155. }
  2156. return true;
  2157. }
  2158. private void gridView2_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
  2159. {
  2160. try
  2161. {
  2162. if (gridView2.FocusedRowHandle < 0)
  2163. {
  2164. return;
  2165. }
  2166. #region colS1
  2167. int SNo = gridView2.FocusedRowHandle;
  2168. int SNoCC = gridView2.RowCount;
  2169. for (int i = SNo; i <= SNo; i++)
  2170. {
  2171. SendKeys.Send("{Down}");
  2172. if (SNo == SNoCC - 1)
  2173. {
  2174. for (int j = 0; j <= SNoCC - 1; j++)
  2175. {
  2176. SendKeys.Send("{Up}");
  2177. }
  2178. SendKeys.Send("{RIGHT}");
  2179. }
  2180. bool istrue = true;
  2181. for (int k = 0; k < gridView2.RowCount; k++)
  2182. {
  2183. #region MyRegion
  2184. //bool _S1 = false;
  2185. //if (gridView2.GetRowCellValue(k, colOK) != null)
  2186. //{
  2187. // if (!string.IsNullOrWhiteSpace(gridView2.GetRowCellValue(k, colOK).ToString()))
  2188. // {
  2189. // if (gridView2.GetRowCellValue(k, colOK).ToString() == "True")
  2190. // {
  2191. // _S1 = true;
  2192. // }
  2193. // }
  2194. //}
  2195. //bool _S2 = false;
  2196. //if (gridView2.GetRowCellValue(k, colNotOK) != null)
  2197. //{
  2198. // if (!string.IsNullOrWhiteSpace(gridView2.GetRowCellValue(k, colNotOK).ToString()))
  2199. // {
  2200. // if (gridView2.GetRowCellValue(k, colNotOK).ToString() == "True")
  2201. // {
  2202. // _S2 = true;
  2203. // }
  2204. // }
  2205. //}
  2206. //if (_S1 && gridView2.FocusedColumn.Caption == "合格")
  2207. //{
  2208. // istrue = true;
  2209. //}
  2210. //else if (gridView2.FocusedColumn.Caption == "检验项代码")
  2211. //{
  2212. // istrue = true;
  2213. //}
  2214. //else if(_S2 && gridView2.FocusedColumn.Caption == "不合格")
  2215. //{
  2216. // istrue = false;
  2217. //}
  2218. #endregion
  2219. string OK = gridView2.GetRowCellValue(k, colOK).ToString();
  2220. string NG = gridView2.GetRowCellValue(k, colNotOK).ToString();
  2221. if (!string.IsNullOrEmpty(OK) && OK == "True")
  2222. {
  2223. istrue = true;
  2224. }
  2225. else if (!string.IsNullOrEmpty(NG) && NG == "True")
  2226. {
  2227. istrue = false;
  2228. break;
  2229. }
  2230. }
  2231. if (istrue)
  2232. {
  2233. this.txtWGResult.Text = "OK";
  2234. this.txtWGResult.BackColor = Color.Blue;
  2235. }
  2236. else
  2237. {
  2238. this.txtWGResult.Text = "NG";
  2239. this.txtWGResult.BackColor = Color.Red;
  2240. }
  2241. }
  2242. #endregion
  2243. }
  2244. catch (Exception ex)
  2245. {
  2246. throw new Exception(ex.ToString());
  2247. }
  2248. }
  2249. private void BtnDesignMap_Click(object sender, EventArgs e)
  2250. {
  2251. try
  2252. {
  2253. string url = @"http://172.16.12.155:8999/api/GetPLMToken";
  2254. //string url = @"http://localhost:51182/api/GetPLMToken";
  2255. SearchPart Bills = new SearchPart();
  2256. //Bills.ItemCode = "20100003035";
  2257. //Bills.ItemCode = "20100000670";
  2258. //Bills.ItemCode = "20800001904";
  2259. Bills.ItemCode = txtProductCode.Text.Trim();
  2260. if (string.IsNullOrWhiteSpace(Bills.ItemCode))
  2261. {
  2262. SetMessage("请先输入产品追踪单号", Color.Red);
  2263. return;
  2264. }
  2265. Bills.size = 100;
  2266. Bills.extra = "DWGSW";
  2267. string JsonData = JsonConvert.SerializeObject(Bills);
  2268. //try
  2269. //{
  2270. // //Bills = JsonConvert.DeserializeObject<List<SearchPart>>(JsonData.ToString());
  2271. // Bills = JsonConvert.DeserializeObject<SearchPart>(JsonData.ToString());
  2272. //}
  2273. #region MyRegion
  2274. BaseModel rtn = PLM.PLMMap(url, JsonData);
  2275. if (rtn.code == "200")
  2276. {
  2277. //txtGetPLMMap.Text = rtn.msg;
  2278. //panelMap.BringToFront();
  2279. //panel8WebMap.BringToFront();
  2280. //webBrowserMap.Navigate(txtGetPLMMap.Text);
  2281. //string path = string.Empty;
  2282. //path = "E:\\PDF";
  2283. //HttpDownloadFile(txtGetPLMMap.Text, path);
  2284. //SetMessage("", Color.Red);
  2285. //return;
  2286. //ICSSoft.Frame.PLM2MESInterface.Token.GetToken.OperationResult result = ICSSoft.Frame.PLM2MESInterface.Token.GetToken.GetPLMToken();
  2287. //string Token = result.errmsg;
  2288. string OpCode = this.txtOPCode.Text;
  2289. //string sql = @"SELECT SOPDrawing from ICSITEMROUTE2OP WHERE ITEMCODE='" + itemCode + "' AND ROUTECODE='" + RouteCode + "' AND OPCODE='" + OpCode + "' ";
  2290. //string connectionString = AppConfig.FrameConnectString; // AppConfig.GetDataBaseConnectStringByKey("[DB.PLM]");
  2291. //string connectionString = AppConfig.GetDataBaseConnectStringByKey("[DB.FTP2]");
  2292. //if (string.IsNullOrWhiteSpace(connectionString))
  2293. // return;
  2294. //string logAdress = ConfigurationManager.AppSettings["PLMAdress"].ToString();
  2295. //object name = DBHelper.ExecuteScalar(connectionString, CommandType.Text, sql);
  2296. //name = "123";
  2297. //if (name == null || string.IsNullOrWhiteSpace(name.ToString()))
  2298. // return;
  2299. //string fileName = "E:\\PDF\\20201015.pdf";
  2300. //string fileName = name.ToString() + itemCode + "\\" + RouteCode + "\\" + OpCode + ".pdf";
  2301. string connectionString = AppConfig.GetDataBaseConnectStringByKey("[DB.FTP]");
  2302. if (string.IsNullOrWhiteSpace(connectionString))
  2303. {
  2304. SetMessage("没有获取到FTP链接,请在数据源中先配置FTP", Color.Red);
  2305. return;
  2306. }
  2307. string[] ftps = connectionString.Split(';');
  2308. string ftpServerIP = ftps[0].Split('=')[1];
  2309. //string ftpRemotePath = ftps[1].Split('=')[1];
  2310. string ftpRemotePath = "";
  2311. string ftpUserID = ftps[2].Split('=')[1];
  2312. string ftpPassword = ftps[3].Split('=')[1];
  2313. FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword);
  2314. //FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword);
  2315. //string filePath = System.IO.Path.GetTempPath() + "\\Drawing";
  2316. string filePath = AppDomain.CurrentDomain.BaseDirectory + "\\Drawing";
  2317. if (!Directory.Exists(filePath))
  2318. {
  2319. Directory.CreateDirectory(filePath);
  2320. }
  2321. string fileName = Bills.ItemCode + ".pdf";
  2322. ftpWeb.Download(filePath + "\\", fileName);
  2323. string filePathName = filePath + "\\" + fileName;
  2324. //string fileName = logAdress + Bills.ItemCode + ".pdf";
  2325. string ftpURL = "ftp://" + ftpServerIP + "/" + fileName;
  2326. //if (!string.IsNullOrEmpty(fileName))
  2327. if (!string.IsNullOrEmpty(filePathName))
  2328. {
  2329. //axAcroPDF.LoadFile(fileName);
  2330. axAcroPDFTZ.LoadFile(filePathName);
  2331. axAcroPDFTZ.setShowToolbar(false);
  2332. axAcroPDFTZ.setShowScrollbars(false);
  2333. axAcroPDFTZ.setPageMode("thumbs");
  2334. axAcroPDFTZ.setLayoutMode("SinglePage");
  2335. axAcroPDFTZ.setView("Fit");
  2336. axAcroPDFTZ.Show();
  2337. }
  2338. #endregion
  2339. }
  2340. else
  2341. {
  2342. SetMessage("调用PLM接口返回异常:" + rtn.code + ";" + rtn.msg, Color.Red);
  2343. return;
  2344. }
  2345. }
  2346. catch (Exception ex)
  2347. {
  2348. MessageBox.Show(ex.Message);
  2349. }
  2350. }
  2351. private void BrnOPMap_Click(object sender, EventArgs e)
  2352. {
  2353. string url = @"http://172.16.12.155:8999/api/GetPLMToken3";
  2354. //string url = @"http://localhost:51182/api/GetPLMToken3";
  2355. SearchPart Bills = new SearchPart();
  2356. //Bills.ItemCode = "20100003035";
  2357. //Bills.ItemCode = "20100000670";
  2358. //Bills.ItemCode = "20800001904";
  2359. Bills.ItemCode = txtProductCode.Text.Trim();
  2360. if (string.IsNullOrWhiteSpace(Bills.ItemCode))
  2361. {
  2362. SetMessage("请先输入料号编码", Color.Red);
  2363. return;
  2364. }
  2365. if (string.IsNullOrEmpty(opseq))
  2366. {
  2367. SetMessage("请先输入正确工序!", Color.Red);
  2368. return;
  2369. }
  2370. Bills.size = 100;
  2371. Bills.extra = "DWGSW";
  2372. Bills.routecode = RouteCode;
  2373. Bills.opseq = opseq;
  2374. string JsonData = JsonConvert.SerializeObject(Bills);
  2375. //try
  2376. //{
  2377. // //Bills = JsonConvert.DeserializeObject<List<SearchPart>>(JsonData.ToString());
  2378. // Bills = JsonConvert.DeserializeObject<SearchPart>(JsonData.ToString());
  2379. //}
  2380. #region MyRegion
  2381. BaseModel rtn = PLM.PLMMap(url, JsonData);
  2382. if (rtn.code == "200")
  2383. {
  2384. string connectionString = AppConfig.GetDataBaseConnectStringByKey("[DB.FTP]");
  2385. if (string.IsNullOrWhiteSpace(connectionString))
  2386. {
  2387. SetMessage("没有获取到FTP链接,请在数据源中先配置FTP", Color.Red);
  2388. return;
  2389. }
  2390. string[] ftps = connectionString.Split(';');
  2391. string ftpServerIP = ftps[0].Split('=')[1];
  2392. //string ftpRemotePath = ftps[1].Split('=')[1];
  2393. string ftpRemotePath = "";
  2394. string ftpUserID = ftps[2].Split('=')[1];
  2395. string ftpPassword = ftps[3].Split('=')[1];
  2396. FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword);
  2397. //FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword);
  2398. //string filePath = System.IO.Path.GetTempPath() + "\\Drawing";
  2399. string filePath = AppDomain.CurrentDomain.BaseDirectory + "\\Drawing";
  2400. if (!Directory.Exists(filePath))
  2401. {
  2402. Directory.CreateDirectory(filePath);
  2403. }
  2404. string fileName = rtn.msg + ".pdf";
  2405. ftpWeb.Download(filePath + "\\", fileName);
  2406. string filePathName = filePath + "\\" + fileName;
  2407. //string fileName = logAdress + Bills.ItemCode + ".pdf";
  2408. string ftpURL = "ftp://" + ftpServerIP + "/" + fileName;
  2409. //if (!string.IsNullOrEmpty(fileName))
  2410. if (!string.IsNullOrEmpty(filePathName))
  2411. {
  2412. //axAcroPDF.LoadFile(fileName);
  2413. axAcroPDFTZ.LoadFile(filePathName);
  2414. axAcroPDFTZ.setShowToolbar(false);
  2415. axAcroPDFTZ.setShowScrollbars(false);
  2416. axAcroPDFTZ.setPageMode("thumbs");
  2417. axAcroPDFTZ.setLayoutMode("SinglePage");
  2418. axAcroPDFTZ.setView("Fit");
  2419. axAcroPDFTZ.Show();
  2420. }
  2421. #endregion
  2422. }
  2423. else
  2424. {
  2425. SetMessage("调用PLM接口返回异常:" + rtn.code + ";" + rtn.msg, Color.Red);
  2426. return;
  2427. }
  2428. }
  2429. private void BtnCheckBookMap_Click_1(object sender, EventArgs e)
  2430. {
  2431. try
  2432. {
  2433. string url = @"http://172.16.12.155:8999/api/GetPLMToken5";
  2434. //string url = @"http://localhost:51182/api/GetPLMToken5";
  2435. SearchPart Bills = new SearchPart();
  2436. //Bills.ItemCode = "20100003035";
  2437. //Bills.ItemCode = "20100000670";
  2438. //Bills.ItemCode = "20800001904";
  2439. Bills.ItemCode = txtProductCode.Text;
  2440. if (string.IsNullOrWhiteSpace(Bills.ItemCode))
  2441. {
  2442. SetMessage("请先输入料号编码", Color.Red);
  2443. return;
  2444. }
  2445. if (string.IsNullOrEmpty(opseq))
  2446. {
  2447. SetMessage("请先输入正确工序!", Color.Red);
  2448. return;
  2449. }
  2450. Bills.size = 100;
  2451. Bills.extra = "DWGSW";
  2452. Bills.routecode = RouteCode;
  2453. Bills.opseq = opseq;
  2454. string JsonData = JsonConvert.SerializeObject(Bills);
  2455. //try
  2456. //{
  2457. // //Bills = JsonConvert.DeserializeObject<List<SearchPart>>(JsonData.ToString());
  2458. // Bills = JsonConvert.DeserializeObject<SearchPart>(JsonData.ToString());
  2459. //}
  2460. #region MyRegion
  2461. BaseModel rtn = PLM.PLMMap(url, JsonData);
  2462. if (rtn.code == "200")
  2463. {
  2464. string connectionString = AppConfig.GetDataBaseConnectStringByKey("[DB.FTP]");
  2465. if (string.IsNullOrWhiteSpace(connectionString))
  2466. {
  2467. SetMessage("没有获取到FTP链接,请在数据源中先配置FTP", Color.Red);
  2468. return;
  2469. }
  2470. string[] ftps = connectionString.Split(';');
  2471. string ftpServerIP = ftps[0].Split('=')[1];
  2472. //string ftpRemotePath = ftps[1].Split('=')[1];
  2473. string ftpRemotePath = "";
  2474. string ftpUserID = ftps[2].Split('=')[1];
  2475. string ftpPassword = ftps[3].Split('=')[1];
  2476. FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword);
  2477. //FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword);
  2478. //string filePath = System.IO.Path.GetTempPath() + "\\Drawing";
  2479. string filePath = AppDomain.CurrentDomain.BaseDirectory + "\\Drawing";
  2480. if (!Directory.Exists(filePath))
  2481. {
  2482. Directory.CreateDirectory(filePath);
  2483. }
  2484. string fileName = rtn.msg + ".pdf";
  2485. ftpWeb.Download(filePath + "\\", fileName);
  2486. string filePathName = filePath + "\\" + fileName;
  2487. //string fileName = logAdress + Bills.ItemCode + ".pdf";
  2488. string ftpURL = "ftp://" + ftpServerIP + "/" + fileName;
  2489. //if (!string.IsNullOrEmpty(fileName))
  2490. if (!string.IsNullOrEmpty(filePathName))
  2491. {
  2492. //axAcroPDF.LoadFile(fileName);
  2493. axAcroPDFTZ.LoadFile(filePathName);
  2494. axAcroPDFTZ.setShowToolbar(false);
  2495. axAcroPDFTZ.setShowScrollbars(false);
  2496. axAcroPDFTZ.setPageMode("thumbs");
  2497. axAcroPDFTZ.setLayoutMode("SinglePage");
  2498. axAcroPDFTZ.setView("Fit");
  2499. axAcroPDFTZ.Show();
  2500. }
  2501. #endregion
  2502. }
  2503. else
  2504. {
  2505. SetMessage("调用PLM接口返回异常:" + rtn.code + ";" + rtn.msg, Color.Red);
  2506. return;
  2507. }
  2508. }
  2509. catch (Exception ex)
  2510. {
  2511. MessageBox.Show(ex.Message);
  2512. }
  2513. }
  2514. private void txtOPCode_KeyDown(object sender, KeyEventArgs e)
  2515. {
  2516. if (e.KeyCode == Keys.Enter)
  2517. {
  2518. txtOpName.Text = "";
  2519. string __sql = @"SELECT a.OPCODE 工序编码,c.OPDESC 工序名称,opseq,b.EATTRIBUTE1,e.result,d.ACTIONRESULT FROM ICSITEMROUTE2OPLot a
  2520. left join ICSMO2User b on a.LotNo= b.LOTNO and a.OPCODE=b.OPCODE
  2521. left join ICSLOTONWIP d on d.LotNo=a.LotNo and d.OPCODE=a.OPCODE
  2522. left join ICSLOTONWIPCheck e on e.onwipid=d.ID
  2523. INNER JOIN ICSOP c ON c.OPCODE=a.OPCODE
  2524. WHERE a.lotno='" + LotNo + "' AND a.WorkPoint='{0}' and a.opcode='" + txtOPCode.Text.Trim() + "' and d.eattribute1 is null ORDER BY a.OPSEQ";
  2525. __sql = string.Format(__sql, AppConfig.WorkPointCode);
  2526. DataTable __dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, __sql).Tables[0];
  2527. if (__dt.Rows.Count <= 0)
  2528. {
  2529. SetMessage("未查询到该工序!", Color.Red);
  2530. btnTempSave.Enabled = false;
  2531. return;
  2532. }
  2533. DataRow row = __dt.Rows[0];
  2534. string isww = "0";
  2535. if (checkboxWW.Checked == true)
  2536. {
  2537. isww = "1";
  2538. }
  2539. if (string.IsNullOrEmpty(row["EATTRIBUTE1"].ToString()))
  2540. {
  2541. SetMessage("该工序未派工!", Color.Red);
  2542. btnTempSave.Enabled = false;
  2543. return;
  2544. }
  2545. if (row["EATTRIBUTE1"].ToString() != isww)
  2546. {
  2547. if (isww == "1")
  2548. SetMessage("该工序不是委外工序", Color.Red);
  2549. else
  2550. SetMessage("该工序不是自制工序", Color.Red);
  2551. btnTempSave.Enabled = false;
  2552. return;
  2553. }
  2554. if (row["ACTIONRESULT"].ToString() != "COLLECT_END")
  2555. {
  2556. SetMessage("该工序还未完工或收料!", Color.Red);
  2557. btnTempSave.Enabled = false;
  2558. return;
  2559. }
  2560. if (string.IsNullOrEmpty(row["result"].ToString()) != true && row["result"].ToString() != "待检")
  2561. {
  2562. SetMessage("该工序已检验!", Color.Red);
  2563. btnTempSave.Enabled = false;
  2564. return;
  2565. }
  2566. if (__dt != null && __dt.Rows.Count > 0)
  2567. {
  2568. opseq = __dt.Rows[0]["opseq"].ToString();
  2569. txtOpName.Text = __dt.Rows[0]["工序名称"].ToString();
  2570. SetMessage("工序条码扫描成功!", Color.Blue);
  2571. //调用检验数据接口
  2572. try
  2573. {
  2574. //GetPLMCKDATA(txtProductCode.Text.Trim(), RouteCode, opseq);
  2575. }
  2576. catch (Exception ex)
  2577. {
  2578. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  2579. return;
  2580. }
  2581. btnTempSave.Enabled = true;
  2582. }
  2583. initCheck();
  2584. }
  2585. }
  2586. public void Clear(bool clearlotno)
  2587. {
  2588. txtUserCode.Text = "";
  2589. txtUserName.Text = "";
  2590. txtMOCode.Text = "";
  2591. txtMOQty.Text = "";
  2592. txtOrderNo.Text = "";
  2593. if (clearlotno)
  2594. {
  2595. txtLotNo.Text = "";
  2596. }
  2597. txtProductCode.Text = "";
  2598. txtPriductName.Text = "";
  2599. txtLotQty.Text = "";
  2600. txtOPCode.Text = "";
  2601. txtOpName.Text = "";
  2602. gridControlcc.DataSource = null;
  2603. txtCCResult.Text = "";
  2604. txtWGResult.Text = "";
  2605. gridControl2.DataSource = null;
  2606. }
  2607. private void btnEnlargeTZ_Click(object sender, EventArgs e)
  2608. {
  2609. FileDrawing.Enlarge(axAcroPDFTZ);
  2610. }
  2611. private void btnOperationManua_Click(object sender, EventArgs e)
  2612. {
  2613. try
  2614. {
  2615. string url = @"http://172.16.12.155:8999/api/GetPLMToken2";
  2616. //string url = @"http://localhost:51182/api/GetPLMToken2";
  2617. //;
  2618. SearchPart Bills = new SearchPart();
  2619. //Bills.ItemCode = "20100003035";
  2620. //Bills.ItemCode = "20100000670";
  2621. //Bills.ItemCode = "20800001904";
  2622. Bills.ItemCode = txtProductCode.Text;
  2623. if (string.IsNullOrWhiteSpace(Bills.ItemCode))
  2624. {
  2625. SetMessage("请先输入料号编码", Color.Red);
  2626. return;
  2627. }
  2628. Bills.size = 100;
  2629. //0916 原来的 Bills.extra = "DWGSW";
  2630. Bills.extra = "PRCF";
  2631. string JsonData = JsonConvert.SerializeObject(Bills);
  2632. //try
  2633. //{
  2634. // //Bills = JsonConvert.DeserializeObject<List<SearchPart>>(JsonData.ToString());
  2635. // Bills = JsonConvert.DeserializeObject<SearchPart>(JsonData.ToString());
  2636. //}
  2637. #region MyRegion
  2638. BaseModel rtn = PLM.PLMMap(url, JsonData);
  2639. if (rtn.code == "200")
  2640. {
  2641. #region MyRegion
  2642. string OpCode = this.txtOPCode.Text;
  2643. string connectionString = AppConfig.GetDataBaseConnectStringByKey("[DB.FTP]");
  2644. if (string.IsNullOrWhiteSpace(connectionString))
  2645. {
  2646. SetMessage("没有获取到FTP链接,请在数据源中先配置FTP", Color.Red);
  2647. return;
  2648. }
  2649. string[] ftps = connectionString.Split(';');
  2650. string ftpServerIP = ftps[0].Split('=')[1];
  2651. //string ftpRemotePath = ftps[1].Split('=')[1];
  2652. string ftpRemotePath = "";
  2653. string ftpUserID = ftps[2].Split('=')[1];
  2654. string ftpPassword = ftps[3].Split('=')[1];
  2655. FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword);
  2656. //FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword);
  2657. //string filePath = System.IO.Path.GetTempPath() + "\\Drawing";
  2658. string filePath = AppDomain.CurrentDomain.BaseDirectory + "\\Drawing";
  2659. if (!Directory.Exists(filePath))
  2660. {
  2661. Directory.CreateDirectory(filePath);
  2662. }
  2663. string fileName = rtn.msg + ".pdf";
  2664. ftpWeb.Download(filePath + "\\", fileName);
  2665. string filePathName = filePath + "\\" + fileName;
  2666. //string fileName = logAdress + Bills.ItemCode + ".pdf";
  2667. string ftpURL = "ftp://" + ftpServerIP + "/" + fileName;
  2668. //if (!string.IsNullOrEmpty(fileName))
  2669. if (!string.IsNullOrEmpty(filePathName))
  2670. {
  2671. //axAcroPDF.LoadFile(fileName);
  2672. axAcroPDFTZ.LoadFile(filePathName);
  2673. axAcroPDFTZ.setShowToolbar(false);
  2674. axAcroPDFTZ.setShowScrollbars(false);
  2675. axAcroPDFTZ.setPageMode("thumbs");
  2676. axAcroPDFTZ.setLayoutMode("SinglePage");
  2677. axAcroPDFTZ.setView("Fit");
  2678. axAcroPDFTZ.Show();
  2679. }
  2680. #endregion
  2681. }
  2682. else
  2683. {
  2684. SetMessage("调用PLM接口返回异常:" + rtn.code + ";" + rtn.msg, Color.Red);
  2685. return;
  2686. }
  2687. #endregion
  2688. }
  2689. catch (Exception ex)
  2690. {
  2691. MessageBox.Show(ex.Message);
  2692. }
  2693. }
  2694. private void GetPLMCKDATA(string itemcode, string routecode, string opseq)
  2695. {
  2696. try
  2697. {
  2698. string url = @"http://172.16.12.155:8999/api/GetPLMCKDATA";
  2699. SearchPart Bills = new SearchPart();
  2700. Bills.opseq = opseq;
  2701. Bills.ItemCode = itemcode;
  2702. Bills.routecode = routecode;
  2703. string opcode = txtOPCode.Text.Trim();
  2704. string JsonData = JsonConvert.SerializeObject(Bills);
  2705. string CKDATA = PLM.PLMMap1(url, JsonData);
  2706. JObject jobject = JObject.Parse(CKDATA);
  2707. if (jobject["code"].ToString() == "200")
  2708. {
  2709. string data = jobject["data"].ToString();
  2710. List<Parts> part = new List<Parts>();
  2711. part = (List<Parts>)JsonConvert.DeserializeObject(data, typeof(List<Parts>));
  2712. List<ICSOQCCKGROUP> group = new List<ICSOQCCKGROUP>();
  2713. List<ICSOQCCKLIST> cklist = new List<ICSOQCCKLIST>();
  2714. List<string> RemoveID = new List<string>();
  2715. foreach (Parts p in part)
  2716. {
  2717. ICSOQCCKGROUP g = ICSOQCCKLISTBLL.isExits(p.objNo);
  2718. if (g == null)
  2719. {
  2720. g = new ICSOQCCKGROUP();
  2721. g.ID = AppConfig.GetGuid();
  2722. g.ISREF = "是";
  2723. g.MTIME = DateTime.Now;
  2724. g.MUSER = AppConfig.UserId;
  2725. g.MUSERName = AppConfig.UserName;
  2726. g.CKGROUP = AppConfig.GetSerialCode(AppConfig.AppConnectString, AppConfig.WorkPointCode, "ICSOQCCKGROUP", "CKGROUP", "A" + DateTime.Now.Year.ToString(), 3);
  2727. g.CKGROUPDESC = p.objNo.Split(',')[1];
  2728. g.WorkPoint = AppConfig.WorkPointCode;
  2729. g.CKGROUPDNAME = p.objNo.Split(',')[0];
  2730. group.Add(g);
  2731. }
  2732. ICSOQCCKLIST c = ICSOQCCKLISTBLL.IsExistCKLIST(p.objId);
  2733. if (c == null || (c != null && Convert.ToDateTime(c.EATTRIBUTE1) < Convert.ToDateTime(string.IsNullOrEmpty(p.mtimestr) ? p.ctimestr : p.mtimestr)))
  2734. {
  2735. c = new ICSOQCCKLIST();
  2736. c.ID = p.objId;
  2737. c.CKGROUPCode = g.CKGROUP;
  2738. c.UNIT = p.extra.DW;
  2739. c.WorkPoint = AppConfig.WorkPointCode;
  2740. c.SetValueMax = string.IsNullOrEmpty(p.extra.SX) ? 0 : Convert.ToDecimal(p.extra.SX);
  2741. c.SetValueMin = string.IsNullOrEmpty(p.extra.XX) ? 0 : Convert.ToDecimal(p.extra.XX);
  2742. c.MUSER = AppConfig.UserName;
  2743. c.MTIME = DateTime.Now;
  2744. c.ISREF = "是";
  2745. c.INVCode = p.extra.MPARTNO;
  2746. c.OPCode = opcode;
  2747. c.CKGROUPMETH = "工序检验";
  2748. c.CKGROUPATTR = p.extra.SX1;
  2749. c.GJ = p.extra.GJ;
  2750. c.JY1 = p.extra.JY1;
  2751. c.JY2 = p.extra.JY2;
  2752. c.PType = Convert.ToDecimal(p.extra.PTYPE);
  2753. c.StandValue = p.extra.NAME;
  2754. if (!string.IsNullOrEmpty(p.mtimestr))
  2755. c.EATTRIBUTE1 = p.mtimestr;
  2756. else
  2757. c.EATTRIBUTE1 = p.ctimestr;
  2758. cklist.Add(c);
  2759. }
  2760. RemoveID.Add(p.objId);
  2761. }
  2762. ICSOQCCKLISTBLL.AddGroupAndList(group, cklist, RemoveID, itemcode, opcode);
  2763. }
  2764. else
  2765. {
  2766. if (jobject["msg"].ToString() != "没有更多了")
  2767. throw new Exception(jobject["msg"].ToString());
  2768. }
  2769. }
  2770. catch (Exception ex)
  2771. {
  2772. throw ex;
  2773. }
  2774. }
  2775. public class Parts
  2776. {
  2777. public string errcode { get; set; }
  2778. public string errmsg { get; set; }
  2779. public string objId { get; set; }
  2780. public string objNo { get; set; }
  2781. public string fname { get; set; }
  2782. public string suffix { get; set; }
  2783. public string hasAffine { get; set; }
  2784. public string name { get; set; }
  2785. public string fsize { get; set; }
  2786. public string fsizeStr { get; set; }
  2787. public string type { get; set; }
  2788. public string tablename { get; set; }
  2789. public string smemo { get; set; }
  2790. public string ctimestr { get; set; }
  2791. public string mtimestr { get; set; }
  2792. public string creator { get; set; }
  2793. public string modifier { get; set; }
  2794. public string ver { get; set; }
  2795. public string stimestr { get; set; }
  2796. public string etimestr { get; set; }
  2797. public Extra extra { get; set; }
  2798. public string searchText { get; set; }
  2799. }
  2800. public class Extra
  2801. {
  2802. public string PTYPE;
  2803. public string XX;
  2804. public string NAME;
  2805. public string SX;
  2806. public string DW;
  2807. public string JY2;
  2808. public string SX1;
  2809. public string GJ;
  2810. public string JY1;
  2811. public string GG;
  2812. public string SMEMO;
  2813. public string MPARTNO;
  2814. }
  2815. private void repositoryItemCheckEdit3_CheckedChanged(object sender, EventArgs e)
  2816. {
  2817. }
  2818. private void repositoryItemCheckEdit3_QueryValueByCheckState(object sender, DevExpress.XtraEditors.Controls.QueryValueByCheckStateEventArgs e)
  2819. {
  2820. int rowhandle = gridViewCC.FocusedRowHandle;
  2821. if (e.CheckState == CheckState.Checked)
  2822. {
  2823. gridViewCC.SetRowCellValue(rowhandle, CCOK, true);
  2824. gridViewCC.SetRowCellValue(rowhandle, CCNG, false);
  2825. }
  2826. else
  2827. {
  2828. gridViewCC.SetRowCellValue(rowhandle, CCOK, false);
  2829. }
  2830. #region
  2831. //try
  2832. //{
  2833. // if (gridViewCC.FocusedRowHandle < 0)
  2834. // {
  2835. // return;
  2836. // }
  2837. // #region colS1
  2838. // int SNo = gridViewCC.FocusedRowHandle;
  2839. // int SNoCC = gridViewCC.RowCount;
  2840. // for (int i = SNo; i <= SNo; i++)
  2841. // {
  2842. // SendKeys.Send("{Down}");
  2843. // if (SNo == SNoCC - 1)
  2844. // {
  2845. // for (int j = 0; j <= SNoCC - 1; j++)
  2846. // {
  2847. // SendKeys.Send("{Up}");
  2848. // }
  2849. // SendKeys.Send("{RIGHT}");
  2850. // }
  2851. // bool istrue = false;
  2852. // for (int k = 0; k < gridViewCC.RowCount; k++)
  2853. // {
  2854. // #region MyRegion
  2855. // Decimal _VALUEMAX = 0; Decimal _VALUEMIN = 0; Decimal _S1 = 0;
  2856. // if (gridViewCC.GetRowCellValue(k, colSetValueMax) != null)
  2857. // {
  2858. // if (!string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, colSetValueMax).ToString()))
  2859. // {
  2860. // _VALUEMAX = Decimal.Parse(gridViewCC.GetRowCellValue(k, colSetValueMax).ToString());
  2861. // }
  2862. // }
  2863. // if (gridViewCC.GetRowCellValue(k, colSetValueMin) != null)
  2864. // {
  2865. // if (!string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, colSetValueMin).ToString()))
  2866. // {
  2867. // _VALUEMIN = Decimal.Parse(gridViewCC.GetRowCellValue(k, colSetValueMin).ToString());
  2868. // }
  2869. // }
  2870. // if (gridViewCC.GetRowCellValue(k, colCheckResult) != null)
  2871. // {
  2872. // if (!string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, colCheckResult).ToString()))
  2873. // {
  2874. // _S1 = Decimal.Parse(gridViewCC.GetRowCellValue(k, colCheckResult).ToString());
  2875. // }
  2876. // }
  2877. // if ((_S1 < _VALUEMIN || _S1 > _VALUEMAX) && gridViewCC.FocusedColumn.Caption == "检验值" && !string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, colCheckResult).ToString()))
  2878. // {
  2879. // istrue = false;
  2880. // break;
  2881. // }
  2882. // else
  2883. // {
  2884. // istrue = true;
  2885. // }
  2886. // #endregion
  2887. // }
  2888. // if (istrue)
  2889. // {
  2890. // this.txtCCResult.Text = "OK";
  2891. // this.txtCCResult.BackColor = Color.Blue;
  2892. // }
  2893. // else
  2894. // {
  2895. // this.txtCCResult.Text = "NG";
  2896. // this.txtCCResult.BackColor = Color.Red;
  2897. // }
  2898. // }
  2899. // #endregion
  2900. //}
  2901. //catch (Exception ex)
  2902. //{
  2903. // throw new Exception(ex.ToString());
  2904. //}
  2905. #endregion
  2906. #region
  2907. try
  2908. {
  2909. if (gridViewCC.FocusedRowHandle < 0)
  2910. {
  2911. return;
  2912. }
  2913. #region colS1
  2914. int SNo = gridViewCC.FocusedRowHandle;
  2915. int SNoCC = gridViewCC.RowCount;
  2916. for (int i = SNo; i <= SNo; i++)
  2917. {
  2918. bool istrue = false;
  2919. for (int k = 0; k < gridViewCC.RowCount; k++)
  2920. {
  2921. #region MyRegion
  2922. bool _S1 = false;
  2923. if (gridViewCC.GetRowCellValue(k, CCOK) != null)
  2924. {
  2925. if (!string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, CCOK).ToString()))
  2926. {
  2927. string cc = gridViewCC.GetRowCellValue(k, CCOK).ToString();
  2928. if (gridViewCC.GetRowCellValue(k, CCOK).ToString() == "True" || (gridViewCC.GetRowCellValue(k, CCOK).ToString() == "False" && gridViewCC.GetRowCellValue(k, CCNG).ToString() == "False"))
  2929. {
  2930. _S1 = true;
  2931. }
  2932. else
  2933. _S1 = false;
  2934. }
  2935. }
  2936. if (_S1)
  2937. {
  2938. istrue = true;
  2939. }
  2940. else
  2941. {
  2942. istrue = false;
  2943. break;
  2944. }
  2945. #endregion
  2946. }
  2947. if (istrue)
  2948. {
  2949. this.txtCCResult.Text = "OK";
  2950. this.txtCCResult.BackColor = Color.Blue;
  2951. }
  2952. else
  2953. {
  2954. this.txtCCResult.Text = "NG";
  2955. this.txtCCResult.BackColor = Color.Red;
  2956. }
  2957. }
  2958. #endregion
  2959. }
  2960. catch (Exception ex)
  2961. {
  2962. throw new Exception(ex.ToString());
  2963. }
  2964. #endregion
  2965. }
  2966. private void repositoryItemCheckEdit4_QueryValueByCheckState(object sender, DevExpress.XtraEditors.Controls.QueryValueByCheckStateEventArgs e)
  2967. {
  2968. int rowhandle = gridViewCC.FocusedRowHandle;
  2969. if (e.CheckState == CheckState.Checked)
  2970. {
  2971. gridViewCC.SetRowCellValue(rowhandle, CCNG, true);
  2972. gridViewCC.SetRowCellValue(rowhandle, CCOK, false);
  2973. }
  2974. else
  2975. {
  2976. gridViewCC.SetRowCellValue(rowhandle, CCNG, false);
  2977. }
  2978. #region
  2979. try
  2980. {
  2981. if (gridViewCC.FocusedRowHandle < 0)
  2982. {
  2983. return;
  2984. }
  2985. #region colS1
  2986. int SNo = gridViewCC.FocusedRowHandle;
  2987. int SNoCC = gridViewCC.RowCount;
  2988. for (int i = SNo; i <= SNo; i++)
  2989. {
  2990. bool istrue = false;
  2991. for (int k = 0; k < gridViewCC.RowCount; k++)
  2992. {
  2993. #region MyRegion
  2994. bool _S1 = false;
  2995. if (gridViewCC.GetRowCellValue(k, CCOK) != null)
  2996. {
  2997. if (!string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, CCOK).ToString()))
  2998. {
  2999. string cc = gridViewCC.GetRowCellValue(k, CCOK).ToString();
  3000. if (gridViewCC.GetRowCellValue(k, CCOK).ToString() == "True" || (gridViewCC.GetRowCellValue(k, CCOK).ToString() == "False" && gridViewCC.GetRowCellValue(k, CCNG).ToString() == "False"))
  3001. {
  3002. _S1 = true;
  3003. }
  3004. else
  3005. _S1 = false;
  3006. }
  3007. }
  3008. if (_S1)
  3009. {
  3010. istrue = true;
  3011. }
  3012. else
  3013. {
  3014. istrue = false;
  3015. break;
  3016. }
  3017. #endregion
  3018. }
  3019. if (istrue)
  3020. {
  3021. this.txtCCResult.Text = "OK";
  3022. this.txtCCResult.BackColor = Color.Blue;
  3023. }
  3024. else
  3025. {
  3026. this.txtCCResult.Text = "NG";
  3027. this.txtCCResult.BackColor = Color.Red;
  3028. }
  3029. }
  3030. #endregion
  3031. }
  3032. catch (Exception ex)
  3033. {
  3034. throw new Exception(ex.ToString());
  3035. }
  3036. #endregion
  3037. }
  3038. private void btnZP_Click(object sender, EventArgs e)
  3039. {
  3040. string url = @"http://172.16.12.155:9999/api/GetPLMToken8";
  3041. //string url = @"http://localhost:51182/api/GetPLMToken8";
  3042. SearchPart Bills = new SearchPart();
  3043. //Bills.ItemCode = "20100003035";
  3044. //Bills.ItemCode = "20100000670";
  3045. //Bills.ItemCode = "20800001904";
  3046. Bills.ItemCode = txtProductCode.Text.Trim();
  3047. if (string.IsNullOrWhiteSpace(Bills.ItemCode))
  3048. {
  3049. SetMessage("请先输入料号编码", Color.Red);
  3050. return;
  3051. }
  3052. if (string.IsNullOrEmpty(opseq))
  3053. {
  3054. SetMessage("请先输入正确工序!", Color.Red);
  3055. return;
  3056. }
  3057. Bills.size = 100;
  3058. Bills.routecode = RouteCode;
  3059. Bills.opseq = opseq;
  3060. string JsonData = JsonConvert.SerializeObject(Bills);
  3061. //try
  3062. //{
  3063. // //Bills = JsonConvert.DeserializeObject<List<SearchPart>>(JsonData.ToString());
  3064. // Bills = JsonConvert.DeserializeObject<SearchPart>(JsonData.ToString());
  3065. //}
  3066. #region MyRegion
  3067. BaseModel rtn = PLM.PLMMap(url, JsonData);
  3068. if (rtn.code == "200")
  3069. {
  3070. string connectionString = AppConfig.GetDataBaseConnectStringByKey("[DB.FTP]");
  3071. if (string.IsNullOrWhiteSpace(connectionString))
  3072. {
  3073. SetMessage("没有获取到FTP链接,请在数据源中先配置FTP", Color.Red);
  3074. return;
  3075. }
  3076. string[] ftps = connectionString.Split(';');
  3077. string ftpServerIP = ftps[0].Split('=')[1];
  3078. //string ftpRemotePath = ftps[1].Split('=')[1];
  3079. string ftpRemotePath = "";
  3080. string ftpUserID = ftps[2].Split('=')[1];
  3081. string ftpPassword = ftps[3].Split('=')[1];
  3082. FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword);
  3083. //FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword);
  3084. //string filePath = System.IO.Path.GetTempPath() + "\\Drawing";
  3085. string filePath = AppDomain.CurrentDomain.BaseDirectory + "\\Drawing";
  3086. if (!Directory.Exists(filePath))
  3087. {
  3088. Directory.CreateDirectory(filePath);
  3089. }
  3090. string fileName = rtn.msg + ".pdf";
  3091. ftpWeb.Download(filePath + "\\", fileName);
  3092. string filePathName = filePath + "\\" + fileName;
  3093. //string fileName = logAdress + Bills.ItemCode + ".pdf";
  3094. string ftpURL = "ftp://" + ftpServerIP + "/" + fileName;
  3095. //if (!string.IsNullOrEmpty(fileName))
  3096. if (!string.IsNullOrEmpty(filePathName))
  3097. {
  3098. //axAcroPDF.LoadFile(fileName);
  3099. axAcroPDFTZ.LoadFile(filePathName);
  3100. axAcroPDFTZ.setShowToolbar(false);
  3101. axAcroPDFTZ.setShowScrollbars(false);
  3102. axAcroPDFTZ.setPageMode("thumbs");
  3103. axAcroPDFTZ.setLayoutMode("SinglePage");
  3104. axAcroPDFTZ.setView("Fit");
  3105. axAcroPDFTZ.Show();
  3106. }
  3107. #endregion
  3108. }
  3109. else
  3110. {
  3111. SetMessage("调用PLM接口返回异常:" + rtn.code + ";" + rtn.msg, Color.Red);
  3112. return;
  3113. }
  3114. }
  3115. private void btnOperationManua_MouseLeave(object sender, EventArgs e)
  3116. {
  3117. btnOperationManua.BackColor = System.Drawing.Color.FromArgb(207, 221, 255);
  3118. }
  3119. private void btnOperationManua_MouseMove(object sender, MouseEventArgs e)
  3120. {
  3121. btnOperationManua.BackColor = System.Drawing.Color.DeepSkyBlue;
  3122. }
  3123. private void btnZP_MouseLeave(object sender, EventArgs e)
  3124. {
  3125. btnZP.BackColor = System.Drawing.Color.FromArgb(207, 221, 255);
  3126. }
  3127. private void btnZP_MouseMove(object sender, MouseEventArgs e)
  3128. {
  3129. btnZP.BackColor = System.Drawing.Color.DeepSkyBlue;
  3130. }
  3131. private void btnAddRow_Click(object sender, EventArgs e)
  3132. {
  3133. string message = txtMessage.Text.Trim();
  3134. if (message != "")
  3135. {
  3136. if (!message.Contains("保存成功"))
  3137. {
  3138. if (!message.Contains("该工序"))
  3139. {
  3140. DataTable dt = this.gridControlcc.DataSource as DataTable;
  3141. DataRow dr = dt.NewRow();
  3142. dr["id"] = AppConfig.GetGuid();
  3143. dt.Rows.Add(dr);
  3144. }
  3145. }
  3146. }
  3147. }
  3148. private void btnDelRow_Click(object sender, EventArgs e)
  3149. {
  3150. gridViewCC.PostEditor();
  3151. this.Validate();
  3152. if (gridViewCC.RowCount == 0)
  3153. return;
  3154. if (gridViewCC.FocusedRowHandle < 0)
  3155. return;
  3156. gridViewCC.DeleteRow(gridViewCC.FocusedRowHandle);
  3157. CheckResult();
  3158. }
  3159. private void CheckResult()
  3160. {
  3161. //重新判断检验结果
  3162. bool istrue = true;
  3163. for (int k = 0; k < gridViewCC.RowCount; k++)
  3164. {
  3165. string OK = gridViewCC.GetRowCellValue(k, CCOK).ToString();
  3166. string NG = gridViewCC.GetRowCellValue(k, CCNG).ToString();
  3167. if (!string.IsNullOrEmpty(OK) && OK == "True")
  3168. {
  3169. istrue = true;
  3170. }
  3171. else if (!string.IsNullOrEmpty(NG) && NG == "True")
  3172. {
  3173. istrue = false;
  3174. break;
  3175. }
  3176. }
  3177. if (istrue)
  3178. {
  3179. this.txtCCResult.Text = "OK";
  3180. this.txtCCResult.BackColor = Color.Blue;
  3181. }
  3182. else
  3183. {
  3184. this.txtCCResult.Text = "NG";
  3185. this.txtCCResult.BackColor = Color.Red;
  3186. }
  3187. }
  3188. #region 查询尺寸检验项目
  3189. private void CCGroupItemButtonEdit_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  3190. {
  3191. ButtonEdit btn = (ButtonEdit)sender;
  3192. string sql = "";
  3193. DataTable data = null;
  3194. ButtonEdit buttonEdit = (sender as ButtonEdit);
  3195. sql = @"select CKGROUP as 检验项代码,CKGROUPDNAME as 检验项名称,CKGROUPDESC as 检验项描述
  3196. from ICSOQCCKGROUP where ISREF='是'";
  3197. sql = string.Format(sql);
  3198. data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  3199. FormDataRefer reForm = new FormDataRefer();
  3200. reForm.FormTitle = "检验项目信息";
  3201. DataTable menuData = data;
  3202. reForm.DataSource = menuData;
  3203. reForm.MSelectFlag = false;
  3204. reForm.RowIndexWidth = 35;
  3205. reForm.FormWidth = 500;
  3206. reForm.FormHeight = 500;
  3207. if (reForm.ShowDialog() == DialogResult.OK)
  3208. {
  3209. DataTable retData = reForm.ReturnData;
  3210. foreach (DataRow dr in retData.Rows)
  3211. {
  3212. buttonEdit.Text = dr["检验项代码"].ToString();
  3213. gridViewCC.SetRowCellValue(gridViewCC.FocusedRowHandle, colCKGROUPDESC, dr["检验项描述"].ToString());
  3214. }
  3215. }
  3216. }
  3217. #endregion
  3218. #region 查询外观检验项目
  3219. private void WGGroupItemButtonEdit_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  3220. {
  3221. ButtonEdit btn = (ButtonEdit)sender;
  3222. string sql = "";
  3223. DataTable data = null;
  3224. ButtonEdit buttonEdit = (sender as ButtonEdit);
  3225. sql = @"select CKGROUP as 检验项代码,CKGROUPDNAME as 检验项名称,CKGROUPDESC as 检验项描述
  3226. from ICSOQCCKGROUP where ISREF='是'";
  3227. sql = string.Format(sql);
  3228. data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  3229. FormDataRefer reForm = new FormDataRefer();
  3230. reForm.FormTitle = "检验项目信息";
  3231. DataTable menuData = data;
  3232. reForm.DataSource = menuData;
  3233. reForm.MSelectFlag = false;
  3234. reForm.RowIndexWidth = 35;
  3235. reForm.FormWidth = 500;
  3236. reForm.FormHeight = 500;
  3237. if (reForm.ShowDialog() == DialogResult.OK)
  3238. {
  3239. DataTable retData = reForm.ReturnData;
  3240. foreach (DataRow dr in retData.Rows)
  3241. {
  3242. buttonEdit.Text = dr["检验项代码"].ToString();
  3243. gridView2.SetRowCellValue(gridView2.FocusedRowHandle, colCKGROUPDESC1, dr["检验项描述"].ToString());
  3244. }
  3245. }
  3246. }
  3247. #endregion
  3248. private void btnAddRow2_Click(object sender, EventArgs e)
  3249. {
  3250. string message = txtMessage.Text.Trim();
  3251. if (message != "")
  3252. {
  3253. if (!message.Contains("保存成功"))
  3254. {
  3255. if (!message.Contains("该工序"))
  3256. {
  3257. DataTable dt = this.gridControl2.DataSource as DataTable;
  3258. DataRow dr = dt.NewRow();
  3259. dr["id"] = AppConfig.GetGuid();
  3260. dt.Rows.Add(dr);
  3261. }
  3262. }
  3263. }
  3264. }
  3265. private void btnDelRow2_Click(object sender, EventArgs e)
  3266. {
  3267. gridView2.PostEditor();
  3268. this.Validate();
  3269. if (gridView2.RowCount == 0)
  3270. return;
  3271. if (gridView2.FocusedRowHandle < 0)
  3272. return;
  3273. gridView2.DeleteRow(gridView2.FocusedRowHandle);
  3274. CheckResult1();
  3275. }
  3276. private void CheckResult1()
  3277. {
  3278. //重新判断检验结果
  3279. bool istrue = true;
  3280. for (int k = 0; k < gridView2.RowCount; k++)
  3281. {
  3282. string OK = gridView2.GetRowCellValue(k, colOK).ToString();
  3283. string NG = gridView2.GetRowCellValue(k, colNotOK).ToString();
  3284. if (!string.IsNullOrEmpty(OK) && OK == "True")
  3285. {
  3286. istrue = true;
  3287. }
  3288. else if (!string.IsNullOrEmpty(NG) && NG == "True")
  3289. {
  3290. istrue = false;
  3291. break;
  3292. }
  3293. }
  3294. if (istrue)
  3295. {
  3296. this.txtWGResult.Text = "OK";
  3297. this.txtWGResult.BackColor = Color.Blue;
  3298. }
  3299. else
  3300. {
  3301. this.txtWGResult.Text = "NG";
  3302. this.txtWGResult.BackColor = Color.Red;
  3303. }
  3304. }
  3305. private void OKItemCheckEdit2_EditValueChanged(object sender, EventArgs e)
  3306. {
  3307. gridView2.SetRowCellValue(gridView2.FocusedRowHandle, colNotOK, false);
  3308. gridView2.SetRowCellValue(gridView2.FocusedRowHandle, colOK, true);
  3309. }
  3310. private void NotOKItemCheckEdit2_EditValueChanged(object sender, EventArgs e)
  3311. {
  3312. gridView2.SetRowCellValue(gridView2.FocusedRowHandle, colOK, false);
  3313. gridView2.SetRowCellValue(gridView2.FocusedRowHandle, colNotOK, true);
  3314. }
  3315. private void LoadGroup()
  3316. {
  3317. try
  3318. {
  3319. string sql = @"select CKGROUP as 检验项代码,CKGROUPDNAME as 检验项名称,CKGROUPDESC as 检验项描述
  3320. from ICSOQCCKGROUP where ISREF='是'";
  3321. sql = string.Format(sql, AppConfig.WorkPointCode);
  3322. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  3323. //尺寸检验
  3324. CCCodeGridLookUpEdit.ValueMember = "检验项代码";
  3325. CCCodeGridLookUpEdit.DisplayMember = "检验项代码";
  3326. CCCodeGridLookUpEdit.DataSource = dt;
  3327. CCCodeGridLookUpEdit.NullText = "";//空时的值
  3328. CCCodeGridLookUpEdit.ImmediatePopup = true;//输入值是否马上弹出窗体
  3329. CCCodeGridLookUpEdit.ValidateOnEnterKey = true;//回车确认
  3330. CCCodeGridLookUpEdit.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
  3331. CCCodeGridLookUpEdit.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
  3332. CCCodeGridLookUpEdit.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
  3333. CCDescGridLookUpEdit.ValueMember = "检验项描述";
  3334. CCDescGridLookUpEdit.DisplayMember = "检验项描述";
  3335. CCDescGridLookUpEdit.DataSource = dt;
  3336. CCDescGridLookUpEdit.NullText = "";//空时的值
  3337. CCDescGridLookUpEdit.ImmediatePopup = true;//输入值是否马上弹出窗体
  3338. CCDescGridLookUpEdit.ValidateOnEnterKey = true;//回车确认
  3339. CCDescGridLookUpEdit.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
  3340. CCDescGridLookUpEdit.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
  3341. CCDescGridLookUpEdit.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
  3342. //外观检验
  3343. WGCodeGridLookUpEdit.ValueMember = "检验项代码";
  3344. WGCodeGridLookUpEdit.DisplayMember = "检验项代码";
  3345. WGCodeGridLookUpEdit.DataSource = dt;
  3346. WGCodeGridLookUpEdit.NullText = "";//空时的值
  3347. WGCodeGridLookUpEdit.ImmediatePopup = true;//输入值是否马上弹出窗体
  3348. WGCodeGridLookUpEdit.ValidateOnEnterKey = true;//回车确认
  3349. WGCodeGridLookUpEdit.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
  3350. WGCodeGridLookUpEdit.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
  3351. WGCodeGridLookUpEdit.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
  3352. WGDescGridLookUpEdit.ValueMember = "检验项描述";
  3353. WGDescGridLookUpEdit.DisplayMember = "检验项描述";
  3354. WGDescGridLookUpEdit.DataSource = dt;
  3355. WGDescGridLookUpEdit.NullText = "";//空时的值
  3356. WGDescGridLookUpEdit.ImmediatePopup = true;//输入值是否马上弹出窗体
  3357. WGDescGridLookUpEdit.ValidateOnEnterKey = true;//回车确认
  3358. WGDescGridLookUpEdit.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
  3359. WGDescGridLookUpEdit.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
  3360. WGDescGridLookUpEdit.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
  3361. }
  3362. catch (Exception ex)
  3363. {
  3364. SetMessage(ex.Message, Color.Red);
  3365. }
  3366. }
  3367. private void CCGroupGridLookUpEdit_EditValueChanged(object sender, EventArgs e)
  3368. {
  3369. GridLookUpEdit LookupEdit = sender as GridLookUpEdit;
  3370. DataRowView SelectedDataRow = (DataRowView)LookupEdit.GetSelectedDataRow();
  3371. if (string.IsNullOrWhiteSpace(LookupEdit.EditValue.ToString()))
  3372. {
  3373. }
  3374. else
  3375. {
  3376. gridViewCC.SetFocusedRowCellValue("CKGROUPCode", SelectedDataRow["检验项代码"].ToString());
  3377. }
  3378. }
  3379. private void WGGroupGridLookUpEdit_EditValueChanged(object sender, EventArgs e)
  3380. {
  3381. GridLookUpEdit LookupEdit = sender as GridLookUpEdit;
  3382. DataRowView SelectedDataRow = (DataRowView)LookupEdit.GetSelectedDataRow();
  3383. if (string.IsNullOrWhiteSpace(LookupEdit.EditValue.ToString()))
  3384. {
  3385. }
  3386. else
  3387. {
  3388. gridView2.SetFocusedRowCellValue("CKGROUPCode1", SelectedDataRow["检验项代码"].ToString());
  3389. }
  3390. }
  3391. private void gridViewCC_CellValueChanging(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
  3392. {
  3393. }
  3394. private void CCCodeGridLookUpEdit_EditValueChanged(object sender, EventArgs e)
  3395. {
  3396. GridLookUpEdit LookupEdit = sender as GridLookUpEdit;
  3397. DataRowView SelectedDataRow = (DataRowView)LookupEdit.GetSelectedDataRow();
  3398. if (string.IsNullOrWhiteSpace(LookupEdit.EditValue.ToString()))
  3399. {
  3400. }
  3401. else
  3402. {
  3403. gridViewCC.SetFocusedRowCellValue("CKGROUPDESC", SelectedDataRow["检验项描述"].ToString());
  3404. }
  3405. }
  3406. private void WGCodeGridLookUpEdit_EditValueChanged(object sender, EventArgs e)
  3407. {
  3408. GridLookUpEdit LookupEdit = sender as GridLookUpEdit;
  3409. DataRowView SelectedDataRow = (DataRowView)LookupEdit.GetSelectedDataRow();
  3410. if (string.IsNullOrWhiteSpace(LookupEdit.EditValue.ToString()))
  3411. {
  3412. }
  3413. else
  3414. {
  3415. gridView2.SetFocusedRowCellValue("CKGROUPDESC1", SelectedDataRow["检验项描述"].ToString());
  3416. }
  3417. }
  3418. }
  3419. }