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

1417 lines
58 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.Linq;
  8. using System.IO;
  9. using System.Windows.Forms;
  10. using DevExpress.XtraEditors;
  11. using ICSSoft.Frame.User.BLL;
  12. using ICSSoft.Base.Language.Tool;
  13. using ICSSoft.Base.UserControl.MessageControl;
  14. using System.Data.SqlClient;
  15. using ICSSoft.Base.Config.AppConfig;
  16. using ICSSoft.Base.Report.Filter;
  17. using ICSSoft.Base.Config.DBHelper;
  18. using ICSSoft.Base.UserControl.FormControl;
  19. using ICSSoft.Base.ReferForm.AppReferForm;
  20. using ICSSoft.Base.Lable.PrintTool;
  21. using ICSSoft.Frame.Data.DAL;
  22. using ICSSoft.Frame.Data.BLL;
  23. using ICSSoft.Frame.Data.Entity;
  24. namespace ICSSoft.Frame.APP
  25. {
  26. public partial class FormICSProductTrackingList : DevExpress.XtraEditors.XtraForm
  27. {
  28. private string sqltxt = "";
  29. private string sqlconn = "";
  30. String guid = AppConfig.GetGuid();
  31. private DataTable dataSource = null;
  32. bool b = false;
  33. //0817新增
  34. string mocode = "";//工单编码
  35. string moseq = "";//生产订单行号
  36. #region 构造函数
  37. public FormICSProductTrackingList()
  38. {
  39. InitializeComponent();
  40. this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  41. this.WindowState = FormWindowState.Maximized;
  42. foreach (DevExpress.XtraGrid.Columns.GridColumn col in grvDetail.Columns)
  43. {
  44. // col.OptionsColumn.AllowEdit = col.Name == colSerial.Name;
  45. // col.OptionsColumn.ReadOnly = true;
  46. }
  47. b = true;
  48. }
  49. public FormICSProductTrackingList(string mocode)
  50. {
  51. InitializeComponent();
  52. this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  53. this.WindowState = FormWindowState.Maximized;
  54. b = false;
  55. foreach (DevExpress.XtraGrid.Columns.GridColumn col in grvDetail.Columns)
  56. {
  57. // col.OptionsColumn.AllowEdit = col.Name == colSerial.Name;
  58. // col.OptionsColumn.ReadOnly = true;
  59. }
  60. searchInfo(mocode);
  61. }
  62. #endregion
  63. #region 构造函数
  64. public FormICSProductTrackingList(string mocode,string moseq)
  65. {
  66. InitializeComponent();
  67. this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  68. this.WindowState = FormWindowState.Maximized;
  69. b = false;
  70. foreach (DevExpress.XtraGrid.Columns.GridColumn col in grvDetail.Columns)
  71. {
  72. // col.OptionsColumn.AllowEdit = col.Name == colSerial.Name;
  73. // col.OptionsColumn.ReadOnly = true;
  74. }
  75. searchInfo(mocode,moseq);
  76. }
  77. /// <summary>
  78. /// 传入产品追踪单号
  79. /// </summary>
  80. /// <param name="lotno"></param>
  81. /// <param name="islotno"></param>
  82. public FormICSProductTrackingList(List<string> lotno)
  83. {
  84. InitializeComponent();
  85. this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  86. this.WindowState = FormWindowState.Maximized;
  87. b = false;
  88. searchInform(lotno);
  89. }
  90. #endregion
  91. private void searchInform(List<string> lotno)
  92. {
  93. try
  94. {
  95. this.Tag = "10.24.04";
  96. FormFilter filter = new FormFilter(AppConfig.GetSourceId(this.Tag.ToString(), btnConfig.Name));
  97. string sql = @"SELECT DISTINCT
  98. case when e.MOPLANSTARTDATE is null then a.MOPLANSTARTDATE else e.MOPLANSTARTDATE end as MOPLANSTARTDATE,
  99. case when e.MOPLANENDDATE is null then a.MOPLANENDDATE else e.MOPLANENDDATE end as MOPLANENDDATE ,
  100. a.MDeptCode as cDepName,
  101. '' AS [isSelect], e.ID as ID, f.INVCODE as INVCODE, f.INVNAME as INVNAME,
  102. f.INVSTD as INVSTD,cast(e.LOTQTY as decimal(18,2)) as QTY,f.INVUOM as INVUOM,
  103. a.MOCODE AS MOCODE, a.MOSEQ as MOSEQ,
  104. a.CUSITEMCODE as CUSITEMCODE,
  105. e.VenderLotNO AS MOVER, e.MUSERName as MUSER, e.MTIME as MTIME,
  106. CAST(CASE WHEN i.LotNO IS NOT NULL THEN '1' ELSE '0' END AS bit) AS ISPUT,
  107. e.LOTNO as LOTNO, e.tFileName,
  108. cast(e.EATTRIBUTE3 as decimal(18,2)) *cast(e.LOTQTY as decimal(18,2)) as AuxiliaryQTY,
  109. f.INVEXPORTIMPORT as AuxiliaryUOM, isnull(e.PrintTimes, 0) PrintTimes, isnull(e.TimesPrint, 0) TimesPrint
  110. FROM
  111. ICSITEMLot e with(nolock)
  112. INNER JOIN ICSMO a with(nolock) on e.TransNO=a.MOCODE AND e.TransLine=a.MOSEQ
  113. left join ICSDepartment dep on a.MDeptCode=dep.cDepCode
  114. INNER JOIN ICSINVENTORY f with(nolock) ON a.ITEMCODE = f.INVCODE
  115. LEFT JOIN ICSWareHouseLotInfo i with(nolock) ON e.LOTNO=i.LotNO
  116. WHERE 1=1 AND e.TYPE='' ";
  117. for (int i = 0; i < lotno.Count; i++)
  118. {
  119. if (i == 0)
  120. {
  121. sql += " and e.LOTNO='" + lotno[i] + "'";
  122. }
  123. else
  124. {
  125. sql += " or e.LOTNO='" + lotno[i] + "'";
  126. }
  127. }
  128. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  129. grdDetail.DataSource = data;
  130. }
  131. catch (Exception ex)
  132. {
  133. MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  134. }
  135. }
  136. private void searchInfo(string mocode)
  137. {
  138. try
  139. {
  140. this.Tag = "10.24.04";
  141. FormFilter filter = new FormFilter(AppConfig.GetSourceId(this.Tag.ToString(), btnConfig.Name));
  142. string sql = @"SELECT DISTINCT
  143. '' AS [isSelect],
  144. e.LOTNO as LOTNO,
  145. a.ID AS ID,
  146. a.ProjectCode AS ProjectCode,
  147. a.MOCODE AS MOCODE,
  148. a.MOTYPE AS MOTYPE,
  149. a.MOSEQ AS MOSEQ,
  150. b.ROUTECODE AS RouteCode,
  151. b.ROUTETYPE AS ROUTETYPE,
  152. a.MOPLANQTY AS MOPLANQTY,
  153. a.MOPLANSTARTDATE AS MOPLANSTARTDATE,
  154. a.MOPLANENDDATE AS MOPLANENDDATE,
  155. f.ItemCtrTypeCode as ItemCtrTypeCode
  156. FROM
  157. ICSMO2Lot e
  158. INNER JOIN ICSMO2User c ON e.LOTNO = c.LOTNO
  159. INNER JOIN ICSMO a on e.MOCODE=a.MOCODE
  160. INNER JOIN ICSMO2ROUTE b ON a.MOCODE = b.MOCODE
  161. INNER JOIN Base_Inventory f ON a.ITEMCODE = f.ItemCode
  162. WHERE
  163. a.MOCODE='" + mocode + "' order by e.LOTNO asc";
  164. sql = string.Format(sql);
  165. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  166. grdDetail.DataSource = data;
  167. }
  168. catch (Exception ex)
  169. {
  170. MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  171. }
  172. }
  173. private void searchInfo(string mocode,string moseq)
  174. {
  175. try
  176. {
  177. this.Tag = "10.24.04";
  178. FormFilter filter = new FormFilter(AppConfig.GetSourceId(this.Tag.ToString(), btnConfig.Name));
  179. // string sql = @"SELECT DISTINCT
  180. // '' AS [isSelect],
  181. // e.LOTNO as LOTNO,
  182. // a.ID AS ID,
  183. // a.MOVER AS ProjectCode,
  184. // a.MOCODE AS MOCODE,
  185. // a.MOTYPE AS MOTYPE,
  186. // a.MOSEQ AS MOSEQ,
  187. //
  188. // b.ROUTECODE AS RouteCode,
  189. // b.ROUTETYPE AS ROUTETYPE,
  190. // a.MOPLANQTY AS MOPLANQTY,
  191. // a.MOPLANSTARTDATE AS MOPLANSTARTDATE,
  192. // a.MOPLANENDDATE AS MOPLANENDDATE,
  193. // '' as ItemCtrTypeCode
  194. //FROM
  195. //ICSITEMLot e
  196. //INNER JOIN ICSMO2User c ON e.LOTNO = c.LOTNO
  197. //INNER JOIN ICSMO a on e.TransNO=a.MOCODE AND e.TransLine=a.MOSEQ
  198. //INNER JOIN ICSMO2ROUTE b ON a.MOCODE = b.MOCODE
  199. //INNER JOIN ICSINVENTORY f ON a.ITEMCODE = f.INVCODE
  200. //WHERE
  201. // a.MOCODE='" + mocode + "' AND a.MOSEQ='"+moseq+"' order by e.LOTNO asc";
  202. string sql = @" SELECT DISTINCT
  203. '' AS [isSelect],
  204. f.INVCODE as INVCODE,
  205. f.INVNAME as INVNAME,
  206. f.INVSTD as INVSTD,
  207. e.LOTQTY as QTY,
  208. f.INVUOM as INVUOM,
  209. a.MOCODE AS MOCODE,
  210. a.MOSEQ as MOSEQ,
  211. a.MOVER AS MOVER,
  212. e.MUSERName as MUSER,
  213. e.MTIME as MTIME,
  214. CAST(CASE WHEN i.LotNO IS NOT NULL THEN '1' ELSE '0' END AS bit) AS ISPUT,
  215. e.LOTNO as LOTNO,
  216. cast(e.EATTRIBUTE3 as decimal(18,2)) *cast(e.LOTQTY as decimal(18,2)) as AuxiliaryQTY,
  217. f.INVEXPORTIMPORT as AuxiliaryUOM
  218. FROM
  219. ICSITEMLot e
  220. INNER JOIN ICSMO a on e.TransNO=a.MOCODE AND e.TransLine=a.MOSEQ
  221. INNER JOIN ICSINVENTORY f ON a.ITEMCODE = f.INVCODE
  222. LEFT JOIN ICSWareHouseLotInfo i ON e.LOTNO=i.LotNO
  223. WHERE 1=1 AND e.TYPE=''
  224. AND MOCODE='" + mocode + "' AND MOSEQ='" + moseq + "' order by e.LOTNO asc";
  225. sql = string.Format(sql);
  226. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  227. grdDetail.DataSource = data;
  228. }
  229. catch (Exception ex)
  230. {
  231. MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  232. }
  233. }
  234. #region 操作权限
  235. public DataTable RightOfExute()
  236. {
  237. DataTable rData = new DataTable();
  238. rData.Columns.Add("BtnName");
  239. rData.Columns.Add("ActionName");
  240. //查看权限(必须有)
  241. DataRow seeRow = rData.NewRow();
  242. seeRow["BtnName"] = "see";
  243. seeRow["ActionName"] = "查看";
  244. rData.Rows.Add(seeRow);
  245. foreach (Control ctr in panelControl3.Controls)
  246. {
  247. if (ctr.Name == btnFilter.Name || ctr.Name == btnConfig.Name ||
  248. ctr.Name == btnSelectAll.Name || ctr.Name == btnCancelAll.Name ||
  249. ctr.Name == btnOutPut.Name || ctr.Name == btnPrint.Name || ctr.Name == txtTarckList.Name || ctr.Name == btnrePrint.Name ||
  250. ctr.Name == btnRefresh.Name || ctr.Name == btnExit.Name || ctr.Name == MOTitle.Name || ctr.Name == btnClose.Name || ctr.Name == btnDelete.Name || ctr.Name == btnCancelPrint.Name)
  251. continue;
  252. DataRow dr = rData.NewRow();
  253. dr["BtnName"] = ctr.Name;
  254. dr["ActionName"] = ctr.Text;
  255. rData.Rows.Add(dr);
  256. }
  257. //List<Control> ControlList = new List<Control>();
  258. ////ControlList.Add(btnCreate);
  259. ////ControlList.Add(btnModify);
  260. ////ControlList.Add(btnDel);
  261. //ControlList.Add(btnOutPut);
  262. //foreach (Control ctr in ControlList)
  263. //{
  264. // if (ctr.GetType() == typeof(SimpleButton))
  265. // {
  266. // DataRow dr = rData.NewRow();
  267. // dr["BtnName"] = ctr.Name;
  268. // dr["ActionName"] = ctr.Text;
  269. // rData.Rows.Add(dr);
  270. // }
  271. //}
  272. rData.AcceptChanges();
  273. return rData;
  274. }
  275. public DataTable RightOfData()// 数据权限
  276. {
  277. DataTable rData = new DataTable();
  278. rData.Columns.Add("BodyName");
  279. rData.Columns.Add("ControlName");
  280. rData.Columns.Add("ControlCaption");
  281. rData.AcceptChanges();
  282. return rData;
  283. }
  284. #endregion
  285. #region 退出
  286. private void btnClose_Click(object sender, EventArgs e)
  287. {
  288. AppConfig.CloseFormShow(this.Text);
  289. this.Close();
  290. }
  291. private void btnExit_Click(object sender, EventArgs e)
  292. {
  293. AppConfig.CloseFormShow(this.Text);
  294. this.Close();
  295. }
  296. #endregion
  297. #region 移动窗体
  298. private const int WM_NCHITTEST = 0x84;
  299. private const int HTCLIENT = 0x1;
  300. private const int HTCAPTION = 0x2;
  301. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  302. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  303. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  304. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  305. //重写窗体,使窗体可以不通过自带标题栏实现移动
  306. protected override void WndProc(ref Message m)
  307. {
  308. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  309. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  310. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  311. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  312. switch (m.Msg)
  313. {
  314. case WM_NCHITTEST:
  315. base.WndProc(ref m);
  316. if ((int)m.Result == HTCLIENT)
  317. m.Result = (IntPtr)HTCAPTION;
  318. return;
  319. }
  320. //拦截双击标题栏、移动窗体的系统消息
  321. if (m.Msg != 0xA3)
  322. {
  323. base.WndProc(ref m);
  324. }
  325. }
  326. #endregion
  327. #region 列表
  328. private void grvDetail_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
  329. {
  330. if (e.Info.IsRowIndicator && e.RowHandle >= 0)
  331. e.Info.DisplayText = (e.RowHandle + 1).ToString();
  332. }
  333. #endregion
  334. #region 过滤
  335. private string tempTableName = "";
  336. private void btnFilter_Click(object sender, EventArgs e)
  337. {
  338. FormFilter filter = new FormFilter(AppConfig.GetSourceId(this.Tag.ToString(), btnConfig.Name));
  339. filter.OldTempTableName = tempTableName;
  340. if (filter.ShowDialog() == DialogResult.OK)
  341. {
  342. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在查找...请稍等...");
  343. try
  344. {
  345. _wait.Show();
  346. tempTableName = filter.NewTempTableName;
  347. sqltxt = filter.SqlText;
  348. sqlconn = filter.FilterConnectString;
  349. dataSource = filter.FilterData.Tables[0];
  350. grdDetail.DataSource = dataSource;
  351. grvDetail.BestFitColumns();
  352. rptPage.RecordNum = dataSource.Rows.Count;
  353. rptPage.PageSize = 500;
  354. rptPage.PageIndex = 1;
  355. rptPage.ReLoad();
  356. _wait.Close();
  357. }
  358. catch (Exception ex)
  359. {
  360. MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  361. _wait.Close();
  362. }
  363. }
  364. }
  365. #endregion
  366. #region 绑定数据源
  367. private void btnConfig_Click(object sender, EventArgs e)
  368. {
  369. if (AppConfig.UserCode.ToLower() != "demo")
  370. {
  371. ICSBaseSimpleCode.AppshowMessageBox("您没有权限设置数据源,请联系软件提供商!");
  372. return;
  373. }
  374. FormDataSource fdata = new FormDataSource(AppConfig.GetMenuId(this.Tag.ToString()), btnConfig.Name);
  375. fdata.ShowDialog();
  376. }
  377. #endregion
  378. #region 分页
  379. private void rptPage_PageIndexChanged(object Sender, EventArgs e)
  380. {
  381. DataTable data = AppConfig.GetPageData(dataSource, rptPage.PageIndex, rptPage.PageSize).Copy();
  382. //DataTable data = AppConfig.GetPageDataByDb(tempTableName, "pagerowindex", rptPage.PageSize, rptPage.PageIndex, dataSource.Rows.Count);
  383. grdDetail.DataSource = data;
  384. }
  385. #endregion
  386. #region 过滤方法
  387. private void FormContainerManager_FormClosing(object sender, FormClosingEventArgs e)
  388. {
  389. AppConfig.DropTemTable(tempTableName);
  390. }
  391. #endregion
  392. #region 全选
  393. private void btnSelectAll_Click(object sender, EventArgs e)
  394. {
  395. grvDetail.PostEditor();
  396. this.Validate();
  397. for (int i = 0; i < grvDetail.RowCount; i++)
  398. {
  399. grvDetail.SetRowCellValue(i, colisSelect, "Y");
  400. }
  401. }
  402. #endregion
  403. #region 全消
  404. private void btnCancelAll_Click(object sender, EventArgs e)
  405. {
  406. grvDetail.PostEditor();
  407. this.Validate();
  408. for (int i = 0; i < grvDetail.RowCount; i++)
  409. {
  410. grvDetail.SetRowCellValue(i, colisSelect, "");
  411. }
  412. }
  413. #endregion
  414. #region 双击
  415. private void grvDetail_DoubleClick(object sender, EventArgs e)
  416. {
  417. if (grvDetail.FocusedRowHandle < 0)
  418. {
  419. return;
  420. }
  421. if (grvDetail.FocusedColumn == colisSelect)
  422. {
  423. if (grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colisSelect).ToString() == "")
  424. {
  425. grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colisSelect, "Y");
  426. }
  427. else
  428. {
  429. grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colisSelect, "");
  430. }
  431. }
  432. }
  433. #endregion
  434. #region 导出
  435. private void btnOutPut_Click(object sender, EventArgs e)
  436. {
  437. try
  438. {
  439. FormOutExcel foe = new FormOutExcel(this.Tag.ToString(), grdDetail);
  440. foe.ShowDialog();
  441. }
  442. catch (Exception ex)
  443. {
  444. MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  445. }
  446. //FormOutExcel foe = new FormOutExcel();
  447. //if (foe.ShowDialog() == DialogResult.OK)
  448. //{
  449. // try
  450. // {
  451. // string outtype = foe._OutType;
  452. // string exceltype = foe._ExcelType;
  453. // string filename = foe._FileName;
  454. // string url = foe._Url;
  455. // string sheetname = foe._SheetName;
  456. // if (outtype.ToLower() == "excel")
  457. // {
  458. // DevExpress.XtraPrinting.XlsExportOptions op = new DevExpress.XtraPrinting.XlsExportOptions();
  459. // op.SheetName = sheetname;
  460. // grdDetail.MainView.ExportToXls((url + "\\" + filename + (exceltype == "2003" ? ".xls" : ".xlsx")), op);
  461. // }
  462. // else
  463. // {
  464. // grdDetail.MainView.ExportToPdf(url + "\\" + filename + ".pdf");
  465. // }
  466. // MessageBox.Show("导出成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  467. // }
  468. // catch (Exception ex)
  469. // {
  470. // MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  471. // }
  472. //}
  473. }
  474. #endregion
  475. #region 刷新
  476. private void btnRefresh_Click(object sender, EventArgs e)
  477. {
  478. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在查找...请稍等...");
  479. try
  480. {
  481. _wait.Show();
  482. FormFilter filter = new FormFilter(AppConfig.GetSourceId(this.Tag.ToString(), btnConfig.Name), false);
  483. filter.OldTempTableName = tempTableName;
  484. //tempTableName = filter.NewTempTableName;
  485. //DataTable data = DBHelper.ExecuteDataset(AppConfig.FrameConnectString, CommandType.Text, "select * from " + tempTableName).Tables[0];
  486. dataSource = DBHelper.ExecuteDataset(sqlconn, CommandType.Text, sqltxt).Tables[0];
  487. grdDetail.DataSource = dataSource;
  488. grvDetail.BestFitColumns();
  489. rptPage.RecordNum = dataSource.Rows.Count;
  490. rptPage.PageIndex = 1;
  491. rptPage.ReLoad();
  492. _wait.Close();
  493. }
  494. catch (Exception ex)
  495. {
  496. MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  497. _wait.Close();
  498. }
  499. }
  500. #endregion
  501. //#region 新增
  502. //private void btnCreate_Click(object sender, EventArgs e)
  503. //{
  504. // SimpleButton btntemp = (SimpleButton)sender;
  505. // if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  506. // {
  507. // ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  508. // return;
  509. // }
  510. // FormICSMOAdd add = new FormICSMOAdd();
  511. // add.ShowDialog();
  512. // btnRefresh_Click(null, null);
  513. //}
  514. //#endregion
  515. //#region 修改
  516. //private void btnModify_Click(object sender, EventArgs e)
  517. //{
  518. // SimpleButton btntemp = (SimpleButton)sender;
  519. // if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  520. // {
  521. // ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  522. // return;
  523. // }
  524. // int count = 0;
  525. // for (int i = 0; i < grvDetail.RowCount; i++)
  526. // {
  527. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  528. // {
  529. // count++;
  530. // }
  531. // }
  532. // if (count != 1)
  533. // {
  534. // ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  535. // return;
  536. // }
  537. // try
  538. // {
  539. // string moid;
  540. // for (int i = 0; i < grvDetail.RowCount; i++)
  541. // {
  542. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  543. // {
  544. // moid = grvDetail.GetRowCellValue(i, colID).ToString();
  545. // FormICSMOAdd add = new FormICSMOAdd(moid);
  546. // add.ShowDialog();
  547. // }
  548. // }
  549. // btnRefresh_Click(null, null);
  550. // }
  551. // catch (Exception ex)
  552. // {
  553. // //throw ex;
  554. // ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  555. // }
  556. //}
  557. //#endregion
  558. //#region 删除
  559. //private void btnDel_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. // List<string> moidList = new List<string>();
  568. // for (int i = 0; i < grvDetail.RowCount; i++)
  569. // {
  570. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  571. // {
  572. // moidList.Add(grvDetail.GetRowCellValue(i, colID).ToString());
  573. // }
  574. // }
  575. // if (moidList.Count == 0 || moidList == null)
  576. // {
  577. // ICSBaseSimpleCode.AppshowMessageBox("请选择数据");
  578. // return;
  579. // }
  580. // if (ICSBaseSimpleCode.AppshowMessageBoxRepose("确定删除工单吗?删除后无法恢复,确定吗?") != DialogResult.OK)
  581. // {
  582. // btnCancelAll_Click(sender, e);
  583. // return;
  584. // }
  585. // try
  586. // {
  587. // ICSMOBLL.deleteInfo(moidList, AppConfig.AppConnectString);
  588. // ICSBaseSimpleCode.AppshowMessageBox("删除成功");
  589. // }
  590. // catch (Exception ex)
  591. // {
  592. // ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  593. // }
  594. // btnRefresh_Click(null, null);
  595. //}
  596. //#endregion
  597. private void ICSItemLot_FormClosing(object sender, FormClosingEventArgs e)
  598. {
  599. AppConfig.DropTemTable(tempTableName);
  600. }
  601. private void FormICSMO_Load(object sender, EventArgs e)
  602. {
  603. if (b == true)
  604. {
  605. btnFilter_Click(sender, e);
  606. }
  607. }
  608. private void grvDetail_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
  609. {
  610. if (e.RowHandle >= 0 && e.Column.FieldName == "DCTCODE")
  611. {
  612. //e.DisplayText = FormatHelper.
  613. e.CellValue = "cccc";
  614. }
  615. }
  616. #region 入库条码打印
  617. private void txtPrint_Click(object sender, EventArgs e)
  618. {
  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. if (grvDetail.FocusedRowHandle < 0)
  626. {
  627. return;
  628. }
  629. try
  630. {
  631. string lotno = "";
  632. string mes = "";
  633. string message = "";
  634. for (int i = 0; i < grvDetail.RowCount; i++)
  635. {
  636. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  637. {
  638. if (Convert.ToInt32(grvDetail.GetRowCellValue(i, colTimesPrint).ToString()) > 0)
  639. {
  640. if (mes == "")
  641. {
  642. mes = "条码:" + grvDetail.GetRowCellValue(i, colLOTNO).ToString();
  643. }
  644. else
  645. {
  646. mes += ";条码:" + grvDetail.GetRowCellValue(i, colLOTNO).ToString();
  647. }
  648. }
  649. }
  650. }
  651. for (int i = 0; i < grvDetail.RowCount; i++)
  652. {
  653. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  654. {
  655. lotno = grvDetail.GetRowCellValue(i, colLOTNO).ToString();
  656. string sql = @"SELECT DISTINCT x.ISCOM
  657. FROM ICSLOTSIMULATION x
  658. -- INNER JOIN ICSLOTONWIP y ON x.LOTNO=y.LOTNO AND x.OPCODE=y.OPCODE
  659. -- INNER JOIN ICSLOTONWIPCheck z ON y.ID=z.ONWIPID
  660. WHERE x.ISCOM='1' AND x.LOTNO='{0}' ";
  661. sql = string.Format(sql, lotno);
  662. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  663. if (dt == null || dt.Rows.Count <= 0)
  664. {
  665. if (message == "")
  666. {
  667. message = "条码:" + grvDetail.GetRowCellValue(i, colLOTNO).ToString();
  668. }
  669. else
  670. {
  671. message += ";条码:" + grvDetail.GetRowCellValue(i, colLOTNO).ToString();
  672. }
  673. }
  674. else
  675. {
  676. sql = @"
  677. select a.LOTNO,a.OPCODE,b.ID ,c.Result,c.TResult
  678. from ICSLOTSIMULATION a
  679. inner join ICSLOTONWIP b on b.LOTNO=a.LOTNO and b.OPCODE=a.OPCODE
  680. inner join ICSLOTONWIPCheck c on c.ONWIPID=b.ID
  681. where a.LOTNO='{0}' ";
  682. sql = string.Format(sql, lotno);
  683. dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  684. if (dt == null || dt.Rows.Count <= 0)
  685. {
  686. if (message == "")
  687. {
  688. message = "条码:" + grvDetail.GetRowCellValue(i, colLOTNO).ToString() + "最后一道工序未检验,无法打印,请先检验;";
  689. }
  690. else
  691. {
  692. message += ";条码:" + grvDetail.GetRowCellValue(i, colLOTNO).ToString() + "最后一道工序未检验,无法打印,请先检验;";
  693. }
  694. }
  695. else
  696. {
  697. if (!(dt.Rows[0]["Result"].ToString() == "合格" || dt.Rows[0]["TResult"].ToString() == "让步"))
  698. {
  699. if (message == "")
  700. {
  701. message = "条码:" + grvDetail.GetRowCellValue(i, colLOTNO).ToString();
  702. }
  703. else
  704. {
  705. message += ";条码:" + grvDetail.GetRowCellValue(i, colLOTNO).ToString();
  706. }
  707. }
  708. }
  709. }
  710. }
  711. }
  712. if (mes == "")
  713. {
  714. if (message == "")
  715. {
  716. List<PrintPara> barCodeList = new List<PrintPara>();
  717. List<ICSITEMLot> InfoList = new List<ICSITEMLot>();
  718. for (int i = 0; i < grvDetail.RowCount; i++)
  719. {
  720. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  721. {
  722. string barCode = grvDetail.GetRowCellValue(i, colLOTNO).ToString();
  723. PrintPara printInfo = new PrintPara();
  724. printInfo.PrintKey = "LOTNO";
  725. printInfo.PrintValues = new object[] { barCode };
  726. barCodeList.Add(printInfo);
  727. ICSITEMLot Info = new ICSITEMLot();
  728. Info.LotNO = grvDetail.GetRowCellValue(i, colLOTNO).ToString();
  729. //Info.PrintTimes = Convert.ToInt32(grvDetail.GetRowCellValue(i, colPrintTimes).ToString()) + 1;
  730. Info.TimesPrint = 1;
  731. Info.lastPrintUSERID = AppConfig.UserId;
  732. Info.lastPrintTime = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss");
  733. Info.WorkPoint = AppConfig.WorkPointCode;
  734. InfoList.Add(Info);
  735. }
  736. }
  737. if (barCodeList.Count == 0)
  738. {
  739. ICSBaseSimpleCode.AppshowMessageBox("没有选择数据");
  740. return;
  741. }
  742. FormPrintDialog printDialog = new FormPrintDialog("025", "ICSProduct", barCodeList, false, null);
  743. printDialog.ShowDialog();
  744. //更新打印信息
  745. ICSRdrecord2LOTBLL.updateGoodPrint(InfoList, AppConfig.AppConnectString);
  746. }
  747. else
  748. {
  749. ICSBaseSimpleCode.AppshowMessageBox(message + "最后一道工序未检验完成,不能打印!");
  750. return;
  751. }
  752. }
  753. else
  754. {
  755. ICSBaseSimpleCode.AppshowMessageBox(mes + "存在已经打印的合格证,不能再次打印!");
  756. return;
  757. }
  758. #region
  759. // for (int i = 0; i < grvDetail.RowCount; i++)
  760. // {
  761. // string sql = "";
  762. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  763. // {
  764. // sql = @"Insert into WM_BarCodePrintLog
  765. // Values
  766. // (NEWID(),'{0}','0001','{1}','{2}',GetDate(),null,null)";
  767. // sql = string.Format(sql, grvDetail.GetRowCellValue(i, colLOTNO).ToString(), AppConfig.UserCode
  768. // , AppConfig.UserName);
  769. // DBHelper.ExecuteNonQuery(AppConfig.AppConnectString, CommandType.Text, sql);
  770. // }
  771. // }
  772. #endregion
  773. }
  774. catch (Exception ex)
  775. {
  776. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  777. }
  778. }
  779. #endregion
  780. #region 跟踪单打印
  781. private void txtTarckList_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. if (grvDetail.FocusedRowHandle < 0)
  790. {
  791. return;
  792. }
  793. try
  794. {
  795. List<PrintPara> barCodeList = new List<PrintPara>();
  796. List<ICSITEMLot> InfoList = new List<ICSITEMLot>();
  797. for (int i = 0; i < grvDetail.RowCount; i++)
  798. {
  799. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  800. {
  801. string barCode = grvDetail.GetRowCellValue(i, colLOTNO).ToString();
  802. PrintPara printInfo = new PrintPara();
  803. printInfo.PrintKey = "LOTNO";
  804. printInfo.PrintValues = new object[] { barCode };
  805. barCodeList.Add(printInfo);
  806. ICSITEMLot Info = new ICSITEMLot();
  807. Info.LotNO = grvDetail.GetRowCellValue(i, colLOTNO).ToString();
  808. //Info.PrintTimes = Convert.ToInt32(grvDetail.GetRowCellValue(i, colPrintTimes).ToString()) + 1;
  809. Info.lastPrintUSERID = AppConfig.UserId;
  810. Info.lastPrintTime = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss");
  811. Info.WorkPoint = AppConfig.WorkPointCode;
  812. InfoList.Add(Info);
  813. }
  814. }
  815. if (barCodeList.Count == 0)
  816. {
  817. ICSBaseSimpleCode.AppshowMessageBox("没有选择数据");
  818. return;
  819. }
  820. FormPrintDialog printDialog = new FormPrintDialog("007", "ICSProduct", barCodeList, false, null);
  821. printDialog.ShowDialog();
  822. //更新打印信息
  823. ICSRdrecord2LOTBLL.updatePrint(InfoList, AppConfig.AppConnectString);
  824. // for (int i = 0; i < grvDetail.RowCount; i++)
  825. // {
  826. // string sql = "";
  827. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  828. // {
  829. // sql = @"Insert into WM_BarCodePrintLog
  830. // Values
  831. // (NEWID(),'{0}','0001','{1}','{2}',GetDate(),null,null)";
  832. // sql = string.Format(sql, grvDetail.GetRowCellValue(i, colLOTNO).ToString(), AppConfig.UserCode
  833. // , AppConfig.UserName);
  834. // DBHelper.ExecuteNonQuery(AppConfig.AppConnectString, CommandType.Text, sql);
  835. // }
  836. // }
  837. }
  838. catch (Exception ex)
  839. {
  840. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  841. }
  842. }
  843. #endregion
  844. #region 合格证打印
  845. private void txtQuality_Click(object sender, EventArgs e)
  846. {
  847. SimpleButton btntemp = (SimpleButton)sender;
  848. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  849. {
  850. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  851. return;
  852. }
  853. if (grvDetail.FocusedRowHandle < 0)
  854. {
  855. return;
  856. }
  857. try
  858. {
  859. List<PrintPara> barCodeList = new List<PrintPara>();
  860. List<ICSITEMLot> InfoList = new List<ICSITEMLot>();
  861. for (int i = 0; i < grvDetail.RowCount; i++)
  862. {
  863. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  864. {
  865. string barCode = grvDetail.GetRowCellValue(i, colLOTNO).ToString();
  866. PrintPara printInfo = new PrintPara();
  867. printInfo.PrintKey = "LOTNO";
  868. printInfo.PrintValues = new object[] { barCode };
  869. barCodeList.Add(printInfo);
  870. ICSITEMLot Info = new ICSITEMLot();
  871. Info.LotNO = grvDetail.GetRowCellValue(i, colLOTNO).ToString();
  872. //Info.PrintTimes = Convert.ToInt32(grvDetail.GetRowCellValue(i, colPrintTimes).ToString()) + 1;
  873. Info.lastPrintUSERID = AppConfig.UserId;
  874. Info.lastPrintTime = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss");
  875. Info.WorkPoint = AppConfig.WorkPointCode;
  876. InfoList.Add(Info);
  877. }
  878. }
  879. if (barCodeList.Count == 0)
  880. {
  881. ICSBaseSimpleCode.AppshowMessageBox("没有选择数据");
  882. return;
  883. }
  884. FormPrintDialog printDialog = new FormPrintDialog("024", "ICSProduct", barCodeList, false, null);
  885. printDialog.ShowDialog();
  886. //更新打印信息
  887. ICSRdrecord2LOTBLL.updatePrint(InfoList, AppConfig.AppConnectString);
  888. // for (int i = 0; i < grvDetail.RowCount; i++)
  889. // {
  890. // string sql = "";
  891. // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  892. // {
  893. // sql = @"Insert into WM_BarCodePrintLog
  894. // Values
  895. // (NEWID(),'{0}','0001','{1}','{2}',GetDate(),null,null)";
  896. // sql = string.Format(sql, grvDetail.GetRowCellValue(i, colLOTNO).ToString(), AppConfig.UserCode
  897. // , AppConfig.UserName);
  898. // DBHelper.ExecuteNonQuery(AppConfig.AppConnectString, CommandType.Text, sql);
  899. // }
  900. // }
  901. }
  902. catch (Exception ex)
  903. {
  904. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  905. }
  906. }
  907. #endregion
  908. #region 上传
  909. private void btnUpLoad_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  910. {
  911. OpenFileDialog openFileDialog1 = new OpenFileDialog(); //显示选择文件对话框
  912. openFileDialog1.InitialDirectory = "c:\\";
  913. openFileDialog1.Filter = "pdf files (*.pdf)|*.pdf|All files (*.*)|*.*"; //所有的文件格式
  914. openFileDialog1.FilterIndex = 2;
  915. openFileDialog1.RestoreDirectory = true;
  916. string filePath = "";
  917. if (openFileDialog1.ShowDialog() == DialogResult.OK)
  918. {
  919. filePath = openFileDialog1.FileName; //显示文件路径
  920. }
  921. else
  922. return;
  923. string connectionString = AppConfig.GetDataBaseConnectStringByKey("[DB.FTP]");
  924. string[] ftps = connectionString.Split(';');
  925. string ftpServerIP = ftps[0].Split('=')[1];
  926. string ftpRemotePath = ftps[1].Split('=')[1];
  927. string ftpUserID = ftps[2].Split('=')[1];
  928. string ftpPassword = ftps[3].Split('=')[1];
  929. FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword);
  930. try
  931. {
  932. string filename = "";
  933. string ftpURL = "ftp://" + ftpServerIP + "/" + ftpRemotePath + "/";
  934. string[] list = filePath.Split('\\');
  935. filename = list[list.Length - 1];
  936. list = filename.Split('.');
  937. filename = list[list.Length - 2];
  938. try
  939. {
  940. ftpWeb.Upload(filePath, filename, filename);
  941. }
  942. catch (Exception ex)
  943. {
  944. throw new Exception(ex.Message + " 上传出错!");
  945. }
  946. ICSITEMLot model = GetModel(grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colID).ToString(), AppConfig.AppConnectString);
  947. model.tFileName = filename;
  948. Uptdate(model, AppConfig.AppConnectString);
  949. ICSBaseSimpleCode.AppshowMessageBox("上传成功 !");
  950. btnRefresh_Click(null, null);
  951. }
  952. catch (Exception ex)
  953. {
  954. throw new Exception(ex.Message);
  955. }
  956. }
  957. #endregion
  958. #region 下载
  959. private void btnDownLoad_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  960. {
  961. #region 下载逻辑
  962. string connectionString = AppConfig.GetDataBaseConnectStringByKey("[DB.FTP]");
  963. string[] ftps = connectionString.Split(';');
  964. string ftpServerIP = ftps[0].Split('=')[1];
  965. string ftpRemotePath = ftps[1].Split('=')[1];
  966. string ftpUserID = ftps[2].Split('=')[1];
  967. string ftpPassword = ftps[3].Split('=')[1];
  968. FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword);
  969. try
  970. {
  971. string ftpURL = "ftp://" + ftpServerIP + "/" + ftpRemotePath + "/" + grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, coltFileName).ToString() + "/";
  972. ICSITEMLot model = GetModel(grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colID).ToString(), AppConfig.AppConnectString);
  973. if (string.IsNullOrEmpty(model.tFileName))
  974. {
  975. ICSBaseSimpleCode.AppshowMessageBox("暂无文档!");
  976. return;
  977. }
  978. //string path = System.Windows.Forms.Application.StartupPath + @"\PDF";
  979. //DirectoryInfo directoryInfo = new DirectoryInfo(path);
  980. //if (!Directory.Exists(path))
  981. //{
  982. // Directory.CreateDirectory(path);
  983. //}
  984. SaveFileDialog save = new SaveFileDialog();
  985. save.FileName = model.tFileName + ".pdf";
  986. save.Filter = "PDF文件(*.pdf)|.pdf";
  987. if (save.ShowDialog() == DialogResult.OK)
  988. {
  989. string filePaths = save.FileName;
  990. ftpWeb.Download(Path.GetDirectoryName(filePaths), Path.GetFileName(filePaths), Path.GetFileNameWithoutExtension(filePaths));
  991. }
  992. #region 现逻辑
  993. //string filePaths = path + @"\" + model.tFileName + ".pdf";
  994. //ftpWeb.Download(path, grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, coltFileName).ToString() + ".pdf", grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, coltFileName).ToString());
  995. ////string filePaths = @"C:\Users\Administrator.UX7663JVU2X64C5\Desktop\123.pdf";
  996. //AxAcroPDFLib.AxAcroPDF axAcroPDF = new AxAcroPDFLib.AxAcroPDF();
  997. //((System.ComponentModel.ISupportInitialize)(axAcroPDF)).BeginInit();
  998. //axAcroPDF.Dock = DockStyle.Fill;
  999. //this.Controls.Add(axAcroPDF);
  1000. //axAcroPDF.Location = new System.Drawing.Point(0, 24);
  1001. //((System.ComponentModel.ISupportInitialize)(axAcroPDF)).EndInit();
  1002. //axAcroPDF.LoadFile(filePaths);
  1003. //axAcroPDF.setShowToolbar(true);
  1004. //axAcroPDF.setPageMode("thumbs");
  1005. //axAcroPDF.setPageMode("none");
  1006. //axAcroPDF.Show();
  1007. //System.Diagnostics.Process.Start(filePaths);
  1008. #endregion
  1009. }
  1010. catch (Exception ex)
  1011. {
  1012. throw new Exception(ex.Message);
  1013. }
  1014. #endregion
  1015. }
  1016. #endregion
  1017. public static ICSITEMLot GetModel(string ID, string Appconstr)
  1018. {
  1019. FramDataContext db = new FramDataContext(Appconstr);
  1020. db.Connection.Open();
  1021. db.Transaction = db.Connection.BeginTransaction();
  1022. try
  1023. {
  1024. ICSITEMLot model = new ICSITEMLot();
  1025. var line = db.ICSITEMLot.SingleOrDefault(a => a.ID == ID);
  1026. if (line != null)
  1027. model = line;
  1028. return model;
  1029. }
  1030. catch (Exception ex)
  1031. {
  1032. throw new Exception(ex.Message);
  1033. }
  1034. }
  1035. public static void Uptdate(ICSITEMLot data, string dsconn)
  1036. {
  1037. FramDataContext db = new FramDataContext(dsconn);
  1038. db.Connection.Open();
  1039. db.Transaction = db.Connection.BeginTransaction();
  1040. try
  1041. {
  1042. var line = db.ICSITEMLot.SingleOrDefault(a => a.ID == data.ID);
  1043. line.tFileName = data.tFileName;
  1044. //db.ICSITEMLot.InsertOnSubmit(line);
  1045. db.SubmitChanges();
  1046. db.Transaction.Commit();
  1047. }
  1048. catch (Exception ex)
  1049. {
  1050. db.Transaction.Rollback();
  1051. throw ex;
  1052. }
  1053. }
  1054. #region
  1055. private void btnDelete_Click(object sender, EventArgs e)
  1056. {
  1057. SimpleButton btntemp = (SimpleButton)sender;
  1058. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  1059. {
  1060. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  1061. return;
  1062. }
  1063. if (ICSBaseSimpleCode.AppshowMessageBoxRepose("确定清除该文件吗?清除后无法恢复") != DialogResult.OK)
  1064. {
  1065. for (int i = 0; i < grvDetail.RowCount; i++)
  1066. {
  1067. grvDetail.SetRowCellValue(i, colisSelect, "");
  1068. }
  1069. return;
  1070. }
  1071. int count = 0;
  1072. for (int i = 0; i < grvDetail.RowCount; i++)
  1073. {
  1074. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  1075. {
  1076. count++;
  1077. }
  1078. }
  1079. if (count == 0)
  1080. {
  1081. ICSBaseSimpleCode.AppshowMessageBox("请选择数据!");
  1082. return;
  1083. }
  1084. string connectionString = AppConfig.GetDataBaseConnectStringByKey("[DB.FTP]");
  1085. string[] ftps = connectionString.Split(';');
  1086. string ftpServerIP = ftps[0].Split('=')[1];
  1087. string ftpRemotePath = ftps[1].Split('=')[1];
  1088. string ftpUserID = ftps[2].Split('=')[1];
  1089. string ftpPassword = ftps[3].Split('=')[1];
  1090. FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword);
  1091. try
  1092. {
  1093. for (int i = 0; i < grvDetail.RowCount; i++)
  1094. {
  1095. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  1096. {
  1097. ICSITEMLot model = GetModel(grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colID).ToString(), AppConfig.AppConnectString);
  1098. if (string.IsNullOrEmpty(model.tFileName))
  1099. {
  1100. ICSBaseSimpleCode.AppshowMessageBox("暂无文档!");
  1101. return;
  1102. }
  1103. ftpWeb.Delete(model.tFileName, model.tFileName + ".pdf");
  1104. ftpWeb.RemoveDirectory(model.tFileName);
  1105. DeletePDF(grvDetail.GetRowCellValue(i, colLOTNO).ToString(), AppConfig.AppConnectString);
  1106. }
  1107. }
  1108. ICSBaseSimpleCode.AppshowMessageBox("清除成功 !");
  1109. btnRefresh_Click(null, null);
  1110. }
  1111. catch (Exception ex)
  1112. {
  1113. throw new Exception(ex.Message);
  1114. }
  1115. }
  1116. #endregion
  1117. public static void DeletePDF(string LotNO, string dsconn)
  1118. {
  1119. FramDataContext db = new FramDataContext(dsconn);
  1120. db.Connection.Open();
  1121. db.Transaction = db.Connection.BeginTransaction();
  1122. try
  1123. {
  1124. var line = db.ICSITEMLot.SingleOrDefault(a => a.LotNO == LotNO);
  1125. if (line != null)
  1126. {
  1127. line.tFileName = null;
  1128. }
  1129. db.SubmitChanges();
  1130. db.Transaction.Commit();
  1131. }
  1132. catch (Exception ex)
  1133. {
  1134. db.Transaction.Rollback();
  1135. throw new Exception(ex.Message);
  1136. }
  1137. }
  1138. private void btnrePrint_Click(object sender, EventArgs e)
  1139. {
  1140. SimpleButton btntemp = (SimpleButton)sender;
  1141. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  1142. {
  1143. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  1144. return;
  1145. }
  1146. if (grvDetail.FocusedRowHandle < 0)
  1147. {
  1148. return;
  1149. }
  1150. try
  1151. {
  1152. string lotno = "";
  1153. string message = "";
  1154. for (int i = 0; i < grvDetail.RowCount; i++)
  1155. {
  1156. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  1157. {
  1158. lotno = grvDetail.GetRowCellValue(i, colLOTNO).ToString();
  1159. string sql = @"SELECT DISTINCT x.ISCOM
  1160. FROM ICSLOTSIMULATION x
  1161. -- INNER JOIN ICSLOTONWIP y ON x.LOTNO=y.LOTNO AND x.OPCODE=y.OPCODE
  1162. -- INNER JOIN ICSLOTONWIPCheck z ON y.ID=z.ONWIPID
  1163. WHERE x.ISCOM='1' AND x.LOTNO='{0}' ";
  1164. sql = string.Format(sql, lotno);
  1165. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  1166. if (dt == null || dt.Rows.Count <= 0)
  1167. {
  1168. if (message == "")
  1169. {
  1170. message = "条码:" + grvDetail.GetRowCellValue(i, colLOTNO).ToString();
  1171. }
  1172. else
  1173. {
  1174. message += ";条码:" + grvDetail.GetRowCellValue(i, colLOTNO).ToString();
  1175. }
  1176. }
  1177. }
  1178. }
  1179. if (message == "")
  1180. {
  1181. List<PrintPara> barCodeList = new List<PrintPara>();
  1182. List<ICSITEMLot> InfoList = new List<ICSITEMLot>();
  1183. for (int i = 0; i < grvDetail.RowCount; i++)
  1184. {
  1185. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  1186. {
  1187. string barCode = grvDetail.GetRowCellValue(i, colLOTNO).ToString();
  1188. PrintPara printInfo = new PrintPara();
  1189. printInfo.PrintKey = "LOTNO";
  1190. printInfo.PrintValues = new object[] { barCode };
  1191. barCodeList.Add(printInfo);
  1192. ICSITEMLot Info = new ICSITEMLot();
  1193. Info.LotNO = grvDetail.GetRowCellValue(i, colLOTNO).ToString();
  1194. Info.lastPrintUSERID = AppConfig.UserId;
  1195. Info.lastPrintTime = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss");
  1196. Info.WorkPoint = AppConfig.WorkPointCode;
  1197. InfoList.Add(Info);
  1198. }
  1199. }
  1200. if (barCodeList.Count == 0)
  1201. {
  1202. ICSBaseSimpleCode.AppshowMessageBox("没有选择数据");
  1203. return;
  1204. }
  1205. FormPrintDialog printDialog = new FormPrintDialog("025", "ICSProduct", barCodeList, false, null);
  1206. printDialog.ShowDialog();
  1207. //更新打印信息
  1208. ICSRdrecord2LOTBLL.updatePrint(InfoList, AppConfig.AppConnectString);
  1209. }
  1210. else
  1211. {
  1212. ICSBaseSimpleCode.AppshowMessageBox(message + "最后一道工序未检验完成,不能打印!");
  1213. return;
  1214. }
  1215. }
  1216. catch (Exception ex)
  1217. {
  1218. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  1219. }
  1220. }
  1221. private void btnCancelPrint_Click(object sender, EventArgs e)
  1222. {
  1223. SimpleButton btntemp = (SimpleButton)sender;
  1224. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  1225. {
  1226. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  1227. return;
  1228. }
  1229. if (grvDetail.FocusedRowHandle < 0)
  1230. {
  1231. return;
  1232. }
  1233. try
  1234. {
  1235. List<PrintPara> barCodeList = new List<PrintPara>();
  1236. List<ICSITEMLot> InfoList = new List<ICSITEMLot>();
  1237. for (int i = 0; i < grvDetail.RowCount; i++)
  1238. {
  1239. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  1240. {
  1241. string sql = @"
  1242. SELECT A.LotNO, A.TYPE, D.LotNO AS BarCode, A.TransNO, B.MOCODE, E.ISCOM, G.Result, G.TResult FROM ICSITEMLot A
  1243. LEFT JOIN ICSMO B ON B.MOCODE = A.TransNO AND B.MOSEQ = A.TransLine
  1244. LEFT JOIN ICSWareHouseLotInfo D ON D.LotNO = A.LotNO
  1245. LEFT JOIN ICSLOTSIMULATION E ON E.LOTNO = A.LotNO
  1246. LEFT JOIN ICSLOTONWIP F ON F.LOTNO = E.LOTNO AND F.OPCODE = E.OPCODE
  1247. LEFT JOIN ICSLOTONWIPCheck G ON G.ONWIPID=F.ID
  1248. WHERE A.LotNO = '{0}' AND A.WorkPoint = '{1}' AND A.TYPE = '' AND F.EATTRIBUTE1 IS NULL ";
  1249. sql = string.Format(sql, grvDetail.GetRowCellValue(i, colLOTNO).ToString(), AppConfig.WorkPointCode);
  1250. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  1251. if (dt.Rows.Count > 0 && dt != null)
  1252. {
  1253. if (!(dt.Rows[0]["Result"].ToString() == "不合格" && dt.Rows[0]["TResult"].ToString() == "报废"))
  1254. {
  1255. ICSBaseSimpleCode.AppshowMessageBox("当前工序检验不为不合格且钉钉状态不为报废,不能打印标签,请确认");
  1256. return;
  1257. }
  1258. }
  1259. string barCode = grvDetail.GetRowCellValue(i, colLOTNO).ToString();
  1260. PrintPara printInfo = new PrintPara();
  1261. printInfo.PrintKey = "LOTNO";
  1262. printInfo.PrintValues = new object[] { barCode };
  1263. barCodeList.Add(printInfo);
  1264. ICSITEMLot Info = new ICSITEMLot();
  1265. Info.LotNO = grvDetail.GetRowCellValue(i, colLOTNO).ToString();
  1266. Info.lastPrintUSERID = AppConfig.UserId;
  1267. Info.lastPrintTime = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss");
  1268. Info.WorkPoint = AppConfig.WorkPointCode;
  1269. InfoList.Add(Info);
  1270. }
  1271. }
  1272. if (barCodeList.Count == 0)
  1273. {
  1274. ICSBaseSimpleCode.AppshowMessageBox("没有选择数据");
  1275. return;
  1276. }
  1277. FormPrintDialog printDialog = new FormPrintDialog("024", "ICSProduct", barCodeList, false, null);
  1278. printDialog.ShowDialog();
  1279. //更新打印信息
  1280. ICSRdrecord2LOTBLL.updatePrint(InfoList, AppConfig.AppConnectString);
  1281. }
  1282. catch (Exception ex)
  1283. {
  1284. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  1285. }
  1286. }
  1287. }
  1288. }