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

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