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

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