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

762 lines
32 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. using ICSSoft.Frame.Data.Entity;
  26. namespace ICSSoft.Frame.APP
  27. {
  28. public partial class FormICSRCVIQC : DevExpress.XtraEditors.XtraForm
  29. {
  30. String guid = AppConfig.GetGuid();
  31. string where = "(RECSTATUS=''待检'' or RECSTATUS=''已检'' and ISALLINSTORAGE=''N'') ";//
  32. string autoRefreshTime = System.Configuration.ConfigurationManager.AppSettings["AutoRefreshTime"].ToString();
  33. string isAutoRefresh = System.Configuration.ConfigurationManager.AppSettings["IsAutoRefresh"].ToString();
  34. System.Timers.Timer t = new System.Timers.Timer();
  35. #region 构造函数
  36. public FormICSRCVIQC()
  37. {
  38. InitializeComponent();
  39. this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  40. this.WindowState = FormWindowState.Maximized;
  41. label2.BackColor = Color.White;
  42. }
  43. #endregion
  44. #region 操作权限
  45. public DataTable RightOfExute()
  46. {
  47. DataTable rData = new DataTable();
  48. rData.Columns.Add("BtnName");
  49. rData.Columns.Add("ActionName");
  50. //查看权限(必须有)
  51. DataRow seeRow = rData.NewRow();
  52. seeRow["BtnName"] = "see";
  53. seeRow["ActionName"] = "查看";
  54. rData.Rows.Add(seeRow);
  55. List<Control> ControlList = new List<Control>();
  56. ControlList.Add(btnSubmit);
  57. ControlList.Add(btnOutPut);
  58. foreach (Control ctr in ControlList)
  59. {
  60. if (ctr.GetType() == typeof(SimpleButton))
  61. {
  62. DataRow dr = rData.NewRow();
  63. dr["BtnName"] = ctr.Name;
  64. dr["ActionName"] = ctr.Text;
  65. rData.Rows.Add(dr);
  66. }
  67. }
  68. rData.AcceptChanges();
  69. return rData;
  70. }
  71. public DataTable RightOfData()// 数据权限
  72. {
  73. DataTable rData = new DataTable();
  74. rData.Columns.Add("BodyName");
  75. rData.Columns.Add("ControlName");
  76. rData.Columns.Add("ControlCaption");
  77. rData.AcceptChanges();
  78. return rData;
  79. }
  80. #endregion
  81. #region 退出
  82. private void btnClose_Click(object sender, EventArgs e)
  83. {
  84. AppConfig.CloseFormShow(this.Text);
  85. this.Close();
  86. }
  87. private void btnExit_Click(object sender, EventArgs e)
  88. {
  89. AppConfig.CloseFormShow(this.Text);
  90. this.Close();
  91. }
  92. #endregion
  93. #region 移动窗体
  94. private const int WM_NCHITTEST = 0x84;
  95. private const int HTCLIENT = 0x1;
  96. private const int HTCAPTION = 0x2;
  97. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  98. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  99. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  100. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  101. //重写窗体,使窗体可以不通过自带标题栏实现移动
  102. protected override void WndProc(ref Message m)
  103. {
  104. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  105. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  106. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  107. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  108. switch (m.Msg)
  109. {
  110. case WM_NCHITTEST:
  111. base.WndProc(ref m);
  112. if ((int)m.Result == HTCLIENT)
  113. m.Result = (IntPtr)HTCAPTION;
  114. return;
  115. }
  116. //拦截双击标题栏、移动窗体的系统消息
  117. if (m.Msg != 0xA3)
  118. {
  119. base.WndProc(ref m);
  120. }
  121. }
  122. #endregion
  123. #region 列表
  124. private void grvDetail_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
  125. {
  126. if (e.Info.IsRowIndicator && e.RowHandle >= 0)
  127. e.Info.DisplayText = (e.RowHandle + 1).ToString();
  128. }
  129. private void gridView1_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
  130. {
  131. if (e.Info.IsRowIndicator && e.RowHandle >= 0)
  132. e.Info.DisplayText = (e.RowHandle + 1).ToString();
  133. }
  134. #endregion
  135. #region 过滤
  136. private string tempTableName = "";
  137. private void btnFilter_Click(object sender, EventArgs e)
  138. {
  139. }
  140. #endregion
  141. #region 双击
  142. private void grvDetail_DoubleClick(object sender, EventArgs e)
  143. {
  144. if (grvDetail.FocusedRowHandle < 0)
  145. {
  146. return;
  147. }
  148. if (grvDetail.FocusedColumn == colSelect)
  149. {
  150. if (grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colSelect).ToString() == "")
  151. {
  152. grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colSelect, "Y");
  153. }
  154. else
  155. {
  156. grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colSelect, "");
  157. }
  158. }
  159. }
  160. #endregion
  161. private void btnSelect_Click(object sender, EventArgs e)
  162. {
  163. grvDetail.PostEditor();
  164. this.Validate();
  165. for (int i = 0; i < grvDetail.RowCount; i++)
  166. {
  167. grvDetail.SetRowCellValue(i, colSelect, "Y");
  168. }
  169. }
  170. private void btnCanSelect_Click(object sender, EventArgs e)
  171. {
  172. grvDetail.PostEditor();
  173. this.Validate();
  174. for (int i = 0; i < grvDetail.RowCount; i++)
  175. {
  176. grvDetail.SetRowCellValue(i, colSelect, "");
  177. }
  178. }
  179. #region 绑定数据源
  180. private void btnConfig_Click(object sender, EventArgs e)
  181. {
  182. }
  183. #endregion
  184. #region 过滤方法
  185. private void FormContainerManager_FormClosing(object sender, FormClosingEventArgs e)
  186. {
  187. AppConfig.DropTemTable(tempTableName);
  188. }
  189. #endregion
  190. #region 刷新
  191. private void btnRefresh_Click(object sender, EventArgs e)
  192. {
  193. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在查找...请稍等...");
  194. try
  195. {
  196. _wait.Show();
  197. gridView1_FocusedRowChanged(null, null);
  198. _wait.Close();
  199. }
  200. catch (Exception ex)
  201. {
  202. MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  203. _wait.Close();
  204. }
  205. }
  206. #endregion
  207. #region 新增
  208. private void btnCreate_Click(object sender, EventArgs e)
  209. {
  210. SimpleButton btn = ((SimpleButton)sender);
  211. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btn.Name) == false)
  212. {
  213. ICSBaseSimpleCode.AppshowMessageBox(1, "对不起您无" + btn.Text + "权限,请联系管理员!");
  214. return;
  215. }
  216. try
  217. {
  218. string ERPSql = @"SELECT a.ID, [ReceiptNO] AS 入库单号
  219. ,b.StorageName AS
  220. ,c.VendorName AS
  221. ,[RECTYPE] AS
  222. ,[MEMO] AS
  223. ,a.[MUSERName] AS
  224. ,a.[MTIME] AS
  225. FROM [ICSINVReceipt] a LEFT JOIN ICSStorage b ON a.StorageID=b.Serial
  226. LEFT JOIN ICSVendor c ON a.[VENDORCODE]=c.ID
  227. WHERE [ReceiptNO] NOT IN
  228. (SELECT DISTINCT STNO FROM dbo.ICSASNIQC)
  229. and a.WorkPoint='" + AppConfig.WorkPointCode + "' ";
  230. DataTable czData = DBHelper.ExecuteDataset(AppConfig.FrameConnectString, CommandType.Text, ERPSql).Tables[0];
  231. FormDataRefer reForm = new FormDataRefer();
  232. reForm.FormTitle = "入库单列表";
  233. reForm.DataSource = czData;
  234. reForm.MSelectFlag = true;
  235. reForm.RowIndexWidth = 35;
  236. reForm.HideCols.Add("ID");
  237. reForm.Width = this.Width - 10;
  238. reForm.Height = this.Height - 10;
  239. if (reForm.ShowDialog() != DialogResult.OK)
  240. {
  241. return;
  242. }
  243. DataTable retData = reForm.ReturnData;
  244. if (retData.Rows.Count == 0)
  245. {
  246. return;
  247. }
  248. ICSASNIQCBLL.save(retData,AppConfig.AppConnectString);
  249. ICSBaseSimpleCode.AppshowMessageBox("生成成功");
  250. btnRefresh_Click(null, null);
  251. }
  252. catch (Exception ex)
  253. {
  254. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  255. }
  256. }
  257. #endregion
  258. #region 页面加载
  259. private void grdDetail_Load(object sender, EventArgs e)
  260. {
  261. // btnFilter_Click(null, null);
  262. }
  263. private void ICSItemLot_FormClosing(object sender, FormClosingEventArgs e)
  264. {
  265. AppConfig.DropTemTable(tempTableName);
  266. }
  267. private void FormICSCREW_Load(object sender, EventArgs e)
  268. {
  269. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在查找...请稍等...");
  270. try
  271. {
  272. _wait.Show();
  273. grdDetail.DataSource = "";
  274. rptPage.PageSize = 100;
  275. rptPage.PageIndex = 1;
  276. rptPage.ReLoad();
  277. _wait.Close();
  278. }
  279. catch (Exception ex)
  280. {
  281. MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  282. _wait.Close();
  283. }
  284. }
  285. #endregion
  286. #region 导出
  287. private void btnOutPut_Click_1(object sender, EventArgs e)
  288. {
  289. try
  290. {
  291. FormOutExcel foe = new FormOutExcel(this.Tag.ToString(), grdDetail);
  292. foe.ShowDialog();
  293. }
  294. catch (Exception ex)
  295. {
  296. MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  297. }
  298. //FormOutExcel foe = new FormOutExcel();
  299. //if (foe.ShowDialog() == DialogResult.OK)
  300. //{
  301. // try
  302. // {
  303. // string outtype = foe._OutType;
  304. // string exceltype = foe._ExcelType;
  305. // string filename = foe._FileName;
  306. // string url = foe._Url;
  307. // string sheetname = foe._SheetName;
  308. // if (outtype.ToLower() == "excel")
  309. // {
  310. // DevExpress.XtraPrinting.XlsExportOptions op = new DevExpress.XtraPrinting.XlsExportOptions();
  311. // op.SheetName = sheetname;
  312. // grdDetail.MainView.ExportToXls((url + "\\" + filename + (exceltype == "2003" ? ".xls" : ".xlsx")), op);
  313. // }
  314. // else
  315. // {
  316. // grdDetail.MainView.ExportToPdf(url + "\\" + filename + ".pdf");
  317. // }
  318. // MessageBox.Show("导出成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  319. // }
  320. // catch (Exception ex)
  321. // {
  322. // MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  323. // }
  324. //}
  325. }
  326. #endregion
  327. #region 到货单列表(作废)
  328. private void simpleButton3_Click(object sender, EventArgs e)
  329. {
  330. string sql = @" select ReceiptNO 到货单号,
  331. RECSTATUS ,
  332. VENDORCODE ,
  333. MEMO ,
  334. CreateUSER ,
  335. CreateTIME
  336. from ICSINVReceipt
  337. order by CreateTIME DESC";
  338. DataTable data = DBHelper.ExecuteDataset(AppConfig.GetDataBaseConnectStringByKey("[DB.SYS]"), CommandType.Text, sql).Tables[0];
  339. FormDataRefer reForm = new FormDataRefer();
  340. reForm.FormTitle = "到货单查询";
  341. DataTable menuData = data;
  342. reForm.DataSource = menuData;
  343. reForm.MSelectFlag = false;
  344. reForm.RowIndexWidth = 35;
  345. reForm.FormWidth = 500;
  346. reForm.FormHeight = 500;
  347. if (reForm.ShowDialog() == DialogResult.OK)
  348. {
  349. DataTable retData = reForm.ReturnData;
  350. foreach (DataRow dr in retData.Rows)
  351. {
  352. sql = @"select
  353. '' as colSelect,
  354. ReceiptNO ,
  355. ReceiptLine ,
  356. IQCStatus ,
  357. PLANQTY ,
  358. VenderLotNO ,
  359. MUSERName ,
  360. MTIME
  361. from ICSINVReceiptDetail
  362. where ReceiptNO='{0}'
  363. ";
  364. sql = string.Format(sql, dr["到货单号"].ToString());
  365. data = DBHelper.ExecuteDataset(AppConfig.GetDataBaseConnectStringByKey("[DB.SYS]"), CommandType.Text, sql).Tables[0];
  366. grdDetail.DataSource = data;
  367. grvDetail.BestFitColumns();
  368. }
  369. }
  370. }
  371. #endregion
  372. #region 到货单列表焦点行改变事件
  373. private void gridView1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
  374. {
  375. string sql = @"select
  376. '' as colSelect,
  377. a.ID as ID,
  378. a.ReceiptNO ,
  379. a.ReceiptLine ,
  380. a.ITEMCODE ,
  381. c.INVNAME ,
  382. c.INVSTD ,
  383. CAST((CASE WHEN d.EATTRIBUTE4='1' THEN 1 ELSE 0 END) AS bit) ,
  384. a.IQCStatus ,
  385. g.TransQTY ,
  386. e.EATTRIBUTE3 YLOTQTY,
  387. (e.LOTQTY-e.EATTRIBUTE3) NLOTQTY,
  388. c.INVUOM ,
  389. g.LotNO LotNo,
  390. a.MEMO colMemo,
  391. a.MUSERName ,
  392. f.EATTRIBUTE1 asnNo,
  393. CONVERT(varchar(100),a.MTIME,120)
  394. from ICSINVReceiptDetail a
  395. left join ICSINVReceipt f on a.ReceiptNO=f.ReceiptNO
  396. left JOIN dbo.ICSINVENTORY c ON a.ITEMCODE = c.INVCODE
  397. LEFT JOIN dbo.ICSINVInfo d ON d.INVCODE=c.INVCODE
  398. LEFT JOIN dbo.ICSWareHouseLotInfoLog g ON g.TransNO=a.ReceiptNO and g.TransLine=a.ReceiptLine
  399. LEFT JOIN dbo.ICSITEMLot e ON e.LotNO=g.LotNO
  400. where a.ReceiptNO='{0}' and a.ISINSTORAGE='N' AND g.TransType=''
  401. ";
  402. sql = string.Format(sql, buttonEdit1.Text);
  403. DataTable data = DBHelper.ExecuteDataset(AppConfig.GetDataBaseConnectStringByKey("[DB.SYS]"), CommandType.Text, sql).Tables[0];
  404. grdDetail.DataSource = data;
  405. grvDetail.BestFitColumns();
  406. }
  407. #endregion
  408. #region 合格不合格判定事件
  409. private void repositoryItemButtonEdit1_Click(object sender, EventArgs e)
  410. {
  411. try
  412. {
  413. DataRow df=CheckStatus("合格");
  414. UpdateStatus(df["到货单号"].ToString(), df["行号"].ToString(), grvDetail.FocusedRowHandle, "合格");
  415. }
  416. catch (Exception ex)
  417. { return; }
  418. }
  419. private void repositoryItemButtonEdit2_Click(object sender, EventArgs e)
  420. {
  421. try
  422. {
  423. DataRow df = CheckStatus("不合格");
  424. UpdateStatus(df["到货单号"].ToString(), df["行号"].ToString(), grvDetail.FocusedRowHandle, "不合格");
  425. }
  426. catch (Exception ex)
  427. { return; }
  428. }
  429. private DataRow CheckStatus(string Status)
  430. {
  431. try
  432. {
  433. if (grvDetail.FocusedRowHandle < 0)
  434. { throw new Exception("error"); }
  435. DataRow df = grvDetail.GetDataRow(grvDetail.FocusedRowHandle);
  436. if (df == null)
  437. { throw new Exception("error"); }
  438. if (df["检验状态"].ToString() == Status)
  439. throw new Exception("error");
  440. df["检验状态"] = Status;
  441. return df;
  442. }
  443. catch (Exception ex) { throw ex; }
  444. }
  445. private void UpdateStatus(string RcvNo,string LineNo,int num,string Status)
  446. {
  447. grvDetail.SetRowCellValue(num, , Status);
  448. grvDetail.SetRowCellValue(num, CreateUser, AppConfig.UserName);
  449. grvDetail.SetRowCellValue(num, CreateTime, AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss").ToString("yyyy-MM-dd HH:mm:ss"));
  450. //修改行状态
  451. string sql = @"update ICSINVReceiptDetail set IQCStatus='{2}',MUSERName='{3}',MTIME='{4}'
  452. where ReceiptNO='{0}' and ReceiptLine='{1}'";
  453. sql = string.Format(sql, RcvNo, LineNo, Status, AppConfig.UserName, AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss").ToString("yyyy-MM-dd HH:mm:ss"));
  454. DBHelper.ExecuteDataset(AppConfig.GetDataBaseConnectStringByKey("[DB.SYS]"), CommandType.Text, sql);
  455. //修改头状态
  456. sql = @"select * from ICSINVReceiptDetail
  457. where ReceiptNO='{0}' and IQCStatus='{1}'";
  458. sql = string.Format(sql, RcvNo,"待检");
  459. DataTable dt=DBHelper.ExecuteDataset(AppConfig.GetDataBaseConnectStringByKey("[DB.SYS]"), CommandType.Text, sql).Tables[0];
  460. if (dt == null || dt.Rows.Count == 0)
  461. {
  462. sql = @"update ICSINVReceipt set RECSTATUS='{1}',MUSERName='{2}',MTIME='{3}'
  463. where ReceiptNO='{0}'";
  464. sql = string.Format(sql, RcvNo, "已检",AppConfig.UserName,AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss"));
  465. DBHelper.ExecuteDataset(AppConfig.GetDataBaseConnectStringByKey("[DB.SYS]"), CommandType.Text, sql);
  466. textBox2.Text = "已检";
  467. }
  468. //修改子状态
  469. sql = @"select * from ICSINVReceiptDetail
  470. where ReceiptNO='{0}' and IQCStatus='{1}'";
  471. sql = string.Format(sql, RcvNo, "待检");
  472. DataTable dt1 = DBHelper.ExecuteDataset(AppConfig.GetDataBaseConnectStringByKey("[DB.SYS]"), CommandType.Text, sql).Tables[0];
  473. if (dt1 == null || dt1.Rows.Count == 0)
  474. {
  475. sql = @"update ICSINVReceiptDetail set RECSTATUS='{1}',MUSERName='{2}',MTIME='{3}'
  476. where ReceiptNO='{0}'";
  477. sql = string.Format(sql, RcvNo, "已检", AppConfig.UserName, AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss"));
  478. DBHelper.ExecuteDataset(AppConfig.GetDataBaseConnectStringByKey("[DB.SYS]"), CommandType.Text, sql);
  479. }
  480. }
  481. private void simpleButton1_Click(object sender, EventArgs e)
  482. {
  483. if (MessageBox.Show("确认要全判定合格吗?", "合格确认", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
  484. {
  485. for (int i = 0; i < grvDetail.RowCount; i++)
  486. {
  487. DataRow df = grvDetail.GetDataRow(i);
  488. if (df == null) continue;
  489. UpdateStatus(df["到货单号"].ToString(), df["行号"].ToString(),i, "合格");
  490. }
  491. }
  492. gridView1_FocusedRowChanged(null, null);
  493. }
  494. private void simpleButton2_Click(object sender, EventArgs e)
  495. {
  496. if (MessageBox.Show("确认要全判定不合格吗?", "不合格确认", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
  497. {
  498. for (int i = 0; i < grvDetail.RowCount; i++)
  499. {
  500. DataRow df = grvDetail.GetDataRow(i);
  501. if (df == null) continue;
  502. UpdateStatus(df["到货单号"].ToString(), df["行号"].ToString(), i, "不合格");
  503. }
  504. }
  505. gridView1_FocusedRowChanged(null,null);
  506. }
  507. #endregion
  508. #region 备注修改
  509. private void repositoryItemButtonEdit3_Click(object sender, EventArgs e)
  510. {
  511. FormRtn rtn = new FormRtn();
  512. if (rtn.ShowDialog() == DialogResult.OK)
  513. {
  514. if (grvDetail.FocusedRowHandle < 0) return;
  515. DataRow dm = grvDetail.GetDataRow(grvDetail.FocusedRowHandle);
  516. if (dm == null) return;
  517. if (!string.IsNullOrEmpty(rtn.Remark))
  518. {
  519. UpdateMEMO(dm, rtn.Remark);
  520. }
  521. else
  522. {
  523. if (MessageBox.Show("备注为空,请确认?", "备注确认", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
  524. {
  525. UpdateMEMO(dm, rtn.Remark);
  526. }
  527. }
  528. }
  529. }
  530. private void UpdateMEMO(DataRow dm,string Memo)
  531. {
  532. grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, , Memo);
  533. string sql = @"update ICSINVReceiptDetail set MEMO='{2}'
  534. where ReceiptNO='{0}' and ReceiptLine='{1}'";
  535. sql = string.Format(sql, dm["到货单号"].ToString(), dm["行号"].ToString(), Memo);
  536. DBHelper.ExecuteDataset(AppConfig.GetDataBaseConnectStringByKey("[DB.SYS]"), CommandType.Text, sql);
  537. }
  538. #endregion
  539. #region 特采标识
  540. private void repositoryItemButtonEdit4_Click(object sender, EventArgs e)
  541. {
  542. if (grvDetail.FocusedRowHandle < 0) return;
  543. DataRow dm = grvDetail.GetDataRow(grvDetail.FocusedRowHandle);
  544. if (dm == null) return;
  545. if (dm["检验状态"].ToString() == "不合格")
  546. {
  547. dm["检验状态"] = "特采";
  548. UpdateStatus(dm["到货单号"].ToString(), dm["行号"].ToString(), grvDetail.FocusedRowHandle, "特采");
  549. }
  550. if (dm["检验状态"].ToString() == "合格")
  551. {
  552. MessageBox.Show("不合格状态下才能特采,请确认。");
  553. }
  554. }
  555. #endregion
  556. private void grvDetail_RowStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowStyleEventArgs e)
  557. {
  558. int hand = e.RowHandle;
  559. if (hand < 0) return;
  560. DataRow dr = this.grvDetail.GetDataRow(hand);
  561. if (dr == null) return;
  562. if (dr["橡胶件"].ToString() == "True")
  563. {
  564. //e.Appearance.ForeColor = Color.Red;// 改变行字体颜色
  565. e.Appearance.BackColor = Color.Red;// 改变行背景颜色
  566. //根据需求
  567. }
  568. }
  569. private void buttonEdit1_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  570. {
  571. string sql = @"SELECT f.ReceiptNO 单号,
  572. EATTRIBUTE1 ,
  573. f.RECSTATUS ,
  574. f.MTIME ,
  575. f.CreateUSER
  576. FROM ICSINVReceipt f
  577. where (RECSTATUS='' or RECSTATUS='') and ISALLINSTORAGE='N'";
  578. DataTable data = DBHelper.ExecuteDataset(AppConfig.GetDataBaseConnectStringByKey("[DB.SYS]"), CommandType.Text, sql).Tables[0];
  579. FormDataRefer reForm = new FormDataRefer();
  580. reForm.FormTitle = "到货单信息";
  581. reForm.DataSource = data;
  582. reForm.MSelectFlag = false;
  583. reForm.RowIndexWidth = 35;
  584. reForm.Width = 600;
  585. reForm.FormHeight = 900;
  586. if (reForm.ShowDialog() == DialogResult.OK)
  587. {
  588. foreach (DataRow dr in reForm.ReturnData.Rows)
  589. {
  590. buttonEdit1.Text = dr["单号"].ToString();
  591. textBox2.Text = dr["状态"].ToString();
  592. textBox3.Text = dr["报检时间"].ToString();
  593. textBox4.Text = dr["报检人"].ToString();
  594. //if (dr["橡胶件"].ToString() == "True")
  595. // label2.BackColor = Color.Red;
  596. //else
  597. // label2.BackColor = Color.White;
  598. }
  599. }
  600. gridView1_FocusedRowChanged(null,null);
  601. }
  602. private void btnSubmit_Click(object sender, EventArgs e)
  603. {
  604. string str = "";
  605. String id = "";
  606. SimpleButton btntemp = (SimpleButton)sender;
  607. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  608. {
  609. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  610. return;
  611. }
  612. if (grvDetail.RowCount == 0)
  613. {
  614. ICSBaseSimpleCode.AppshowMessageBox("请添加送检单!");
  615. return;
  616. }
  617. //string sql3 = @"select * from ICSINVReceipt where ReceiptNO='{0}' and RECSTATUS='已检'";
  618. //sql3 = string.Format(sql3, buttonEdit1.Text);
  619. //DataTable dt2 = DBHelper.ExecuteDataset(AppConfig.GetDataBaseConnectStringByKey("[DB.SYS]"), CommandType.Text, sql3).Tables[0];
  620. //if (dt2 != null && dt2.Rows.Count != 0)
  621. //{
  622. // ICSBaseSimpleCode.AppshowMessageBox("此送检单部分或全部已检!");
  623. //}
  624. try {
  625. string sql2 = @"update ICSINVReceipt set RECSTATUS='{1}',MUSERName='{2}',MTIME='{3}'
  626. where ReceiptNO='{0}'";
  627. sql2 = string.Format(sql2, buttonEdit1.Text, "已检", AppConfig.UserName, AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss").ToString("yyyy-MM-dd HH:mm:ss"));
  628. DBHelper.ExecuteDataset(AppConfig.GetDataBaseConnectStringByKey("[DB.SYS]"), CommandType.Text, sql2);
  629. textBox2.Text = "已检";
  630. List<string> editList = new List<string>();
  631. for (int i = 0; i < grvDetail.RowCount; i++)
  632. {
  633. if (grvDetail.GetRowCellValue(i, colSelect).ToString() == "Y")
  634. {
  635. id = grvDetail.GetRowCellValue(i, colID).ToString();
  636. editList.Add(id);
  637. }
  638. }
  639. if (editList.Count == 0 || id == "")
  640. {
  641. ICSBaseSimpleCode.AppshowMessageBox("请选择数据进行编辑!!!");
  642. return;
  643. }
  644. for (int i = 0; i < grvDetail.RowCount; i++)
  645. {
  646. if (grvDetail.GetRowCellValue(i, colSelect).ToString() == "Y")
  647. {
  648. string sql1 = @"select * from ICSWareHouseLotInfoLog where LotNO='{0}' and BusinessCode='{1}'";
  649. sql1 = string.Format(sql1, grvDetail.GetRowCellValue(i, LotNo).ToString(), "采购入库");
  650. DataTable dt1 = DBHelper.ExecuteDataset(AppConfig.GetDataBaseConnectStringByKey("[DB.SYS]"), CommandType.Text, sql1).Tables[0];
  651. //string sql3 = @"select * from ICSINVReceiptDetail where ReceiptNO='{0}' and RECSTATUS='{1}'";
  652. //sql3 = string.Format(sql3, grvDetail.GetRowCellValue(i, RCVNo).ToString(), "已检");
  653. //DataTable dt3 = DBHelper.ExecuteDataset(AppConfig.GetDataBaseConnectStringByKey("[DB.SYS]"), CommandType.Text, sql3).Tables[0];
  654. if (dt1 == null || dt1.Rows.Count == 0)
  655. {
  656. string sql = @"update ICSITEMLot set EATTRIBUTE3={1},EATTRIBUTE4={2}
  657. where LotNo='{0}' and MCODE='{3}'
  658. update ICSINVReceiptDetail set RECSTATUS='{4}',IQCStatus='{4}',MUSERName='{5}',MTIME='{6}'
  659. where ReceiptNO='{7}' AND ReceiptLine='{8}'";
  660. sql = string.Format(sql, grvDetail.GetRowCellValue(i, LotNo).ToString(), grvDetail.GetRowCellValue(i, YLOTQTY).ToString(),
  661. Convert.ToDecimal(grvDetail.GetRowCellValue(i, Qty).ToString()) - Convert.ToDecimal(grvDetail.GetRowCellValue(i, YLOTQTY).ToString()),
  662. grvDetail.GetRowCellValue(i, ).ToString(), "已检", AppConfig.UserName, AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss").ToString("yyyy-MM-dd HH:mm:ss"),
  663. grvDetail.GetRowCellValue(i, RCVNo).ToString(), grvDetail.GetRowCellValue(i, ).ToString());
  664. DBHelper.ExecuteDataset(AppConfig.GetDataBaseConnectStringByKey("[DB.SYS]"), CommandType.Text, sql);
  665. }
  666. else
  667. {
  668. str += grvDetail.GetRowCellValue(i, LotNo).ToString() + "\r\n";
  669. continue;
  670. }
  671. }
  672. }
  673. }
  674. catch (Exception ex)
  675. {
  676. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  677. }
  678. if (str == "")
  679. {
  680. ICSBaseSimpleCode.AppshowMessageBox("保存成功!");
  681. btnRefresh_Click(null, null);
  682. }
  683. else
  684. {
  685. MessageBox.Show("提示:本单据以下条码\r\n" + str + "已经入库,不能修改!");
  686. btnRefresh_Click(null, null);
  687. }
  688. }
  689. }
  690. }