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

665 lines
24 KiB

5 months ago
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using DevExpress.XtraEditors;
  9. using ICSSoft.Base.Language.Tool;
  10. using ICSSoft.Base.UserControl.MessageControl;
  11. using System.Data.SqlClient;
  12. using ICSSoft.Base.Config.AppConfig;
  13. using ICSSoft.Base.Report.Filter;
  14. using ICSSoft.Base.Config.DBHelper;
  15. using ICSSoft.Base.UserControl.FormControl;
  16. using ICSSoft.Base.ReferForm.AppReferForm;
  17. using ICSSoft.Frame.Data.BLL;
  18. using ICSSoft.Frame.Data.Entity;
  19. namespace ICSSoft.Frame.APP
  20. {
  21. public partial class FormICSEQPDataInfoAdd : DevExpress.XtraEditors.XtraForm
  22. {
  23. private string sqltxt = "";
  24. private string sqlconn = "";
  25. String guid = AppConfig.GetGuid();
  26. private DataTable dataSource = null;
  27. #region 构造函数
  28. public FormICSEQPDataInfoAdd()
  29. {
  30. InitializeComponent();
  31. this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  32. this.WindowState = FormWindowState.Maximized;
  33. }
  34. #endregion
  35. #region 移动窗体
  36. private const int WM_NCHITTEST = 0x84;
  37. private const int HTCLIENT = 0x1;
  38. private const int HTCAPTION = 0x2;
  39. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  40. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  41. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  42. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  43. //重写窗体,使窗体可以不通过自带标题栏实现移动
  44. protected override void WndProc(ref Message m)
  45. {
  46. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  47. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  48. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  49. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  50. switch (m.Msg)
  51. {
  52. case WM_NCHITTEST:
  53. base.WndProc(ref m);
  54. if ((int)m.Result == HTCLIENT)
  55. m.Result = (IntPtr)HTCAPTION;
  56. return;
  57. }
  58. //拦截双击标题栏、移动窗体的系统消息
  59. if (m.Msg != 0xA3)
  60. {
  61. base.WndProc(ref m);
  62. }
  63. }
  64. #endregion
  65. #region SystemOptition
  66. /// <summary>
  67. /// 操作权限
  68. /// </summary>
  69. /// <returns></returns>
  70. public DataTable RightOfExute()
  71. {
  72. DataTable rData = new DataTable();
  73. rData.Columns.Add("BtnName");
  74. rData.Columns.Add("ActionName");
  75. //查看权限(必须有)
  76. DataRow seeRow = rData.NewRow();
  77. seeRow["BtnName"] = "see";
  78. seeRow["ActionName"] = "查看";
  79. rData.Rows.Add(seeRow);
  80. List<Control> ControlList = new List<Control>();
  81. //ControlList.Add(btnConfig);
  82. ControlList.Add(btnSave);
  83. //ControlList.Add(btnEdit);
  84. //ControlList.Add(btnDelLable);
  85. foreach (Control ctr in ControlList)
  86. {
  87. if (ctr.GetType() == typeof(SimpleButton))
  88. {
  89. DataRow dr = rData.NewRow();
  90. dr["BtnName"] = ctr.Name;
  91. dr["ActionName"] = ctr.Text;
  92. rData.Rows.Add(dr);
  93. }
  94. }
  95. rData.AcceptChanges();
  96. return rData;
  97. }
  98. /// <summary>
  99. /// 数据权限
  100. /// </summary>
  101. /// <returns></returns>
  102. public DataTable RightOfData()
  103. {
  104. DataTable rData = new DataTable();
  105. rData.Columns.Add("BodyName");
  106. rData.Columns.Add("ControlName");
  107. rData.Columns.Add("ControlCaption");
  108. rData.AcceptChanges();
  109. return rData;
  110. }
  111. #endregion
  112. #region 退出
  113. private void btnClose_Click(object sender, EventArgs e)
  114. {
  115. AppConfig.CloseFormShow(this.Text);
  116. this.Close();
  117. }
  118. private void btnExit_Click(object sender, EventArgs e)
  119. {
  120. AppConfig.CloseFormShow(this.Text);
  121. this.Close();
  122. }
  123. #endregion
  124. #region 分页
  125. private void rptPage_PageIndexChanged(object Sender, EventArgs e)
  126. {
  127. DataTable data = AppConfig.GetPageData(dataSource, rptPage.PageIndex, rptPage.PageSize).Copy();
  128. //DataTable data = AppConfig.GetPageDataByDb(tempTableName, "pagerowindex", rptPage.PageSize, rptPage.PageIndex, dataSource.Rows.Count);
  129. grdDetail.DataSource = data;
  130. }
  131. #endregion
  132. #region 全选
  133. private void btnSelect_Click(object sender, EventArgs e)
  134. {
  135. for (int i = 0; i < grvDetail.RowCount; i++)
  136. {
  137. grvDetail.SetRowCellValue(i, colisSelect, "Y");
  138. }
  139. }
  140. #endregion
  141. #region 全消
  142. private void btnCanSelect_Click(object sender, EventArgs e)
  143. {
  144. for (int i = 0; i < grvDetail.RowCount; i++)
  145. {
  146. grvDetail.SetRowCellValue(i, colisSelect, "");
  147. }
  148. }
  149. #endregion
  150. //#region 刷新
  151. //private void btnFalsh_Click(object sender, EventArgs e)
  152. //{
  153. // if (sqlconn == null || sqlconn == "")
  154. // {
  155. // return;
  156. // }
  157. // DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在查找...请稍等...");
  158. // try
  159. // {
  160. // _wait.Show();
  161. // FormFilter filter = new FormFilter(AppConfig.GetSourceId(this.Tag.ToString(), btnConfig.Name), false);
  162. // filter.OldTempTableName = tempTableName;
  163. // //tempTableName = filter.NewTempTableName;
  164. // //DataTable data = DBHelper.ExecuteDataset(AppConfig.FrameConnectString, CommandType.Text, "select * from " + tempTableName).Tables[0];
  165. // dataSource = DBHelper.ExecuteDataset(sqlconn, CommandType.Text, sqltxt).Tables[0];
  166. // grdDetail.DataSource = dataSource;
  167. // grvDetail.BestFitColumns();
  168. // rptPage.RecordNum = dataSource.Rows.Count;
  169. // rptPage.PageIndex = 1;
  170. // rptPage.ReLoad();
  171. // _wait.Close();
  172. // }
  173. // catch (Exception ex)
  174. // {
  175. // MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  176. // _wait.Close();
  177. // }
  178. //}
  179. //#endregion
  180. #region 列表
  181. private void grvDetail_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
  182. {
  183. if (e.Info.IsRowIndicator && e.RowHandle >= 0)
  184. e.Info.DisplayText = (e.RowHandle + 1).ToString();
  185. }
  186. #endregion
  187. #region 双击选择
  188. private void grvDetail_DoubleClick(object sender, EventArgs e)
  189. {
  190. if (grvDetail.FocusedRowHandle < 0)
  191. {
  192. return;
  193. }
  194. if (grvDetail.FocusedColumn == colisSelect)
  195. {
  196. if (grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colisSelect).ToString() == "")
  197. {
  198. grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colisSelect, "Y");
  199. }
  200. else
  201. {
  202. grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colisSelect, "");
  203. }
  204. }
  205. }
  206. #endregion
  207. //#region 删除
  208. //private void btnDel_Click(object sender, EventArgs e)
  209. //{
  210. // grvDetail.PostEditor();
  211. // this.Validate();
  212. // if (grvDetail.RowCount == 0)
  213. // return;
  214. // SimpleButton btntemp = (SimpleButton)sender;
  215. // if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  216. // {
  217. // ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  218. // }
  219. // List<string> guidList = new List<string>();
  220. // List<string> guidList1 = new List<string>();
  221. // for (int i = 0; i < grvDetail.RowCount; i++)
  222. // {
  223. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  224. // {
  225. // //guidList.Add(grvDetail.GetRowCellValue(i, colGUID).ToString());
  226. // }
  227. // }
  228. // if (guidList.Count == 0)
  229. // {
  230. // ICSBaseSimpleCode.AppshowMessageBox("请选择数据!");
  231. // return;
  232. // }
  233. // if (ICSBaseSimpleCode.AppshowMessageBoxRepose("确定删除该设备保养计划吗?删除后无法恢复,确定吗?") != DialogResult.OK)
  234. // return;
  235. // try
  236. // {
  237. // ICSEQPMaintainPlanBLL.delete(guidList);
  238. // ICSBaseSimpleCode.AppshowMessageBox(0, "删除成功");
  239. // }
  240. // catch (Exception ex)
  241. // {
  242. // ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  243. // }
  244. // btnFalsh_Click(null, null);
  245. //}
  246. //#endregion
  247. private void repositoryItemCheckEdit1_QueryCheckStateByValue(object sender, DevExpress.XtraEditors.Controls.QueryCheckStateByValueEventArgs e)
  248. {
  249. string val = "";
  250. if (e.Value != null)
  251. {
  252. val = e.Value.ToString();
  253. }
  254. else
  255. {
  256. val = "False";//默认为不选
  257. }
  258. switch (val)
  259. {
  260. case "True":
  261. e.CheckState = CheckState.Checked;
  262. break;
  263. case "False":
  264. e.CheckState = CheckState.Unchecked;
  265. break;
  266. //default:
  267. // e.CheckState = CheckState.Checked;
  268. // break;
  269. }
  270. e.Handled = true;
  271. }
  272. private void repositoryItemCheckEdit1_QueryValueByCheckState(object sender, DevExpress.XtraEditors.Controls.QueryValueByCheckStateEventArgs e)
  273. {
  274. //if (e.CheckState == CheckState.Checked)
  275. //{
  276. // grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colRESULT, 1);
  277. //}
  278. //else
  279. //{
  280. // grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colRESULT, 0);
  281. //}
  282. }
  283. #region 保存
  284. private void btnSave_Click(object sender, EventArgs e)
  285. {
  286. List<string> guidList = new List<string>();
  287. for (int i = 0; i < grvDetail.RowCount; i++)
  288. {
  289. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  290. {
  291. guidList.Add(grvDetail.GetRowCellValue(i, colEQPCode).ToString());
  292. }
  293. }
  294. if (guidList.Count == 0)
  295. {
  296. ICSBaseSimpleCode.AppshowMessageBox("请选择数据!");
  297. return;
  298. }
  299. for (int i = 0; i < grvDetail.RowCount; i++)
  300. {
  301. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  302. {
  303. FormICSEQPDataUIModel equipmentInfo = new FormICSEQPDataUIModel();
  304. equipmentInfo.GUID = AppConfig.GetGuid();
  305. equipmentInfo.EQPID = grvDetail.GetRowCellValue(i, colEQPID).ToString();
  306. equipmentInfo.EQPCode = grvDetail.GetRowCellValue(i, colEQPCode).ToString();
  307. equipmentInfo.CKGROUP = grvDetail.GetRowCellValue(i, colCKGROUP).ToString();
  308. equipmentInfo.CKItemCode = grvDetail.GetRowCellValue(i, colCKItemCode).ToString();
  309. equipmentInfo.SetValueMax = grvDetail.GetRowCellValue(i, colSetValueMax).ToString();
  310. equipmentInfo.SetValueMin = grvDetail.GetRowCellValue(i, colSetValueMin).ToString();
  311. equipmentInfo.RealValue = grvDetail.GetRowCellValue(i, colRealValue).ToString();
  312. equipmentInfo.UNIT = grvDetail.GetRowCellValue(i, colUNIT).ToString();
  313. equipmentInfo.MUSER = AppConfig.UserId;
  314. equipmentInfo.MUSERName = AppConfig.UserName;
  315. equipmentInfo.MTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
  316. equipmentInfo.WorkPoint = AppConfig.WorkPointCode;
  317. equipmentInfo.EATTRIBUTE1 = null;
  318. try
  319. {
  320. ICSEQPDataBLL.Add(equipmentInfo, AppConfig.AppConnectString);
  321. //this.Close();
  322. }
  323. catch (Exception ex)
  324. {
  325. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  326. }
  327. }
  328. }
  329. ICSBaseSimpleCode.AppshowMessageBox("操作成功");
  330. //btnFalsh_Click(null, null);
  331. }
  332. #endregion
  333. //private string getcheckeditvalue(object sender, EventArgs e)
  334. //{
  335. // //string result="";
  336. // //if (repositoryItemCheckEdit1.Equals("True"))
  337. // //{
  338. // // result = "OK";
  339. // //}
  340. // //if (repositoryItemCheckEdit1.Equals("False"))
  341. // //{
  342. // // result = "NG";
  343. // //}
  344. // //return result;
  345. //}
  346. //#region 绑定数据源
  347. //private void btnConfig_Click(object sender, EventArgs e)//绑定数据源
  348. //{
  349. // if (AppConfig.UserCode.ToLower() != "demo")
  350. // {
  351. // //ICSBaseSimpleCode.AppshowMessageBox("您没有权限设置数据源,请联系软件提供商!");
  352. // return;
  353. // }
  354. // FormDataSource fdata = new FormDataSource(AppConfig.GetMenuId(this.Tag.ToString()), btnConfig.Name);
  355. // fdata.ShowDialog();
  356. //}
  357. //#endregion
  358. // private void FormICSShift_Load(object sender, EventArgs e)
  359. // {
  360. // try
  361. // {
  362. // string sql = @"select '' as [isSelect],
  363. //
  364. //b.EQPID as EQPID,
  365. //b.EQPCode as EQPCode,
  366. //b.EQPName as EQPName,
  367. //c.CKGROUP as CKGROUP,
  368. //c.CKGROUPDESC as CKGROUPDESC,
  369. //d.CKITEMCODE as CKItemCode,
  370. //d.CKITEMDESC as CKItemName,
  371. //d.SetValueMax as SetValueMax,
  372. //d.SetValueMin as SetValueMin,
  373. //'' as RealValue,
  374. //d.UNIT as UNIT
  375. //
  376. //
  377. //from dbo.ICSEQPCHECKLIST a
  378. //left join dbo.ICSEquipment b on a.EQPCode=b.EQPCode
  379. //
  380. //left join dbo.ICSOQCCKGROUP c on a.CKGROUP=c.CKGROUP
  381. //left join dbo.ICSOQCCKGROUP2LIST e on c.CKGROUP=e.CKGROUP
  382. //left join dbo.ICSOQCCKLIST d on e.CKITEMCODE=d.CKITEMCODE
  383. //where 1=1
  384. //order by b.EQPCode asc";
  385. // DataTable ddf = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  386. // grdDetail.DataSource = ddf;
  387. // }
  388. // catch (Exception ex)
  389. // {
  390. // MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  391. // }
  392. // }
  393. //#region 修改
  394. //private void btnEdit_Click(object sender, EventArgs e)
  395. //{
  396. // SimpleButton btntemp = (SimpleButton)sender;
  397. // if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  398. // {
  399. // ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  400. // return;
  401. // }
  402. // int count = 0;
  403. // for (int i = 0; i < grvDetail.RowCount; i++)
  404. // {
  405. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  406. // {
  407. // count++;
  408. // }
  409. // }
  410. // if (count != 1)
  411. // {
  412. // ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  413. // return;
  414. // }
  415. // try
  416. // {
  417. // string id;
  418. // for (int i = 0; i < grvDetail.RowCount; i++)
  419. // {
  420. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  421. // {
  422. // //id = grvDetail.GetRowCellValue(i, colGUID).ToString();
  423. // //FormICSEQPMaintainPlanAdd add = new FormICSEQPMaintainPlanAdd(id);
  424. // //add.ShowDialog();
  425. // }
  426. // }
  427. // btnFalsh_Click(null, null);
  428. // }
  429. // catch (Exception ex)
  430. // {
  431. // //throw ex;
  432. // ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  433. // }
  434. //}
  435. //#endregion
  436. private void btnOutPut_Click(object sender, EventArgs e)
  437. {
  438. FormOutExcel foe = new FormOutExcel(this.Tag.ToString(), grdDetail);
  439. foe.ShowDialog();
  440. }
  441. private void grvDetail_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
  442. {
  443. if (e.RowHandle >= 0 && e.Column.FieldName == "SHIFTBTIME")
  444. {
  445. e.DisplayText = ICSSoft.Frame.Helper.FormatHelper.ToTimeString(int.Parse(e.CellValue.ToString()));
  446. }
  447. if (e.RowHandle >= 0 && e.Column.FieldName == "SHIFTETIME")
  448. {
  449. e.DisplayText = ICSSoft.Frame.Helper.FormatHelper.ToTimeString(int.Parse(e.CellValue.ToString()));
  450. }
  451. }
  452. #region 测试项目按钮
  453. private void repositoryItemButtonEdit1_BottonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  454. {
  455. ButtonEdit btn = (ButtonEdit)sender;
  456. string sql = "select 'OK' as 保养结果 union all select 'NG' as 保养结果 WHERE 1=1";
  457. //object obj = AppConfig.InvokeWebservice(AppConfig.BaseServiceUri, "WebBaseService", "BaseService", "GetHuaRongErpConnectString", new object[] { });
  458. //if (obj == null)
  459. //{
  460. // ICSBaseSimpleCode.AppshowMessageBox(1, "ERP数据库连接取得失败!");
  461. //}
  462. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  463. FormDataRefer reForm = new FormDataRefer();
  464. reForm.FormTitle = "保养结果";
  465. DataTable menuData = data;
  466. reForm.DataSource = menuData;
  467. reForm.MSelectFlag = false;
  468. reForm.RowIndexWidth = 35;
  469. reForm.HideCols.Add("ID");
  470. reForm.FormWidth = 500;
  471. reForm.FormHeight = 500;
  472. //reForm.FilterKey = btn.Text;
  473. //grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, grvDetail.FocusedColumn).ToString().Trim();
  474. if (reForm.ShowDialog() == DialogResult.OK)
  475. {
  476. DataTable retData = reForm.ReturnData;
  477. foreach (DataRow dr in retData.Rows)
  478. {
  479. if (grvDetail.FocusedColumn == colCKGROUPDESC)
  480. {
  481. grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colCKGROUPDESC, dr["保养结果"].ToString());
  482. }
  483. }
  484. }
  485. }
  486. #endregion
  487. #region 设备编号按钮
  488. private void txtEQPCode_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  489. {
  490. ButtonEdit btn = (ButtonEdit)sender;
  491. string sql = "select distinct EQPID as [设备ID],EQPCode as [设备编号],EQPName as [设备名称] from dbo.ICSEquipment with(nolock) WHERE 1=1";
  492. //object obj = AppConfig.InvokeWebservice(AppConfig.BaseServiceUri, "WebBaseService", "BaseService", "GetHuaRongErpConnectString", new object[] { });
  493. //if (obj == null)
  494. //{
  495. // ICSBaseSimpleCode.AppshowMessageBox(1, "ERP数据库连接取得失败!");
  496. //}
  497. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  498. FormDataRefer reForm = new FormDataRefer();
  499. reForm.FormTitle = "设备信息";
  500. DataTable menuData = data;
  501. reForm.DataSource = menuData;
  502. reForm.MSelectFlag = false;
  503. reForm.RowIndexWidth = 35;
  504. reForm.HideCols.Add("设备ID");
  505. reForm.FormWidth = 500;
  506. reForm.FormHeight = 500;
  507. //reForm.FilterKey = btn.Text;
  508. //grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, grvDetail.FocusedColumn).ToString().Trim();
  509. if (reForm.ShowDialog() == DialogResult.OK)
  510. {
  511. DataTable retData = reForm.ReturnData;
  512. foreach (DataRow dr in retData.Rows)
  513. {
  514. txtEQPCode.Text = dr["设备编号"].ToString();
  515. }
  516. }
  517. }
  518. #endregion
  519. #region 检验项目组按钮
  520. private void txtCKGROUP_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  521. {
  522. ButtonEdit btn = (ButtonEdit)sender;
  523. string sql = @"select distinct a.CKGROUP as [检验项目组],a.CKGROUPDESC as [检验项目组描述]
  524. from dbo.ICSOQCCKGROUP a
  525. left join dbo.ICSEQPCHECKLIST b on a.CKGROUP=b.CKGROUP
  526. WHERE b.EQPCode='" + txtEQPCode.Text + "' and 1=1";
  527. //object obj = AppConfig.InvokeWebservice(AppConfig.BaseServiceUri, "WebBaseService", "BaseService", "GetHuaRongErpConnectString", new object[] { });
  528. //if (obj == null)
  529. //{
  530. // ICSBaseSimpleCode.AppshowMessageBox(1, "ERP数据库连接取得失败!");
  531. //}
  532. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  533. FormDataRefer reForm = new FormDataRefer();
  534. reForm.FormTitle = "检验项目组信息";
  535. DataTable menuData = data;
  536. reForm.DataSource = menuData;
  537. reForm.MSelectFlag = false;
  538. reForm.RowIndexWidth = 35;
  539. reForm.HideCols.Add("设备ID");
  540. reForm.FormWidth = 500;
  541. reForm.FormHeight = 500;
  542. //reForm.FilterKey = btn.Text;
  543. //grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, grvDetail.FocusedColumn).ToString().Trim();
  544. if (reForm.ShowDialog() == DialogResult.OK)
  545. {
  546. DataTable retData = reForm.ReturnData;
  547. foreach (DataRow dr in retData.Rows)
  548. {
  549. txtCKGROUP.Text = dr["检验项目组"].ToString();
  550. }
  551. }
  552. searchinfo(txtEQPCode.Text, txtCKGROUP.Text);
  553. }
  554. #endregion
  555. private void searchinfo(string eqpcode, string ckgroup)
  556. {
  557. try
  558. {
  559. string sql = @"select '' as [isSelect],
  560. b.EQPID as EQPID,
  561. b.EQPCode as EQPCode,
  562. b.EQPName as EQPName,
  563. c.CKGROUP as CKGROUP,
  564. c.CKGROUPDESC as CKGROUPDESC,
  565. d.CKITEMCODE as CKItemCode,
  566. d.CKITEMDESC as CKItemName,
  567. d.SetValueMax as SetValueMax,
  568. d.SetValueMin as SetValueMin,
  569. '' as RealValue,
  570. d.UNIT as UNIT
  571. from dbo.ICSEQPCHECKLIST a
  572. left join dbo.ICSEquipment b on a.EQPCode=b.EQPCode
  573. left join dbo.ICSOQCCKGROUP c on a.CKGROUP=c.CKGROUP
  574. left join dbo.ICSOQCCKGROUP2LIST e on c.CKGROUP=e.CKGROUP
  575. left join dbo.ICSOQCCKLIST d on e.CKITEMCODE=d.CKITEMCODE
  576. where b.EQPCode='" + eqpcode + "' and c.CKGROUP='" + ckgroup + "' and 1=1";
  577. DataTable ddf = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  578. grdDetail.DataSource = ddf;
  579. }
  580. catch (Exception ex)
  581. {
  582. MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  583. }
  584. }
  585. }
  586. }