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

626 lines
29 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 FormICSONWIPCheckAll : DevExpress.XtraEditors.XtraForm
  29. {
  30. private string sqltxt = "";
  31. private string sqlconn = "";
  32. private DataTable dataSource = null;
  33. public string id = "";
  34. private OPType type;
  35. #region 构造函数
  36. public FormICSONWIPCheckAll(OPType Type)
  37. {
  38. InitializeComponent();
  39. this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  40. this.WindowState = FormWindowState.Maximized;
  41. type = Type;
  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(btnCreate);
  57. ControlList.Add(btnModify);
  58. ControlList.Add(btnOutPut);
  59. foreach (Control ctr in ControlList)
  60. {
  61. if (ctr.GetType() == typeof(SimpleButton))
  62. {
  63. DataRow dr = rData.NewRow();
  64. dr["BtnName"] = ctr.Name;
  65. dr["ActionName"] = ctr.Text;
  66. rData.Rows.Add(dr);
  67. }
  68. }
  69. rData.AcceptChanges();
  70. return rData;
  71. }
  72. public DataTable RightOfData()// 数据权限
  73. {
  74. DataTable rData = new DataTable();
  75. rData.Columns.Add("BodyName");
  76. rData.Columns.Add("ControlName");
  77. rData.Columns.Add("ControlCaption");
  78. rData.AcceptChanges();
  79. return rData;
  80. }
  81. #endregion
  82. #region 退出
  83. private void btnClose_Click(object sender, EventArgs e)
  84. {
  85. AppConfig.CloseFormShow(this.Text);
  86. this.Close();
  87. }
  88. private void btnExit_Click(object sender, EventArgs e)
  89. {
  90. AppConfig.CloseFormShow(this.Text);
  91. this.Close();
  92. }
  93. #endregion
  94. #region 移动窗体
  95. private const int WM_NCHITTEST = 0x84;
  96. private const int HTCLIENT = 0x1;
  97. private const int HTCAPTION = 0x2;
  98. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  99. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  100. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  101. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  102. //重写窗体,使窗体可以不通过自带标题栏实现移动
  103. protected override void WndProc(ref Message m)
  104. {
  105. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  106. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  107. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  108. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  109. switch (m.Msg)
  110. {
  111. case WM_NCHITTEST:
  112. base.WndProc(ref m);
  113. if ((int)m.Result == HTCLIENT)
  114. m.Result = (IntPtr)HTCAPTION;
  115. return;
  116. }
  117. //拦截双击标题栏、移动窗体的系统消息
  118. if (m.Msg != 0xA3)
  119. {
  120. base.WndProc(ref m);
  121. }
  122. }
  123. #endregion
  124. #region 列表
  125. private void grvDetail_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
  126. {
  127. if (e.Info.IsRowIndicator && e.RowHandle >= 0)
  128. e.Info.DisplayText = (e.RowHandle + 1).ToString();
  129. }
  130. #endregion
  131. #region 全选
  132. private void btnSelectAll_Click(object sender, EventArgs e)
  133. {
  134. grvDetail.PostEditor();
  135. this.Validate();
  136. for (int i = 0; i < grvDetail.RowCount; i++)
  137. {
  138. grvDetail.SetRowCellValue(i, colisSelect, true);
  139. }
  140. }
  141. #endregion
  142. #region 全消
  143. private void btnCancelAll_Click(object sender, EventArgs e)
  144. {
  145. grvDetail.PostEditor();
  146. this.Validate();
  147. for (int i = 0; i < grvDetail.RowCount; i++)
  148. {
  149. grvDetail.SetRowCellValue(i, colisSelect, false);
  150. }
  151. }
  152. #endregion
  153. #region 导出
  154. private void btnOutPut_Click(object sender, EventArgs e)
  155. {
  156. FormOutExcel foe = new FormOutExcel(this.Tag.ToString(), grdDetail);
  157. foe.ShowDialog();
  158. }
  159. #endregion
  160. #region 刷新
  161. private void btnRefresh_Click(object sender, EventArgs e)
  162. {
  163. SearchData(" AND chk.EndDateTime IS NULL ");
  164. }
  165. #endregion
  166. private void check(int index)
  167. {
  168. if (type == OPType.Self)
  169. {
  170. if (Convert.ToBoolean(grvDetail.GetRowCellValue(index, colisCtrlType))
  171. && string.IsNullOrWhiteSpace(grvDetail.GetRowCellValue(index, colOKQuantity).ToString()))
  172. {
  173. throw new Exception(string.Format("第{0}行上道工序未检验,不能执行此操作!", index + 1));
  174. }
  175. if (!Convert.ToBoolean(grvDetail.GetRowCellValue(index, colCanCheck)))
  176. {
  177. throw new Exception(string.Format("第{0}行过程检验未完成,不能执行此操作!", index + 1));
  178. }
  179. }
  180. else if (type == OPType.Check && string.IsNullOrWhiteSpace(grvDetail.GetRowCellValue(index, colID).ToString()))
  181. {
  182. throw new Exception("第" + (index + 1) + "行未生成巡检单,不能执行此操作!");
  183. }
  184. }
  185. #region 新增
  186. private void btnCreate_Click(object sender, EventArgs e)
  187. {
  188. try
  189. {
  190. saveData("放行");
  191. btnRefresh_Click(null, null);
  192. }
  193. catch (Exception ex)
  194. {
  195. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  196. }
  197. }
  198. #endregion
  199. #region 修改
  200. private void btnModify_Click(object sender, EventArgs e)
  201. {
  202. try
  203. {
  204. saveData("判退");
  205. btnRefresh_Click(null, null);
  206. }
  207. catch (Exception ex)
  208. {
  209. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  210. }
  211. }
  212. #endregion
  213. #region 置顶
  214. private void btnTop_Click(object sender, EventArgs e)
  215. {
  216. try
  217. {
  218. int count = 0;
  219. string sql = "";
  220. for (int i = 0; i < grvDetail.RowCount; i++)
  221. {
  222. if (Convert.ToBoolean(grvDetail.GetRowCellValue(i, colisSelect)))
  223. {
  224. if (type == OPType.Check && string.IsNullOrWhiteSpace(grvDetail.GetRowCellValue(i, colID).ToString()))
  225. {
  226. throw new Exception("第" + (i + 1) + "行未生成巡检单,不能执行此操作!");
  227. }
  228. count++;
  229. // sql = @" INSERT INTO ICSLOTONWIPCheckTop(ID, FORTRANID, Type, TopDateTime, MUSER, MUSERName, MTIME, WorkPoint, EATTRIBUTE1)
  230. // VALUES (NEWID(),'{0}','{1}',SysDateTime(),'{2}','{3}',GETDATE(),'{4}','1')
  231. // ";
  232. sql = @"
  233. IF NOT EXISTS(SELECT 1 FROM ICSLOTONWIPCheckTop WHERE FORTRANID='{0}')
  234. BEGIN
  235. INSERT INTO ICSLOTONWIPCheckTop
  236. (ID, FORTRANID, Type, TopDateTime, MUSER, MUSERName, MTIME, WorkPoint, EATTRIBUTE1)
  237. VALUES (NEWID(),'{0}','{1}',SysDateTime(),'{2}','{3}',GETDATE(),'{4}','1')
  238. END
  239. ELSE
  240. BEGIN
  241. UPDATE ICSLOTONWIPCheckTop SET TopDateTime=SysDateTime(),EATTRIBUTE1=1 WHERE FORTRANID='{0}'
  242. END
  243. ";
  244. sql = string.Format(sql, grvDetail.GetRowCellValue(i, colID).ToString(), FormICSONWIPCheck.GetEnumDescription<OPType>(type),
  245. AppConfig.UserCode, AppConfig.UserName, AppConfig.WorkPointCode);
  246. }
  247. }
  248. if (count != 1)
  249. {
  250. ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  251. return;
  252. }
  253. DBHelper.ExecuteNonQuery(AppConfig.AppConnectString, CommandType.Text, sql);
  254. btnRefresh_Click(null, null);
  255. }
  256. catch (Exception ex)
  257. {
  258. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  259. }
  260. }
  261. #endregion
  262. #region 显示全部
  263. private void btnALL_Click(object sender, EventArgs e)
  264. {
  265. try
  266. {
  267. SearchData("");
  268. }
  269. catch (Exception ex)
  270. {
  271. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  272. }
  273. }
  274. #endregion
  275. private void FormICSONWIPCheckAll_Load(object sender, EventArgs e)
  276. {
  277. try
  278. {
  279. btnCreate.Visible = true;
  280. btnModify.Visible = true;
  281. btnCheck.Visible = false;
  282. colQuantity.OptionsColumn.ReadOnly = true;
  283. if (type == OPType.Inspect)
  284. {
  285. colCode.Caption = "送检单号";
  286. colQuantity.Caption = "送检数量";
  287. colMUSERName.Caption = "送检人";
  288. colMTIME.Caption = "送检时间";
  289. }
  290. else if (type == OPType.Check)
  291. {
  292. colCode.Caption = "产品跟踪单";
  293. colQuantity.Caption = "巡检数量";
  294. btnCheck.Visible = true;
  295. colQuantity.OptionsColumn.ReadOnly = false;
  296. colMUSERName.Caption = "送检人";
  297. colMTIME.Caption = "送检时间";
  298. }
  299. else
  300. {
  301. btnCreate.Visible = false;
  302. btnModify.Visible = false;
  303. colCode.Caption = "产品跟踪单";
  304. colQuantity.Caption = "跟踪单数量";
  305. colMUSERName.Caption = "完工人";
  306. colMTIME.Caption = "完工时间";
  307. //if (type == OPType.Self)
  308. //{
  309. // btnCreate.Visible = false;
  310. // btnModify.Visible = false;
  311. //}
  312. }
  313. SearchData(" AND chk.EndDateTime IS NULL ");
  314. }
  315. catch (Exception ex)
  316. {
  317. ICSBaseSimpleCode.AppshowMessageBox("异常:" + ex.Message);
  318. }
  319. }
  320. #region 查询数据
  321. private void SearchData(string where)
  322. {
  323. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在查找...请稍等...");
  324. try
  325. {
  326. _wait.Show();
  327. string sql = "";
  328. if (type == OPType.Inspect)
  329. {
  330. #region 检验
  331. sql = @"SELECT
  332. CAST( 0 AS BIT ) AS isSelect,e.ID,e.TransNO AS Code,e.MTIME,a.ITEMCODE,b.INVNAME,b.INVSTD,e.CheckMode,lot.OPSEQ,a.OPCODE,d.OPDESC,e.Quantity,e.MUSERName,
  333. u.UserName AS chkMUSERName,chk.BeginDateTime,chk.EndDateTime,a.LOTNO,
  334. chk.Status AS Result,CAST(CASE WHEN t.FORTRANID IS NULL THEN '0' ELSE '1' END AS BIT) AS [Top],
  335. CASE WHEN ISNULL( chk.Status , '' ) = '' THEN '' ELSE '' END AS [Status]
  336. FROM ICSLOTONWIP a
  337. INNER JOIN ICSINVENTORY b ON a.ITEMCODE=b.INVCODE AND a.WorkPoint=b.WorkPoint
  338. INNER JOIN ICSITEMROUTE2OPLot lot ON a.LOTNO=lot.LOTNO AND a.OPCODE=lot.OPCODE AND a.WorkPoint=lot.WorkPoint
  339. INNER JOIN ICSOP d ON a.OPCODE=d.OPCODE AND a.WorkPoint=d.WorkPoint
  340. INNER JOIN ICSLOTONWIPDetail det ON det.LOTNO=a.LOTNO AND det.OPCode=a.OPCODE AND a.WorkPoint=det.WorkPoint
  341. INNER JOIN ICSLOTONWIPInspection e ON det.ID=e.DetailID AND det.WorkPoint=e.WorkPoint
  342. LEFT JOIN ICSLOTONWIPCheck chk ON e.ID=chk.FORTRANID AND e.WorkPoint=chk.WorkPoint AND chk.Enable='1'
  343. LEFT JOIN Sys_User u ON u.UserCode=chk.EATTRIBUTE1 AND u.WorkPointCode=chk.WorkPoint
  344. LEFT JOIN ICSLOTONWIPCheckTop t ON e.ID=t.FORTRANID AND e.WorkPoint=t.WorkPoint AND t.EATTRIBUTE1='1'
  345. WHERE a.WorkPoint='{0}' {1} ORDER BY e.CheckMode,t.TopDateTime DESC,e.TransNO";
  346. #endregion
  347. }
  348. else if (type == OPType.Check)
  349. {
  350. #region 巡检
  351. sql = @"SELECT
  352. CAST( 0 AS BIT ) AS isSelect,e.ID,a.LOTNO AS Code,e.MTIME,a.ITEMCODE,b.INVNAME,b.INVSTD,'' AS CheckMode,lot.OPSEQ,a.OPCODE,d.OPDESC,ISNULL(e.Quantity, det.OKQty) AS Quantity,e.MUSERName,
  353. u.UserName AS chkMUSERName,chk.BeginDateTime,chk.EndDateTime,a.LOTNO,
  354. chk.Status AS Result,CAST(CASE WHEN t.FORTRANID IS NULL THEN '0' ELSE '1' END AS BIT) AS [Top],
  355. CASE WHEN ISNULL( chk.Status , '' ) = '' THEN '' ELSE '' END AS [Status],det.ID AS DetailID
  356. FROM ICSLOTONWIP a
  357. INNER JOIN ICSINVENTORY b ON a.ITEMCODE=b.INVCODE AND a.WorkPoint=b.WorkPoint
  358. INNER JOIN ICSITEMROUTE2OPLot lot ON a.LOTNO=lot.LOTNO AND a.OPCODE=lot.OPCODE AND a.WorkPoint=lot.WorkPoint
  359. INNER JOIN ICSOP d ON a.OPCODE=d.OPCODE AND a.WorkPoint=d.WorkPoint
  360. INNER JOIN ICSLOTONWIPDetail det ON det.LOTNO=a.LOTNO AND det.OPCode=a.OPCODE AND a.WorkPoint=det.WorkPoint
  361. LEFT JOIN ICSLOTONWIPInspection e ON det.ID=e.DetailID AND det.WorkPoint=e.WorkPoint
  362. LEFT JOIN ICSLOTONWIPCheck chk ON e.ID=chk.FORTRANID AND e.WorkPoint=chk.WorkPoint AND chk.Enable='1'
  363. LEFT JOIN Sys_User u ON u.UserCode=chk.EATTRIBUTE1 AND u.WorkPointCode=chk.WorkPoint
  364. LEFT JOIN ICSLOTONWIPCheckTop t ON e.ID=t.FORTRANID AND e.WorkPoint=t.WorkPoint AND t.EATTRIBUTE1='1'
  365. WHERE CollectStatus='COLLECT_BEGIN' AND a.WorkPoint='{0}' {1} ORDER BY e.CheckMode,t.TopDateTime DESC,e.TransNO";
  366. #endregion
  367. }
  368. else if (type == OPType.Self)
  369. {
  370. #region 完工检验
  371. sql = @"SELECT
  372. CAST( 0 AS BIT ) AS isSelect,a.ID,a.LOTNO AS Code,a.MTIME,a.ITEMCODE,b.INVNAME,b.INVSTD,'' AS CheckMode,lot.OPSEQ,a.OPCODE,d.OPDESC,a.LOTQTY AS Quantity,u.UserName AS MUSERName,
  373. u2.UserName AS chkMUSERName,chk.BeginDateTime,chk.EndDateTime,a.LOTNO,
  374. chk.Status AS Result,CAST(CASE WHEN t.FORTRANID IS NULL THEN '0' ELSE '1' END AS BIT) AS [Top],
  375. CASE WHEN ISNULL( chk.Status , '' ) = '' THEN '' ELSE '' END AS [Status],
  376. CAST(CASE WHEN lot.CtrlType='' AND lotlast.CtrlType='' THEN '1' ELSE '0' END AS BIT) AS isCtrlType,
  377. CASE WHEN lot.CtrlType='' AND lotlast.CtrlType='' THEN chklast.OKQuantity ELSE a.LOTQTY END AS OKQuantity,
  378. CAST(CASE WHEN chk.Status='' AND ncr.FORTRANID IS NULL THEN 0 ELSE 1 END AS BIT) AS CanCheck
  379. FROM ICSLOTONWIP a
  380. INNER JOIN ICSINVENTORY b ON a.ITEMCODE=b.INVCODE AND a.WorkPoint=b.WorkPoint
  381. INNER JOIN ICSMO2User us ON a.LOTNO=us.LOTNO AND a.OPCODE=us.OPCODE AND a.WorkPoint=us.WorkPoint
  382. INNER JOIN ICSITEMROUTE2OPLot lot ON a.LOTNO=lot.LOTNO AND a.OPCODE=lot.OPCODE AND a.WorkPoint=lot.WorkPoint
  383. LEFT JOIN ICSITEMROUTE2OPLot lotlast ON lot.LOTNO=lotlast.LOTNO AND lot.WorkPoint=lotlast.WorkPoint AND lotlast.OPSEQ=(SELECT MAX(OPSEQ) FROM ICSITEMROUTE2OPLot WHERE LotNo=lot.LotNo AND WorkPoint=lot.WorkPoint AND OPSEQ<lot.OPSEQ)
  384. LEFT JOIN ICSLOTONWIP wip ON wip.LOTNO=lotlast.LOTNO AND wip.OPCODE=lotlast.OPCODE AND wip.WorkPoint=lotlast.WorkPoint
  385. LEFT JOIN ICSLOTONWIPCheck chklast ON wip.ID=chklast.FORTRANID AND wip.WorkPoint=chklast.WorkPoint AND chklast.Enable='1'
  386. INNER JOIN ICSOP d ON a.OPCODE=d.OPCODE AND a.WorkPoint=d.WorkPoint
  387. LEFT JOIN ICSLOTONWIPCheck chk ON a.ID=chk.FORTRANID AND a.WorkPoint=chk.WorkPoint AND chk.Enable='1'
  388. LEFT JOIN (SELECT b.FORTRANID,b.WorkPoint
  389. FROM ICSLOTONWIPCheckDetail b
  390. LEFT JOIN ICSLOTONWIPCheckNCR a ON a.CheckID=b.ID AND a.WorkPoint=b.WorkPoint
  391. WHERE b.Type=''
  392. GROUP BY b.FORTRANID,b.WorkPoint
  393. HAVING COUNT(b.FORTRANID)=SUM(CASE WHEN a.DownDateTime IS NULL THEN 0 ELSE 1 END)) ncr ON chk.ID=ncr.FORTRANID AND chk.WorkPoint=ncr.WorkPoint
  394. LEFT JOIN Sys_User u ON u.UserCode=a.UserCodeEnd AND u.WorkPointCode=a.WorkPoint
  395. LEFT JOIN Sys_User u2 ON u2.UserCode=chk.EATTRIBUTE1 AND u2.WorkPointCode=chk.WorkPoint
  396. LEFT JOIN ICSLOTONWIPCheckTop t ON a.ID=t.FORTRANID AND a.WorkPoint=t.WorkPoint AND t.EATTRIBUTE1='1'
  397. WHERE us.EATTRIBUTE1='0' AND a.ACTIONRESULT='COLLECT_END' and a.WorkPoint='{0}' {1} ORDER BY t.TopDateTime DESC,a.LOTNO";
  398. #endregion
  399. }
  400. else
  401. {
  402. #region 委外检验
  403. sql = @"SELECT
  404. CAST( 0 AS BIT ) AS isSelect,a.ID,a.LOTNO AS Code,a.MTIME,a.ITEMCODE,b.INVNAME,b.INVSTD,'' AS CheckMode,lot.OPSEQ,a.OPCODE,d.OPDESC,a.LOTQTY AS Quantity,u.UserName AS MUSERName,
  405. u2.UserName AS chkMUSERName,chk.BeginDateTime,chk.EndDateTime,a.LOTNO,
  406. chk.Status AS Result,CAST(CASE WHEN t.FORTRANID IS NULL THEN '0' ELSE '1' END AS BIT) AS [Top],
  407. CASE WHEN ISNULL( chk.Status , '' ) = '' THEN '' ELSE '' END AS [Status]
  408. FROM ICSLOTONWIP a
  409. INNER JOIN ICSINVENTORY b ON a.ITEMCODE=b.INVCODE AND a.WorkPoint=b.WorkPoint
  410. INNER JOIN ICSMO2User us ON a.LOTNO=us.LOTNO AND a.OPCODE=us.OPCODE AND a.WorkPoint=us.WorkPoint
  411. INNER JOIN ICSITEMROUTE2OPLot lot ON a.LOTNO=lot.LOTNO AND a.OPCODE=lot.OPCODE AND a.WorkPoint=lot.WorkPoint
  412. INNER JOIN ICSOP d ON a.OPCODE=d.OPCODE AND a.WorkPoint=d.WorkPoint
  413. LEFT JOIN ICSLOTONWIPCheck chk ON a.ID=chk.FORTRANID AND a.WorkPoint=chk.WorkPoint AND chk.Enable='1'
  414. LEFT JOIN Sys_User u ON u.UserCode=a.UserCodeBegin AND u.WorkPointCode=a.WorkPoint
  415. LEFT JOIN Sys_User u2 ON u2.UserCode=chk.EATTRIBUTE1 AND u2.WorkPointCode=chk.WorkPoint
  416. LEFT JOIN ICSLOTONWIPCheckTop t ON a.ID=t.FORTRANID AND a.WorkPoint=t.WorkPoint AND t.EATTRIBUTE1='1'
  417. WHERE a.WorkPoint='{0}' {1} AND us.EATTRIBUTE1='1' AND a.ACTIONRESULT='COLLECT_END' ORDER BY t.TopDateTime DESC, a.LOTNO";
  418. #endregion
  419. }
  420. sql = string.Format(sql, AppConfig.WorkPointCode, where);
  421. dataSource = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  422. grdDetail.DataSource = dataSource;
  423. grvDetail.BestFitColumns();
  424. _wait.Close();
  425. }
  426. catch (Exception ex)
  427. {
  428. ICSBaseSimpleCode.AppshowMessageBox("异常:" + ex.Message);
  429. _wait.Close();
  430. }
  431. }
  432. #endregion
  433. #region 保存数据
  434. private void saveData(string status)
  435. {
  436. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在保存...请稍等...");
  437. try
  438. {
  439. _wait.Show();
  440. DateTime dt = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
  441. List<ICSLOTONWIPCheck> list = new List<ICSLOTONWIPCheck>();
  442. for (int i = 0; i < grvDetail.RowCount; i++)
  443. {
  444. if (Convert.ToBoolean(grvDetail.GetRowCellValue(i, colisSelect))
  445. && !grvDetail.GetRowCellValue(i, colStatus).Equals("已检"))
  446. {
  447. check(i);
  448. ICSLOTONWIPCheck Info = new ICSLOTONWIPCheck();
  449. Info.ID = AppConfig.GetGuid();
  450. Info.FORTRANID = grvDetail.GetRowCellValue(i, colID).ToString();
  451. Info.Quantity = Convert.ToDecimal(grvDetail.GetRowCellValue(i, colQuantity));
  452. if (status == "放行")
  453. {
  454. Info.OKQuantity = Info.Quantity;
  455. Info.NGQuantity = 0;
  456. }
  457. else
  458. {
  459. Info.OKQuantity = 0;
  460. Info.NGQuantity = Info.Quantity;
  461. }
  462. Info.Status = status;
  463. Info.BeginDateTime = dt;
  464. Info.EndDateTime = dt;
  465. Info.Enable = true;
  466. Info.FileName = "";
  467. Info.Type = FormICSONWIPCheck.GetEnumDescription<OPType>(type);
  468. Info.MUSER = AppConfig.UserCode;
  469. Info.MUSERName = AppConfig.UserName;
  470. Info.MTIME = dt;
  471. Info.WorkPoint = AppConfig.WorkPointCode;
  472. if (type == OPType.Self || type == OPType.Outsourcing)
  473. {
  474. Info.isBatch = true;
  475. }
  476. else
  477. {
  478. Info.isBatch = false;
  479. }
  480. Info.EATTRIBUTE1 = null;
  481. list.Add(Info);
  482. }
  483. }
  484. if (list.Count == 0)
  485. {
  486. _wait.Close();
  487. ICSBaseSimpleCode.AppshowMessageBox("请选择数据!");
  488. return;
  489. }
  490. ICSLOTONWIPCheckBLL.Add(list, AppConfig.AppConnectString);
  491. _wait.Close();
  492. }
  493. catch (Exception ex)
  494. {
  495. ICSBaseSimpleCode.AppshowMessageBox("异常:" + ex.Message);
  496. _wait.Close();
  497. }
  498. }
  499. #endregion
  500. private void grvDetail_DoubleClick(object sender, EventArgs e)
  501. {
  502. try
  503. {
  504. check(grvDetail.FocusedRowHandle);
  505. id = grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colID).ToString();
  506. this.Close();
  507. }
  508. catch (Exception ex)
  509. {
  510. ICSBaseSimpleCode.AppshowMessageBox("异常:" + ex.Message);
  511. }
  512. }
  513. private void grvDetail_RowStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowStyleEventArgs e)
  514. {
  515. try
  516. {
  517. int hand = e.RowHandle;
  518. if (hand < 0)
  519. return;
  520. if (Convert.ToBoolean(grvDetail.GetRowCellValue(hand, colTop)))
  521. {
  522. e.Appearance.BackColor = Color.Yellow;// 改变行背景颜色
  523. }
  524. }
  525. catch (Exception ex)
  526. {
  527. ICSBaseSimpleCode.AppshowMessageBox("异常:" + ex.Message);
  528. }
  529. }
  530. /// <summary>
  531. /// 送检
  532. /// </summary>
  533. /// <param name="sender"></param>
  534. /// <param name="e"></param>
  535. private void btnCheck_Click(object sender, EventArgs e)
  536. {
  537. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在保存...请稍等...");
  538. try
  539. {
  540. _wait.Show();
  541. List<ICSLOTONWIPInspection> infos = new List<ICSLOTONWIPInspection>();
  542. for (int i = 0; i < grvDetail.RowCount; i++)
  543. {
  544. if (Convert.ToBoolean(grvDetail.GetRowCellValue(i, colisSelect)))
  545. {
  546. if (!string.IsNullOrWhiteSpace(grvDetail.GetRowCellValue(i, colID).ToString()))
  547. {
  548. throw new Exception("第" + (i + 1) + "行已生成巡检单,不能重复生成!");
  549. }
  550. if (string.IsNullOrWhiteSpace(grvDetail.GetRowCellValue(i, colQuantity).ToString()))
  551. {
  552. throw new Exception("第" + (i + 1) + "行数量不能为空!");
  553. }
  554. ICSLOTONWIPInspection info = new ICSLOTONWIPInspection();
  555. info.ID = AppConfig.GetGuid();
  556. info.DetailID = grvDetail.GetRowCellValue(i, colDetailID).ToString();
  557. info.CheckMode = grvDetail.GetRowCellValue(i, colCheckMode).ToString();
  558. info.UserCode = AppConfig.UserCode;
  559. info.Quantity = grvDetail.GetRowCellValue(i, colQuantity).ToString();
  560. info.WorkPoint = AppConfig.WorkPointCode;
  561. info.MTIME = DateTime.Now;
  562. info.MUSER = AppConfig.UserCode;
  563. info.MUSERName = AppConfig.UserName;
  564. info.IsCalc = true;
  565. info.EATTRIBUTE1 = "巡检";
  566. infos.Add(info);
  567. }
  568. }
  569. if (infos.Count == 0)
  570. {
  571. _wait.Close();
  572. ICSBaseSimpleCode.AppshowMessageBox("请选择数据!");
  573. return;
  574. }
  575. ICSLOTONWIPInspectionBLL.AddList(infos, AppConfig.AppConnectString);
  576. _wait.Close();
  577. btnRefresh_Click(null, null);
  578. }
  579. catch (Exception ex)
  580. {
  581. ICSBaseSimpleCode.AppshowMessageBox("异常:" + ex.Message);
  582. _wait.Close();
  583. }
  584. }
  585. }
  586. }