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

1007 lines
43 KiB

5 months ago
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Data.Linq;
  6. using System.Linq;
  7. using System.Drawing;
  8. using System.Text;
  9. using System.Windows.Forms;
  10. using DevExpress.XtraEditors;
  11. using DevExpress.XtraGrid.Views.BandedGrid;
  12. using DevExpress.XtraGrid.Columns;
  13. using DevExpress.XtraGrid;
  14. using System.IO;
  15. using System.Threading;
  16. using ICSSoft.Base.Language.Tool;
  17. using ICSSoft.Base.Config.AppConfig;
  18. using ICSSoft.Base.UserControl.MessageControl;
  19. using ICSSoft.Base.Config.DBHelper;
  20. using ICSSoft.Base.Report.Filter;
  21. using ICSSoft.Base.UserControl.FormControl;
  22. using ICSSoft.Base.Report.GridReport;
  23. using ICSSoft.Base.ReferForm.AppReferForm;
  24. using ICSSoft.Frame.Data.BLL;
  25. using ICSSoft.Frame.Data.Entity;
  26. using ICSSoft.Base.Lable.PrintTool;
  27. namespace ICSSoft.Frame.APP
  28. {
  29. public partial class FormICSPOArriveLOT : DevExpress.XtraEditors.XtraForm
  30. {
  31. private string sqltxt = "";
  32. private string sqlconn = "";
  33. String guid = AppConfig.GetGuid();
  34. private DataTable dataSource = null;
  35. private DataTable Serialdata = null;
  36. private bool isVenBatch = false;//判断是否要有供应商炉批号
  37. private bool isBatch = false;//判断是否要有批次号
  38. private bool isCheck = false;//判断是否需要检验
  39. public string[] Codes = { "4101", "4102", "4701", "4301", "4302", "4702", "4703", "111301", "4201", "4202", "43", "46" };
  40. #region 构造函数
  41. public FormICSPOArriveLOT()
  42. {
  43. InitializeComponent();
  44. this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  45. this.WindowState = FormWindowState.Maximized;
  46. }
  47. #endregion
  48. #region 操作权限
  49. public DataTable RightOfExute()
  50. {
  51. DataTable rData = new DataTable();
  52. rData.Columns.Add("BtnName");
  53. rData.Columns.Add("ActionName");
  54. //查看权限(必须有)
  55. DataRow seeRow = rData.NewRow();
  56. seeRow["BtnName"] = "see";
  57. seeRow["ActionName"] = "查看";
  58. rData.Rows.Add(seeRow);
  59. List<Control> ControlList = new List<Control>();
  60. ControlList.Add(btnCreate);
  61. ControlList.Add(btnDel);
  62. ControlList.Add(btnPrint);
  63. ControlList.Add(btnSelAll);
  64. ControlList.Add(btnDelAll);
  65. ControlList.Add(btnAllCreate);
  66. foreach (Control ctr in ControlList)
  67. {
  68. if (ctr.GetType() == typeof(SimpleButton))
  69. {
  70. DataRow dr = rData.NewRow();
  71. dr["BtnName"] = ctr.Name;
  72. dr["ActionName"] = ctr.Text;
  73. rData.Rows.Add(dr);
  74. }
  75. }
  76. rData.AcceptChanges();
  77. return rData;
  78. }
  79. public DataTable RightOfData()// 数据权限
  80. {
  81. DataTable rData = new DataTable();
  82. rData.Columns.Add("BodyName");
  83. rData.Columns.Add("ControlName");
  84. rData.Columns.Add("ControlCaption");
  85. rData.AcceptChanges();
  86. return rData;
  87. }
  88. #endregion
  89. #region 退出
  90. private void btnClose_Click(object sender, EventArgs e)
  91. {
  92. AppConfig.CloseFormShow(this.Text);
  93. this.Close();
  94. }
  95. private void btnExit_Click(object sender, EventArgs e)
  96. {
  97. AppConfig.CloseFormShow(this.Text);
  98. this.Close();
  99. }
  100. #endregion
  101. #region 移动窗体
  102. private const int WM_NCHITTEST = 0x84;
  103. private const int HTCLIENT = 0x1;
  104. private const int HTCAPTION = 0x2;
  105. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  106. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  107. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  108. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  109. //重写窗体,使窗体可以不通过自带标题栏实现移动
  110. protected override void WndProc(ref Message m)
  111. {
  112. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  113. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  114. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  115. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  116. switch (m.Msg)
  117. {
  118. case WM_NCHITTEST:
  119. base.WndProc(ref m);
  120. if ((int)m.Result == HTCLIENT)
  121. m.Result = (IntPtr)HTCAPTION;
  122. return;
  123. }
  124. //拦截双击标题栏、移动窗体的系统消息
  125. if (m.Msg != 0xA3)
  126. {
  127. base.WndProc(ref m);
  128. }
  129. }
  130. #endregion
  131. #region 过滤
  132. private string tempTableName = "";
  133. private void btnFilter_Click(object sender, EventArgs e)
  134. {
  135. FormFilter filter = new FormFilter(AppConfig.GetSourceId(this.Tag.ToString(), btnConfig.Name));
  136. filter.OldTempTableName = tempTableName;
  137. if (filter.ShowDialog() == DialogResult.OK)
  138. {
  139. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在查找...请稍等...");
  140. try
  141. {
  142. _wait.Show();
  143. tempTableName = filter.NewTempTableName;
  144. sqltxt = filter.SqlText;
  145. sqlconn = filter.FilterConnectString;
  146. dataSource = filter.FilterData.Tables[0];
  147. gridControl.DataSource = dataSource;
  148. gridView.BestFitColumns();
  149. _wait.Close();
  150. }
  151. catch (Exception ex)
  152. {
  153. MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  154. _wait.Close();
  155. }
  156. }
  157. }
  158. #endregion
  159. #region 绑定数据源
  160. private void btnConfig_Click(object sender, EventArgs e)
  161. {
  162. if (AppConfig.UserCode.ToLower() != "demo")
  163. {
  164. ICSBaseSimpleCode.AppshowMessageBox("您没有权限设置数据源,请联系软件提供商!");
  165. return;
  166. }
  167. FormDataSource fdata = new FormDataSource(AppConfig.GetMenuId(this.Tag.ToString()), btnConfig.Name);
  168. fdata.ShowDialog();
  169. }
  170. #endregion
  171. #region 过滤方法
  172. private void FormContainerManager_FormClosing(object sender, FormClosingEventArgs e)
  173. {
  174. AppConfig.DropTemTable(tempTableName);
  175. }
  176. #endregion
  177. #region 全选
  178. private void btnSelectAll_Click(object sender, EventArgs e)
  179. {
  180. grvDetail.PostEditor();
  181. this.Validate();
  182. for (int i = 0; i < grvDetail.RowCount; i++)
  183. {
  184. grvDetail.SetRowCellValue(i, colisSelect, "Y");
  185. }
  186. }
  187. #endregion
  188. #region 全消
  189. private void btnCancelAll_Click(object sender, EventArgs e)
  190. {
  191. grvDetail.PostEditor();
  192. this.Validate();
  193. for (int i = 0; i < grvDetail.RowCount; i++)
  194. {
  195. grvDetail.SetRowCellValue(i, colisSelect, "");
  196. }
  197. }
  198. #endregion
  199. #region 双击
  200. private void grvDetail_DoubleClick(object sender, EventArgs e)
  201. {
  202. if (grvDetail.FocusedRowHandle < 0)
  203. {
  204. return;
  205. }
  206. if (grvDetail.FocusedColumn == colisSelect)
  207. {
  208. if (grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colisSelect).ToString() == "")
  209. {
  210. grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colisSelect, "Y");
  211. }
  212. else
  213. {
  214. grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colisSelect, "");
  215. }
  216. }
  217. }
  218. private void gridView_DoubleClick(object sender, EventArgs e)
  219. {
  220. int x = 0;
  221. if (gridView.FocusedRowHandle < 0)
  222. {
  223. return;
  224. }
  225. if (gridView.FocusedColumn == coSelect)
  226. {
  227. if (gridView.GetRowCellValue(gridView.FocusedRowHandle, coSelect).ToString() == "")
  228. {
  229. gridView.SetRowCellValue(gridView.FocusedRowHandle, coSelect, "Y");
  230. x = gridView.FocusedRowHandle;
  231. }
  232. else
  233. {
  234. gridView.SetRowCellValue(gridView.FocusedRowHandle, coSelect, "");
  235. }
  236. }
  237. for (int i = 0; i < gridView.RowCount; i++)
  238. {
  239. if (x != i)
  240. {
  241. gridView.SetRowCellValue(i, coSelect, "");
  242. }
  243. }
  244. try
  245. {
  246. string cCode = "";
  247. string irowno = "";
  248. for (int i = 0; i < gridView.RowCount; i++)
  249. {
  250. if (gridView.GetRowCellValue(i, coSelect).ToString() == "Y")
  251. {
  252. cCode = gridView.GetRowCellValue(i, cocCode).ToString();
  253. irowno = gridView.GetRowCellValue(i, coirowno).ToString();
  254. }
  255. }
  256. GetSearchData(cCode, irowno);
  257. }
  258. catch (Exception ex)
  259. {
  260. ICSBaseSimpleCode.AppshowMessageBox(ex.ToString());
  261. }
  262. }
  263. #endregion
  264. private void GetSearchData(string cCode, string irowno)
  265. {
  266. DataSet ds = ICSPOArriveBLL.SearchData(cCode, irowno, AppConfig.AppConnectString);
  267. if (ds != null && ds.Tables.Count > 0)
  268. {
  269. Serialdata = ds.Tables[0];
  270. grdDetail.DataSource = Serialdata;
  271. grvDetail.BestFitColumns();
  272. rptPage.RecordNum = Serialdata.Rows.Count;
  273. rptPage.PageSize = 499;
  274. rptPage.PageIndex = 1;
  275. rptPage.ReLoad();
  276. rptPage.PageSize = 500;
  277. rptPage.PageIndex = 1;
  278. rptPage.ReLoad();
  279. rptPage_PageIndexChanged(null, null);
  280. }
  281. }
  282. #region 列表
  283. private void grvDetail_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
  284. {
  285. if (e.Info.IsRowIndicator && e.RowHandle >= 0)
  286. e.Info.DisplayText = (e.RowHandle + 1).ToString();
  287. }
  288. private void gridView_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
  289. {
  290. if (e.Info.IsRowIndicator && e.RowHandle >= 0)
  291. e.Info.DisplayText = (e.RowHandle + 1).ToString();
  292. }
  293. #endregion
  294. #region 分页
  295. private void rptPage_PageIndexChanged(object Sender, EventArgs e)
  296. {
  297. DataTable data = AppConfig.GetPageData(Serialdata, rptPage.PageIndex, rptPage.PageSize).Copy();
  298. grdDetail.DataSource = data;
  299. }
  300. #endregion
  301. #region 生成条码
  302. private void btnCreate_Click(object sender, EventArgs e)
  303. {
  304. try
  305. {
  306. SimpleButton btntemp = (SimpleButton)sender;
  307. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  308. {
  309. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  310. return;
  311. }
  312. int count = 0;
  313. string cCode = "";
  314. string irowno = "";
  315. string cInvCode = "";
  316. string Batch = "";
  317. for (int i = 0; i < gridView.RowCount; i++)
  318. {
  319. if (gridView.GetRowCellValue(i, coSelect).ToString() == "Y")
  320. {
  321. count++;
  322. cCode = gridView.GetRowCellValue(i, cocCode).ToString();
  323. irowno = gridView.GetRowCellValue(i, coirowno).ToString();
  324. cInvCode = gridView.GetRowCellValue(i, cocInvCode).ToString();
  325. Batch = gridView.GetRowCellValue(i, coBatch).ToString();
  326. if (gridView.GetRowCellValue(i, colHasQty).ToString() != "")
  327. {
  328. if (decimal.Parse(gridView.GetRowCellValue(i, coiQuantity).ToString()) <= decimal.Parse(gridView.GetRowCellValue(i, colHasQty).ToString()))
  329. {
  330. ICSBaseSimpleCode.AppshowMessageBox("所选到货单行号条码数量已经全部生成,请确认");
  331. return;
  332. }
  333. }
  334. }
  335. }
  336. if (count != 1)
  337. {
  338. ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  339. return;
  340. }
  341. FormICSPOArriveLOTCreate From = new FormICSPOArriveLOTCreate(cCode, irowno, cInvCode, Batch);
  342. From.ShowDialog();
  343. try
  344. {
  345. DataSet ds = ICSPOArriveBLL.SearchData(cCode, irowno, AppConfig.AppConnectString);
  346. if (ds != null && ds.Tables.Count > 0)
  347. {
  348. Serialdata = ds.Tables[0];
  349. grdDetail.DataSource = Serialdata;
  350. grvDetail.BestFitColumns();
  351. rptPage.RecordNum = Serialdata.Rows.Count;
  352. rptPage.PageSize = 499;
  353. rptPage.PageIndex = 1;
  354. rptPage.ReLoad();
  355. rptPage.PageSize = 500;
  356. rptPage.PageIndex = 1;
  357. rptPage.ReLoad();
  358. rptPage_PageIndexChanged(null, null);
  359. }
  360. }
  361. catch (Exception ex)
  362. {
  363. ICSBaseSimpleCode.AppshowMessageBox(ex.ToString());
  364. }
  365. #region
  366. if (ICSBaseSimpleCode.AppshowMessageBoxRepose("是否打印?") == DialogResult.OK)
  367. {
  368. btnPrint_Click(null, null);
  369. }
  370. #endregion
  371. }
  372. catch (Exception ex)
  373. {
  374. ICSBaseSimpleCode.AppshowMessageBox(ex.ToString());
  375. }
  376. }
  377. #endregion
  378. #region CustomDrawCell
  379. private void grvDetail_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
  380. {
  381. if (e.RowHandle >= 0 && e.Column.FieldName == "DCTCODE")
  382. {
  383. e.CellValue = "cccc";
  384. }
  385. }
  386. private void gridView_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
  387. {
  388. if (e.RowHandle >= 0 && e.Column.FieldName == "DCTCODE")
  389. {
  390. e.CellValue = "cccc";
  391. }
  392. }
  393. #endregion
  394. #region 删除条码信息
  395. private void btnDel_Click(object sender, EventArgs e)
  396. {
  397. SimpleButton btntemp = (SimpleButton)sender;
  398. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  399. {
  400. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  401. return;
  402. }
  403. List<string> rcardList = new List<string>();
  404. for (int i = 0; i < grvDetail.RowCount; i++)
  405. {
  406. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y" && grvDetail.GetRowCellValue(i, colisInput).ToString() == "False")
  407. {
  408. rcardList.Add(grvDetail.GetRowCellValue(i, colID).ToString());
  409. }
  410. }
  411. if (rcardList.Count == 0 || rcardList == null)
  412. {
  413. ICSBaseSimpleCode.AppshowMessageBox("请选择数据");
  414. return;
  415. }
  416. if (ICSBaseSimpleCode.AppshowMessageBoxRepose("确定删除序列号吗?删除后无法恢复,确定吗?") != DialogResult.OK)
  417. {
  418. btnCancelAll_Click(sender, e);
  419. return;
  420. }
  421. try
  422. {
  423. ICSPOArriveBLL.deleteInfo(rcardList, AppConfig.AppConnectString);
  424. ICSBaseSimpleCode.AppshowMessageBox("删除成功");
  425. string cCode = "";
  426. string irowno = "";
  427. for (int i = 0; i < gridView.RowCount; i++)
  428. {
  429. if (gridView.GetRowCellValue(i, coSelect).ToString() == "Y")
  430. {
  431. cCode = gridView.GetRowCellValue(i, cocCode).ToString();
  432. irowno = gridView.GetRowCellValue(i, coirowno).ToString();
  433. }
  434. }
  435. GetSearchData(cCode, irowno);
  436. //Refresh();
  437. }
  438. catch (Exception ex)
  439. {
  440. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  441. }
  442. }
  443. #endregion
  444. #region 打印
  445. private void btnPrint_Click(object sender, EventArgs e)
  446. {
  447. try
  448. {
  449. if (sender != null)
  450. {
  451. SimpleButton btntemp = (SimpleButton)sender;
  452. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  453. {
  454. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  455. return;
  456. }
  457. }
  458. List<PrintPara> parasList = new List<PrintPara>();
  459. List<ICSITEMLot> InfoList = new List<ICSITEMLot>();
  460. for (int i = 0; i < grvDetail.RowCount; i++)
  461. {
  462. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  463. {
  464. PrintPara para = new PrintPara();
  465. para.PrintKey = "LotNO";
  466. para.PrintValues = new object[] { grvDetail.GetRowCellValue(i, colLotNO).ToString() };
  467. parasList.Add(para);
  468. ICSITEMLot Info = new ICSITEMLot();
  469. Info.LotNO = grvDetail.GetRowCellValue(i, colLotNO).ToString();
  470. Info.lastPrintUSERID = AppConfig.UserId;
  471. Info.lastPrintTime = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss");
  472. Info.WorkPoint = AppConfig.WorkPointCode;
  473. InfoList.Add(Info);
  474. }
  475. }
  476. if (parasList.Count == 0)
  477. {
  478. ICSBaseSimpleCode.AppshowMessageBox("请选择数据!");
  479. return;
  480. }
  481. #region 修改打印模板逻辑
  482. FormPrintDialog f = new FormPrintDialog("001", this.Text, parasList, false, null);
  483. f.ShowDialog();
  484. #endregion
  485. //更新打印信息
  486. FormICSPurchaseLOTBLL.updatePrint(InfoList, AppConfig.AppConnectString);
  487. }
  488. catch (Exception ex)
  489. {
  490. MessageBox.Show(ex.ToString());
  491. }
  492. }
  493. #endregion
  494. private void btnUpLoad_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  495. {
  496. try
  497. {
  498. OpenFileDialog openFileDialog1 = new OpenFileDialog(); //显示选择文件对话框
  499. openFileDialog1.InitialDirectory = "c:\\";
  500. openFileDialog1.Filter = "pdf files (*.pdf)|*.pdf"; //所有的文件格式
  501. openFileDialog1.FilterIndex = 2;
  502. openFileDialog1.RestoreDirectory = true;
  503. string a = "";
  504. if (openFileDialog1.ShowDialog() == DialogResult.OK)
  505. {
  506. a = openFileDialog1.FileName; //显示文件路径
  507. }
  508. else
  509. return;
  510. string connectionString = AppConfig.GetDataBaseConnectStringByKey("[DB.FTP]");
  511. string[] ftps = connectionString.Split(';');
  512. string ftpServerIP = ftps[0].Split('=')[1];
  513. string ftpRemotePath = ftps[1].Split('=')[1];
  514. string ftpUserID = ftps[2].Split('=')[1];
  515. string ftpPassword = ftps[3].Split('=')[1];
  516. FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword);
  517. try
  518. {
  519. ftpWeb.Upload(a, grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, coERPAutoid).ToString(), grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, coERPAutoid).ToString());
  520. }
  521. catch (Exception ex)
  522. {
  523. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  524. }
  525. ICSBaseSimpleCode.AppshowMessageBox("图片上传成功 !");
  526. }
  527. catch (Exception ex)
  528. {
  529. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  530. }
  531. }
  532. private void btnDownLoad_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  533. {
  534. #region 下载逻辑
  535. string connectionString = AppConfig.GetDataBaseConnectStringByKey("[DB.FTP]");
  536. string[] ftps = connectionString.Split(';');
  537. string ftpServerIP = ftps[0].Split('=')[1];
  538. string ftpRemotePath = ftps[1].Split('=')[1];
  539. string ftpUserID = ftps[2].Split('=')[1];
  540. string ftpPassword = ftps[3].Split('=')[1];
  541. FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword);
  542. if (grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, coERPAutoid).ToString() == "")
  543. {
  544. ICSBaseSimpleCode.AppshowMessageBox("无追溯号,无法查看!");
  545. return;
  546. }
  547. try
  548. {
  549. string ftpURL = "ftp://" + ftpServerIP + "/" + ftpRemotePath + "/" + grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, coERPAutoid).ToString() + "/";
  550. if (string.IsNullOrEmpty(ftpURL))
  551. {
  552. ICSBaseSimpleCode.AppshowMessageBox("暂无文档!");
  553. return;
  554. }
  555. #region
  556. //RegistryKey folders;
  557. //folders = OpenRegistryPath(Registry.CurrentUser, @"/software/microsoft/windows/currentversion/explorer/shell folders");
  558. //string desktopPath = folders.GetValue("Desktop").ToString();
  559. //string filePath = desktopPath + "DE_DOCUMENTS";
  560. #endregion
  561. string path = System.Windows.Forms.Application.StartupPath + @"\PDF";
  562. DirectoryInfo directoryInfo = new DirectoryInfo(path);
  563. if (!Directory.Exists(path))
  564. {
  565. Directory.CreateDirectory(path);
  566. }
  567. #region 现逻辑
  568. string filePaths = path + @"\" + grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, coERPAutoid).ToString() + ".pdf";
  569. ftpWeb.Download(path, grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, coERPAutoid).ToString() + ".pdf", grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, coERPAutoid).ToString());
  570. //string filePaths = @"C:\Users\Administrator.UX7663JVU2X64C5\Desktop\123.pdf";
  571. AxAcroPDFLib.AxAcroPDF axAcroPDF = new AxAcroPDFLib.AxAcroPDF();
  572. ((System.ComponentModel.ISupportInitialize)(axAcroPDF)).BeginInit();
  573. axAcroPDF.Dock = DockStyle.Fill;
  574. this.Controls.Add(axAcroPDF);
  575. axAcroPDF.Location = new System.Drawing.Point(0, 24);
  576. ((System.ComponentModel.ISupportInitialize)(axAcroPDF)).EndInit();
  577. axAcroPDF.LoadFile(filePaths);
  578. axAcroPDF.setShowToolbar(true);
  579. axAcroPDF.setPageMode("thumbs");
  580. axAcroPDF.setPageMode("none");
  581. axAcroPDF.Show();
  582. System.Diagnostics.Process.Start(filePaths);
  583. #endregion
  584. #region 原逻辑
  585. //ftpWeb.Download(desktopPath, model.tFile, grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colTraceNO).ToString());
  586. //ICSIQCLoadBLL.AddEdit(model, "下载", AppConfig.AppConnectString);
  587. ////ICSBaseSimpleCode.AppshowMessageBox("下载成功 !");
  588. //System.Diagnostics.Process.Start(desktopPath + model.tFile);
  589. #endregion
  590. }
  591. catch (Exception ex)
  592. {
  593. throw new Exception(ex.Message);
  594. }
  595. #endregion
  596. }
  597. private void FormICSPOArriveLOT_Load(object sender, EventArgs e)
  598. {
  599. btnFilter_Click(sender, e);
  600. }
  601. private void Refresh()
  602. {
  603. if (sqlconn == null || sqlconn == "")
  604. {
  605. return;
  606. }
  607. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在查找...请稍等...");
  608. try
  609. {
  610. _wait.Show();
  611. FormFilter filter = new FormFilter(AppConfig.GetSourceId(this.Tag.ToString(), btnConfig.Name), false);
  612. filter.OldTempTableName = tempTableName;
  613. //tempTableName = filter.NewTempTableName;
  614. //DataTable data = DBHelper.ExecuteDataset(AppConfig.FrameConnectString, CommandType.Text, "select * from " + tempTableName).Tables[0];
  615. dataSource = DBHelper.ExecuteDataset(sqlconn, CommandType.Text, sqltxt).Tables[0];
  616. gridControl.DataSource = dataSource;
  617. gridView.BestFitColumns();
  618. rptPage.RecordNum = dataSource.Rows.Count;
  619. rptPage.PageIndex = 1;
  620. rptPage.ReLoad();
  621. _wait.Close();
  622. }
  623. catch (Exception ex)
  624. {
  625. MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  626. _wait.Close();
  627. }
  628. }
  629. private void btnSelAll_Click(object sender, EventArgs e)
  630. {
  631. grvDetail.PostEditor();
  632. this.Validate();
  633. for (int i = 0; i < gridView.RowCount; i++)
  634. {
  635. gridView.SetRowCellValue(i, coSelect, "Y");
  636. }
  637. }
  638. private void btnDelAll_Click(object sender, EventArgs e)
  639. {
  640. grvDetail.PostEditor();
  641. this.Validate();
  642. for (int i = 0; i < gridView.RowCount; i++)
  643. {
  644. gridView.SetRowCellValue(i, coSelect, "");
  645. }
  646. }
  647. private void btnAllCreate_Click(object sender, EventArgs e)
  648. {
  649. Serialdata = new DataTable();
  650. string INVCLASS = "";
  651. string cCode = "";
  652. for (int i = 0; i < gridView.RowCount; i++)
  653. {
  654. if (gridView.GetRowCellValue(i, coSelect).ToString() == "Y")
  655. {
  656. if (INVCLASS == "")
  657. {
  658. INVCLASS = gridView.GetRowCellValue(i, colINVCLASS).ToString();
  659. cCode = gridView.GetRowCellValue(i, cocCode).ToString();
  660. }
  661. else
  662. {
  663. if (INVCLASS != gridView.GetRowCellValue(i, colINVCLASS).ToString())
  664. {
  665. ICSBaseSimpleCode.AppshowMessageBox("物料大类不一致,不能同时生成");
  666. return;
  667. }
  668. if (cCode != gridView.GetRowCellValue(i, cocCode).ToString())
  669. {
  670. ICSBaseSimpleCode.AppshowMessageBox("到货单号不一致,不能同时生成");
  671. return;
  672. }
  673. }
  674. }
  675. }
  676. #region 判断是否要有供应商炉批号
  677. DataTable dts = ICSPOArriveBLL.GetVenBatch(INVCLASS, AppConfig.WorkPointCode, AppConfig.AppConnectString);
  678. if (dts != null && dts.Rows.Count > 0)
  679. {
  680. isVenBatch = true;
  681. }
  682. else
  683. {
  684. isVenBatch = false;
  685. }
  686. #endregion
  687. string VenBatch = "";
  688. if (isVenBatch)
  689. {
  690. FormICSPOArriveLOTAllCreate add = new FormICSPOArriveLOTAllCreate();
  691. add.ShowDialog();
  692. if (add.DialogResult == DialogResult.OK)
  693. {
  694. if (add.VenBatch == "")
  695. {
  696. ICSBaseSimpleCode.AppshowMessageBox("供应商炉批号不能为空");
  697. return;
  698. }
  699. VenBatch = add.VenBatch;
  700. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在生成条码……");
  701. List<ICSITEMLot> InfoList = new List<ICSITEMLot>();
  702. try
  703. {
  704. for (int i = 0; i < gridView.RowCount; i++)
  705. {
  706. int Num = 0;
  707. if (gridView.GetRowCellValue(i, coSelect).ToString() == "Y")
  708. {
  709. Num++;
  710. string Code = gridView.GetRowCellValue(i, cocCode).ToString();
  711. string rowno = gridView.GetRowCellValue(i, coirowno).ToString();
  712. FormICSRdrecord2LOTUIModelX RecInfo = ICSPOArriveBLL.Search_Info(Code, rowno, AppConfig.AppConnectString);
  713. string LotNO = "";
  714. if (RecInfo == null)
  715. {
  716. ICSBaseSimpleCode.AppshowMessageBox("到货单信息取得失败");
  717. return;
  718. }
  719. _wait.Show();
  720. int count = Convert.ToInt32(RecInfo.MaxNo);
  721. DateTime time = DateTime.Now;
  722. string timeStr = time.ToString("yyMMdd");
  723. int NO = 0;
  724. string subTime = "7" + time.ToString("yyyyMMdd");
  725. string sql = @"SELECT MAX(A.LotNO) AS LOTNO FROM ICSITEMLot A WHERE 1=1 AND A.LotNO LIKE '{0}%' ";
  726. sql = string.Format(sql, subTime);
  727. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  728. if (dt != null && dt.Rows.Count > 0 && !string.IsNullOrEmpty(dt.Rows[0]["LotNO"].ToString()))
  729. {
  730. LotNO = dt.Rows[0]["LOTNO"].ToString();
  731. NO = int.Parse(LotNO.Substring(LotNO.Length - 4, 4));
  732. }
  733. _wait.Caption = "正在生成条码……" + " " + i.ToString() + "/" + Num.ToString();
  734. _wait.Refresh();
  735. ICSITEMLot Info = new ICSITEMLot();
  736. Info.ID = "";
  737. Info.LOTQTY = RecInfo.Arr.iQuantity;
  738. Info.LotNO = subTime + (NO + i + 1).ToString().PadLeft(4, '0');
  739. Info.ItemCode = RecInfo.Arr.cInvCode;
  740. if (RecInfo.icsitems == null)
  741. {
  742. Info.TransNO = RecInfo.Arr.cCode;
  743. }
  744. else
  745. {
  746. Info.TransNO = RecInfo.icsitems.TransNO;
  747. }
  748. if (RecInfo.icsitems == null)
  749. {
  750. Info.TransLine = RecInfo.Arr.irowno.ToString();
  751. }
  752. else
  753. {
  754. Info.TransLine = RecInfo.icsitems.TransLine;
  755. }
  756. Info.VenderLotNO = RecInfo.Arr.Batch;
  757. Info.PRODUCTDATE = time;
  758. Info.ACTIVE = "Y";
  759. Info.Exdate = Convert.ToDateTime("2999-12-31");
  760. Info.TYPE = "到货";
  761. Info.VenBatch = VenBatch;
  762. if (isCheck)
  763. {
  764. Info.EATTRIBUTE2 = "合格";
  765. Info.EATTRIBUTE5 = "已检";
  766. }
  767. else
  768. {
  769. Info.EATTRIBUTE2 = "";
  770. }
  771. if (RecInfo.Arr.iNum == 0)
  772. {
  773. Info.EATTRIBUTE3 = 0;
  774. }
  775. else
  776. {
  777. Info.EATTRIBUTE3 = RecInfo.Arr.iNum / RecInfo.Arr.iQuantity;
  778. }
  779. InfoList.Add(Info);
  780. }
  781. }
  782. ICSPOArriveBLL.Add(InfoList, AppConfig.AppConnectString);
  783. _wait.Close();
  784. for (int i = 0; i < gridView.RowCount; i++)
  785. {
  786. if (gridView.GetRowCellValue(i, coSelect).ToString() == "Y")
  787. {
  788. DataSet ds = ICSPOArriveBLL.SearchData(gridView.GetRowCellValue(i, cocCode).ToString(), gridView.GetRowCellValue(i, coirowno).ToString(), AppConfig.AppConnectString);
  789. if (ds != null && ds.Tables.Count > 0)
  790. {
  791. Serialdata.Merge(ds.Tables[0]);
  792. }
  793. }
  794. }
  795. grdDetail.DataSource = Serialdata;
  796. AppConfig.BindCustomDrawRowIndicator(grvDetail);
  797. //grvDetail.BestFitColumns();
  798. rptPage.RecordNum = Serialdata.Rows.Count;
  799. rptPage.PageSize = 499;
  800. rptPage.PageIndex = 1;
  801. rptPage.ReLoad();
  802. rptPage.PageSize = 500;
  803. rptPage.PageIndex = 1;
  804. rptPage.ReLoad();
  805. rptPage_PageIndexChanged(null, null);
  806. }
  807. catch (Exception ex)
  808. {
  809. _wait.Close();
  810. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  811. }
  812. }
  813. }
  814. else
  815. {
  816. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在生成条码……");
  817. List<ICSITEMLot> InfoList = new List<ICSITEMLot>();
  818. try
  819. {
  820. for (int i = 0; i < gridView.RowCount; i++)
  821. {
  822. int Num = 0;
  823. if (gridView.GetRowCellValue(i, coSelect).ToString() == "Y")
  824. {
  825. Num++;
  826. string Code = gridView.GetRowCellValue(i, cocCode).ToString();
  827. string rowno = gridView.GetRowCellValue(i, coirowno).ToString();
  828. FormICSRdrecord2LOTUIModelX RecInfo = ICSPOArriveBLL.Search_Info(Code, rowno, AppConfig.AppConnectString);
  829. string LotNO = "";
  830. if (RecInfo == null)
  831. {
  832. ICSBaseSimpleCode.AppshowMessageBox("到货单信息取得失败");
  833. return;
  834. }
  835. _wait.Show();
  836. int count = Convert.ToInt32(RecInfo.MaxNo);
  837. DateTime time = DateTime.Now;
  838. string timeStr = time.ToString("yyMMdd");
  839. int NO = 0;
  840. string subTime = "7" + time.ToString("yyyyMMdd");
  841. string sql = @"SELECT MAX(A.LotNO) AS LOTNO FROM ICSITEMLot A WHERE 1=1 AND A.LotNO LIKE '{0}%' ";
  842. sql = string.Format(sql, subTime);
  843. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  844. if (dt != null && dt.Rows.Count > 0 && !string.IsNullOrEmpty(dt.Rows[0]["LotNO"].ToString()))
  845. {
  846. LotNO = dt.Rows[0]["LOTNO"].ToString();
  847. NO = int.Parse(LotNO.Substring(LotNO.Length - 4, 4));
  848. }
  849. _wait.Caption = "正在生成条码……" + " " + i.ToString() + "/" + Num.ToString();
  850. _wait.Refresh();
  851. ICSITEMLot Info = new ICSITEMLot();
  852. Info.ID = "";
  853. Info.LOTQTY = RecInfo.Arr.iQuantity;
  854. Info.LotNO = subTime + (NO + i + 1).ToString().PadLeft(4, '0');
  855. Info.ItemCode = RecInfo.Arr.cInvCode;
  856. if (RecInfo.icsitems == null)
  857. {
  858. Info.TransNO = RecInfo.Arr.cCode;
  859. }
  860. else
  861. {
  862. Info.TransNO = RecInfo.icsitems.TransNO;
  863. }
  864. if (RecInfo.icsitems == null)
  865. {
  866. Info.TransLine = RecInfo.Arr.irowno.ToString();
  867. }
  868. else
  869. {
  870. Info.TransLine = RecInfo.icsitems.TransLine;
  871. }
  872. Info.VenderLotNO = RecInfo.Arr.Batch;
  873. Info.PRODUCTDATE = time;
  874. Info.ACTIVE = "Y";
  875. Info.Exdate = Convert.ToDateTime("2999-12-31");
  876. Info.TYPE = "到货";
  877. Info.VenBatch = VenBatch;
  878. if (isCheck)
  879. {
  880. Info.EATTRIBUTE2 = "合格";
  881. Info.EATTRIBUTE5 = "已检";
  882. }
  883. else
  884. {
  885. Info.EATTRIBUTE2 = "";
  886. }
  887. if (RecInfo.Arr.iNum == 0)
  888. {
  889. Info.EATTRIBUTE3 = 0;
  890. }
  891. else
  892. {
  893. Info.EATTRIBUTE3 = RecInfo.Arr.iNum / RecInfo.Arr.iQuantity;
  894. }
  895. InfoList.Add(Info);
  896. }
  897. }
  898. ICSPOArriveBLL.Add(InfoList, AppConfig.AppConnectString);
  899. _wait.Close();
  900. for (int i = 0; i < gridView.RowCount; i++)
  901. {
  902. if (gridView.GetRowCellValue(i, coSelect).ToString() == "Y")
  903. {
  904. DataSet ds = ICSPOArriveBLL.SearchData(gridView.GetRowCellValue(i, cocCode).ToString(), gridView.GetRowCellValue(i, coirowno).ToString(), AppConfig.AppConnectString);
  905. if (ds != null && ds.Tables.Count > 0)
  906. {
  907. Serialdata.Merge(ds.Tables[0]);
  908. }
  909. }
  910. }
  911. grdDetail.DataSource = Serialdata;
  912. AppConfig.BindCustomDrawRowIndicator(grvDetail);
  913. //grvDetail.BestFitColumns();
  914. rptPage.RecordNum = Serialdata.Rows.Count;
  915. rptPage.PageSize = 499;
  916. rptPage.PageIndex = 1;
  917. rptPage.ReLoad();
  918. rptPage.PageSize = 500;
  919. rptPage.PageIndex = 1;
  920. rptPage.ReLoad();
  921. rptPage_PageIndexChanged(null, null);
  922. }
  923. catch (Exception ex)
  924. {
  925. _wait.Close();
  926. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  927. }
  928. }
  929. }
  930. private void CheckData(string cInvCode)
  931. {
  932. #region 判断是否要有批次号
  933. DataTable dt = ICSPOArriveBLL.GetBatch(cInvCode, AppConfig.WorkPointCode, AppConfig.AppConnectString);
  934. if (dt != null && dt.Rows.Count > 0)
  935. {
  936. if (dt.Rows[0]["INVCONTROLTYPE"].ToString().Trim().ToUpper() == "TRUE")
  937. {
  938. isBatch = true;
  939. }
  940. }
  941. else
  942. {
  943. throw new Exception("物料存货信息取得失败");
  944. }
  945. #endregion
  946. #region 判断是否要有供应商炉批号
  947. dt = ICSPOArriveBLL.GetVen(cInvCode, AppConfig.WorkPointCode, AppConfig.AppConnectString);
  948. if (dt != null && dt.Rows.Count > 0)
  949. {
  950. isVenBatch = true;
  951. }
  952. else
  953. {
  954. isVenBatch = false;
  955. }
  956. #endregion
  957. #region //判断是否需要检验
  958. dt = ICSPOArriveBLL.GetCheck(cInvCode, AppConfig.WorkPointCode, AppConfig.AppConnectString);
  959. if (dt != null && dt.Rows.Count > 0)
  960. {
  961. isCheck = true;
  962. }
  963. #endregion
  964. }
  965. }
  966. }