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

834 lines
32 KiB

5 months ago
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using DevExpress.XtraEditors;
  9. using ICSSoft.Base.Language.Tool;
  10. using ICSSoft.Base.UserControl.MessageControl;
  11. using ICSSoft.Base.Config.AppConfig;
  12. using ICSSoft.Base.Config.DBHelper;
  13. using ICSSoft.Base.Report.Filter;
  14. using ICSSoft.Base.UserControl.FormControl;
  15. using ICSSoft.Base.Lable.PrintTool;
  16. using System.Linq;
  17. using System.Data.Linq;
  18. using DevExpress.XtraGrid.Views.Grid;
  19. using ICSSoft.Base.ReferForm.AppReferForm;
  20. using ICSSoft.Frame.APP;
  21. using ICSSoft.Frame.Data.BLL;
  22. using ICSSoft.Frame.Data.Entity;
  23. namespace ICSSoft.Frame.APP
  24. {
  25. public partial class FormStockBarCode : DevExpress.XtraEditors.XtraForm
  26. {
  27. #region private参数
  28. private string sqltxt = "";
  29. private string sqlconn = "";
  30. private DataTable dataSource = null;
  31. #endregion
  32. #region 构造函数
  33. public FormStockBarCode()
  34. {
  35. InitializeComponent();
  36. this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  37. this.WindowState = FormWindowState.Maximized;
  38. //grvDetail.OptionsView.ShowIndicator = false;
  39. //grvDetail.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.None;
  40. //grvDetail.OptionsSelection.EnableAppearanceFocusedCell = false;
  41. //grvDetail.OptionsSelection.EnableAppearanceFocusedRow = false;
  42. //grvDetail.OptionsSelection.EnableAppearanceHideSelection = false;
  43. }
  44. private void gridView1_CustomDrawRowIndicator(object sender, RowIndicatorCustomDrawEventArgs e)
  45. {
  46. e.Info.ImageIndex = -1;
  47. }
  48. #endregion
  49. #region SystemOptition
  50. /// <summary>
  51. /// 操作权限
  52. /// </summary>
  53. /// <returns></returns>
  54. public DataTable RightOfExute()
  55. {
  56. DataTable rData = new DataTable();
  57. rData.Columns.Add("BtnName");
  58. rData.Columns.Add("ActionName");
  59. //查看权限(必须有)
  60. DataRow seeRow = rData.NewRow();
  61. seeRow["BtnName"] = "see";
  62. seeRow["ActionName"] = "查看";
  63. rData.Rows.Add(seeRow);
  64. List<Control> ControlList = new List<Control>();
  65. ControlList.Add(btnAdd);
  66. ControlList.Add(btnDel);
  67. ControlList.Add(btnExport);
  68. ControlList.Add(btnPrintOne);
  69. foreach (Control ctr in ControlList)
  70. {
  71. if (ctr.GetType() == typeof(SimpleButton))
  72. {
  73. DataRow dr = rData.NewRow();
  74. dr["BtnName"] = ctr.Name;
  75. dr["ActionName"] = ctr.Text;
  76. rData.Rows.Add(dr);
  77. }
  78. }
  79. rData.AcceptChanges();
  80. return rData;
  81. }
  82. /// <summary>
  83. /// 数据权限
  84. /// </summary>
  85. /// <returns></returns>
  86. public DataTable RightOfData()
  87. {
  88. DataTable rData = new DataTable();
  89. rData.Columns.Add("BodyName");
  90. rData.Columns.Add("ControlName");
  91. rData.Columns.Add("ControlCaption");
  92. rData.AcceptChanges();
  93. return rData;
  94. }
  95. #region 移动窗体
  96. private const int WM_NCHITTEST = 0x84;
  97. private const int HTCLIENT = 0x1;
  98. private const int HTCAPTION = 0x2;
  99. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  100. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  101. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  102. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  103. //重写窗体,使窗体可以不通过自带标题栏实现移动
  104. protected override void WndProc(ref Message m)
  105. {
  106. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  107. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  108. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  109. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  110. switch (m.Msg)
  111. {
  112. case WM_NCHITTEST:
  113. base.WndProc(ref m);
  114. if ((int)m.Result == HTCLIENT)
  115. m.Result = (IntPtr)HTCAPTION;
  116. return;
  117. }
  118. //拦截双击标题栏、移动窗体的系统消息
  119. if (m.Msg != 0xA3)
  120. {
  121. base.WndProc(ref m);
  122. }
  123. }
  124. #endregion
  125. protected override void OnCreateControl()
  126. {
  127. base.OnCreateControl();
  128. }
  129. private void btnExport_Click(object sender, EventArgs e)
  130. {
  131. SimpleButton btntemp = (SimpleButton)sender;
  132. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  133. {
  134. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  135. return;
  136. }
  137. FormOutExcel foe = new FormOutExcel(this.Tag.ToString(), grdDetail);
  138. foe.ShowDialog();
  139. }
  140. private void btnClose_Click(object sender, EventArgs e)
  141. {
  142. this.DialogResult = DialogResult.Cancel;
  143. this.Close();
  144. }
  145. private void btnExit_Click(object sender, EventArgs e)
  146. {
  147. this.Close();
  148. }
  149. private string tempTableName = "";
  150. private void btnFilter_Click(object sender, EventArgs e)
  151. {
  152. FormFilter filter = new FormFilter(AppConfig.GetSourceId(this.Tag.ToString(), btnDataConfig.Name));
  153. filter.OldTempTableName = tempTableName;
  154. if (filter.ShowDialog() == DialogResult.OK)
  155. {
  156. try
  157. {
  158. tempTableName = filter.NewTempTableName;
  159. sqltxt = filter.SqlText;
  160. sqlconn = filter.FilterConnectString;
  161. dataSource = filter.FilterData.Tables[0];
  162. grdDetail.DataSource = dataSource;
  163. grvDetail.BestFitColumns();
  164. rptPage.RecordNum = dataSource.Rows.Count;
  165. rptPage.PageSize = 499;
  166. rptPage.PageIndex = 1;
  167. rptPage.ReLoad();
  168. rptPage.PageSize = 500;
  169. rptPage.PageIndex = 1;
  170. rptPage.ReLoad();
  171. }
  172. catch (Exception ex)
  173. {
  174. ICSBaseSimpleCode.AppshowMessageBox(1, ex.Message);
  175. }
  176. }
  177. }
  178. private void btnflash_Click(object sender, EventArgs e)
  179. {
  180. if (sqlconn == null || sqlconn == "")
  181. {
  182. return;
  183. }
  184. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在刷新数据...请稍等...");
  185. try
  186. {
  187. _wait.Show();
  188. FormFilter filter = new FormFilter(AppConfig.GetSourceId(this.Tag.ToString(), btnDataConfig.Name), false);
  189. dataSource = DBHelper.ExecuteDataset(sqlconn, CommandType.Text, sqltxt).Tables[0];
  190. grdDetail.DataSource = dataSource;
  191. grvDetail.BestFitColumns();
  192. rptPage.RecordNum = dataSource.Rows.Count;
  193. rptPage.PageIndex = 1;
  194. rptPage.ReLoad();
  195. _wait.Close();
  196. }
  197. catch (Exception ex)
  198. {
  199. _wait.Close();
  200. ICSBaseSimpleCode.AppshowMessageBox(1, ex.Message);
  201. }
  202. }
  203. private void grvDetail_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
  204. {
  205. if (e.Info.IsRowIndicator && e.RowHandle >= 0)
  206. e.Info.DisplayText = (e.RowHandle + 1).ToString();
  207. }
  208. private void btnDataConfig_Click(object sender, EventArgs e)
  209. {
  210. if (AppConfig.UserCode.ToLower() != "demo")
  211. {
  212. ICSBaseSimpleCode.AppshowMessageBox("您没有权限设置数据源,请联系软件提供商!");
  213. return;
  214. }
  215. FormDataSource fdata = new FormDataSource(AppConfig.GetMenuId(this.Tag.ToString()), btnDataConfig.Name);
  216. fdata.ShowDialog();
  217. }
  218. #region selectAll And selectCancle
  219. private void btnSelectAll_Click(object sender, EventArgs e)
  220. {
  221. for (int i = 0; i < grvDetail.RowCount; i++)
  222. {
  223. grvDetail.SetRowCellValue(i, colSelect, "Y");
  224. }
  225. }
  226. private void btncancleAll_Click(object sender, EventArgs e)
  227. {
  228. for (int i = 0; i < grvDetail.RowCount; i++)
  229. {
  230. grvDetail.SetRowCellValue(i, colSelect, "");
  231. }
  232. }
  233. #endregion
  234. #region delete
  235. private void btnDel_Click(object sender, EventArgs e)
  236. {
  237. SimpleButton btntemp = (SimpleButton)sender;
  238. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  239. {
  240. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  241. return;
  242. }
  243. grvDetail.PostEditor();
  244. this.Validate();
  245. List<string> guidList = new List<string>();
  246. for (int i = 0; i < grvDetail.RowCount; i++)
  247. {
  248. if (grvDetail.GetRowCellValue(i, colSelect).ToString() == "Y")
  249. {
  250. string barCode = grvDetail.GetRowCellValue(i, LotNO).ToString();
  251. guidList.Add(barCode);
  252. }
  253. }
  254. if (guidList.Count == 0)
  255. {
  256. ICSBaseSimpleCode.AppshowMessageBox("请选择数据!");
  257. return;
  258. }
  259. if (ICSBaseSimpleCode.AppshowMessageBoxRepose("确定要删除选择的数据吗?") != DialogResult.OK)
  260. {
  261. return;
  262. }
  263. List<string> failDel = new List<string>();
  264. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在删除箱号条码...请稍候...");
  265. try
  266. {
  267. _wait.Show();
  268. ICSStockBarCodeBLL.delete(guidList, AppConfig.AppConnectString.ToString());
  269. _wait.Close();
  270. ICSBaseSimpleCode.AppshowMessageBox("删除成功");
  271. btnflash_Click(null, null);
  272. }
  273. catch (Exception ex)
  274. {
  275. _wait.Close();
  276. Application.DoEvents();
  277. ICSBaseSimpleCode.AppshowMessageBox(1, ex.Message);
  278. }
  279. }
  280. #endregion
  281. #region print
  282. private void btnPrint_Click(object sender, EventArgs e)
  283. {
  284. SimpleButton btntemp = (SimpleButton)sender;
  285. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  286. {
  287. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  288. return;
  289. }
  290. string batch = "";
  291. string sql = @"SELECT BatchCode AS 批次,ItemCode AS 存货编码,ItemName AS 存货名称,
  292. ItemStd AS ,PackedQuantity AS ,cComUnitCode AS
  293. ,IsPrint as
  294. FROM dbo.ICSItemLot WHERE BatchCode IN (SELECT DISTINCT BatchCode FROM dbo.ICSCarton)
  295. ";
  296. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  297. FormDataRefer reForm = new FormDataRefer();
  298. reForm.FormTitle = "打印批次列表";
  299. DataTable menuData = data;
  300. reForm.DataSource = menuData;
  301. reForm.MSelectFlag = false;
  302. reForm.RowIndexWidth = 35;
  303. reForm.FormWidth = 500;
  304. reForm.FormHeight = 500;
  305. reForm.FilterKey = "";
  306. if (reForm.ShowDialog() == DialogResult.OK)
  307. {
  308. DataTable retData = reForm.ReturnData;
  309. foreach (DataRow dr in retData.Rows)
  310. {
  311. batch = dr["批次"].ToString();
  312. }
  313. }
  314. else
  315. {
  316. return;
  317. }
  318. string sqls = @"SELECT Serial FROM dbo.ICSCarton WHERE BatchCode='" + batch + "' ORDER BY CartonNO";
  319. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sqls).Tables[0];
  320. List<string> failPrint = new List<string>();
  321. List<string> guidList = new List<string>();
  322. List<PrintPara> parasList = new List<PrintPara>();
  323. for (int i = 0; i < dt.Rows.Count; i++)
  324. {
  325. string ID = dt.Rows[i]["Serial"].ToString();
  326. PrintPara para = new PrintPara();
  327. para.PrintKey = ID;
  328. para.PrintValues = new object[] { ID };
  329. parasList.Add(para);
  330. guidList.Add(ID);
  331. }
  332. if (parasList.Count == 0)
  333. {
  334. ICSBaseSimpleCode.AppshowMessageBox("没有有效的数据,无法打印");
  335. btnflash_Click(null, null);
  336. return;
  337. }
  338. FormPrintDialog printDialog = new FormPrintDialog("1", "ICSCarton", parasList, false, null);
  339. printDialog.ShowDialog();
  340. string print = @"UPDATE dbo.ICSItemLot SET IsPrint = '是' WHERE BatchCode='" + batch + "'";
  341. DBHelper.ExecuteNonQuery(AppConfig.AppConnectString, CommandType.Text, print);
  342. }
  343. private void btnPrintAgain_Click(object sender, EventArgs e)
  344. {
  345. SimpleButton btntemp = (SimpleButton)sender;
  346. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  347. {
  348. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  349. return;
  350. }
  351. List<string> itemCode = new List<string>();
  352. List<string> guidList = new List<string>();
  353. List<PrintPara> parasList = new List<PrintPara>();
  354. string code = "";
  355. string custCode = "";
  356. for (int i = 0; i < grvDetail.RowCount; i++)
  357. {
  358. string SFlag = grvDetail.GetRowCellValue(i, colSelect).ToString();
  359. code = grvDetail.GetRowCellValue(i, ItemCode).ToString();
  360. if (SFlag=="Y")
  361. {
  362. if (itemCode.Count > 0 && !itemCode.Contains(code))
  363. {
  364. ICSBaseSimpleCode.AppshowMessageBox("请选择相同物料条码进行打印!!");
  365. btnflash_Click(null, null);
  366. return;
  367. }
  368. itemCode.Add(code);
  369. }
  370. }
  371. if (itemCode.Count==0)
  372. {
  373. ICSBaseSimpleCode.AppshowMessageBox("请选择物料条码进行打印!!");
  374. btnflash_Click(null, null);
  375. return;
  376. }
  377. string sql = @"SELECT b.cCusCode as 客户编码,a.cInvName as 存货编码,
  378. c.cCusName as ,b.cCusInvName as FROM {0}.dbo.Inventory a
  379. LEFT JOIN {0}.dbo.CusInvContrapose b ON a.cInvCode=b.cInvCode
  380. LEFT JOIN {0}.dbo.Customer c ON b.cCusCode=c.cCusCode
  381. WHERE a.cInvCode='" + itemCode[0] + "' and b.cCusCode is not null ";
  382. sql = string.Format(sql, ICSBaseSimpleCode.GetWorkPointErpData());
  383. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  384. if(data==null||data.Rows.Count==0){
  385. ICSBaseSimpleCode.AppshowMessageBox("该物料没有在ERP维护客户存货!!");
  386. btnflash_Click(null, null);
  387. return;
  388. }
  389. FormDataRefer reForm = new FormDataRefer();
  390. reForm.FormTitle = "客户存货列表";
  391. DataTable menuData = data;
  392. reForm.DataSource = menuData;
  393. reForm.MSelectFlag = false;
  394. reForm.HideCols.Add("cCusCode");
  395. reForm.RowIndexWidth = 35;
  396. reForm.FormWidth = 500;
  397. reForm.FormHeight = 500;
  398. reForm.FilterKey = "";
  399. if (reForm.ShowDialog() == DialogResult.OK)
  400. {
  401. DataTable retData = reForm.ReturnData;
  402. foreach (DataRow dr in retData.Rows)
  403. {
  404. custCode = dr["客户编码"].ToString();
  405. }
  406. }
  407. else {
  408. return;
  409. }
  410. for (int i = 0; i < grvDetail.RowCount; i++)
  411. {
  412. string SFlag = grvDetail.GetRowCellValue(i, colSelect).ToString();
  413. string id = grvDetail.GetRowCellValue(i, ID).ToString();
  414. if (SFlag == "Y")
  415. {
  416. PrintPara para = new PrintPara();
  417. para.PrintKey = id;
  418. para.PrintValues = new object[] { ID , custCode };
  419. parasList.Add(para);
  420. itemCode.Add(code);
  421. }
  422. }
  423. if (parasList.Count == 0)
  424. {
  425. ICSBaseSimpleCode.AppshowMessageBox("没有有效的数据,无法打印");
  426. btnflash_Click(null, null);
  427. return;
  428. }
  429. FormPrintDialog printDialog = new FormPrintDialog("5", "ICSCarton4", parasList, false, null);
  430. printDialog.ShowDialog();
  431. }
  432. #endregion
  433. private void btnAdd_Click(object sender, EventArgs e)
  434. {
  435. SimpleButton btntemp = (SimpleButton)sender;
  436. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  437. {
  438. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  439. return;
  440. }
  441. FormStockBarCodeSelect pubSelect = new FormStockBarCodeSelect();
  442. pubSelect.ShowDialog();
  443. btnflash_Click(null,null);
  444. //if(pubSelect.ShowDialog()==System.Windows.Forms.DialogResult.OK)
  445. //{
  446. // ICSBaseSimpleCode.AppshowMessageBox("批号生成成功!!");
  447. // return;
  448. //}
  449. }
  450. #endregion
  451. #region 分页
  452. private void rptPage_PageIndexChanged(object Sender, EventArgs e)
  453. {
  454. DataTable data = AppConfig.GetPageData(dataSource, rptPage.PageIndex, rptPage.PageSize).Copy();
  455. //DataTable data = AppConfig.GetPageDataByDb(tempTableName, "pagerowindex", rptPage.PageSize, rptPage.PageIndex, dataSource.Rows.Count);
  456. grdDetail.DataSource = data;
  457. }
  458. #endregion
  459. #region 列表
  460. private void grvDetails_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
  461. {
  462. if (e.Info.IsRowIndicator && e.RowHandle >= 0)
  463. e.Info.DisplayText = (e.RowHandle + 1).ToString();
  464. }
  465. #endregion
  466. private void FormProductBarCode_FormClosing(object sender, FormClosingEventArgs e)
  467. {
  468. AppConfig.DropTemTable(tempTableName);
  469. }
  470. private void btnCartonOpen_Click(object sender, EventArgs e)
  471. {
  472. SimpleButton btntemp = (SimpleButton)sender;
  473. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  474. {
  475. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  476. return;
  477. }
  478. grvDetail.PostEditor();
  479. this.Validate();
  480. List<string> guidlist=new List<string>();
  481. string oldBarCode = "";
  482. for (int i = 0; i < grvDetail.RowCount;i++ )
  483. {
  484. if(grvDetail.GetRowCellValue(i,colSelect).ToString()=="Y")
  485. {
  486. }
  487. }
  488. if(guidlist.Count==0)
  489. {
  490. ICSBaseSimpleCode.AppshowMessageBox("请选择数据!");
  491. return;
  492. }
  493. if(guidlist.Count>1)
  494. {
  495. ICSBaseSimpleCode.AppshowMessageBox("请选择一条数据进行分箱!");
  496. return;
  497. }
  498. //FormStockBarCodeOpen CartonOpen = new FormStockBarCodeOpen(guidlist,oldBarCode);
  499. //if(CartonOpen.ShowDialog()==System.Windows.Forms.DialogResult.OK)
  500. //{
  501. // btnflash_Click(null, null);
  502. //}
  503. }
  504. private void btnCartonClose_Click(object sender, EventArgs e)
  505. {
  506. SimpleButton btntemp = (SimpleButton)sender;
  507. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  508. {
  509. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  510. return;
  511. }
  512. grvDetail.PostEditor();
  513. this.Validate();
  514. List<string> guidlist = new List<string>();
  515. string bacthcode = "";
  516. decimal Qty = 0;
  517. decimal Count = 0;
  518. for (int i = 0; i < grvDetail.RowCount; i++)
  519. {
  520. if (grvDetail.GetRowCellValue(i, colSelect).ToString() == "Y")
  521. {
  522. }
  523. }
  524. if (guidlist.Count <2)
  525. {
  526. ICSBaseSimpleCode.AppshowMessageBox("请选择两条及以上数据进行分箱!");
  527. return;
  528. }
  529. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在合包...请稍等...");
  530. try
  531. {
  532. //using (AoMyEntityDataContext db = new AoMyEntityDataContext(AppConfig.AppConnectString))
  533. //{
  534. // var lines = db.ICSStockBarCode.Where(a => guidlist.Contains(a.Serial)).ToList();
  535. // foreach (var line in lines)
  536. // {
  537. // Qty = Qty + decimal.Parse(line.Quantity.ToString());
  538. // }
  539. //}
  540. //if (Count != Qty)
  541. //{
  542. // throw new Exception("分包之前的总数不等于分包之后的总数,分包错误!");
  543. //}
  544. //List<ICSSoft.AoMy.DAL.StockBarCodeDAL.CartonNoCreat> Listguid = new List<DAL.StockBarCodeDAL.CartonNoCreat>();
  545. //List<ICSSoft.AoMy.DAL.StockBarCodeDAL.CartonNoCreat> Delguid = new List<DAL.StockBarCodeDAL.CartonNoCreat>();
  546. //ICSSoft.AoMy.DAL.StockBarCodeDAL.CartonNoCreat Newline = new ICSSoft.AoMy.DAL.StockBarCodeDAL.CartonNoCreat();
  547. bool b = true;
  548. for (int j = 0; j < grvDetail.RowCount; j++)
  549. {
  550. if (grvDetail.GetRowCellValue(j, colSelect).ToString() == "Y" && b == true)
  551. {
  552. //Newline.serial = grvDetail.GetRowCellValue(j, Serial).ToString();
  553. //Newline.Quantity = Count;
  554. //Listguid.Add(Newline);
  555. //b = false;
  556. }
  557. else if (grvDetail.GetRowCellValue(j, colSelect).ToString() == "Y" && b == false)
  558. {
  559. //ICSSoft.AoMy.DAL.StockBarCodeDAL.CartonNoCreat line = new ICSSoft.AoMy.DAL.StockBarCodeDAL.CartonNoCreat();
  560. //line.serial = grvDetail.GetRowCellValue(j, Serial).ToString();
  561. //line.BarCode = grvDetail.GetRowCellValue(j, BarCode).ToString();
  562. //Delguid.Add(line);
  563. }
  564. }
  565. //ICSSoft.AoMy.BLL.StockBarCodeBLL.CartonClose(Listguid, Delguid, AppConfig.AppConnectString);
  566. _wait.Close();
  567. ICSBaseSimpleCode.AppshowMessageBox("合包成功!");
  568. btnflash_Click(null, null);
  569. }
  570. catch (Exception ex)
  571. {
  572. _wait.Close();
  573. ICSBaseSimpleCode.AppshowMessageBox(1, "合包失败\r\n" + ex.Message);
  574. }
  575. }
  576. private void btnCartonModify_Click(object sender, EventArgs e)
  577. {
  578. SimpleButton btntemp = (SimpleButton)sender;
  579. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  580. {
  581. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  582. return;
  583. }
  584. grvDetail.PostEditor();
  585. this.Validate();
  586. List<string> GuidList = new List<string>();
  587. if(grvDetail.RowCount==0)
  588. {
  589. return;
  590. }
  591. if(grvDetail.FocusedRowHandle<0)
  592. {
  593. return;
  594. }
  595. for (int i = 0; i < grvDetail.RowCount;i++ )
  596. {
  597. if(grvDetail.GetRowCellValue(i,colSelect).ToString()=="Y")
  598. {
  599. GuidList.Add(grvDetail.GetRowCellValue(i,ID).ToString());
  600. }
  601. }
  602. if(GuidList.Count==0)
  603. {
  604. ICSBaseSimpleCode.AppshowMessageBox("请选择数据!");
  605. return;
  606. }
  607. if(GuidList.Count>1)
  608. {
  609. ICSBaseSimpleCode.AppshowMessageBox("请选择一条数据进行修改箱号!");
  610. return;
  611. }
  612. //FormStockBarCodeModify CartonModify = new FormStockBarCodeModify(GuidList);
  613. //if(CartonModify.ShowDialog()==System.Windows.Forms.DialogResult.OK)
  614. //{
  615. // btnflash_Click(null, null);
  616. //}
  617. }
  618. private void grvDetail_DoubleClick(object sender, EventArgs e)
  619. {
  620. if(grvDetail.RowCount==0)
  621. {
  622. return;
  623. }
  624. if(grvDetail.FocusedRowHandle<0)
  625. {
  626. return;
  627. }
  628. if(grvDetail.FocusedColumn==colSelect)
  629. {
  630. if (grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colSelect).ToString() == "Y")
  631. {
  632. grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colSelect, "");
  633. }
  634. else
  635. {
  636. grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle,colSelect,"Y");
  637. }
  638. }
  639. }
  640. private void btnfrompallet_Click(object sender, EventArgs e)
  641. {
  642. SimpleButton btntemp = (SimpleButton)sender;
  643. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  644. {
  645. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  646. return;
  647. }
  648. grvDetail.PostEditor();
  649. this.Validate();
  650. List<string> GuidList = new List<string>();
  651. if (grvDetail.RowCount == 0)
  652. {
  653. return;
  654. }
  655. if (grvDetail.FocusedRowHandle < 0)
  656. {
  657. return;
  658. }
  659. for (int i = 0; i < grvDetail.RowCount; i++)
  660. {
  661. if (grvDetail.GetRowCellValue(i, colSelect).ToString() == "Y")
  662. {
  663. }
  664. }
  665. if (GuidList.Count == 0)
  666. {
  667. ICSBaseSimpleCode.AppshowMessageBox("请选择数据!");
  668. return;
  669. }
  670. if (ICSBaseSimpleCode.AppshowMessageBoxRepose("确定要将选择的箱号脱离栈板吗?") != DialogResult.OK)
  671. {
  672. return;
  673. }
  674. //ICSCartonBLL.FromPallet(GuidList,AppConfig.AppConnectString.ToString());
  675. ICSBaseSimpleCode.AppshowMessageBox("脱离栈板成功!");
  676. btnflash_Click(null, null);
  677. }
  678. private void FormCartonProtect_Load(object sender, EventArgs e)
  679. {
  680. btnFilter_Click(null, null);
  681. }
  682. private void btnPrintOne_Click(object sender, EventArgs e)
  683. {
  684. try
  685. {
  686. List<PrintPara> parasList = new List<PrintPara>();
  687. List<ICSITEMLot> InfoList = new List<ICSITEMLot>();
  688. for (int i = 0; i < grvDetail.RowCount; i++)
  689. {
  690. if (grvDetail.GetRowCellValue(i, colSelect).ToString() == "Y")
  691. {
  692. PrintPara para = new PrintPara();
  693. para.PrintKey = "LOTNO";
  694. para.PrintValues = new object[] { grvDetail.GetRowCellValue(i, LotNO).ToString() };
  695. parasList.Add(para);
  696. ICSITEMLot Info = new ICSITEMLot();
  697. Info.LotNO = grvDetail.GetRowCellValue(i, LotNO).ToString();
  698. Info.lastPrintUSERID = AppConfig.UserId;
  699. Info.lastPrintTime = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss");
  700. Info.WorkPoint = AppConfig.WorkPointCode;
  701. InfoList.Add(Info);
  702. }
  703. }
  704. if (parasList.Count == 0)
  705. {
  706. ICSBaseSimpleCode.AppshowMessageBox("请选择数据!");
  707. return;
  708. }
  709. FormPrintDialog f = new FormPrintDialog("006", this.Text, parasList, false, null);
  710. f.ShowDialog();
  711. //更新打印信息
  712. ICSRdrecord2LOTBLL.updatePrint(InfoList, AppConfig.AppConnectString);
  713. btnflash_Click(null, null);
  714. }
  715. catch (Exception ex)
  716. {
  717. MessageBox.Show(ex.ToString());
  718. }
  719. //SimpleButton btntemp = (SimpleButton)sender;
  720. //if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  721. //{
  722. // ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  723. // return;
  724. //}
  725. //List<string> failPrint = new List<string>();
  726. //List<string> guidList = new List<string>();
  727. //List<PrintPara> parasList = new List<PrintPara>();
  728. //for (int i = 0; i < grvDetail.RowCount; i++)
  729. //{
  730. // string SFlag = grvDetail.GetRowCellValue(i, colSelect).ToString();
  731. // string id = grvDetail.GetRowCellValue(i, ID).ToString();
  732. // if (SFlag == "Y")
  733. // {
  734. // PrintPara para = new PrintPara();
  735. // para.PrintKey = id;
  736. // para.PrintValues = new object[] { ID };
  737. // parasList.Add(para);
  738. // guidList.Add(id);
  739. // }
  740. //}
  741. //if (parasList.Count == 0)
  742. //{
  743. // ICSBaseSimpleCode.AppshowMessageBox("没有有效的数据,无法打印");
  744. // btnflash_Click(null, null);
  745. // return;
  746. //}
  747. //FormPrintDialog printDialog = new FormPrintDialog("1", "ICSStockBarCode", parasList, false, null);
  748. //printDialog.ShowDialog();
  749. }
  750. }
  751. }