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

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