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

752 lines
30 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 FormICSTS : DevExpress.XtraEditors.XtraForm
  29. {
  30. private string sqltxt = "";
  31. private string sqlconn = "";
  32. String guid = AppConfig.GetGuid();
  33. private DataTable dataSource = null;
  34. private string ecscode = "";
  35. private string ecode = "";
  36. private string ecsgcode = "";
  37. private string dutycode = "";
  38. private string solcode = "";
  39. private string tsid = "";
  40. private FormICSTSUIModel TS;
  41. private string fnode = "";
  42. private string snode = "";
  43. TreeNode theLastNode = null;
  44. #region 构造函数
  45. public FormICSTS()
  46. {
  47. InitializeComponent();
  48. this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  49. this.WindowState = FormWindowState.Maximized;
  50. txtECGDESC.Properties.ReadOnly = true;
  51. txtECDESC.Properties.ReadOnly = true;
  52. groupBox1.Visible = false;
  53. }
  54. #endregion
  55. private void InitDataTable()
  56. {
  57. string sql = @"select distinct ECGCODE
  58. from ICSTSERRORCODE
  59. where RCARD='" + txtRCARD.Text + "' and WorkPoint='" + AppConfig.WorkPointCode + "'";
  60. sql = string.Format(sql);
  61. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  62. BindRoot(data);
  63. }
  64. private void BindRoot(DataTable data)
  65. {
  66. //取根
  67. foreach (DataRow dr in data.Rows)
  68. {
  69. TreeNode rootNode = new TreeNode();
  70. rootNode.Tag = dr;
  71. rootNode.Text = dr["ECGCODE"].ToString();
  72. treeView1.Nodes.Add(rootNode);
  73. BindChildAreas(rootNode, data);
  74. }
  75. }
  76. //递归绑定子区域
  77. private void BindChildAreas(TreeNode fNode, DataTable data)
  78. {
  79. string sql = @"select ECODE
  80. from ICSTSERRORCODE
  81. where RCARD='" + txtRCARD.Text + "' and ECGCODE='" + fNode .Text+ "' and WorkPoint='" + AppConfig.WorkPointCode + "'";
  82. sql = string.Format(sql);
  83. DataTable data1 = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  84. //DataRow dr = (DataRow)fNode.Tag;
  85. ////父节点数据关联的数据行
  86. //string fid = (string)dr["ECGCODE"];
  87. ////父节点ID
  88. //DataRow[] rows = data1.Rows;//子区域
  89. if (data1.Rows.Count == 0) //递归终止,区域不包含子区域时
  90. { return; }
  91. foreach (DataRow dr in data1.Rows)
  92. {
  93. TreeNode node = new TreeNode();
  94. node.Tag = dr;
  95. node.Text = dr["ECODE"].ToString(); //添加子点
  96. fNode.Nodes.Add(node); //递归
  97. //BindChildAreas(node, data);
  98. }
  99. }
  100. private void TreeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
  101. {
  102. foreach (TreeNode node in treeView1.Nodes)
  103. {
  104. if (node.IsSelected)
  105. {
  106. return;
  107. }
  108. foreach (TreeNode childnode in node.Nodes)
  109. {
  110. if (childnode.IsSelected)
  111. {
  112. fnode = node.Text;
  113. snode = childnode.Text;
  114. groupBox1.Visible = true;
  115. string sql = @"select ECGDESC
  116. from ICSECG
  117. where ECGCODE='" + fnode + "' and WorkPoint='" + AppConfig.WorkPointCode + "'";
  118. sql = string.Format(sql);
  119. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  120. foreach (DataRow dr in data.Rows)
  121. {
  122. txtECGDESC.Text = dr["ECGDESC"].ToString();
  123. }
  124. string sql2 = @"select ECDESC
  125. from ICSEC
  126. where ECODE='" + snode + "' and WorkPoint='" + AppConfig.WorkPointCode + "'";
  127. sql2 = string.Format(sql2);
  128. DataTable data2 = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql2).Tables[0];
  129. foreach (DataRow dr2 in data2.Rows)
  130. {
  131. txtECDESC.Text = dr2["ECDESC"].ToString();
  132. }
  133. string sql3 = @"select a.EPART,b.PARTNAME
  134. from ICSTSERRORCAUSE2EPART a
  135. left join ICSPART b on a.EPART=b.PARTCODE
  136. where a.RCARD='" + txtRCARD.Text + "' and a.ECGCODE='" + fnode + "' and a.ECODE='" + snode + "' and a.WorkPoint='" + AppConfig.WorkPointCode + "'";
  137. sql3 = string.Format(sql3);
  138. DataTable data3 = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql3).Tables[0];
  139. if (data3.Rows.Count > 0)
  140. {
  141. foreach (DataRow dr3 in data3.Rows)
  142. {
  143. txtEPART.Text = dr3["PARTNAME"].ToString();
  144. }
  145. }
  146. else
  147. {
  148. txtEPART.Text = "";
  149. }
  150. string sql4 = @"select a.ECSCODE,a.ECSGCODE,a.DUTYCODE,a.SOLCODE,a.PREVENTION,b.ECSDESC,c.ECSGDESC,d.DUTYDESC,e.SOLDESC
  151. from ICSTSERRORCAUSE a
  152. left join ICSECS b on a.ECSCODE=b.ECSCODE
  153. left join ICSECSG c on a.ECSGCODE=c.ECSGCODE
  154. left join ICSDUTY d on a.DUTYCODE=d.DUTYCODE
  155. left join ICSSOLUTION e on a.SOLCODE=e.SOLCODE
  156. where a.RCARD='" + txtRCARD.Text + "' and a.ECGCODE='" + fnode + "' and a.ECODE='" + snode + "' and a.WorkPoint='" + AppConfig.WorkPointCode + "'";
  157. sql4 = string.Format(sql4);
  158. DataTable data4 = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql4).Tables[0];
  159. if (data4.Rows.Count > 0)
  160. {
  161. foreach (DataRow dr4 in data4.Rows)
  162. {
  163. txtECSCODE.Text = dr4["ECSDESC"].ToString();
  164. txtECSGCODE.Text = dr4["ECSGDESC"].ToString();
  165. txtDUTYCODE.Text = dr4["DUTYDESC"].ToString();
  166. txtSOLCODE.Text = dr4["SOLDESC"].ToString();
  167. txtPREVENTION.Text = dr4["PREVENTION"].ToString();
  168. }
  169. }
  170. else
  171. {
  172. txtECSCODE.Text = "";
  173. txtECSGCODE.Text = "";
  174. txtDUTYCODE.Text = "";
  175. txtSOLCODE.Text = "";
  176. txtPREVENTION.Text = "";
  177. }
  178. string sql5 = @"select ELOC
  179. from ICSTSERRORCODE2LOC
  180. where RCARD='" + txtRCARD.Text + "' and ECGCODE='" + fnode + "' and ECODE='" + snode + "' and WorkPoint='" + AppConfig.WorkPointCode + "'";
  181. sql5 = string.Format(sql5);
  182. DataTable data5 = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql5).Tables[0];
  183. if (data5.Rows.Count > 0)
  184. {
  185. foreach (DataRow dr5 in data5.Rows)
  186. {
  187. txtELOC.Text = dr5["ELOC"].ToString();
  188. }
  189. }
  190. else
  191. {
  192. txtELOC.Text = "";
  193. }
  194. }
  195. }
  196. }
  197. }
  198. #region 操作权限
  199. public DataTable RightOfExute()
  200. {
  201. DataTable rData = new DataTable();
  202. rData.Columns.Add("BtnName");
  203. rData.Columns.Add("ActionName");
  204. //查看权限(必须有)
  205. DataRow seeRow = rData.NewRow();
  206. seeRow["BtnName"] = "see";
  207. seeRow["ActionName"] = "查看";
  208. rData.Rows.Add(seeRow);
  209. List<Control> ControlList = new List<Control>();
  210. ControlList.Add(btnSave);
  211. //ControlList.Add(btnModify);
  212. //ControlList.Add(btnDel);
  213. //ControlList.Add(btnOutPut);
  214. foreach (Control ctr in ControlList)
  215. {
  216. if (ctr.GetType() == typeof(SimpleButton))
  217. {
  218. DataRow dr = rData.NewRow();
  219. dr["BtnName"] = ctr.Name;
  220. dr["ActionName"] = ctr.Text;
  221. rData.Rows.Add(dr);
  222. }
  223. }
  224. rData.AcceptChanges();
  225. return rData;
  226. }
  227. public DataTable RightOfData()// 数据权限
  228. {
  229. DataTable rData = new DataTable();
  230. rData.Columns.Add("BodyName");
  231. rData.Columns.Add("ControlName");
  232. rData.Columns.Add("ControlCaption");
  233. rData.AcceptChanges();
  234. return rData;
  235. }
  236. #endregion
  237. #region 退出
  238. private void btnClose_Click(object sender, EventArgs e)
  239. {
  240. AppConfig.CloseFormShow(this.Text);
  241. this.Close();
  242. }
  243. private void btnExit_Click(object sender, EventArgs e)
  244. {
  245. AppConfig.CloseFormShow(this.Text);
  246. this.Close();
  247. }
  248. #endregion
  249. #region 移动窗体
  250. private const int WM_NCHITTEST = 0x84;
  251. private const int HTCLIENT = 0x1;
  252. private const int HTCAPTION = 0x2;
  253. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  254. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  255. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  256. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  257. //重写窗体,使窗体可以不通过自带标题栏实现移动
  258. protected override void WndProc(ref Message m)
  259. {
  260. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  261. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  262. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  263. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  264. switch (m.Msg)
  265. {
  266. case WM_NCHITTEST:
  267. base.WndProc(ref m);
  268. if ((int)m.Result == HTCLIENT)
  269. m.Result = (IntPtr)HTCAPTION;
  270. return;
  271. }
  272. //拦截双击标题栏、移动窗体的系统消息
  273. if (m.Msg != 0xA3)
  274. {
  275. base.WndProc(ref m);
  276. }
  277. }
  278. #endregion
  279. #region 列表
  280. private void grvDetail_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
  281. {
  282. if (e.Info.IsRowIndicator && e.RowHandle >= 0)
  283. e.Info.DisplayText = (e.RowHandle + 1).ToString();
  284. }
  285. #endregion
  286. // #region 根据选择的不良代码组为不良代码赋值
  287. // private void txtECSCODE_SelectedValueChanged(object sender, EventArgs e)
  288. // {
  289. // string sql = @"select a.ECODE,b.ECDESC
  290. // from ICSTSERRORCODE a
  291. // left join ICSEC b on a.ECODE=b.ECODE
  292. // where a.RCARD='" + txtRCARD.Text + "' and a.ECGCODE='" + txtECGCODE.Text + "' and a.WorkPoint='" + AppConfig.WorkPointCode + "'";
  293. // sql = string.Format(sql);
  294. // DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  295. // txtECODE.Items.Clear();
  296. // foreach (DataRow dr in data.Rows)
  297. // {
  298. // txtECODE.Items.Add(dr[0].ToString());
  299. // }
  300. // }
  301. //#endregion
  302. #region 根据输入的产品序列号
  303. private void txtRCARD_KeyPress(object sender, KeyPressEventArgs e)
  304. {
  305. if (e.KeyChar == 13)
  306. {
  307. treeView1.Nodes.Clear();
  308. groupBox1.Visible = false;
  309. string rcard = "";
  310. rcard = txtRCARD.Text;
  311. bool include = ICSTSBLL.IsIncludingInICSTS(rcard);
  312. if (include)
  313. {
  314. ICSBaseSimpleCode.AppshowMessageBox("产品序列号不存在或状态不正确!");
  315. return;
  316. }
  317. string sql1 = @"select TSID,MODELCODE,ITEMCODE,MOCODE,SHIFTDAY,MOSEQ,RCARDSEQ
  318. from ICSTS
  319. where RCARD='" + txtRCARD.Text + "' and WorkPoint='" + AppConfig.WorkPointCode + "'";
  320. sql1 = string.Format(sql1);
  321. DataTable data1 = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql1).Tables[0];
  322. tsid = data1.Rows[0]["TSID"].ToString();
  323. TS = new FormICSTSUIModel();
  324. TS.MODELCODE = data1.Rows[0]["MODELCODE"].ToString();
  325. TS.ITEMCODE = data1.Rows[0]["ITEMCODE"].ToString();
  326. TS.MOCODE = data1.Rows[0]["MOCODE"].ToString();
  327. TS.SHIFTDAY = Convert.ToInt32(data1.Rows[0]["SHIFTDAY"].ToString());
  328. TS.MOSEQ = Convert.ToDecimal(data1.Rows[0]["MOSEQ"].ToString());
  329. TS.RCARDSEQ = Convert.ToInt32(data1.Rows[0]["RCARDSEQ"].ToString());
  330. InitDataTable();
  331. }
  332. }
  333. #endregion
  334. #region 不良组件按钮
  335. private void txtEPART_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  336. {
  337. ButtonEdit btn = (ButtonEdit)sender;
  338. string sql = @"select ID,PARTCODE as [组件编码],PARTNAME as [组件名称] from ICSPART";
  339. sql = string.Format(sql);
  340. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  341. FormDataRefer reForm = new FormDataRefer();
  342. reForm.FormTitle = "产品信息";
  343. DataTable menuData = data;
  344. reForm.DataSource = menuData;
  345. reForm.MSelectFlag = false;
  346. reForm.RowIndexWidth = 35;
  347. reForm.HideCols.Add("ID");
  348. reForm.FormWidth = 800;
  349. reForm.FormHeight = 600;
  350. //reForm.FilterKey = btn.Text;
  351. if (reForm.ShowDialog() == DialogResult.OK)
  352. {
  353. DataTable retData = reForm.ReturnData;
  354. foreach (DataRow dr in retData.Rows)
  355. {
  356. txtEPART.Text = dr["组件编码"].ToString();
  357. }
  358. }
  359. }
  360. #endregion
  361. #region 保存
  362. private void btnSave_Click(object sender, EventArgs e)
  363. {
  364. try
  365. {
  366. if (fnode == "" || snode=="")
  367. {
  368. ICSBaseSimpleCode.AppshowMessageBox("请选择不良代码!");
  369. return;
  370. }
  371. if (txtRCARD.Text.Trim() == "")
  372. {
  373. ICSBaseSimpleCode.AppshowMessageBox("请输入产品序列号!");
  374. return;
  375. }
  376. //if (txtECGCODE.Text.Trim() == "")
  377. //{
  378. // ICSBaseSimpleCode.AppshowMessageBox("请选择不良代码组!");
  379. // return;
  380. //}
  381. //if (txtECODE.Text.Trim() == "")
  382. //{
  383. // ICSBaseSimpleCode.AppshowMessageBox("请选择不良代码!");
  384. // return;
  385. //}
  386. if (txtEPART.Text.Trim() == "")
  387. {
  388. ICSBaseSimpleCode.AppshowMessageBox("请选择不良组件!");
  389. return;
  390. }
  391. if (txtECSCODE.Text.Trim() == "")
  392. {
  393. ICSBaseSimpleCode.AppshowMessageBox("请选择不良原因!");
  394. return;
  395. }
  396. if (txtECSGCODE.Text.Trim() == "")
  397. {
  398. ICSBaseSimpleCode.AppshowMessageBox("请选择不良原因组!");
  399. return;
  400. }
  401. if (txtDUTYCODE.Text.Trim() == "")
  402. {
  403. ICSBaseSimpleCode.AppshowMessageBox("请选择责任别!");
  404. return;
  405. }
  406. if (txtSOLCODE.Text.Trim() == "")
  407. {
  408. ICSBaseSimpleCode.AppshowMessageBox("请选择解决方案!");
  409. return;
  410. }
  411. if (txtELOC.Text.Trim() == "")
  412. {
  413. ICSBaseSimpleCode.AppshowMessageBox("请输入不良位置!");
  414. return;
  415. }
  416. FormICSTSERRORCAUSEUIModel errorcause = new FormICSTSERRORCAUSEUIModel();
  417. errorcause.ECODE = snode;
  418. errorcause.ECSCODE = ecscode;
  419. errorcause.ECGCODE = fnode;
  420. errorcause.ECSGCODE = ecsgcode;
  421. errorcause.TSID = tsid;
  422. errorcause.RCARD = txtRCARD.Text;
  423. errorcause.RCARDSEQ = TS.RCARDSEQ;
  424. errorcause.MODELCODE = TS.MODELCODE;
  425. errorcause.ITEMCODE = TS.ITEMCODE;
  426. errorcause.MOCODE = TS.MOCODE;
  427. errorcause.SHIFTDAY = TS.SHIFTDAY;
  428. errorcause.MOSEQ = Convert.ToInt32(TS.MOSEQ);
  429. errorcause.RRESCODE = "";
  430. errorcause.ROPCODE = "";
  431. errorcause.SOLCODE = solcode;
  432. errorcause.DUTYCODE = dutycode;
  433. errorcause.SOLMEMO = "";
  434. errorcause.PREVENTION = txtPREVENTION.Text;
  435. errorcause.MUSER = AppConfig.UserCode;
  436. errorcause.MUSERName = AppConfig.UserName;
  437. errorcause.MTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
  438. errorcause.WorkPoint = AppConfig.WorkPointCode;
  439. errorcause.EATTRIBUTE1 = "";
  440. FormICSTSERRORCODE2LOCUIModel erCode2loc = new FormICSTSERRORCODE2LOCUIModel();
  441. erCode2loc.ECODE = snode;
  442. erCode2loc.ECGCODE =fnode;
  443. erCode2loc.ELOC = txtELOC.Text;
  444. erCode2loc.AB = "";
  445. erCode2loc.TSID = tsid;
  446. erCode2loc.SUBELOC = "";
  447. erCode2loc.RCARD = txtRCARD.Text;
  448. erCode2loc.RCARDSEQ = TS.RCARDSEQ;
  449. erCode2loc.MODELCODE = TS.MODELCODE;
  450. erCode2loc.ITEMCODE = TS.ITEMCODE;
  451. erCode2loc.MOCODE = TS.MOCODE;
  452. erCode2loc.SHIFTDAY = TS.SHIFTDAY;
  453. erCode2loc.MOSEQ = Convert.ToInt32(TS.MOSEQ);
  454. erCode2loc.MEMO = "";
  455. erCode2loc.MUSER = AppConfig.UserCode;
  456. erCode2loc.MUSERName = AppConfig.UserName;
  457. erCode2loc.MTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
  458. erCode2loc.WorkPoint = AppConfig.WorkPointCode;
  459. erCode2loc.EATTRIBUTE1 = "";
  460. FormICSTSERRORCAUSE2LOCUIModel erCause2loc = new FormICSTSERRORCAUSE2LOCUIModel();
  461. erCause2loc.ECSCODE = ecscode;
  462. erCause2loc.ECGCODE = fnode;
  463. erCause2loc.ECODE = snode;
  464. erCause2loc.ELOC = txtELOC.Text;
  465. erCause2loc.AB = "";
  466. erCause2loc.TSID = tsid;
  467. erCause2loc.SUBELOC = "";
  468. erCause2loc.RCARD = txtRCARD.Text;
  469. erCause2loc.RCARDSEQ = TS.RCARDSEQ;
  470. erCause2loc.MODELCODE = TS.MODELCODE;
  471. erCause2loc.ITEMCODE = TS.ITEMCODE;
  472. erCause2loc.MOCODE = TS.MOCODE;
  473. erCause2loc.RRESCODE = "";
  474. erCause2loc.ROPCODE = "";
  475. erCause2loc.ECSGCODE = ecsgcode;
  476. erCause2loc.MOSEQ = TS.MOSEQ;
  477. erCause2loc.EPART = txtEPART.Text;
  478. erCause2loc.MUSER = AppConfig.UserCode;
  479. erCause2loc.MUSERName = AppConfig.UserName;
  480. erCause2loc.MTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
  481. erCause2loc.WorkPoint = AppConfig.WorkPointCode;
  482. erCause2loc.EATTRIBUTE1 = "";
  483. FormICSTSERRORCAUSE2EPARTUIModel erCause2epart = new FormICSTSERRORCAUSE2EPARTUIModel();
  484. erCause2epart.TSID = tsid;
  485. erCause2epart.ECODE = snode;
  486. erCause2epart.ECSCODE = ecscode;
  487. erCause2epart.ECGCODE = fnode;
  488. erCause2epart.EPART = txtEPART.Text;
  489. erCause2epart.RCARD = txtRCARD.Text;
  490. erCause2epart.RCARDSEQ = TS.RCARDSEQ;
  491. erCause2epart.MODELCODE = TS.MODELCODE;
  492. erCause2epart.ITEMCODE = TS.ITEMCODE;
  493. erCause2epart.MOCODE = TS.MOCODE;
  494. erCause2epart.ECSGCODE = ecsgcode;
  495. erCause2epart.MOSEQ = TS.MOSEQ;
  496. erCause2epart.RRESCODE = "";
  497. erCause2epart.ROPCODE = "";
  498. erCause2epart.MUSER = AppConfig.UserCode;
  499. erCause2epart.MUSERName = AppConfig.UserName;
  500. erCause2epart.MTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
  501. erCause2epart.WorkPoint = AppConfig.WorkPointCode;
  502. erCause2epart.EATTRIBUTE1 = "";
  503. ICSTSBLL.Add(errorcause, erCode2loc, erCause2loc, erCause2epart, AppConfig.AppConnectString);
  504. ICSBaseSimpleCode.AppshowMessageBox("保存成功");
  505. }
  506. catch (Exception ex)
  507. {
  508. MessageBox.Show(ex.Message);
  509. }
  510. }
  511. #endregion
  512. #region 不良原因按钮
  513. private void txtECSCODE_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  514. {
  515. ButtonEdit btn = (ButtonEdit)sender;
  516. string sql = @"select distinct a.RCARD as [产品序列号],b.ECSCODE as [不良原因代码],c.ECSDESC as [不良原因描述]
  517. from ICSTSERRORCODE a
  518. left join ICSMODEL2ECS b on a.MODELCODE=b.MODELCODE
  519. left join ICSECS c on b.ECSCODE=c.ECSCODE
  520. where a.RCARD='" + txtRCARD.Text + "' and a.WorkPoint='" + AppConfig.WorkPointCode + "'";
  521. sql = string.Format(sql);
  522. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  523. FormDataRefer reForm = new FormDataRefer();
  524. reForm.FormTitle = "不良原因";
  525. DataTable menuData = data;
  526. reForm.DataSource = menuData;
  527. reForm.MSelectFlag = false;
  528. reForm.RowIndexWidth = 35;
  529. reForm.HideCols.Add("产品序列号");
  530. reForm.FormWidth = 800;
  531. reForm.FormHeight = 600;
  532. //reForm.FilterKey = btn.Text;
  533. if (reForm.ShowDialog() == DialogResult.OK)
  534. {
  535. DataTable retData = reForm.ReturnData;
  536. foreach (DataRow dr in retData.Rows)
  537. {
  538. txtECSCODE.Text = dr["不良原因描述"].ToString();
  539. ecscode = dr["不良原因代码"].ToString();
  540. }
  541. }
  542. }
  543. #endregion
  544. #region 不良原因组按钮
  545. private void txtECSGCODE_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  546. {
  547. ButtonEdit btn = (ButtonEdit)sender;
  548. string sql = @"select a.ECSGCODE as [不良原因组代码],b.ECSGDESC as [不良原因组描述]
  549. from ICSECSG2ECS a
  550. left join ICSECSG b on a.ECSGCODE=b.ECSGCODE
  551. where a.ECSCODE='" + ecscode + "' and a.WorkPoint='" + AppConfig.WorkPointCode + "'";
  552. sql = string.Format(sql);
  553. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  554. FormDataRefer reForm = new FormDataRefer();
  555. reForm.FormTitle = "不良原因组";
  556. DataTable menuData = data;
  557. reForm.DataSource = menuData;
  558. reForm.MSelectFlag = false;
  559. reForm.RowIndexWidth = 35;
  560. reForm.HideCols.Add("ID");
  561. reForm.FormWidth = 800;
  562. reForm.FormHeight = 600;
  563. //reForm.FilterKey = btn.Text;
  564. if (reForm.ShowDialog() == DialogResult.OK)
  565. {
  566. DataTable retData = reForm.ReturnData;
  567. foreach (DataRow dr in retData.Rows)
  568. {
  569. txtECSGCODE.Text = dr["不良原因组描述"].ToString();
  570. ecsgcode = dr["不良原因组代码"].ToString();
  571. }
  572. }
  573. }
  574. #endregion
  575. #region 责任别按钮
  576. private void txtDUTYCODE_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  577. {
  578. ButtonEdit btn = (ButtonEdit)sender;
  579. string sql = @"select DUTYCODE as [责任别代码],DUTYDESC as [责任别描述]
  580. from ICSDUTY
  581. where WorkPoint='" + AppConfig.WorkPointCode + "'";
  582. sql = string.Format(sql);
  583. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  584. FormDataRefer reForm = new FormDataRefer();
  585. reForm.FormTitle = "责任别";
  586. DataTable menuData = data;
  587. reForm.DataSource = menuData;
  588. reForm.MSelectFlag = false;
  589. reForm.RowIndexWidth = 35;
  590. reForm.HideCols.Add("ID");
  591. reForm.FormWidth = 800;
  592. reForm.FormHeight = 600;
  593. //reForm.FilterKey = btn.Text;
  594. if (reForm.ShowDialog() == DialogResult.OK)
  595. {
  596. DataTable retData = reForm.ReturnData;
  597. foreach (DataRow dr in retData.Rows)
  598. {
  599. txtDUTYCODE.Text = dr["责任别描述"].ToString();
  600. dutycode = dr["责任别代码"].ToString();
  601. }
  602. }
  603. }
  604. #endregion
  605. #region 解决方案按钮
  606. private void txtSOLCODE_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  607. {
  608. ButtonEdit btn = (ButtonEdit)sender;
  609. string sql = @"select distinct a.MODELCODE as [产品别代码], b.SOLCODE as [解决方案代码],c.SOLDESC as [解决方案描述]
  610. from ICSTSERRORCODE a
  611. left join ICSMODEL2SOLUTION b on a.MODELCODE=b.MODELCODE
  612. left join ICSSOLUTION c on b.SOLCODE=c.SOLCODE
  613. where a.RCARD='" + txtRCARD.Text + "' and a.WorkPoint='" + AppConfig.WorkPointCode + "'";
  614. sql = string.Format(sql);
  615. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  616. FormDataRefer reForm = new FormDataRefer();
  617. reForm.FormTitle = "责任别";
  618. DataTable menuData = data;
  619. reForm.DataSource = menuData;
  620. reForm.MSelectFlag = false;
  621. reForm.RowIndexWidth = 35;
  622. reForm.HideCols.Add("产品别代码");
  623. reForm.FormWidth = 800;
  624. reForm.FormHeight = 600;
  625. //reForm.FilterKey = btn.Text;
  626. if (reForm.ShowDialog() == DialogResult.OK)
  627. {
  628. DataTable retData = reForm.ReturnData;
  629. foreach (DataRow dr in retData.Rows)
  630. {
  631. txtSOLCODE.Text = dr["解决方案描述"].ToString();
  632. solcode = dr["解决方案代码"].ToString();
  633. }
  634. }
  635. }
  636. #endregion
  637. #region 增加不良代码
  638. private void btnAddEcode_Click(object sender, EventArgs e)
  639. {
  640. if (txtRCARD.Text.Trim() == "" || (ICSTSBLL.IsIncludingInICSTS(txtRCARD.Text.Trim())))
  641. {
  642. ICSBaseSimpleCode.AppshowMessageBox("请先输入正确的产品序列号!");
  643. return;
  644. }
  645. groupBox1.Visible = false;
  646. treeView1.Nodes.Clear();
  647. SimpleButton btntemp = (SimpleButton)sender;
  648. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  649. {
  650. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  651. return;
  652. }
  653. FormICSTSECodeAdd add = new FormICSTSECodeAdd(txtRCARD.Text.Trim());
  654. add.ShowDialog();
  655. }
  656. #endregion
  657. //private void txtECODE_SelectedValueChanged(object sender, EventArgs e)
  658. //{
  659. //}
  660. }
  661. }