锐腾搅拌上料功能
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.

1367 lines
55 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. namespace ICSSoft.Frame.APP
  27. {
  28. public partial class FormICSMO : DevExpress.XtraEditors.XtraForm
  29. {
  30. private string sqltxt = "";
  31. private string sqlconn = "";
  32. String guid = AppConfig.GetGuid();
  33. private DataTable dataSource = null;
  34. #region 构造函数
  35. public FormICSMO()
  36. {
  37. InitializeComponent();
  38. this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  39. this.WindowState = FormWindowState.Maximized;
  40. foreach (DevExpress.XtraGrid.Columns.GridColumn col in grvDetail.Columns)
  41. {
  42. col.OptionsColumn.AllowEdit = col.Name == colSerial.Name;
  43. // col.OptionsColumn.ReadOnly = true;
  44. }
  45. }
  46. #endregion
  47. #region 操作权限
  48. public DataTable RightOfExute()
  49. {
  50. DataTable rData = new DataTable();
  51. rData.Columns.Add("BtnName");
  52. rData.Columns.Add("ActionName");
  53. //查看权限(必须有)
  54. DataRow seeRow = rData.NewRow();
  55. seeRow["BtnName"] = "see";
  56. seeRow["ActionName"] = "查看";
  57. rData.Rows.Add(seeRow);
  58. List<Control> ControlList = new List<Control>();
  59. ControlList.Add(btnModify);
  60. ControlList.Add(btnOutPut);
  61. ControlList.Add(btnBatchOne2One);
  62. ControlList.Add(btnCancelAll);
  63. ControlList.Add(btnRefresh);
  64. ControlList.Add(txtsend);
  65. ControlList.Add(txtcancelSend);
  66. ControlList.Add(btnBatch);
  67. ControlList.Add(btnExit);
  68. //ControlList.Add(btnDel);
  69. //ControlList.Add(txtstop);
  70. //ControlList.Add(txtcancelStop);
  71. //ControlList.Add(txtcloseDan);
  72. //ControlList.Add(btnCreate);
  73. foreach (Control ctr in ControlList)
  74. {
  75. if (ctr.GetType() == typeof(SimpleButton))
  76. {
  77. DataRow dr = rData.NewRow();
  78. dr["BtnName"] = ctr.Name;
  79. dr["ActionName"] = ctr.Text;
  80. rData.Rows.Add(dr);
  81. }
  82. }
  83. rData.AcceptChanges();
  84. return rData;
  85. }
  86. public DataTable RightOfData()// 数据权限
  87. {
  88. DataTable rData = new DataTable();
  89. rData.Columns.Add("BodyName");
  90. rData.Columns.Add("ControlName");
  91. rData.Columns.Add("ControlCaption");
  92. rData.AcceptChanges();
  93. return rData;
  94. }
  95. #endregion
  96. #region 退出
  97. private void btnClose_Click(object sender, EventArgs e)
  98. {
  99. AppConfig.CloseFormShow(this.Text);
  100. this.Close();
  101. }
  102. private void btnExit_Click(object sender, EventArgs e)
  103. {
  104. AppConfig.CloseFormShow(this.Text);
  105. this.Close();
  106. }
  107. #endregion
  108. #region 移动窗体
  109. private const int WM_NCHITTEST = 0x84;
  110. private const int HTCLIENT = 0x1;
  111. private const int HTCAPTION = 0x2;
  112. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  113. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  114. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  115. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  116. //重写窗体,使窗体可以不通过自带标题栏实现移动
  117. protected override void WndProc(ref Message m)
  118. {
  119. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  120. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  121. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  122. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  123. switch (m.Msg)
  124. {
  125. case WM_NCHITTEST:
  126. base.WndProc(ref m);
  127. if ((int)m.Result == HTCLIENT)
  128. m.Result = (IntPtr)HTCAPTION;
  129. return;
  130. }
  131. //拦截双击标题栏、移动窗体的系统消息
  132. if (m.Msg != 0xA3)
  133. {
  134. base.WndProc(ref m);
  135. }
  136. }
  137. #endregion
  138. #region 列表
  139. private void grvDetail_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
  140. {
  141. if (e.Info.IsRowIndicator && e.RowHandle >= 0)
  142. e.Info.DisplayText = (e.RowHandle + 1).ToString();
  143. }
  144. #endregion
  145. #region 过滤
  146. private string tempTableName = "";
  147. private void btnFilter_Click(object sender, EventArgs e)
  148. {
  149. FormFilter filter = new FormFilter(AppConfig.GetSourceId(this.Tag.ToString(), btnConfig.Name));
  150. filter.OldTempTableName = tempTableName;
  151. if (filter.ShowDialog() == DialogResult.OK)
  152. {
  153. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在查找...请稍等...");
  154. try
  155. {
  156. _wait.Show();
  157. tempTableName = filter.NewTempTableName;
  158. sqltxt = filter.SqlText;
  159. sqlconn = filter.FilterConnectString;
  160. dataSource = filter.FilterData.Tables[0];
  161. grdDetail.DataSource = dataSource;
  162. grvDetail.BestFitColumns();
  163. rptPage.RecordNum = dataSource.Rows.Count;
  164. rptPage.PageSize = 499;
  165. rptPage.PageIndex = 1;
  166. rptPage.ReLoad();
  167. rptPage.PageSize = 500;
  168. rptPage.PageIndex = 1;
  169. rptPage.ReLoad();
  170. _wait.Close();
  171. }
  172. catch (Exception ex)
  173. {
  174. MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  175. _wait.Close();
  176. }
  177. }
  178. }
  179. #endregion
  180. #region 绑定数据源
  181. private void btnConfig_Click(object sender, EventArgs e)
  182. {
  183. if (AppConfig.UserCode.ToLower() != "demo")
  184. {
  185. ICSBaseSimpleCode.AppshowMessageBox("您没有权限设置数据源,请联系软件提供商!");
  186. return;
  187. }
  188. FormDataSource fdata = new FormDataSource(AppConfig.GetMenuId(this.Tag.ToString()), btnConfig.Name);
  189. fdata.ShowDialog();
  190. }
  191. #endregion
  192. #region 分页
  193. private void rptPage_PageIndexChanged(object Sender, EventArgs e)
  194. {
  195. DataTable data = AppConfig.GetPageData(dataSource, rptPage.PageIndex, rptPage.PageSize).Copy();
  196. //DataTable data = AppConfig.GetPageDataByDb(tempTableName, "pagerowindex", rptPage.PageSize, rptPage.PageIndex, dataSource.Rows.Count);
  197. grdDetail.DataSource = data;
  198. }
  199. #endregion
  200. #region 过滤方法
  201. private void FormContainerManager_FormClosing(object sender, FormClosingEventArgs e)
  202. {
  203. AppConfig.DropTemTable(tempTableName);
  204. }
  205. #endregion
  206. #region 全选
  207. private void btnSelectAll_Click(object sender, EventArgs e)
  208. {
  209. grvDetail.PostEditor();
  210. this.Validate();
  211. for (int i = 0; i < grvDetail.RowCount; i++)
  212. {
  213. grvDetail.SetRowCellValue(i, colisSelect, "Y");
  214. }
  215. }
  216. #endregion
  217. #region 全消
  218. private void btnCancelAll_Click(object sender, EventArgs e)
  219. {
  220. grvDetail.PostEditor();
  221. this.Validate();
  222. for (int i = 0; i < grvDetail.RowCount; i++)
  223. {
  224. grvDetail.SetRowCellValue(i, colisSelect, "");
  225. }
  226. }
  227. #endregion
  228. #region 双击
  229. private void grvDetail_DoubleClick(object sender, EventArgs e)
  230. {
  231. if (grvDetail.FocusedRowHandle < 0)
  232. {
  233. return;
  234. }
  235. if (grvDetail.FocusedColumn == colisSelect)
  236. {
  237. if (grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colisSelect).ToString() == "")
  238. {
  239. grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colisSelect, "Y");
  240. }
  241. else
  242. {
  243. grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colisSelect, "");
  244. }
  245. }
  246. }
  247. #endregion
  248. #region 删除
  249. private void btnDel_Click(object sender, EventArgs e)
  250. {
  251. SimpleButton btntemp = (SimpleButton)sender;
  252. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  253. {
  254. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  255. return;
  256. }
  257. List<string> moidList = new List<string>();
  258. for (int i = 0; i < grvDetail.RowCount; i++)
  259. {
  260. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  261. {
  262. string moid;
  263. if (grvDetail.GetRowCellValue(i, colMOTYPE).ToString() == "1")
  264. {
  265. moidList.Add(grvDetail.GetRowCellValue(i, colID).ToString());
  266. }
  267. else
  268. {
  269. ICSBaseSimpleCode.AppshowMessageBox("非返程工单,不能删除!!!");
  270. return;
  271. }
  272. }
  273. }
  274. if (moidList.Count == 0 || moidList == null)
  275. {
  276. ICSBaseSimpleCode.AppshowMessageBox("请选择数据");
  277. return;
  278. }
  279. if (ICSBaseSimpleCode.AppshowMessageBoxRepose("确定删除工单吗?删除后无法恢复,确定吗?") != DialogResult.OK)
  280. {
  281. btnCancelAll_Click(sender, e);
  282. return;
  283. }
  284. try
  285. {
  286. ICSMOBLL.deleteInfo(moidList, AppConfig.AppConnectString);
  287. ICSBaseSimpleCode.AppshowMessageBox("删除成功");
  288. }
  289. catch (Exception ex)
  290. {
  291. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  292. }
  293. btnRefresh_Click(null, null);
  294. }
  295. #endregion
  296. #region 导出
  297. private void btnOutPut_Click(object sender, EventArgs e)
  298. {
  299. FormOutExcel foe = new FormOutExcel(this.Tag.ToString(), grdDetail);
  300. foe.ShowDialog();
  301. }
  302. #endregion
  303. #region 刷新
  304. private void btnRefresh_Click(object sender, EventArgs e)
  305. {
  306. string tip = "正在查找...请稍等...";
  307. if (sender == null)
  308. {
  309. tip = "正在刷新界面...";
  310. }
  311. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm(tip);
  312. try
  313. {
  314. _wait.Show();
  315. FormFilter filter = new FormFilter(AppConfig.GetSourceId(this.Tag.ToString(), btnConfig.Name), false);
  316. filter.OldTempTableName = tempTableName;
  317. //tempTableName = filter.NewTempTableName;
  318. //DataTable data = DBHelper.ExecuteDataset(AppConfig.FrameConnectString, CommandType.Text, "select * from " + tempTableName).Tables[0];
  319. if (!string.IsNullOrWhiteSpace(sqlconn))
  320. {
  321. dataSource = DBHelper.ExecuteDataset(sqlconn, CommandType.Text, sqltxt).Tables[0];
  322. grdDetail.DataSource = dataSource;
  323. grvDetail.BestFitColumns();
  324. rptPage.RecordNum = dataSource.Rows.Count;
  325. rptPage.PageIndex = 1;
  326. rptPage.ReLoad();
  327. }
  328. _wait.Close();
  329. }
  330. catch (Exception ex)
  331. {
  332. MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  333. _wait.Close();
  334. }
  335. }
  336. #endregion
  337. #region 新增
  338. private void btnCreate_Click(object sender, EventArgs e)
  339. {
  340. SimpleButton btntemp = (SimpleButton)sender;
  341. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  342. {
  343. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  344. return;
  345. }
  346. FormICSMOAdd add = new FormICSMOAdd();
  347. add.ShowDialog();
  348. btnRefresh_Click(null, null);
  349. }
  350. #endregion
  351. #region 修改
  352. private void btnModify_Click(object sender, EventArgs e)
  353. {
  354. //已经分批的不能修改途程20190717ZM
  355. SimpleButton btntemp = (SimpleButton)sender;
  356. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  357. {
  358. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  359. return;
  360. }
  361. int count = 0;
  362. for (int i = 0; i < grvDetail.RowCount; i++)
  363. {
  364. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  365. {
  366. count++;
  367. }
  368. }
  369. if (count != 1)
  370. {
  371. ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  372. return;
  373. }
  374. try
  375. {
  376. string moid;
  377. for (int i = 0; i < grvDetail.RowCount; i++)
  378. {
  379. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  380. {
  381. moid = grvDetail.GetRowCellValue(i, colID).ToString();
  382. bool issplit = ChechIsSplit(moid);
  383. if (issplit)
  384. {
  385. ICSBaseSimpleCode.AppshowMessageBox("已经分批过的不能进行修改");
  386. return;
  387. }
  388. else
  389. {
  390. FormICSMOAdd add = new FormICSMOAdd(moid);
  391. add.ShowDialog();
  392. }
  393. //}
  394. //else
  395. //{
  396. // ICSBaseSimpleCode.AppshowMessageBox("非返程工单,不能修改!!!");
  397. // return;
  398. //}
  399. }
  400. }
  401. btnRefresh_Click(null, null);
  402. }
  403. catch (Exception ex)
  404. {
  405. //throw ex;
  406. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  407. }
  408. }
  409. #endregion
  410. private bool ChechIsSplit(string moid)
  411. {
  412. bool isSplit = false;
  413. string mocode = string.Empty; ;
  414. string MOSEQ = string.Empty;
  415. string sql = @" SELECT MOCODE,MOSEQ FROM ICSMO WHERE ID='" + moid + "' ";
  416. sql = string.Format(sql);
  417. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  418. if (data != null && data.Rows.Count > 0)
  419. {
  420. mocode = data.Rows[0][0].ToString();
  421. MOSEQ = data.Rows[0][1].ToString();
  422. }
  423. string _sql = @"
  424. SELECT COUNT(*) AS num FROM
  425. ICSITEMLot b
  426. WHERE b.TransNO='" + mocode + "' AND B.TransLine='" + MOSEQ + "' ";
  427. _sql = string.Format(_sql);
  428. DataTable _data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, _sql).Tables[0];
  429. if (_data != null || _data.Rows.Count > 0)
  430. {
  431. int a = Int32.Parse(_data.Rows[0][0].ToString());
  432. if (a > 0)
  433. {
  434. isSplit = true;
  435. }
  436. }
  437. return isSplit;
  438. //if (isSplit)
  439. //{
  440. // ICSBaseSimpleCode.AppshowMessageBox("已经分批过的不能进行修改");
  441. // return;
  442. //}
  443. }
  444. private void ICSItemLot_FormClosing(object sender, FormClosingEventArgs e)
  445. {
  446. AppConfig.DropTemTable(tempTableName);
  447. }
  448. private void FormICSMO_Load(object sender, EventArgs e)
  449. {
  450. btnFilter_Click(sender, e);
  451. }
  452. private void grvDetail_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
  453. {
  454. if (e.RowHandle >= 0 && e.Column.FieldName == "DCTCODE")
  455. {
  456. //e.DisplayText = FormatHelper.
  457. e.CellValue = "cccc";
  458. }
  459. }
  460. //生成序列号
  461. private void newRcard_Click(object sender, EventArgs e)
  462. {
  463. //SimpleButton btntemp = (SimpleButton)sender;
  464. //if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  465. //{
  466. // ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  467. // return;
  468. //}
  469. //int count = 0;
  470. //for (int i = 0; i < grvDetail.RowCount; i++)
  471. //{
  472. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  473. // {
  474. // count++;
  475. // }
  476. //}
  477. //if (count != 1)
  478. //{
  479. // ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  480. // return;
  481. //}
  482. //try
  483. //{
  484. // string moID;
  485. // string moCode;
  486. // decimal qty = 0.00m;
  487. // for (int i = 0; i < grvDetail.RowCount; i++)
  488. // {
  489. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  490. // {
  491. // moID = grvDetail.GetRowCellValue(i, colID).ToString();
  492. // moCode = grvDetail.GetRowCellValue(i, colMOCODE).ToString();
  493. // qty = decimal.Parse(grvDetail.GetRowCellValue(i, colMOPLANQTY).ToString());
  494. // FormICSMO2RCARDAdd rec = new FormICSMO2RCARDAdd(moID, moCode, qty);
  495. // rec.ShowDialog();
  496. // }
  497. // }
  498. // btnRefresh_Click(null, null);
  499. //}
  500. //catch (Exception ex)
  501. //{
  502. // //throw ex;
  503. // ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  504. //}
  505. }
  506. private void repSerialButtonEdit_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  507. {
  508. try
  509. {
  510. string moID;
  511. string moCode;
  512. decimal qty = 0.00m;
  513. moID = grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colID).ToString();
  514. moCode = grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colMOCODE).ToString();
  515. qty = Convert.ToDecimal(grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colMOPLANQTY).ToString());
  516. FormICSMO2RCARDAdd rec = new FormICSMO2RCARDAdd(moID, moCode, qty);
  517. rec.ShowDialog();
  518. btnRefresh_Click(null, null);
  519. }
  520. catch (Exception ex)
  521. {
  522. throw ex;
  523. }
  524. }
  525. //下发
  526. private void txtsend_Click(object sender, EventArgs e)
  527. {
  528. SimpleButton btntemp = (SimpleButton)sender;
  529. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  530. {
  531. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  532. return;
  533. }
  534. List<ICSMO> list = new List<ICSMO>();
  535. for (int i = 0; i < grvDetail.RowCount; i++)
  536. {
  537. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  538. {
  539. string state = grvDetail.GetRowCellValue(i, colMOSTATUS).ToString();
  540. if (state != "初始")
  541. {
  542. grvDetail.SetRowCellValue(i, colisSelect, "");
  543. Application.DoEvents();
  544. continue;
  545. }
  546. ICSMO mo = new ICSMO();
  547. mo.MOCODE = grvDetail.GetRowCellValue(i, colMOCODE).ToString();
  548. mo.MOSEQ = grvDetail.GetRowCellValue(i, colMOSEQ).ToString();
  549. mo.WorkPoint = AppConfig.WorkPointCode;
  550. list.Add(mo);
  551. }
  552. }
  553. if (list.Count == 0)
  554. {
  555. ICSBaseSimpleCode.AppshowMessageBox("请选择状态为'初始'的工单行进行下发!");
  556. return;
  557. }
  558. btntemp.Enabled = false;
  559. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("开始下发...");
  560. try
  561. {
  562. _wait.Show();
  563. int u = ICSMOBLL.Send(list, AppConfig.AppConnectString);
  564. _wait.Close();
  565. ICSBaseSimpleCode.AppshowMessageBox("下发成功 " + u.ToString() + " 条");
  566. btnRefresh_Click(null, null);
  567. #region old
  568. // string mocode = "";
  569. // string moseq = "";
  570. // string state = "";
  571. // for (int i = 0; i < grvDetail.RowCount; i++)
  572. // {
  573. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  574. // {
  575. // mocode = grvDetail.GetRowCellValue(i, colMOCODE).ToString();
  576. // state = grvDetail.GetRowCellValue(i, colMOSTATUS).ToString();
  577. // moseq = grvDetail.GetRowCellValue(i, colMOSEQ).ToString();
  578. // }
  579. // }
  580. // string sendSql = @"SELECT * FROM ICSITEMLot WHERE TransNO='" + mocode + "' ";
  581. // sendSql = string.Format(sendSql);
  582. // DataTable sendData = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sendSql).Tables[0];
  583. // if (sendData == null || sendData.Rows.Count < 1)
  584. // {
  585. // ICSBaseSimpleCode.AppshowMessageBox("只有分完批次才能下发!");
  586. // return;
  587. // }
  588. // string _sql = @"
  589. //SELECT
  590. // c.ROUTECODE
  591. //FROM
  592. // ICSMO a
  593. //LEFT JOIN ICSMO2ROUTE c ON a.ID = c.MOID AND a.WorkPoint=c.WorkPoint
  594. //LEFT JOIN (
  595. // SELECT
  596. // b.MOCODE,
  597. // CONVERT (INT, b.MOSEQ) AS MOSEQ,
  598. // b.ITEMCODE,
  599. // COUNT (*) AS IsUse
  600. // FROM
  601. // ICSMOPickLog a
  602. // INNER JOIN ICSMO b ON (a.MOCode = b.MOCODE AND b.MOSEQ = a.MOSEQ AND a.ITEMCODE = b.ITEMCODE AND b.WorkPoint=a.WorkPoint)
  603. // WHERE a.WorkPoint='"+AppConfig.WorkPointCode+@"'
  604. // GROUP BY b.MOCODE, b.MOSEQ,b.ITEMCODE
  605. //) d ON (d.MOCODE = a.MOCODE AND d.MOSEQ = a.MOSEQ AND d.ITEMCODE = a.ITEMCODE)
  606. //WHERE
  607. // 1 = 1
  608. //AND a.MOCODE = '" + mocode + "' AND a.MOSEQ =" + moseq + " AND a.WorkPoint='"+AppConfig.WorkPointCode+"' ORDER BY a.MOCODE, CONVERT (INT, a.MOSEQ)";
  609. // _sql = string.Format(_sql);
  610. // DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, _sql).Tables[0];
  611. // string _ROUTECODE = string.Empty;
  612. // if (data != null && data.Rows.Count > 0)
  613. // {
  614. // _ROUTECODE = data.Rows[0][0].ToString();
  615. // }
  616. // else
  617. // {
  618. // ICSBaseSimpleCode.AppshowMessageBox("工单尚未绑定工艺路线不能下发!");
  619. // return;
  620. // }
  621. // if (string.IsNullOrWhiteSpace(_ROUTECODE))
  622. // {
  623. // ICSBaseSimpleCode.AppshowMessageBox("工单尚未绑定工艺路线不能下发!");
  624. // return;
  625. // }
  626. // //判断是否是初始状态
  627. // if (state.Equals("初始"))
  628. // {
  629. // ////判断是否在工单首检记录表中
  630. // //if (ICSMOBLL.isInFirstCheck(mocode, AppConfig.AppConnectString))
  631. // //{
  632. // ////判断(最近的时间)是否合格
  633. // //if (ICSMOBLL.isQualified(mocode, AppConfig.AppConnectString))
  634. // //{
  635. // ICSMOBLL.Send(mocode, moseq, AppConfig.AppConnectString);
  636. // ICSBaseSimpleCode.AppshowMessageBox("下发成功");
  637. // //}
  638. // //else
  639. // //{
  640. // // ICSBaseSimpleCode.AppshowMessageBox("不合格,不能下发");
  641. // // return;
  642. // // //}
  643. // // }
  644. // //else
  645. // // {
  646. // // ICSBaseSimpleCode.AppshowMessageBox("不存在工单首检记录中");
  647. // // return;
  648. // // }
  649. // }
  650. // else
  651. // {
  652. // ICSBaseSimpleCode.AppshowMessageBox("不是初始状态,不能下发");
  653. // return;
  654. // }
  655. //btnRefresh_Click(null, null);
  656. #endregion
  657. }
  658. catch (Exception ex)
  659. {
  660. _wait.Close();
  661. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  662. }
  663. finally
  664. {
  665. btntemp.Enabled = true;
  666. }
  667. }
  668. //取消下发
  669. private void txtcancelSend_Click(object sender, EventArgs e)
  670. {
  671. SimpleButton btntemp = (SimpleButton)sender;
  672. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  673. {
  674. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  675. return;
  676. }
  677. List<ICSMO> list = new List<ICSMO>();
  678. for (int i = 0; i < grvDetail.RowCount; i++)
  679. {
  680. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  681. {
  682. string state = grvDetail.GetRowCellValue(i, colMOSTATUS).ToString();
  683. if (state != "下发")
  684. {
  685. grvDetail.SetRowCellValue(i, colisSelect, "");
  686. Application.DoEvents();
  687. continue;
  688. }
  689. ICSMO mo = new ICSMO();
  690. mo.MOCODE = grvDetail.GetRowCellValue(i, colMOCODE).ToString();
  691. mo.MOSEQ = grvDetail.GetRowCellValue(i, colMOSEQ).ToString();
  692. mo.WorkPoint = AppConfig.WorkPointCode;
  693. list.Add(mo);
  694. }
  695. }
  696. if (list.Count == 0)
  697. {
  698. ICSBaseSimpleCode.AppshowMessageBox("请选择状态为'下发'的工单行进行[取消下发]操作!");
  699. return;
  700. }
  701. btntemp.Enabled = false;
  702. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("开始下发...");
  703. try
  704. {
  705. _wait.Show();
  706. int u = ICSMOBLL.CancelSend(list, AppConfig.AppConnectString);
  707. _wait.Close();
  708. ICSBaseSimpleCode.AppshowMessageBox("取消下发成功 " + u.ToString() + " 条");
  709. btnRefresh_Click(null, null);
  710. }
  711. catch (Exception ex)
  712. {
  713. _wait.Close();
  714. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  715. }
  716. finally
  717. {
  718. btntemp.Enabled = true;
  719. }
  720. #region old
  721. //int count = 0;
  722. //for (int i = 0; i < grvDetail.RowCount; i++)
  723. //{
  724. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  725. // {
  726. // count++;
  727. // }
  728. //}
  729. //if (count != 1)
  730. //{
  731. // ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  732. // return;
  733. //}
  734. //try
  735. //{
  736. // string mocode = "";
  737. // string state = "";
  738. // string moseq = "";
  739. // for (int i = 0; i < grvDetail.RowCount; i++)
  740. // {
  741. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  742. // {
  743. // mocode = grvDetail.GetRowCellValue(i, colMOCODE).ToString();
  744. // state = grvDetail.GetRowCellValue(i, colMOSTATUS).ToString();
  745. // moseq = grvDetail.GetRowCellValue(i, colMOSEQ).ToString();
  746. // }
  747. // }
  748. // //1.
  749. // DataTable dt = ICSMO2UserBLL.SelectMO2USER(mocode, moseq, AppConfig.AppConnectString, AppConfig.WorkPointCode);
  750. // if (dt.Rows.Count != 0)
  751. // {
  752. // string msg = "";
  753. // foreach (DataRow dr in dt.Rows)
  754. // {
  755. // msg += ("跟踪单:" + dr["LOTNO"].ToString() + "工序:" + dr["OPCODE"].ToString() + "\r\n");
  756. // }
  757. // throw new Exception("已有派工记录,不可取消下发\r\n" + msg);
  758. // }
  759. // //2.判断是否是下发状态
  760. // if (state.Equals("下发"))
  761. // {
  762. // ICSMOBLL.cancelSend(mocode, moseq, AppConfig.AppConnectString);
  763. // ICSBaseSimpleCode.AppshowMessageBox("取消下发成功");
  764. // }
  765. // else
  766. // {
  767. // ICSBaseSimpleCode.AppshowMessageBox("不是下发状态,不能取消下发");
  768. // return;
  769. // }
  770. // btnRefresh_Click(null, null);
  771. //}
  772. //catch (Exception ex)
  773. //{
  774. // ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  775. //}
  776. #endregion
  777. }
  778. //暂停
  779. private void txtstop_Click(object sender, EventArgs e)
  780. {
  781. SimpleButton btntemp = (SimpleButton)sender;
  782. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  783. {
  784. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  785. return;
  786. }
  787. int count = 0;
  788. for (int i = 0; i < grvDetail.RowCount; i++)
  789. {
  790. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  791. {
  792. count++;
  793. }
  794. }
  795. if (count != 1)
  796. {
  797. ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  798. return;
  799. }
  800. try
  801. {
  802. string mocode = "";
  803. string state = "";
  804. for (int i = 0; i < grvDetail.RowCount; i++)
  805. {
  806. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  807. {
  808. mocode = grvDetail.GetRowCellValue(i, colMOCODE).ToString();
  809. state = grvDetail.GetRowCellValue(i, colMOSTATUS).ToString();
  810. }
  811. }
  812. //判断是否是生产中状态
  813. if (state.Equals("生产中"))
  814. {
  815. ICSMOBLL.stop(mocode, AppConfig.AppConnectString);
  816. ICSBaseSimpleCode.AppshowMessageBox("暂停成功");
  817. }
  818. else
  819. {
  820. ICSBaseSimpleCode.AppshowMessageBox("不是生产中状态,不能暂停");
  821. return;
  822. }
  823. btnRefresh_Click(null, null);
  824. }
  825. catch (Exception ex)
  826. {
  827. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  828. }
  829. }
  830. //取消暂停
  831. private void txtcancelStop_Click(object sender, EventArgs e)
  832. {
  833. SimpleButton btntemp = (SimpleButton)sender;
  834. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  835. {
  836. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  837. return;
  838. }
  839. int count = 0;
  840. for (int i = 0; i < grvDetail.RowCount; i++)
  841. {
  842. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  843. {
  844. count++;
  845. }
  846. }
  847. if (count != 1)
  848. {
  849. ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  850. return;
  851. }
  852. try
  853. {
  854. string mocode = "";
  855. string state = "";
  856. for (int i = 0; i < grvDetail.RowCount; i++)
  857. {
  858. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  859. {
  860. mocode = grvDetail.GetRowCellValue(i, colMOCODE).ToString();
  861. state = grvDetail.GetRowCellValue(i, colMOSTATUS).ToString();
  862. }
  863. }
  864. //判断是否是暂停状态
  865. if (state.Equals("暂停"))
  866. {
  867. ICSMOBLL.cancelStop(mocode, AppConfig.AppConnectString);
  868. ICSBaseSimpleCode.AppshowMessageBox("取消暂停成功");
  869. }
  870. else
  871. {
  872. ICSBaseSimpleCode.AppshowMessageBox("不是暂停状态,不能取消暂停");
  873. return;
  874. }
  875. btnRefresh_Click(null, null);
  876. }
  877. catch (Exception ex)
  878. {
  879. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  880. }
  881. }
  882. //关单
  883. private void txtcloseDan_Click(object sender, EventArgs e)
  884. {
  885. SimpleButton btntemp = (SimpleButton)sender;
  886. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  887. {
  888. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  889. return;
  890. }
  891. int count = 0;
  892. for (int i = 0; i < grvDetail.RowCount; i++)
  893. {
  894. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  895. {
  896. count++;
  897. }
  898. }
  899. if (count != 1)
  900. {
  901. ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  902. return;
  903. }
  904. try
  905. {
  906. string mocode = "";
  907. string state = "";
  908. for (int i = 0; i < grvDetail.RowCount; i++)
  909. {
  910. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  911. {
  912. mocode = grvDetail.GetRowCellValue(i, colMOCODE).ToString();
  913. state = grvDetail.GetRowCellValue(i, colMOSTATUS).ToString();
  914. }
  915. }
  916. //判断是否是关单状态
  917. if (!(state.Equals("关单")))
  918. {
  919. ICSMOBLL.closeDan(mocode, AppConfig.AppConnectString);
  920. ICSBaseSimpleCode.AppshowMessageBox("关单成功");
  921. }
  922. else
  923. {
  924. ICSBaseSimpleCode.AppshowMessageBox("已经是关单状态");
  925. return;
  926. }
  927. btnRefresh_Click(null, null);
  928. }
  929. catch (Exception ex)
  930. {
  931. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  932. }
  933. }
  934. //批次信息
  935. private void btnBatch_Click(object sender, EventArgs e)
  936. {
  937. //SimpleButton btntemp = (SimpleButton)sender;
  938. //if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  939. //{
  940. // ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  941. // return;
  942. //}
  943. //FormICSMO2Lot add = new FormICSMO2Lot();
  944. //add.ShowDialog();
  945. //btnRefresh_Click(null, null);
  946. SimpleButton btntemp = (SimpleButton)sender;
  947. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  948. {
  949. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  950. return;
  951. }
  952. int count = 0;
  953. for (int i = 0; i < grvDetail.RowCount; i++)
  954. {
  955. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  956. {
  957. count++;
  958. }
  959. }
  960. if (count != 1)
  961. {
  962. ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  963. return;
  964. }
  965. try
  966. {
  967. string id;
  968. string code;
  969. int Qty = 0;
  970. string itemcode;
  971. for (int i = 0; i < grvDetail.RowCount; i++)
  972. {
  973. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  974. {
  975. id = grvDetail.GetRowCellValue(i, colID).ToString();
  976. code = grvDetail.GetRowCellValue(i, colMOCODE).ToString();
  977. Qty = (int)Convert.ToDecimal(grvDetail.GetRowCellValue(i, colMOPLANQTY).ToString());
  978. itemcode = grvDetail.GetRowCellValue(i, colITEMCODE).ToString();
  979. string moseq = grvDetail.GetRowCellValue(i, colMOSEQ).ToString();
  980. FormICSMO2Lot add = new FormICSMO2Lot(id, code, Qty, itemcode, moseq);
  981. add.ShowDialog();
  982. //btnRefresh_Click(null, null);
  983. }
  984. }
  985. //判断是否是关单状态
  986. //if (!(state.Equals("关单")))
  987. //{
  988. //}
  989. //else
  990. //{
  991. // ICSBaseSimpleCode.AppshowMessageBox("已经是关单状态");
  992. // return;
  993. //}
  994. btnRefresh_Click(null, null);
  995. }
  996. catch (Exception ex)
  997. {
  998. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  999. }
  1000. }
  1001. private void btnBatchOne2One_Click(object sender, EventArgs e)
  1002. {
  1003. SimpleButton btntemp = (SimpleButton)sender;
  1004. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  1005. {
  1006. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  1007. return;
  1008. }
  1009. List<string> listId = new List<string>();
  1010. for (int i = 0; i < grvDetail.RowCount; i++)
  1011. {
  1012. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  1013. {
  1014. listId.Add(grvDetail.GetRowCellValue(i, colID).ToString());
  1015. }
  1016. }
  1017. if (listId.Count() == 0)
  1018. {
  1019. ICSBaseSimpleCode.AppshowMessageBox("请选择数据!!!");
  1020. return;
  1021. }
  1022. if (MessageBox.Show("每个工单行只分批成一个跟踪单,确定分批吗?", "提示", MessageBoxButtons.YesNo) != DialogResult.Yes)
  1023. {
  1024. return;
  1025. }
  1026. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在执行,请稍等...");
  1027. try
  1028. {
  1029. _wait.Show();
  1030. string res = "";
  1031. string msg11 = "";
  1032. string ID = "";
  1033. string MOCODE = "";
  1034. string MOSEQ = "";
  1035. string ITEMCODE = "";
  1036. string MOVER = "";
  1037. decimal MOPLANQTY = 0;
  1038. DateTime mtime = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
  1039. List<ICSITEMLot> listItemLot = new List<ICSITEMLot>();
  1040. List<ICSITEMROUTE2OPLot> listItemRouteOpLot = new List<ICSITEMROUTE2OPLot>();
  1041. #region 1是否已分批.2 生成ICSITEMLot
  1042. DataTable dt = ICSMO2LotBLL.GetMO2LotInfo(listId, AppConfig.WorkPointCode, AppConfig.AppConnectString);
  1043. foreach (DataRow dr in dt.Rows)
  1044. {
  1045. ID = dr["ID"].ToString();
  1046. MOCODE = dr["MOCODE"].ToString();
  1047. MOSEQ = dr["MOSEQ"].ToString();
  1048. MOVER = dr["MOVER"].ToString();
  1049. MOPLANQTY = Convert.ToDecimal(dr["MOPLANQTY"]);
  1050. ITEMCODE = dr["ITEMCODE"].ToString();
  1051. int FP = Convert.ToInt32(dr["FP"].ToString());
  1052. if (listId.Contains(ID) && FP > 0)
  1053. {
  1054. if (msg11 == "")
  1055. {
  1056. msg11 = "以下工单行已分批\r\n";
  1057. }
  1058. msg11 += ("工单:" + MOCODE + "行:" + MOSEQ + "\r\n");
  1059. listId.Remove(ID);
  1060. continue;
  1061. }
  1062. #region ItemLot
  1063. ICSITEMLot itemlot = new ICSITEMLot();
  1064. itemlot.ID = Guid.NewGuid().ToString();
  1065. itemlot.LotNO = MOCODE + MOSEQ + "0001";
  1066. itemlot.ItemCode = ITEMCODE;
  1067. itemlot.LOTQTY = MOPLANQTY;
  1068. itemlot.TransNO = MOCODE;
  1069. itemlot.TransLine = MOSEQ;
  1070. itemlot.TYPE = "工单";
  1071. itemlot.VenderLotNO = MOVER;
  1072. itemlot.MUSER = AppConfig.UserId;
  1073. itemlot.MUSERName = AppConfig.UserName;
  1074. itemlot.Exdate = Convert.ToDateTime("2999-12-31 00:00:00.000");
  1075. itemlot.PRODUCTDATE = itemlot.MTIME = mtime;
  1076. itemlot.WorkPoint = AppConfig.WorkPointCode;
  1077. itemlot.ACTIVE = "Y";
  1078. listItemLot.Add(itemlot);
  1079. #endregion
  1080. }
  1081. if (listItemLot.Count == 0)
  1082. {
  1083. throw new Exception("没有符合条件的工单行," + msg11);
  1084. }
  1085. if (msg11 != "")
  1086. {
  1087. DialogResult dResult1 = MessageBox.Show(msg11, "是否跳过?", MessageBoxButtons.YesNo);
  1088. if (dResult1 != DialogResult.Yes)
  1089. {
  1090. throw new Exception("取消分批");
  1091. }
  1092. }
  1093. #endregion
  1094. #region 关联工单的默认途程
  1095. // string isref = "";
  1096. // string routeid = "";
  1097. // //查找工单--产品途程
  1098. // string sql1 = @"select ROUTEID,ISREF from ICSITEM2ROUTE where ITEMCODE='" + itemcode + "' and ISREF = '是' and WorkPoint='" + AppConfig.WorkPointCode + "'";
  1099. // sql1 = string.Format(sql1);
  1100. // DataTable data1 = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql1).Tables[0];
  1101. // if (data1 != null && data1.Rows.Count > 0)
  1102. // {
  1103. // routeid = data1.Rows[0]["ROUTEID"].ToString();
  1104. // isref = data1.Rows[0]["ISREF"].ToString();
  1105. // ICSMOBLL.addRoute(moid, routeid, itemcode, isref, AppConfig.AppConnectString);
  1106. // }
  1107. // else
  1108. // {
  1109. // string sql = @"select a.ROUTEID,
  1110. // a.ISREF
  1111. // from ICSMODEL2ROUTE a
  1112. // left join Base_Inventory b on a.MODELCODE=b.ItemMainCategoryCode
  1113. // where b.ItemCode='" + itemcode + "' and a.ISREF = '是' and a.WorkPoint='" + AppConfig.WorkPointCode + "'";
  1114. // sql = string.Format(sql);
  1115. // DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  1116. // if (data != null && data.Rows.Count > 0)
  1117. // {
  1118. // routeid = data.Rows[0]["ROUTEID"].ToString();
  1119. // isref = data.Rows[0]["ISREF"].ToString();
  1120. // ICSMOBLL.addRoute(moid, routeid, itemcode, isref, AppConfig.AppConnectString);
  1121. // }
  1122. // else
  1123. // {
  1124. // if (ICSBaseSimpleCode.AppshowMessageBoxRepose("该工单没有默认途程,是否继续生成批次?") != DialogResult.OK)
  1125. // {
  1126. // return;
  1127. // }
  1128. // }
  1129. // }
  1130. #endregion
  1131. #region 1校验工单是否关联途程、工艺路线、工序.2生成ItemRoute2OPLot
  1132. string msg21 = "";
  1133. string msg22 = "";
  1134. string msg23 = "";
  1135. dt = ICSMO2LotBLL.GetMO2Route(listId, AppConfig.WorkPointCode, AppConfig.AppConnectString);
  1136. for (int i = dt.Rows.Count - 1; i >= 0; i--)
  1137. {
  1138. DataRow dr = dt.Rows[i];
  1139. ID = dr["ID"].ToString();
  1140. MOCODE = dr["MOCODE"].ToString();
  1141. MOSEQ = dr["MOSEQ"].ToString();
  1142. ITEMCODE = dr["ITEMCODE"].ToString();
  1143. string ROUTECODE = dr["ROUTECODE"].ToString().Trim();
  1144. string OPSEQ = dr["OPSEQ"].ToString();
  1145. string OPCODE = dr["OPCODE"].ToString().Trim();
  1146. string OPAttr = dr["OPAttr"].ToString().Trim();
  1147. string CtrlType = dr["CtrlType"].ToString().Trim();
  1148. string RouteMGR = dr["RouteMGR"].ToString().Trim();
  1149. string = dr["工时"].ToString().Trim();
  1150. if (string.IsNullOrEmpty(ROUTECODE))
  1151. {
  1152. if (msg21 == "")
  1153. {
  1154. msg21 = "以下工单行未关联工艺路线\r\n";
  1155. }
  1156. msg21 += ("工单:" + MOCODE + "行:" + MOSEQ + "\r\n");
  1157. dt.Rows.Remove(dr);
  1158. listId.Remove(ID);
  1159. listItemLot.RemoveAll(a => a.TransNO == MOCODE && a.TransLine == MOSEQ);
  1160. continue;
  1161. }
  1162. if (string.IsNullOrEmpty(OPCODE))
  1163. {
  1164. if (msg22 == "")
  1165. {
  1166. msg22 = "以下工单行,工艺路线未关联工序信息\r\n";
  1167. }
  1168. msg22 += ("工单:" + MOCODE + "行:" + MOSEQ + "工艺路线:" + ROUTECODE + "\r\n");
  1169. dt.Rows.Remove(dr);
  1170. listId.Remove(ID);
  1171. listItemLot.RemoveAll(a => a.TransNO == MOCODE && a.TransLine == MOSEQ);
  1172. continue;
  1173. }
  1174. if ( == "未维护")
  1175. {
  1176. if (msg23 == "")
  1177. {
  1178. msg23 = "以下工单行,不是所有工序都维护了工时\r\n";
  1179. }
  1180. msg23 += ("工单:" + MOCODE + "行:" + MOSEQ + "工序" + OPCODE + "\r\n");
  1181. dt.Rows.Remove(dr);
  1182. listId.Remove(ID);
  1183. listItemLot.RemoveAll(a => a.TransNO == MOCODE && a.TransLine == MOSEQ);
  1184. continue;
  1185. }
  1186. #region ItemRoute2OPLot
  1187. foreach (ICSITEMLot itemlot in listItemLot)
  1188. {
  1189. if (itemlot.TransNO == MOCODE && itemlot.TransLine == MOSEQ)
  1190. {
  1191. ICSITEMROUTE2OPLot ItemRouteOpLot = new ICSITEMROUTE2OPLot();
  1192. ItemRouteOpLot.ID = Guid.NewGuid().ToString();
  1193. ItemRouteOpLot.ITEMCODE = ITEMCODE;
  1194. ItemRouteOpLot.LotNo = itemlot.LotNO;
  1195. ItemRouteOpLot.ROUTECODE = ROUTECODE;
  1196. ItemRouteOpLot.OPCODE = OPCODE;
  1197. ItemRouteOpLot.OPSEQ = Convert.ToInt32(OPSEQ);
  1198. ItemRouteOpLot.OPCONTROL = "";
  1199. ItemRouteOpLot.OPTIONALOP = "";
  1200. ItemRouteOpLot.IDMERGETYPE = "";
  1201. ItemRouteOpLot.IDMERGERULE = 0;
  1202. ItemRouteOpLot.MUSER = AppConfig.UserId;
  1203. ItemRouteOpLot.MUSERName = AppConfig.UserName;
  1204. ItemRouteOpLot.MTIME = mtime;
  1205. ItemRouteOpLot.WorkPoint = AppConfig.WorkPointCode;
  1206. ItemRouteOpLot.CtrlType = CtrlType;
  1207. ItemRouteOpLot.OPAttr = OPAttr;
  1208. ItemRouteOpLot.RouteMGR = RouteMGR;
  1209. listItemRouteOpLot.Add(ItemRouteOpLot);
  1210. }
  1211. }
  1212. #endregion
  1213. }
  1214. if (listItemRouteOpLot.Count == 0)
  1215. {
  1216. throw new Exception("没有符合条件的工单行," + msg21 + msg22 + msg23);
  1217. }
  1218. if (msg21 != "")
  1219. {
  1220. DialogResult dResult1 = MessageBox.Show(msg21, "是否跳过?", MessageBoxButtons.YesNo);
  1221. if (dResult1 != DialogResult.Yes)
  1222. {
  1223. throw new Exception("取消分批");
  1224. }
  1225. }
  1226. if (msg22 != "")
  1227. {
  1228. DialogResult dResult1 = MessageBox.Show(msg22, "是否跳过?", MessageBoxButtons.YesNo);
  1229. if (dResult1 != DialogResult.Yes)
  1230. {
  1231. throw new Exception("取消分批");
  1232. }
  1233. }
  1234. if (msg23 != "")
  1235. {
  1236. DialogResult dResult1 = MessageBox.Show(msg22, "是否跳过?", MessageBoxButtons.YesNo);
  1237. if (dResult1 != DialogResult.Yes)
  1238. {
  1239. throw new Exception("取消分批");
  1240. }
  1241. }
  1242. #endregion
  1243. //批次汇入
  1244. ICSMO2LotBLL.Mo2LotOne2One(listItemLot, listItemRouteOpLot, AppConfig.AppConnectString);
  1245. foreach (ICSITEMLot item in listItemLot)
  1246. {
  1247. res += ("工单:" + item.TransNO + ",行:" + item.TransLine + "\r\n");//+ ",跟踪单:" + item.LotNO
  1248. }
  1249. _wait.Close();
  1250. ICSBaseSimpleCode.AppshowMessageBox("分批成功!\r\n" + res);
  1251. btnRefresh_Click(null, null);
  1252. }
  1253. catch (Exception ex)
  1254. {
  1255. _wait.Close();
  1256. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  1257. }
  1258. }
  1259. }
  1260. }