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

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