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

687 lines
29 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 FormICSPicking : 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 FormICSPicking()
  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. foreach (Control ctr in ControlList)
  51. {
  52. if (ctr.GetType() == typeof(SimpleButton))
  53. {
  54. DataRow dr = rData.NewRow();
  55. dr["BtnName"] = ctr.Name;
  56. dr["ActionName"] = ctr.Text;
  57. rData.Rows.Add(dr);
  58. }
  59. }
  60. rData.AcceptChanges();
  61. return rData;
  62. }
  63. public DataTable RightOfData()// 数据权限
  64. {
  65. DataTable rData = new DataTable();
  66. rData.Columns.Add("BodyName");
  67. rData.Columns.Add("ControlName");
  68. rData.Columns.Add("ControlCaption");
  69. rData.AcceptChanges();
  70. return rData;
  71. }
  72. #endregion
  73. #region 退出
  74. private void btnClose_Click(object sender, EventArgs e)
  75. {
  76. AppConfig.CloseFormShow(this.Text);
  77. this.Close();
  78. }
  79. private void btnExit_Click(object sender, EventArgs e)
  80. {
  81. AppConfig.CloseFormShow(this.Text);
  82. this.Close();
  83. }
  84. #endregion
  85. #region 移动窗体
  86. private const int WM_NCHITTEST = 0x84;
  87. private const int HTCLIENT = 0x1;
  88. private const int HTCAPTION = 0x2;
  89. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  90. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  91. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  92. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  93. //重写窗体,使窗体可以不通过自带标题栏实现移动
  94. protected override void WndProc(ref Message m)
  95. {
  96. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  97. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  98. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  99. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  100. switch (m.Msg)
  101. {
  102. case WM_NCHITTEST:
  103. base.WndProc(ref m);
  104. if ((int)m.Result == HTCLIENT)
  105. m.Result = (IntPtr)HTCAPTION;
  106. return;
  107. }
  108. //拦截双击标题栏、移动窗体的系统消息
  109. if (m.Msg != 0xA3)
  110. {
  111. base.WndProc(ref m);
  112. }
  113. }
  114. #endregion
  115. #region 列表
  116. private void grvDetail_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
  117. {
  118. if (e.Info.IsRowIndicator && e.RowHandle >= 0)
  119. e.Info.DisplayText = (e.RowHandle + 1).ToString();
  120. }
  121. #endregion
  122. #region 过滤
  123. private string tempTableName = "";
  124. private void btnFilter_Click(object sender, EventArgs e)
  125. {
  126. FormFilter filter = new FormFilter(AppConfig.GetSourceId(this.Tag.ToString(), btnConfig.Name));
  127. filter.OldTempTableName = tempTableName;
  128. if (filter.ShowDialog() == DialogResult.OK)
  129. {
  130. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在查找...请稍等...");
  131. try
  132. {
  133. _wait.Show();
  134. ds.Reset();
  135. dataSource = null;
  136. body = null;
  137. tempTableName = filter.NewTempTableName;
  138. sqltxt = filter.SqlText;
  139. sqlconn = filter.FilterConnectString;
  140. dataSource = filter.FilterData.Tables[0];
  141. dataSource.TableName = "Hand";
  142. ds.Tables.Add(dataSource.Copy());
  143. body = ICSPickingBLL.GetDetail(sqltxt);
  144. body.TableName = "Body";
  145. ds.Tables.Add(body.Copy());
  146. DataRelation dr = new DataRelation("详情", new DataColumn[] { ds.Tables["Hand"].Columns["VouchCode"] }, new DataColumn[] { ds.Tables["Body"].Columns["VouchCode"] });
  147. ds.Relations.Add(dr);
  148. grdDetail.DataSource = ds.Tables["Hand"];
  149. grvDetail.BestFitColumns();
  150. rptPage.RecordNum = dataSource.Rows.Count;
  151. rptPage.PageSize = 499;
  152. rptPage.PageIndex = 1;
  153. rptPage.ReLoad();
  154. rptPage.PageSize = 500;
  155. rptPage.PageIndex = 1;
  156. //rptPage.ReLoad();
  157. _wait.Close();
  158. }
  159. catch (Exception ex)
  160. {
  161. MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  162. _wait.Close();
  163. }
  164. }
  165. }
  166. #endregion
  167. #region 绑定数据源
  168. private void btnConfig_Click(object sender, EventArgs e)
  169. {
  170. if (AppConfig.UserCode.ToLower() != "demo")
  171. {
  172. ICSBaseSimpleCode.AppshowMessageBox("您没有权限设置数据源,请联系软件提供商!");
  173. return;
  174. }
  175. FormDataSource fdata = new FormDataSource(AppConfig.GetMenuId(this.Tag.ToString()), btnConfig.Name);
  176. fdata.ShowDialog();
  177. }
  178. #endregion
  179. #region 分页
  180. private void rptPage_PageIndexChanged(object Sender, EventArgs e)
  181. {
  182. DataTable data = AppConfig.GetPageData(dataSource, rptPage.PageIndex, rptPage.PageSize).Copy();
  183. ds.Tables.Add(dataSource.Copy());
  184. ds.Tables.Add(body.Copy());
  185. DataRelation dr = new DataRelation("详情", new DataColumn[] { ds.Tables["Hand"].Columns["VouchCode"] }, new DataColumn[] { ds.Tables["Body"].Columns["VouchCode"] });
  186. ds.Relations.Add(dr);
  187. grdDetail.DataSource = ds.Tables["Hand"];
  188. //DataTable data = AppConfig.GetPageDataByDb(tempTableName, "pagerowindex", rptPage.PageSize, rptPage.PageIndex, dataSource.Rows.Count);
  189. grdDetail.DataSource = data;
  190. }
  191. #endregion
  192. #region 过滤方法
  193. private void FormContainerManager_FormClosing(object sender, FormClosingEventArgs e)
  194. {
  195. AppConfig.DropTemTable(tempTableName);
  196. }
  197. #endregion
  198. #region 全选
  199. private void btnSelectAll_Click(object sender, EventArgs e)
  200. {
  201. grvDetail.PostEditor();
  202. this.Validate();
  203. for (int i = 0; i < grvDetail.RowCount; i++)
  204. {
  205. grvDetail.SetRowCellValue(i, colisSelect, "Y");
  206. }
  207. }
  208. #endregion
  209. #region 全消
  210. private void btnCancelAll_Click(object sender, EventArgs e)
  211. {
  212. grvDetail.PostEditor();
  213. this.Validate();
  214. for (int i = 0; i < grvDetail.RowCount; i++)
  215. {
  216. grvDetail.SetRowCellValue(i, colisSelect, "");
  217. }
  218. }
  219. #endregion
  220. #region 双击
  221. private void grvDetail_DoubleClick(object sender, EventArgs e)
  222. {
  223. if (grvDetail.FocusedRowHandle < 0)
  224. {
  225. return;
  226. }
  227. if (grvDetail.FocusedColumn == colisSelect)
  228. {
  229. if (grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colisSelect).ToString() == "")
  230. {
  231. grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colisSelect, "Y");
  232. }
  233. else
  234. {
  235. grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colisSelect, "");
  236. }
  237. }
  238. }
  239. #endregion
  240. #region 导出
  241. private void btnOutPut_Click(object sender, EventArgs e)
  242. {
  243. SimpleButton btntemp = (SimpleButton)sender;
  244. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  245. {
  246. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  247. return;
  248. }
  249. FormOutExcel foe = new FormOutExcel(this.Tag.ToString(), grdDetail);
  250. foe.ShowDialog();
  251. }
  252. #endregion
  253. #region 刷新
  254. private void btnRefresh_Click(object sender, EventArgs e)
  255. {
  256. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在查找...请稍等...");
  257. try
  258. {
  259. _wait.Show();
  260. ds.Reset();
  261. dataSource = null;
  262. body = null;
  263. FormFilter filter = new FormFilter(AppConfig.GetSourceId(this.Tag.ToString(), btnConfig.Name), false);
  264. filter.OldTempTableName = tempTableName;
  265. //tempTableName = filter.NewTempTableName;
  266. //DataTable data = DBHelper.ExecuteDataset(AppConfig.FrameConnectString, CommandType.Text, "select * from " + tempTableName).Tables[0];
  267. dataSource = DBHelper.ExecuteDataset(sqlconn, CommandType.Text, sqltxt).Tables[0];
  268. dataSource.TableName = "Hand";
  269. ds.Tables.Add(dataSource.Copy());
  270. body = ICSPickingBLL.GetDetail(sqltxt);
  271. body.TableName = "Body";
  272. ds.Tables.Add(body.Copy());
  273. DataRelation dr = new DataRelation("详情", new DataColumn[] { ds.Tables["Hand"].Columns["VouchCode"] }, new DataColumn[] { ds.Tables["Body"].Columns["VouchCode"] });
  274. ds.Relations.Add(dr);
  275. grdDetail.DataSource = ds.Tables["Hand"];
  276. grvDetail.BestFitColumns();
  277. rptPage.RecordNum = dataSource.Rows.Count;
  278. rptPage.PageIndex = 1;
  279. //rptPage.ReLoad();
  280. _wait.Close();
  281. }
  282. catch (Exception ex)
  283. {
  284. MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  285. _wait.Close();
  286. }
  287. }
  288. #endregion
  289. //#region 新增
  290. //private void btnCreate_Click(object sender, EventArgs e)
  291. //{
  292. // SimpleButton btntemp = (SimpleButton)sender;
  293. // if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  294. // {
  295. // ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  296. // return;
  297. // }
  298. // FormICSMOAdd add = new FormICSMOAdd();
  299. // add.ShowDialog();
  300. // btnRefresh_Click(null, null);
  301. //}
  302. //#endregion
  303. //#region 修改
  304. //private void btnModify_Click(object sender, EventArgs e)
  305. //{
  306. // SimpleButton btntemp = (SimpleButton)sender;
  307. // if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  308. // {
  309. // ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  310. // return;
  311. // }
  312. // int count = 0;
  313. // for (int i = 0; i < grvDetail.RowCount; i++)
  314. // {
  315. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  316. // {
  317. // count++;
  318. // }
  319. // }
  320. // if (count != 1)
  321. // {
  322. // ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  323. // return;
  324. // }
  325. // try
  326. // {
  327. // string moid;
  328. // for (int i = 0; i < grvDetail.RowCount; i++)
  329. // {
  330. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  331. // {
  332. // moid = grvDetail.GetRowCellValue(i, colID).ToString();
  333. // FormICSMOAdd add = new FormICSMOAdd(moid);
  334. // add.ShowDialog();
  335. // }
  336. // }
  337. // btnRefresh_Click(null, null);
  338. // }
  339. // catch (Exception ex)
  340. // {
  341. // //throw ex;
  342. // ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  343. // }
  344. //}
  345. //#endregion
  346. //#region 删除
  347. //private void btnDel_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. // List<string> moidList = new List<string>();
  356. // for (int i = 0; i < grvDetail.RowCount; i++)
  357. // {
  358. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  359. // {
  360. // moidList.Add(grvDetail.GetRowCellValue(i, colID).ToString());
  361. // }
  362. // }
  363. // if (moidList.Count == 0 || moidList == null)
  364. // {
  365. // ICSBaseSimpleCode.AppshowMessageBox("请选择数据");
  366. // return;
  367. // }
  368. // if (ICSBaseSimpleCode.AppshowMessageBoxRepose("确定删除工单吗?删除后无法恢复,确定吗?") != DialogResult.OK)
  369. // {
  370. // btnCancelAll_Click(sender, e);
  371. // return;
  372. // }
  373. // try
  374. // {
  375. // ICSMOBLL.deleteInfo(moidList, AppConfig.AppConnectString);
  376. // ICSBaseSimpleCode.AppshowMessageBox("删除成功");
  377. // }
  378. // catch (Exception ex)
  379. // {
  380. // ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  381. // }
  382. // btnRefresh_Click(null, null);
  383. //}
  384. //#endregion
  385. private void ICSItemLot_FormClosing(object sender, FormClosingEventArgs e)
  386. {
  387. AppConfig.DropTemTable(tempTableName);
  388. }
  389. private void FormICSMO_Load(object sender, EventArgs e)
  390. {
  391. btnFilter_Click(sender, e);
  392. }
  393. #region
  394. //生成序列号
  395. private void newRcard_Click(object sender, EventArgs e)
  396. {
  397. //SimpleButton btntemp = (SimpleButton)sender;
  398. //if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  399. //{
  400. // ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  401. // return;
  402. //}
  403. //int count = 0;
  404. //for (int i = 0; i < grvDetail.RowCount; i++)
  405. //{
  406. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  407. // {
  408. // count++;
  409. // }
  410. //}
  411. //if (count != 1)
  412. //{
  413. // ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  414. // return;
  415. //}
  416. //try
  417. //{
  418. // string moID;
  419. // string moCode;
  420. // decimal qty = 0.00m;
  421. // for (int i = 0; i < grvDetail.RowCount; i++)
  422. // {
  423. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  424. // {
  425. // moID = grvDetail.GetRowCellValue(i, colID).ToString();
  426. // moCode = grvDetail.GetRowCellValue(i, colMOCODE).ToString();
  427. // qty = decimal.Parse(grvDetail.GetRowCellValue(i, colMOPLANQTY).ToString());
  428. // FormICSMO2RCARDAdd rec = new FormICSMO2RCARDAdd(moID, moCode, qty);
  429. // rec.ShowDialog();
  430. // }
  431. // }
  432. // btnRefresh_Click(null, null);
  433. //}
  434. //catch (Exception ex)
  435. //{
  436. // //throw ex;
  437. // ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  438. //}
  439. }
  440. #endregion
  441. private void repSerialButtonEdit_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  442. {
  443. try
  444. {
  445. string moID;
  446. string moCode;
  447. decimal qty = 0.00m;
  448. moID = grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, ID).ToString();
  449. moCode = grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colMOCODE).ToString();
  450. qty = Convert.ToDecimal(grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colEATTRIBUTE1).ToString());
  451. FormICSMO2RCARDAdd rec = new FormICSMO2RCARDAdd(moID, moCode, qty);
  452. rec.ShowDialog();
  453. btnRefresh_Click(null, null);
  454. }
  455. catch (Exception ex)
  456. {
  457. throw ex;
  458. }
  459. }
  460. #region 同步
  461. private void btnGetInfo_Click(object sender, EventArgs e)
  462. {
  463. SimpleButton btntemp = (SimpleButton)sender;
  464. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  465. {
  466. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  467. return;
  468. }
  469. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在同步请稍等...");
  470. try
  471. {
  472. string sql = @"
  473. UPDATE b SET b.ReceiptNO = a.cCode,
  474. b.ReceiptLine = a.irowno,b.MEMO = a.cbMemo,b.MOCODE = a.cmocode,
  475. b.ITEMCODE = a.cInvCode,b.PLANQTY = a.iQuantity,b.QualifyQTY = a.iQuantity,
  476. b.EATTRIBUTE1 = a.AutoID,b.MOSEQ = a.imoseq,b.TYPE = a.type
  477. FROM
  478. ( SELECT e.ID,a.cCode,b.irowno,b.cbMemo,
  479. b.cmocode,b.cInvCode,b.iQuantity,
  480. b.AutoID,imoseq,CASE WHEN inv.cInvCCode LIKE '3%' THEN '' WHEN inv.cInvCCode LIKE '2%'
  481. THEN '' ELSE '' END AS type FROM UFDATA_888_2016.dbo.rdrecord10 a
  482. INNER JOIN {1}.dbo.rdrecords10 b ON a.ID = b.ID
  483. LEFT JOIN [dbo].[ICSINVReceipt] e ON a.cCode = e.ReceiptNO
  484. AND ISNULL(a.dnmodifytime,'') = ISNULL(e.[EATTRIBUTE1],'')
  485. LEFT JOIN {1}.dbo.Inventory inv ON b.cInvCode = inv.cInvCode
  486. LEFT JOIN [dbo].[ICSINVReceiptDetail] d ON d.EATTRIBUTE1 = b.AutoID
  487. WHERE (cHandler IS NULL or cHandler = '')AND e.ReceiptNO IS NULL) a
  488. INNER JOIN [ICSINVReceiptDetail] b ON a.AutoID = b.EATTRIBUTE1
  489. UPDATE b SET b.StorageID = a.Serial,b.MEMO = a.cMemo,
  490. b.CreateTIME = a.dnmaketime,b.CreateUSER = a.cMaker,
  491. b.EATTRIBUTE1 = CONVERT(NVARCHAR(50),a.dnmodifytime,21)
  492. FROM (SELECT b.Serial,a.cMemo,a.cCode,a.dnmaketime,
  493. a.cMaker,a.dnmodifytime,c.[EATTRIBUTE1]
  494. FROM {1}.dbo.rdrecord10 a
  495. INNER JOIN dbo.ICSStorage b ON a.cWhCode = b.StorageCode
  496. LEFT JOIN [dbo].[ICSINVReceipt] c ON a.cCode = c.ReceiptNO
  497. AND ISNULL(a.dnmodifytime,'') = ISNULL(c.EATTRIBUTE1,'')
  498. WHERE (cHandler IS NULL or cHandler = '') AND c.ReceiptNO IS NULL) a
  499. INNER JOIN [dbo].[ICSINVReceipt] b ON a.cCode = b.ReceiptNO
  500. INSERT INTO [dbo].[ICSINVReceipt]
  501. ([ID],[ReceiptNO],[StorageID],[RECSTATUS],[VENDORCODE]
  502. ,[RECTYPE],[MEMO],[CreateTIME],[CreateUSER],[WorkPoint]
  503. ,[MUSER],[MUSERName],[MTIME],[EATTRIBUTE1],[ISALLINSTORAGE])
  504. SELECT NEWID(),cCode,b.Serial,'','','',a.cMemo,a.dnmaketime,a.cMaker,
  505. '0001','',a.cMaker,GETDATE(),
  506. '','N' FROM {1}.dbo.rdrecord10 a
  507. INNER JOIN dbo.ICSStorage b ON a.cWhCode = b.StorageCode
  508. LEFT JOIN [dbo].[ICSINVReceipt] c ON a.cCode = c.ReceiptNO
  509. AND ISNULL(a.dnmodifytime,'') = ISNULL(c.[EATTRIBUTE1],'')
  510. WHERE (cHandler IS NULL or cHandler = '') AND c.ReceiptNO IS NULL
  511. INSERT INTO [dbo].[ICSINVReceiptDetail]
  512. ([ID],[ReceiptID],[ReceiptNO],[ReceiptLine],[ORDERNO],[ORDERLINE]
  513. ,[RECSTATUS],[IQCStatus],[MEMO],[MOCODE],[ITEMCODE],[PLANQTY]
  514. ,[QualifyQTY],[VenderLotNO],[ACTQTY],[RECTIME],[RECUSER],[WorkPoint]
  515. ,[MUSER],[MUSERName],[MTIME],[EATTRIBUTE1],[INVUSER],[ISINSTORAGE]
  516. ,[MOSEQ],[TYPE])
  517. SELECT NEWID(),c.ID,a.cCode,b.irowno,'','','','',b.cbMemo,
  518. b.cmocode,b.cInvCode,b.iQuantity,b.iQuantity,'','','','','0001',
  519. '',a.cMaker,GETDATE(),b.AutoID,NULL,
  520. 'N',imoseq,CASE WHEN inv.cInvCCode LIKE '3%' THEN '' WHEN inv.cInvCCode LIKE '2%'
  521. THEN '' ELSE '' END FROM {1}.dbo.rdrecord10 a
  522. INNER JOIN {1}.dbo.rdrecords10 b ON a.ID = b.ID
  523. INNER JOIN [dbo].[ICSINVReceipt] c ON a.cCode = c.ReceiptNO
  524. LEFT JOIN {1}.dbo.Inventory inv ON b.cInvCode = inv.cInvCode
  525. LEFT JOIN [dbo].[ICSINVReceiptDetail] d ON d.EATTRIBUTE1 = b.AutoID
  526. WHERE (cHandler IS NULL or cHandler = '') AND d.EATTRIBUTE1 IS NULL";
  527. sql = string.Format(sql, AppConfig.WorkPointCode, ICSBaseSimpleCode.GetWorkPointErpData());
  528. DBHelper.ExecuteNonQuery(AppConfig.AppConnectString, CommandType.Text, sql);
  529. _wait.Close();
  530. ICSBaseSimpleCode.AppshowMessageBox("同步成功");
  531. }
  532. catch (Exception ex)
  533. {
  534. _wait.Close();
  535. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  536. }
  537. }
  538. #endregion
  539. private void btnCreate_Click(object sender, EventArgs e)
  540. {
  541. SimpleButton btntemp = (SimpleButton)sender;
  542. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  543. {
  544. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  545. return;
  546. }
  547. FormICSPickingEditAdd add = new FormICSPickingEditAdd();
  548. add.ShowDialog();
  549. btnRefresh_Click(null, null);
  550. }
  551. private void btnModify_Click(object sender, EventArgs e)
  552. {
  553. String id = "";
  554. SimpleButton btntemp = (SimpleButton)sender;
  555. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  556. {
  557. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  558. return;
  559. }
  560. List<string> editList = new List<string>();
  561. List<string> guidList1 = new List<string>();
  562. for (int i = 0; i < grvDetail.RowCount; i++)
  563. {
  564. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  565. {
  566. id = grvDetail.GetRowCellValue(i, ID).ToString();
  567. editList.Add(id);
  568. }
  569. }
  570. if (editList.Count != 1 || id == "")
  571. {
  572. ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  573. return;
  574. }
  575. try
  576. {
  577. ICSPickingBLL.SearchInfoByID(id, AppConfig.AppConnectString);
  578. FormICSPickingEditAdd add = new FormICSPickingEditAdd(id);
  579. add.ShowDialog();
  580. btnRefresh_Click(null, null);
  581. }
  582. catch (Exception ex)
  583. {
  584. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  585. }
  586. }
  587. #region 删除
  588. private void btnDele_Click(object sender, EventArgs e)
  589. {
  590. SimpleButton btntemp = (SimpleButton)sender;
  591. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  592. {
  593. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  594. return;
  595. }
  596. List<ICSMaterial> item2routeList = new List<ICSMaterial>();
  597. List<string> routecodeList = new List<string>();
  598. for (int i = 0; i < grvDetail.RowCount; i++)
  599. {
  600. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  601. {
  602. ICSMaterial item2route = new ICSMaterial();
  603. item2route.VouchCode = grvDetail.GetRowCellValue(i, colPickingNO).ToString();
  604. string PCode = grvDetail.GetRowCellValue(i, colPickingNO).ToString();
  605. string sql = "SELECT * from ICSITEMLot WHERE TransNO='{0}'";
  606. sql = string.Format(sql, PCode);
  607. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  608. if (dt.Rows.Count > 0)
  609. {
  610. ICSBaseSimpleCode.AppshowMessageBox("要删除的单据必须为空,不能含有批次!");
  611. return;
  612. }
  613. else
  614. {
  615. item2routeList.Add(item2route);
  616. }
  617. }
  618. }
  619. if (item2routeList.Count == 0)
  620. {
  621. ICSBaseSimpleCode.AppshowMessageBox("请选择数据");
  622. return;
  623. }
  624. if (ICSBaseSimpleCode.AppshowMessageBoxRepose("确定删除吗?删除后无法恢复,确定吗?") != DialogResult.OK)
  625. {
  626. btnCancelAll_Click(sender, e);
  627. return;
  628. }
  629. ICSPickingBLL.deleteInfo(item2routeList, AppConfig.AppConnectString);
  630. ICSBaseSimpleCode.AppshowMessageBox("删除成功");
  631. btnRefresh_Click(null, null);
  632. }
  633. #endregion
  634. }
  635. }