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

789 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.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. using ICSSoft.Frame.Data.DAL;
  27. using ICSSoft.Base.Log;
  28. namespace ICSSoft.Frame.APP
  29. {
  30. public partial class FormICSINLoad : DevExpress.XtraEditors.XtraForm
  31. {
  32. private string sqltxt = "";
  33. private string sqlconn = "";
  34. string path = "";
  35. List<string> barList = new List<string>();
  36. string errorBar = "";
  37. String guid = AppConfig.GetGuid();
  38. private DataTable dataSource = null;
  39. private DataTable BodySource = null;
  40. DataSet ds = new DataSet();
  41. DataTable HandDt;
  42. DataTable BodyDt;
  43. public bool isNew = false;
  44. public string LotNO = "";
  45. public string MOVER = "";
  46. #region 构造函数
  47. public FormICSINLoad()
  48. {
  49. InitializeComponent();
  50. this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  51. this.WindowState = FormWindowState.Maximized;
  52. isNew = true;
  53. }
  54. public FormICSINLoad(string _LotNO, string _VenderLotNO)
  55. {
  56. InitializeComponent();
  57. this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  58. this.WindowState = FormWindowState.Maximized;
  59. isNew = false;
  60. LotNO = _LotNO;
  61. MOVER = _VenderLotNO;
  62. }
  63. #endregion
  64. #region 操作权限
  65. /// <summary>
  66. /// 操作权限
  67. /// </summary>
  68. /// <returns></returns>
  69. public DataTable RightOfExute()
  70. {
  71. DataTable rData = new DataTable();
  72. rData.Columns.Add("BtnName");
  73. rData.Columns.Add("ActionName");
  74. //查看权限(必须有)
  75. DataRow seeRow = rData.NewRow();
  76. seeRow["BtnName"] = "see";
  77. seeRow["ActionName"] = "查看";
  78. rData.Rows.Add(seeRow);
  79. List<Control> ControlList = new List<Control>();
  80. ControlList.Add(btnStove);
  81. ControlList.Add(btnOutPut);
  82. ControlList.Add(btnCancel);
  83. ControlList.Add(btnDel);
  84. foreach (Control ctr in ControlList)
  85. {
  86. if (ctr.GetType() == typeof(SimpleButton))
  87. {
  88. DataRow dr = rData.NewRow();
  89. dr["BtnName"] = ctr.Name;
  90. dr["ActionName"] = ctr.Text;
  91. rData.Rows.Add(dr);
  92. }
  93. }
  94. rData.AcceptChanges();
  95. return rData;
  96. }
  97. /// <summary>
  98. /// 数据权限
  99. /// </summary>
  100. /// <returns></returns>
  101. public DataTable RightOfData()
  102. {
  103. DataTable rData = new DataTable();
  104. rData.Columns.Add("BodyName");
  105. rData.Columns.Add("ControlName");
  106. rData.Columns.Add("ControlCaption");
  107. rData.AcceptChanges();
  108. return rData;
  109. }
  110. #endregion
  111. #region 退出
  112. private void btnClose_Click(object sender, EventArgs e)
  113. {
  114. AppConfig.CloseFormShow(this.Text);
  115. this.Close();
  116. }
  117. private void btnExit_Click(object sender, EventArgs e)
  118. {
  119. AppConfig.CloseFormShow(this.Text);
  120. this.Close();
  121. }
  122. #endregion
  123. #region 移动窗体
  124. private const int WM_NCHITTEST = 0x84;
  125. private const int HTCLIENT = 0x1;
  126. private const int HTCAPTION = 0x2;
  127. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  128. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  129. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  130. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  131. //重写窗体,使窗体可以不通过自带标题栏实现移动
  132. protected override void WndProc(ref Message m)
  133. {
  134. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  135. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  136. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  137. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  138. switch (m.Msg)
  139. {
  140. case WM_NCHITTEST:
  141. base.WndProc(ref m);
  142. if ((int)m.Result == HTCLIENT)
  143. m.Result = (IntPtr)HTCAPTION;
  144. return;
  145. }
  146. //拦截双击标题栏、移动窗体的系统消息
  147. if (m.Msg != 0xA3)
  148. {
  149. base.WndProc(ref m);
  150. }
  151. }
  152. #endregion
  153. #region dataSet绑定
  154. private DataSet dataSetTool(DataTable hand, DataTable body)
  155. {
  156. DataColumn[] relations_dt, relations_ds;
  157. hand.TableName = "Hand";
  158. body.TableName = "Body";
  159. HandDt = hand.Copy();
  160. BodyDt = body.Copy();
  161. ds.Tables.Add(HandDt);
  162. ds.Tables.Add(BodyDt);
  163. relations_dt = new DataColumn[] { ds.Tables["Hand"].Columns["TransNo"] };
  164. relations_ds = new DataColumn[] { ds.Tables["Body"].Columns["TransNO"] };
  165. ds.Relations.Add("详情", relations_dt, relations_ds, false);
  166. return ds;
  167. }
  168. #endregion
  169. #region 过滤
  170. private string tempTableName = "";
  171. private void btnFilter_Click(object sender, EventArgs e)
  172. {
  173. if (isNew)
  174. {
  175. FormFilter filter = new FormFilter(AppConfig.GetSourceId(this.Tag.ToString(), btnConfig.Name));
  176. filter.OldTempTableName = tempTableName;
  177. if (filter.ShowDialog() == DialogResult.OK)
  178. {
  179. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在查找...请稍等...");
  180. try
  181. {
  182. BodyDt = null;
  183. BodySource = null;
  184. ds.Reset();
  185. _wait.Show();
  186. tempTableName = filter.NewTempTableName;
  187. sqltxt = filter.SqlText;
  188. sqlconn = filter.FilterConnectString;
  189. dataSource = filter.FilterData.Tables[0];
  190. grdDetail.DataSource = dataSource;
  191. grvDetail.BestFitColumns();
  192. rptPage.RecordNum = dataSource.Rows.Count;
  193. rptPage.PageIndex = 1;
  194. rptPage.ReLoad();
  195. _wait.Close();
  196. }
  197. catch (Exception ex)
  198. {
  199. MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  200. _wait.Close();
  201. }
  202. }
  203. }
  204. else
  205. {
  206. try
  207. {
  208. BodyDt = null;
  209. BodySource = null;
  210. ds.Reset();
  211. sqltxt = @"
  212. SELECT '' AS isSelect, A.ID AS ID, A.INCode, A.VenBatch, A.VenderLotNO MOVER, A.LotNOs,
  213. '' UpLoad, '' DownLoad, '' Del, A.tFileName, A.MUSER, A.MUSERName, A.MTIME FROM ICSINFile A
  214. WHERE 1=1 AND ISNULL(A.VenderLotNO, '') LIKE '{0}' ";
  215. if (MOVER == null || MOVER == "")
  216. {
  217. MOVER = "";
  218. }
  219. else
  220. {
  221. MOVER = "%" + MOVER + "%";
  222. }
  223. sqltxt = string.Format(sqltxt, MOVER);
  224. dataSource = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sqltxt).Tables[0];
  225. grdDetail.DataSource = dataSource;
  226. grvDetail.BestFitColumns();
  227. rptPage.RecordNum = dataSource.Rows.Count;
  228. rptPage.PageIndex = 1;
  229. rptPage.ReLoad();
  230. this.btnConfig.Enabled = false;
  231. this.btnFilter.Enabled = false;
  232. this.btnStove.Enabled = false;
  233. this.btnOutPut.Enabled = false;
  234. }
  235. catch (Exception ex)
  236. {
  237. MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  238. }
  239. }
  240. }
  241. #endregion
  242. #region 绑定数据源
  243. private void btnConfig_Click(object sender, EventArgs e)
  244. {
  245. if (AppConfig.UserCode.ToLower() != "demo")
  246. {
  247. ICSBaseSimpleCode.AppshowMessageBox("您没有权限设置数据源,请联系软件提供商!");
  248. return;
  249. }
  250. FormDataSource fdata = new FormDataSource(AppConfig.GetMenuId(this.Tag.ToString()), btnConfig.Name);
  251. fdata.ShowDialog();
  252. }
  253. #endregion
  254. #region 分页
  255. private void rptPage_PageIndexChanged(object Sender, EventArgs e)
  256. {
  257. DataTable data = AppConfig.GetPageData(dataSource, rptPage.PageIndex, rptPage.PageSize).Copy();
  258. //DataTable data = AppConfig.GetPageDataByDb(tempTableName, "pagerowindex", rptPage.PageSize, rptPage.PageIndex, dataSource.Rows.Count);
  259. grdDetail.DataSource = data;
  260. }
  261. #endregion
  262. #region 过滤方法
  263. private void FormContainerManager_FormClosing(object sender, FormClosingEventArgs e)
  264. {
  265. AppConfig.DropTemTable(tempTableName);
  266. }
  267. #endregion
  268. #region 全选
  269. private void btnSelectAll_Click(object sender, EventArgs e)
  270. {
  271. grvDetail.PostEditor();
  272. this.Validate();
  273. for (int i = 0; i < grvDetail.RowCount; i++)
  274. {
  275. grvDetail.SetRowCellValue(i, colSelect, "Y");
  276. }
  277. }
  278. #endregion
  279. #region 全消
  280. private void btnCancelAll_Click(object sender, EventArgs e)
  281. {
  282. grvDetail.PostEditor();
  283. this.Validate();
  284. for (int i = 0; i < grvDetail.RowCount; i++)
  285. {
  286. grvDetail.SetRowCellValue(i, colSelect, "");
  287. }
  288. }
  289. #endregion
  290. #region 双击
  291. private void grvDetail_DoubleClick(object sender, EventArgs e)
  292. {
  293. if (grvDetail.FocusedRowHandle < 0)
  294. {
  295. return;
  296. }
  297. if (grvDetail.FocusedColumn == colSelect)
  298. {
  299. if (grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colSelect).ToString() == "")
  300. {
  301. grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colSelect, "Y");
  302. }
  303. else
  304. {
  305. grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colSelect, "");
  306. }
  307. }
  308. }
  309. #endregion
  310. #region 导出
  311. private void btnOutPut_Click(object sender, EventArgs e)
  312. {
  313. try
  314. {
  315. FormOutExcel foe = new FormOutExcel(this.Tag.ToString(), grdDetail);
  316. foe.ShowDialog();
  317. }
  318. catch (Exception ex)
  319. {
  320. MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  321. }
  322. //SimpleButton btntemp = (SimpleButton)sender;
  323. //if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  324. //{
  325. // ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  326. // return;
  327. //}
  328. //FormOutExcel foe = new FormOutExcel();
  329. //if (foe.ShowDialog() == DialogResult.OK)
  330. //{
  331. // try
  332. // {
  333. // string outtype = foe._OutType;
  334. // string exceltype = foe._ExcelType;
  335. // string filename = foe._FileName;
  336. // string url = foe._Url;
  337. // string sheetname = foe._SheetName;
  338. // if (outtype.ToLower() == "excel")
  339. // {
  340. // DevExpress.XtraPrinting.XlsExportOptions op = new DevExpress.XtraPrinting.XlsExportOptions();
  341. // op.SheetName = sheetname;
  342. // grdDetail.MainView.ExportToXls((url + "\\" + filename + (exceltype == "2003" ? ".xls" : ".xlsx")), op);
  343. // }
  344. // else
  345. // {
  346. // grdDetail.MainView.ExportToPdf(url + "\\" + filename + ".pdf");
  347. // }
  348. // MessageBox.Show("导出成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  349. // }
  350. // catch (Exception ex)
  351. // {
  352. // MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  353. // }
  354. //}
  355. }
  356. #endregion
  357. #region 刷新
  358. private void btnRefresh_Click(object sender, EventArgs e)
  359. {
  360. if (isNew)
  361. {
  362. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在查找...请稍等...");
  363. try
  364. {
  365. BodyDt = null;
  366. BodySource = null;
  367. ds.Reset();
  368. _wait.Show();
  369. FormFilter filter = new FormFilter(AppConfig.GetSourceId(this.Tag.ToString(), btnConfig.Name), false);
  370. filter.OldTempTableName = tempTableName; ;
  371. //tempTableName = filter.NewTempTableName;
  372. //DataTable data = DBHelper.ExecuteDataset(AppConfig.FrameConnectString, CommandType.Text, "select * from " + tempTableName).Tables[0];
  373. //dataSource = DBHelper.ExecuteDataset(sqlconn, CommandType.Text, sqltxt).Tables[0];
  374. DataSet dataset = DBHelper.ExecuteDataset(sqlconn, CommandType.Text, sqltxt);
  375. dataSource = dataset.Tables[0];
  376. grdDetail.DataSource = dataSource;
  377. grvDetail.BestFitColumns();
  378. rptPage.RecordNum = dataSource.Rows.Count;
  379. rptPage.PageIndex = 1;
  380. rptPage.ReLoad();
  381. _wait.Close();
  382. }
  383. catch (Exception ex)
  384. {
  385. MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  386. _wait.Close();
  387. }
  388. }
  389. else
  390. {
  391. try
  392. {
  393. BodyDt = null;
  394. BodySource = null;
  395. ds.Reset();
  396. sqltxt = @"
  397. SELECT '' AS isSelect, A.ID AS ID, A.INCode, A.VenBatch, A.VenderLotNO MOVER, A.LotNOs,
  398. '' UpLoad, '' DownLoad, '' Del, A.tFileName, A.MUSER, A.MUSERName, A.MTIME FROM ICSINFile A
  399. WHERE 1=1 AND ISNULL(A.VenderLotNO, '') LIKE '{0}' ";
  400. if (MOVER == null || MOVER == "")
  401. {
  402. MOVER = "";
  403. }
  404. else
  405. {
  406. MOVER = "%" + MOVER + "%";
  407. }
  408. sqltxt = string.Format(sqltxt, MOVER);
  409. dataSource = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sqltxt).Tables[0];
  410. grdDetail.DataSource = dataSource;
  411. grvDetail.BestFitColumns();
  412. rptPage.RecordNum = dataSource.Rows.Count;
  413. rptPage.PageIndex = 1;
  414. rptPage.ReLoad();
  415. this.btnConfig.Enabled = false;
  416. this.btnFilter.Enabled = false;
  417. this.btnStove.Enabled = false;
  418. this.btnOutPut.Enabled = false;
  419. }
  420. catch (Exception ex)
  421. {
  422. MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  423. }
  424. }
  425. }
  426. #endregion
  427. #region 删除
  428. private void btnDelete_Click(object sender, EventArgs e)
  429. {
  430. grvDetail.PostEditor();
  431. this.Validate();
  432. if (grvDetail.RowCount == 0)
  433. return;
  434. SimpleButton btntemp = (SimpleButton)sender;
  435. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  436. {
  437. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  438. }
  439. List<string> guidList = new List<string>();
  440. List<string> codeList = new List<string>();
  441. for (int i = 0; i < grvDetail.RowCount; i++)
  442. {
  443. if (grvDetail.GetRowCellValue(i, colSelect).ToString() == "Y")
  444. {
  445. guidList.Add(grvDetail.GetRowCellValue(i, colID).ToString());
  446. //codeList.Add(grvDetail.GetRowCellValue(i, MODELCODE).ToString());
  447. }
  448. }
  449. if (guidList.Count == 0)
  450. {
  451. ICSBaseSimpleCode.AppshowMessageBox("请选择数据!");
  452. return;
  453. }
  454. if (ICSBaseSimpleCode.AppshowMessageBoxRepose("确定删除该数据吗?数据删除后无法恢复!!") != DialogResult.OK)
  455. return;
  456. try
  457. {
  458. ICSMODELBLL.delete(guidList, codeList);
  459. ICSBaseSimpleCode.AppshowMessageBox(0, "删除成功");
  460. btnRefresh_Click(null, null);
  461. }
  462. catch (Exception ex)
  463. {
  464. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  465. }
  466. }
  467. #endregion
  468. #region 上传下载PDF
  469. //上传事件
  470. private void repositoryItemButtonEdit1_Click(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  471. {
  472. OpenFileDialog openFileDialog1 = new OpenFileDialog(); //显示选择文件对话框
  473. openFileDialog1.InitialDirectory = "c:\\";
  474. openFileDialog1.Filter = "pdf files (*.pdf)|*.pdf"; //所有的文件格式
  475. //openFileDialog1.Filter = "pdf files (*.pdf)|*.pdf|All files (*.*)|*.*"; //所有的文件格式
  476. openFileDialog1.FilterIndex = 2;
  477. openFileDialog1.RestoreDirectory = true;
  478. string INCode = grvDetail.GetFocusedRowCellValue(colINCode).ToString();
  479. string filePath = "";
  480. if (openFileDialog1.ShowDialog() == DialogResult.OK)
  481. {
  482. filePath = openFileDialog1.FileName; //显示文件路径
  483. }
  484. else
  485. return;
  486. string connectionString = AppConfig.GetDataBaseConnectStringByKey("[DB.FTP]");
  487. string[] ftps = connectionString.Split(';');
  488. string ftpServerIP = ftps[0].Split('=')[1];
  489. string ftpRemotePath = ftps[1].Split('=')[1];
  490. string ftpUserID = ftps[2].Split('=')[1];
  491. string ftpPassword = ftps[3].Split('=')[1];
  492. FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword);
  493. try
  494. {
  495. string filename = "";
  496. string ftpURL = "ftp://" + ftpServerIP + "/" + ftpRemotePath + "/";
  497. string[] list = filePath.Split('\\');
  498. filename = list[list.Length - 1];
  499. list = filename.Split('.');
  500. filename = list[list.Length - 2];
  501. try
  502. {
  503. ftpWeb.Upload(filePath, filename, filename);
  504. }
  505. catch (Exception ex)
  506. {
  507. throw new Exception(ex.Message + " 上传出错!");
  508. }
  509. ICSHeatTreatmentBLL.AddINPDF(INCode, filename, AppConfig.AppConnectString);
  510. ICSBaseSimpleCode.AppshowMessageBox("上传成功 !");
  511. btnRefresh_Click(null, null);
  512. }
  513. catch (Exception ex)
  514. {
  515. throw new Exception(ex.Message);
  516. }
  517. }
  518. //下载事件
  519. private void repositoryItemButtonEdit2_Click(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  520. {
  521. string connectionString = AppConfig.GetDataBaseConnectStringByKey("[DB.FTP]");
  522. string[] ftps = connectionString.Split(';');
  523. string ftpServerIP = ftps[0].Split('=')[1];
  524. string ftpRemotePath = ftps[1].Split('=')[1];
  525. string ftpUserID = ftps[2].Split('=')[1];
  526. string ftpPassword = ftps[3].Split('=')[1];
  527. FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword);
  528. try
  529. {
  530. ICSINFile model = ICSHeatTreatmentBLL.GetINModel(grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colID).ToString(), AppConfig.AppConnectString);
  531. if (model==null||string.IsNullOrEmpty(model.tFileName))
  532. {
  533. ICSBaseSimpleCode.AppshowMessageBox("暂无文档!");
  534. return;
  535. }
  536. string path = System.Windows.Forms.Application.StartupPath + @"\PDF";
  537. DirectoryInfo directoryInfo = new DirectoryInfo(path);
  538. if (!Directory.Exists(path))
  539. {
  540. Directory.CreateDirectory(path);
  541. }
  542. string filePaths = path + @"\" + model.tFileName + ".pdf";
  543. ftpWeb.Download(path, model.tFileName + ".pdf", model.tFileName);
  544. FileDrawing.LoadPDF(filePaths);
  545. }
  546. catch (Exception ex)
  547. {
  548. throw new Exception(ex.Message);
  549. }
  550. }
  551. /// 删除文件
  552. private void repositoryItemButtonEdit5_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  553. {
  554. if (MessageBox.Show("是否要删除文件", "删除文件", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1) == DialogResult.OK)
  555. {
  556. string connectionString = AppConfig.GetDataBaseConnectStringByKey("[DB.FTP]");
  557. string[] ftps = connectionString.Split(';');
  558. string ftpServerIP = ftps[0].Split('=')[1];
  559. string ftpRemotePath = ftps[1].Split('=')[1];
  560. string ftpUserID = ftps[2].Split('=')[1];
  561. string ftpPassword = ftps[3].Split('=')[1];
  562. FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword);
  563. try
  564. {
  565. ICSINFile model = ICSHeatTreatmentBLL.GetINModel(grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colID).ToString(), AppConfig.AppConnectString);
  566. if (model == null || string.IsNullOrEmpty(model.tFileName))
  567. {
  568. ICSBaseSimpleCode.AppshowMessageBox("暂无文档!");
  569. return;
  570. }
  571. ftpWeb.Delete(model.tFileName, model.tFileName + ".pdf");
  572. ftpWeb.RemoveDirectory(model.tFileName);
  573. //ftpWeb.RemoveDirectory(model.FileName);
  574. ICSHeatTreatmentBLL.DeletePDF(grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colID).ToString(), AppConfig.AppConnectString);
  575. ICSBaseSimpleCode.AppshowMessageBox("删除成功 !");
  576. btnRefresh_Click(null, null);
  577. //FileDrawing.LoadPDF(filePaths);
  578. }
  579. catch (Exception ex)
  580. {
  581. throw new Exception(ex.Message);
  582. }
  583. }
  584. }
  585. #endregion
  586. private void FormICSItemLot_FormClosing(object sender, FormClosingEventArgs e)
  587. {
  588. AppConfig.DropTemTable(tempTableName);
  589. }
  590. private void FormICSItemLot_Load(object sender, EventArgs e)
  591. {
  592. btnFilter_Click(sender, e);
  593. }
  594. private void grvDetail_MasterRowExpanded(object sender, DevExpress.XtraGrid.Views.Grid.CustomMasterRowEventArgs e)
  595. {
  596. gridView1 = grvDetail.GetDetailView(e.RowHandle, e.RelationIndex) as DevExpress.XtraGrid.Views.Grid.GridView;
  597. gridView1.BestFitColumns();
  598. }
  599. #region 新增
  600. private void btnStove_Click(object sender, EventArgs e)
  601. {
  602. SimpleButton btntemp = (SimpleButton)sender;
  603. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  604. {
  605. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  606. return;
  607. }
  608. FormICSINLoadAdd add = new FormICSINLoadAdd();
  609. add.ShowDialog();
  610. btnRefresh_Click(null, null);
  611. }
  612. #endregion
  613. #region 新增试样号
  614. private void btnSample_Click(object sender, EventArgs e)
  615. {
  616. String id = "";
  617. string transno = "";
  618. string eqpcode = "";
  619. SimpleButton btntemp = (SimpleButton)sender;
  620. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  621. {
  622. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  623. return;
  624. }
  625. List<string> editList = new List<string>();
  626. for (int i = 0; i < grvDetail.RowCount; i++)
  627. {
  628. if (grvDetail.GetRowCellValue(i, colSelect).ToString() == "Y")
  629. {
  630. id = grvDetail.GetRowCellValue(i, colID).ToString();
  631. transno = grvDetail.GetRowCellValue(i, colINCode).ToString();
  632. editList.Add(id);
  633. }
  634. }
  635. if (editList.Count != 1)
  636. {
  637. ICSBaseSimpleCode.AppshowMessageBox("请选择单据号,且只能选择新增一条数据!!!");
  638. return;
  639. }
  640. try
  641. {
  642. FormICSHeatTreatmentAdd add = new FormICSHeatTreatmentAdd(id,transno,eqpcode);
  643. add.ShowDialog();
  644. btnRefresh_Click(null,null);
  645. }
  646. catch (Exception ex)
  647. {
  648. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  649. }
  650. }
  651. #endregion
  652. #region 删除
  653. private void btnDel_Click(object sender, EventArgs e)
  654. {
  655. grvDetail.PostEditor();
  656. this.Validate();
  657. if (grvDetail.RowCount == 0)
  658. return;
  659. SimpleButton btntemp = (SimpleButton)sender;
  660. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  661. {
  662. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  663. return;
  664. }
  665. List<string> guidList = new List<string>();
  666. for (int i = 0; i < grvDetail.RowCount; i++)
  667. {
  668. if (grvDetail.GetRowCellValue(i, colSelect).ToString() == "Y")
  669. {
  670. guidList.Add(grvDetail.GetRowCellValue(i, colID).ToString());
  671. }
  672. }
  673. if (guidList.Count == 0)
  674. {
  675. ICSBaseSimpleCode.AppshowMessageBox("请选择数据!");
  676. return;
  677. }
  678. if (ICSBaseSimpleCode.AppshowMessageBoxRepose("确定删除该存货吗?存货删除后无法恢复,确定吗?") != DialogResult.OK)
  679. return;
  680. try
  681. {
  682. ICSHeatTreatmentBLL.deleteIN(guidList);
  683. ICSBaseSimpleCode.AppshowMessageBox(0, "删除成功");
  684. btnRefresh_Click(null, null);
  685. }
  686. catch (Exception ex)
  687. {
  688. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  689. }
  690. }
  691. #endregion
  692. private void btnCancel_Click(object sender, EventArgs e)
  693. {
  694. SimpleButton btntemp = (SimpleButton)sender;
  695. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  696. {
  697. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  698. return;
  699. }
  700. int count = 0;
  701. for (int i = 0; i < grvDetail.RowCount; i++)
  702. {
  703. if (grvDetail.GetRowCellValue(i, colSelect).ToString() == "Y")
  704. {
  705. count++;
  706. }
  707. }
  708. if (count == 0)
  709. {
  710. ICSBaseSimpleCode.AppshowMessageBox("请选择数据!");
  711. return;
  712. }
  713. if (ICSBaseSimpleCode.AppshowMessageBoxRepose("确定清除文件吗?清除文件后无法恢复,确定吗?") != DialogResult.OK)
  714. return;
  715. for (int i = 0; i < grvDetail.RowCount; i++)
  716. {
  717. if (grvDetail.GetRowCellValue(i, colSelect).ToString() == "Y")
  718. {
  719. string connectionString = AppConfig.GetDataBaseConnectStringByKey("[DB.FTP]");
  720. string[] ftps = connectionString.Split(';');
  721. string ftpServerIP = ftps[0].Split('=')[1];
  722. string ftpRemotePath = ftps[1].Split('=')[1];
  723. string ftpUserID = ftps[2].Split('=')[1];
  724. string ftpPassword = ftps[3].Split('=')[1];
  725. FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword);
  726. try
  727. {
  728. ICSINFile model = ICSHeatTreatmentBLL.GetINModel(grvDetail.GetRowCellValue(i, colID).ToString(), AppConfig.AppConnectString);
  729. if (model == null || string.IsNullOrEmpty(model.tFileName))
  730. {
  731. ICSBaseSimpleCode.AppshowMessageBox("暂无文档!");
  732. return;
  733. }
  734. ftpWeb.Delete(model.tFileName, model.tFileName + ".pdf");
  735. ftpWeb.RemoveDirectory(model.tFileName);
  736. //ftpWeb.RemoveDirectory(model.FileName);
  737. ICSHeatTreatmentBLL.DeleteINPDF(grvDetail.GetRowCellValue(i, colID).ToString(), AppConfig.AppConnectString);
  738. //FileDrawing.LoadPDF(filePaths);
  739. }
  740. catch (Exception ex)
  741. {
  742. throw new Exception(ex.Message);
  743. }
  744. }
  745. }
  746. ICSBaseSimpleCode.AppshowMessageBox("清除成功 !");
  747. btnRefresh_Click(null, null);
  748. }
  749. }
  750. }