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

4771 lines
204 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 System.Text.RegularExpressions;
  27. using Newtonsoft.Json;
  28. using System.Net;
  29. using System.Configuration;
  30. using Newtonsoft.Json.Linq;
  31. namespace ICSSoft.Frame.APP
  32. {
  33. public partial class FormICSProductionReport : DevExpress.XtraEditors.XtraForm
  34. {
  35. private FramDataContext _domainDataProvider = null;
  36. private string sqltxt = "";
  37. private string sqlconn = "";
  38. //String guid = AppConfig.GetGuid();
  39. private DataTable dataSource = null;
  40. //string ID = "";
  41. string ItemCode = string.Empty;
  42. string ItemName = string.Empty; string INVDESC = string.Empty; string RCVCode = string.Empty; string LotNo = string.Empty;
  43. Decimal TotalQty = 0;
  44. Decimal YLOTQTY = 0; Decimal UYLOTQTY = 0;
  45. string OPCode = string.Empty;
  46. string lotno = "";
  47. private const string PAUSE = "暂停";
  48. private const string CANCELPAUSE = "取消暂停";
  49. private const string START = "开工";
  50. private const string END = "完工";
  51. private string Status;
  52. private string routeCode;
  53. private string EQPType;
  54. private string partCode = "";
  55. private string partSpec = "";
  56. string RouteCode = string.Empty;
  57. private const string STARTSTATUS = "COLLECT_BEGIN";
  58. private const string ENDSTATUS = "COLLECT_END";
  59. String guid = "";
  60. FormICSECGUIModel ecgUIModel;
  61. int Flag;
  62. DataTable palINVdt = new DataTable();
  63. //DataTable grvdt = new DataTable();
  64. //DataTable connectgrvdt = new DataTable();
  65. int MainKniefQTY = 0;
  66. string MOSEQ = "";
  67. bool InvControl = false;
  68. bool MouldContorl = false;
  69. string OPCodeCurrent = "";
  70. string OPCodeNext = "";
  71. string opseq="";
  72. DataTable dataUpOPDetail = new DataTable();
  73. #region 构造函数
  74. public FormICSProductionReport()
  75. {
  76. InitializeComponent();
  77. this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  78. this.WindowState = FormWindowState.Maximized;
  79. initType();
  80. this.txtLotNo.Focus();
  81. panelMap.Dock = DockStyle.Fill;
  82. panelOP.Dock = DockStyle.Fill;
  83. //panel8WebMap.Dock = DockStyle.Fill;
  84. this.label23.Visible = false;
  85. panelMap.BringToFront();
  86. //panel8WebMap.BringToFront();
  87. this.txtReturnMateralSave.Visible = false;
  88. labelControl1.Visible = false;
  89. txtSBItemCode.Visible = false;
  90. labelControl2.Visible = false;
  91. txtSBItemCodeQty.Visible = false;
  92. }
  93. #endregion
  94. #region 构造函数
  95. public FormICSProductionReport(string _ItemCode, string _ItemName, string _INVDESC, string _RCVCode, string _LotNo, Decimal _TotalQty, Decimal _YLOTQTY, Decimal _UYLOTQTY)
  96. {
  97. InitializeComponent();
  98. this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  99. this.WindowState = FormWindowState.Maximized;
  100. //txtMOCode.Text = ItemCode = _ItemCode;
  101. //txtItemName.Text = ItemName = _ItemName;
  102. txtLotNo.Text = LotNo = _LotNo;
  103. //txtItemINVDESC.Text = INVDESC = _INVDESC;
  104. //txtTotalQty.Text = _TotalQty.ToString();
  105. TotalQty = _TotalQty;
  106. RCVCode = _RCVCode;
  107. Decimal YLOTQTY = _YLOTQTY; Decimal UYLOTQTY = _UYLOTQTY;
  108. //init();
  109. BandData(ItemCode, LotNo, OPCode);
  110. }
  111. #endregion
  112. #region 初始化查询条件
  113. private void init()
  114. {
  115. #region
  116. string sql = @"SELECT a.CKListCode ,
  117. b.CKITENAME ,
  118. a.CKGROUP,
  119. a.CKITEMCODE,
  120. a.VALUEMAX ,
  121. a.VALUEMIN ,
  122. a.UNIT,
  123. a.AQL,
  124. a.InspectionStandard, IQC.S1,IQC.S2,IQC.S3,IQC.S4,IQC.S5,IQC.S6,IQC.S7,IQC.S8,IQC.S9,IQC.S10,IQC.CCResult
  125. FROM ICSOQCCKGROUP2LIST a
  126. LEFT JOIN ICSOQCCKLIST b ON a.CKListCode = b.CKITEMCODE
  127. LEFT JOIN ICSOQCCKGROUP2LISTCheckResult IQC ON IQC.CKListCode=a.CKListCode AND a.CKITEMCODE =IQC.CKITEMCODE AND IQC.RCVCode='" + RCVCode + "' AND IQC.LotNo='" + LotNo + "' AND IQC.VALUEMAX=A.VALUEMAX AND IQC.VALUEMIN=A.VALUEMIN " +
  128. " WHERE a.CKITEMCODE = '" + ItemCode + "' AND IQC.CheckoutAttribute = '量化'";//AND a.IsUse = '1'
  129. sql = string.Format(sql, AppConfig.WorkPointCode);
  130. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  131. if (dt != null && dt.Rows.Count > 0)
  132. {
  133. if (dt != null && dt.Rows.Count > 0)
  134. {
  135. bool istrue = false;
  136. foreach (DataRow item in dt.Rows)
  137. {
  138. string resultCC = item["CCResult"].ToString();
  139. if (resultCC == "NG")
  140. {
  141. istrue = false;
  142. break;
  143. }
  144. if (resultCC == "OK")
  145. {
  146. istrue = true;
  147. }
  148. }
  149. }
  150. }
  151. else
  152. {
  153. string sqlUn = @"SELECT a.CKListCode ,
  154. b.CKITENAME ,
  155. a.CKGROUP,
  156. a.CKITEMCODE,
  157. a.VALUEMAX ,
  158. a.VALUEMIN ,
  159. a.UNIT,
  160. a.AQL,
  161. a.InspectionStandard,'' S1,'' S2,'' S3,'' S4,'' S5,'' S6,'' S7,'' S8,'' S9,'' S10
  162. FROM ICSOQCCKGROUP2LIST a
  163. LEFT JOIN ICSOQCCKLIST b ON a.CKListCode = b.CKITEMCODE
  164. WHERE a.CKITEMCODE = '" + ItemCode + "' AND a.IsUse = '1' AND a.CheckoutAttribute = ''";
  165. sqlUn = string.Format(sqlUn, AppConfig.WorkPointCode);
  166. DataTable dtun = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sqlUn).Tables[0];
  167. //gridControlcc.DataSource = dtun;
  168. }
  169. #endregion
  170. string sql2 = @"SELECT a.CKListCode CKListCode1 ,
  171. b.CKITENAME CKITENAME1 ,
  172. a.CKGROUP,
  173. a.CKITEMCODE,
  174. a.VALUEMAX ,
  175. a.VALUEMIN ,
  176. a.UNIT,
  177. a.AQL ,
  178. a.InspectionStandard ,IQC.Qualified,IQC.UnQualified,IQC.WGResult
  179. FROM ICSOQCCKGROUP2LIST a
  180. LEFT JOIN ICSOQCCKLIST b ON a.CKListCode = b.CKITEMCODE
  181. LEFT JOIN ICSOQCCKGROUP2LISTCheckResult IQC ON IQC.CKListCode=a.CKListCode AND a.CKITEMCODE =IQC.CKITEMCODE AND IQC.RCVCode='" + RCVCode + "' AND IQC.LotNo='" + LotNo + "' AND A.AQL=IQC.AQL AND A.InspectionStandard=IQC.InspectionStandard " +
  182. " WHERE a.CKITEMCODE = '" + ItemCode + "' AND a.IsUse = '1' AND IQC.CheckoutAttribute = '外观'";
  183. sql2 = string.Format(sql2, AppConfig.WorkPointCode);
  184. DataTable dt2 = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql2).Tables[0];
  185. if (dt2 != null && dt2.Rows.Count > 0)
  186. {
  187. //gridControl1.DataSource = dt2;
  188. if (dt2 != null && dt2.Rows.Count > 0)
  189. {
  190. bool istrue = false;
  191. foreach (DataRow item in dt2.Rows)
  192. {
  193. string resultCC = item["WGResult"].ToString();
  194. if (resultCC == "NG")
  195. {
  196. istrue = false;
  197. break;
  198. }
  199. if (resultCC == "OK")
  200. {
  201. istrue = true;
  202. }
  203. }
  204. }
  205. }
  206. else
  207. {
  208. string sql2Un = @"SELECT a.CKListCode CKListCode1 ,
  209. b.CKITENAME CKITENAME1 ,
  210. a.CKGROUP,
  211. a.CKITEMCODE,
  212. a.VALUEMAX ,
  213. a.VALUEMIN ,
  214. a.UNIT,
  215. a.AQL ,
  216. a.InspectionStandard ,'' Qualified,'' UnQualified
  217. FROM ICSOQCCKGROUP2LIST a
  218. LEFT JOIN ICSOQCCKLIST b ON a.CKListCode = b.CKITEMCODE
  219. WHERE a.CKITEMCODE = '" + ItemCode + "' AND a.IsUse = '1' AND a.CheckoutAttribute = ''";
  220. sql2Un = string.Format(sql2Un, AppConfig.WorkPointCode);
  221. DataTable dt2Un = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql2Un).Tables[0];
  222. //gridControl1.DataSource = dt2Un;
  223. }
  224. }
  225. private void initType()
  226. {
  227. #region 暂停
  228. string sql2 = @"SELECT DISTINCT EnumValue [暂停类型编码] ,EnumText [暂停类型] FROM Sys_EnumValues WHERE EnumKey='00022'
  229. UNION SELECT '' [],'' [] FROM Sys_EnumValues ";
  230. sql2 = string.Format(sql2, AppConfig.WorkPointCode);
  231. DataTable dt2 = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql2).Tables[0];
  232. txtStopType.Properties.ValueMember = "暂停类型";
  233. txtStopType.Properties.DisplayMember = "暂停类型";
  234. txtStopType.Properties.DataSource = dt2;
  235. txtStopType.Properties.NullText = "";//空时的值
  236. txtStopType.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
  237. txtStopType.Properties.ValidateOnEnterKey = true;//回车确认
  238. txtStopType.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
  239. txtStopType.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
  240. //自适应宽度
  241. txtStopType.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
  242. #endregion
  243. //this.txtLotNo.SelectAll();
  244. }
  245. private void init_()
  246. {
  247. #region
  248. string sql = @"SELECT a.CKListCode ,
  249. b.CKITENAME ,
  250. a.CKGROUP,
  251. a.CKITEMCODE,
  252. a.VALUEMAX ,
  253. a.VALUEMIN ,
  254. a.UNIT,
  255. a.AQL,
  256. a.InspectionStandard
  257. FROM ICSOQCCKGROUP2LIST a
  258. LEFT JOIN ICSOQCCKLIST b ON a.CKListCode = b.CKITEMCODE
  259. WHERE a.CKITEMCODE = '" + ItemCode + "' AND a.IsUse = '1' AND a.CheckoutAttribute = ''";
  260. sql = string.Format(sql, AppConfig.WorkPointCode);
  261. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  262. //gridControlcc.DataSource = dt;
  263. #endregion
  264. string sql2 = @"SELECT a.CKListCode CKListCode1 ,
  265. b.CKITENAME CKITENAME1 ,
  266. a.CKGROUP,
  267. a.CKITEMCODE,
  268. a.VALUEMAX ,
  269. a.VALUEMIN ,
  270. a.UNIT,
  271. a.AQL ,
  272. a.InspectionStandard
  273. FROM ICSOQCCKGROUP2LIST a
  274. LEFT JOIN ICSOQCCKLIST b ON a.CKListCode = b.CKITEMCODE
  275. WHERE a.CKITEMCODE = '" + ItemCode + "' AND a.IsUse = '1' AND a.CheckoutAttribute = ''";
  276. sql2 = string.Format(sql2, AppConfig.WorkPointCode);
  277. DataTable dt2 = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql2).Tables[0];
  278. //gridControl1.DataSource = dt2;
  279. }
  280. #endregion
  281. #region 根据存货编码查询列表信息
  282. private void BandData(string itemCode, string LotNo, string OPCode)
  283. {
  284. try
  285. {
  286. string sql = @"SELECT EnumName FROM Sys_EnumKey WHERE EnumKey='00006'";
  287. //sql = string.Format(sql, itemCode);
  288. string connectionString = AppConfig.FrameConnectString; // AppConfig.GetDataBaseConnectStringByKey("[DB.PLM]");
  289. if (string.IsNullOrWhiteSpace(connectionString))
  290. return;
  291. object name = DBHelper.ExecuteScalar(connectionString, CommandType.Text, sql);
  292. if (name == null || string.IsNullOrWhiteSpace(name.ToString()))
  293. return;
  294. //string fileName = name.ToString() + itemCode + "\\" + RouteCode + "\\" + itemCode + OpCode + ".pdf";
  295. string fileName = name.ToString() + itemCode + "\\" + itemCode + LotNo + OPCode + ".pdf";
  296. if (!string.IsNullOrEmpty(fileName))
  297. {
  298. axAcroPDF.LoadFile(fileName);
  299. axAcroPDF.setShowToolbar(false);
  300. axAcroPDF.setShowScrollbars(false);
  301. axAcroPDF.setPageMode("thumbs");
  302. axAcroPDF.setLayoutMode("SinglePage");
  303. axAcroPDF.setView("Fit");
  304. axAcroPDF.Show();
  305. }
  306. }
  307. catch (Exception ex)
  308. {
  309. MessageBox.Show(ex.Message);
  310. }
  311. }
  312. #endregion
  313. #region 操作权限
  314. public DataTable RightOfExute()
  315. {
  316. DataTable rData = new DataTable();
  317. rData.Columns.Add("BtnName");
  318. rData.Columns.Add("ActionName");
  319. //查看权限(必须有)
  320. DataRow seeRow = rData.NewRow();
  321. seeRow["BtnName"] = "see";
  322. seeRow["ActionName"] = "查看";
  323. rData.Rows.Add(seeRow);
  324. List<Control> ControlList = new List<Control>();
  325. //ControlList.Add(simpleButton2);
  326. //ControlList.Add(simpleButton3);
  327. //ControlList.Add(btnOutPut);
  328. foreach (Control ctr in ControlList)
  329. {
  330. if (ctr.GetType() == typeof(SimpleButton))
  331. {
  332. DataRow dr = rData.NewRow();
  333. dr["BtnName"] = ctr.Name;
  334. dr["ActionName"] = ctr.Text;
  335. rData.Rows.Add(dr);
  336. }
  337. }
  338. rData.AcceptChanges();
  339. return rData;
  340. }
  341. public DataTable RightOfData()// 数据权限
  342. {
  343. DataTable rData = new DataTable();
  344. rData.Columns.Add("BodyName");
  345. rData.Columns.Add("ControlName");
  346. rData.Columns.Add("ControlCaption");
  347. rData.AcceptChanges();
  348. return rData;
  349. }
  350. #endregion
  351. #region 退出
  352. private void btnClose_Click(object sender, EventArgs e)
  353. {
  354. AppConfig.CloseFormShow(this.Text);
  355. this.Close();
  356. }
  357. private void btnExit_Click(object sender, EventArgs e)
  358. {
  359. AppConfig.CloseFormShow(this.Text);
  360. this.Close();
  361. }
  362. #endregion
  363. #region 移动窗体
  364. private const int WM_NCHITTEST = 0x84;
  365. private const int HTCLIENT = 0x1;
  366. private const int HTCAPTION = 0x2;
  367. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  368. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  369. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  370. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  371. //重写窗体,使窗体可以不通过自带标题栏实现移动
  372. protected override void WndProc(ref Message m)
  373. {
  374. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  375. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  376. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  377. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  378. switch (m.Msg)
  379. {
  380. case WM_NCHITTEST:
  381. base.WndProc(ref m);
  382. if ((int)m.Result == HTCLIENT)
  383. m.Result = (IntPtr)HTCAPTION;
  384. return;
  385. }
  386. //拦截双击标题栏、移动窗体的系统消息
  387. if (m.Msg != 0xA3)
  388. {
  389. base.WndProc(ref m);
  390. }
  391. }
  392. #endregion
  393. #region 列表
  394. private void grvDetail_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
  395. {
  396. if (e.Info.IsRowIndicator && e.RowHandle >= 0)
  397. e.Info.DisplayText = (e.RowHandle + 1).ToString();
  398. }
  399. #endregion
  400. #region 过滤
  401. //private string tempTableName = "";
  402. //private void btnFilter_Click(object sender, EventArgs e)
  403. //{
  404. // FormFilter filter = new FormFilter(AppConfig.GetSourceId(this.Tag.ToString(), btnConfig.Name));
  405. // filter.OldTempTableName = tempTableName;
  406. // if (filter.ShowDialog() == DialogResult.OK)
  407. // {
  408. // DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在查找...请稍等...");
  409. // try
  410. // {
  411. // _wait.Show();
  412. // tempTableName = filter.NewTempTableName;
  413. // sqltxt = filter.SqlText;
  414. // sqlconn = filter.FilterConnectString;
  415. // dataSource = filter.FilterData.Tables[0];
  416. // grdDetail.DataSource = dataSource;
  417. // grvDetail.BestFitColumns();
  418. // rptPage.RecordNum = dataSource.Rows.Count;
  419. // rptPage.PageSize = 499;
  420. // rptPage.PageIndex = 1;
  421. // rptPage.ReLoad();
  422. // rptPage.PageSize = 500;
  423. // rptPage.PageIndex = 1;
  424. // rptPage.ReLoad();
  425. // _wait.Close();
  426. // }
  427. // catch (Exception ex)
  428. // {
  429. // MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  430. // _wait.Close();
  431. // }
  432. // }
  433. //}
  434. #endregion
  435. #region 绑定数据源
  436. private void btnConfig_Click(object sender, EventArgs e)
  437. {
  438. //if (AppConfig.UserCode.ToLower() != "demo")
  439. //{
  440. // ICSBaseSimpleCode.AppshowMessageBox("您没有权限设置数据源,请联系软件提供商!");
  441. // return;
  442. //}
  443. //FormDataSource fdata = new FormDataSource(AppConfig.GetMenuId(this.Tag.ToString()), btnConfig.Name);
  444. //fdata.ShowDialog();
  445. }
  446. #endregion
  447. #region 分页
  448. private void rptPage_PageIndexChanged(object Sender, EventArgs e)
  449. {
  450. //DataTable data = AppConfig.GetPageData(dataSource, rptPage.PageIndex, rptPage.PageSize).Copy();
  451. ////DataTable data = AppConfig.GetPageDataByDb(tempTableName, "pagerowindex", rptPage.PageSize, rptPage.PageIndex, dataSource.Rows.Count);
  452. //grdDetail.DataSource = data;
  453. }
  454. #endregion
  455. #region 过滤方法
  456. private void FormContainerManager_FormClosing(object sender, FormClosingEventArgs e)
  457. {
  458. //AppConfig.DropTemTable(tempTableName);
  459. }
  460. #endregion
  461. #region 全选
  462. private void btnSelectAll_Click(object sender, EventArgs e)
  463. {
  464. //grvDetail.PostEditor();
  465. //this.Validate();
  466. //for (int i = 0; i < grvDetail.RowCount; i++)
  467. //{
  468. // grvDetail.SetRowCellValue(i, colisSelect, "Y");
  469. //}
  470. }
  471. #endregion
  472. #region 全消
  473. private void btnCancelAll_Click(object sender, EventArgs e)
  474. {
  475. //grvDetail.PostEditor();
  476. //this.Validate();
  477. //for (int i = 0; i < grvDetail.RowCount; i++)
  478. //{
  479. // grvDetail.SetRowCellValue(i, colisSelect, "");
  480. //}
  481. }
  482. #endregion
  483. #region 刷新
  484. private void btnFalsh_Click(object sender, EventArgs e)
  485. {
  486. //FormICSCREW_Load(null, null);
  487. //txtMOCode.Text = ItemCode;
  488. //txtItemName.Text = ItemName;
  489. txtLotNo.Text = LotNo;
  490. //txtItemINVDESC.Text = INVDESC;
  491. //txtTotalQty.Text = TotalQty.ToString();
  492. //init_();
  493. }
  494. #endregion
  495. //private void ICSItemLot_FormClosing(object sender, FormClosingEventArgs e)
  496. //{
  497. // AppConfig.DropTemTable(tempTableName);
  498. //}
  499. #region 页面加载
  500. private void FormICSCREW_Load(object sender, EventArgs e)
  501. {
  502. //btnFilter_Click(sender, e);
  503. //button1.Enabled = false;
  504. }
  505. #endregion
  506. #region 导入模板下载
  507. #endregion
  508. #region 导入
  509. #endregion
  510. #region 保存
  511. #endregion
  512. private bool CheckIsDecmil(string KeyValue)
  513. {
  514. try
  515. {
  516. Decimal.Parse(KeyValue);
  517. return true;
  518. }
  519. catch (Exception ex)
  520. {
  521. return false;
  522. }
  523. }
  524. // private void txtUserCode_TextChanged(object sender, EventArgs e)
  525. // {
  526. // #region
  527. // string chksql = @"SELECT UserCode,UserName,StartFlag FROM Sys_User WHERE UserCode='{0}' AND WorkPointCode='{1}' and StartFlag='1' ";
  528. // chksql = string.Format(chksql, this.txtUserCode.Text.Trim(), AppConfig.WorkPointCode);
  529. // DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, chksql).Tables[0];
  530. // if (dt.Rows.Count == 0)
  531. // {
  532. // ICSBaseSimpleCode.AppshowMessageBox("该人员不存在或者账号已经停用!!");
  533. // return;
  534. // }
  535. // //else
  536. // //{
  537. // // if (dt.Rows[0]["EATTRIBUTE6"].ToString() == "")
  538. // // {
  539. // // ICSBaseSimpleCode.AppshowMessageBox("产品跟踪单号未绑定零件号,请先绑定再发料!!");
  540. // // return;
  541. // // }
  542. // //}
  543. // #endregion
  544. // string LotNo = txtLotNo.Text.Trim();
  545. // string sql = @"SELECT DISTINCT
  546. // a.ID,
  547. // a.LOTNO,
  548. // a.LOTQTY,
  549. // b.MOCODE,
  550. // b.ITEMCODE,
  551. // a.VenderLotNO,
  552. // c.INVNAME AS ItemName,
  553. // d.LOTStatus,
  554. // CASE d.CollectStatus WHEN 'COLLECT_BEGIN' THEN 'WG' ELSE 'KG' END AS Status
  555. // FROM
  556. // ICSITEMLot a WITH (nolock)
  557. // LEFT JOIN ICSMO b WITH (nolock) ON a.TransNO = b.MOCODE AND a.TransLine=b.MOSEQ
  558. // LEFT JOIN ICSINVENTORY c WITH (nolock) ON b.ITEMCODE = c.INVCODE
  559. // LEFT JOIN ICSLOTSIMULATION d WITH(nolock) ON a.LOTNO = d.LOTNO
  560. // WHERE
  561. // a.LOTNO = '{0}'";
  562. // sql = string.Format(sql, LotNo);
  563. // DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  564. // if (data.Rows.Count > 0)
  565. // {
  566. // foreach (DataRow dr in data.Rows)
  567. // {
  568. // txtLotNo.Text = dr["LOTNO"].ToString();
  569. // txtItemCode.Text = dr["ITEMCODE"].ToString();
  570. // txtItemName.Text = dr["ItemName"].ToString();
  571. // }
  572. // }
  573. // }
  574. // private void txtLotNo_TextChanged(object sender, EventArgs e)
  575. // {
  576. // #region
  577. // string chksql = @"select LotNO ,b.ISSMT from ICSITEMLot a
  578. // LEFT JOIN ICSINVENTORY b ON a.ItemCODE=b.INVCODE
  579. // where LotNO='{0}' AND a.WorkPoint='{1}'";
  580. // chksql = string.Format(chksql, txtLotNo.Text.Trim(), AppConfig.WorkPointCode);
  581. // DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, chksql).Tables[0];
  582. // if (dt.Rows.Count == 0)
  583. // {
  584. // ICSBaseSimpleCode.AppshowMessageBox("产品跟踪单号不存在!!");
  585. // return;
  586. // }
  587. // else
  588. // {
  589. // if (dt.Rows[0]["LotNO"].ToString() == "")
  590. // {
  591. // ICSBaseSimpleCode.AppshowMessageBox("产品跟踪单号未绑定零件号,请先绑定再发料!!");
  592. // return;
  593. // }
  594. // if (dt.Rows[0]["ISSMT"].ToString() == "1")
  595. // {
  596. // ICSBaseSimpleCode.AppshowMessageBox("该批次产品只能单件报工!!");
  597. // return;
  598. // }
  599. // }
  600. // #endregion
  601. // string LotNo = txtLotNo.Text.Trim();
  602. // string sql = @"SELECT DISTINCT
  603. // a.ID,
  604. // a.LOTNO,
  605. // a.LOTQTY,
  606. // b.MOCODE,
  607. // b.ITEMCODE,
  608. // a.VenderLotNO,
  609. // c.INVNAME AS ItemName,
  610. // d.LOTStatus,
  611. // CASE d.CollectStatus WHEN 'COLLECT_BEGIN' THEN 'WG' ELSE 'KG' END AS Status
  612. // FROM
  613. // ICSITEMLot a WITH (nolock)
  614. // LEFT JOIN ICSMO b WITH (nolock) ON a.TransNO = b.MOCODE AND a.TransLine=b.MOSEQ
  615. // LEFT JOIN ICSINVENTORY c WITH (nolock) ON b.ITEMCODE = c.INVCODE
  616. // LEFT JOIN ICSLOTSIMULATION d WITH(nolock) ON a.LOTNO = d.LOTNO
  617. // WHERE
  618. // a.LOTNO = '{0}'";
  619. // sql = string.Format(sql, LotNo);
  620. // DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  621. // if (data.Rows.Count > 0)
  622. // {
  623. // foreach (DataRow dr in data.Rows)
  624. // {
  625. // txtLotNo.Text = dr["LOTNO"].ToString();
  626. // txtItemCode.Text = dr["ITEMCODE"].ToString();
  627. // txtItemName.Text = dr["ItemName"].ToString();
  628. // txtMOCode.Text = dr["MOCODE"].ToString();
  629. // }
  630. // }
  631. // }
  632. //private void txtOPCode_TextChanged(object sender, EventArgs e)
  633. //{
  634. // OPCodeCurrent = this.txtOPCode.Text;
  635. //}
  636. //private void txtMachineCode_TextChanged(object sender, EventArgs e)
  637. //{
  638. //}
  639. private void txtLotNo_KeyPress(object sender, KeyPressEventArgs e)
  640. {
  641. try
  642. {
  643. #region`
  644. if (e.KeyChar == (char)Keys.Enter)
  645. {
  646. txtOPCode.Enabled = true;
  647. txtUserCode.ReadOnly = false;
  648. txtEQPCode.ReadOnly = false;
  649. foreach (Control control in tableLayoutPanel2.Controls)
  650. {
  651. if (control is TextBox && control.Name != "txtLotNo")
  652. {
  653. TextBox box = control as TextBox;
  654. box.Text = "";
  655. }
  656. }
  657. #region
  658. // string chksql = @"select LotNO ,a.LOTQTY,b.ISSMT from ICSITEMLot a
  659. // LEFT JOIN ICSINVENTORY b ON a.ItemCODE=b.INVCODE
  660. // where LotNO='{0}' AND a.WorkPoint='{1}'";
  661. string chksql = @"select LotNO ,a.LOTQTY,b.ISSMT from ICSITEMLot a
  662. LEFT JOIN ICSINVENTORY b ON a.MCODE=b.INVCODE
  663. where LotNO='{0}' AND a.WorkPoint='{1}'";
  664. chksql = string.Format(chksql, txtLotNo.Text.Trim(), AppConfig.WorkPointCode);
  665. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, chksql).Tables[0];
  666. if (dt.Rows.Count == 0)
  667. {
  668. ICSBaseSimpleCode.AppshowMessageBox("产品跟踪单号不存在!!");
  669. return;
  670. }
  671. else
  672. {
  673. if (dt.Rows[0]["LotNO"].ToString() == "")
  674. {
  675. ICSBaseSimpleCode.AppshowMessageBox("产品跟踪单号未绑定零件号,请先绑定再发料!!");
  676. return;
  677. }
  678. if (dt.Rows[0]["ISSMT"].ToString() == "1")
  679. {
  680. ICSBaseSimpleCode.AppshowMessageBox("该批次产品只能单件报工!!");
  681. return;
  682. }
  683. }
  684. #endregion
  685. string LotNo = txtLotNo.Text.Trim();
  686. txtLONTQty.Text = dt.Rows[0]["LOTQTY"].ToString();
  687. string sql = @"SELECT DISTINCT
  688. a.ID, a.LOTNO, b.MOPLANQTY, a.LOTQTY,d.NGQTY,D.GOODQTY, b.MOCODE,b.MOSEQ, b.ITEMCODE, a.VenderLotNO, c.INVNAME AS ItemName, d.LOTStatus,b.MOPLANQTY,a.EATTRIBUTE5,
  689. CASE d.CollectStatus WHEN 'COLLECT_BEGIN' THEN 'WG' ELSE 'KG' END AS Status
  690. FROM ICSITEMLot a WITH (nolock)
  691. LEFT JOIN ICSMO b WITH (nolock) ON a.TransNO = b.MOCODE AND a.TransLine=b.MOSEQ
  692. LEFT JOIN ICSINVENTORY c WITH (nolock) ON b.ITEMCODE = c.INVCODE
  693. LEFT JOIN ICSLOTSIMULATION d WITH(nolock) ON a.LOTNO = d.LOTNO
  694. WHERE a.LOTNO = '{0}'";
  695. sql = string.Format(sql, LotNo);
  696. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  697. string NGQTY = string.Empty;
  698. string GOODQTY = string.Empty;
  699. string MOQTY = string.Empty;
  700. Decimal _NGQTY = 0;
  701. Decimal _LOTQTY = 0;
  702. Decimal _GOODQTY = 0;
  703. Decimal _MOQTY = 0;
  704. if (data.Rows.Count > 0)
  705. {
  706. foreach (DataRow dr in data.Rows)
  707. {
  708. //新增返修条码判断逻辑
  709. txtLotNo.Text = dr["LOTNO"].ToString();
  710. txtItemCode.Text = dr["ITEMCODE"].ToString();
  711. txtItemName.Text = dr["ItemName"].ToString();
  712. this.txtMOCode.Text = dr["MOCODE"].ToString();
  713. NGQTY = dr["NGQTY"].ToString();
  714. GOODQTY = dr["GOODQTY"].ToString();
  715. this.txtMOQty.Text = dr["MOPLANQTY"].ToString();
  716. if (!string.IsNullOrWhiteSpace(GOODQTY))
  717. {
  718. _GOODQTY = Decimal.Parse(GOODQTY);
  719. }
  720. if (!string.IsNullOrWhiteSpace(NGQTY))
  721. {
  722. _NGQTY = Decimal.Parse(NGQTY);
  723. }
  724. if (!string.IsNullOrWhiteSpace(dr["LOTQTY"].ToString()))
  725. {
  726. _LOTQTY = Decimal.Parse(dr["LOTQTY"].ToString());
  727. }
  728. //this.txtLONTQty.Text = (_LOTQTY - _NGQTY - _GOODQTY).ToString();
  729. MOSEQ = dr["MOSEQ"].ToString();
  730. }
  731. lotno = this.txtLotNo.Text.Trim();
  732. ItemCode = txtItemCode.Text.Trim();
  733. txtOPCode.SelectAll();
  734. txtOPCode.Focus();
  735. //新增 自动带出当前追踪单进行中的工序
  736. string opcodenew = GetLotNoOp(lotno);
  737. if (opcodenew != "") {
  738. txtOPCode.Text = opcodenew;
  739. txtOPCode_KeyPress(null, new KeyPressEventArgs((char)Keys.Enter));
  740. if (txtMessage.ForeColor == Color.Red)
  741. return;
  742. txtUserCode.Text = AppConfig.UserCode;
  743. txtUserCode_KeyPress(null, new KeyPressEventArgs((char)Keys.Enter));
  744. if (txtMessage.ForeColor == Color.Red)
  745. return;
  746. }
  747. SetMessage("", Color.Blue);
  748. //button1.Enabled = true;
  749. }
  750. else
  751. {
  752. txtItemCode.Text = "";
  753. txtItemName.Text = "";
  754. txtLotNo.SelectAll();
  755. txtLotNo.Focus();
  756. SetMessage("产品跟踪单号不存在!", Color.Red);
  757. this.btnOPOption.Enabled = false;
  758. //button1.Enabled = false;
  759. }
  760. SetMessage("产品跟踪单扫码成功!", Color.Blue);
  761. this.btnOPOption.Enabled = true;
  762. return;
  763. }
  764. #endregion
  765. }
  766. catch (Exception ex)
  767. {
  768. SetMessage(ex.Message, Color.Red);
  769. }
  770. }
  771. private void txtOPCode_KeyPress(object sender, KeyPressEventArgs e)
  772. {
  773. try
  774. {
  775. if (e.KeyChar == (char)Keys.Enter)
  776. {
  777. string OpCode = txtOPCode.Text.Trim();
  778. OPCodeCurrent = OpCode;
  779. string LOTNO = txtLotNo.Text.Trim();
  780. string sql = @"
  781. SELECT DISTINCT
  782. a.ID,d.BeginTime,
  783. a.OPCode,
  784. a.OPDESC,d.LOTQTY, D.NGQTY,D.GOODQTY,
  785. b.RouteCode,f.OPSEQ,
  786. b.EQPCode,
  787. b.EQPName,d.LOTStatus,d.EATTRIBUTE2,
  788. CASE d.CollectStatus WHEN 'COLLECT_BEGIN' THEN 'WG' WHEN 'COLLECT_END' THEN 'KG' ELSE '' END AS Status,
  789. Type,ISNULL(b.EATTRIBUTE1,0) AS EATTRIBUTE1
  790. FROM ICSOP a WITH (nolock)
  791. LEFT JOIN ICSMO2User b WITH(nolock) ON a.OPCODE = b.OPCODE
  792. LEFT JOIN ICSLOTSIMULATION d WITH(nolock) ON b.LOTNO = d.LOTNO and b.OPCODE=d.OPCODE
  793. LEFT JOIN ICSEquipment e WITH(nolock) ON b.EQPCode=e.EQPCode
  794. LEFT JOIN ICSITEMROUTE2OPLot f ON f.lotno=b.lotno and f.OPCODE=a.OPCODE
  795. WHERE b.OPCODE = '{0}' AND b.LOTNO = '{1}'
  796. ";
  797. sql = string.Format(sql, OpCode, LOTNO);
  798. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  799. if (data.Rows.Count > 0)
  800. {
  801. foreach (DataRow dr in data.Rows)
  802. {
  803. txtOPCode.Text = dr["OPCODE"].ToString();
  804. txtOPName.Text = dr["OPDESC"].ToString();
  805. RouteCode = dr["RouteCode"].ToString();
  806. txtStopType.Text = dr["EATTRIBUTE2"].ToString();
  807. opseq = dr["OPSEQ"].ToString();
  808. //工序完成
  809. if (dr["Status"].ToString() == "KG")
  810. {
  811. string OPSEQ = dr["OPSEQ"].ToString();
  812. int _OPSEQ = Int32.Parse(OPSEQ) - 10;
  813. if (_OPSEQ == 0)
  814. {
  815. SetMessage("该工序已经完工,请扫描下道工序!", Color.Red);
  816. this.btnOPOption.Enabled = false;
  817. return;
  818. }
  819. bool isOK = CheckIsOK(_OPSEQ);
  820. if (!isOK)
  821. {
  822. SetMessage("上道工序检验结果不合格,不能开工!", Color.Red);
  823. this.btnOPOption.Enabled = false;
  824. return;
  825. }
  826. SetMessage("当前工序已经完工,请扫描下道工序!", Color.Red);
  827. this.btnOPOption.Enabled = false;
  828. return;
  829. //Decimal _LOTQTY = 0;
  830. //Decimal _GOODQTY = 0;
  831. //Decimal _NGQTY = 0;
  832. //if (!string.IsNullOrWhiteSpace(dr["LOTQTY"].ToString()))
  833. //{
  834. // _LOTQTY = Decimal.Parse(dr["LOTQTY"].ToString());
  835. //}
  836. //if (!string.IsNullOrWhiteSpace(dr["GOODQTY"].ToString()))
  837. //{
  838. // _GOODQTY = Decimal.Parse(dr["GOODQTY"].ToString());
  839. //}
  840. //if (!string.IsNullOrWhiteSpace(dr["NGQTY"].ToString()))
  841. //{
  842. // _NGQTY = Decimal.Parse(dr["NGQTY"].ToString());
  843. //}
  844. //if (_LOTQTY <= _GOODQTY + _NGQTY && _LOTQTY > 0)
  845. //{
  846. // SetMessage("当前工序所有数量已经完工,请扫描下道工序!", Color.Red);
  847. // this.btnOPOption.Enabled = false;
  848. // return;
  849. //}
  850. // string sql_ = @"SELECT DISTINCT
  851. // d.LOTQTY,
  852. // D.NGQTY,
  853. // D.GOODQTY,
  854. // a.ID,
  855. // a.OPCODE,
  856. // a.OPDESC
  857. // FROM ICSOP a WITH (nolock)
  858. // LEFT JOIN ICSMO2User b WITH (nolock) ON a.OPCODE = b.OPCODE
  859. // LEFT JOIN ICSLOTSIMULATION d WITH (nolock) ON b.LOTNO = d.LOTNO
  860. // AND b.OPCODE = d.OPCODE
  861. // LEFT JOIN ICSROUTE2OP f ON f.ROUTECODE = b.RouteCode
  862. // AND f.OPCODE = a.OPCODE
  863. // WHERE f.OPSEQ = '" + _OPSEQ + "' AND b.LOTNO = '" + LOTNO + "' AND d.CollectStatus = 'COLLECT_END' ";
  864. // DataTable _data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql_).Tables[0];
  865. // if (_data != null && _data.Rows.Count > 0)
  866. // {
  867. // //txtLONTQty.Text = _data.Rows[0]["GOODQTY"].ToString();
  868. // //txtLONTQty.Text = _data.Rows[0]["LOTQTY"].ToString();
  869. // //txtUPOPAllQty.Text = _data.Rows[0]["GOODQTY"].ToString();
  870. // }
  871. // else
  872. // {
  873. // SetMessage("上道工序还没有已经完工,请先扫描上道工序!", Color.Red);
  874. // this.btnOPOption.Enabled = false;
  875. // return;
  876. // }
  877. //this.btnOPOption.Enabled = true;
  878. }
  879. else if (dr["Status"].ToString() == "WG")
  880. {
  881. string NGQTY = dr["NGQTY"].ToString();
  882. string GOODQTY = dr["GOODQTY"].ToString();
  883. string LOTStatus = dr["LOTStatus"].ToString();
  884. if (LOTStatus == "暂停")
  885. {
  886. this.btnPauseBegin.Text = "取消暂停";
  887. }
  888. Decimal _GOODQTY = 0;
  889. Decimal _NGQTY = 0;
  890. Decimal _LOTQTY = 0;
  891. if (!string.IsNullOrWhiteSpace(GOODQTY))
  892. {
  893. _GOODQTY = Decimal.Parse(GOODQTY);
  894. }
  895. if (!string.IsNullOrWhiteSpace(NGQTY))
  896. {
  897. _NGQTY = Decimal.Parse(NGQTY);
  898. }
  899. if (!string.IsNullOrWhiteSpace(dr["LOTQTY"].ToString()))
  900. {
  901. _LOTQTY = Decimal.Parse(dr["LOTQTY"].ToString());
  902. }
  903. //this.txtLONTQty.Text = (_LOTQTY - _NGQTY - _GOODQTY).ToString();
  904. //Decimal LsaterLontQty = _LOTQTY - _NGQTY - _GOODQTY;
  905. //if (LsaterLontQty <= 0)
  906. //{
  907. // SetMessage("当前工序所有数量已经完工,请扫描下道工序!", Color.Red);
  908. // this.btnOPOption.Enabled = false;
  909. // return;
  910. //}
  911. string OPSEQ = dr["OPSEQ"].ToString();
  912. if (OPSEQ == "10")
  913. {
  914. //上工序总数
  915. //txtMOQty.Text = "";
  916. }
  917. else
  918. {
  919. int _OPSEQ = Int32.Parse(OPSEQ) - 10;
  920. string sql_ = @"SELECT sum(a.LOTQTY) FROM ICSLOTONWIP a
  921. LEFT JOIN ICSROUTE2OP b ON a.ROUTECODE=b.ROUTECODE AND a.OPCODE=b.OPCODE
  922. WHERE LOTNO='" + LOTNO + "' AND b.OPSEQ='" + _OPSEQ + "' ";
  923. DataTable _data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql_).Tables[0];
  924. if (_data != null && _data.Rows.Count > 0)
  925. {
  926. //txtMOQty.Text = _data.Rows[0][0].ToString();
  927. //this.txtLONTQty.Text = _data.Rows[0][0].ToString();
  928. }
  929. bool isOK = CheckIsOK(_OPSEQ);
  930. if (!isOK)
  931. {
  932. SetMessage("上道工序检验结果不合格,不能开工!", Color.Red);
  933. this.btnOPOption.Enabled = false;
  934. return;
  935. }
  936. }
  937. string sqlAll = @"SELECT SUM( a.GOODQTY) GOODQTY, SUM( a.NGQTY) NGQTY FROM ICSLOTONWIP a
  938. LEFT JOIN ICSROUTE2OP b ON a.ROUTECODE=b.ROUTECODE AND a.OPCODE=b.OPCODE
  939. WHERE LOTNO='" + LOTNO + "' AND b.OPCODE='" + OpCode + "' ";
  940. DataTable _dataAll = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sqlAll).Tables[0];
  941. if (_dataAll != null && _dataAll.Rows.Count > 0)
  942. {
  943. //txtThisOPOKQty.Text = _dataAll.Rows[0][0].ToString();
  944. //txtThisOPNGQty.Text = _dataAll.Rows[0][1].ToString();
  945. }
  946. }
  947. else
  948. {
  949. string OPSEQ = dr["OPSEQ"].ToString();
  950. int _OPSEQ = Int32.Parse(OPSEQ) - 10;
  951. if (_OPSEQ == 0)
  952. {
  953. SetMessage("工序扫码成功!", Color.Blue);
  954. this.btnOPOption.Enabled = true;
  955. txtUserCode.SelectAll();
  956. txtUserCode.Focus();
  957. #region 根据批批号和员工条码获取当前采集状态
  958. if (sender == null)
  959. {
  960. string statussql = @"SELECT
  961. a.ACTIONRESULT,a.UserCodeEnd,b.CollectStatus,b.MUSER,
  962. b.LOTStatus
  963. FROM ICSLOTONWIP a
  964. LEFT JOIN ICSLOTSIMULATION b ON a.LOTNO=b.LOTNO AND a.OPCODE=b.OPCODE AND a.UserCodeBegin=b.MUSER
  965. WHERE a.LOTNO = '" + txtLotNo.Text + "' AND a.OPCODE = '" + txtOPCode.Text + "' ORDER BY a.MTIME DESC ";
  966. // AND a.UserCodeBegin = '" + txtUserCode.Text + "'
  967. DataTable statusdt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, statussql).Tables[0];
  968. if (statusdt.Rows.Count == 0)
  969. {
  970. btnOPOption.Text = "开工";
  971. btnPauseBegin.Text = "暂停";
  972. }
  973. else
  974. {
  975. if (statusdt.Rows[0]["ACTIONRESULT"].ToString() == "COLLECT_BEGIN")
  976. {
  977. btnOPOption.Text = "完工";
  978. initCheck();
  979. }
  980. else
  981. {
  982. btnOPOption.Text = "开工";
  983. }
  984. if (statusdt.Rows[0]["LOTStatus"].ToString() == "暂停")
  985. {
  986. btnPauseBegin.Text = "取消暂停";
  987. }
  988. else
  989. {
  990. btnPauseBegin.Text = "暂停";
  991. }
  992. }
  993. #endregion
  994. }
  995. try
  996. {
  997. GetPLMCKDATA(ItemCode, RouteCode, opseq);
  998. }
  999. catch (Exception ex)
  1000. {
  1001. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  1002. return;
  1003. }
  1004. return;
  1005. }
  1006. bool isOK = CheckIsOK(_OPSEQ);
  1007. if (!isOK)
  1008. {
  1009. SetMessage("上道工序检验结果不合格,不能开工!", Color.Red);
  1010. this.btnOPOption.Enabled = false;
  1011. return;
  1012. }
  1013. Decimal _LOTQTY = 0;
  1014. Decimal _GOODQTY = 0;
  1015. Decimal _NGQTY = 0;
  1016. if (!string.IsNullOrWhiteSpace(dr["LOTQTY"].ToString()))
  1017. {
  1018. _LOTQTY = Decimal.Parse(dr["LOTQTY"].ToString());
  1019. }
  1020. if (!string.IsNullOrWhiteSpace(dr["GOODQTY"].ToString()))
  1021. {
  1022. _GOODQTY = Decimal.Parse(dr["GOODQTY"].ToString());
  1023. }
  1024. if (!string.IsNullOrWhiteSpace(dr["NGQTY"].ToString()))
  1025. {
  1026. _NGQTY = Decimal.Parse(dr["NGQTY"].ToString());
  1027. }
  1028. string sql_ = @"SELECT DISTINCT
  1029. d.LOTQTY,
  1030. D.NGQTY,
  1031. D.GOODQTY,
  1032. a.ID,
  1033. a.OPCODE,
  1034. a.OPDESC
  1035. FROM ICSOP a WITH (nolock)
  1036. LEFT JOIN ICSMO2User b WITH (nolock) ON a.OPCODE = b.OPCODE
  1037. LEFT JOIN ICSLOTSIMULATION d WITH (nolock) ON b.LOTNO = d.LOTNO
  1038. AND b.OPCODE = d.OPCODE
  1039. LEFT JOIN ICSROUTE2OP f ON f.ROUTECODE = b.RouteCode
  1040. AND f.OPCODE = a.OPCODE
  1041. WHERE f.OPSEQ = '" + _OPSEQ + "' AND b.LOTNO = '" + LOTNO + "' AND d.CollectStatus = 'COLLECT_END' ";
  1042. DataTable _data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql_).Tables[0];
  1043. if (_data != null && _data.Rows.Count > 0)
  1044. {
  1045. txtLONTQty.Text = _data.Rows[0]["GOODQTY"].ToString();
  1046. //txtMOQty.Text = _data.Rows[0]["GOODQTY"].ToString();
  1047. }
  1048. else
  1049. {
  1050. //20200618
  1051. //SetMessage("上道工序还没有完工,请先扫描上道工序!", Color.Red);
  1052. //this.btnOPOption.Enabled = false;
  1053. //return;
  1054. }
  1055. //if (string.IsNullOrWhiteSpace(dr["BeginTime"].ToString()))
  1056. //{
  1057. // SetMessage("工序扫码成功!", Color.Blue);
  1058. // this.btnOPOption.Enabled = true;
  1059. // txtUserCode.SelectAll();
  1060. // txtUserCode.Focus();
  1061. // //initCheck();
  1062. // return;
  1063. //}
  1064. }
  1065. }
  1066. txtUserCode.SelectAll();
  1067. txtUserCode.Focus();
  1068. SetMessage("工序扫描成功!", Color.Blue);
  1069. this.btnOPOption.Enabled = true;
  1070. IsWriteAll();
  1071. #region 根据批批号和员工条码获取当前采集状态
  1072. if (sender == null)
  1073. {
  1074. string statussql = @"SELECT
  1075. a.ACTIONRESULT,a.UserCodeEnd,b.CollectStatus,b.MUSER,
  1076. b.LOTStatus
  1077. FROM ICSLOTONWIP a
  1078. LEFT JOIN ICSLOTSIMULATION b ON a.LOTNO=b.LOTNO AND a.OPCODE=b.OPCODE AND a.UserCodeBegin=b.MUSER
  1079. WHERE a.LOTNO = '" + txtLotNo.Text + "' AND a.OPCODE = '" + txtOPCode.Text + "' ORDER BY a.MTIME DESC ";
  1080. // AND a.UserCodeBegin = '" + txtUserCode.Text + "'
  1081. DataTable statusdt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, statussql).Tables[0];
  1082. if (statusdt.Rows.Count == 0)
  1083. {
  1084. btnOPOption.Text = "开工";
  1085. btnPauseBegin.Text = "暂停";
  1086. }
  1087. else
  1088. {
  1089. if (statusdt.Rows[0]["ACTIONRESULT"].ToString() == "COLLECT_BEGIN")
  1090. {
  1091. btnOPOption.Text = "完工";
  1092. initCheck();
  1093. }
  1094. else
  1095. {
  1096. btnOPOption.Text = "开工";
  1097. }
  1098. if (statusdt.Rows[0]["LOTStatus"].ToString() == "暂停")
  1099. {
  1100. btnPauseBegin.Text = "取消暂停";
  1101. }
  1102. else
  1103. {
  1104. btnPauseBegin.Text = "暂停";
  1105. }
  1106. }
  1107. #endregion
  1108. }
  1109. try
  1110. {
  1111. GetPLMCKDATA(ItemCode, RouteCode, opseq);
  1112. }
  1113. catch (Exception ex)
  1114. {
  1115. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  1116. return;
  1117. }
  1118. //initCheck();
  1119. }
  1120. else
  1121. {
  1122. txtOPName.Text = "";
  1123. txtEQPCode.Text = "";
  1124. txtMachineName.Text = "";
  1125. txtOPCode.SelectAll();
  1126. txtOPCode.Focus();
  1127. SetMessage("该批次工序对应的派工信息不存在!", Color.Red);
  1128. this.btnOPOption.Enabled = false;
  1129. }
  1130. }
  1131. }
  1132. catch (Exception ex)
  1133. {
  1134. SetMessage(ex.Message, Color.Red);
  1135. this.btnOPOption.Enabled = false;
  1136. }
  1137. }
  1138. private void IsWriteAll()
  1139. {
  1140. if (!string.IsNullOrEmpty(txtOPName.Text) && !string.IsNullOrEmpty(txtUserName.Text) && !string.IsNullOrEmpty(txtMachineName.Text)) {
  1141. txtOPCode.Enabled = true;
  1142. txtUserCode.ReadOnly = true;
  1143. txtEQPCode.ReadOnly = true;
  1144. }
  1145. }
  1146. private void initCheck()
  1147. {
  1148. string _OQCSql = @"SELECT a.SetValueMax,a.SetValueMin,a.CKGROUPCode,b.CKGROUPDESC,b.CKGROUPDNAME,'' Remark,'' CheckResult,standvalue as standresult,CAST (ISNULL(0, 0) AS BIT) AS OK,CAST (ISNULL(0, 0) AS BIT) AS NG,ptype, a.id FROM ICSOQCCKLIST a
  1149. LEFT JOIN ICSOQCCKGROUP b ON a.CKGROUPCode=b.CKGROUP
  1150. WHERE INVCode='" + txtItemCode.Text + "' AND a.CKGROUPATTR='' and a.ISREF='是' AND a.OPCode='" + txtOPCode.Text + "' and a.CKGROUPMETH='' ";//0906
  1151. DataTable _OQCdt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, _OQCSql).Tables[0];
  1152. _OQCdt.PrimaryKey = new DataColumn[] { _OQCdt.Columns["id"] };
  1153. List<DataRow> list = _OQCdt.AsEnumerable().Where(a => Convert.ToDecimal(a["ptype"]) > 1).ToList();
  1154. if (list.Count > 0)
  1155. {
  1156. foreach (DataRow row in list)
  1157. {
  1158. int num = Convert.ToInt32(row["ptype"]);
  1159. for (int i = 0; i < num; i++)
  1160. {
  1161. DataRow newrow = _OQCdt.NewRow();
  1162. newrow["SetValueMax"] = row["SetValueMax"];
  1163. newrow["SetValueMin"] = row["SetValueMin"];
  1164. newrow["CKGROUPCode"] = row["CKGROUPCode"];
  1165. newrow["CKGROUPDESC"] = row["CKGROUPDESC"];
  1166. newrow["CKGROUPDNAME"] = row["CKGROUPDNAME"];
  1167. newrow["Remark"] = row["Remark"];
  1168. newrow["CheckResult"] = row["CheckResult"];
  1169. newrow["standresult"] = row["standresult"];
  1170. newrow["OK"] = row["OK"];
  1171. newrow["NG"] = row["NG"];
  1172. newrow["ptype"] = "1";
  1173. newrow["id"] = AppConfig.GetGuid();
  1174. _OQCdt.Rows.Add(newrow);
  1175. }
  1176. _OQCdt.Rows.Remove(row);
  1177. }
  1178. }
  1179. gridControlcc.DataSource = _OQCdt;
  1180. string _OQCWGSql = @"SELECT a.CKGROUPATTR,a.CKGROUPMETH,a.CKGROUPCode CKGROUPCode1,b.CKGROUPDESC CKGROUPDESC1,b.CKGROUPDNAME,'' AS Remark1,CAST (ISNULL(0, 0) AS BIT) AS OK ,
  1181. CAST (ISNULL(0, 0) AS BIT) AS NG,ptype,a.id FROM ICSOQCCKLIST a
  1182. LEFT JOIN ICSOQCCKGROUP b ON a.CKGROUPCode=b.CKGROUP
  1183. WHERE INVCode='" + txtItemCode.Text + "' AND a.CKGROUPATTR='' and a.ISREF='是' AND a.OPCode='" + txtOPCode.Text + "' and a.CKGROUPMETH='' ";//0906
  1184. DataTable _OQCWGdt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, _OQCWGSql).Tables[0];
  1185. _OQCWGdt.PrimaryKey = new DataColumn[] { _OQCWGdt.Columns["id"] };
  1186. list = _OQCWGdt.AsEnumerable().Where(a => Convert.ToDecimal(a["ptype"]) > 1).ToList();
  1187. if (list.Count > 0)
  1188. {
  1189. foreach (DataRow row in list)
  1190. {
  1191. int num = Convert.ToInt32(row["ptype"]);
  1192. for (int i = 0; i < num; i++)
  1193. {
  1194. DataRow newrow = _OQCWGdt.NewRow();
  1195. newrow["CKGROUPATTR"] = row["CKGROUPATTR"];
  1196. newrow["CKGROUPMETH"] = row["CKGROUPMETH"];
  1197. newrow["CKGROUPCode1"] = row["CKGROUPCode1"];
  1198. newrow["CKGROUPDESC1"] = row["CKGROUPDESC1"];
  1199. newrow["CKGROUPDNAME"] = row["CKGROUPDNAME"];
  1200. newrow["Remark1"] = row["Remark1"];
  1201. newrow["OK"] = row["OK"];
  1202. newrow["ptype"] = "1";
  1203. newrow["id"] = AppConfig.GetGuid();
  1204. _OQCWGdt.Rows.Add(newrow);
  1205. }
  1206. _OQCWGdt.Rows.Remove(row);
  1207. }
  1208. }
  1209. gridControl2.DataSource = _OQCWGdt;
  1210. }
  1211. private bool CheckIsOK(int OPSEQ)
  1212. {
  1213. bool isfalse = false;
  1214. string _OQCSql ="";
  1215. _OQCSql = @"SELECT DISTINCT ACTION FROM ICSLOTONWIP bb WITH (nolock)
  1216. LEFT JOIN ICSLOTONWIPCHECK CC ON BB.ID=CC.ONWIPID
  1217. INNER JOIN ICSITEMROUTE2OPLot a WITH (nolock) ON bb.lotno=a.lotno and bb.opcode=a.opcode
  1218. WHERE bb.LotNo='" + txtLotNo.Text + "' AND a.OPSEQ='" + OPSEQ + "' AND CC.RESULT='' ";
  1219. DataTable _OQCdt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, _OQCSql).Tables[0];
  1220. if (_OQCdt != null && _OQCdt.Rows.Count > 0)
  1221. {
  1222. isfalse = false;
  1223. //foreach (DataRow item in _OQCdt.Rows)
  1224. //{
  1225. // if (item["CCorWGResult"].ToString() == "NG")
  1226. // {
  1227. // isfalse = false;
  1228. // SetMessage("上道工序检验结果不合格,不能开工!", Color.Red);
  1229. // this.btnOPOption.Enabled = false;
  1230. // return isfalse;
  1231. // }
  1232. //}
  1233. }
  1234. else
  1235. {
  1236. isfalse = true;
  1237. }
  1238. return isfalse;
  1239. }
  1240. private void txtUserCode_KeyPress(object sender, KeyPressEventArgs e)
  1241. {
  1242. if (e.KeyChar == (char)Keys.Enter)
  1243. {
  1244. string chksql = @"SELECT UserCode,UserName,StartFlag FROM Sys_User WHERE UserCode='{0}' AND WorkPointCode='{1}' and StartFlag='1' ";
  1245. chksql = string.Format(chksql, this.txtUserCode.Text.Trim(), AppConfig.WorkPointCode);
  1246. DataTable chkdt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, chksql).Tables[0];
  1247. if (chkdt.Rows.Count == 0)
  1248. {
  1249. ICSBaseSimpleCode.AppshowMessageBox("该人员不存在或者账号已经停用!!");
  1250. this.btnOPOption.Enabled = false;
  1251. return;
  1252. }
  1253. if (txtLotNo.Text.Trim() != "")
  1254. {
  1255. string JNsql = @"SELECT DISTINCT a.OPCODE, a.UserCode
  1256. FROM ICSOP2User a
  1257. WHERE 1 = 1 AND a.UserCode='" + this.txtUserCode.Text + "' AND a.OPCODE='" + this.txtOPCode.Text + "' ORDER BY a.OPCODE ";
  1258. DataTable JNdt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, JNsql).Tables[0];
  1259. if (JNdt.Rows.Count == 0 || JNdt == null)
  1260. {
  1261. SetMessage("该人员:" + this.txtUserCode.Text + "对应工序:" + txtOPCode.Text + ",不存在,请先维护!", Color.Red);
  1262. this.btnOPOption.Enabled = false;
  1263. return;
  1264. }
  1265. string LotNo = txtLotNo.Text.Trim();
  1266. string UserCode = txtUserCode.Text.Trim();
  1267. string sql = @"SELECT UserCode,UserName,StartFlag FROM Sys_User WHERE UserCode='{0}' AND WorkPointCode='{1}' and StartFlag='1' ";
  1268. sql = string.Format(sql, UserCode, AppConfig.WorkPointCode);
  1269. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  1270. if (dt.Rows.Count == 0)
  1271. {
  1272. SetMessage("员工条码不存在,请确认后重新输入!", Color.Red);
  1273. this.btnOPOption.Enabled = false;
  1274. txtUserCode.SelectAll();
  1275. txtUserCode.Focus();
  1276. return;
  1277. }
  1278. else
  1279. {
  1280. txtUserName.Text = dt.Rows[0]["UserName"].ToString();
  1281. #region 根据批批号和员工条码获取当前采集状态
  1282. string statussql = @"SELECT
  1283. a.ACTIONRESULT,a.UserCodeEnd,b.CollectStatus,b.MUSER,
  1284. b.LOTStatus
  1285. FROM ICSLOTONWIP a
  1286. LEFT JOIN ICSLOTSIMULATION b ON a.LOTNO=b.LOTNO AND a.OPCODE=b.OPCODE AND a.UserCodeBegin=b.MUSER
  1287. WHERE a.LOTNO = '" + txtLotNo.Text + "' AND a.OPCODE = '" + txtOPCode.Text + "' ORDER BY a.MTIME DESC ";
  1288. // AND a.UserCodeBegin = '" + txtUserCode.Text + "'
  1289. statussql = string.Format(statussql, LotNo, UserCode);
  1290. DataTable statusdt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, statussql).Tables[0];
  1291. if (statusdt.Rows.Count == 0)
  1292. {
  1293. btnOPOption.Text = "开工";
  1294. btnPauseBegin.Text = "暂停";
  1295. }
  1296. else
  1297. {
  1298. if (statusdt.Rows[0]["ACTIONRESULT"].ToString() == "COLLECT_BEGIN")
  1299. {
  1300. btnOPOption.Text = "完工";
  1301. initCheck();
  1302. }
  1303. else
  1304. {
  1305. btnOPOption.Text = "开工";
  1306. }
  1307. if (statusdt.Rows[0]["LOTStatus"].ToString() == "暂停")
  1308. {
  1309. btnPauseBegin.Text = "取消暂停";
  1310. }
  1311. else
  1312. {
  1313. btnPauseBegin.Text = "暂停";
  1314. }
  1315. }
  1316. #endregion
  1317. }
  1318. txtEQPCode.SelectAll();
  1319. txtEQPCode.Focus();
  1320. SetMessage("员工条码扫描成功!", Color.Blue);
  1321. IsWriteAll();
  1322. this.btnOPOption.Enabled = true;
  1323. return;
  1324. }
  1325. else {
  1326. string UserCode = txtUserCode.Text.Trim();
  1327. string sql = @"SELECT UserCode,UserName,StartFlag FROM Sys_User WHERE UserCode='{0}' AND WorkPointCode='{1}' and StartFlag='1' ";
  1328. sql = string.Format(sql, UserCode, AppConfig.WorkPointCode);
  1329. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  1330. if (dt.Rows.Count == 0)
  1331. {
  1332. SetMessage("员工条码不存在,请确认后重新输入!", Color.Red);
  1333. this.btnOPOption.Enabled = false;
  1334. txtUserCode.SelectAll();
  1335. txtUserCode.Focus();
  1336. return;
  1337. }
  1338. else
  1339. {
  1340. txtUserName.Text = dt.Rows[0]["UserName"].ToString();
  1341. SetMessage("员工条码扫描成功!", Color.Blue);
  1342. txtEQPCode.SelectAll();
  1343. txtEQPCode.Focus();
  1344. }
  1345. }
  1346. }
  1347. }
  1348. //消息提示
  1349. private void SetMessage(string Msg, Color color)
  1350. {
  1351. txtMessage.Text = Msg;
  1352. txtMessage.ForeColor = color;
  1353. }
  1354. public class SearchPart
  1355. {
  1356. /// <summary>
  1357. /// 关键字
  1358. /// </summary>
  1359. public string ItemCode { get; set; }
  1360. public int size { get; set; }
  1361. /// <summary>
  1362. /// 可以通过扩展字段参数,指定需要额外获取的字段清单
  1363. /// </summary>
  1364. public string extra { get; set; }
  1365. public string routecode { get; set; }
  1366. public string opseq { get; set; }
  1367. }
  1368. #region 开工
  1369. //消息提示
  1370. private void SetMsg(Color color, string Msg)
  1371. {
  1372. txtMessage.Text = Msg;
  1373. txtMessage.ForeColor = color;
  1374. }
  1375. #region 检查输入数据
  1376. public string check()
  1377. {
  1378. string msg = "";
  1379. if (txtUserName.Text.Trim() == "")
  1380. {
  1381. msg += "请重新扫描员工条码!\n";
  1382. }
  1383. if (txtLotNo.Text.Trim() == "")
  1384. {
  1385. msg += "请重新扫描产品批号!\n";
  1386. }
  1387. if (txtOPCode.Text.Trim() == "")
  1388. {
  1389. msg += "请重新扫描工序条码!\n";
  1390. }
  1391. if (txtUserCode.Text.Trim() == "")
  1392. {
  1393. msg += "请重新扫描人员条码!\n";
  1394. }
  1395. if (txtEQPCode.Text.Trim() == "")
  1396. {
  1397. msg += "请重新扫描设备条码!\n";
  1398. }
  1399. if (txtMachineName.Text.Trim() == "") {
  1400. msg += "请重新扫描设备条码!\n";
  1401. }
  1402. return msg;
  1403. }
  1404. #endregion
  1405. /// 0906获取单据号
  1406. public static string GetSerialCode(string connectString, string tbName, string colName, string Pre, int numLen)
  1407. {
  1408. string sql = "EXEC Addins_GetSerialCode '{0}','{1}','{2}','{3}',{4}";
  1409. sql = string.Format(sql, new object[] { "",tbName, colName, Pre, numLen});
  1410. return DBHelper.ExecuteScalar(connectString, CommandType.Text, sql).ToString();
  1411. }
  1412. //0913不合格传入NCR
  1413. private void SendNCR(List<string> codeList, string strResult, decimal QTY, string itemcode, string mocode, string OPCODE, string LotNo)
  1414. {//
  1415. try
  1416. {
  1417. string codeStr = "";
  1418. foreach (string str in codeList)
  1419. {
  1420. codeStr += str + ",";
  1421. }
  1422. codeStr = codeStr.TrimEnd(',');
  1423. string NewCartonNo = "NCR" + AppConfig.GetSeverDateTime("yyyy-MM-dd").ToString("yyyyMMdd");
  1424. NewCartonNo = GetSerialCode(AppConfig.FrameConnectString, "ICSNCRDoc", "SecDocNO", NewCartonNo, 3);
  1425. ICSSecDocType secDocType = ICSSecDocTypeBLL.select("QC_Collect", AppConfig.FrameConnectString);
  1426. #region 20210816
  1427. //获取对应的接收人和抄送人
  1428. //ICSSecDocTypeStep docTypeStep = ICSSecDocTypeStepBLL.selectStepBySeq(secDocType.guid, "1", AppConfig.FrameConnectString);
  1429. //string ToUserList = "";
  1430. //ToUserList = ICSNCRDocBLL.QualityEngineer(CKType, AppConfig.AppConnectString);
  1431. #endregion
  1432. //string CCUserList = ICSNCRDocBLL.QualityEngineer("经理", AppConfig.AppConnectString);
  1433. //string sql = @"SELECT a.ProjectCode FROM ICSMO a WHERE a.MOCODE='{0}'";
  1434. //sql = string.Format(sql, mocode);
  1435. //DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  1436. string ProjectCode = "";
  1437. //if (dt != null && dt.Rows.Count > 0)
  1438. //{
  1439. // ProjectCode = dt.Rows[0]["ProjectCode"].ToString();
  1440. //}
  1441. ICSNCRDoc SecDoc = new ICSNCRDoc();
  1442. SecDoc.SecDocNO = NewCartonNo;
  1443. SecDoc.SecDocType = secDocType.guid;
  1444. SecDoc.SecDocStatus = "已发送";
  1445. SecDoc.SecDocSeq = 1;
  1446. SecDoc.SecDocCreateUser = AppConfig.UserCode;
  1447. SecDoc.SecDocCreateUserName = AppConfig.UserName;
  1448. SecDoc.SecDocCreateTime = AppConfig.GetSeverDateTime("");
  1449. //SecDoc.ErrorType = CKType;
  1450. SecDoc.ErrorType = "自检";//modify on 20230317 NCRtype修改
  1451. SecDoc.EQPCode = "";
  1452. SecDoc.ItemCode = itemcode;
  1453. SecDoc.ProjectCode = ProjectCode;
  1454. SecDoc.TimeLimit = "1";
  1455. SecDoc.ContentDesc = strResult;
  1456. // SecDoc.EATTRIBUTE2 = CKType;
  1457. //SecDoc.ToUserList = ToUserList;
  1458. //SecDoc.CCUserList = CCUserList;
  1459. //SecDoc.ToUserList = ToUserList;
  1460. //SecDoc.CCUserList = CCUserList;
  1461. SecDoc.LOTNO = LotNo;
  1462. SecDoc.OPCode = OPCODE;
  1463. SecDoc.SecDocOKTime = Convert.ToDateTime("1990-01-01");
  1464. SecDoc.Qty = QTY;
  1465. SecDoc.SrcDocInfo = LotNo;
  1466. ICSNCRDoc NCR = new ICSNCRDoc();
  1467. // NCR = ICSNCRDocBLL.selectBySrcDocInfo(codeStr, AppConfig.AppConnectString);
  1468. NCR = null;//modify on 20200418
  1469. if (NCR == null)
  1470. {
  1471. ICSNCRDocBLL.CreateNCR(SecDoc, AppConfig.AppConnectString);
  1472. }
  1473. else
  1474. {
  1475. MessageBox.Show(codeStr + "已产生NCR单号:" + NCR.SecDocNO + ",不能新增NCR单");
  1476. }
  1477. }
  1478. catch (Exception ex)
  1479. {
  1480. throw new Exception(ex.Message);
  1481. }
  1482. }
  1483. /// <summary>
  1484. /// 点击开工/完工
  1485. /// </summary>
  1486. /// <param name="sender"></param>
  1487. /// <param name="e"></param>
  1488. private void btnOPOption_Click(object sender, EventArgs e)
  1489. {
  1490. SetMsg(Color.Blue, "");
  1491. var FXSTATUS = false;
  1492. string msg = check();
  1493. if (msg != "")
  1494. {
  1495. SetMsg(Color.Red, msg);
  1496. return;
  1497. }
  1498. ///////////////////////////////////////////////////0906
  1499. List<string> codeList = new List<string>();
  1500. string strResult = "";
  1501. decimal QTY = 1;//批次数量
  1502. ///////////////////////////////////////////////////0906
  1503. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在处理...请稍等...");
  1504. try
  1505. {
  1506. _wait.Show();
  1507. string OpCode = txtOPCode.Text.Trim();
  1508. string LOTNO = txtLotNo.Text.Trim();
  1509. string sql = @"SELECT DISTINCT
  1510. a.ID,
  1511. a.OPCODE,
  1512. a.OPDESC,
  1513. b.RouteCode,
  1514. b.EQPCode,
  1515. b.EQPName,d.LOTStatus,
  1516. CASE d.CollectStatus WHEN 'COLLECT_BEGIN' THEN 'WG' ELSE 'KG' END AS Status,
  1517. E.Type,ISNULL(b.EATTRIBUTE1,0) AS EATTRIBUTE1,f.eattribute5
  1518. FROM
  1519. ICSOP a WITH (nolock)
  1520. LEFT JOIN ICSMO2User b WITH(nolock) ON a.OPCODE = b.OPCODE
  1521. LEFT JOIN ICSLOTSIMULATION d WITH(nolock) ON b.LOTNO = d.LOTNO and b.OPCODE=d.OPCODE
  1522. LEFT JOIN ICSEquipment e WITH(nolock) ON b.EQPCode=e.EQPCode
  1523. LEFT JOIN ICSITEMLOT f on d.lotno=f.lotno
  1524. WHERE
  1525. b.OPCODE = '{0}' AND b.LOTNO = '{1}'";
  1526. sql = string.Format(sql, OpCode, LOTNO);
  1527. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  1528. if (data.Rows.Count > 0)
  1529. {
  1530. foreach (DataRow dr in data.Rows)
  1531. {
  1532. if (dr["EATTRIBUTE1"].ToString() == "1")
  1533. {
  1534. txtOPName.Text = "";
  1535. txtEQPCode.Text = "";
  1536. txtMachineName.Text = "";
  1537. Status = "";
  1538. routeCode = "";
  1539. EQPType = "";
  1540. txtOPCode.SelectAll();
  1541. txtOPCode.Focus();
  1542. _wait.Close();
  1543. SetMsg(Color.Red, "所扫描的工序为委外工序,无法开工,请确认!");
  1544. return;
  1545. }
  1546. }
  1547. }
  1548. //返修条码提示
  1549. sql = "select eattribute5 from icsitemlot where lotno='"+ LOTNO+"'";
  1550. data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  1551. if (data.Rows.Count > 0 && data.Rows[0]["eattribute5"].ToString() == "返修中") {
  1552. if (ICSBaseSimpleCode.AppshowMessageBoxRepose("该条码是返修条码,是否返修完成?") != DialogResult.OK)
  1553. {
  1554. _wait.Close();
  1555. return;
  1556. }
  1557. else
  1558. {
  1559. FXSTATUS = true;
  1560. }
  1561. }
  1562. #region simulation
  1563. ICSLOTSIMULATION simulationNew = new ICSLOTSIMULATION();
  1564. simulationNew.MUSER = txtUserCode.Text.Trim();
  1565. simulationNew.LOTNO = txtLotNo.Text.Trim();
  1566. simulationNew.OPCODE = txtOPCode.Text.Trim();
  1567. simulationNew.EQPCODE = txtEQPCode.Text.Trim();
  1568. simulationNew.SHELFNO = "";
  1569. if (FXSTATUS)
  1570. simulationNew.SHELFNO = "返修完成";
  1571. #endregion
  1572. List<ICSOQCCKGROUP2LISTCheckResult> entityList = new List<ICSOQCCKGROUP2LISTCheckResult>();
  1573. ICSQualityCKDATA QualityCKDATA = new ICSQualityCKDATA();
  1574. if (btnOPOption.Text.Trim().Equals(START))
  1575. {
  1576. simulationNew.EATTRIBUTE1 = "COLLECT_BEGIN";
  1577. }
  1578. else
  1579. {
  1580. //0826注释
  1581. //if (gridViewCC.DataRowCount == 0 || gridView2.DataRowCount == 0)
  1582. //{
  1583. // SetMsg(Color.Red, "没有维护自检信息,请确认!");
  1584. // _wait.Close();
  1585. // return;
  1586. //}
  1587. #region 完工 检验上道工序是否有不合格的
  1588. QualityCKDATA.EATTRIBUTE3 = "";//参与人
  1589. QualityCKDATA.LOTNO ="";
  1590. QualityCKDATA.OPCode = this.txtOPCode.Text.Trim();
  1591. QualityCKDATA.MOCODE = txtMOCode.Text.Trim();
  1592. QualityCKDATA.CKUserCode = txtUserCode.Text.Trim();
  1593. QualityCKDATA.Type = "GX";
  1594. if ((txtCCResult.Text == "OK"||gridViewCC.RowCount<=0) && (txtWGResult.Text == "OK"|| gridView2.RowCount <= 0))
  1595. {
  1596. QualityCKDATA.CKResult = "1";
  1597. }
  1598. else
  1599. {
  1600. QualityCKDATA.CKResult = "0";
  1601. //QualityCKDATA.LOTNO = txtLotNo.Text;
  1602. }
  1603. if (gridViewCC.RowCount <= 0)
  1604. {
  1605. }
  1606. else
  1607. {
  1608. for (int k = 0; k < gridViewCC.RowCount; k++)
  1609. {
  1610. ICSOQCCKGROUP2LISTCheckResult entity = new ICSOQCCKGROUP2LISTCheckResult();
  1611. #region MyRegion
  1612. Decimal OKQty = 0; Decimal NGQty = 0;
  1613. if (gridViewCC.RowCount > 0)
  1614. {
  1615. if (string.IsNullOrWhiteSpace(txtCCResult.Text))
  1616. {
  1617. ICSBaseSimpleCode.AppshowMessageBox("尺寸还没有检验!!!");
  1618. _wait.Close();
  1619. return;
  1620. }
  1621. if (string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, colCheckResult).ToString()))
  1622. {
  1623. ICSBaseSimpleCode.AppshowMessageBox("存在未填写的检验值!请确认!");
  1624. _wait.Close();
  1625. return;
  1626. }
  1627. string ok = gridViewCC.GetRowCellValue(k, CCOK).ToString();
  1628. string ng = gridViewCC.GetRowCellValue(k, CCNG).ToString();
  1629. if ((string.IsNullOrEmpty(ok) && string.IsNullOrEmpty(ng) || (ok == "False" && ng == "False")))
  1630. {
  1631. ICSBaseSimpleCode.AppshowMessageBox("存在检验项目未勾选合格或不合格!请确认!");
  1632. _wait.Close();
  1633. return;
  1634. }
  1635. }
  1636. //entity.CKITEMCODE = txtUserName.Text;// gridViewCC.GetRowCellValue(k, colCKITEMCODE).ToString();
  1637. ///0826 设置尺寸检验------------------------------------------------------------------
  1638. entity.CKListCode = gridViewCC.GetRowCellValue(k, colCKGROUPCode).ToString();
  1639. entity.RCVCode = RCVCode;
  1640. entity.INVDESC = INVDESC;
  1641. entity.CheckoutAttribute = "量化";
  1642. entity.GXorWWCheck = "GX";
  1643. entity.VALUEMAX = Decimal.Parse(gridViewCC.GetRowCellValue(k, colSetValueMax).ToString());
  1644. entity.VALUEMIN = Decimal.Parse(gridViewCC.GetRowCellValue(k, colSetValueMin).ToString());
  1645. entity.CheckResultValue = gridViewCC.GetRowCellValue(k, colCheckResult).ToString();
  1646. if (txtCCResult.Text == "OK")
  1647. {
  1648. entity.Qualified = Decimal.Parse(txtLONTQty.Text);//合格数
  1649. }
  1650. else
  1651. {
  1652. entity.UnQualified = Decimal.Parse(txtLONTQty.Text); ;//不合格数
  1653. }
  1654. entity.CCorWGResult = txtCCResult.Text;
  1655. entity.LotNo = txtLotNo.Text;
  1656. entity.UserCode = this.txtUserCode.Text;
  1657. entity.MOCode = this.txtMOCode.Text;
  1658. entity.OPCode = this.txtOPCode.Text;
  1659. entityList.Add(entity);
  1660. }
  1661. }
  1662. if (gridView2.RowCount <= 0)
  1663. {
  1664. }
  1665. else
  1666. {
  1667. for (int k = 0; k < gridView2.RowCount; k++)
  1668. {
  1669. ICSOQCCKGROUP2LISTCheckResult entity = new ICSOQCCKGROUP2LISTCheckResult();
  1670. #region MyRegion
  1671. if (gridView2.RowCount > 0)
  1672. {
  1673. if (string.IsNullOrWhiteSpace(txtWGResult.Text))
  1674. {
  1675. ICSBaseSimpleCode.AppshowMessageBox("外观还没有检验!!!");
  1676. _wait.Close();
  1677. return;
  1678. }
  1679. }
  1680. #endregion
  1681. //entity.CKITEMCODE = txtUserName.Text;// gridViewCC.GetRowCellValue(k, colCKITEMCODE).ToString();
  1682. entity.CKListCode = gridView2.GetRowCellValue(k, colCKGROUPCode1).ToString();
  1683. entity.RCVCode = RCVCode;
  1684. entity.INVDESC = INVDESC;
  1685. entity.GXorWWCheck = "GX";
  1686. entity.CheckoutAttribute = "外观";
  1687. entity.CCorWGResult = txtWGResult.Text;
  1688. entity.AQL = gridView2.GetRowCellValue(k, colCKGROUPATTR).ToString();
  1689. entity.InspectionStandard = gridView2.GetRowCellValue(k, colCKGROUPMETH).ToString();
  1690. if (gridView2.GetRowCellValue(k, colOK).ToString() == "True")
  1691. {
  1692. entity.IsOK = 1;
  1693. }
  1694. if (gridView2.GetRowCellValue(k, colNG).ToString() == "True")
  1695. {
  1696. //entity.IsOK = 1;
  1697. entity.IsOK = 0;
  1698. }
  1699. //else
  1700. //{
  1701. // entity.IsOK = 0;
  1702. //}
  1703. if (txtWGResult.Text == "OK")
  1704. {
  1705. entity.Qualified = Decimal.Parse(txtLONTQty.Text);//合格数
  1706. }
  1707. else
  1708. {
  1709. entity.UnQualified = Decimal.Parse(txtLONTQty.Text); ;//不合格数
  1710. }
  1711. entity.LotNo = txtLotNo.Text;
  1712. entity.UserCode = this.txtUserCode.Text;
  1713. entity.MOCode = this.txtMOCode.Text;
  1714. entity.OPCode = this.txtOPCode.Text;
  1715. entityList.Add(entity);
  1716. #endregion
  1717. }
  1718. }
  1719. #endregion
  1720. simulationNew.EATTRIBUTE1 = "COLLECT_END";
  1721. }
  1722. ICSCollectBLL.Save(AppConfig.AppConnectString, simulationNew);
  1723. SetMsg(Color.Blue, btnOPOption.Text.Trim() + "成功!");
  1724. if (entityList != null && btnOPOption.Text == "完工")
  1725. {
  1726. ICSDataCollectionBLL.AddAndEditList(QualityCKDATA, entityList, AppConfig.AppConnectString, false);
  1727. }
  1728. ////////////////////////////////////////////////////////////////////0906判退到NCR
  1729. if (QualityCKDATA.CKResult == "0")
  1730. {
  1731. string itemcode = txtItemCode.Text;
  1732. string OPCODE = txtOPCode.Text;
  1733. string MOCODE = txtMOCode.Text;
  1734. QTY = Convert.ToDecimal(txtLONTQty.Text);
  1735. LotNo = txtLotNo.Text;
  1736. if (!codeList.Contains(LotNo))
  1737. {
  1738. strResult += "产品追踪单:" + LotNo + " " + CCNCRMes() + " " + WWNCRMes();
  1739. codeList.Add(LotNo);
  1740. }
  1741. SendNCR(codeList, strResult, QTY, itemcode, MOCODE, OpCode, LotNo);
  1742. ////////////////////////////////////0906判退到NCR
  1743. }
  1744. ClearTxt();
  1745. if (btnOPOption.Text.Trim().Equals(START))
  1746. {
  1747. btnOPOption.Text = END;
  1748. }
  1749. else
  1750. {
  1751. btnOPOption.Text = START;
  1752. }
  1753. _wait.Close();
  1754. txtOPCode.Enabled = true;
  1755. txtUserCode.ReadOnly = false;
  1756. txtEQPCode.ReadOnly = false;
  1757. }
  1758. catch (Exception ex)
  1759. {
  1760. _wait.Close();
  1761. SetMsg(Color.Red, ex.Message);
  1762. }
  1763. }
  1764. #endregion
  1765. #region 任务暂停、取消暂停
  1766. private void btnPauseBegin_Click(object sender, EventArgs e)
  1767. {
  1768. if (btnPauseBegin.Text.Trim().Equals(PAUSE))
  1769. {
  1770. Pause();
  1771. }
  1772. else
  1773. {
  1774. CancelPause();
  1775. }
  1776. }
  1777. #region 取消暂停
  1778. private void CancelPause()
  1779. {
  1780. try
  1781. {
  1782. if (txtLotNo.Text.Trim() == "" || txtOPCode.Text.Trim() == "" || txtUserCode.Text.Trim() == "" || txtEQPCode.Text.Trim() == "")
  1783. {
  1784. SetMsg(Color.Red, "请先扫描批次信息!");
  1785. return;
  1786. }
  1787. #region simulation
  1788. ICSLOTSIMULATION simulationNew = new ICSLOTSIMULATION();
  1789. simulationNew.MUSER = txtUserCode.Text.Trim();
  1790. simulationNew.MUSERName = txtUserName.Text.Trim();
  1791. simulationNew.LOTNO = txtLotNo.Text.Trim();
  1792. simulationNew.OPCODE = txtOPCode.Text.Trim();
  1793. simulationNew.EQPCODE = txtEQPCode.Text.Trim();
  1794. #endregion
  1795. ICSCollectBLL.CancelPause(AppConfig.AppConnectString, simulationNew);
  1796. SetMsg(Color.Blue, "取消暂停成功!");
  1797. btnPauseBegin.Text = PAUSE;
  1798. //clear();
  1799. //ClearTxt();
  1800. this.txtStopType.Text = "";
  1801. this.txtStopCode.Text = "";
  1802. }
  1803. catch (Exception ex)
  1804. {
  1805. SetMsg(Color.Red, ex.Message);
  1806. }
  1807. }
  1808. //private void clear()
  1809. //{
  1810. // try
  1811. // {
  1812. // txtUserCode.Text = "";
  1813. // txtUserName.Text = "";
  1814. // txtItemCode.Text = "";
  1815. // txtLotNO.Text = "";
  1816. // txtLotNo.Text = "";
  1817. // txtMoCode.Text = "";
  1818. // txtItemName.Text = "";
  1819. // txtOpCode.Text = "";
  1820. // txtOpName.Text = "";
  1821. // txtKeyPart.Text = "";
  1822. // txtEQPCode.Text = "";
  1823. // txtEQPName.Text = "";
  1824. // txtInvLotFurnace.Text = "";
  1825. // txtEQPCode.Text = "";
  1826. // txtRealEQPName.Text = "";
  1827. // txtMemo.Text = "";
  1828. // }
  1829. // catch (Exception ex)
  1830. // {
  1831. // SetMsg(Color.Red, ex.Message);
  1832. // }
  1833. //}
  1834. #endregion
  1835. private void Pause()
  1836. {
  1837. try
  1838. {
  1839. if (string.IsNullOrWhiteSpace(this.txtStopType.Text))
  1840. {
  1841. SetMsg(Color.Red, "请先选择暂停类型!");
  1842. return;
  1843. }
  1844. if (txtLotNo.Text.Trim() == "" || txtOPCode.Text.Trim() == "" || txtUserCode.Text.Trim() == "" || txtEQPCode.Text.Trim() == "")
  1845. {
  1846. SetMsg(Color.Red, "请先扫描批次信息!");
  1847. return;
  1848. }
  1849. #region simulation
  1850. ICSLOTSIMULATION simulationNew = new ICSLOTSIMULATION();
  1851. simulationNew.MUSER = txtUserCode.Text.Trim();
  1852. simulationNew.MUSERName = txtUserName.Text.Trim();
  1853. simulationNew.LOTNO = txtLotNo.Text.Trim();
  1854. simulationNew.OPCODE = txtOPCode.Text.Trim();
  1855. simulationNew.EQPCODE = txtEQPCode.Text.Trim();
  1856. simulationNew.EATTRIBUTE2 = txtStopCode.Text.Trim();
  1857. #endregion
  1858. ICSCollectBLL.Pause(AppConfig.AppConnectString, simulationNew);
  1859. SetMsg(Color.Blue, "暂停成功!");
  1860. btnPauseBegin.Text = CANCELPAUSE;
  1861. }
  1862. catch (Exception ex)
  1863. {
  1864. SetMsg(Color.Red, ex.Message);
  1865. }
  1866. }
  1867. #endregion
  1868. #region 工序结束
  1869. private void button4_Click_bak(object sender, EventArgs e)
  1870. {
  1871. }
  1872. #endregion
  1873. #region 退出
  1874. private void button5_Click(object sender, EventArgs e)
  1875. {
  1876. AppConfig.CloseFormShow(this.Text);
  1877. this.Close();
  1878. }
  1879. #endregion
  1880. public void FormClear()
  1881. {
  1882. foreach (Control control in panel1.Controls)
  1883. {
  1884. if (control is TextBox)
  1885. {
  1886. ((TextBox)control).Text = "";
  1887. }
  1888. }
  1889. foreach (Control control in panel2.Controls)
  1890. {
  1891. if (control is TextBox)
  1892. {
  1893. ((TextBox)control).Text = "";
  1894. }
  1895. }
  1896. txtLotNo.Focus();
  1897. //grvdt.Clear();
  1898. //connectgrvdt.Clear();
  1899. }
  1900. private void btnEnlargeTZ_Click(object sender, EventArgs e)
  1901. {
  1902. FileDrawing.Enlarge(axAcroPDF);
  1903. }
  1904. private void txtStopType_EditValueChanged(object sender, EventArgs e)
  1905. {
  1906. string sql1 = @"SELECT DISTINCT EnumValue [暂停类型编码] ,EnumText [暂停类型] FROM Sys_EnumValues WHERE EnumKey='00022' and WorkPointCode='" + AppConfig.WorkPointCode + "' and EnumText='" + txtStopType.Text + "' ";
  1907. sql1 = string.Format(sql1, AppConfig.WorkPointCode);
  1908. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql1).Tables[0];
  1909. if (dt != null && dt.Rows.Count > 0)
  1910. {
  1911. txtStopType.Text = dt.Rows[0]["暂停类型"].ToString();
  1912. txtStopCode.Text = dt.Rows[0]["暂停类型编码"].ToString();
  1913. }
  1914. }
  1915. private void FormICSProductionReport_Activated(object sender, EventArgs e)
  1916. {
  1917. this.txtLotNo.Focus();
  1918. }
  1919. private void ClearTxt()
  1920. {
  1921. txtLotNo.Text = "";
  1922. txtOPCode.Text = "";
  1923. txtUserCode.Text = "";
  1924. txtUserName.Text = "";
  1925. txtEQPCode.Text = "";
  1926. txtMOCode.Text = "";
  1927. txtOPName.Text = "";
  1928. txtItemCode.Text = "";
  1929. txtItemName.Text = "";
  1930. txtMachineName.Text = "";
  1931. txtLONTQty.Text = "";
  1932. txtMOQty.Text = "";
  1933. txtThisOPOKQty.Text = "";
  1934. txtThisOPNGQty.Text = "";
  1935. //txtMachineCode1.Text = "";
  1936. //txtMachineName1.Text = "";
  1937. //txtMachineCode2.Text = "";
  1938. //txtMachineName2.Text = "";
  1939. //txtOKQty.Text = "";
  1940. //txtNGQty.Text = "";
  1941. gridControlcc.DataSource = null;
  1942. gridControl2.DataSource = null;
  1943. }
  1944. #region 设备
  1945. private void txtMachineCode_KeyPress(object sender, KeyPressEventArgs e)
  1946. {
  1947. try
  1948. {
  1949. if (e.KeyChar == (char)Keys.Enter)
  1950. {
  1951. string sql = @"SELECT EQPName FROM ICSEquipment (NOLOCK) WHERE EQPCode='" + txtEQPCode.Text + "' AND WorkPoint='" + AppConfig.WorkPointCode + "'";
  1952. DataTable dt2 = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  1953. if (dt2 != null && dt2.Rows.Count > 0)
  1954. {
  1955. txtMachineName.Text = dt2.Rows[0][0].ToString();
  1956. SetMessage("设备扫描成功", Color.Blue);
  1957. IsWriteAll();
  1958. }
  1959. else
  1960. {
  1961. SetMessage("输入的设备编码:" + txtEQPCode.Text + ",有误,请核对数据", Color.Red);
  1962. return;
  1963. }
  1964. }
  1965. }
  1966. catch (Exception ex)
  1967. {
  1968. SetMessage(ex.Message, Color.Red);
  1969. return;
  1970. }
  1971. }
  1972. #endregion
  1973. private void txtMachineCode1_KeyPress(object sender, KeyPressEventArgs e)
  1974. {
  1975. try
  1976. {
  1977. if (e.KeyChar == (char)Keys.Enter)
  1978. {
  1979. string sql = @"SELECT EQPName FROM ICSEquipment (NOLOCK) WHERE EQPCode='" + txtEQPCode.Text + "' AND WorkPoint='" + AppConfig.WorkPointCode + "'";
  1980. DataTable dt2 = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  1981. if (dt2 != null && dt2.Rows.Count > 0)
  1982. {
  1983. txtMachineName.Text = dt2.Rows[0][0].ToString();
  1984. SetMessage("设备扫描成功", Color.Blue);
  1985. this.btnOPOption.Enabled = true;
  1986. }
  1987. else
  1988. {
  1989. SetMessage("输入的设备编码:" + txtEQPCode.Text + ",有误,请核对数据", Color.Red);
  1990. this.btnOPOption.Enabled = false;
  1991. return;
  1992. }
  1993. }
  1994. }
  1995. catch (Exception ex)
  1996. {
  1997. SetMessage(ex.Message, Color.Red);
  1998. return;
  1999. }
  2000. }
  2001. //private void txtMachineCode2_KeyPress(object sender, KeyPressEventArgs e)
  2002. //{
  2003. // try
  2004. // {
  2005. // if (e.KeyChar == (char)Keys.Enter)
  2006. // {
  2007. // string sql = @"SELECT EQPName FROM ICSEquipment (NOLOCK) WHERE EQPCode='" + txtMachineCode2.Text + "' AND WorkPoint='" + AppConfig.WorkPointCode + "'";
  2008. // DataTable dt2 = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  2009. // if (dt2 != null && dt2.Rows.Count > 0)
  2010. // {
  2011. // txtMachineName.Text = dt2.Rows[0][0].ToString();
  2012. // SetMessage("设备扫描成功", Color.Blue);
  2013. // }
  2014. // else
  2015. // {
  2016. // SetMessage("输入的设备编码:" + txtEQPCode.Text + ",有误,请核对数据", Color.Red);
  2017. // return;
  2018. // }
  2019. // }
  2020. // }
  2021. // catch (Exception ex)
  2022. // {
  2023. // SetMessage(ex.Message, Color.Red);
  2024. // return;
  2025. // }
  2026. //}
  2027. private void txtIsReturnItem_CheckedChanged(object sender, EventArgs e)
  2028. {
  2029. //if (this.txtIsReturnItem.Checked == true)
  2030. //{
  2031. // this.labelControl2.Text = "退料数量";
  2032. // this.txtReturnMateralSave.Visible = true;
  2033. // labelControl1.Visible = true;
  2034. // txtSBItemCode.Visible = true;
  2035. // labelControl2.Visible = true;
  2036. // txtSBItemCodeQty.Visible = true;
  2037. //}
  2038. //else
  2039. //{
  2040. // this.labelControl2.Text = "发料数量";
  2041. // this.txtReturnMateralSave.Visible = false;
  2042. // labelControl1.Visible = false;
  2043. // txtSBItemCode.Visible = false;
  2044. // labelControl2.Visible = false;
  2045. // txtSBItemCodeQty.Visible = false;
  2046. //}
  2047. }
  2048. #region 工序上料退料
  2049. #endregion
  2050. /// <summary>
  2051. /// 操作手册
  2052. /// </summary>
  2053. /// <param name="sender"></param>
  2054. /// <param name="e"></param>
  2055. private void button1_Click(object sender, EventArgs e)
  2056. {
  2057. }
  2058. private void gridViewCC_KeyUp(object sender, KeyEventArgs e)
  2059. {
  2060. #region
  2061. try
  2062. {
  2063. if (e.KeyCode == Keys.Enter)
  2064. {
  2065. if (gridViewCC.FocusedRowHandle < 0)
  2066. {
  2067. return;
  2068. }
  2069. #region colS1
  2070. int SNo = gridViewCC.FocusedRowHandle;
  2071. int SNoCC = gridViewCC.RowCount;
  2072. for (int i = SNo; i <= SNo; i++)
  2073. {
  2074. SendKeys.Send("{Down}");
  2075. if (SNo == SNoCC - 1)
  2076. {
  2077. for (int j = 0; j <= SNoCC - 1; j++)
  2078. {
  2079. SendKeys.Send("{Up}");
  2080. }
  2081. SendKeys.Send("{RIGHT}");
  2082. }
  2083. //bool istrue = false;
  2084. //for (int k = 0; k < gridViewCC.RowCount; k++)
  2085. //{
  2086. // #region MyRegion
  2087. // Decimal _VALUEMAX = 0; Decimal _VALUEMIN = 0; Decimal _S1 = 0;
  2088. // if (gridViewCC.GetRowCellValue(k, colSetValueMax) != null)
  2089. // {
  2090. // if (!string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, colSetValueMax).ToString()))
  2091. // {
  2092. // _VALUEMAX = Decimal.Parse(gridViewCC.GetRowCellValue(k, colSetValueMax).ToString());
  2093. // }
  2094. // }
  2095. // if (gridViewCC.GetRowCellValue(k, colSetValueMin) != null)
  2096. // {
  2097. // if (!string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, colSetValueMin).ToString()))
  2098. // {
  2099. // _VALUEMIN = Decimal.Parse(gridViewCC.GetRowCellValue(k, colSetValueMin).ToString());
  2100. // }
  2101. // }
  2102. // if (gridViewCC.GetRowCellValue(k, colCheckResult) != null)
  2103. // {
  2104. // if (!string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, colCheckResult).ToString()))
  2105. // {
  2106. // _S1 = Decimal.Parse(gridViewCC.GetRowCellValue(k, colCheckResult).ToString());
  2107. // }
  2108. // }
  2109. // if ((_S1 < _VALUEMIN || _S1 > _VALUEMAX) && gridViewCC.FocusedColumn.Caption == "检验值" && !string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, colCheckResult).ToString()))
  2110. // {
  2111. // istrue = false;
  2112. // break;
  2113. // }
  2114. // else
  2115. // {
  2116. // istrue = true;
  2117. // }
  2118. // #endregion
  2119. //}
  2120. //if (istrue)
  2121. //{
  2122. // this.txtCCResult.Text = "OK";
  2123. // this.txtCCResult.BackColor = Color.Blue;
  2124. //}
  2125. //else
  2126. //{
  2127. // this.txtCCResult.Text = "NG";
  2128. // this.txtCCResult.BackColor = Color.Red;
  2129. //}
  2130. }
  2131. #endregion
  2132. }
  2133. }
  2134. catch (Exception ex)
  2135. {
  2136. throw new Exception(ex.ToString());
  2137. }
  2138. #endregion
  2139. }
  2140. private void gridView2_KeyUp(object sender, KeyEventArgs e)
  2141. {
  2142. }
  2143. private void txtIsReturnItem_CheckedChanged_1(object sender, EventArgs e)
  2144. {
  2145. if (this.txtIsReturnItem.Checked == true)
  2146. {
  2147. this.labelControl2.Text = "退料数量";
  2148. this.txtReturnMateralSave.Visible = true;
  2149. labelControl1.Visible = true;
  2150. txtSBItemCode.Visible = true;
  2151. labelControl2.Visible = true;
  2152. txtSBItemCodeQty.Visible = true;
  2153. }
  2154. else
  2155. {
  2156. this.labelControl2.Text = "发料数量";
  2157. this.txtReturnMateralSave.Visible = false;
  2158. labelControl1.Visible = false;
  2159. txtSBItemCode.Visible = false;
  2160. labelControl2.Visible = false;
  2161. txtSBItemCodeQty.Visible = false;
  2162. }
  2163. }
  2164. private void txtReturnMateralSave_Click(object sender, EventArgs e)
  2165. {
  2166. if (string.IsNullOrWhiteSpace(this.txtSBItemCode.Text) || string.IsNullOrWhiteSpace(this.txtSBItemCodeQty.Text))
  2167. {
  2168. SetMessage("退料编码或者退料数量不能为空", Color.Red);
  2169. return;
  2170. }
  2171. string sqlUpOPDetail = @"SELECT DISTINCT a.SBItemCode cInvCode,d.QTY UPQty
  2172. FROM ICSMOOPDetail a
  2173. LEFT JOIN ICSITEMLot b ON a.MOCODE = b.TransNO AND a.MOSEQ=b.TransLine AND b.ItemCODE=a.ITEMCODE
  2174. LEFT JOIN ICSINVENTORY c ON a.SBItemCode = c.INVCODE
  2175. LEFT JOIN ICSLOTONWIPITEM d ON d.LOTNO = b.LotNO AND d.ROUTECODE=a.MoRoute AND d.OPCODE=a.OPCode
  2176. LEFT JOIN ICSMO e ON e.MOCODE=a.MOCODE AND e.MOSEQ=a.MOSEQ
  2177. WHERE b.LotNO='{0}' AND a.OPCode='{1}' AND a.OPType='UPBOM' AND a.WorkPoint='{2}' and b.WorkPoint='{2}' AND a.SBItemCode='{3}'";
  2178. sqlUpOPDetail = string.Format(sqlUpOPDetail, txtLotNo.Text.Trim(), txtOPCode.Text.Trim(), AppConfig.WorkPointCode, txtSBItemCode.Text);
  2179. DataTable _dataUpOPDetail = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sqlUpOPDetail).Tables[0];
  2180. if (_dataUpOPDetail != null && _dataUpOPDetail.Rows.Count > 0)
  2181. {
  2182. Decimal UPQty = 0;
  2183. Decimal _UPQty = Convert.ToDecimal(txtSBItemCodeQty.Text);
  2184. if (!string.IsNullOrWhiteSpace(_dataUpOPDetail.Rows[0][1].ToString()))
  2185. {
  2186. UPQty = Convert.ToDecimal(_dataUpOPDetail.Rows[0][1].ToString());
  2187. }
  2188. else
  2189. {
  2190. SetMessage("当前工序子件料号:" + txtSBItemCode.Text + "还没有发料,不能退料", Color.Red);
  2191. return;
  2192. }
  2193. if (_UPQty > UPQty)
  2194. {
  2195. SetMessage("当前工序子件料号:" + txtSBItemCode.Text + ";退料数量:" + txtSBItemCodeQty.Text + "大于发料数量:" + UPQty + ",不能退料", Color.Red);
  2196. return;
  2197. }
  2198. }
  2199. else
  2200. {
  2201. SetMessage("当前工序子件料号:" + txtSBItemCode.Text + "不属于工单上料明细", Color.Red);
  2202. return;
  2203. }
  2204. if (dataUpOPDetail != null && dataUpOPDetail.Rows.Count > 0)
  2205. {
  2206. List<ICSLOTONWIPITEM> list = new List<ICSLOTONWIPITEM>();
  2207. foreach (DataRow item in dataUpOPDetail.Rows)
  2208. {
  2209. if (item["cInvCode"].ToString() == txtSBItemCode.Text)
  2210. {
  2211. //d.QTY UPQty,
  2212. ICSLOTONWIPITEM wipItem = new ICSLOTONWIPITEM();
  2213. wipItem.MOCODE = item["MOCODE"].ToString();
  2214. wipItem.MOSEQ = Int32.Parse(item["TransLine"].ToString());
  2215. wipItem.LOTNO = item["LotNO"].ToString();
  2216. wipItem.ITEMCODE = txtItemCode.Text;//母件编码
  2217. wipItem.INVCODE = item["cInvCode"].ToString();//子件编码
  2218. wipItem.OPCODE = item["OPCode"].ToString();
  2219. wipItem.ROUTECODE = item["MoRoute"].ToString(); ;
  2220. Decimal OPOKQty = 0;
  2221. Decimal OPNGQty = 0;
  2222. if (!string.IsNullOrWhiteSpace(txtLONTQty.Text))
  2223. {
  2224. OPOKQty = Convert.ToDecimal(txtLONTQty.Text);
  2225. }
  2226. //if (!string.IsNullOrWhiteSpace(txtLONTQty.Text))
  2227. //{
  2228. // OPNGQty = Convert.ToDecimal(txtLONTQty.Text);
  2229. //}
  2230. if (!string.IsNullOrWhiteSpace(txtLONTQty.Text))
  2231. {
  2232. OPNGQty = 0;
  2233. }
  2234. Decimal MOQty = Convert.ToDecimal(item["MOPLANQTY"].ToString()); ;
  2235. wipItem.QTY = Convert.ToDecimal(item["UPQty"].ToString()) - Convert.ToDecimal(txtSBItemCodeQty.Text);
  2236. wipItem.MTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
  2237. wipItem.MUSER = AppConfig.UserCode; ;
  2238. wipItem.MUSERName = AppConfig.UserName;
  2239. wipItem.WorkPoint = AppConfig.WorkPointCode;
  2240. list.Add(wipItem);
  2241. }
  2242. }
  2243. ICSDataCollectionBLL.CollectOPUP(list, "0", AppConfig.AppConnectString);
  2244. SetMessage("工序退料成功!", Color.Blue);
  2245. if (!string.IsNullOrWhiteSpace(this.txtLotNo.Text.Trim()) && !string.IsNullOrWhiteSpace(this.txtOPCode.Text.Trim()))
  2246. {
  2247. string _sqlUpOPDetail = @"SELECT DISTINCT a.MOCODE,b.TransLine,a.MoRoute,b.LotNO,b.LOTQTY,a.MOUPBOM,e.MOPLANQTY,
  2248. a.SBItemCode cInvCode,c.INVNAME,a.OPCode,c.INVSTD,a.OPUseQty iQuantity,d.QTY UPQty,(a.OPUseQty - ISNULL(d.QTY, 0)) UnUpQty
  2249. FROM ICSMOOPDetail a
  2250. LEFT JOIN ICSITEMLot b ON a.MOCODE = b.TransNO AND a.MOSEQ=b.TransLine AND b.ItemCODE=a.ITEMCODE
  2251. LEFT JOIN ICSINVENTORY c ON a.SBItemCode = c.INVCODE
  2252. LEFT JOIN ICSLOTONWIPITEM d ON d.LOTNO = b.LotNO AND d.ROUTECODE=a.MoRoute AND d.OPCODE=a.OPCode AND d.INVCODE=a.SBItemCode
  2253. LEFT JOIN ICSMO e ON e.MOCODE=a.MOCODE AND e.MOSEQ=a.MOSEQ
  2254. WHERE b.LotNO='{0}' AND a.OPCode='{1}' AND a.OPType='UPBOM' AND a.WorkPoint='{2}' and b.WorkPoint='{2}'";
  2255. _sqlUpOPDetail = string.Format(_sqlUpOPDetail, txtLotNo.Text.Trim(), txtOPCode.Text.Trim(), AppConfig.WorkPointCode);
  2256. dataUpOPDetail = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, _sqlUpOPDetail).Tables[0];
  2257. this.gridControl1.DataSource = dataUpOPDetail;
  2258. gridView1.BestFitColumns();
  2259. }
  2260. }
  2261. }
  2262. private void btnTransfer_Click(object sender, EventArgs e)
  2263. {
  2264. SetMsg(Color.Blue, "");
  2265. string msg = check();
  2266. if (msg != "")
  2267. {
  2268. SetMsg(Color.Red, msg);
  2269. return;
  2270. }
  2271. try
  2272. {
  2273. #region simulation
  2274. ICSLOTSIMULATION simulationNew = new ICSLOTSIMULATION();
  2275. simulationNew.MUSER = txtUserCode.Text.Trim();
  2276. simulationNew.LOTNO = txtLotNo.Text.Trim();
  2277. simulationNew.OPCODE = txtOPCode.Text.Trim();
  2278. simulationNew.EQPCODE = txtEQPCode.Text.Trim();
  2279. //simulationNew.RESCODE = txtInvLotFurnace.Text.Trim();//试样号
  2280. //simulationNew.CHECKLOTNO = txtMemo.Text.Trim(); //备注
  2281. #endregion
  2282. ICSCollectBLL.Transfer(AppConfig.AppConnectString, simulationNew);
  2283. SetMsg(Color.Blue, btnTransfer.Text.Trim() + "成功!");
  2284. }
  2285. catch (Exception ex)
  2286. {
  2287. SetMsg(Color.Red, ex.Message);
  2288. }
  2289. }
  2290. #region 失去焦点
  2291. private void gridView2_LostFocus(object sender, EventArgs e)
  2292. {
  2293. //#region
  2294. //try
  2295. //{
  2296. // //if (e.KeyCode == Keys.Enter)
  2297. // //{
  2298. // if (gridView2.FocusedRowHandle < 0)
  2299. // {
  2300. // return;
  2301. // }
  2302. // #region colS1
  2303. // int SNo = gridView2.FocusedRowHandle;
  2304. // int SNoCC = gridView2.RowCount;
  2305. // //for (int i = SNo; i <= SNo; i++)
  2306. // //{
  2307. // // SendKeys.Send("{Down}");
  2308. // // if (SNo == SNoCC - 1)
  2309. // // {
  2310. // // for (int j = 0; j <= SNoCC - 1; j++)
  2311. // // {
  2312. // // SendKeys.Send("{Up}");
  2313. // // }
  2314. // // SendKeys.Send("{RIGHT}");
  2315. // // }
  2316. // bool istrue = false;
  2317. // for (int k = 0; k < gridView2.RowCount; k++)
  2318. // {
  2319. // //DevExpress.XtraGrid.Views.Grid.GridView GV = sender as DevExpress.XtraGrid.Views.Grid.GridView;
  2320. // //if (GV.EditingValue == null || GV.EditingValue.ToString() == "" || GV == null)
  2321. // //{
  2322. // // return;
  2323. // //}
  2324. // //string Memo = GV.EditingValue.ToString();
  2325. // //if (Memo != "")
  2326. // //{
  2327. // // string ID = gridView2.GetRowCellValue(gridView2.FocusedRowHandle, colOK).ToString();
  2328. // //}
  2329. // #region MyRegion
  2330. // bool _S1 = false;
  2331. // bool _S2 = false;
  2332. // if (gridView2.GetRowCellValue(k, colOK) != null)
  2333. // {
  2334. // if (!string.IsNullOrWhiteSpace(gridView2.GetRowCellValue(k, colOK).ToString()))
  2335. // {
  2336. // if (gridView2.GetRowCellValue(k, colOK).ToString() == "True")
  2337. // {
  2338. // _S1 = true;
  2339. // }
  2340. // }
  2341. // }
  2342. // if (gridView2.GetRowCellValue(k, colNG) != null)
  2343. // {
  2344. // if (!string.IsNullOrWhiteSpace(gridView2.GetRowCellValue(k, colNG).ToString()))
  2345. // {
  2346. // if (gridView2.GetRowCellValue(k, colNG).ToString() == "True")
  2347. // {
  2348. // _S2 = true;
  2349. // }
  2350. // }
  2351. // }
  2352. // if (_S1 && gridView2.FocusedColumn.Caption == "合格")
  2353. // {
  2354. // istrue = true;
  2355. // }
  2356. // //else
  2357. // //{
  2358. // // istrue = false;
  2359. // // break;
  2360. // //}
  2361. // if (_S2 && gridView2.FocusedColumn.Caption == "不合格")
  2362. // {
  2363. // istrue = false;
  2364. // break;
  2365. // }
  2366. // #endregion
  2367. // }
  2368. // if (istrue)
  2369. // {
  2370. // this.txtWGResult.Text = "OK";
  2371. // this.txtWGResult.BackColor = Color.Blue;
  2372. // }
  2373. // else
  2374. // {
  2375. // this.txtWGResult.Text = "NG";
  2376. // this.txtWGResult.BackColor = Color.Red;
  2377. // }
  2378. // //}
  2379. // #endregion
  2380. // //}
  2381. //}
  2382. //catch (Exception ex)
  2383. //{
  2384. // throw new Exception(ex.ToString());
  2385. //}
  2386. //#endregion
  2387. }
  2388. #endregion
  2389. private void gridViewCC_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
  2390. {
  2391. //#region
  2392. //try
  2393. //{
  2394. // //if (e.KeyCode == Keys.Enter)
  2395. // //{
  2396. // if (gridViewCC.FocusedRowHandle < 0)
  2397. // {
  2398. // return;
  2399. // }
  2400. // #region colS1
  2401. // int SNo = gridViewCC.FocusedRowHandle;
  2402. // int SNoCC = gridViewCC.RowCount;
  2403. // //for (int i = SNo; i <= SNo; i++)
  2404. // //{
  2405. // //SendKeys.Send("{Down}");
  2406. // //if (SNo == SNoCC - 1)
  2407. // //{
  2408. // // for (int j = 0; j <= SNoCC - 1; j++)
  2409. // // {
  2410. // // SendKeys.Send("{Up}");
  2411. // // }
  2412. // // SendKeys.Send("{RIGHT}");
  2413. // //}
  2414. // bool istrue = false;
  2415. // if (gridViewCC.FocusedColumn.Caption == "检验值")
  2416. // {
  2417. // for (int k = 0; k < gridViewCC.RowCount; k++)
  2418. // {
  2419. // #region MyRegion
  2420. // Decimal _VALUEMAX = 0; Decimal _VALUEMIN = 0; Decimal _S1 = 0;
  2421. // if (gridViewCC.GetRowCellValue(k, colSetValueMax) != null)
  2422. // {
  2423. // if (!string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, colSetValueMax).ToString()))
  2424. // {
  2425. // _VALUEMAX = Decimal.Parse(gridViewCC.GetRowCellValue(k, colSetValueMax).ToString());
  2426. // }
  2427. // }
  2428. // if (gridViewCC.GetRowCellValue(k, colSetValueMin) != null)
  2429. // {
  2430. // if (!string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, colSetValueMin).ToString()))
  2431. // {
  2432. // _VALUEMIN = Decimal.Parse(gridViewCC.GetRowCellValue(k, colSetValueMin).ToString());
  2433. // }
  2434. // }
  2435. // if (gridViewCC.GetRowCellValue(k, colCheckResult) != null)
  2436. // {
  2437. // if (!string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, colCheckResult).ToString()))
  2438. // {
  2439. // _S1 = Decimal.Parse(gridViewCC.GetRowCellValue(k, colCheckResult).ToString());
  2440. // }
  2441. // }
  2442. // if ((_S1 >= _VALUEMIN && _S1 <= _VALUEMAX) && gridViewCC.FocusedColumn.Caption == "检验值" && !string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, colCheckResult).ToString()))
  2443. // {
  2444. // istrue = true;
  2445. // }
  2446. // else
  2447. // {
  2448. // istrue = false;
  2449. // break;
  2450. // }
  2451. // #endregion
  2452. // }
  2453. // if (istrue)
  2454. // {
  2455. // this.txtCCResult.Text = "OK";
  2456. // //this.txtCCResult.BackColor = Color.Blue;//5572e8
  2457. // this.txtCCResult.BackColor = Color.MediumSlateBlue;//5572e8
  2458. // }
  2459. // else
  2460. // {
  2461. // this.txtCCResult.Text = "NG";
  2462. // this.txtCCResult.BackColor = Color.Red;
  2463. // }
  2464. // //}
  2465. // }
  2466. // #endregion
  2467. // //}
  2468. //}
  2469. //catch (Exception ex)
  2470. //{
  2471. // throw new Exception(ex.ToString());
  2472. //}
  2473. //#endregion
  2474. }
  2475. private string CCNCRMes() {
  2476. string result = "";
  2477. for (int k = 0; k < gridViewCC.RowCount; k++)
  2478. {
  2479. //Decimal _VALUEMAX = 0; Decimal _VALUEMIN = 0; Decimal _S1 = 0;
  2480. //if (gridViewCC.GetRowCellValue(k, colSetValueMax) != null)
  2481. //{
  2482. // if (!string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, colSetValueMax).ToString()))
  2483. // {
  2484. // _VALUEMAX = Decimal.Parse(gridViewCC.GetRowCellValue(k, colSetValueMax).ToString());
  2485. // }
  2486. //}
  2487. //if (gridViewCC.GetRowCellValue(k, colSetValueMin) != null)
  2488. //{
  2489. // if (!string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, colSetValueMin).ToString()))
  2490. // {
  2491. // _VALUEMIN = Decimal.Parse(gridViewCC.GetRowCellValue(k, colSetValueMin).ToString());
  2492. // }
  2493. //}
  2494. //if (gridViewCC.GetRowCellValue(k, colCheckResult) != null)
  2495. //{
  2496. // if (!string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, colCheckResult).ToString()))
  2497. // {
  2498. // _S1 = Decimal.Parse(gridViewCC.GetRowCellValue(k, colCheckResult).ToString());
  2499. // }
  2500. //}
  2501. if (gridViewCC.GetRowCellValue(k, CCNG).ToString() == "True")
  2502. {
  2503. result += "在尺寸检验,检验项目:" + gridViewCC.GetRowCellValue(k, colCKGROUPDESC) + " 发生不良:实测值:" + gridViewCC.GetRowCellValue(k, colCheckResult).ToString() + ",不良原因:" + gridViewCC.GetRowCellValue(k, colRemark).ToString() + "";
  2504. }
  2505. }
  2506. return result;
  2507. }
  2508. private void gridView2_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
  2509. {
  2510. #region
  2511. try
  2512. {
  2513. //if (e.KeyCode == Keys.Enter)
  2514. //{
  2515. if (gridView2.FocusedRowHandle < 0)
  2516. {
  2517. return;
  2518. }
  2519. #region colS1
  2520. int SNo = gridView2.FocusedRowHandle;
  2521. int SNoCC = gridView2.RowCount;
  2522. //for (int i = SNo; i <= SNo; i++)
  2523. //{
  2524. // SendKeys.Send("{Down}");
  2525. // if (SNo == SNoCC - 1)
  2526. // {
  2527. // for (int j = 0; j <= SNoCC - 1; j++)
  2528. // {
  2529. // SendKeys.Send("{Up}");
  2530. // }
  2531. // SendKeys.Send("{RIGHT}");
  2532. // }
  2533. bool istrue = false;
  2534. for (int k = 0; k < gridView2.RowCount; k++)
  2535. {
  2536. //DevExpress.XtraGrid.Views.Grid.GridView GV = sender as DevExpress.XtraGrid.Views.Grid.GridView;
  2537. //if (GV.EditingValue == null || GV.EditingValue.ToString() == "" || GV == null)
  2538. //{
  2539. // return;
  2540. //}
  2541. //string Memo = GV.EditingValue.ToString();
  2542. //if (Memo != "")
  2543. //{
  2544. // string ID = gridView2.GetRowCellValue(gridView2.FocusedRowHandle, colOK).ToString();
  2545. //}
  2546. #region MyRegion
  2547. bool _S1 = false;
  2548. bool _S2 = false;
  2549. if (gridView2.GetRowCellValue(k, colOK) != null && e.Column.Caption == "合格")
  2550. {
  2551. if (!string.IsNullOrWhiteSpace(gridView2.GetRowCellValue(k, colOK).ToString()))
  2552. {
  2553. if (gridView2.GetRowCellValue(k, colOK).ToString() == "True")
  2554. {
  2555. _S1 = true;
  2556. if (gridView2.GetRowCellValue(k, colNG).ToString() == "True")
  2557. {
  2558. gridView2.SetRowCellValue(k, colNG, "False");
  2559. }
  2560. }
  2561. }
  2562. }
  2563. if (gridView2.GetRowCellValue(k, colNG) != null && e.Column.Caption == "不合格")
  2564. {
  2565. if (!string.IsNullOrWhiteSpace(gridView2.GetRowCellValue(k, colNG).ToString()))
  2566. {
  2567. if (gridView2.GetRowCellValue(k, colNG).ToString() == "True")
  2568. {
  2569. _S2 = true;
  2570. if (gridView2.GetRowCellValue(k, colOK).ToString() == "True")
  2571. {
  2572. gridView2.SetRowCellValue(k, colOK, "False");
  2573. }
  2574. }
  2575. }
  2576. }
  2577. if (_S1 && gridView2.FocusedColumn.Caption == "合格")
  2578. {
  2579. istrue = true;
  2580. }
  2581. //else
  2582. //{
  2583. // istrue = false;
  2584. // break;
  2585. //}
  2586. if (_S2 && gridView2.FocusedColumn.Caption == "不合格")
  2587. {
  2588. istrue = false;
  2589. //break;
  2590. }
  2591. #endregion
  2592. }
  2593. if (istrue)
  2594. {
  2595. this.txtWGResult.Text = "OK";
  2596. this.txtWGResult.BackColor = Color.Blue;
  2597. }
  2598. else
  2599. {
  2600. this.txtWGResult.Text = "NG";
  2601. this.txtWGResult.BackColor = Color.Red;
  2602. }
  2603. //}
  2604. #endregion
  2605. //}
  2606. }
  2607. catch (Exception ex)
  2608. {
  2609. throw new Exception(ex.ToString());
  2610. }
  2611. #endregion
  2612. }
  2613. private string WWNCRMes() {
  2614. string result = "";
  2615. for (int k = 0; k < gridView2.RowCount; k++)
  2616. {
  2617. bool _S2 = false;
  2618. if (gridView2.GetRowCellValue(k, colNG) != null)
  2619. {
  2620. if (!string.IsNullOrWhiteSpace(gridView2.GetRowCellValue(k, colNG).ToString()))
  2621. {
  2622. if (gridView2.GetRowCellValue(k, colNG).ToString() == "True")
  2623. {
  2624. _S2 = true;
  2625. }
  2626. }
  2627. }
  2628. if (_S2)
  2629. {
  2630. result += "在外观检验,检验项目:" + gridView2.GetRowCellValue(k, colCKGROUPDESC1) + "发生不良";
  2631. }
  2632. }
  2633. return result;
  2634. }
  2635. //private void webBrowserMap_SizeChanged(object sender, EventArgs e)
  2636. //{
  2637. // panelMap.Width = this.Width;
  2638. // panelMap.Height = this.Height;
  2639. // //webBrowserMap.Dock = DockStyle.Fill;
  2640. //}
  2641. public static string PLMMap_(string url, string JsonData)
  2642. {
  2643. //ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  2644. Encoding encoding = Encoding.UTF8;
  2645. //构造一个Web请求的对象
  2646. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url + JsonData);
  2647. request.Method = "GET";
  2648. request.Accept = "text/html, application/xhtml+xml, */*";
  2649. request.ContentType = "application/json";
  2650. //获取web请求的响应的内容
  2651. HttpWebResponse response = (HttpWebResponse)request.GetResponse();
  2652. using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
  2653. {
  2654. return reader.ReadToEnd();
  2655. }
  2656. //HttpWebRequest request = (HttpWebRequest)WebRequest.Create(https + strContent);
  2657. //request.Method = "GET";
  2658. //request.ContentType = "textml;charset=UTF-8";
  2659. //HttpWebResponse response = (HttpWebResponse)request.GetResponse();
  2660. //Stream myResponseStream = response.GetResponseStream();
  2661. //StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.UTF8);
  2662. //string retString = myStreamReader.ReadToEnd();
  2663. //myStreamReader.Close();
  2664. //myResponseStream.Close();
  2665. //dynamic ja = JsonConvert.DeserializeObject(retString);
  2666. //return ja;
  2667. }
  2668. public static BaseModel PLMMap(string URL, string JsonData)
  2669. {
  2670. try
  2671. {
  2672. //调用接口获取返回信息
  2673. //string ContentType = "application/json;charset=UTF-8;";
  2674. string ContentType = "application/json";
  2675. WebRequest request = WebRequest.Create(URL);
  2676. request.Method = "POST";
  2677. byte[] bytes = System.Text.Encoding.UTF8.GetBytes(JsonData);
  2678. request.ContentType = ContentType;
  2679. request.ContentLength = bytes.Length;
  2680. //using (Stream postStream = request.GetRequestStream())
  2681. //{
  2682. // postStream.Write(bytes, 0, bytes.Length);
  2683. //}
  2684. using (Stream postStream = request.GetRequestStream())
  2685. {
  2686. postStream.Write(bytes, 0, bytes.Length);
  2687. }
  2688. request.Credentials = CredentialCache.DefaultCredentials;
  2689. string str = string.Empty;
  2690. WebResponse response = null;
  2691. try
  2692. {
  2693. response = request.GetResponse();
  2694. }
  2695. catch (WebException ex)
  2696. {
  2697. if (ex.Status == WebExceptionStatus.ProtocolError)
  2698. response = (WebResponse)ex.Response;
  2699. }
  2700. if (response != null)
  2701. {
  2702. using (StreamReader st = new StreamReader(response.GetResponseStream(), System.Text.Encoding.UTF8))
  2703. {
  2704. str = System.Web.HttpUtility.UrlDecode(st.ReadToEnd());
  2705. }
  2706. }
  2707. //将返回的string类型转换成model
  2708. BaseModel obj = (BaseModel)Newtonsoft.Json.JsonConvert.DeserializeObject(str, typeof(BaseModel));
  2709. //string obj = (string)Newtonsoft.Json.JsonConvert.DeserializeObject(str, typeof(string));
  2710. return obj;
  2711. }
  2712. catch (Exception ex)
  2713. {
  2714. throw new Exception("调用MES接口错误:" + ex.Message);
  2715. }
  2716. }
  2717. public static string PLMMap1(string URL, string JsonData)
  2718. {
  2719. try
  2720. {
  2721. //调用接口获取返回信息
  2722. //string ContentType = "application/json;charset=UTF-8;";
  2723. string ContentType = "application/json";
  2724. WebRequest request = WebRequest.Create(URL);
  2725. request.Method = "POST";
  2726. byte[] bytes = System.Text.Encoding.UTF8.GetBytes(JsonData);
  2727. request.ContentType = ContentType;
  2728. request.ContentLength = bytes.Length;
  2729. //using (Stream postStream = request.GetRequestStream())
  2730. //{
  2731. // postStream.Write(bytes, 0, bytes.Length);
  2732. //}
  2733. using (Stream postStream = request.GetRequestStream())
  2734. {
  2735. postStream.Write(bytes, 0, bytes.Length);
  2736. }
  2737. request.Credentials = CredentialCache.DefaultCredentials;
  2738. string str = string.Empty;
  2739. WebResponse response = null;
  2740. try
  2741. {
  2742. response = request.GetResponse();
  2743. }
  2744. catch (WebException ex)
  2745. {
  2746. if (ex.Status == WebExceptionStatus.ProtocolError)
  2747. response = (WebResponse)ex.Response;
  2748. }
  2749. if (response != null)
  2750. {
  2751. using (StreamReader st = new StreamReader(response.GetResponseStream(), System.Text.Encoding.UTF8))
  2752. {
  2753. str = System.Web.HttpUtility.UrlDecode(st.ReadToEnd());
  2754. }
  2755. }
  2756. return str;
  2757. }
  2758. catch (Exception ex)
  2759. {
  2760. throw new Exception("调用MES接口错误:" + ex.Message);
  2761. }
  2762. }
  2763. public class BaseModel
  2764. {
  2765. public string code { get; set; }
  2766. public string msg { get; set; }
  2767. public string data { get; set; }
  2768. }
  2769. public static string HttpDownloadFile(string url, string path)
  2770. {
  2771. // 设置参数
  2772. HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
  2773. //发送请求并获取相应回应数据
  2774. HttpWebResponse response = request.GetResponse() as HttpWebResponse;
  2775. //直到request.GetResponse()程序才开始向目标网页发送Post请求
  2776. Stream responseStream = response.GetResponseStream();
  2777. //创建本地文件写入流
  2778. Stream stream = new FileStream(path, FileMode.Create);
  2779. byte[] bArr = new byte[1024];
  2780. int size = responseStream.Read(bArr, 0, (int)bArr.Length);
  2781. while (size > 0)
  2782. {
  2783. stream.Write(bArr, 0, size);
  2784. size = responseStream.Read(bArr, 0, (int)bArr.Length);
  2785. }
  2786. stream.Close();
  2787. responseStream.Close();
  2788. return path;
  2789. }
  2790. private void btnEnlargeTZ_Click_1(object sender, EventArgs e)
  2791. {
  2792. FileDrawing.Enlarge(axAcroPDF);
  2793. }
  2794. //初始化颜色
  2795. public void initcolor()
  2796. {
  2797. BtnSOP.BackColor = Color.FromArgb(207, 221, 255);
  2798. BtnSIP.BackColor = Color.FromArgb(207, 221, 255);
  2799. btnOPDrowing.BackColor = Color.FromArgb(207, 221, 255);
  2800. btnOperationManual.BackColor = Color.FromArgb(207, 221, 255);
  2801. BtnOPUp.BackColor = Color.FromArgb(207, 221, 255);
  2802. btnDaoJu.BackColor = Color.FromArgb(207, 221, 255);//刀具
  2803. btnCaoZuo.BackColor = Color.FromArgb(207, 221, 255);//操作
  2804. btnJianYan.BackColor = Color.FromArgb(207, 221, 255);//检验
  2805. }
  2806. #region 零部件 设计图纸 SOP
  2807. private void BtnSOP_Click(object sender, EventArgs e)
  2808. {
  2809. try
  2810. {
  2811. initcolor();
  2812. BtnSOP.BackColor = Color.Aqua;
  2813. string url = @"http://172.16.12.155:8999/api/GetPLMToken";
  2814. //string url = @"http://localhost:51182/api/GetPLMToken";
  2815. SearchPart Bills = new SearchPart();
  2816. //Bills.ItemCode = "20100003035";
  2817. //Bills.ItemCode = "20100000670";
  2818. //Bills.ItemCode = "20800001904";
  2819. Bills.ItemCode = txtItemCode.Text;
  2820. if (string.IsNullOrWhiteSpace(txtItemCode.Text))
  2821. {
  2822. SetMessage("请先输入料号编码", Color.Red);
  2823. return;
  2824. }
  2825. Bills.size = 100;
  2826. Bills.extra = "DWGSW";
  2827. string JsonData = JsonConvert.SerializeObject(Bills);
  2828. //try
  2829. //{
  2830. // //Bills = JsonConvert.DeserializeObject<List<SearchPart>>(JsonData.ToString());
  2831. // Bills = JsonConvert.DeserializeObject<SearchPart>(JsonData.ToString());
  2832. //}
  2833. #region MyRegion
  2834. BaseModel rtn = PLMMap(url, JsonData);
  2835. if (rtn.code == "200")
  2836. {
  2837. //txtGetPLMMap.Text = rtn.msg;
  2838. //panelMap.BringToFront();
  2839. //panel8WebMap.BringToFront();
  2840. //webBrowserMap.Navigate(txtGetPLMMap.Text);
  2841. //string path = string.Empty;
  2842. //path = "E:\\PDF";
  2843. //HttpDownloadFile(txtGetPLMMap.Text, path);
  2844. //SetMessage("", Color.Red);
  2845. //return;
  2846. //ICSSoft.Frame.PLM2MESInterface.Token.GetToken.OperationResult result = ICSSoft.Frame.PLM2MESInterface.Token.GetToken.GetPLMToken();
  2847. //string Token = result.errmsg;
  2848. #region MyRegion
  2849. panelMap.BringToFront();
  2850. this.label23.Visible = false;
  2851. string itemCode = this.txtItemCode.Text;
  2852. //string RouteCode = string.Empty;
  2853. string OpCode = this.txtOPCode.Text;
  2854. //string sql = @"SELECT SOPDrawing from ICSITEMROUTE2OP WHERE ITEMCODE='" + itemCode + "' AND ROUTECODE='" + RouteCode + "' AND OPCODE='" + OpCode + "' ";
  2855. //string connectionString = AppConfig.FrameConnectString; // AppConfig.GetDataBaseConnectStringByKey("[DB.PLM]");
  2856. //string connectionString = AppConfig.GetDataBaseConnectStringByKey("[DB.FTP2]");
  2857. //if (string.IsNullOrWhiteSpace(connectionString))
  2858. // return;
  2859. //string logAdress = ConfigurationManager.AppSettings["PLMAdress"].ToString();
  2860. //object name = DBHelper.ExecuteScalar(connectionString, CommandType.Text, sql);
  2861. //name = "123";
  2862. //if (name == null || string.IsNullOrWhiteSpace(name.ToString()))
  2863. // return;
  2864. //string fileName = "E:\\PDF\\20201015.pdf";
  2865. //string fileName = name.ToString() + itemCode + "\\" + RouteCode + "\\" + OpCode + ".pdf";
  2866. string connectionString = AppConfig.GetDataBaseConnectStringByKey("[DB.FTP]");
  2867. if (string.IsNullOrWhiteSpace(connectionString))
  2868. {
  2869. SetMessage("没有获取到FTP链接,请在数据源中先配置FTP", Color.Red);
  2870. return;
  2871. }
  2872. string[] ftps = connectionString.Split(';');
  2873. string ftpServerIP = ftps[0].Split('=')[1];
  2874. //string ftpRemotePath = ftps[1].Split('=')[1];
  2875. string ftpRemotePath = "";
  2876. string ftpUserID = ftps[2].Split('=')[1];
  2877. string ftpPassword = ftps[3].Split('=')[1];
  2878. FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword);
  2879. //FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword);
  2880. //string filePath = System.IO.Path.GetTempPath() + "\\Drawing";
  2881. string filePath = AppDomain.CurrentDomain.BaseDirectory + "\\Drawing";
  2882. if (!Directory.Exists(filePath))
  2883. {
  2884. Directory.CreateDirectory(filePath);
  2885. }
  2886. string fileName = Bills.ItemCode + ".pdf";
  2887. ftpWeb.Download(filePath + "\\", fileName);
  2888. string filePathName = filePath + "\\" + fileName;
  2889. //string fileName = logAdress + Bills.ItemCode + ".pdf";
  2890. string ftpURL = "ftp://" + ftpServerIP + "/" + fileName;
  2891. //if (!string.IsNullOrEmpty(fileName))
  2892. if (!string.IsNullOrEmpty(filePathName))
  2893. {
  2894. //axAcroPDF.LoadFile(fileName);
  2895. axAcroPDF.LoadFile(filePathName);
  2896. axAcroPDF.setShowToolbar(false);
  2897. axAcroPDF.setShowScrollbars(false);
  2898. axAcroPDF.setPageMode("thumbs");
  2899. axAcroPDF.setLayoutMode("SinglePage");
  2900. axAcroPDF.setView("Fit");
  2901. axAcroPDF.Show();
  2902. }
  2903. #endregion
  2904. }
  2905. else
  2906. {
  2907. SetMessage("调用PLM接口返回异常:" + rtn.code + ";" + rtn.msg, Color.Red);
  2908. return;
  2909. }
  2910. #endregion
  2911. }
  2912. catch (Exception ex)
  2913. {
  2914. MessageBox.Show(ex.Message);
  2915. }
  2916. }
  2917. #endregion
  2918. #region 工艺过程卡2
  2919. private void btnOperationManual_Click(object sender, EventArgs e)
  2920. {
  2921. try
  2922. {
  2923. initcolor();
  2924. btnOperationManual.BackColor = Color.Aqua;
  2925. string url = @"http://172.16.12.155:8999/api/GetPLMToken2";
  2926. //string url = @"http://localhost:51182/api/GetPLMToken2";
  2927. //;
  2928. SearchPart Bills = new SearchPart();
  2929. //Bills.ItemCode = "20100003035";
  2930. //Bills.ItemCode = "20100000670";
  2931. //Bills.ItemCode = "20800001904";
  2932. Bills.ItemCode = txtItemCode.Text;
  2933. if (string.IsNullOrWhiteSpace(txtItemCode.Text))
  2934. {
  2935. SetMessage("请先输入料号编码", Color.Red);
  2936. return;
  2937. }
  2938. Bills.size = 100;
  2939. //0916 原来的 Bills.extra = "DWGSW";
  2940. Bills.extra = "PRCF";
  2941. string JsonData = JsonConvert.SerializeObject(Bills);
  2942. //try
  2943. //{
  2944. // //Bills = JsonConvert.DeserializeObject<List<SearchPart>>(JsonData.ToString());
  2945. // Bills = JsonConvert.DeserializeObject<SearchPart>(JsonData.ToString());
  2946. //}
  2947. #region MyRegion
  2948. BaseModel rtn = PLMMap(url, JsonData);
  2949. if (rtn.code == "200")
  2950. {
  2951. //txtGetPLMMap.Text = rtn.msg;
  2952. //panelMap.BringToFront();
  2953. //panel8WebMap.BringToFront();
  2954. //webBrowserMap.Navigate(txtGetPLMMap.Text);
  2955. //string path = string.Empty;
  2956. //path = "E:\\PDF";
  2957. //HttpDownloadFile(txtGetPLMMap.Text, path);
  2958. //SetMessage("", Color.Red);
  2959. //return;
  2960. //ICSSoft.Frame.PLM2MESInterface.Token.GetToken.OperationResult result = ICSSoft.Frame.PLM2MESInterface.Token.GetToken.GetPLMToken();
  2961. //string Token = result.errmsg;
  2962. #region MyRegion
  2963. panelMap.BringToFront();
  2964. this.label23.Visible = false;
  2965. string itemCode = this.txtItemCode.Text;
  2966. //string RouteCode = string.Empty;
  2967. string OpCode = this.txtOPCode.Text;
  2968. //string sql = @"SELECT SOPDrawing from ICSITEMROUTE2OP WHERE ITEMCODE='" + itemCode + "' AND ROUTECODE='" + RouteCode + "' AND OPCODE='" + OpCode + "' ";
  2969. //string connectionString = AppConfig.FrameConnectString; // AppConfig.GetDataBaseConnectStringByKey("[DB.PLM]");
  2970. //string connectionString = AppConfig.GetDataBaseConnectStringByKey("[DB.FTP2]");
  2971. //if (string.IsNullOrWhiteSpace(connectionString))
  2972. // return;
  2973. //string logAdress = ConfigurationManager.AppSettings["PLMAdress"].ToString();
  2974. //object name = DBHelper.ExecuteScalar(connectionString, CommandType.Text, sql);
  2975. //name = "123";
  2976. //if (name == null || string.IsNullOrWhiteSpace(name.ToString()))
  2977. // return;
  2978. //string fileName = "E:\\PDF\\20201015.pdf";
  2979. //string fileName = name.ToString() + itemCode + "\\" + RouteCode + "\\" + OpCode + ".pdf";
  2980. string connectionString = AppConfig.GetDataBaseConnectStringByKey("[DB.FTP]");
  2981. if (string.IsNullOrWhiteSpace(connectionString))
  2982. {
  2983. SetMessage("没有获取到FTP链接,请在数据源中先配置FTP", Color.Red);
  2984. return;
  2985. }
  2986. string[] ftps = connectionString.Split(';');
  2987. string ftpServerIP = ftps[0].Split('=')[1];
  2988. //string ftpRemotePath = ftps[1].Split('=')[1];
  2989. string ftpRemotePath = "";
  2990. string ftpUserID = ftps[2].Split('=')[1];
  2991. string ftpPassword = ftps[3].Split('=')[1];
  2992. FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword);
  2993. //FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword);
  2994. //string filePath = System.IO.Path.GetTempPath() + "\\Drawing";
  2995. string filePath = AppDomain.CurrentDomain.BaseDirectory + "\\Drawing";
  2996. if (!Directory.Exists(filePath))
  2997. {
  2998. Directory.CreateDirectory(filePath);
  2999. }
  3000. string fileName=rtn.msg+ ".pdf";
  3001. ftpWeb.Download(filePath + "\\", fileName);
  3002. string filePathName = filePath + "\\" + fileName;
  3003. //string fileName = logAdress + Bills.ItemCode + ".pdf";
  3004. string ftpURL = "ftp://" + ftpServerIP + "/" + fileName;
  3005. //if (!string.IsNullOrEmpty(fileName))
  3006. if (!string.IsNullOrEmpty(filePathName))
  3007. {
  3008. //axAcroPDF.LoadFile(fileName);
  3009. axAcroPDF.LoadFile(filePathName);
  3010. axAcroPDF.setShowToolbar(false);
  3011. axAcroPDF.setShowScrollbars(false);
  3012. axAcroPDF.setPageMode("thumbs");
  3013. axAcroPDF.setLayoutMode("SinglePage");
  3014. axAcroPDF.setView("Fit");
  3015. axAcroPDF.Show();
  3016. }
  3017. #endregion
  3018. }
  3019. else
  3020. {
  3021. SetMessage("调用PLM接口返回异常:" + rtn.code + ";" + rtn.msg, Color.Red);
  3022. return;
  3023. }
  3024. #endregion
  3025. }
  3026. catch (Exception ex)
  3027. {
  3028. MessageBox.Show(ex.Message);
  3029. }
  3030. }
  3031. #endregion
  3032. #region 工序卡3 SIP
  3033. private void BtnSIP_Click(object sender, EventArgs e)
  3034. {
  3035. try
  3036. {
  3037. initcolor();
  3038. BtnSIP.BackColor = Color.Aqua;
  3039. string url = @"http://172.16.12.155:8999/api/GetPLMToken3";
  3040. //string url = @"http://localhost:51182/api/GetPLMToken3";
  3041. SearchPart Bills = new SearchPart();
  3042. //Bills.ItemCode = "20100003035";
  3043. //Bills.ItemCode = "20100000670";
  3044. //Bills.ItemCode = "20800001904";
  3045. Bills.ItemCode = txtItemCode.Text;
  3046. if (string.IsNullOrWhiteSpace(txtItemCode.Text))
  3047. {
  3048. SetMessage("请先输入料号编码", Color.Red);
  3049. return;
  3050. }
  3051. if (string.IsNullOrEmpty(opseq)) {
  3052. SetMessage("请先输入正确工序!", Color.Red);
  3053. return;
  3054. }
  3055. Bills.size = 100;
  3056. Bills.extra = "DWGSW";
  3057. Bills.routecode = RouteCode;
  3058. Bills.opseq = opseq;
  3059. string JsonData = JsonConvert.SerializeObject(Bills);
  3060. //try
  3061. //{
  3062. // //Bills = JsonConvert.DeserializeObject<List<SearchPart>>(JsonData.ToString());
  3063. // Bills = JsonConvert.DeserializeObject<SearchPart>(JsonData.ToString());
  3064. //}
  3065. #region MyRegion
  3066. BaseModel rtn = PLMMap(url, JsonData);
  3067. if (rtn.code == "200")
  3068. {
  3069. //txtGetPLMMap.Text = rtn.msg;
  3070. //panelMap.BringToFront();
  3071. //panel8WebMap.BringToFront();
  3072. //webBrowserMap.Navigate(txtGetPLMMap.Text);
  3073. //string path = string.Empty;
  3074. //path = "E:\\PDF";
  3075. //HttpDownloadFile(txtGetPLMMap.Text, path);
  3076. //SetMessage("", Color.Red);
  3077. //return;
  3078. //ICSSoft.Frame.PLM2MESInterface.Token.GetToken.OperationResult result = ICSSoft.Frame.PLM2MESInterface.Token.GetToken.GetPLMToken();
  3079. //string Token = result.errmsg;
  3080. #region MyRegion
  3081. panelMap.BringToFront();
  3082. this.label23.Visible = false;
  3083. string itemCode = this.txtItemCode.Text;
  3084. //string RouteCode = string.Empty;
  3085. string OpCode = this.txtOPCode.Text;
  3086. //string sql = @"SELECT SOPDrawing from ICSITEMROUTE2OP WHERE ITEMCODE='" + itemCode + "' AND ROUTECODE='" + RouteCode + "' AND OPCODE='" + OpCode + "' ";
  3087. //string connectionString = AppConfig.FrameConnectString; // AppConfig.GetDataBaseConnectStringByKey("[DB.PLM]");
  3088. //string connectionString = AppConfig.GetDataBaseConnectStringByKey("[DB.FTP2]");
  3089. //if (string.IsNullOrWhiteSpace(connectionString))
  3090. // return;
  3091. //string logAdress = ConfigurationManager.AppSettings["PLMAdress"].ToString();
  3092. //object name = DBHelper.ExecuteScalar(connectionString, CommandType.Text, sql);
  3093. //name = "123";
  3094. //if (name == null || string.IsNullOrWhiteSpace(name.ToString()))
  3095. // return;
  3096. //string fileName = "E:\\PDF\\20201015.pdf";
  3097. //string fileName = name.ToString() + itemCode + "\\" + RouteCode + "\\" + OpCode + ".pdf";
  3098. string connectionString = AppConfig.GetDataBaseConnectStringByKey("[DB.FTP]");
  3099. if (string.IsNullOrWhiteSpace(connectionString))
  3100. {
  3101. SetMessage("没有获取到FTP链接,请在数据源中先配置FTP", Color.Red);
  3102. return;
  3103. }
  3104. string[] ftps = connectionString.Split(';');
  3105. string ftpServerIP = ftps[0].Split('=')[1];
  3106. //string ftpRemotePath = ftps[1].Split('=')[1];
  3107. string ftpRemotePath = "";
  3108. string ftpUserID = ftps[2].Split('=')[1];
  3109. string ftpPassword = ftps[3].Split('=')[1];
  3110. FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword);
  3111. //FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword);
  3112. //string filePath = System.IO.Path.GetTempPath() + "\\Drawing";
  3113. string filePath = AppDomain.CurrentDomain.BaseDirectory + "\\Drawing";
  3114. if (!Directory.Exists(filePath))
  3115. {
  3116. Directory.CreateDirectory(filePath);
  3117. }
  3118. string fileName = rtn.msg+ ".pdf";
  3119. ftpWeb.Download(filePath + "\\", fileName);
  3120. string filePathName = filePath + "\\" + fileName;
  3121. //string fileName = logAdress + Bills.ItemCode + ".pdf";
  3122. string ftpURL = "ftp://" + ftpServerIP + "/" + fileName;
  3123. //if (!string.IsNullOrEmpty(fileName))
  3124. if (!string.IsNullOrEmpty(filePathName))
  3125. {
  3126. //axAcroPDF.LoadFile(fileName);
  3127. axAcroPDF.LoadFile(filePathName);
  3128. axAcroPDF.setShowToolbar(false);
  3129. axAcroPDF.setShowScrollbars(false);
  3130. axAcroPDF.setPageMode("thumbs");
  3131. axAcroPDF.setLayoutMode("SinglePage");
  3132. axAcroPDF.setView("Fit");
  3133. axAcroPDF.Show();
  3134. }
  3135. #endregion
  3136. }
  3137. else
  3138. {
  3139. SetMessage("调用PLM接口返回异常:" + rtn.code + ";" + rtn.msg, Color.Red);
  3140. return;
  3141. }
  3142. #endregion
  3143. }
  3144. catch (Exception ex)
  3145. {
  3146. MessageBox.Show(ex.Message);
  3147. }
  3148. }
  3149. #endregion
  3150. #region 作业指导书4
  3151. private void btnOPDrowing_Click(object sender, EventArgs e)
  3152. {
  3153. try
  3154. {
  3155. initcolor();
  3156. btnOPDrowing.BackColor = Color.Aqua;
  3157. string url = @"http://172.16.12.155:9999/api/GetPLMToken8";
  3158. //string url = @"http://localhost:51182/api/GetPLMToken8";
  3159. SearchPart Bills = new SearchPart();
  3160. //Bills.ItemCode = "20100003035";
  3161. //Bills.ItemCode = "20100000670";
  3162. //Bills.ItemCode = "20800001904";
  3163. Bills.ItemCode = txtItemCode.Text;
  3164. if (string.IsNullOrWhiteSpace(txtItemCode.Text))
  3165. {
  3166. SetMessage("请先输入料号编码", Color.Red);
  3167. return;
  3168. }
  3169. if (string.IsNullOrEmpty(opseq))
  3170. {
  3171. SetMessage("请先输入正确工序!", Color.Red);
  3172. return;
  3173. }
  3174. Bills.size = 100;
  3175. Bills.extra = "DWGSW";
  3176. Bills.routecode = RouteCode;
  3177. Bills.opseq = opseq;
  3178. string JsonData = JsonConvert.SerializeObject(Bills);
  3179. //try
  3180. //{
  3181. // //Bills = JsonConvert.DeserializeObject<List<SearchPart>>(JsonData.ToString());
  3182. // Bills = JsonConvert.DeserializeObject<SearchPart>(JsonData.ToString());
  3183. //}
  3184. #region MyRegion
  3185. BaseModel rtn = PLMMap(url, JsonData);
  3186. if (rtn.code == "200")
  3187. {
  3188. //txtGetPLMMap.Text = rtn.msg;
  3189. //panelMap.BringToFront();
  3190. //panel8WebMap.BringToFront();
  3191. //webBrowserMap.Navigate(txtGetPLMMap.Text);
  3192. //string path = string.Empty;
  3193. //path = "E:\\PDF";
  3194. //HttpDownloadFile(txtGetPLMMap.Text, path);
  3195. //SetMessage("", Color.Red);
  3196. //return;
  3197. //ICSSoft.Frame.PLM2MESInterface.Token.GetToken.OperationResult result = ICSSoft.Frame.PLM2MESInterface.Token.GetToken.GetPLMToken();
  3198. //string Token = result.errmsg;
  3199. #region MyRegion
  3200. panelMap.BringToFront();
  3201. this.label23.Visible = false;
  3202. string itemCode = this.txtItemCode.Text;
  3203. //string RouteCode = string.Empty;
  3204. string OpCode = this.txtOPCode.Text;
  3205. //string sql = @"SELECT SOPDrawing from ICSITEMROUTE2OP WHERE ITEMCODE='" + itemCode + "' AND ROUTECODE='" + RouteCode + "' AND OPCODE='" + OpCode + "' ";
  3206. //string connectionString = AppConfig.FrameConnectString; // AppConfig.GetDataBaseConnectStringByKey("[DB.PLM]");
  3207. //string connectionString = AppConfig.GetDataBaseConnectStringByKey("[DB.FTP2]");
  3208. //if (string.IsNullOrWhiteSpace(connectionString))
  3209. // return;
  3210. //string logAdress = ConfigurationManager.AppSettings["PLMAdress"].ToString();
  3211. //object name = DBHelper.ExecuteScalar(connectionString, CommandType.Text, sql);
  3212. //name = "123";
  3213. //if (name == null || string.IsNullOrWhiteSpace(name.ToString()))
  3214. // return;
  3215. //string fileName = "E:\\PDF\\20201015.pdf";
  3216. //string fileName = name.ToString() + itemCode + "\\" + RouteCode + "\\" + OpCode + ".pdf";
  3217. string connectionString = AppConfig.GetDataBaseConnectStringByKey("[DB.FTP]");
  3218. if (string.IsNullOrWhiteSpace(connectionString))
  3219. {
  3220. SetMessage("没有获取到FTP链接,请在数据源中先配置FTP", Color.Red);
  3221. return;
  3222. }
  3223. string[] ftps = connectionString.Split(';');
  3224. string ftpServerIP = ftps[0].Split('=')[1];
  3225. //string ftpRemotePath = ftps[1].Split('=')[1];
  3226. string ftpRemotePath = "";
  3227. string ftpUserID = ftps[2].Split('=')[1];
  3228. string ftpPassword = ftps[3].Split('=')[1];
  3229. FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword);
  3230. //FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword);
  3231. //string filePath = System.IO.Path.GetTempPath() + "\\Drawing";
  3232. string filePath = AppDomain.CurrentDomain.BaseDirectory + "\\Drawing";
  3233. if (!Directory.Exists(filePath))
  3234. {
  3235. Directory.CreateDirectory(filePath);
  3236. }
  3237. string fileName = rtn.msg + ".pdf";
  3238. ftpWeb.Download(filePath + "\\", fileName);
  3239. string filePathName = filePath + "\\" + fileName;
  3240. //string fileName = logAdress + Bills.ItemCode + ".pdf";
  3241. string ftpURL = "ftp://" + ftpServerIP + "/" + fileName;
  3242. //if (!string.IsNullOrEmpty(fileName))
  3243. if (!string.IsNullOrEmpty(filePathName))
  3244. {
  3245. //axAcroPDF.LoadFile(fileName);
  3246. axAcroPDF.LoadFile(filePathName);
  3247. axAcroPDF.setShowToolbar(false);
  3248. axAcroPDF.setShowScrollbars(false);
  3249. axAcroPDF.setPageMode("thumbs");
  3250. axAcroPDF.setLayoutMode("SinglePage");
  3251. axAcroPDF.setView("Fit");
  3252. axAcroPDF.Show();
  3253. }
  3254. #endregion
  3255. }
  3256. else
  3257. {
  3258. SetMessage("调用PLM接口返回异常:" + rtn.code + ";" + rtn.msg, Color.Red);
  3259. return;
  3260. }
  3261. #endregion
  3262. }
  3263. catch (Exception ex)
  3264. {
  3265. MessageBox.Show(ex.Message);
  3266. }
  3267. }
  3268. #endregion
  3269. #region 检验判定书5
  3270. private void btnJianYan_Click(object sender, EventArgs e)
  3271. {
  3272. try
  3273. {
  3274. initcolor();
  3275. btnJianYan.BackColor = Color.Aqua;
  3276. string url = @"http://172.16.12.155:8999/api/GetPLMToken5";
  3277. //string url = @"http://localhost:51182/api/GetPLMToken5";
  3278. SearchPart Bills = new SearchPart();
  3279. //Bills.ItemCode = "20100003035";
  3280. //Bills.ItemCode = "20100000670";
  3281. //Bills.ItemCode = "20800001904";
  3282. Bills.ItemCode = txtItemCode.Text;
  3283. if (string.IsNullOrWhiteSpace(txtItemCode.Text))
  3284. {
  3285. SetMessage("请先输入料号编码", Color.Red);
  3286. return;
  3287. }
  3288. if (string.IsNullOrEmpty(opseq))
  3289. {
  3290. SetMessage("请先输入正确工序!", Color.Red);
  3291. return;
  3292. }
  3293. Bills.size = 100;
  3294. Bills.extra = "DWGSW";
  3295. Bills.routecode = RouteCode;
  3296. Bills.opseq = opseq;
  3297. string JsonData = JsonConvert.SerializeObject(Bills);
  3298. //try
  3299. //{
  3300. // //Bills = JsonConvert.DeserializeObject<List<SearchPart>>(JsonData.ToString());
  3301. // Bills = JsonConvert.DeserializeObject<SearchPart>(JsonData.ToString());
  3302. //}
  3303. #region MyRegion
  3304. BaseModel rtn = PLMMap(url, JsonData);
  3305. if (rtn.code == "200")
  3306. {
  3307. //txtGetPLMMap.Text = rtn.msg;
  3308. //panelMap.BringToFront();
  3309. //panel8WebMap.BringToFront();
  3310. //webBrowserMap.Navigate(txtGetPLMMap.Text);
  3311. //string path = string.Empty;
  3312. //path = "E:\\PDF";
  3313. //HttpDownloadFile(txtGetPLMMap.Text, path);
  3314. //SetMessage("", Color.Red);
  3315. //return;
  3316. //ICSSoft.Frame.PLM2MESInterface.Token.GetToken.OperationResult result = ICSSoft.Frame.PLM2MESInterface.Token.GetToken.GetPLMToken();
  3317. //string Token = result.errmsg;
  3318. #region MyRegion
  3319. panelMap.BringToFront();
  3320. this.label23.Visible = false;
  3321. string itemCode = this.txtItemCode.Text;
  3322. //string RouteCode = string.Empty;
  3323. string OpCode = this.txtOPCode.Text;
  3324. //string sql = @"SELECT SOPDrawing from ICSITEMROUTE2OP WHERE ITEMCODE='" + itemCode + "' AND ROUTECODE='" + RouteCode + "' AND OPCODE='" + OpCode + "' ";
  3325. //string connectionString = AppConfig.FrameConnectString; // AppConfig.GetDataBaseConnectStringByKey("[DB.PLM]");
  3326. //string connectionString = AppConfig.GetDataBaseConnectStringByKey("[DB.FTP2]");
  3327. //if (string.IsNullOrWhiteSpace(connectionString))
  3328. // return;
  3329. //string logAdress = ConfigurationManager.AppSettings["PLMAdress"].ToString();
  3330. //object name = DBHelper.ExecuteScalar(connectionString, CommandType.Text, sql);
  3331. //name = "123";
  3332. //if (name == null || string.IsNullOrWhiteSpace(name.ToString()))
  3333. // return;
  3334. //string fileName = "E:\\PDF\\20201015.pdf";
  3335. //string fileName = name.ToString() + itemCode + "\\" + RouteCode + "\\" + OpCode + ".pdf";
  3336. string connectionString = AppConfig.GetDataBaseConnectStringByKey("[DB.FTP]");
  3337. if (string.IsNullOrWhiteSpace(connectionString))
  3338. {
  3339. SetMessage("没有获取到FTP链接,请在数据源中先配置FTP", Color.Red);
  3340. return;
  3341. }
  3342. string[] ftps = connectionString.Split(';');
  3343. string ftpServerIP = ftps[0].Split('=')[1];
  3344. //string ftpRemotePath = ftps[1].Split('=')[1];
  3345. string ftpRemotePath = "";
  3346. string ftpUserID = ftps[2].Split('=')[1];
  3347. string ftpPassword = ftps[3].Split('=')[1];
  3348. FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword);
  3349. //FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword);
  3350. //string filePath = System.IO.Path.GetTempPath() + "\\Drawing";
  3351. string filePath = AppDomain.CurrentDomain.BaseDirectory + "\\Drawing";
  3352. if (!Directory.Exists(filePath))
  3353. {
  3354. Directory.CreateDirectory(filePath);
  3355. }
  3356. string fileName = rtn.msg + ".pdf";
  3357. ftpWeb.Download(filePath + "\\", fileName);
  3358. string filePathName = filePath + "\\" + fileName;
  3359. //string fileName = logAdress + Bills.ItemCode + ".pdf";
  3360. string ftpURL = "ftp://" + ftpServerIP + "/" + fileName;
  3361. //if (!string.IsNullOrEmpty(fileName))
  3362. if (!string.IsNullOrEmpty(filePathName))
  3363. {
  3364. //axAcroPDF.LoadFile(fileName);
  3365. axAcroPDF.LoadFile(filePathName);
  3366. axAcroPDF.setShowToolbar(false);
  3367. axAcroPDF.setShowScrollbars(false);
  3368. axAcroPDF.setPageMode("thumbs");
  3369. axAcroPDF.setLayoutMode("SinglePage");
  3370. axAcroPDF.setView("Fit");
  3371. axAcroPDF.Show();
  3372. }
  3373. #endregion
  3374. }
  3375. else
  3376. {
  3377. SetMessage("调用PLM接口返回异常:" + rtn.code + ";" + rtn.msg, Color.Red);
  3378. return;
  3379. }
  3380. #endregion
  3381. }
  3382. catch (Exception ex)
  3383. {
  3384. MessageBox.Show(ex.Message);
  3385. }
  3386. }
  3387. #endregion
  3388. #region 刀具清单6
  3389. private void btnDaoJu_Click(object sender, EventArgs e)
  3390. {
  3391. try
  3392. {
  3393. initcolor();
  3394. btnDaoJu.BackColor = Color.Aqua;
  3395. string url = @"http://172.16.12.155:8999/api/GetPLMToken6";
  3396. //string url = @"http://localhost:51182/api/GetPLMToken6";
  3397. SearchPart Bills = new SearchPart();
  3398. //Bills.ItemCode = "20100003035";
  3399. //Bills.ItemCode = "20100000670";
  3400. //Bills.ItemCode = "20800001904";
  3401. Bills.ItemCode = txtItemCode.Text;
  3402. if (string.IsNullOrWhiteSpace(txtItemCode.Text))
  3403. {
  3404. SetMessage("请先输入料号编码", Color.Red);
  3405. return;
  3406. }
  3407. if (string.IsNullOrEmpty(opseq))
  3408. {
  3409. SetMessage("请先输入正确工序!", Color.Red);
  3410. return;
  3411. }
  3412. Bills.size = 100;
  3413. Bills.extra = "DWGSW";
  3414. Bills.routecode = RouteCode;
  3415. Bills.opseq = opseq;
  3416. string JsonData = JsonConvert.SerializeObject(Bills);
  3417. //try
  3418. //{
  3419. // //Bills = JsonConvert.DeserializeObject<List<SearchPart>>(JsonData.ToString());
  3420. // Bills = JsonConvert.DeserializeObject<SearchPart>(JsonData.ToString());
  3421. //}
  3422. #region MyRegion
  3423. BaseModel rtn = PLMMap(url, JsonData);
  3424. if (rtn.code == "200")
  3425. {
  3426. //txtGetPLMMap.Text = rtn.msg;
  3427. //panelMap.BringToFront();
  3428. //panel8WebMap.BringToFront();
  3429. //webBrowserMap.Navigate(txtGetPLMMap.Text);
  3430. //string path = string.Empty;
  3431. //path = "E:\\PDF";
  3432. //HttpDownloadFile(txtGetPLMMap.Text, path);
  3433. //SetMessage("", Color.Red);
  3434. //return;
  3435. //ICSSoft.Frame.PLM2MESInterface.Token.GetToken.OperationResult result = ICSSoft.Frame.PLM2MESInterface.Token.GetToken.GetPLMToken();
  3436. //string Token = result.errmsg;
  3437. #region MyRegion
  3438. panelMap.BringToFront();
  3439. this.label23.Visible = false;
  3440. string itemCode = this.txtItemCode.Text;
  3441. //string RouteCode = string.Empty;
  3442. string OpCode = this.txtOPCode.Text;
  3443. //string sql = @"SELECT SOPDrawing from ICSITEMROUTE2OP WHERE ITEMCODE='" + itemCode + "' AND ROUTECODE='" + RouteCode + "' AND OPCODE='" + OpCode + "' ";
  3444. //string connectionString = AppConfig.FrameConnectString; // AppConfig.GetDataBaseConnectStringByKey("[DB.PLM]");
  3445. //string connectionString = AppConfig.GetDataBaseConnectStringByKey("[DB.FTP2]");
  3446. //if (string.IsNullOrWhiteSpace(connectionString))
  3447. // return;
  3448. //string logAdress = ConfigurationManager.AppSettings["PLMAdress"].ToString();
  3449. //object name = DBHelper.ExecuteScalar(connectionString, CommandType.Text, sql);
  3450. //name = "123";
  3451. //if (name == null || string.IsNullOrWhiteSpace(name.ToString()))
  3452. // return;
  3453. //string fileName = "E:\\PDF\\20201015.pdf";
  3454. //string fileName = name.ToString() + itemCode + "\\" + RouteCode + "\\" + OpCode + ".pdf";
  3455. string connectionString = AppConfig.GetDataBaseConnectStringByKey("[DB.FTP]");
  3456. if (string.IsNullOrWhiteSpace(connectionString))
  3457. {
  3458. SetMessage("没有获取到FTP链接,请在数据源中先配置FTP", Color.Red);
  3459. return;
  3460. }
  3461. string[] ftps = connectionString.Split(';');
  3462. string ftpServerIP = ftps[0].Split('=')[1];
  3463. //string ftpRemotePath = ftps[1].Split('=')[1];
  3464. string ftpRemotePath = "";
  3465. string ftpUserID = ftps[2].Split('=')[1];
  3466. string ftpPassword = ftps[3].Split('=')[1];
  3467. FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword);
  3468. //FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword);
  3469. //string filePath = System.IO.Path.GetTempPath() + "\\Drawing";
  3470. string filePath = AppDomain.CurrentDomain.BaseDirectory + "\\Drawing";
  3471. if (!Directory.Exists(filePath))
  3472. {
  3473. Directory.CreateDirectory(filePath);
  3474. }
  3475. string fileName = rtn.msg + ".pdf";
  3476. ftpWeb.Download(filePath + "\\", fileName);
  3477. string filePathName = filePath + "\\" + fileName;
  3478. //string fileName = logAdress + Bills.ItemCode + ".pdf";
  3479. string ftpURL = "ftp://" + ftpServerIP + "/" + fileName;
  3480. //if (!string.IsNullOrEmpty(fileName))
  3481. if (!string.IsNullOrEmpty(filePathName))
  3482. {
  3483. //axAcroPDF.LoadFile(fileName);
  3484. axAcroPDF.LoadFile(filePathName);
  3485. axAcroPDF.setShowToolbar(false);
  3486. axAcroPDF.setShowScrollbars(false);
  3487. axAcroPDF.setPageMode("thumbs");
  3488. axAcroPDF.setLayoutMode("SinglePage");
  3489. axAcroPDF.setView("Fit");
  3490. axAcroPDF.Show();
  3491. }
  3492. #endregion
  3493. }
  3494. else
  3495. {
  3496. SetMessage("调用PLM接口返回异常:" + rtn.code + ";" + rtn.msg, Color.Red);
  3497. return;
  3498. }
  3499. #endregion
  3500. }
  3501. catch (Exception ex)
  3502. {
  3503. MessageBox.Show(ex.Message);
  3504. }
  3505. }
  3506. #endregion
  3507. #region 操作指导书7
  3508. private void btnCaoZuo_Click(object sender, EventArgs e)
  3509. {
  3510. //initcolor();
  3511. //btnCaoZuo.BackColor = Color.Aqua;
  3512. //this.label23.Visible = false;
  3513. try
  3514. {
  3515. initcolor();
  3516. btnCaoZuo.BackColor = Color.Aqua;
  3517. string url = @"http://172.16.12.155:8999/api/GetPLMToken7";
  3518. //string url = @"http://localhost:51182/api/GetPLMToken7";
  3519. SearchPart Bills = new SearchPart();
  3520. //Bills.ItemCode = "20100003035";
  3521. //Bills.ItemCode = "20100000670";
  3522. //Bills.ItemCode = "20800001904";
  3523. Bills.ItemCode = txtItemCode.Text;
  3524. if (string.IsNullOrWhiteSpace(txtItemCode.Text))
  3525. {
  3526. SetMessage("请先输入料号编码", Color.Red);
  3527. return;
  3528. }
  3529. if (string.IsNullOrEmpty(opseq))
  3530. {
  3531. SetMessage("请先输入正确工序!", Color.Red);
  3532. return;
  3533. }
  3534. Bills.size = 100;
  3535. Bills.extra = "DWGSW";
  3536. Bills.routecode = RouteCode;
  3537. Bills.opseq = opseq;
  3538. string JsonData = JsonConvert.SerializeObject(Bills);
  3539. //try
  3540. //{
  3541. // //Bills = JsonConvert.DeserializeObject<List<SearchPart>>(JsonData.ToString());
  3542. // Bills = JsonConvert.DeserializeObject<SearchPart>(JsonData.ToString());
  3543. //}
  3544. #region MyRegion
  3545. BaseModel rtn = PLMMap(url, JsonData);
  3546. if (rtn.code == "200")
  3547. {
  3548. //txtGetPLMMap.Text = rtn.msg;
  3549. //panelMap.BringToFront();
  3550. //panel8WebMap.BringToFront();
  3551. //webBrowserMap.Navigate(txtGetPLMMap.Text);
  3552. //string path = string.Empty;
  3553. //path = "E:\\PDF";
  3554. //HttpDownloadFile(txtGetPLMMap.Text, path);
  3555. //SetMessage("", Color.Red);
  3556. //return;
  3557. //ICSSoft.Frame.PLM2MESInterface.Token.GetToken.OperationResult result = ICSSoft.Frame.PLM2MESInterface.Token.GetToken.GetPLMToken();
  3558. //string Token = result.errmsg;
  3559. #region MyRegion
  3560. panelMap.BringToFront();
  3561. this.label23.Visible = false;
  3562. string itemCode = this.txtItemCode.Text;
  3563. //string RouteCode = string.Empty;
  3564. string OpCode = this.txtOPCode.Text;
  3565. //string sql = @"SELECT SOPDrawing from ICSITEMROUTE2OP WHERE ITEMCODE='" + itemCode + "' AND ROUTECODE='" + RouteCode + "' AND OPCODE='" + OpCode + "' ";
  3566. //string connectionString = AppConfig.FrameConnectString; // AppConfig.GetDataBaseConnectStringByKey("[DB.PLM]");
  3567. //string connectionString = AppConfig.GetDataBaseConnectStringByKey("[DB.FTP2]");
  3568. //if (string.IsNullOrWhiteSpace(connectionString))
  3569. // return;
  3570. //string logAdress = ConfigurationManager.AppSettings["PLMAdress"].ToString();
  3571. //object name = DBHelper.ExecuteScalar(connectionString, CommandType.Text, sql);
  3572. //name = "123";
  3573. //if (name == null || string.IsNullOrWhiteSpace(name.ToString()))
  3574. // return;
  3575. //string fileName = "E:\\PDF\\20201015.pdf";
  3576. //string fileName = name.ToString() + itemCode + "\\" + RouteCode + "\\" + OpCode + ".pdf";
  3577. string connectionString = AppConfig.GetDataBaseConnectStringByKey("[DB.FTP]");
  3578. if (string.IsNullOrWhiteSpace(connectionString))
  3579. {
  3580. SetMessage("没有获取到FTP链接,请在数据源中先配置FTP", Color.Red);
  3581. return;
  3582. }
  3583. string[] ftps = connectionString.Split(';');
  3584. string ftpServerIP = ftps[0].Split('=')[1];
  3585. //string ftpRemotePath = ftps[1].Split('=')[1];
  3586. string ftpRemotePath = "";
  3587. string ftpUserID = ftps[2].Split('=')[1];
  3588. string ftpPassword = ftps[3].Split('=')[1];
  3589. FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword);
  3590. //FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword);
  3591. //string filePath = System.IO.Path.GetTempPath() + "\\Drawing";
  3592. string filePath = AppDomain.CurrentDomain.BaseDirectory + "\\Drawing";
  3593. if (!Directory.Exists(filePath))
  3594. {
  3595. Directory.CreateDirectory(filePath);
  3596. }
  3597. string fileName = rtn.msg+".pdf";
  3598. ftpWeb.Download(filePath + "\\", fileName);
  3599. string filePathName = filePath + "\\" + fileName;
  3600. //string fileName = logAdress + Bills.ItemCode + ".pdf";
  3601. string ftpURL = "ftp://" + ftpServerIP + "/" + fileName;
  3602. //if (!string.IsNullOrEmpty(fileName))
  3603. if (!string.IsNullOrEmpty(filePathName))
  3604. {
  3605. //axAcroPDF.LoadFile(fileName);
  3606. axAcroPDF.LoadFile(filePathName);
  3607. axAcroPDF.setShowToolbar(false);
  3608. axAcroPDF.setShowScrollbars(false);
  3609. axAcroPDF.setPageMode("thumbs");
  3610. axAcroPDF.setLayoutMode("SinglePage");
  3611. axAcroPDF.setView("Fit");
  3612. axAcroPDF.Show();
  3613. }
  3614. #endregion
  3615. }
  3616. else
  3617. {
  3618. SetMessage("调用PLM接口返回异常:" + rtn.code + ";" + rtn.msg, Color.Red);
  3619. return;
  3620. }
  3621. #endregion
  3622. }
  3623. catch (Exception ex)
  3624. {
  3625. MessageBox.Show(ex.Message);
  3626. }
  3627. }
  3628. #endregion
  3629. #region 工序上料
  3630. public ICSLOTSIMULATION GetSimulationByLotNo(string LotNo)
  3631. {
  3632. string sql = @"select * from ICSLOTSIMULATION
  3633. where LOTNO = '" + LotNo + "' order by MTIME desc";
  3634. var objs = this._domainDataProvider.ExecuteQuery<ICSLOTSIMULATION>(sql).ToList();
  3635. if (objs == null || objs.Count < 1)
  3636. return null;
  3637. else
  3638. return (ICSLOTSIMULATION)objs[0];
  3639. }
  3640. private void BtnOPUp_Click(object sender, EventArgs e)
  3641. {
  3642. initcolor();
  3643. BtnOPUp.BackColor = Color.Aqua;
  3644. // BtnOPUp.BackColor = System.Drawing.Color.DeepSkyBlue;
  3645. this.label23.Visible = true;
  3646. panelOP.BringToFront();
  3647. //this.txtSBItemCode.Text = txtLotNo.Text;
  3648. //this.txtSBItemCode.Text = txtLotNo.Text;
  3649. if (this.btnOPOption.Text == " 开工")
  3650. {
  3651. List<ICSLOTONWIPITEM> list = new List<ICSLOTONWIPITEM>();
  3652. if (dataUpOPDetail != null && dataUpOPDetail.Rows.Count > 0)
  3653. {
  3654. foreach (DataRow item in dataUpOPDetail.Rows)
  3655. {
  3656. //d.QTY UPQty,
  3657. //ICSLOTSIMULATION simulation = GetSimulationByLotNo(this.txtLotNo.Text.Trim());
  3658. //ICSLOTSIMULATIONREPORT simulationReport = _DataCollectFacade.GetLastSimulationReport(this.txtLotNo.Text.Trim());
  3659. ICSLOTONWIPITEM wipItem = new ICSLOTONWIPITEM();
  3660. wipItem.ID = AppConfig.GetGuid();
  3661. wipItem.MOCODE = item["MOCODE"].ToString();
  3662. wipItem.MOSEQ = Int32.Parse(item["TransLine"].ToString());
  3663. wipItem.LOTNO = item["LotNO"].ToString();
  3664. wipItem.ITEMCODE = txtItemCode.Text;//母件编码
  3665. wipItem.INVCODE = item["cInvCode"].ToString();//子件编码
  3666. wipItem.OPCODE = item["OPCode"].ToString();
  3667. wipItem.ROUTECODE = item["MoRoute"].ToString(); ;
  3668. wipItem.QTY = 0;// Convert.ToDecimal(item["iQuantity"].ToString()) / Convert.ToDecimal(txtLONTQty.Text.ToString());
  3669. wipItem.MTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
  3670. wipItem.MUSER = AppConfig.UserCode; ;
  3671. wipItem.MUSERName = AppConfig.UserName;
  3672. wipItem.WorkPoint = AppConfig.WorkPointCode;
  3673. list.Add(wipItem);
  3674. //wipItem.MCARDTYPE = simulation.EATTRIBUTE1;
  3675. //wipItem.RESCODE = simulation.RESCODE;
  3676. //wipItem.SEGCODE = simulationReport.SEGCODE;
  3677. //wipItem.SHIFTTYPECODE = "";
  3678. //wipItem.SSCODE = simulationReport.SSCODE;
  3679. //wipItem.MOCODE = simulation.MOCODE;
  3680. //wipItem.MODELCODE = simulation.MODELCODE;
  3681. //wipItem.DATECODE = luhaoCode;
  3682. //wipItem.BeginSHIFTCODE = simulationReport.SHIFTTYPECODE;
  3683. //wipItem.EndSHIFTCODE = simulationReport.SHIFTTYPECODE;
  3684. //wipItem.BeginTPCODE = "";
  3685. //wipItem.ENDTPCODE = "";
  3686. //wipItem.INVLOTNO = txtKeyPart.Text;
  3687. //wipItem.TRANSSTATUS = TransactionStatus.TransactionStatus_NO;
  3688. //wipItem.MCARDTYPE = MCardType.MCardType_INNO;
  3689. //wipItem.LOTSEQ = (int)simulation.LOTSEQ;
  3690. //新增 采集类型
  3691. //wipItem.ACTIONTYPE = (int)Enum.Parse(typeof(MaterialType), "CollectMaterial");
  3692. }
  3693. ICSDataCollectionBLL.CollectOPUP(list, "1", AppConfig.AppConnectString);
  3694. SetMessage("工序上料成功!", Color.Blue);
  3695. }
  3696. }
  3697. if (this.btnOPOption.Text == " 完工")
  3698. {
  3699. if (true)
  3700. {
  3701. }
  3702. }
  3703. }
  3704. #endregion
  3705. private void button1_Click_1(object sender, EventArgs e)
  3706. {
  3707. if (string.IsNullOrEmpty(lotno))
  3708. {
  3709. ICSBaseSimpleCode.AppshowMessageBox("请先输入正确追踪单号!");
  3710. return;
  3711. }
  3712. FormICSPictureNew form = new FormICSPictureNew(this.lotno);
  3713. form.ShowDialog();
  3714. }
  3715. private void repositoryItemCheckEdit3_QueryValueByCheckState(object sender, DevExpress.XtraEditors.Controls.QueryValueByCheckStateEventArgs e)
  3716. {
  3717. int rowhandle = gridViewCC.FocusedRowHandle;
  3718. if (e.CheckState == CheckState.Checked)
  3719. {
  3720. gridViewCC.SetRowCellValue(rowhandle, CCOK, true);
  3721. gridViewCC.SetRowCellValue(rowhandle, CCNG, false);
  3722. }
  3723. else
  3724. {
  3725. gridViewCC.SetRowCellValue(rowhandle, CCOK, false);
  3726. }
  3727. #region
  3728. //try
  3729. //{
  3730. // if (gridViewCC.FocusedRowHandle < 0)
  3731. // {
  3732. // return;
  3733. // }
  3734. // #region colS1
  3735. // int SNo = gridViewCC.FocusedRowHandle;
  3736. // int SNoCC = gridViewCC.RowCount;
  3737. // for (int i = SNo; i <= SNo; i++)
  3738. // {
  3739. // SendKeys.Send("{Down}");
  3740. // if (SNo == SNoCC - 1)
  3741. // {
  3742. // for (int j = 0; j <= SNoCC - 1; j++)
  3743. // {
  3744. // SendKeys.Send("{Up}");
  3745. // }
  3746. // SendKeys.Send("{RIGHT}");
  3747. // }
  3748. // bool istrue = false;
  3749. // for (int k = 0; k < gridViewCC.RowCount; k++)
  3750. // {
  3751. // #region MyRegion
  3752. // Decimal _VALUEMAX = 0; Decimal _VALUEMIN = 0; Decimal _S1 = 0;
  3753. // if (gridViewCC.GetRowCellValue(k, colSetValueMax) != null)
  3754. // {
  3755. // if (!string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, colSetValueMax).ToString()))
  3756. // {
  3757. // _VALUEMAX = Decimal.Parse(gridViewCC.GetRowCellValue(k, colSetValueMax).ToString());
  3758. // }
  3759. // }
  3760. // if (gridViewCC.GetRowCellValue(k, colSetValueMin) != null)
  3761. // {
  3762. // if (!string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, colSetValueMin).ToString()))
  3763. // {
  3764. // _VALUEMIN = Decimal.Parse(gridViewCC.GetRowCellValue(k, colSetValueMin).ToString());
  3765. // }
  3766. // }
  3767. // if (gridViewCC.GetRowCellValue(k, colCheckResult) != null)
  3768. // {
  3769. // if (!string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, colCheckResult).ToString()))
  3770. // {
  3771. // _S1 = Decimal.Parse(gridViewCC.GetRowCellValue(k, colCheckResult).ToString());
  3772. // }
  3773. // }
  3774. // if ((_S1 < _VALUEMIN || _S1 > _VALUEMAX) && gridViewCC.FocusedColumn.Caption == "检验值" && !string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, colCheckResult).ToString()))
  3775. // {
  3776. // istrue = false;
  3777. // break;
  3778. // }
  3779. // else
  3780. // {
  3781. // istrue = true;
  3782. // }
  3783. // #endregion
  3784. // }
  3785. // if (istrue)
  3786. // {
  3787. // this.txtCCResult.Text = "OK";
  3788. // this.txtCCResult.BackColor = Color.Blue;
  3789. // }
  3790. // else
  3791. // {
  3792. // this.txtCCResult.Text = "NG";
  3793. // this.txtCCResult.BackColor = Color.Red;
  3794. // }
  3795. // }
  3796. // #endregion
  3797. //}
  3798. //catch (Exception ex)
  3799. //{
  3800. // throw new Exception(ex.ToString());
  3801. //}
  3802. #endregion
  3803. #region
  3804. try
  3805. {
  3806. if (gridViewCC.FocusedRowHandle < 0)
  3807. {
  3808. return;
  3809. }
  3810. #region colS1
  3811. int SNo = gridViewCC.FocusedRowHandle;
  3812. int SNoCC = gridViewCC.RowCount;
  3813. for (int i = SNo; i <= SNo; i++)
  3814. {
  3815. bool istrue = false;
  3816. for (int k = 0; k < gridViewCC.RowCount; k++)
  3817. {
  3818. #region MyRegion
  3819. bool _S1 = false;
  3820. if (gridViewCC.GetRowCellValue(k, CCOK) != null)
  3821. {
  3822. if (!string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, CCOK).ToString()))
  3823. {
  3824. string cc = gridViewCC.GetRowCellValue(k, CCOK).ToString();
  3825. if (gridViewCC.GetRowCellValue(k, CCOK).ToString() == "True" || (gridViewCC.GetRowCellValue(k, CCOK).ToString() == "False" && gridViewCC.GetRowCellValue(k, CCNG).ToString() == "False"))
  3826. {
  3827. _S1 = true;
  3828. }
  3829. else
  3830. _S1 = false;
  3831. }
  3832. }
  3833. if (_S1)
  3834. {
  3835. istrue = true;
  3836. }
  3837. else
  3838. {
  3839. istrue = false;
  3840. break;
  3841. }
  3842. #endregion
  3843. }
  3844. if (istrue)
  3845. {
  3846. this.txtCCResult.Text = "OK";
  3847. this.txtCCResult.BackColor = Color.Blue;
  3848. }
  3849. else
  3850. {
  3851. this.txtCCResult.Text = "NG";
  3852. this.txtCCResult.BackColor = Color.Red;
  3853. }
  3854. }
  3855. #endregion
  3856. }
  3857. catch (Exception ex)
  3858. {
  3859. throw new Exception(ex.ToString());
  3860. }
  3861. #endregion
  3862. }
  3863. private void repositoryItemCheckEdit4_QueryValueByCheckState(object sender, DevExpress.XtraEditors.Controls.QueryValueByCheckStateEventArgs e)
  3864. {
  3865. int rowhandle = gridViewCC.FocusedRowHandle;
  3866. if (e.CheckState == CheckState.Checked)
  3867. {
  3868. gridViewCC.SetRowCellValue(rowhandle, CCNG, true);
  3869. gridViewCC.SetRowCellValue(rowhandle, CCOK, false);
  3870. }
  3871. else
  3872. {
  3873. gridViewCC.SetRowCellValue(rowhandle, CCNG, false);
  3874. }
  3875. #region
  3876. try
  3877. {
  3878. if (gridViewCC.FocusedRowHandle < 0)
  3879. {
  3880. return;
  3881. }
  3882. #region colS1
  3883. int SNo = gridViewCC.FocusedRowHandle;
  3884. int SNoCC = gridViewCC.RowCount;
  3885. for (int i = SNo; i <= SNo; i++)
  3886. {
  3887. bool istrue = false;
  3888. for (int k = 0; k < gridViewCC.RowCount; k++)
  3889. {
  3890. #region MyRegion
  3891. bool _S1 = false;
  3892. if (gridViewCC.GetRowCellValue(k, CCOK) != null)
  3893. {
  3894. if (!string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, CCOK).ToString()))
  3895. {
  3896. string cc = gridViewCC.GetRowCellValue(k, CCOK).ToString();
  3897. if (gridViewCC.GetRowCellValue(k, CCOK).ToString() == "True" || (gridViewCC.GetRowCellValue(k, CCOK).ToString() == "False" && gridViewCC.GetRowCellValue(k, CCNG).ToString() == "False"))
  3898. {
  3899. _S1 = true;
  3900. }
  3901. else
  3902. _S1 = false;
  3903. }
  3904. }
  3905. if (_S1)
  3906. {
  3907. istrue = true;
  3908. }
  3909. else
  3910. {
  3911. istrue = false;
  3912. break;
  3913. }
  3914. #endregion
  3915. }
  3916. if (istrue)
  3917. {
  3918. this.txtCCResult.Text = "OK";
  3919. this.txtCCResult.BackColor = Color.Blue;
  3920. }
  3921. else
  3922. {
  3923. this.txtCCResult.Text = "NG";
  3924. this.txtCCResult.BackColor = Color.Red;
  3925. }
  3926. }
  3927. #endregion
  3928. }
  3929. catch (Exception ex)
  3930. {
  3931. throw new Exception(ex.ToString());
  3932. }
  3933. #endregion
  3934. }
  3935. private void GetPLMCKDATA(string itemcode, string routecode, string opseq)
  3936. {
  3937. try
  3938. {
  3939. string url = @"http://172.16.12.155:8999/api/GetPLMCKDATA";
  3940. SearchPart Bills = new SearchPart();
  3941. Bills.opseq = opseq;
  3942. Bills.ItemCode = itemcode;
  3943. Bills.routecode = routecode;
  3944. string opcode = txtOPCode.Text.Trim();
  3945. string JsonData = JsonConvert.SerializeObject(Bills);
  3946. string CKDATA = PLMMap1(url, JsonData);
  3947. JObject jobject = JObject.Parse(CKDATA);
  3948. if (jobject["code"].ToString() == "200")
  3949. {
  3950. string data = jobject["data"].ToString();
  3951. List<Parts> part = new List<Parts>();
  3952. part = (List<Parts>)JsonConvert.DeserializeObject(data, typeof(List<Parts>));
  3953. List<ICSOQCCKGROUP> group = new List<ICSOQCCKGROUP>();
  3954. List<ICSOQCCKLIST> cklist = new List<ICSOQCCKLIST>();
  3955. List<string> RemoveID = new List<string>();
  3956. foreach (Parts p in part)
  3957. {
  3958. ICSOQCCKGROUP g = ICSOQCCKLISTBLL.isExits(p.objNo);
  3959. if (g == null)
  3960. {
  3961. g = new ICSOQCCKGROUP();
  3962. g.ID = AppConfig.GetGuid();
  3963. g.ISREF = "是";
  3964. g.MTIME = DateTime.Now;
  3965. g.MUSER = AppConfig.UserId;
  3966. g.MUSERName = AppConfig.UserName;
  3967. g.CKGROUP = AppConfig.GetSerialCode(AppConfig.AppConnectString, AppConfig.WorkPointCode, "ICSOQCCKGROUP", "CKGROUP", "A" + DateTime.Now.Year.ToString(), 3);
  3968. g.CKGROUPDESC = p.objNo.Split(',')[1];
  3969. g.WorkPoint = AppConfig.WorkPointCode;
  3970. g.CKGROUPDNAME = p.objNo.Split(',')[0];
  3971. group.Add(g);
  3972. }
  3973. ICSOQCCKLIST c = ICSOQCCKLISTBLL.IsExistCKLIST(p.objId);
  3974. if (c == null || (c != null && Convert.ToDateTime(c.EATTRIBUTE1) < Convert.ToDateTime(string.IsNullOrEmpty(p.mtimestr) ? p.ctimestr : p.mtimestr)))
  3975. {
  3976. c = new ICSOQCCKLIST();
  3977. c.ID = p.objId;
  3978. c.CKGROUPCode = g.CKGROUP;
  3979. c.UNIT = p.extra.DW;
  3980. c.WorkPoint = AppConfig.WorkPointCode;
  3981. c.SetValueMax = string.IsNullOrEmpty(p.extra.SX) ? 0 : Convert.ToDecimal(p.extra.SX);
  3982. c.SetValueMin = string.IsNullOrEmpty(p.extra.XX) ? 0 : Convert.ToDecimal(p.extra.XX);
  3983. c.MUSER = AppConfig.UserName;
  3984. c.MTIME = DateTime.Now;
  3985. c.ISREF = "是";
  3986. c.INVCode = p.extra.MPARTNO;
  3987. c.OPCode = opcode;
  3988. c.CKGROUPMETH = "工序检验";
  3989. c.CKGROUPATTR = p.extra.SX1;
  3990. c.GJ = p.extra.GJ;
  3991. c.JY1 = p.extra.JY1;
  3992. c.JY2 = p.extra.JY2;
  3993. c.PType = Convert.ToDecimal(p.extra.PTYPE);
  3994. c.StandValue = p.extra.NAME;
  3995. if (!string.IsNullOrEmpty(p.mtimestr))
  3996. c.EATTRIBUTE1 = p.mtimestr;
  3997. else
  3998. c.EATTRIBUTE1 = p.ctimestr;
  3999. cklist.Add(c);
  4000. }
  4001. RemoveID.Add(p.objId);
  4002. }
  4003. ICSOQCCKLISTBLL.AddGroupAndList(group, cklist, RemoveID, itemcode, opcode);
  4004. }
  4005. else
  4006. {
  4007. if (jobject["msg"].ToString() != "没有更多了")
  4008. throw new Exception(jobject["msg"].ToString());
  4009. }
  4010. }
  4011. catch (Exception ex)
  4012. {
  4013. throw ex;
  4014. }
  4015. }
  4016. public class Parts
  4017. {
  4018. public string errcode { get; set; }
  4019. public string errmsg { get; set; }
  4020. public string objId { get; set; }
  4021. public string objNo { get; set; }
  4022. public string fname { get; set; }
  4023. public string suffix { get; set; }
  4024. public string hasAffine { get; set; }
  4025. public string name { get; set; }
  4026. public string fsize { get; set; }
  4027. public string fsizeStr { get; set; }
  4028. public string type { get; set; }
  4029. public string tablename { get; set; }
  4030. public string smemo { get; set; }
  4031. public string ctimestr { get; set; }
  4032. public string mtimestr { get; set; }
  4033. public string creator { get; set; }
  4034. public string modifier { get; set; }
  4035. public string ver { get; set; }
  4036. public string stimestr { get; set; }
  4037. public string etimestr { get; set; }
  4038. public Extra extra { get; set; }
  4039. public string searchText { get; set; }
  4040. }
  4041. public class Extra
  4042. {
  4043. public string PTYPE;
  4044. public string XX;
  4045. public string NAME;
  4046. public string SX;
  4047. public string DW;
  4048. public string JY2;
  4049. public string SX1;
  4050. public string GJ;
  4051. public string JY1;
  4052. public string GG;
  4053. public string SMEMO;
  4054. public string MPARTNO;
  4055. }
  4056. private void txtItemCode_TextChanged(object sender, EventArgs e)
  4057. {
  4058. }
  4059. private void txtLotNo_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  4060. {
  4061. if (txtUserCode.Text.Trim() == "" || txtEQPCode.Text.Trim() == "") {
  4062. ICSBaseSimpleCode.AppshowMessageBox("请先输入员工条码和设备!");
  4063. return;
  4064. }
  4065. string usercode = txtUserCode.Text.Trim();
  4066. string eqpcode = txtEQPCode.Text.Trim();
  4067. string username = txtUserName.Text.Trim();
  4068. string eqpname = txtMachineName.Text.Trim();
  4069. ButtonEdit btn = (ButtonEdit)sender;
  4070. string sql = @"select distinct a.LOTNO AS 产品跟踪单 from ICSMO2User a
  4071. left join ICSLOTONWIP b on a.LOTNO=b.LOTNO and a.OPCODE=b.OPCODE
  4072. where (b.ACTIONRESULT is null or ACTIONRESULT='COLLECT_BEGIN') and a.usercode='"+ txtUserCode.Text.Trim()+@"' and a.eqpcode='"+ txtEQPCode.Text.Trim()+@"' order By a.lotno desc
  4073. ";
  4074. sql = string.Format(sql);
  4075. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  4076. FormDataRefer reForm = new FormDataRefer();
  4077. reForm.FormTitle = "产品跟踪单";
  4078. DataTable menuData = data;
  4079. reForm.DataSource = menuData;
  4080. reForm.MSelectFlag = false;
  4081. reForm.RowIndexWidth = 35;
  4082. reForm.HideCols.Add("ID");
  4083. reForm.FormWidth = 800;
  4084. reForm.FormHeight = 600;
  4085. if (reForm.ShowDialog() == DialogResult.OK)
  4086. {
  4087. DataTable retData = reForm.ReturnData;
  4088. foreach (DataRow dr in retData.Rows)
  4089. {
  4090. txtLotNo.Text = dr["产品跟踪单"].ToString();
  4091. }
  4092. txtLotNo_KeyPress(null, new KeyPressEventArgs(Convert.ToChar(Keys.Enter)));
  4093. txtUserCode.Text = usercode;
  4094. txtEQPCode.Text = eqpcode;
  4095. txtMachineName.Text = eqpname;
  4096. txtUserName.Text = username;
  4097. }
  4098. }
  4099. private void txtOPCode_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  4100. {
  4101. if (string.IsNullOrEmpty(txtLotNo.Text.Trim())) {
  4102. ICSBaseSimpleCode.AppshowMessageBox("请先输入产品跟踪单!");
  4103. return;
  4104. }
  4105. ButtonEdit btn = (ButtonEdit)sender;
  4106. string sql = @"select DISTINCT a.OPCODE as 工序,b.opdesc as 名称 from ICSMO2User a left join icsop b on a.OPCODE=b.OPCODE WHERE LOTNO='"+txtLotNo.Text.Trim()+"' and a.usercode='"+txtUserCode.Text.Trim()+@"' and a.eqpcode='"+txtEQPCode.Text.Trim()+@"' ";
  4107. sql = string.Format(sql);
  4108. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  4109. FormDataRefer reForm = new FormDataRefer();
  4110. reForm.FormTitle = "工序";
  4111. DataTable menuData = data;
  4112. reForm.DataSource = menuData;
  4113. reForm.MSelectFlag = false;
  4114. reForm.RowIndexWidth = 35;
  4115. reForm.HideCols.Add("ID");
  4116. reForm.FormWidth = 800;
  4117. reForm.FormHeight = 600;
  4118. if (reForm.ShowDialog() == DialogResult.OK)
  4119. {
  4120. DataTable retData = reForm.ReturnData;
  4121. foreach (DataRow dr in retData.Rows)
  4122. {
  4123. txtOPCode.Text = dr["工序"].ToString();
  4124. }
  4125. txtOPCode_KeyPress(null, new KeyPressEventArgs(Convert.ToChar(Keys.Enter)));
  4126. }
  4127. }
  4128. private string GetLotNoOp(string lotno) {
  4129. string sql = @"select A.OPCODE,B.OPSEQ,a.CollectStatus,a.LOTNO from ICSLOTSIMULATION A
  4130. LEFT JOIN ICSITEMROUTE2OPLot B ON A.LOTNO = B.LotNo and a.OPCODE = b.OPCODE where a.lotno='"+lotno+"'";
  4131. DataTable table = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  4132. sql = "select opcode,opseq from ICSITEMROUTE2OPLot where lotno='"+lotno+"' order by opseq";
  4133. DataTable Optable= DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  4134. if (table.Rows.Count <= 0)
  4135. {
  4136. return Optable.Rows[0]["opcode"].ToString();
  4137. }
  4138. else {
  4139. if (table.Rows[0]["CollectStatus"].ToString() == "COLLECT_BEGIN")
  4140. {
  4141. return table.Rows[0]["OPCODE"].ToString();
  4142. }
  4143. else if (table.Rows[0]["CollectStatus"].ToString() == "COLLECT_END")
  4144. {
  4145. //判断是否检验合格
  4146. int opseq = Convert.ToInt32(table.Rows[0]["OPSEQ"].ToString());
  4147. int opseq_ = opseq + 10;
  4148. if (CheckIsOK(opseq))
  4149. {
  4150. string opcode = Optable.AsEnumerable().Where(a => a["opseq"].ToString() == opseq_.ToString()).Select(a => a["opcode"].ToString()).FirstOrDefault();
  4151. if (opcode != null)
  4152. {
  4153. return opcode;
  4154. }
  4155. else
  4156. return "";
  4157. }
  4158. else
  4159. return "";
  4160. }
  4161. else
  4162. return "";
  4163. }
  4164. }
  4165. }
  4166. }