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

962 lines
40 KiB

5 months ago
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Drawing;
  5. using System.Windows.Forms;
  6. using DevExpress.XtraEditors;
  7. using ICSSoft.Base.Config.AppConfig;
  8. using ICSSoft.Base.Config.DBHelper;
  9. using ICSSoft.Base.Report.Filter;
  10. using ICSSoft.Base.UserControl.FormControl;
  11. using ICSSoft.Frame.Data.BLL;
  12. using ICSSoft.Frame.Data.Entity;
  13. namespace ICSSoft.Frame.APP
  14. {
  15. public partial class FormICSMROPicking : DevExpress.XtraEditors.XtraForm
  16. {
  17. private string sqltxt = "";
  18. private string sqlconn = "";
  19. String guid = AppConfig.GetGuid();
  20. private DataTable dataSource = null;
  21. private DataTable body = null;
  22. private DataSet ds = new DataSet();
  23. #region 构造函数
  24. public FormICSMROPicking()
  25. {
  26. InitializeComponent();
  27. this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  28. this.WindowState = FormWindowState.Maximized;
  29. }
  30. #endregion
  31. #region 操作权限
  32. public DataTable RightOfExute()
  33. {
  34. DataTable rData = new DataTable();
  35. rData.Columns.Add("BtnName");
  36. rData.Columns.Add("ActionName");
  37. //查看权限(必须有)
  38. DataRow seeRow = rData.NewRow();
  39. seeRow["BtnName"] = "see";
  40. seeRow["ActionName"] = "查看";
  41. rData.Rows.Add(seeRow);
  42. List<Control> ControlList = new List<Control>();
  43. ControlList.Add(btnFilter);
  44. ControlList.Add(btnSelectAll);
  45. ControlList.Add(btnCancelAll);
  46. ControlList.Add(btnCreate);
  47. ControlList.Add(btnOutPut);
  48. ControlList.Add(btnModify);
  49. ControlList.Add(btnRefresh);
  50. ControlList.Add(txtDeptCheck);
  51. ControlList.Add(BtnDiscardedTrial);
  52. ControlList.Add(BtnRefuse);
  53. ControlList.Add(btnDele);
  54. foreach (Control ctr in ControlList)
  55. {
  56. if (ctr.GetType() == typeof(SimpleButton))
  57. {
  58. DataRow dr = rData.NewRow();
  59. dr["BtnName"] = ctr.Name;
  60. dr["ActionName"] = ctr.Text;
  61. rData.Rows.Add(dr);
  62. }
  63. }
  64. rData.AcceptChanges();
  65. return rData;
  66. }
  67. public DataTable RightOfData()// 数据权限
  68. {
  69. DataTable rData = new DataTable();
  70. rData.Columns.Add("BodyName");
  71. rData.Columns.Add("ControlName");
  72. rData.Columns.Add("ControlCaption");
  73. rData.AcceptChanges();
  74. return rData;
  75. }
  76. #endregion
  77. #region 退出
  78. private void btnClose_Click(object sender, EventArgs e)
  79. {
  80. AppConfig.CloseFormShow(this.Text);
  81. this.Close();
  82. }
  83. private void btnExit_Click(object sender, EventArgs e)
  84. {
  85. AppConfig.CloseFormShow(this.Text);
  86. this.Close();
  87. }
  88. #endregion
  89. #region 移动窗体
  90. private const int WM_NCHITTEST = 0x84;
  91. private const int HTCLIENT = 0x1;
  92. private const int HTCAPTION = 0x2;
  93. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  94. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  95. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  96. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  97. //重写窗体,使窗体可以不通过自带标题栏实现移动
  98. protected override void WndProc(ref Message m)
  99. {
  100. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  101. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  102. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  103. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  104. switch (m.Msg)
  105. {
  106. case WM_NCHITTEST:
  107. base.WndProc(ref m);
  108. if ((int)m.Result == HTCLIENT)
  109. m.Result = (IntPtr)HTCAPTION;
  110. return;
  111. }
  112. //拦截双击标题栏、移动窗体的系统消息
  113. if (m.Msg != 0xA3)
  114. {
  115. base.WndProc(ref m);
  116. }
  117. }
  118. #endregion
  119. #region 列表
  120. private void grvDetail_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
  121. {
  122. if (e.Info.IsRowIndicator && e.RowHandle >= 0)
  123. e.Info.DisplayText = (e.RowHandle + 1).ToString();
  124. }
  125. #endregion
  126. #region 过滤
  127. private string tempTableName = "";
  128. private void btnFilter_Click(object sender, EventArgs e)
  129. {
  130. FormFilter filter = new FormFilter(AppConfig.GetSourceId(this.Tag.ToString(), btnConfig.Name));
  131. filter.OldTempTableName = tempTableName;
  132. if (filter.ShowDialog() == DialogResult.OK)
  133. {
  134. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在查找...请稍等...");
  135. try
  136. {
  137. //_wait.Show();
  138. //ds.Reset();
  139. //dataSource = null;
  140. //body = null;
  141. //tempTableName = filter.NewTempTableName;
  142. //sqltxt = filter.SqlText;
  143. //sqlconn = filter.FilterConnectString;
  144. //dataSource = filter.FilterData.Tables[0];
  145. //dataSource.TableName = "Hand";
  146. //ds.Tables.Add(dataSource.Copy());
  147. //body = ICSPickingBLL.GetDetail(sqltxt);
  148. //body.TableName = "Body";
  149. //ds.Tables.Add(body.Copy());
  150. //DataRelation dr = new DataRelation("详情", new DataColumn[] { ds.Tables["Hand"].Columns["VouchCode"] }, new DataColumn[] { ds.Tables["Body"].Columns["VouchCode"] });
  151. //ds.Relations.Add(dr);
  152. //grdDetail.DataSource = ds.Tables["Hand"];
  153. //grvDetail.BestFitColumns();
  154. //rptPage.RecordNum = dataSource.Rows.Count;
  155. //rptPage.PageSize = 499;
  156. //rptPage.PageIndex = 1;
  157. //rptPage.ReLoad();
  158. //rptPage.PageSize = 500;
  159. //rptPage.PageIndex = 1;
  160. ////rptPage.ReLoad();
  161. //_wait.Close();
  162. _wait.Show();
  163. ds.Reset();
  164. dataSource = null;
  165. body = null;
  166. //FormFilter filter = new FormFilter(AppConfig.GetSourceId(this.Tag.ToString(), btnConfig.Name), false);
  167. //filter.OldTempTableName = tempTableName;
  168. //tempTableName = filter.NewTempTableName;
  169. //DataTable data = DBHelper.ExecuteDataset(AppConfig.FrameConnectString, CommandType.Text, "select * from " + tempTableName).Tables[0];
  170. sqltxt = filter.SqlText;
  171. sqlconn = filter.FilterConnectString;
  172. dataSource = DBHelper.ExecuteDataset(sqlconn, CommandType.Text, sqltxt).Tables[0];
  173. dataSource.TableName = "Hand";
  174. ds.Tables.Add(dataSource.Copy());
  175. body = ICSPickingBLL.GetDetail(sqltxt);
  176. body.TableName = "Body";
  177. ds.Tables.Add(body.Copy());
  178. DataRelation dr = new DataRelation("详情", new DataColumn[] { ds.Tables["Hand"].Columns["VouchCode"] }, new DataColumn[] { ds.Tables["Body"].Columns["VouchCode"] });
  179. ds.Relations.Add(dr);
  180. grdDetail.DataSource = ds.Tables["Hand"];
  181. grvDetail.BestFitColumns();
  182. rptPage.RecordNum = dataSource.Rows.Count;
  183. rptPage.PageIndex = 1;
  184. //rptPage.ReLoad();
  185. _wait.Close();
  186. }
  187. catch (Exception ex)
  188. {
  189. MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  190. _wait.Close();
  191. }
  192. }
  193. }
  194. #endregion
  195. #region 绑定数据源
  196. private void btnConfig_Click(object sender, EventArgs e)
  197. {
  198. if (AppConfig.UserCode.ToLower() != "demo")
  199. {
  200. ICSBaseSimpleCode.AppshowMessageBox("您没有权限设置数据源,请联系软件提供商!");
  201. return;
  202. }
  203. FormDataSource fdata = new FormDataSource(AppConfig.GetMenuId(this.Tag.ToString()), btnConfig.Name);
  204. fdata.ShowDialog();
  205. }
  206. #endregion
  207. #region 分页
  208. private void rptPage_PageIndexChanged(object Sender, EventArgs e)
  209. {
  210. DataTable data = AppConfig.GetPageData(dataSource, rptPage.PageIndex, rptPage.PageSize).Copy();
  211. //DataTable data = AppConfig.GetPageDataByDb(tempTableName, "pagerowindex", rptPage.PageSize, rptPage.PageIndex, dataSource.Rows.Count);
  212. grdDetail.DataSource = data;
  213. }
  214. #endregion
  215. #region 过滤方法
  216. private void FormContainerManager_FormClosing(object sender, FormClosingEventArgs e)
  217. {
  218. AppConfig.DropTemTable(tempTableName);
  219. }
  220. #endregion
  221. #region 全选
  222. private void btnSelectAll_Click(object sender, EventArgs e)
  223. {
  224. grvDetail.PostEditor();
  225. this.Validate();
  226. for (int i = 0; i < grvDetail.RowCount; i++)
  227. {
  228. grvDetail.SetRowCellValue(i, colisSelect, "Y");
  229. }
  230. }
  231. #endregion
  232. #region 全消
  233. private void btnCancelAll_Click(object sender, EventArgs e)
  234. {
  235. grvDetail.PostEditor();
  236. this.Validate();
  237. for (int i = 0; i < grvDetail.RowCount; i++)
  238. {
  239. grvDetail.SetRowCellValue(i, colisSelect, "");
  240. }
  241. }
  242. #endregion
  243. #region 双击
  244. private void grvDetail_DoubleClick(object sender, EventArgs e)
  245. {
  246. if (grvDetail.FocusedRowHandle < 0)
  247. {
  248. return;
  249. }
  250. if (grvDetail.FocusedColumn == colisSelect)
  251. {
  252. if (grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colisSelect).ToString() == "")
  253. {
  254. grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colisSelect, "Y");
  255. }
  256. else
  257. {
  258. grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colisSelect, "");
  259. }
  260. }
  261. }
  262. #endregion
  263. #region 导出
  264. private void btnOutPut_Click(object sender, EventArgs e)
  265. {
  266. try
  267. {
  268. FormOutExcel foe = new FormOutExcel(this.Tag.ToString(), grdDetail);
  269. foe.ShowDialog();
  270. }
  271. catch (Exception ex)
  272. {
  273. MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  274. }
  275. //SimpleButton btntemp = (SimpleButton)sender;
  276. //if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  277. //{
  278. // ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  279. // return;
  280. //}
  281. //FormOutExcel foe = new FormOutExcel();
  282. //if (foe.ShowDialog() == DialogResult.OK)
  283. //{
  284. // try
  285. // {
  286. // string outtype = foe._OutType;
  287. // string exceltype = foe._ExcelType;
  288. // string filename = foe._FileName;
  289. // string url = foe._Url;
  290. // string sheetname = foe._SheetName;
  291. // if (outtype.ToLower() == "excel")
  292. // {
  293. // DevExpress.XtraPrinting.XlsExportOptions op = new DevExpress.XtraPrinting.XlsExportOptions();
  294. // op.SheetName = sheetname;
  295. // grdDetail.MainView.ExportToXls((url + "\\" + filename + (exceltype == "2003" ? ".xls" : ".xlsx")), op);
  296. // }
  297. // else
  298. // {
  299. // grdDetail.MainView.ExportToPdf(url + "\\" + filename + ".pdf");
  300. // }
  301. // MessageBox.Show("导出成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  302. // }
  303. // catch (Exception ex)
  304. // {
  305. // MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  306. // }
  307. //}
  308. }
  309. #endregion
  310. #region 刷新
  311. private void btnRefresh_Click(object sender, EventArgs e)
  312. {
  313. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在查找...请稍等...");
  314. try
  315. {
  316. _wait.Show();
  317. ds.Reset();
  318. dataSource = null;
  319. body = null;
  320. FormFilter filter = new FormFilter(AppConfig.GetSourceId(this.Tag.ToString(), btnConfig.Name), false);
  321. filter.OldTempTableName = tempTableName;
  322. //tempTableName = filter.NewTempTableName;
  323. //DataTable data = DBHelper.ExecuteDataset(AppConfig.FrameConnectString, CommandType.Text, "select * from " + tempTableName).Tables[0];
  324. dataSource = DBHelper.ExecuteDataset(sqlconn, CommandType.Text, sqltxt).Tables[0];
  325. dataSource.TableName = "Hand";
  326. ds.Tables.Add(dataSource.Copy());
  327. body = ICSPickingBLL.GetDetail(sqltxt);
  328. body.TableName = "Body";
  329. ds.Tables.Add(body.Copy());
  330. DataRelation dr = new DataRelation("详情", new DataColumn[] { ds.Tables["Hand"].Columns["VouchCode"] }, new DataColumn[] { ds.Tables["Body"].Columns["VouchCode"] });
  331. ds.Relations.Add(dr);
  332. grdDetail.DataSource = ds.Tables["Hand"];
  333. grvDetail.BestFitColumns();
  334. rptPage.RecordNum = dataSource.Rows.Count;
  335. rptPage.PageIndex = 1;
  336. //rptPage.ReLoad();
  337. _wait.Close();
  338. }
  339. catch (Exception ex)
  340. {
  341. MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  342. _wait.Close();
  343. }
  344. }
  345. #endregion
  346. //#region 新增
  347. //private void btnCreate_Click(object sender, EventArgs e)
  348. //{
  349. // SimpleButton btntemp = (SimpleButton)sender;
  350. // if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  351. // {
  352. // ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  353. // return;
  354. // }
  355. // FormICSMOAdd add = new FormICSMOAdd();
  356. // add.ShowDialog();
  357. // btnRefresh_Click(null, null);
  358. //}
  359. //#endregion
  360. //#region 修改
  361. //private void btnModify_Click(object sender, EventArgs e)
  362. //{
  363. // SimpleButton btntemp = (SimpleButton)sender;
  364. // if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  365. // {
  366. // ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  367. // return;
  368. // }
  369. // int count = 0;
  370. // for (int i = 0; i < grvDetail.RowCount; i++)
  371. // {
  372. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  373. // {
  374. // count++;
  375. // }
  376. // }
  377. // if (count != 1)
  378. // {
  379. // ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  380. // return;
  381. // }
  382. // try
  383. // {
  384. // string moid;
  385. // for (int i = 0; i < grvDetail.RowCount; i++)
  386. // {
  387. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  388. // {
  389. // moid = grvDetail.GetRowCellValue(i, colID).ToString();
  390. // FormICSMOAdd add = new FormICSMOAdd(moid);
  391. // add.ShowDialog();
  392. // }
  393. // }
  394. // btnRefresh_Click(null, null);
  395. // }
  396. // catch (Exception ex)
  397. // {
  398. // //throw ex;
  399. // ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  400. // }
  401. //}
  402. //#endregion
  403. //#region 删除
  404. //private void btnDel_Click(object sender, EventArgs e)
  405. //{
  406. // SimpleButton btntemp = (SimpleButton)sender;
  407. // if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  408. // {
  409. // ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  410. // return;
  411. // }
  412. // List<string> moidList = new List<string>();
  413. // for (int i = 0; i < grvDetail.RowCount; i++)
  414. // {
  415. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  416. // {
  417. // moidList.Add(grvDetail.GetRowCellValue(i, colID).ToString());
  418. // }
  419. // }
  420. // if (moidList.Count == 0 || moidList == null)
  421. // {
  422. // ICSBaseSimpleCode.AppshowMessageBox("请选择数据");
  423. // return;
  424. // }
  425. // if (ICSBaseSimpleCode.AppshowMessageBoxRepose("确定删除工单吗?删除后无法恢复,确定吗?") != DialogResult.OK)
  426. // {
  427. // btnCancelAll_Click(sender, e);
  428. // return;
  429. // }
  430. // try
  431. // {
  432. // ICSMOBLL.deleteInfo(moidList, AppConfig.AppConnectString);
  433. // ICSBaseSimpleCode.AppshowMessageBox("删除成功");
  434. // }
  435. // catch (Exception ex)
  436. // {
  437. // ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  438. // }
  439. // btnRefresh_Click(null, null);
  440. //}
  441. //#endregion
  442. private void ICSItemLot_FormClosing(object sender, FormClosingEventArgs e)
  443. {
  444. AppConfig.DropTemTable(tempTableName);
  445. }
  446. private void FormICSMO_Load(object sender, EventArgs e)
  447. {
  448. btnFilter_Click(sender, e);
  449. }
  450. #region
  451. //生成序列号
  452. private void newRcard_Click(object sender, EventArgs e)
  453. {
  454. //SimpleButton btntemp = (SimpleButton)sender;
  455. //if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  456. //{
  457. // ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  458. // return;
  459. //}
  460. //int count = 0;
  461. //for (int i = 0; i < grvDetail.RowCount; i++)
  462. //{
  463. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  464. // {
  465. // count++;
  466. // }
  467. //}
  468. //if (count != 1)
  469. //{
  470. // ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  471. // return;
  472. //}
  473. //try
  474. //{
  475. // string moID;
  476. // string moCode;
  477. // decimal qty = 0.00m;
  478. // for (int i = 0; i < grvDetail.RowCount; i++)
  479. // {
  480. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  481. // {
  482. // moID = grvDetail.GetRowCellValue(i, colID).ToString();
  483. // moCode = grvDetail.GetRowCellValue(i, colMOCODE).ToString();
  484. // qty = decimal.Parse(grvDetail.GetRowCellValue(i, colMOPLANQTY).ToString());
  485. // FormICSMO2RCARDAdd rec = new FormICSMO2RCARDAdd(moID, moCode, qty);
  486. // rec.ShowDialog();
  487. // }
  488. // }
  489. // btnRefresh_Click(null, null);
  490. //}
  491. //catch (Exception ex)
  492. //{
  493. // //throw ex;
  494. // ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  495. //}
  496. }
  497. #endregion
  498. private void repSerialButtonEdit_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  499. {
  500. try
  501. {
  502. string moID;
  503. string moCode;
  504. decimal qty = 0.00m;
  505. moID = grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, ID).ToString();
  506. moCode = grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colMOCODE).ToString();
  507. qty = Convert.ToDecimal(grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colEATTRIBUTE1).ToString());
  508. FormICSMO2RCARDAdd rec = new FormICSMO2RCARDAdd(moID, moCode, qty);
  509. rec.ShowDialog();
  510. btnRefresh_Click(null, null);
  511. }
  512. catch (Exception ex)
  513. {
  514. throw ex;
  515. }
  516. }
  517. #region 同步
  518. private void btnGetInfo_Click(object sender, EventArgs e)
  519. {
  520. SimpleButton btntemp = (SimpleButton)sender;
  521. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  522. {
  523. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  524. return;
  525. }
  526. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在同步请稍等...");
  527. try
  528. {
  529. string sql = @"
  530. UPDATE b SET b.ReceiptNO = a.cCode,
  531. b.ReceiptLine = a.irowno,b.MEMO = a.cbMemo,b.MOCODE = a.cmocode,
  532. b.ITEMCODE = a.cInvCode,b.PLANQTY = a.iQuantity,b.QualifyQTY = a.iQuantity,
  533. b.EATTRIBUTE1 = a.AutoID,b.MOSEQ = a.imoseq,b.TYPE = a.type
  534. FROM
  535. ( SELECT e.ID,a.cCode,b.irowno,b.cbMemo,
  536. b.cmocode,b.cInvCode,b.iQuantity,
  537. b.AutoID,imoseq,CASE WHEN inv.cInvCCode LIKE '3%' THEN '' WHEN inv.cInvCCode LIKE '2%'
  538. THEN '' ELSE '' END AS type FROM UFDATA_888_2016.dbo.rdrecord10 a
  539. INNER JOIN {1}.dbo.rdrecords10 b ON a.ID = b.ID
  540. LEFT JOIN [dbo].[ICSINVReceipt] e ON a.cCode = e.ReceiptNO
  541. AND ISNULL(a.dnmodifytime,'') = ISNULL(e.[EATTRIBUTE1],'')
  542. LEFT JOIN {1}.dbo.Inventory inv ON b.cInvCode = inv.cInvCode
  543. LEFT JOIN [dbo].[ICSINVReceiptDetail] d ON d.EATTRIBUTE1 = b.AutoID
  544. WHERE (cHandler IS NULL or cHandler = '')AND e.ReceiptNO IS NULL) a
  545. INNER JOIN [ICSINVReceiptDetail] b ON a.AutoID = b.EATTRIBUTE1
  546. UPDATE b SET b.StorageID = a.Serial,b.MEMO = a.cMemo,
  547. b.CreateTIME = a.dnmaketime,b.CreateUSER = a.cMaker,
  548. b.EATTRIBUTE1 = CONVERT(NVARCHAR(50),a.dnmodifytime,21)
  549. FROM (SELECT b.Serial,a.cMemo,a.cCode,a.dnmaketime,
  550. a.cMaker,a.dnmodifytime,c.[EATTRIBUTE1]
  551. FROM {1}.dbo.rdrecord10 a
  552. INNER JOIN dbo.ICSStorage b ON a.cWhCode = b.StorageCode
  553. LEFT JOIN [dbo].[ICSINVReceipt] c ON a.cCode = c.ReceiptNO
  554. AND ISNULL(a.dnmodifytime,'') = ISNULL(c.EATTRIBUTE1,'')
  555. WHERE (cHandler IS NULL or cHandler = '') AND c.ReceiptNO IS NULL) a
  556. INNER JOIN [dbo].[ICSINVReceipt] b ON a.cCode = b.ReceiptNO
  557. INSERT INTO [dbo].[ICSINVReceipt]
  558. ([ID],[ReceiptNO],[StorageID],[RECSTATUS],[VENDORCODE]
  559. ,[RECTYPE],[MEMO],[CreateTIME],[CreateUSER],[WorkPoint]
  560. ,[MUSER],[MUSERName],[MTIME],[EATTRIBUTE1],[ISALLINSTORAGE])
  561. SELECT NEWID(),cCode,b.Serial,'','','',a.cMemo,a.dnmaketime,a.cMaker,
  562. '0001','',a.cMaker,GETDATE(),
  563. '','N' FROM {1}.dbo.rdrecord10 a
  564. INNER JOIN dbo.ICSStorage b ON a.cWhCode = b.StorageCode
  565. LEFT JOIN [dbo].[ICSINVReceipt] c ON a.cCode = c.ReceiptNO
  566. AND ISNULL(a.dnmodifytime,'') = ISNULL(c.[EATTRIBUTE1],'')
  567. WHERE (cHandler IS NULL or cHandler = '') AND c.ReceiptNO IS NULL
  568. INSERT INTO [dbo].[ICSINVReceiptDetail]
  569. ([ID],[ReceiptID],[ReceiptNO],[ReceiptLine],[ORDERNO],[ORDERLINE]
  570. ,[RECSTATUS],[IQCStatus],[MEMO],[MOCODE],[ITEMCODE],[PLANQTY]
  571. ,[QualifyQTY],[VenderLotNO],[ACTQTY],[RECTIME],[RECUSER],[WorkPoint]
  572. ,[MUSER],[MUSERName],[MTIME],[EATTRIBUTE1],[INVUSER],[ISINSTORAGE]
  573. ,[MOSEQ],[TYPE])
  574. SELECT NEWID(),c.ID,a.cCode,b.irowno,'','','','',b.cbMemo,
  575. b.cmocode,b.cInvCode,b.iQuantity,b.iQuantity,'','','','','0001',
  576. '',a.cMaker,GETDATE(),b.AutoID,NULL,
  577. 'N',imoseq,CASE WHEN inv.cInvCCode LIKE '3%' THEN '' WHEN inv.cInvCCode LIKE '2%'
  578. THEN '' ELSE '' END FROM {1}.dbo.rdrecord10 a
  579. INNER JOIN {1}.dbo.rdrecords10 b ON a.ID = b.ID
  580. INNER JOIN [dbo].[ICSINVReceipt] c ON a.cCode = c.ReceiptNO
  581. LEFT JOIN {1}.dbo.Inventory inv ON b.cInvCode = inv.cInvCode
  582. LEFT JOIN [dbo].[ICSINVReceiptDetail] d ON d.EATTRIBUTE1 = b.AutoID
  583. WHERE (cHandler IS NULL or cHandler = '') AND d.EATTRIBUTE1 IS NULL";
  584. sql = string.Format(sql, AppConfig.WorkPointCode, ICSBaseSimpleCode.GetWorkPointErpData());
  585. DBHelper.ExecuteNonQuery(AppConfig.AppConnectString, CommandType.Text, sql);
  586. _wait.Close();
  587. ICSBaseSimpleCode.AppshowMessageBox("同步成功");
  588. }
  589. catch (Exception ex)
  590. {
  591. _wait.Close();
  592. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  593. }
  594. }
  595. #endregion
  596. private void btnCreate_Click(object sender, EventArgs e)
  597. {
  598. SimpleButton btntemp = (SimpleButton)sender;
  599. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  600. {
  601. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  602. return;
  603. }
  604. FormICSMROPickingEditAdd add = new FormICSMROPickingEditAdd();
  605. add.ShowDialog();
  606. btnRefresh_Click(null, null);
  607. }
  608. //修改
  609. private void btnModify_Click(object sender, EventArgs e)
  610. {
  611. String id = "";
  612. SimpleButton btntemp = (SimpleButton)sender;
  613. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  614. {
  615. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  616. return;
  617. }
  618. List<string> editList = new List<string>();
  619. List<string> guidList1 = new List<string>();
  620. for (int i = 0; i < grvDetail.RowCount; i++)
  621. {
  622. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  623. {
  624. id = grvDetail.GetRowCellValue(i, ID).ToString();
  625. editList.Add(id);
  626. }
  627. }
  628. if (editList.Count == 1)
  629. {
  630. DataTable dt = ICSPickingBLL.searchInfoByID(id, AppConfig.AppConnectString);
  631. if (dt.Rows[0]["PickingSTATUS"].ToString() == "已审核")
  632. {
  633. ICSBaseSimpleCode.AppshowMessageBox("此条数据为已审核状态,不能编辑!!!");
  634. return;
  635. }
  636. if (Convert.ToDecimal(dt.Rows[0]["HasQuantity"].ToString()) > 0)
  637. {
  638. ICSBaseSimpleCode.AppshowMessageBox("此条数据已经领过料,不能编辑!!!");
  639. return;
  640. }
  641. }
  642. else
  643. {
  644. ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  645. return;
  646. }
  647. #region
  648. //if (editList.Count != 1 || id == "")
  649. //{
  650. // ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  651. // return;
  652. //}
  653. #endregion
  654. try
  655. {
  656. ICSPickingBLL.SearchInfoByID(id, AppConfig.AppConnectString);
  657. FormICSMROPickingEditAdd add = new FormICSMROPickingEditAdd(id);
  658. add.ShowDialog();
  659. btnRefresh_Click(null, null);
  660. }
  661. catch (Exception ex)
  662. {
  663. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  664. }
  665. }
  666. #region 删除
  667. private void btnDele_Click(object sender, EventArgs e)
  668. {
  669. SimpleButton btntemp = (SimpleButton)sender;
  670. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  671. {
  672. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  673. return;
  674. }
  675. List<ICSMaterial> item2routeList = new List<ICSMaterial>();
  676. List<string> routecodeList = new List<string>();
  677. for (int i = 0; i < grvDetail.RowCount; i++)
  678. {
  679. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  680. {
  681. if (grvDetail.GetRowCellValue(i, colPickingSTATUS).ToString() != "已审核")
  682. {
  683. ICSMaterial item2route = new ICSMaterial();
  684. item2route.VouchCode = grvDetail.GetRowCellValue(i, colPickingNO).ToString();
  685. string PCode = grvDetail.GetRowCellValue(i, colPickingNO).ToString();
  686. string sql = "SELECT * from ICSITEMLot WHERE TransNO='{0}'";
  687. sql = string.Format(sql, PCode);
  688. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  689. if (dt.Rows.Count > 0)
  690. {
  691. ICSBaseSimpleCode.AppshowMessageBox("要删除的单据必须为空,不能含有批次!");
  692. return;
  693. }
  694. else
  695. {
  696. item2routeList.Add(item2route);
  697. }
  698. }
  699. else
  700. {
  701. ICSBaseSimpleCode.AppshowMessageBox("要删除的单据不能审核!");
  702. return;
  703. }
  704. }
  705. }
  706. if (item2routeList.Count == 0)
  707. {
  708. ICSBaseSimpleCode.AppshowMessageBox("请选择数据");
  709. return;
  710. }
  711. if (ICSBaseSimpleCode.AppshowMessageBoxRepose("确定删除吗?删除后无法恢复,确定吗?") != DialogResult.OK)
  712. {
  713. btnCancelAll_Click(sender, e);
  714. return;
  715. }
  716. ICSPickingBLL.deleteInfo(item2routeList, AppConfig.AppConnectString);
  717. ICSBaseSimpleCode.AppshowMessageBox("删除成功");
  718. btnRefresh_Click(null, null);
  719. }
  720. #endregion
  721. #region 审核
  722. private void txtDeptCheck_Click(object sender, EventArgs e)
  723. {
  724. SimpleButton btntemp = (SimpleButton)sender;
  725. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  726. {
  727. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  728. return;
  729. }
  730. int count = 0;
  731. string Sid = "";
  732. for (int i = 0; i < grvDetail.RowCount; i++)
  733. {
  734. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  735. {
  736. Sid = grvDetail.GetRowCellValue(i, colID).ToString();
  737. count++;
  738. }
  739. }
  740. if (count == 1)
  741. {
  742. DataTable dt = ICSPickingBLL.searchInfoByID(Sid, AppConfig.AppConnectString);
  743. if (dt.Rows[0]["PickingSTATUS"].ToString() == "已审核")
  744. {
  745. ICSBaseSimpleCode.AppshowMessageBox("此条数据已审核!!!");
  746. return;
  747. }
  748. }
  749. if (count != 1)
  750. {
  751. ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  752. return;
  753. }
  754. try
  755. {
  756. string id = "";
  757. for (int i = 0; i < grvDetail.RowCount; i++)
  758. {
  759. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  760. {
  761. id = grvDetail.GetRowCellValue(i, colID).ToString();
  762. }
  763. }
  764. ICSPickingBLL.Check(id, AppConfig.AppConnectString);
  765. ICSBaseSimpleCode.AppshowMessageBox("审核成功");
  766. btnRefresh_Click(null, null);
  767. }
  768. catch (Exception ex)
  769. {
  770. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  771. }
  772. }
  773. #endregion
  774. #region 弃审
  775. private void BtnDiscardedTrial_Click(object sender, EventArgs e)
  776. {
  777. SimpleButton btntemp = (SimpleButton)sender;
  778. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  779. {
  780. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  781. return;
  782. }
  783. int count = 0;
  784. string Sid = "";
  785. for (int i = 0; i < grvDetail.RowCount; i++)
  786. {
  787. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  788. {
  789. Sid = grvDetail.GetRowCellValue(i, colID).ToString();
  790. count++;
  791. }
  792. }
  793. if (count == 1)
  794. {
  795. DataTable dt = ICSPickingBLL.searchInfoByID(Sid, AppConfig.AppConnectString);
  796. if (dt.Rows[0]["PickingSTATUS"].ToString() == "新增")
  797. {
  798. ICSBaseSimpleCode.AppshowMessageBox("此条数据为新增状态,不能弃审!!!");
  799. return;
  800. }
  801. if (Convert.ToDecimal(dt.Rows[0]["HasQuantity"].ToString()) > 0)
  802. {
  803. ICSBaseSimpleCode.AppshowMessageBox("此条数据已经领过料,不能弃审!!!");
  804. return;
  805. }
  806. }
  807. #region
  808. //int count = 0;
  809. //for (int i = 0; i < grvDetail.RowCount; i++)
  810. //{
  811. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  812. // {
  813. // count++;
  814. // }
  815. //}
  816. #endregion
  817. if (count != 1)
  818. {
  819. ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  820. return;
  821. }
  822. try
  823. {
  824. string id = "";
  825. for (int i = 0; i < grvDetail.RowCount; i++)
  826. {
  827. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  828. {
  829. id = grvDetail.GetRowCellValue(i, colID).ToString();
  830. }
  831. }
  832. ICSPickingBLL.DiscardedTrialCheck(id, AppConfig.AppConnectString);
  833. ICSBaseSimpleCode.AppshowMessageBox("弃审成功");
  834. btnRefresh_Click(null, null);
  835. }
  836. catch (Exception ex)
  837. {
  838. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  839. }
  840. }
  841. #endregion
  842. #region 拒绝
  843. private void BtnRefuse_Click(object sender, EventArgs e)
  844. {
  845. SimpleButton btntemp = (SimpleButton)sender;
  846. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  847. {
  848. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  849. return;
  850. }
  851. int count = 0;
  852. string Sid = "";
  853. for (int i = 0; i < grvDetail.RowCount; i++)
  854. {
  855. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  856. {
  857. Sid = grvDetail.GetRowCellValue(i, colID).ToString();
  858. count++;
  859. }
  860. }
  861. if (count == 1)
  862. {
  863. DataTable dt = ICSPickingBLL.searchInfoByID(Sid, AppConfig.AppConnectString);
  864. if (dt.Rows[0]["PickingSTATUS"].ToString() == "拒绝")
  865. {
  866. ICSBaseSimpleCode.AppshowMessageBox("此条数据为拒绝状态,不能拒绝!!!");
  867. return;
  868. }
  869. if (Convert.ToDecimal(dt.Rows[0]["HasQuantity"].ToString()) > 0)
  870. {
  871. ICSBaseSimpleCode.AppshowMessageBox("此条数据已经领过料,不能拒绝!!!");
  872. return;
  873. }
  874. }
  875. if (count != 1)
  876. {
  877. ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  878. return;
  879. }
  880. try
  881. {
  882. string id = "";
  883. for (int i = 0; i < grvDetail.RowCount; i++)
  884. {
  885. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  886. {
  887. id = grvDetail.GetRowCellValue(i, colID).ToString();
  888. }
  889. }
  890. ICSPickingBLL.RefuseCheck(id, AppConfig.AppConnectString);
  891. ICSBaseSimpleCode.AppshowMessageBox("拒绝成功");
  892. btnRefresh_Click(null, null);
  893. }
  894. catch (Exception ex)
  895. {
  896. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  897. }
  898. }
  899. #endregion
  900. }
  901. }