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

927 lines
38 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. SimpleButton btntemp = (SimpleButton)sender;
  267. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  268. {
  269. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  270. return;
  271. }
  272. FormOutExcel foe = new FormOutExcel(this.Tag.ToString(), grdDetail);
  273. foe.ShowDialog();
  274. }
  275. #endregion
  276. #region 刷新
  277. private void btnRefresh_Click(object sender, EventArgs e)
  278. {
  279. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在查找...请稍等...");
  280. try
  281. {
  282. _wait.Show();
  283. ds.Reset();
  284. dataSource = null;
  285. body = null;
  286. FormFilter filter = new FormFilter(AppConfig.GetSourceId(this.Tag.ToString(), btnConfig.Name), false);
  287. filter.OldTempTableName = tempTableName;
  288. //tempTableName = filter.NewTempTableName;
  289. //DataTable data = DBHelper.ExecuteDataset(AppConfig.FrameConnectString, CommandType.Text, "select * from " + tempTableName).Tables[0];
  290. dataSource = DBHelper.ExecuteDataset(sqlconn, CommandType.Text, sqltxt).Tables[0];
  291. dataSource.TableName = "Hand";
  292. ds.Tables.Add(dataSource.Copy());
  293. body = ICSPickingBLL.GetDetail(sqltxt);
  294. body.TableName = "Body";
  295. ds.Tables.Add(body.Copy());
  296. DataRelation dr = new DataRelation("详情", new DataColumn[] { ds.Tables["Hand"].Columns["VouchCode"] }, new DataColumn[] { ds.Tables["Body"].Columns["VouchCode"] });
  297. ds.Relations.Add(dr);
  298. grdDetail.DataSource = ds.Tables["Hand"];
  299. grvDetail.BestFitColumns();
  300. rptPage.RecordNum = dataSource.Rows.Count;
  301. rptPage.PageIndex = 1;
  302. //rptPage.ReLoad();
  303. _wait.Close();
  304. }
  305. catch (Exception ex)
  306. {
  307. MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  308. _wait.Close();
  309. }
  310. }
  311. #endregion
  312. //#region 新增
  313. //private void btnCreate_Click(object sender, EventArgs e)
  314. //{
  315. // SimpleButton btntemp = (SimpleButton)sender;
  316. // if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  317. // {
  318. // ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  319. // return;
  320. // }
  321. // FormICSMOAdd add = new FormICSMOAdd();
  322. // add.ShowDialog();
  323. // btnRefresh_Click(null, null);
  324. //}
  325. //#endregion
  326. //#region 修改
  327. //private void btnModify_Click(object sender, EventArgs e)
  328. //{
  329. // SimpleButton btntemp = (SimpleButton)sender;
  330. // if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  331. // {
  332. // ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  333. // return;
  334. // }
  335. // int count = 0;
  336. // for (int i = 0; i < grvDetail.RowCount; i++)
  337. // {
  338. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  339. // {
  340. // count++;
  341. // }
  342. // }
  343. // if (count != 1)
  344. // {
  345. // ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  346. // return;
  347. // }
  348. // try
  349. // {
  350. // string moid;
  351. // for (int i = 0; i < grvDetail.RowCount; i++)
  352. // {
  353. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  354. // {
  355. // moid = grvDetail.GetRowCellValue(i, colID).ToString();
  356. // FormICSMOAdd add = new FormICSMOAdd(moid);
  357. // add.ShowDialog();
  358. // }
  359. // }
  360. // btnRefresh_Click(null, null);
  361. // }
  362. // catch (Exception ex)
  363. // {
  364. // //throw ex;
  365. // ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  366. // }
  367. //}
  368. //#endregion
  369. //#region 删除
  370. //private void btnDel_Click(object sender, EventArgs e)
  371. //{
  372. // SimpleButton btntemp = (SimpleButton)sender;
  373. // if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  374. // {
  375. // ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  376. // return;
  377. // }
  378. // List<string> moidList = new List<string>();
  379. // for (int i = 0; i < grvDetail.RowCount; i++)
  380. // {
  381. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  382. // {
  383. // moidList.Add(grvDetail.GetRowCellValue(i, colID).ToString());
  384. // }
  385. // }
  386. // if (moidList.Count == 0 || moidList == null)
  387. // {
  388. // ICSBaseSimpleCode.AppshowMessageBox("请选择数据");
  389. // return;
  390. // }
  391. // if (ICSBaseSimpleCode.AppshowMessageBoxRepose("确定删除工单吗?删除后无法恢复,确定吗?") != DialogResult.OK)
  392. // {
  393. // btnCancelAll_Click(sender, e);
  394. // return;
  395. // }
  396. // try
  397. // {
  398. // ICSMOBLL.deleteInfo(moidList, AppConfig.AppConnectString);
  399. // ICSBaseSimpleCode.AppshowMessageBox("删除成功");
  400. // }
  401. // catch (Exception ex)
  402. // {
  403. // ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  404. // }
  405. // btnRefresh_Click(null, null);
  406. //}
  407. //#endregion
  408. private void ICSItemLot_FormClosing(object sender, FormClosingEventArgs e)
  409. {
  410. AppConfig.DropTemTable(tempTableName);
  411. }
  412. private void FormICSMO_Load(object sender, EventArgs e)
  413. {
  414. btnFilter_Click(sender, e);
  415. }
  416. #region
  417. //生成序列号
  418. private void newRcard_Click(object sender, EventArgs e)
  419. {
  420. //SimpleButton btntemp = (SimpleButton)sender;
  421. //if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  422. //{
  423. // ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  424. // return;
  425. //}
  426. //int count = 0;
  427. //for (int i = 0; i < grvDetail.RowCount; i++)
  428. //{
  429. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  430. // {
  431. // count++;
  432. // }
  433. //}
  434. //if (count != 1)
  435. //{
  436. // ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  437. // return;
  438. //}
  439. //try
  440. //{
  441. // string moID;
  442. // string moCode;
  443. // decimal qty = 0.00m;
  444. // for (int i = 0; i < grvDetail.RowCount; i++)
  445. // {
  446. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  447. // {
  448. // moID = grvDetail.GetRowCellValue(i, colID).ToString();
  449. // moCode = grvDetail.GetRowCellValue(i, colMOCODE).ToString();
  450. // qty = decimal.Parse(grvDetail.GetRowCellValue(i, colMOPLANQTY).ToString());
  451. // FormICSMO2RCARDAdd rec = new FormICSMO2RCARDAdd(moID, moCode, qty);
  452. // rec.ShowDialog();
  453. // }
  454. // }
  455. // btnRefresh_Click(null, null);
  456. //}
  457. //catch (Exception ex)
  458. //{
  459. // //throw ex;
  460. // ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  461. //}
  462. }
  463. #endregion
  464. private void repSerialButtonEdit_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  465. {
  466. try
  467. {
  468. string moID;
  469. string moCode;
  470. decimal qty = 0.00m;
  471. moID = grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, ID).ToString();
  472. moCode = grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colMOCODE).ToString();
  473. qty = Convert.ToDecimal(grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colEATTRIBUTE1).ToString());
  474. FormICSMO2RCARDAdd rec = new FormICSMO2RCARDAdd(moID, moCode, qty);
  475. rec.ShowDialog();
  476. btnRefresh_Click(null, null);
  477. }
  478. catch (Exception ex)
  479. {
  480. throw ex;
  481. }
  482. }
  483. #region 同步
  484. private void btnGetInfo_Click(object sender, EventArgs e)
  485. {
  486. SimpleButton btntemp = (SimpleButton)sender;
  487. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  488. {
  489. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  490. return;
  491. }
  492. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在同步请稍等...");
  493. try
  494. {
  495. string sql = @"
  496. UPDATE b SET b.ReceiptNO = a.cCode,
  497. b.ReceiptLine = a.irowno,b.MEMO = a.cbMemo,b.MOCODE = a.cmocode,
  498. b.ITEMCODE = a.cInvCode,b.PLANQTY = a.iQuantity,b.QualifyQTY = a.iQuantity,
  499. b.EATTRIBUTE1 = a.AutoID,b.MOSEQ = a.imoseq,b.TYPE = a.type
  500. FROM
  501. ( SELECT e.ID,a.cCode,b.irowno,b.cbMemo,
  502. b.cmocode,b.cInvCode,b.iQuantity,
  503. b.AutoID,imoseq,CASE WHEN inv.cInvCCode LIKE '3%' THEN '' WHEN inv.cInvCCode LIKE '2%'
  504. THEN '' ELSE '' END AS type FROM UFDATA_888_2016.dbo.rdrecord10 a
  505. INNER JOIN {1}.dbo.rdrecords10 b ON a.ID = b.ID
  506. LEFT JOIN [dbo].[ICSINVReceipt] e ON a.cCode = e.ReceiptNO
  507. AND ISNULL(a.dnmodifytime,'') = ISNULL(e.[EATTRIBUTE1],'')
  508. LEFT JOIN {1}.dbo.Inventory inv ON b.cInvCode = inv.cInvCode
  509. LEFT JOIN [dbo].[ICSINVReceiptDetail] d ON d.EATTRIBUTE1 = b.AutoID
  510. WHERE (cHandler IS NULL or cHandler = '')AND e.ReceiptNO IS NULL) a
  511. INNER JOIN [ICSINVReceiptDetail] b ON a.AutoID = b.EATTRIBUTE1
  512. UPDATE b SET b.StorageID = a.Serial,b.MEMO = a.cMemo,
  513. b.CreateTIME = a.dnmaketime,b.CreateUSER = a.cMaker,
  514. b.EATTRIBUTE1 = CONVERT(NVARCHAR(50),a.dnmodifytime,21)
  515. FROM (SELECT b.Serial,a.cMemo,a.cCode,a.dnmaketime,
  516. a.cMaker,a.dnmodifytime,c.[EATTRIBUTE1]
  517. FROM {1}.dbo.rdrecord10 a
  518. INNER JOIN dbo.ICSStorage b ON a.cWhCode = b.StorageCode
  519. LEFT JOIN [dbo].[ICSINVReceipt] c ON a.cCode = c.ReceiptNO
  520. AND ISNULL(a.dnmodifytime,'') = ISNULL(c.EATTRIBUTE1,'')
  521. WHERE (cHandler IS NULL or cHandler = '') AND c.ReceiptNO IS NULL) a
  522. INNER JOIN [dbo].[ICSINVReceipt] b ON a.cCode = b.ReceiptNO
  523. INSERT INTO [dbo].[ICSINVReceipt]
  524. ([ID],[ReceiptNO],[StorageID],[RECSTATUS],[VENDORCODE]
  525. ,[RECTYPE],[MEMO],[CreateTIME],[CreateUSER],[WorkPoint]
  526. ,[MUSER],[MUSERName],[MTIME],[EATTRIBUTE1],[ISALLINSTORAGE])
  527. SELECT NEWID(),cCode,b.Serial,'','','',a.cMemo,a.dnmaketime,a.cMaker,
  528. '0001','',a.cMaker,GETDATE(),
  529. '','N' FROM {1}.dbo.rdrecord10 a
  530. INNER JOIN dbo.ICSStorage b ON a.cWhCode = b.StorageCode
  531. LEFT JOIN [dbo].[ICSINVReceipt] c ON a.cCode = c.ReceiptNO
  532. AND ISNULL(a.dnmodifytime,'') = ISNULL(c.[EATTRIBUTE1],'')
  533. WHERE (cHandler IS NULL or cHandler = '') AND c.ReceiptNO IS NULL
  534. INSERT INTO [dbo].[ICSINVReceiptDetail]
  535. ([ID],[ReceiptID],[ReceiptNO],[ReceiptLine],[ORDERNO],[ORDERLINE]
  536. ,[RECSTATUS],[IQCStatus],[MEMO],[MOCODE],[ITEMCODE],[PLANQTY]
  537. ,[QualifyQTY],[VenderLotNO],[ACTQTY],[RECTIME],[RECUSER],[WorkPoint]
  538. ,[MUSER],[MUSERName],[MTIME],[EATTRIBUTE1],[INVUSER],[ISINSTORAGE]
  539. ,[MOSEQ],[TYPE])
  540. SELECT NEWID(),c.ID,a.cCode,b.irowno,'','','','',b.cbMemo,
  541. b.cmocode,b.cInvCode,b.iQuantity,b.iQuantity,'','','','','0001',
  542. '',a.cMaker,GETDATE(),b.AutoID,NULL,
  543. 'N',imoseq,CASE WHEN inv.cInvCCode LIKE '3%' THEN '' WHEN inv.cInvCCode LIKE '2%'
  544. THEN '' ELSE '' END FROM {1}.dbo.rdrecord10 a
  545. INNER JOIN {1}.dbo.rdrecords10 b ON a.ID = b.ID
  546. INNER JOIN [dbo].[ICSINVReceipt] c ON a.cCode = c.ReceiptNO
  547. LEFT JOIN {1}.dbo.Inventory inv ON b.cInvCode = inv.cInvCode
  548. LEFT JOIN [dbo].[ICSINVReceiptDetail] d ON d.EATTRIBUTE1 = b.AutoID
  549. WHERE (cHandler IS NULL or cHandler = '') AND d.EATTRIBUTE1 IS NULL";
  550. sql = string.Format(sql, AppConfig.WorkPointCode, ICSBaseSimpleCode.GetWorkPointErpData());
  551. DBHelper.ExecuteNonQuery(AppConfig.AppConnectString, CommandType.Text, sql);
  552. _wait.Close();
  553. ICSBaseSimpleCode.AppshowMessageBox("同步成功");
  554. }
  555. catch (Exception ex)
  556. {
  557. _wait.Close();
  558. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  559. }
  560. }
  561. #endregion
  562. private void btnCreate_Click(object sender, EventArgs e)
  563. {
  564. SimpleButton btntemp = (SimpleButton)sender;
  565. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  566. {
  567. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  568. return;
  569. }
  570. FormICSMROPickingEditAdd add = new FormICSMROPickingEditAdd();
  571. add.ShowDialog();
  572. btnRefresh_Click(null, null);
  573. }
  574. //修改
  575. private void btnModify_Click(object sender, EventArgs e)
  576. {
  577. String id = "";
  578. SimpleButton btntemp = (SimpleButton)sender;
  579. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  580. {
  581. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  582. return;
  583. }
  584. List<string> editList = new List<string>();
  585. List<string> guidList1 = new List<string>();
  586. for (int i = 0; i < grvDetail.RowCount; i++)
  587. {
  588. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  589. {
  590. id = grvDetail.GetRowCellValue(i, ID).ToString();
  591. editList.Add(id);
  592. }
  593. }
  594. if (editList.Count == 1)
  595. {
  596. DataTable dt = ICSPickingBLL.searchInfoByID(id, AppConfig.AppConnectString);
  597. if (dt.Rows[0]["PickingSTATUS"].ToString() == "已审核")
  598. {
  599. ICSBaseSimpleCode.AppshowMessageBox("此条数据为已审核状态,不能编辑!!!");
  600. return;
  601. }
  602. if (Convert.ToDecimal(dt.Rows[0]["HasQuantity"].ToString()) > 0)
  603. {
  604. ICSBaseSimpleCode.AppshowMessageBox("此条数据已经领过料,不能编辑!!!");
  605. return;
  606. }
  607. }
  608. else
  609. {
  610. ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  611. return;
  612. }
  613. #region
  614. //if (editList.Count != 1 || id == "")
  615. //{
  616. // ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  617. // return;
  618. //}
  619. #endregion
  620. try
  621. {
  622. ICSPickingBLL.SearchInfoByID(id, AppConfig.AppConnectString);
  623. FormICSMROPickingEditAdd add = new FormICSMROPickingEditAdd(id);
  624. add.ShowDialog();
  625. btnRefresh_Click(null, null);
  626. }
  627. catch (Exception ex)
  628. {
  629. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  630. }
  631. }
  632. #region 删除
  633. private void btnDele_Click(object sender, EventArgs e)
  634. {
  635. SimpleButton btntemp = (SimpleButton)sender;
  636. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  637. {
  638. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  639. return;
  640. }
  641. List<ICSMaterial> item2routeList = new List<ICSMaterial>();
  642. List<string> routecodeList = new List<string>();
  643. for (int i = 0; i < grvDetail.RowCount; i++)
  644. {
  645. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  646. {
  647. if (grvDetail.GetRowCellValue(i, colPickingSTATUS).ToString() != "已审核")
  648. {
  649. ICSMaterial item2route = new ICSMaterial();
  650. item2route.VouchCode = grvDetail.GetRowCellValue(i, colPickingNO).ToString();
  651. string PCode = grvDetail.GetRowCellValue(i, colPickingNO).ToString();
  652. string sql = "SELECT * from ICSITEMLot WHERE TransNO='{0}'";
  653. sql = string.Format(sql, PCode);
  654. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  655. if (dt.Rows.Count > 0)
  656. {
  657. ICSBaseSimpleCode.AppshowMessageBox("要删除的单据必须为空,不能含有批次!");
  658. return;
  659. }
  660. else
  661. {
  662. item2routeList.Add(item2route);
  663. }
  664. }
  665. else
  666. {
  667. ICSBaseSimpleCode.AppshowMessageBox("要删除的单据不能审核!");
  668. return;
  669. }
  670. }
  671. }
  672. if (item2routeList.Count == 0)
  673. {
  674. ICSBaseSimpleCode.AppshowMessageBox("请选择数据");
  675. return;
  676. }
  677. if (ICSBaseSimpleCode.AppshowMessageBoxRepose("确定删除吗?删除后无法恢复,确定吗?") != DialogResult.OK)
  678. {
  679. btnCancelAll_Click(sender, e);
  680. return;
  681. }
  682. ICSPickingBLL.deleteInfo(item2routeList, AppConfig.AppConnectString);
  683. ICSBaseSimpleCode.AppshowMessageBox("删除成功");
  684. btnRefresh_Click(null, null);
  685. }
  686. #endregion
  687. #region 审核
  688. private void txtDeptCheck_Click(object sender, EventArgs e)
  689. {
  690. SimpleButton btntemp = (SimpleButton)sender;
  691. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  692. {
  693. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  694. return;
  695. }
  696. int count = 0;
  697. string Sid = "";
  698. for (int i = 0; i < grvDetail.RowCount; i++)
  699. {
  700. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  701. {
  702. Sid = grvDetail.GetRowCellValue(i, colID).ToString();
  703. count++;
  704. }
  705. }
  706. if (count == 1)
  707. {
  708. DataTable dt = ICSPickingBLL.searchInfoByID(Sid, AppConfig.AppConnectString);
  709. if (dt.Rows[0]["PickingSTATUS"].ToString() == "已审核")
  710. {
  711. ICSBaseSimpleCode.AppshowMessageBox("此条数据已审核!!!");
  712. return;
  713. }
  714. }
  715. if (count != 1)
  716. {
  717. ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  718. return;
  719. }
  720. try
  721. {
  722. string id = "";
  723. for (int i = 0; i < grvDetail.RowCount; i++)
  724. {
  725. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  726. {
  727. id = grvDetail.GetRowCellValue(i, colID).ToString();
  728. }
  729. }
  730. ICSPickingBLL.Check(id, AppConfig.AppConnectString);
  731. ICSBaseSimpleCode.AppshowMessageBox("审核成功");
  732. btnRefresh_Click(null, null);
  733. }
  734. catch (Exception ex)
  735. {
  736. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  737. }
  738. }
  739. #endregion
  740. #region 弃审
  741. private void BtnDiscardedTrial_Click(object sender, EventArgs e)
  742. {
  743. SimpleButton btntemp = (SimpleButton)sender;
  744. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  745. {
  746. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  747. return;
  748. }
  749. int count = 0;
  750. string Sid = "";
  751. for (int i = 0; i < grvDetail.RowCount; i++)
  752. {
  753. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  754. {
  755. Sid = grvDetail.GetRowCellValue(i, colID).ToString();
  756. count++;
  757. }
  758. }
  759. if (count == 1)
  760. {
  761. DataTable dt = ICSPickingBLL.searchInfoByID(Sid, AppConfig.AppConnectString);
  762. if (dt.Rows[0]["PickingSTATUS"].ToString() == "新增")
  763. {
  764. ICSBaseSimpleCode.AppshowMessageBox("此条数据为新增状态,不能弃审!!!");
  765. return;
  766. }
  767. if (Convert.ToDecimal(dt.Rows[0]["HasQuantity"].ToString()) > 0)
  768. {
  769. ICSBaseSimpleCode.AppshowMessageBox("此条数据已经领过料,不能弃审!!!");
  770. return;
  771. }
  772. }
  773. #region
  774. //int count = 0;
  775. //for (int i = 0; i < grvDetail.RowCount; i++)
  776. //{
  777. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  778. // {
  779. // count++;
  780. // }
  781. //}
  782. #endregion
  783. if (count != 1)
  784. {
  785. ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  786. return;
  787. }
  788. try
  789. {
  790. string id = "";
  791. for (int i = 0; i < grvDetail.RowCount; i++)
  792. {
  793. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  794. {
  795. id = grvDetail.GetRowCellValue(i, colID).ToString();
  796. }
  797. }
  798. ICSPickingBLL.DiscardedTrialCheck(id, AppConfig.AppConnectString);
  799. ICSBaseSimpleCode.AppshowMessageBox("弃审成功");
  800. btnRefresh_Click(null, null);
  801. }
  802. catch (Exception ex)
  803. {
  804. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  805. }
  806. }
  807. #endregion
  808. #region 拒绝
  809. private void BtnRefuse_Click(object sender, EventArgs e)
  810. {
  811. SimpleButton btntemp = (SimpleButton)sender;
  812. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  813. {
  814. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  815. return;
  816. }
  817. int count = 0;
  818. string Sid = "";
  819. for (int i = 0; i < grvDetail.RowCount; i++)
  820. {
  821. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  822. {
  823. Sid = grvDetail.GetRowCellValue(i, colID).ToString();
  824. count++;
  825. }
  826. }
  827. if (count == 1)
  828. {
  829. DataTable dt = ICSPickingBLL.searchInfoByID(Sid, AppConfig.AppConnectString);
  830. if (dt.Rows[0]["PickingSTATUS"].ToString() == "拒绝")
  831. {
  832. ICSBaseSimpleCode.AppshowMessageBox("此条数据为拒绝状态,不能拒绝!!!");
  833. return;
  834. }
  835. if (Convert.ToDecimal(dt.Rows[0]["HasQuantity"].ToString()) > 0)
  836. {
  837. ICSBaseSimpleCode.AppshowMessageBox("此条数据已经领过料,不能拒绝!!!");
  838. return;
  839. }
  840. }
  841. if (count != 1)
  842. {
  843. ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  844. return;
  845. }
  846. try
  847. {
  848. string id = "";
  849. for (int i = 0; i < grvDetail.RowCount; i++)
  850. {
  851. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  852. {
  853. id = grvDetail.GetRowCellValue(i, colID).ToString();
  854. }
  855. }
  856. ICSPickingBLL.RefuseCheck(id, AppConfig.AppConnectString);
  857. ICSBaseSimpleCode.AppshowMessageBox("拒绝成功");
  858. btnRefresh_Click(null, null);
  859. }
  860. catch (Exception ex)
  861. {
  862. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  863. }
  864. }
  865. #endregion
  866. }
  867. }