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

810 lines
31 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. FormOutExcel foe = new FormOutExcel(this.Tag.ToString(), grdDetail);
  372. foe.ShowDialog();
  373. }
  374. #endregion
  375. #region 导入
  376. private void btnImportData_Click(object sender, EventArgs e)
  377. {
  378. SimpleButton btntemp = (SimpleButton)sender;
  379. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  380. {
  381. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  382. return;
  383. }
  384. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm();
  385. _wait.Hide();
  386. try
  387. {
  388. FormReadExcel fre = new FormReadExcel();
  389. if (fre.ShowDialog() != DialogResult.OK)
  390. {
  391. return;
  392. }
  393. DataTable dataSource = fre._excelData;
  394. if (dataSource == null)
  395. {
  396. throw new Exception("excel数据取得失败");
  397. }
  398. _wait.Show();
  399. _wait.Caption = "判断模版是否正确......";
  400. #region 判断模版是否正确
  401. List<FormReadExcelUIModelColumns> colNameList = new List<FormReadExcelUIModelColumns>();
  402. colNameList.Add(new FormReadExcelUIModelColumns("生产时间", true));
  403. colNameList.Add(new FormReadExcelUIModelColumns("生产订单号", true));
  404. colNameList.Add(new FormReadExcelUIModelColumns("产品编号", true));
  405. colNameList.Add(new FormReadExcelUIModelColumns("存货名称", true));
  406. colNameList.Add(new FormReadExcelUIModelColumns("项目号", false));
  407. colNameList.Add(new FormReadExcelUIModelColumns("加工工序", true));
  408. colNameList.Add(new FormReadExcelUIModelColumns("加工数量", true));
  409. colNameList.Add(new FormReadExcelUIModelColumns("设备编号", true));
  410. colNameList.Add(new FormReadExcelUIModelColumns("设备名称", true));
  411. colNameList.Add(new FormReadExcelUIModelColumns("单位工时", true));
  412. colNameList.Add(new FormReadExcelUIModelColumns("加工工时", true));
  413. colNameList.Add(new FormReadExcelUIModelColumns("加工人员", true));
  414. colNameList.Add(new FormReadExcelUIModelColumns("加工工序", true));
  415. colNameList.Add(new FormReadExcelUIModelColumns("加工数量", true));
  416. foreach (FormReadExcelUIModelColumns columnsName in colNameList)
  417. {
  418. if (!dataSource.Columns.Contains(columnsName.columnsName))
  419. {
  420. throw new Exception("模版不正确,缺少列" + columnsName.columnsName);
  421. }
  422. }
  423. #endregion
  424. _wait.Caption = "数据整理中......";
  425. List<ICSNCTP> InitInvInfoList = new List<ICSNCTP>();
  426. foreach (DataRow dr in dataSource.Rows)
  427. {
  428. ///判断必输项目是否为空
  429. foreach (FormReadExcelUIModelColumns columnsName in colNameList)
  430. {
  431. if (string.IsNullOrWhiteSpace(dr[columnsName.columnsName].ToString()) == true && columnsName.NotNull == true)
  432. {
  433. throw new Exception("列" + columnsName.columnsName + "没有输入值");
  434. }
  435. }
  436. ICSNCTP Info = new ICSNCTP();
  437. Info.guid = "";
  438. DateTime s;
  439. if (!DateTime.TryParse(dr["生产时间"].ToString(), out s))
  440. {
  441. ICSBaseSimpleCode.AppshowMessageBox("生产时间格式不正确!");
  442. return;
  443. }
  444. else
  445. {
  446. Info.ProductDate = DateTime.Parse(dr["生产时间"].ToString());
  447. }
  448. Info.ProductMO = dr["生产订单号"].ToString();
  449. Info.ItemCode = dr["产品编号"].ToString();
  450. Info.ItemName = dr["存货名称"].ToString();
  451. Info.ProjectCode = dr["项目号"].ToString();
  452. Info.OPCode = dr["加工工序"].ToString();
  453. decimal count;
  454. if (!decimal.TryParse(dr["加工数量"].ToString(), out count))
  455. {
  456. ICSBaseSimpleCode.AppshowMessageBox("加工数量格式不正确!");
  457. return;
  458. }
  459. else
  460. {
  461. Info.ProductNum = decimal.Parse(dr["加工数量"].ToString());
  462. }
  463. Info.EQPCode = dr["设备编号"].ToString();
  464. Info.EQPName = dr["设备名称"].ToString();
  465. if (!decimal.TryParse(dr["单位工时"].ToString(), out count))
  466. {
  467. ICSBaseSimpleCode.AppshowMessageBox("单位工时格式不正确!");
  468. return;
  469. }
  470. else
  471. {
  472. Info.UnitTP = decimal.Parse(dr["单位工时"].ToString());
  473. }
  474. if (!decimal.TryParse(dr["加工工时"].ToString(), out count))
  475. {
  476. ICSBaseSimpleCode.AppshowMessageBox("加工工时格式不正确!");
  477. return;
  478. }
  479. else
  480. {
  481. Info.TotalTP = decimal.Parse(dr["加工工时"].ToString());
  482. }
  483. Info.ProductUser = dr["加工人员"].ToString();
  484. Info.MUSER = AppConfig.UserId;
  485. Info.MUSERName = AppConfig.UserName;
  486. Info.MTIME = DateTime.Now;
  487. Info.WorkPoint = AppConfig.WorkPointCode;
  488. Info.EATTRIBUTE1 = "";
  489. InitInvInfoList.Add(Info);
  490. }
  491. _wait.Caption = "导入数据......";
  492. string str = ICSNCTPBLL.AddList(InitInvInfoList, AppConfig.AppConnectString);
  493. _wait.Close();
  494. if (str == "")
  495. {
  496. ICSBaseSimpleCode.AppshowMessageBox("数据导入成功!");
  497. }
  498. else
  499. {
  500. ICSBaseSimpleCode.AppshowMessageBox(str);
  501. }
  502. btnFalsh_Click(null, null);
  503. }
  504. catch (Exception ex)
  505. {
  506. _wait.Close();
  507. ICSBaseSimpleCode.AppshowMessageBox("数据导入失败:" + ex.Message);
  508. }
  509. }
  510. #endregion
  511. #region 导入模板下载
  512. private void btnImportMould_Click(object sender, EventArgs e)
  513. {
  514. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm();
  515. _wait.Hide();
  516. string anjianExcelFileName = Environment.CommandLine.Substring(1, Environment.CommandLine.LastIndexOf("\\")) + "Output\\";
  517. try
  518. {
  519. _wait.Show();
  520. _wait.Caption = "模板下载中......";
  521. SaveFileDialog dlgSaveFileDialog = new SaveFileDialog(); //弹框提示保存
  522. dlgSaveFileDialog.InitialDirectory = anjianExcelFileName; //默认打开目录
  523. dlgSaveFileDialog.FilterIndex = 1;
  524. dlgSaveFileDialog.RestoreDirectory = true;
  525. dlgSaveFileDialog.FileName = "加工工时导入模板.xlsx"; //默认保存名称
  526. dlgSaveFileDialog.Filter = "Excel文件(*.xlsx)|*.xlsx";
  527. if (dlgSaveFileDialog.ShowDialog() == DialogResult.OK)
  528. {
  529. string fileName = dlgSaveFileDialog.FileName; //获取弹出框选择或填写的文件名称
  530. List<FormReadExcelUIModelColumns> colNameList = new List<FormReadExcelUIModelColumns>();
  531. colNameList.Add(new FormReadExcelUIModelColumns("生产时间", true));
  532. colNameList.Add(new FormReadExcelUIModelColumns("生产订单号", true));
  533. colNameList.Add(new FormReadExcelUIModelColumns("产品编号", true));
  534. colNameList.Add(new FormReadExcelUIModelColumns("存货名称", true));
  535. colNameList.Add(new FormReadExcelUIModelColumns("项目号", false));
  536. colNameList.Add(new FormReadExcelUIModelColumns("加工工序", true));
  537. colNameList.Add(new FormReadExcelUIModelColumns("加工数量", true));
  538. colNameList.Add(new FormReadExcelUIModelColumns("设备编号", true));
  539. colNameList.Add(new FormReadExcelUIModelColumns("设备名称", true));
  540. colNameList.Add(new FormReadExcelUIModelColumns("单位工时", true));
  541. colNameList.Add(new FormReadExcelUIModelColumns("加工工时", true));
  542. colNameList.Add(new FormReadExcelUIModelColumns("加工人员", true));
  543. colNameList.Add(new FormReadExcelUIModelColumns("加工工序", true));
  544. colNameList.Add(new FormReadExcelUIModelColumns("加工数量", true));
  545. FileUtil.exportToExcelFile(fileName, colNameList);
  546. _wait.Close();
  547. ICSBaseSimpleCode.AppshowMessageBox("模板下载成功!");
  548. }
  549. _wait.Close();
  550. }
  551. catch (Exception ex)
  552. {
  553. _wait.Close();
  554. ICSBaseSimpleCode.AppshowMessageBox("模板下载失败:" + ex.Message);
  555. }
  556. }
  557. #endregion
  558. #region 工艺审核
  559. private void txtMECheck_Click(object sender, EventArgs e)
  560. {
  561. SimpleButton btntemp = (SimpleButton)sender;
  562. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  563. {
  564. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  565. return;
  566. }
  567. int count = 0;
  568. for (int i = 0; i < grvDetail.RowCount; i++)
  569. {
  570. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  571. {
  572. count++;
  573. }
  574. }
  575. if (count != 1)
  576. {
  577. ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  578. return;
  579. }
  580. try
  581. {
  582. string id = "";
  583. for (int i = 0; i < grvDetail.RowCount; i++)
  584. {
  585. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  586. {
  587. id = grvDetail.GetRowCellValue(i, colID).ToString();
  588. }
  589. }
  590. ICSNCTPBLL.meCheck(id, AppConfig.AppConnectString);
  591. ICSBaseSimpleCode.AppshowMessageBox("审核成功");
  592. btnFalsh_Click(null, null);
  593. }
  594. catch (Exception ex)
  595. {
  596. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  597. }
  598. }
  599. #endregion
  600. #region 部门审核
  601. private void txtDeptCheck_Click(object sender, EventArgs e)
  602. {
  603. SimpleButton btntemp = (SimpleButton)sender;
  604. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  605. {
  606. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  607. return;
  608. }
  609. int count = 0;
  610. string Sid = "";
  611. for (int i = 0; i < grvDetail.RowCount; i++)
  612. {
  613. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  614. {
  615. Sid = grvDetail.GetRowCellValue(i, colID).ToString();
  616. count++;
  617. }
  618. }
  619. if (count == 1)
  620. {
  621. DataTable dt = ICSNCTPBLL.searchInfoByID(Sid, AppConfig.AppConnectString);
  622. if (dt.Rows[0]["Status"].ToString() == "已审核")
  623. {
  624. ICSBaseSimpleCode.AppshowMessageBox("此条数据已审核!!!");
  625. return;
  626. }
  627. }
  628. if (count != 1)
  629. {
  630. ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  631. return;
  632. }
  633. try
  634. {
  635. string id = "";
  636. for (int i = 0; i < grvDetail.RowCount; i++)
  637. {
  638. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  639. {
  640. id = grvDetail.GetRowCellValue(i, colID).ToString();
  641. }
  642. }
  643. ICSNCTPBLL.depCheck(id, AppConfig.AppConnectString);
  644. ICSBaseSimpleCode.AppshowMessageBox("审核成功");
  645. btnFalsh_Click(null, null);
  646. }
  647. catch (Exception ex)
  648. {
  649. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  650. }
  651. }
  652. #endregion
  653. #region 弃审
  654. private void BtnDiscardedTrial_Click(object sender, EventArgs e)
  655. {
  656. SimpleButton btntemp = (SimpleButton)sender;
  657. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  658. {
  659. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  660. return;
  661. }
  662. int count = 0;
  663. string Sid = "";
  664. for (int i = 0; i < grvDetail.RowCount; i++)
  665. {
  666. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  667. {
  668. Sid = grvDetail.GetRowCellValue(i, colID).ToString();
  669. count++;
  670. }
  671. }
  672. if (count == 1)
  673. {
  674. DataTable dt = ICSNCTPBLL.searchInfoByID(Sid, AppConfig.AppConnectString);
  675. if (dt.Rows[0]["Status"].ToString() == "新增")
  676. {
  677. ICSBaseSimpleCode.AppshowMessageBox("此条数据为新增状态,不能弃审!!!");
  678. return;
  679. }
  680. }
  681. //int count = 0;
  682. //for (int i = 0; i < grvDetail.RowCount; i++)
  683. //{
  684. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  685. // {
  686. // count++;
  687. // }
  688. //}
  689. if (count != 1)
  690. {
  691. ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  692. return;
  693. }
  694. try
  695. {
  696. string id = "";
  697. for (int i = 0; i < grvDetail.RowCount; i++)
  698. {
  699. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  700. {
  701. id = grvDetail.GetRowCellValue(i, colID).ToString();
  702. }
  703. }
  704. ICSNCTPBLL.DiscardedTrialCheck(id, AppConfig.AppConnectString);
  705. ICSBaseSimpleCode.AppshowMessageBox("弃审成功");
  706. btnFalsh_Click(null, null);
  707. }
  708. catch (Exception ex)
  709. {
  710. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  711. }
  712. }
  713. #endregion
  714. }
  715. }