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

845 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.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using DevExpress.XtraEditors;
  9. using ICSSoft.Frame.User.BLL;
  10. using ICSSoft.Base.Language.Tool;
  11. using ICSSoft.Base.UserControl.MessageControl;
  12. using System.Data.SqlClient;
  13. using ICSSoft.Base.Config.AppConfig;
  14. using ICSSoft.Base.Report.Filter;
  15. using ICSSoft.Base.Config.DBHelper;
  16. using ICSSoft.Base.UserControl.FormControl;
  17. using ICSSoft.Base.ReferForm.AppReferForm;
  18. using ICSSoft.Base.Lable.PrintTool;
  19. using ICSSoft.Frame.Data.DAL;
  20. using ICSSoft.Frame.Data.BLL;
  21. using ICSSoft.Frame.Data.Entity;
  22. namespace ICSSoft.Frame.APP
  23. {
  24. public partial class FormICSNCTP : DevExpress.XtraEditors.XtraForm
  25. {
  26. private string sqltxt = "";
  27. private string sqlconn = "";
  28. String guid = AppConfig.GetGuid();
  29. private DataTable dataSource = null;
  30. //WorkPointBLL workBll = new WorkPointBLL();
  31. #region 构造函数
  32. public FormICSNCTP()
  33. {
  34. InitializeComponent();
  35. this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  36. this.WindowState = FormWindowState.Maximized;
  37. }
  38. #endregion
  39. #region 移动窗体
  40. private const int WM_NCHITTEST = 0x84;
  41. private const int HTCLIENT = 0x1;
  42. private const int HTCAPTION = 0x2;
  43. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  44. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  45. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  46. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  47. //重写窗体,使窗体可以不通过自带标题栏实现移动
  48. protected override void WndProc(ref Message m)
  49. {
  50. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  51. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  52. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  53. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  54. switch (m.Msg)
  55. {
  56. case WM_NCHITTEST:
  57. base.WndProc(ref m);
  58. if ((int)m.Result == HTCLIENT)
  59. m.Result = (IntPtr)HTCAPTION;
  60. return;
  61. }
  62. //拦截双击标题栏、移动窗体的系统消息
  63. if (m.Msg != 0xA3)
  64. {
  65. base.WndProc(ref m);
  66. }
  67. }
  68. #endregion
  69. #region SystemOptition
  70. /// <summary>
  71. /// 操作权限
  72. /// </summary>
  73. /// <returns></returns>
  74. public DataTable RightOfExute()
  75. {
  76. DataTable rData = new DataTable();
  77. rData.Columns.Add("BtnName");
  78. rData.Columns.Add("ActionName");
  79. //查看权限(必须有)
  80. DataRow seeRow = rData.NewRow();
  81. seeRow["BtnName"] = "see";
  82. seeRow["ActionName"] = "查看";
  83. rData.Rows.Add(seeRow);
  84. foreach (Control ctr in panelControl3.Controls)
  85. {
  86. if (ctr.Name == btnFilter.Name || ctr.Name == btnConfig.Name ||
  87. ctr.Name == btnSelect.Name || ctr.Name == btnCanSelect.Name ||
  88. ctr.Name == btnImportMould.Name || ctr.Name == btnOutPut.Name ||
  89. ctr.Name == btnFalsh.Name || ctr.Name == btnExit.Name || ctr.Name == lblTitle.Name || ctr.Name == btnClose.Name)
  90. continue;
  91. DataRow dr = rData.NewRow();
  92. dr["BtnName"] = ctr.Name;
  93. dr["ActionName"] = ctr.Text;
  94. rData.Rows.Add(dr);
  95. }
  96. //List<Control> ControlList = new List<Control>();
  97. //ControlList.Add(btnConfig);
  98. //ControlList.Add(btnAdd);
  99. //ControlList.Add(btnEdit);
  100. //ControlList.Add(btnDelLable);
  101. //foreach (Control ctr in ControlList)
  102. //{
  103. // if (ctr.GetType() == typeof(SimpleButton))
  104. // {
  105. // DataRow dr = rData.NewRow();
  106. // dr["BtnName"] = ctr.Name;
  107. // dr["ActionName"] = ctr.Text;
  108. // rData.Rows.Add(dr);
  109. // }
  110. //}
  111. rData.AcceptChanges();
  112. return rData;
  113. }
  114. /// <summary>
  115. /// 数据权限
  116. /// </summary>
  117. /// <returns></returns>
  118. public DataTable RightOfData()
  119. {
  120. DataTable rData = new DataTable();
  121. rData.Columns.Add("BodyName");
  122. rData.Columns.Add("ControlName");
  123. rData.Columns.Add("ControlCaption");
  124. rData.AcceptChanges();
  125. return rData;
  126. }
  127. #endregion
  128. #region 退出
  129. private void btnClose_Click(object sender, EventArgs e)
  130. {
  131. AppConfig.CloseFormShow(this.Text);
  132. this.Close();
  133. }
  134. private void btnExit_Click(object sender, EventArgs e)
  135. {
  136. AppConfig.CloseFormShow(this.Text);
  137. this.Close();
  138. }
  139. #endregion
  140. #region 过滤
  141. private string tempTableName = "";
  142. private void btnFilter_Click(object sender, EventArgs e)
  143. {
  144. FormFilter filter = new FormFilter(AppConfig.GetSourceId(this.Tag.ToString(), btnConfig.Name));
  145. filter.OldTempTableName = tempTableName;
  146. if (filter.ShowDialog() == DialogResult.OK)
  147. {
  148. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在查找...请稍等...");
  149. try
  150. {
  151. _wait.Show();
  152. tempTableName = filter.NewTempTableName;
  153. sqltxt = filter.SqlText;
  154. sqlconn = filter.FilterConnectString;
  155. dataSource = filter.FilterData.Tables[0];
  156. grdDetail.DataSource = dataSource;
  157. grvDetail.BestFitColumns();
  158. rptPage.RecordNum = dataSource.Rows.Count;
  159. rptPage.PageSize = 500;
  160. rptPage.PageIndex = 1;
  161. rptPage.ReLoad();
  162. _wait.Close();
  163. }
  164. catch (Exception ex)
  165. {
  166. MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  167. _wait.Close();
  168. }
  169. }
  170. }
  171. #endregion
  172. #region 全选
  173. private void btnSelect_Click(object sender, EventArgs e)
  174. {
  175. for (int i = 0; i < grvDetail.RowCount; i++)
  176. {
  177. grvDetail.SetRowCellValue(i, colisSelect, "Y");
  178. }
  179. }
  180. #endregion
  181. #region 全消
  182. private void btnCanSelect_Click(object sender, EventArgs e)
  183. {
  184. for (int i = 0; i < grvDetail.RowCount; i++)
  185. {
  186. grvDetail.SetRowCellValue(i, colisSelect, "");
  187. }
  188. }
  189. #endregion
  190. #region 刷新
  191. private void btnFalsh_Click(object sender, EventArgs e)
  192. {
  193. if (sqlconn == null || sqlconn == "")
  194. {
  195. return;
  196. }
  197. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在查找...请稍等...");
  198. try
  199. {
  200. _wait.Show();
  201. FormFilter filter = new FormFilter(AppConfig.GetSourceId(this.Tag.ToString(), btnConfig.Name), false);
  202. filter.OldTempTableName = tempTableName;
  203. //tempTableName = filter.NewTempTableName;
  204. //DataTable data = DBHelper.ExecuteDataset(AppConfig.FrameConnectString, CommandType.Text, "select * from " + tempTableName).Tables[0];
  205. dataSource = DBHelper.ExecuteDataset(sqlconn, CommandType.Text, sqltxt).Tables[0];
  206. grdDetail.DataSource = dataSource;
  207. rptPage.RecordNum = dataSource.Rows.Count;
  208. rptPage.PageIndex = 1;
  209. rptPage.ReLoad();
  210. _wait.Close();
  211. }
  212. catch (Exception ex)
  213. {
  214. MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  215. _wait.Close();
  216. }
  217. }
  218. #endregion
  219. #region 列表
  220. private void grvDetail_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
  221. {
  222. if (e.Info.IsRowIndicator && e.RowHandle >= 0)
  223. e.Info.DisplayText = (e.RowHandle + 1).ToString();
  224. }
  225. #endregion
  226. #region 双击选择
  227. private void grvDetail_DoubleClick(object sender, EventArgs e)
  228. {
  229. if (grvDetail.FocusedRowHandle < 0)
  230. {
  231. return;
  232. }
  233. if (grvDetail.FocusedColumn == colisSelect)
  234. {
  235. if (grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colisSelect).ToString() == "")
  236. {
  237. grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colisSelect, "Y");
  238. }
  239. else
  240. {
  241. grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colisSelect, "");
  242. }
  243. }
  244. }
  245. #endregion
  246. #region 绑定数据源
  247. private void btnConfig_Click(object sender, EventArgs e)//绑定数据源
  248. {
  249. if (AppConfig.UserCode.ToLower() != "demo")
  250. {
  251. //ICSBaseSimpleCode.AppshowMessageBox("您没有权限设置数据源,请联系软件提供商!");
  252. return;
  253. }
  254. FormDataSource fdata = new FormDataSource(AppConfig.GetMenuId(this.Tag.ToString()), btnConfig.Name);
  255. fdata.ShowDialog();
  256. }
  257. #endregion
  258. #region 分页
  259. private void rptPage_PageIndexChanged(object Sender, EventArgs e)
  260. {
  261. DataTable data = AppConfig.GetPageData(dataSource, rptPage.PageIndex, rptPage.PageSize).Copy();
  262. //DataTable data = AppConfig.GetPageDataByDb(tempTableName, "pagerowindex", rptPage.PageSize, rptPage.PageIndex, dataSource.Rows.Count);
  263. grdDetail.DataSource = data;
  264. }
  265. #endregion
  266. #region 加载
  267. private void FormICSFACTORY_Load(object sender, EventArgs e)
  268. {
  269. btnFilter_Click(sender, e);
  270. }
  271. #endregion
  272. #region 增加
  273. private void btnAdd_Click(object sender, EventArgs e)
  274. {
  275. SimpleButton btntemp = (SimpleButton)sender;
  276. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  277. {
  278. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  279. return;
  280. }
  281. FormICSNCTPAdd add = new FormICSNCTPAdd();
  282. add.ShowDialog();
  283. btnFalsh_Click(null, null);
  284. }
  285. #endregion
  286. #region 修改
  287. private void btnEdit_Click(object sender, EventArgs e)
  288. {
  289. SimpleButton btntemp = (SimpleButton)sender;
  290. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  291. {
  292. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  293. return;
  294. }
  295. int count = 0;
  296. for (int i = 0; i < grvDetail.RowCount; i++)
  297. {
  298. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  299. {
  300. count++;
  301. }
  302. }
  303. if (count != 1)
  304. {
  305. ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  306. return;
  307. }
  308. try
  309. {
  310. string id;
  311. string status;
  312. for (int i = 0; i < grvDetail.RowCount; i++)
  313. {
  314. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  315. {
  316. id = grvDetail.GetRowCellValue(i, colID).ToString();
  317. status = grvDetail.GetRowCellValue(i, colStatus).ToString();
  318. if (status == "已审核")
  319. {
  320. ICSBaseSimpleCode.AppshowMessageBox("该条数据已审核不可修改!!!");
  321. return;
  322. }
  323. FormICSNCTPAdd add = new FormICSNCTPAdd(id);
  324. add.ShowDialog();
  325. }
  326. }
  327. btnFalsh_Click(null, null);
  328. }
  329. catch (Exception ex)
  330. {
  331. //throw ex;
  332. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  333. }
  334. }
  335. #endregion
  336. #region 删除
  337. private void btnDel_Click(object sender, EventArgs e)
  338. {
  339. SimpleButton btntemp = (SimpleButton)sender;
  340. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  341. {
  342. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  343. return;
  344. }
  345. List<string> routecodeList = new List<string>();
  346. for (int i = 0; i < grvDetail.RowCount; i++)
  347. {
  348. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  349. {
  350. routecodeList.Add(grvDetail.GetRowCellValue(i, colID).ToString());
  351. }
  352. }
  353. if (routecodeList.Count == 0 || routecodeList == null)
  354. {
  355. ICSBaseSimpleCode.AppshowMessageBox("请选择数据");
  356. return;
  357. }
  358. if (ICSBaseSimpleCode.AppshowMessageBoxRepose("确定删除吗?删除后无法恢复,确定吗?") != DialogResult.OK)
  359. {
  360. btnCanSelect_Click(sender, e);
  361. return;
  362. }
  363. ICSNCTPBLL.deleteInfo(routecodeList, AppConfig.AppConnectString);
  364. ICSBaseSimpleCode.AppshowMessageBox("删除成功");
  365. btnFalsh_Click(null, null);
  366. }
  367. #endregion
  368. #region 导出
  369. private void btnOutPut_Click(object sender, EventArgs e)
  370. {
  371. try
  372. {
  373. FormOutExcel foe = new FormOutExcel(this.Tag.ToString(), grdDetail);
  374. foe.ShowDialog();
  375. }
  376. catch (Exception ex)
  377. {
  378. MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  379. }
  380. // FormOutExcel foe = new FormOutExcel();
  381. // if (foe.ShowDialog() == DialogResult.OK)
  382. // {
  383. // try
  384. // {
  385. // string outtype = foe._OutType;
  386. // string exceltype = foe._ExcelType;
  387. // string filename = foe._FileName;
  388. // string url = foe._Url;
  389. // string sheetname = foe._SheetName;
  390. // if (outtype.ToLower() == "excel")
  391. // {
  392. // DevExpress.XtraPrinting.XlsExportOptions op = new DevExpress.XtraPrinting.XlsExportOptions();
  393. // op.SheetName = sheetname;
  394. // grdDetail.MainView.ExportToXls((url + "\\" + filename + (exceltype == "2003" ? ".xls" : ".xlsx")), op);
  395. // }
  396. // else
  397. // {
  398. // grdDetail.MainView.ExportToPdf(url + "\\" + filename + ".pdf");
  399. // }
  400. // MessageBox.Show("导出成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  401. // }
  402. // catch (Exception ex)
  403. // {
  404. // MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  405. // }
  406. //}
  407. }
  408. #endregion
  409. #region 导入
  410. private void btnImportData_Click(object sender, EventArgs e)
  411. {
  412. SimpleButton btntemp = (SimpleButton)sender;
  413. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  414. {
  415. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  416. return;
  417. }
  418. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm();
  419. _wait.Hide();
  420. try
  421. {
  422. FormReadExcel fre = new FormReadExcel();
  423. if (fre.ShowDialog() != DialogResult.OK)
  424. {
  425. return;
  426. }
  427. DataTable dataSource = fre._excelData;
  428. if (dataSource == null)
  429. {
  430. throw new Exception("excel数据取得失败");
  431. }
  432. _wait.Show();
  433. _wait.Caption = "判断模版是否正确......";
  434. #region 判断模版是否正确
  435. List<FormReadExcelUIModelColumns> colNameList = new List<FormReadExcelUIModelColumns>();
  436. colNameList.Add(new FormReadExcelUIModelColumns("生产时间", true));
  437. colNameList.Add(new FormReadExcelUIModelColumns("生产订单号", true));
  438. colNameList.Add(new FormReadExcelUIModelColumns("产品编号", true));
  439. colNameList.Add(new FormReadExcelUIModelColumns("存货名称", true));
  440. colNameList.Add(new FormReadExcelUIModelColumns("项目号", false));
  441. colNameList.Add(new FormReadExcelUIModelColumns("加工工序", true));
  442. colNameList.Add(new FormReadExcelUIModelColumns("加工数量", true));
  443. colNameList.Add(new FormReadExcelUIModelColumns("设备编号", true));
  444. colNameList.Add(new FormReadExcelUIModelColumns("设备名称", true));
  445. colNameList.Add(new FormReadExcelUIModelColumns("单位工时", true));
  446. colNameList.Add(new FormReadExcelUIModelColumns("加工工时", true));
  447. colNameList.Add(new FormReadExcelUIModelColumns("加工人员", true));
  448. colNameList.Add(new FormReadExcelUIModelColumns("加工工序", true));
  449. colNameList.Add(new FormReadExcelUIModelColumns("加工数量", true));
  450. foreach (FormReadExcelUIModelColumns columnsName in colNameList)
  451. {
  452. if (!dataSource.Columns.Contains(columnsName.columnsName))
  453. {
  454. throw new Exception("模版不正确,缺少列" + columnsName.columnsName);
  455. }
  456. }
  457. #endregion
  458. _wait.Caption = "数据整理中......";
  459. List<ICSNCTP> InitInvInfoList = new List<ICSNCTP>();
  460. foreach (DataRow dr in dataSource.Rows)
  461. {
  462. ///判断必输项目是否为空
  463. foreach (FormReadExcelUIModelColumns columnsName in colNameList)
  464. {
  465. if (string.IsNullOrWhiteSpace(dr[columnsName.columnsName].ToString()) == true && columnsName.NotNull == true)
  466. {
  467. throw new Exception("列" + columnsName.columnsName + "没有输入值");
  468. }
  469. }
  470. ICSNCTP Info = new ICSNCTP();
  471. Info.guid = "";
  472. DateTime s;
  473. if (!DateTime.TryParse(dr["生产时间"].ToString(), out s))
  474. {
  475. ICSBaseSimpleCode.AppshowMessageBox("生产时间格式不正确!");
  476. return;
  477. }
  478. else
  479. {
  480. Info.ProductDate = DateTime.Parse(dr["生产时间"].ToString());
  481. }
  482. Info.ProductMO = dr["生产订单号"].ToString();
  483. Info.ItemCode = dr["产品编号"].ToString();
  484. Info.ItemName = dr["存货名称"].ToString();
  485. Info.ProjectCode = dr["项目号"].ToString();
  486. Info.OPCode = dr["加工工序"].ToString();
  487. decimal count;
  488. if (!decimal.TryParse(dr["加工数量"].ToString(), out count))
  489. {
  490. ICSBaseSimpleCode.AppshowMessageBox("加工数量格式不正确!");
  491. return;
  492. }
  493. else
  494. {
  495. Info.ProductNum = decimal.Parse(dr["加工数量"].ToString());
  496. }
  497. Info.EQPCode = dr["设备编号"].ToString();
  498. Info.EQPName = dr["设备名称"].ToString();
  499. if (!decimal.TryParse(dr["单位工时"].ToString(), out count))
  500. {
  501. ICSBaseSimpleCode.AppshowMessageBox("单位工时格式不正确!");
  502. return;
  503. }
  504. else
  505. {
  506. Info.UnitTP = decimal.Parse(dr["单位工时"].ToString());
  507. }
  508. if (!decimal.TryParse(dr["加工工时"].ToString(), out count))
  509. {
  510. ICSBaseSimpleCode.AppshowMessageBox("加工工时格式不正确!");
  511. return;
  512. }
  513. else
  514. {
  515. Info.TotalTP = decimal.Parse(dr["加工工时"].ToString());
  516. }
  517. Info.ProductUser = dr["加工人员"].ToString();
  518. Info.MUSER = AppConfig.UserId;
  519. Info.MUSERName = AppConfig.UserName;
  520. Info.MTIME = DateTime.Now;
  521. Info.WorkPoint = AppConfig.WorkPointCode;
  522. Info.EATTRIBUTE1 = "";
  523. InitInvInfoList.Add(Info);
  524. }
  525. _wait.Caption = "导入数据......";
  526. string str = ICSNCTPBLL.AddList(InitInvInfoList, AppConfig.AppConnectString);
  527. _wait.Close();
  528. if (str == "")
  529. {
  530. ICSBaseSimpleCode.AppshowMessageBox("数据导入成功!");
  531. }
  532. else
  533. {
  534. ICSBaseSimpleCode.AppshowMessageBox(str);
  535. }
  536. btnFalsh_Click(null, null);
  537. }
  538. catch (Exception ex)
  539. {
  540. _wait.Close();
  541. ICSBaseSimpleCode.AppshowMessageBox("数据导入失败:" + ex.Message);
  542. }
  543. }
  544. #endregion
  545. #region 导入模板下载
  546. private void btnImportMould_Click(object sender, EventArgs e)
  547. {
  548. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm();
  549. _wait.Hide();
  550. string anjianExcelFileName = Environment.CommandLine.Substring(1, Environment.CommandLine.LastIndexOf("\\")) + "Output\\";
  551. try
  552. {
  553. _wait.Show();
  554. _wait.Caption = "模板下载中......";
  555. SaveFileDialog dlgSaveFileDialog = new SaveFileDialog(); //弹框提示保存
  556. dlgSaveFileDialog.InitialDirectory = anjianExcelFileName; //默认打开目录
  557. dlgSaveFileDialog.FilterIndex = 1;
  558. dlgSaveFileDialog.RestoreDirectory = true;
  559. dlgSaveFileDialog.FileName = "加工工时导入模板.xlsx"; //默认保存名称
  560. dlgSaveFileDialog.Filter = "Excel文件(*.xlsx)|*.xlsx";
  561. if (dlgSaveFileDialog.ShowDialog() == DialogResult.OK)
  562. {
  563. string fileName = dlgSaveFileDialog.FileName; //获取弹出框选择或填写的文件名称
  564. List<FormReadExcelUIModelColumns> colNameList = new List<FormReadExcelUIModelColumns>();
  565. colNameList.Add(new FormReadExcelUIModelColumns("生产时间", true));
  566. colNameList.Add(new FormReadExcelUIModelColumns("生产订单号", true));
  567. colNameList.Add(new FormReadExcelUIModelColumns("产品编号", true));
  568. colNameList.Add(new FormReadExcelUIModelColumns("存货名称", true));
  569. colNameList.Add(new FormReadExcelUIModelColumns("项目号", false));
  570. colNameList.Add(new FormReadExcelUIModelColumns("加工工序", true));
  571. colNameList.Add(new FormReadExcelUIModelColumns("加工数量", true));
  572. colNameList.Add(new FormReadExcelUIModelColumns("设备编号", true));
  573. colNameList.Add(new FormReadExcelUIModelColumns("设备名称", true));
  574. colNameList.Add(new FormReadExcelUIModelColumns("单位工时", true));
  575. colNameList.Add(new FormReadExcelUIModelColumns("加工工时", true));
  576. colNameList.Add(new FormReadExcelUIModelColumns("加工人员", true));
  577. colNameList.Add(new FormReadExcelUIModelColumns("加工工序", true));
  578. colNameList.Add(new FormReadExcelUIModelColumns("加工数量", true));
  579. FileUtil.exportToExcelFile(fileName, colNameList);
  580. _wait.Close();
  581. ICSBaseSimpleCode.AppshowMessageBox("模板下载成功!");
  582. }
  583. _wait.Close();
  584. }
  585. catch (Exception ex)
  586. {
  587. _wait.Close();
  588. ICSBaseSimpleCode.AppshowMessageBox("模板下载失败:" + ex.Message);
  589. }
  590. }
  591. #endregion
  592. #region 工艺审核
  593. private void txtMECheck_Click(object sender, EventArgs e)
  594. {
  595. SimpleButton btntemp = (SimpleButton)sender;
  596. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  597. {
  598. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  599. return;
  600. }
  601. int count = 0;
  602. for (int i = 0; i < grvDetail.RowCount; i++)
  603. {
  604. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  605. {
  606. count++;
  607. }
  608. }
  609. if (count != 1)
  610. {
  611. ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  612. return;
  613. }
  614. try
  615. {
  616. string id = "";
  617. for (int i = 0; i < grvDetail.RowCount; i++)
  618. {
  619. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  620. {
  621. id = grvDetail.GetRowCellValue(i, colID).ToString();
  622. }
  623. }
  624. ICSNCTPBLL.meCheck(id, AppConfig.AppConnectString);
  625. ICSBaseSimpleCode.AppshowMessageBox("审核成功");
  626. btnFalsh_Click(null, null);
  627. }
  628. catch (Exception ex)
  629. {
  630. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  631. }
  632. }
  633. #endregion
  634. #region 部门审核
  635. private void txtDeptCheck_Click(object sender, EventArgs e)
  636. {
  637. SimpleButton btntemp = (SimpleButton)sender;
  638. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  639. {
  640. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  641. return;
  642. }
  643. int count = 0;
  644. string Sid = "";
  645. for (int i = 0; i < grvDetail.RowCount; i++)
  646. {
  647. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  648. {
  649. Sid = grvDetail.GetRowCellValue(i, colID).ToString();
  650. count++;
  651. }
  652. }
  653. if (count == 1)
  654. {
  655. DataTable dt = ICSNCTPBLL.searchInfoByID(Sid, AppConfig.AppConnectString);
  656. if (dt.Rows[0]["Status"].ToString() == "已审核")
  657. {
  658. ICSBaseSimpleCode.AppshowMessageBox("此条数据已审核!!!");
  659. return;
  660. }
  661. }
  662. if (count != 1)
  663. {
  664. ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  665. return;
  666. }
  667. try
  668. {
  669. string id = "";
  670. for (int i = 0; i < grvDetail.RowCount; i++)
  671. {
  672. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  673. {
  674. id = grvDetail.GetRowCellValue(i, colID).ToString();
  675. }
  676. }
  677. ICSNCTPBLL.depCheck(id, AppConfig.AppConnectString);
  678. ICSBaseSimpleCode.AppshowMessageBox("审核成功");
  679. btnFalsh_Click(null, null);
  680. }
  681. catch (Exception ex)
  682. {
  683. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  684. }
  685. }
  686. #endregion
  687. #region 弃审
  688. private void BtnDiscardedTrial_Click(object sender, EventArgs e)
  689. {
  690. SimpleButton btntemp = (SimpleButton)sender;
  691. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  692. {
  693. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  694. return;
  695. }
  696. int count = 0;
  697. string Sid = "";
  698. for (int i = 0; i < grvDetail.RowCount; i++)
  699. {
  700. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  701. {
  702. Sid = grvDetail.GetRowCellValue(i, colID).ToString();
  703. count++;
  704. }
  705. }
  706. if (count == 1)
  707. {
  708. DataTable dt = ICSNCTPBLL.searchInfoByID(Sid, AppConfig.AppConnectString);
  709. if (dt.Rows[0]["Status"].ToString() == "新增")
  710. {
  711. ICSBaseSimpleCode.AppshowMessageBox("此条数据为新增状态,不能弃审!!!");
  712. return;
  713. }
  714. }
  715. //int count = 0;
  716. //for (int i = 0; i < grvDetail.RowCount; i++)
  717. //{
  718. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  719. // {
  720. // count++;
  721. // }
  722. //}
  723. if (count != 1)
  724. {
  725. ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  726. return;
  727. }
  728. try
  729. {
  730. string id = "";
  731. for (int i = 0; i < grvDetail.RowCount; i++)
  732. {
  733. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  734. {
  735. id = grvDetail.GetRowCellValue(i, colID).ToString();
  736. }
  737. }
  738. ICSNCTPBLL.DiscardedTrialCheck(id, AppConfig.AppConnectString);
  739. ICSBaseSimpleCode.AppshowMessageBox("弃审成功");
  740. btnFalsh_Click(null, null);
  741. }
  742. catch (Exception ex)
  743. {
  744. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  745. }
  746. }
  747. #endregion
  748. }
  749. }