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

963 lines
39 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. namespace ICSSoft.Frame.APP
  26. {
  27. public partial class FormICSMONew : DevExpress.XtraEditors.XtraForm
  28. {
  29. private string sqltxt = "";
  30. private string sqlconn = "";
  31. String guid = AppConfig.GetGuid();
  32. private DataTable dataSource = null;
  33. private DataTable body = null;
  34. private DataSet ds = new DataSet();
  35. #region 构造函数
  36. public FormICSMONew()
  37. {
  38. InitializeComponent();
  39. this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  40. this.WindowState = FormWindowState.Maximized;
  41. foreach (DevExpress.XtraGrid.Columns.GridColumn col in grvDetail.Columns)
  42. {
  43. col.OptionsColumn.AllowEdit = col.Name == colSerial.Name;
  44. // col.OptionsColumn.ReadOnly = true;
  45. }
  46. }
  47. #endregion
  48. #region 操作权限
  49. public DataTable RightOfExute()
  50. {
  51. DataTable rData = new DataTable();
  52. rData.Columns.Add("BtnName");
  53. rData.Columns.Add("ActionName");
  54. //查看权限(必须有)
  55. DataRow seeRow = rData.NewRow();
  56. seeRow["BtnName"] = "see";
  57. seeRow["ActionName"] = "查看";
  58. rData.Rows.Add(seeRow);
  59. List<Control> ControlList = new List<Control>();
  60. //ControlList.Add(btnCreate);
  61. //ControlList.Add(btnModify);
  62. //ControlList.Add(btnDel);
  63. ControlList.Add(btnCancelAll);
  64. ControlList.Add(btnRefresh);
  65. ControlList.Add(btnExit);
  66. ControlList.Add(btnGetInfo);
  67. ControlList.Add(btnOutPut);
  68. foreach (Control ctr in ControlList)
  69. {
  70. if (ctr.GetType() == typeof(SimpleButton))
  71. {
  72. DataRow dr = rData.NewRow();
  73. dr["BtnName"] = ctr.Name;
  74. dr["ActionName"] = ctr.Text;
  75. rData.Rows.Add(dr);
  76. }
  77. }
  78. rData.AcceptChanges();
  79. return rData;
  80. }
  81. public DataTable RightOfData()// 数据权限
  82. {
  83. DataTable rData = new DataTable();
  84. rData.Columns.Add("BodyName");
  85. rData.Columns.Add("ControlName");
  86. rData.Columns.Add("ControlCaption");
  87. rData.AcceptChanges();
  88. return rData;
  89. }
  90. #endregion
  91. #region 退出
  92. private void btnClose_Click(object sender, EventArgs e)
  93. {
  94. AppConfig.CloseFormShow(this.Text);
  95. this.Close();
  96. }
  97. private void btnExit_Click(object sender, EventArgs e)
  98. {
  99. AppConfig.CloseFormShow(this.Text);
  100. this.Close();
  101. }
  102. #endregion
  103. #region 移动窗体
  104. private const int WM_NCHITTEST = 0x84;
  105. private const int HTCLIENT = 0x1;
  106. private const int HTCAPTION = 0x2;
  107. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  108. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  109. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  110. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  111. //重写窗体,使窗体可以不通过自带标题栏实现移动
  112. protected override void WndProc(ref Message m)
  113. {
  114. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  115. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  116. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  117. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  118. switch (m.Msg)
  119. {
  120. case WM_NCHITTEST:
  121. base.WndProc(ref m);
  122. if ((int)m.Result == HTCLIENT)
  123. m.Result = (IntPtr)HTCAPTION;
  124. return;
  125. }
  126. //拦截双击标题栏、移动窗体的系统消息
  127. if (m.Msg != 0xA3)
  128. {
  129. base.WndProc(ref m);
  130. }
  131. }
  132. #endregion
  133. #region 列表
  134. private void grvDetail_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
  135. {
  136. if (e.Info.IsRowIndicator && e.RowHandle >= 0)
  137. e.Info.DisplayText = (e.RowHandle + 1).ToString();
  138. }
  139. #endregion
  140. #region 过滤
  141. private string tempTableName = "";
  142. private void btnFilter_Click(object sender, EventArgs e)
  143. {
  144. FormFilter filter = new FormFilter(AppConfig.GetSourceId(this.Tag.ToString(), btnConfig.Name));
  145. filter.OldTempTableName = tempTableName;
  146. if (filter.ShowDialog() == DialogResult.OK)
  147. {
  148. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在查找...请稍等...");
  149. try
  150. {
  151. _wait.Show();
  152. ds.Reset();
  153. dataSource = null;
  154. body = null;
  155. tempTableName = filter.NewTempTableName;
  156. sqltxt = filter.SqlText;
  157. sqlconn = filter.FilterConnectString;
  158. dataSource = filter.FilterData.Tables[0].Copy();
  159. dataSource.TableName = "Hand";
  160. ds.Tables.Add(dataSource);
  161. body = ICSMOBLL.GetMOBOM(sqltxt).Copy();
  162. body.TableName = "Body";
  163. ds.Tables.Add(body);
  164. DataRelation dr = new DataRelation("子件资料", new DataColumn[] { ds.Tables["Hand"].Columns["MOCODE"], ds.Tables["Hand"].Columns["MOSEQ"]}, new DataColumn[] { ds.Tables["Body"].Columns["MOCODE"], ds.Tables["Body"].Columns["SEQ"] });
  165. ds.Relations.Add(dr);
  166. grdDetail.DataSource = ds.Tables["Hand"];
  167. grvDetail.BestFitColumns();
  168. rptPage.RecordNum = dataSource.Rows.Count;
  169. rptPage.PageSize = 499;
  170. rptPage.PageIndex = 1;
  171. rptPage.ReLoad();
  172. rptPage.PageSize = 500;
  173. rptPage.PageIndex = 1;
  174. //rptPage.ReLoad();
  175. _wait.Close();
  176. }
  177. catch (Exception ex)
  178. {
  179. MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  180. _wait.Close();
  181. }
  182. }
  183. }
  184. #endregion
  185. #region 绑定数据源
  186. private void btnConfig_Click(object sender, EventArgs e)
  187. {
  188. if (AppConfig.UserCode.ToLower() != "demo")
  189. {
  190. ICSBaseSimpleCode.AppshowMessageBox("您没有权限设置数据源,请联系软件提供商!");
  191. return;
  192. }
  193. FormDataSource fdata = new FormDataSource(AppConfig.GetMenuId(this.Tag.ToString()), btnConfig.Name);
  194. fdata.ShowDialog();
  195. }
  196. #endregion
  197. #region 分页
  198. private void rptPage_PageIndexChanged(object Sender, EventArgs e)
  199. {
  200. DataTable data = AppConfig.GetPageData(dataSource, rptPage.PageIndex, rptPage.PageSize).Copy();
  201. //DataTable data = AppConfig.GetPageDataByDb(tempTableName, "pagerowindex", rptPage.PageSize, rptPage.PageIndex, dataSource.Rows.Count);
  202. grdDetail.DataSource = data;
  203. }
  204. #endregion
  205. #region 过滤方法
  206. private void FormContainerManager_FormClosing(object sender, FormClosingEventArgs e)
  207. {
  208. AppConfig.DropTemTable(tempTableName);
  209. }
  210. #endregion
  211. #region 全选
  212. private void btnSelectAll_Click(object sender, EventArgs e)
  213. {
  214. grvDetail.PostEditor();
  215. this.Validate();
  216. for (int i = 0; i < grvDetail.RowCount; i++)
  217. {
  218. grvDetail.SetRowCellValue(i, colisSelect, "Y");
  219. }
  220. }
  221. #endregion
  222. #region 全消
  223. private void btnCancelAll_Click(object sender, EventArgs e)
  224. {
  225. grvDetail.PostEditor();
  226. this.Validate();
  227. for (int i = 0; i < grvDetail.RowCount; i++)
  228. {
  229. grvDetail.SetRowCellValue(i, colisSelect, "");
  230. }
  231. }
  232. #endregion
  233. #region 双击
  234. private void grvDetail_DoubleClick(object sender, EventArgs e)
  235. {
  236. if (grvDetail.FocusedRowHandle < 0)
  237. {
  238. return;
  239. }
  240. if (grvDetail.FocusedColumn == colisSelect)
  241. {
  242. if (grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colisSelect).ToString() == "")
  243. {
  244. grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colisSelect, "Y");
  245. }
  246. else
  247. {
  248. grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colisSelect, "");
  249. }
  250. }
  251. }
  252. #endregion
  253. #region 导出
  254. private void btnOutPut_Click(object sender, EventArgs e)
  255. {
  256. SimpleButton btntemp = (SimpleButton)sender;
  257. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  258. {
  259. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  260. return;
  261. }
  262. FormOutExcel foe = new FormOutExcel(this.Tag.ToString(), grdDetail);
  263. foe.ShowDialog();
  264. }
  265. #endregion
  266. #region 刷新
  267. private void btnRefresh_Click(object sender, EventArgs e)
  268. {
  269. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在查找...请稍等...");
  270. try
  271. {
  272. _wait.Show();
  273. ds.Reset();
  274. dataSource = null;
  275. body = null;
  276. FormFilter filter = new FormFilter(AppConfig.GetSourceId(this.Tag.ToString(), btnConfig.Name), false);
  277. filter.OldTempTableName = tempTableName;
  278. //tempTableName = filter.NewTempTableName;
  279. //DataTable data = DBHelper.ExecuteDataset(AppConfig.FrameConnectString, CommandType.Text, "select * from " + tempTableName).Tables[0];
  280. dataSource = DBHelper.ExecuteDataset(sqlconn, CommandType.Text, sqltxt).Tables[0].Copy();
  281. dataSource.TableName = "Hand";
  282. ds.Tables.Add(dataSource);
  283. body = ICSMOBLL.GetMOBOM(sqltxt).Copy();
  284. body.TableName = "Body";
  285. ds.Tables.Add(body);
  286. DataRelation dr = new DataRelation("子件资料", new DataColumn[] { ds.Tables["Hand"].Columns["MOCODE"], ds.Tables["Hand"].Columns["MOSEQ"] }, new DataColumn[] { ds.Tables["Body"].Columns["MOCODE"], ds.Tables["Body"].Columns["SEQ"] });
  287. ds.Relations.Add(dr);
  288. grdDetail.DataSource = ds.Tables["Hand"];
  289. grvDetail.BestFitColumns();
  290. rptPage.RecordNum = dataSource.Rows.Count;
  291. rptPage.PageIndex = 1;
  292. //rptPage.ReLoad();
  293. _wait.Close();
  294. }
  295. catch (Exception ex)
  296. {
  297. MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  298. _wait.Close();
  299. }
  300. }
  301. #endregion
  302. //#region 新增
  303. //private void btnCreate_Click(object sender, EventArgs e)
  304. //{
  305. // SimpleButton btntemp = (SimpleButton)sender;
  306. // if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  307. // {
  308. // ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  309. // return;
  310. // }
  311. // FormICSMOAdd add = new FormICSMOAdd();
  312. // add.ShowDialog();
  313. // btnRefresh_Click(null, null);
  314. //}
  315. //#endregion
  316. //#region 修改
  317. //private void btnModify_Click(object sender, EventArgs e)
  318. //{
  319. // SimpleButton btntemp = (SimpleButton)sender;
  320. // if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  321. // {
  322. // ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  323. // return;
  324. // }
  325. // int count = 0;
  326. // for (int i = 0; i < grvDetail.RowCount; i++)
  327. // {
  328. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  329. // {
  330. // count++;
  331. // }
  332. // }
  333. // if (count != 1)
  334. // {
  335. // ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  336. // return;
  337. // }
  338. // try
  339. // {
  340. // string moid;
  341. // for (int i = 0; i < grvDetail.RowCount; i++)
  342. // {
  343. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  344. // {
  345. // moid = grvDetail.GetRowCellValue(i, colID).ToString();
  346. // FormICSMOAdd add = new FormICSMOAdd(moid);
  347. // add.ShowDialog();
  348. // }
  349. // }
  350. // btnRefresh_Click(null, null);
  351. // }
  352. // catch (Exception ex)
  353. // {
  354. // //throw ex;
  355. // ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  356. // }
  357. //}
  358. //#endregion
  359. //#region 删除
  360. //private void btnDel_Click(object sender, EventArgs e)
  361. //{
  362. // SimpleButton btntemp = (SimpleButton)sender;
  363. // if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  364. // {
  365. // ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  366. // return;
  367. // }
  368. // List<string> moidList = new List<string>();
  369. // for (int i = 0; i < grvDetail.RowCount; i++)
  370. // {
  371. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  372. // {
  373. // moidList.Add(grvDetail.GetRowCellValue(i, colID).ToString());
  374. // }
  375. // }
  376. // if (moidList.Count == 0 || moidList == null)
  377. // {
  378. // ICSBaseSimpleCode.AppshowMessageBox("请选择数据");
  379. // return;
  380. // }
  381. // if (ICSBaseSimpleCode.AppshowMessageBoxRepose("确定删除工单吗?删除后无法恢复,确定吗?") != DialogResult.OK)
  382. // {
  383. // btnCancelAll_Click(sender, e);
  384. // return;
  385. // }
  386. // try
  387. // {
  388. // ICSMOBLL.deleteInfo(moidList, AppConfig.AppConnectString);
  389. // ICSBaseSimpleCode.AppshowMessageBox("删除成功");
  390. // }
  391. // catch (Exception ex)
  392. // {
  393. // ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  394. // }
  395. // btnRefresh_Click(null, null);
  396. //}
  397. //#endregion
  398. private void ICSItemLot_FormClosing(object sender, FormClosingEventArgs e)
  399. {
  400. AppConfig.DropTemTable(tempTableName);
  401. }
  402. private void FormICSMO_Load(object sender, EventArgs e)
  403. {
  404. btnFilter_Click(sender, e);
  405. }
  406. private void grvDetail_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
  407. {
  408. if (e.RowHandle >= 0 && e.Column.FieldName == "DCTCODE")
  409. {
  410. //e.DisplayText = FormatHelper.
  411. e.CellValue = "cccc";
  412. }
  413. }
  414. //生成序列号
  415. private void newRcard_Click(object sender, EventArgs e)
  416. {
  417. //SimpleButton btntemp = (SimpleButton)sender;
  418. //if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  419. //{
  420. // ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  421. // return;
  422. //}
  423. //int count = 0;
  424. //for (int i = 0; i < grvDetail.RowCount; i++)
  425. //{
  426. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  427. // {
  428. // count++;
  429. // }
  430. //}
  431. //if (count != 1)
  432. //{
  433. // ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  434. // return;
  435. //}
  436. //try
  437. //{
  438. // string moID;
  439. // string moCode;
  440. // decimal qty = 0.00m;
  441. // for (int i = 0; i < grvDetail.RowCount; i++)
  442. // {
  443. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  444. // {
  445. // moID = grvDetail.GetRowCellValue(i, colID).ToString();
  446. // moCode = grvDetail.GetRowCellValue(i, colMOCODE).ToString();
  447. // qty = decimal.Parse(grvDetail.GetRowCellValue(i, colMOPLANQTY).ToString());
  448. // FormICSMO2RCARDAdd rec = new FormICSMO2RCARDAdd(moID, moCode, qty);
  449. // rec.ShowDialog();
  450. // }
  451. // }
  452. // btnRefresh_Click(null, null);
  453. //}
  454. //catch (Exception ex)
  455. //{
  456. // //throw ex;
  457. // ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  458. //}
  459. }
  460. private void repSerialButtonEdit_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  461. {
  462. try
  463. {
  464. string moID;
  465. string moCode;
  466. decimal qty = 0.00m;
  467. moID = grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colID).ToString();
  468. moCode = grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colMOCODE).ToString();
  469. qty = Convert.ToDecimal(grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colMOPLANQTY).ToString());
  470. FormICSMO2RCARDAdd rec = new FormICSMO2RCARDAdd(moID, moCode, qty);
  471. rec.ShowDialog();
  472. btnRefresh_Click(null, null);
  473. }
  474. catch (Exception ex)
  475. {
  476. throw ex;
  477. }
  478. }
  479. //下发
  480. //private void txtsend_Click(object sender, EventArgs e)
  481. //{
  482. // SimpleButton btntemp = (SimpleButton)sender;
  483. // if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  484. // {
  485. // ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  486. // return;
  487. // }
  488. // int count = 0;
  489. // for (int i = 0; i < grvDetail.RowCount; i++)
  490. // {
  491. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  492. // {
  493. // count++;
  494. // }
  495. // }
  496. // if (count != 1)
  497. // {
  498. // ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  499. // return;
  500. // }
  501. // try
  502. // {
  503. // string mocode="";
  504. // string state = "";
  505. // for (int i = 0; i < grvDetail.RowCount; i++)
  506. // {
  507. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  508. // {
  509. // mocode = grvDetail.GetRowCellValue(i,colMOCODE).ToString();
  510. // state = grvDetail.GetRowCellValue(i, colMOSTATUS).ToString();
  511. // }
  512. // }
  513. // //判断是否是初始状态
  514. // if (state.Equals("初始"))
  515. // {
  516. // //判断是否在工单首检记录表中
  517. // if (ICSMOBLL.isInFirstCheck(mocode, AppConfig.AppConnectString))
  518. // {
  519. // //判断(最近的时间)是否合格
  520. // if (ICSMOBLL.isQualified(mocode, AppConfig.AppConnectString))
  521. // {
  522. // ICSMOBLL.Send(mocode,AppConfig.AppConnectString);
  523. // ICSBaseSimpleCode.AppshowMessageBox("下发成功");
  524. // }
  525. // else
  526. // {
  527. // ICSBaseSimpleCode.AppshowMessageBox("不合格,不能下发");
  528. // return;
  529. // }
  530. // }
  531. // else
  532. // {
  533. // ICSBaseSimpleCode.AppshowMessageBox("不存在工单首检记录中");
  534. // return;
  535. // }
  536. // }
  537. // else
  538. // {
  539. // ICSBaseSimpleCode.AppshowMessageBox("不是初始状态,不能下发");
  540. // return;
  541. // }
  542. // btnRefresh_Click(null, null);
  543. // }
  544. // catch (Exception ex)
  545. // {
  546. // ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  547. // }
  548. //}
  549. ////取消下发
  550. //private void txtcancelSend_Click(object sender, EventArgs e)
  551. //{
  552. // SimpleButton btntemp = (SimpleButton)sender;
  553. // if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  554. // {
  555. // ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  556. // return;
  557. // }
  558. // int count = 0;
  559. // for (int i = 0; i < grvDetail.RowCount; i++)
  560. // {
  561. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  562. // {
  563. // count++;
  564. // }
  565. // }
  566. // if (count != 1)
  567. // {
  568. // ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  569. // return;
  570. // }
  571. // try
  572. // {
  573. // string mocode = "";
  574. // string state = "";
  575. // for (int i = 0; i < grvDetail.RowCount; i++)
  576. // {
  577. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  578. // {
  579. // mocode = grvDetail.GetRowCellValue(i, colMOCODE).ToString();
  580. // state = grvDetail.GetRowCellValue(i, colMOSTATUS).ToString();
  581. // }
  582. // }
  583. // //判断是否是下发状态
  584. // if (state.Equals("下发"))
  585. // {
  586. // ICSMOBLL.cancelSend(mocode,AppConfig.AppConnectString);
  587. // ICSBaseSimpleCode.AppshowMessageBox("取消下发成功");
  588. // }
  589. // else
  590. // {
  591. // ICSBaseSimpleCode.AppshowMessageBox("不是下发状态,不能取消下发");
  592. // return;
  593. // }
  594. // btnRefresh_Click(null, null);
  595. // }
  596. // catch (Exception ex)
  597. // {
  598. // ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  599. // }
  600. //}
  601. ////暂停
  602. //private void txtstop_Click(object sender, EventArgs e)
  603. //{
  604. // SimpleButton btntemp = (SimpleButton)sender;
  605. // if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  606. // {
  607. // ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  608. // return;
  609. // }
  610. // int count = 0;
  611. // for (int i = 0; i < grvDetail.RowCount; i++)
  612. // {
  613. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  614. // {
  615. // count++;
  616. // }
  617. // }
  618. // if (count != 1)
  619. // {
  620. // ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  621. // return;
  622. // }
  623. // try
  624. // {
  625. // string mocode = "";
  626. // string state = "";
  627. // for (int i = 0; i < grvDetail.RowCount; i++)
  628. // {
  629. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  630. // {
  631. // mocode = grvDetail.GetRowCellValue(i, colMOCODE).ToString();
  632. // state = grvDetail.GetRowCellValue(i, colMOSTATUS).ToString();
  633. // }
  634. // }
  635. // //判断是否是生产中状态
  636. // if (state.Equals("生产中"))
  637. // {
  638. // ICSMOBLL.stop(mocode, AppConfig.AppConnectString);
  639. // ICSBaseSimpleCode.AppshowMessageBox("暂停成功");
  640. // }
  641. // else
  642. // {
  643. // ICSBaseSimpleCode.AppshowMessageBox("不是生产中状态,不能暂停");
  644. // return;
  645. // }
  646. // btnRefresh_Click(null, null);
  647. // }
  648. // catch (Exception ex)
  649. // {
  650. // ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  651. // }
  652. //}
  653. ////取消暂停
  654. //private void txtcancelStop_Click(object sender, EventArgs e)
  655. //{
  656. // SimpleButton btntemp = (SimpleButton)sender;
  657. // if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  658. // {
  659. // ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  660. // return;
  661. // }
  662. // int count = 0;
  663. // for (int i = 0; i < grvDetail.RowCount; i++)
  664. // {
  665. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  666. // {
  667. // count++;
  668. // }
  669. // }
  670. // if (count != 1)
  671. // {
  672. // ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  673. // return;
  674. // }
  675. // try
  676. // {
  677. // string mocode = "";
  678. // string state = "";
  679. // for (int i = 0; i < grvDetail.RowCount; i++)
  680. // {
  681. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  682. // {
  683. // mocode = grvDetail.GetRowCellValue(i, colMOCODE).ToString();
  684. // state = grvDetail.GetRowCellValue(i, colMOSTATUS).ToString();
  685. // }
  686. // }
  687. // //判断是否是暂停状态
  688. // if (state.Equals("暂停"))
  689. // {
  690. // ICSMOBLL.cancelStop(mocode, AppConfig.AppConnectString);
  691. // ICSBaseSimpleCode.AppshowMessageBox("取消暂停成功");
  692. // }
  693. // else
  694. // {
  695. // ICSBaseSimpleCode.AppshowMessageBox("不是暂停状态,不能取消暂停");
  696. // return;
  697. // }
  698. // btnRefresh_Click(null, null);
  699. // }
  700. // catch (Exception ex)
  701. // {
  702. // ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  703. // }
  704. //}
  705. ////关单
  706. //private void txtcloseDan_Click(object sender, EventArgs e)
  707. //{
  708. // SimpleButton btntemp = (SimpleButton)sender;
  709. // if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  710. // {
  711. // ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  712. // return;
  713. // }
  714. // int count = 0;
  715. // for (int i = 0; i < grvDetail.RowCount; i++)
  716. // {
  717. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  718. // {
  719. // count++;
  720. // }
  721. // }
  722. // if (count != 1)
  723. // {
  724. // ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  725. // return;
  726. // }
  727. // try
  728. // {
  729. // string mocode = "";
  730. // string state = "";
  731. // for (int i = 0; i < grvDetail.RowCount; i++)
  732. // {
  733. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  734. // {
  735. // mocode = grvDetail.GetRowCellValue(i, colMOCODE).ToString();
  736. // state = grvDetail.GetRowCellValue(i, colMOSTATUS).ToString();
  737. // }
  738. // }
  739. // //判断是否是关单状态
  740. // if (!(state.Equals("关单")))
  741. // {
  742. // ICSMOBLL.closeDan(mocode, AppConfig.AppConnectString);
  743. // ICSBaseSimpleCode.AppshowMessageBox("关单成功");
  744. // }
  745. // else
  746. // {
  747. // ICSBaseSimpleCode.AppshowMessageBox("已经是关单状态");
  748. // return;
  749. // }
  750. // btnRefresh_Click(null, null);
  751. // }
  752. // catch (Exception ex)
  753. // {
  754. // ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  755. // }
  756. //}
  757. //同步
  758. private void btnGetInfo_Click(object sender, EventArgs e)
  759. {
  760. SimpleButton btntemp = (SimpleButton)sender;
  761. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  762. {
  763. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  764. return;
  765. }
  766. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在同步请稍等...");
  767. try
  768. {
  769. string sql = @"delete ICSMO
  770. where MOCODE in
  771. (SELECT a.MoCode
  772. FROM {1}.dbo.mom_order a
  773. INNER JOIN {1}.dbo.mom_orderdetail b ON a.MoId = b.MoId
  774. LEFT JOIN [ICSMES_WLSys].[dbo].ICSMO d ON b.MoDId = d.EATTRIBUTE1
  775. and isnull(a.ModifyTime,'') = isnull(d.EATTRIBUTE2,'')
  776. WHERE (b.RelsUser IS NOT NULL OR b.RelsUser <> '')
  777. AND b.CloseUser IS NULL AND ISNULL(b.QualifiedInQty,0) = 0
  778. AND d.EATTRIBUTE1 IS NULL and a.CreateDate >= '2018-01-01 00:00:00.000')
  779. delete ICSMO
  780. where MOCODE in
  781. (select b.MOCODE from {1}.dbo.mom_order a
  782. right join ICSMO b on a.MoCode = b.MOCODE where a.MoCode is null)
  783. delete ICSMOBOM
  784. where MOBITEMECN in
  785. (SELECT c.AllocateId
  786. FROM {1}.dbo.mom_order a
  787. INNER JOIN {1}.dbo.mom_orderdetail b ON a.MoId = b.MoId
  788. INNER JOIN {1}.dbo.mom_moallocate c ON b.MoDId = c.MoDId
  789. LEFT JOIN [dbo].ICSMO g
  790. ON b.MoDId = g.EATTRIBUTE1 and isnull(a.ModifyTime,'') = isnull(g.EATTRIBUTE2,'')
  791. LEFT JOIN [dbo].ICSMOBOM bom ON c.AllocateId = bom.MOBITEMECN
  792. WHERE (b.RelsUser IS NOT NULL OR b.RelsUser <> '')
  793. AND b.CloseUser IS NULL AND ISNULL(b.QualifiedInQty,0) = 0
  794. AND bom.MOBITEMECN IS NULL and a.CreateDate >= '2018-01-01 00:00:00.000')
  795. delete ICSMOBOM
  796. where MOBITEMECN in
  797. (select b.MOBITEMECN from {1}.dbo.mom_moallocate a
  798. right join ICSMOBOM b on a.AllocateId = b.MOBITEMECN where a.AllocateId is null)
  799. INSERT INTO [ICSMES_WLSys].[dbo].[ICSMO] (
  800. [ID],[MOCODE],[MOMEMO],[MOTYPE],[MODESC],[MOBIOSVER]
  801. ,[MOPCBAVER],[MOPLANQTY],[MOINPUTQTY],[MOSCRAPQTY],[MOACTQTY]
  802. ,[MOPLANSTARTDATE],[MOPLANENDDATE],[MOACTSTARTDATE],[MOACTENDDATE]
  803. ,[FACTORY],[CUSCODE],[CUSNAME],[CUSORDERNO] ,[CUSITEMCODE],[ORDERNO]
  804. ,[ORDERSEQ],[MOUSER],[MODOWNDATE],[MOSTATUS],[MOVER],[ISCONINPUT]
  805. ,[ISBOMPASS],[IDMERGERULE],[WorkPoint],[MUSER],[MUSERName]
  806. ,[MTIME],[EATTRIBUTE1],[ITEMCODE],[MORELEASETIME],[MOPENDINGCAUSE]
  807. ,[MOIMPORTTIME],[OFFMOQTY],[ISCOMPARESOFT],[RMABILLCODE],[MOSEQ]
  808. ,[REMOCODE],[REMOITEMCODE],[REMOITEMDESC],[REMOLOTNO],[REMOENABLED]
  809. ,[MOBOM],[MOOP],[ITEMDESC],[MOPLANENDTIME],[MOPLANLINE],[BackflushStorage]
  810. ,[WarningStopLine],[MORemark],[EATTRIBUTE2],[EATTRIBUTE3],[EATTRIBUTE4])
  811. SELECT NEWID(), a.MoCode,'','','','','',b.Qty,'0','0','0',
  812. c.StartDate,c.DueDate,c.StartDate,c.DueDate,'',b.CustCode,cus.cCusName,b.OrderCode,cusInv.cCusInvCode,
  813. b.OrderCode,ISNULL(so.iRowNo,''),'',a.CreateDate,'','','','','0.00','{0}',
  814. '','',GETDATE(),b.MoDId,b.InvCode,
  815. NULL,'',GETDATE(),'0.00','0','',b.SortSeq,'','','','','',b.PartId,'','',NULL,
  816. '','','',ISNULL(b.Remark,''),CONVERT(NVARCHAR(50),a.ModifyTime,21),NULL,NULL
  817. FROM {1}.dbo.mom_order a
  818. INNER JOIN {1}.dbo.mom_orderdetail b ON a.MoId = b.MoId
  819. INNER JOIN {1}.dbo.mom_morder c ON b.MoDId = c.MoDId
  820. LEFT JOIN {1}.dbo.Customer cus ON b.CustCode = cus.cCusCode
  821. LEFT JOIN {1}.dbo.SO_SODetails so ON b.OrderDId = so.iSOsID
  822. LEFT JOIN {1}.dbo.CusInvContrapose cusInv
  823. ON cusinv.cCusCode = b.CustCode AND b.InvCode = cusInv.cInvCode
  824. LEFT JOIN [ICSMES_WLSys].[dbo].ICSMO d
  825. ON b.MoDId = d.EATTRIBUTE1 and isnull(a.ModifyTime,'') = isnull(d.EATTRIBUTE2,'')
  826. WHERE (b.RelsUser IS NOT NULL OR b.RelsUser <> '')
  827. AND b.CloseUser IS NULL AND ISNULL(b.QualifiedInQty,0) = 0
  828. AND d.EATTRIBUTE1 IS NULL and a.CreateDate >= '2018-01-01 00:00:00.000'
  829. INSERT INTO [ICSMES_WLSys].[dbo].ICSMOBOM
  830. SELECT a.MoCode,b.InvCode,b.SortSeq,c.InvCode,c.AllocateId,d.cInvName,d.cInvStd,
  831. '1','',GETDATE(),DATEADD(YEAR,100,GETDATE()),BaseQtyN,'','',
  832. '','','',GETDATE(),'{0}','',
  833. unit.cComUnitName,CONVERT(INT,SUBSTRING(c.Ufts,0,18)),f.Version,c.SortSeq,'',''
  834. FROM {1}.dbo.mom_order a
  835. INNER JOIN {1}.dbo.mom_orderdetail b ON a.MoId = b.MoId
  836. INNER JOIN {1}.dbo.mom_moallocate c ON b.MoDId = c.MoDId
  837. INNER JOIN {1}.dbo.Inventory d ON c.InvCode = d.cInvCode
  838. LEFT JOIN {1}.dbo.bom_parent e ON b.BomId = e.ParentId
  839. LEFT JOIN {1}.dbo.bom_bom f ON e.BomId = f.BomId
  840. LEFT JOIN [dbo].ICSMO g
  841. ON b.MoDId = g.EATTRIBUTE1 and isnull(a.ModifyTime,'') = isnull(g.EATTRIBUTE2,'')
  842. LEFT JOIN [dbo].ICSMOBOM bom ON c.AllocateId = bom.MOBITEMECN
  843. LEFT JOIN {1}.dbo.ComputationUnit unit
  844. ON d.cComUnitCode = unit.cComunitCode
  845. WHERE (b.RelsUser IS NOT NULL OR b.RelsUser <> '')
  846. AND b.CloseUser IS NULL AND ISNULL(b.QualifiedInQty,0) = 0
  847. AND bom.MOBITEMECN IS NULL and a.CreateDate >= '2018-01-01 00:00:00.000'
  848. UPDATE a SET a.MOBITEMQTY = b.BaseQtyN
  849. FROM dbo.ICSMOBOM a
  850. INNER JOIN {1}.dbo.mom_moallocate b
  851. ON a.MOBITEMECN = b.AllocateId
  852. WHERE CONVERT(INT,SUBSTRING(b.Ufts,0,18)) <> a.OPCODE";
  853. sql = string.Format(sql, AppConfig.WorkPointCode, ICSBaseSimpleCode.GetWorkPointErpData());
  854. DBHelper.ExecuteNonQuery(AppConfig.AppConnectString, CommandType.Text, sql);
  855. _wait.Close();
  856. ICSBaseSimpleCode.AppshowMessageBox("同步成功");
  857. }
  858. catch (Exception ex)
  859. {
  860. _wait.Close();
  861. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  862. }
  863. }
  864. }
  865. }