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

740 lines
27 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.Frame.User.BLL;
  10. using ICSSoft.Base.Language.Tool;
  11. using ICSSoft.Base.UserControl.MessageControl;
  12. using System.Data.SqlClient;
  13. using ICSSoft.Base.Config.AppConfig;
  14. using ICSSoft.Base.Report.Filter;
  15. using ICSSoft.Base.Config.DBHelper;
  16. using ICSSoft.Base.UserControl.FormControl;
  17. using ICSSoft.Base.ReferForm.AppReferForm;
  18. using ICSSoft.Base.Lable.PrintTool;
  19. using ICSSoft.Frame.Data.DAL;
  20. using ICSSoft.Frame.Data.BLL;
  21. using ICSSoft.Frame.Data.Entity;
  22. using System.Text.RegularExpressions;
  23. using System.Runtime.InteropServices;
  24. namespace ICSSoft.Frame.APP
  25. {
  26. public partial class FormICSPallet : DevExpress.XtraEditors.XtraForm
  27. {
  28. string OPID;
  29. private string PalletCode;
  30. [DllImport("user32.dll", EntryPoint = "GetWindowLong", CharSet = CharSet.Auto)]
  31. public static extern int GetWindowLong(HandleRef hWnd, int nIndex);
  32. [DllImport("user32.dll", EntryPoint = "SetWindowLong", CharSet = CharSet.Auto)]
  33. public static extern IntPtr SetWindowLong(HandleRef hWnd, int nIndex, int dwNewLong);
  34. DataSet ds = new DataSet();
  35. private DataTable BodySource = null;
  36. private string whereStr = "";
  37. private string sqltxt = "";
  38. private string sqlconn = "";
  39. String guid = AppConfig.GetGuid();
  40. private DataTable dataSource = null;
  41. private DataTable dttwo;
  42. private DataTable dtthree;
  43. private DataSet dstwo;
  44. protected override CreateParams CreateParams
  45. {
  46. get
  47. {
  48. const int WS_MINIMIZEBOX = 0x00020000; // Winuser.h中定义
  49. CreateParams cp = base.CreateParams;
  50. cp.Style = cp.Style | WS_MINIMIZEBOX; // 允许最小化操作
  51. return cp;
  52. }
  53. }
  54. #region 构造函数
  55. public FormICSPallet()
  56. {
  57. InitializeComponent();
  58. this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  59. this.WindowState = FormWindowState.Maximized;
  60. }
  61. #endregion
  62. #region 子表
  63. public DataTable ThreeTable()
  64. {
  65. string sql = @"select '' as selecttwo,
  66. a.ID as ID,
  67. a.PalletCode as PalletCode,
  68. a.LotNO as LotNO,
  69. c.INVCODE as INVCODE,
  70. c.INVNAME as INVNAME,
  71. b.LOTQTY as LOTQTY,
  72. b.TYPE as TYPE,
  73. a.WorkPoint as WorkPoint,
  74. a.MuserCode as MuserCode,
  75. a.MuserName as MuserName,
  76. a.Mtime as Mtime,
  77. a.Free1 as Free1
  78. from ICSPalletLotNO a
  79. left join ICSITEMLot b on a.LotNO = b.LotNO AND a.WorkPoint=b.WorkPoint
  80. left join ICSINVENTORY c on b.ItemCode = c.INVCODE and b.WorkPoint=c.WorkPoint
  81. ";
  82. if (whereStr != "")
  83. {
  84. sql = sql + " WHERE 1=1 " + whereStr;
  85. }
  86. sql = string.Format(sql);
  87. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  88. return data;
  89. }
  90. #endregion
  91. #region 操作权限
  92. public DataTable RightOfExute()
  93. {
  94. DataTable rData = new DataTable();
  95. rData.Columns.Add("BtnName");
  96. rData.Columns.Add("ActionName");
  97. //查看权限(必须有)
  98. DataRow seeRow = rData.NewRow();
  99. seeRow["BtnName"] = "see";
  100. seeRow["ActionName"] = "查看";
  101. rData.Rows.Add(seeRow);
  102. foreach (Control ctr in panelControl3.Controls)
  103. {
  104. if (ctr.Name == btnFilter.Name || ctr.Name == btnConfig.Name ||
  105. ctr.Name == btnSelectAll.Name || ctr.Name == btnCancelAll.Name ||
  106. ctr.Name == btnRefresh.Name || ctr.Name == btnExit.Name || ctr.Name == lblTitle.Name || ctr.Name == btnClose.Name)
  107. continue;
  108. DataRow dr = rData.NewRow();
  109. dr["BtnName"] = ctr.Name;
  110. dr["ActionName"] = ctr.Text;
  111. rData.Rows.Add(dr);
  112. }
  113. //List<Control> ControlList = new List<Control>();
  114. //ControlList.Add(btnCreate);
  115. //ControlList.Add(btnModify);
  116. //ControlList.Add(btnDel);
  117. //ControlList.Add(btnOutPut);
  118. //foreach (Control ctr in ControlList)
  119. //{
  120. // if (ctr.GetType() == typeof(SimpleButton))
  121. // {
  122. // DataRow dr = rData.NewRow();
  123. // dr["BtnName"] = ctr.Name;
  124. // dr["ActionName"] = ctr.Text;
  125. // rData.Rows.Add(dr);
  126. // }
  127. //}
  128. rData.AcceptChanges();
  129. return rData;
  130. }
  131. public DataTable RightOfData()// 数据权限
  132. {
  133. DataTable rData = new DataTable();
  134. rData.Columns.Add("BodyName");
  135. rData.Columns.Add("ControlName");
  136. rData.Columns.Add("ControlCaption");
  137. rData.AcceptChanges();
  138. return rData;
  139. }
  140. #endregion
  141. #region 退出
  142. private void btnClose_Click(object sender, EventArgs e)
  143. {
  144. AppConfig.CloseFormShow(this.Text);
  145. this.Close();
  146. }
  147. private void btnExit_Click(object sender, EventArgs e)
  148. {
  149. AppConfig.CloseFormShow(this.Text);
  150. this.Close();
  151. }
  152. #endregion
  153. #region 移动窗体
  154. private const int WM_NCHITTEST = 0x84;
  155. private const int HTCLIENT = 0x1;
  156. private const int HTCAPTION = 0x2;
  157. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  158. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  159. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  160. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  161. //重写窗体,使窗体可以不通过自带标题栏实现移动
  162. protected override void WndProc(ref Message m)
  163. {
  164. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  165. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  166. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  167. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  168. switch (m.Msg)
  169. {
  170. case WM_NCHITTEST:
  171. base.WndProc(ref m);
  172. if ((int)m.Result == HTCLIENT)
  173. m.Result = (IntPtr)HTCAPTION;
  174. return;
  175. }
  176. //拦截双击标题栏、移动窗体的系统消息
  177. if (m.Msg != 0xA3)
  178. {
  179. base.WndProc(ref m);
  180. }
  181. }
  182. #endregion
  183. #region 列表
  184. private void grvDetail_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
  185. {
  186. if (e.Info.IsRowIndicator && e.RowHandle >= 0)
  187. e.Info.DisplayText = (e.RowHandle + 1).ToString();
  188. }
  189. #endregion
  190. #region 过滤
  191. private string tempTableName = "";
  192. private void btnFilter_Click(object sender, EventArgs e)
  193. {
  194. FormFilter filter = new FormFilter(AppConfig.GetSourceId(this.Tag.ToString(), btnConfig.Name));
  195. filter.OldTempTableName = tempTableName;
  196. if (filter.ShowDialog() == DialogResult.OK)
  197. {
  198. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在查找...请稍等...");
  199. try
  200. {
  201. _wait.Show();
  202. dataSource = null;
  203. BodySource = null;
  204. ds.Reset();
  205. tempTableName = filter.NewTempTableName;
  206. sqltxt = filter.SqlText;
  207. string[] wheres = Regex.Split(sqltxt, "1=1", RegexOptions.IgnoreCase);
  208. if (wheres.Length >= 2 && wheres[1] != "\r\n")
  209. {
  210. whereStr = wheres[1];
  211. int index = whereStr.IndexOf("GROUP BY");
  212. if (index > 0)
  213. whereStr = whereStr.Substring(0, index);
  214. if (whereStr == "\r\n")
  215. whereStr = "";
  216. }
  217. else
  218. {
  219. whereStr = "";
  220. }
  221. sqlconn = filter.FilterConnectString;
  222. dataSource = filter.FilterData.Tables[0].Copy();
  223. BodySource = ThreeTable().Copy();
  224. dataSource.TableName = "Hand";
  225. BodySource.TableName = "Body";
  226. if (ds != null)
  227. {
  228. ds.Tables.Add(dataSource);
  229. ds.Tables.Add(BodySource);
  230. }
  231. DataRelation dr = new DataRelation("详情", new DataColumn[] { ds.Tables["Hand"].Columns["PalletCode"] }, new DataColumn[] { ds.Tables["Body"].Columns["PalletCode"] }, false);
  232. ds.Relations.Add(dr);
  233. grdDetail.DataSource = dataSource;
  234. grvDetail.BestFitColumns();
  235. gridView1.BestFitColumns();
  236. rptPage.RecordNum = dataSource.Rows.Count;
  237. rptPage.PageSize = 100;
  238. rptPage.PageIndex = 1;
  239. //rptPage.ReLoad();
  240. _wait.Close();
  241. }
  242. catch (Exception ex)
  243. {
  244. MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  245. _wait.Close();
  246. }
  247. }
  248. }
  249. #endregion
  250. #region 绑定数据源
  251. private void btnConfig_Click(object sender, EventArgs e)
  252. {
  253. if (AppConfig.UserCode.ToLower() != "demo")
  254. {
  255. ICSBaseSimpleCode.AppshowMessageBox("您没有权限设置数据源,请联系软件提供商!");
  256. return;
  257. }
  258. FormDataSource fdata = new FormDataSource(AppConfig.GetMenuId(this.Tag.ToString()), btnConfig.Name);
  259. fdata.ShowDialog();
  260. }
  261. #endregion
  262. #region 分页
  263. private void rptPage_PageIndexChanged(object Sender, EventArgs e)
  264. {
  265. DataTable data = AppConfig.GetPageData(dataSource, rptPage.PageIndex, rptPage.PageSize).Copy();
  266. //DataTable data = AppConfig.GetPageDataByDb(tempTableName, "pagerowindex", rptPage.PageSize, rptPage.PageIndex, dataSource.Rows.Count);
  267. grdDetail.DataSource = data;
  268. }
  269. #endregion
  270. #region 过滤方法
  271. private void FormContainerManager_FormClosing(object sender, FormClosingEventArgs e)
  272. {
  273. AppConfig.DropTemTable(tempTableName);
  274. }
  275. #endregion
  276. #region 全选
  277. private void btnSelectAll_Click(object sender, EventArgs e)
  278. {
  279. grvDetail.PostEditor();
  280. this.Validate();
  281. for (int i = 0; i < grvDetail.RowCount; i++)
  282. {
  283. grvDetail.SetRowCellValue(i, colselectone, "Y");
  284. }
  285. }
  286. #endregion
  287. #region 全消
  288. private void btnCancelAll_Click(object sender, EventArgs e)
  289. {
  290. grvDetail.PostEditor();
  291. this.Validate();
  292. for (int i = 0; i < grvDetail.RowCount; i++)
  293. {
  294. grvDetail.SetRowCellValue(i, colselectone, "");
  295. }
  296. }
  297. #endregion
  298. #region 双击
  299. private void grvDetail_DoubleClick(object sender, EventArgs e)
  300. {
  301. if (grvDetail.FocusedRowHandle < 0)
  302. {
  303. return;
  304. }
  305. if (grvDetail.FocusedColumn == colselectone)
  306. {
  307. if (grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colselectone).ToString() == "")
  308. {
  309. grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colselectone, "Y");
  310. }
  311. else
  312. {
  313. grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colselectone, "");
  314. }
  315. }
  316. }
  317. #endregion
  318. #region 双击子表
  319. private void gridView1_DoubleClick(object sender, EventArgs e)
  320. {
  321. if (gridView1.FocusedRowHandle < 0)
  322. {
  323. return;
  324. }
  325. if (gridView1.FocusedColumn.Name == colselecttwo.Name)
  326. {
  327. if (gridView1.GetRowCellValue(gridView1.FocusedRowHandle, colselecttwo).ToString() == "")
  328. {
  329. gridView1.SetRowCellValue(gridView1.FocusedRowHandle, colselecttwo, "Y");
  330. }
  331. else
  332. {
  333. gridView1.SetRowCellValue(gridView1.FocusedRowHandle, colselecttwo, "");
  334. }
  335. }
  336. }
  337. #endregion
  338. #region 删除
  339. private void btnDel_Click(object sender, EventArgs e)
  340. {
  341. SimpleButton btntemp = (SimpleButton)sender;
  342. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  343. {
  344. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  345. return;
  346. }
  347. List<ICSPallet> item2routeList = new List<ICSPallet>();
  348. List<string> routecodeList = new List<string>();
  349. for (int i = 0; i < grvDetail.RowCount; i++)
  350. {
  351. if (grvDetail.GetRowCellValue(i, colselectone).ToString() == "Y")
  352. {
  353. ICSPallet item2route = new ICSPallet();
  354. item2route.PalletCode = grvDetail.GetRowCellValue(i, colPalletCode).ToString();
  355. item2routeList.Add(item2route);
  356. }
  357. }
  358. if (item2routeList.Count == 0)
  359. {
  360. ICSBaseSimpleCode.AppshowMessageBox("请选择数据");
  361. return;
  362. }
  363. if (ICSBaseSimpleCode.AppshowMessageBoxRepose("确定删除吗?删除后无法恢复,确定吗?") != DialogResult.OK)
  364. {
  365. btnCancelAll_Click(sender, e);
  366. return;
  367. }
  368. ICSPalletBLL.deleteInfo(item2routeList, AppConfig.AppConnectString);
  369. ICSBaseSimpleCode.AppshowMessageBox("删除成功");
  370. btnRefresh_Click(null, null);
  371. }
  372. #endregion
  373. #region 刷新
  374. private void btnRefresh_Click(object sender, EventArgs e)
  375. {
  376. if (sqlconn == null || sqlconn == "")
  377. {
  378. return;
  379. }
  380. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在查找...请稍等...");
  381. try
  382. {
  383. _wait.Show();
  384. dataSource = null;
  385. BodySource = null;
  386. ds.Reset();
  387. FormFilter filter = new FormFilter(AppConfig.GetSourceId(this.Tag.ToString(), btnConfig.Name), false);
  388. filter.OldTempTableName = tempTableName;
  389. //tempTableName = filter.NewTempTableName;
  390. //DataTable data = DBHelper.ExecuteDataset(AppConfig.FrameConnectString, CommandType.Text, "select * from " + tempTableName).Tables[0];
  391. dataSource = DBHelper.ExecuteDataset(sqlconn, CommandType.Text, sqltxt).Tables[0].Copy();
  392. BodySource = ThreeTable().Copy();
  393. dataSource.TableName = "Hand";
  394. BodySource.TableName = "Body";
  395. if (ds != null)
  396. {
  397. ds.Tables.Add(dataSource);
  398. ds.Tables.Add(BodySource);
  399. }
  400. DataRelation dr = new DataRelation("详情", new DataColumn[] { ds.Tables["Hand"].Columns["PalletCode"] }, new DataColumn[] { ds.Tables["Body"].Columns["PalletCode"] });
  401. ds.Relations.Add(dr);
  402. grdDetail.DataSource = dataSource;
  403. grvDetail.BestFitColumns();
  404. gridView1.BestFitColumns();
  405. rptPage.RecordNum = dataSource.Rows.Count;
  406. rptPage.PageSize = 100;
  407. rptPage.PageIndex = 1;
  408. //rptPage.ReLoad();
  409. _wait.Close();
  410. }
  411. catch (Exception ex)
  412. {
  413. MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  414. _wait.Close();
  415. }
  416. }
  417. #endregion
  418. private void ICSItemLot_FormClosing(object sender, FormClosingEventArgs e)
  419. {
  420. AppConfig.DropTemTable(tempTableName);
  421. }
  422. private void FormICSPallet_Load(object sender, EventArgs e)
  423. {
  424. //无标题窗体右键菜单
  425. int WS_SYSMENU = 0x00080000; // 系统菜单
  426. int WS_MINIMIZEBOX = 0x20000; // 最大最小化按钮
  427. int windowLong = (GetWindowLong(new HandleRef(this, this.Handle), -16));
  428. SetWindowLong(new HandleRef(this, this.Handle), -16, windowLong | WS_SYSMENU | WS_MINIMIZEBOX);
  429. //dstwo.Reset();
  430. //dttwo = null;
  431. //dtthree = null;
  432. btnFilter_Click(sender, e);
  433. }
  434. private void grvDetail_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
  435. {
  436. if (e.RowHandle >= 0 && e.Column.FieldName == "DCTCODE")
  437. {
  438. //e.DisplayText = FormatHelper.
  439. e.CellValue = "cccc";
  440. }
  441. }
  442. private void grvDetail_MasterRowExpanded(object sender, DevExpress.XtraGrid.Views.Grid.CustomMasterRowEventArgs e)
  443. {
  444. gridView1 = grvDetail.GetDetailView(e.RowHandle, e.RelationIndex) as DevExpress.XtraGrid.Views.Grid.GridView;
  445. gridView1.BestFitColumns();
  446. }
  447. #region 打印
  448. private void btnPrint_Click(object sender, EventArgs e)
  449. {
  450. SimpleButton btntemp = (SimpleButton)sender;
  451. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  452. {
  453. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  454. return;
  455. }
  456. if (grvDetail.FocusedRowHandle < 0)
  457. {
  458. return;
  459. }
  460. try
  461. {
  462. List<PrintPara> barCodeList = new List<PrintPara>();
  463. for (int i = 0; i < grvDetail.RowCount; i++)
  464. {
  465. if (grvDetail.GetRowCellValue(i, colselectone).ToString() == "Y")
  466. {
  467. string barCode = grvDetail.GetRowCellValue(i, colPalletCode).ToString();
  468. PrintPara printInfo = new PrintPara();
  469. printInfo.PrintKey = "PalletCode";
  470. printInfo.PrintValues = new object[] { barCode };
  471. barCodeList.Add(printInfo);
  472. }
  473. }
  474. if (barCodeList.Count == 0)
  475. {
  476. ICSBaseSimpleCode.AppshowMessageBox("没有选择数据");
  477. return;
  478. }
  479. FormPrintDialog printDialog = new FormPrintDialog("013", "ICSProduct", barCodeList, false, null);
  480. printDialog.ShowDialog();
  481. }
  482. catch (Exception ex)
  483. {
  484. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  485. }
  486. }
  487. #endregion
  488. #region 查询
  489. private void FormDCT_Load(object sender, EventArgs e)
  490. {
  491. string sql = @"select ''as [Select],
  492. ID as ID,
  493. PalletCode as PalletCode,
  494. LotNO as LotNO,
  495. WorkPoint as WorkPoint,
  496. MuserCode as MuserCode,
  497. MuserName as MuserName,
  498. Mtime as Mtime
  499. from ICSPalletLotNO
  500. where PalletCode='{0}'
  501. ";
  502. sql = string.Format(sql, PalletCode);
  503. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  504. grdDetail.DataSource = dt;
  505. grvDetail.BestFitColumns();
  506. }
  507. #endregion
  508. #region 关联批次
  509. private void btnTBLOP2RES_Click(object sender, EventArgs e)
  510. {
  511. SimpleButton btntemp = (SimpleButton)sender;
  512. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  513. {
  514. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  515. return;
  516. }
  517. int count = 0;
  518. string PalletCode = "";
  519. for (int i = 0; i < grvDetail.RowCount; i++)
  520. {
  521. if (grvDetail.GetRowCellValue(i, colselectone).ToString() == "Y")
  522. {
  523. PalletCode = grvDetail.GetRowCellValue(i, colPalletCode).ToString();
  524. count++;
  525. }
  526. }
  527. if (count != 1)
  528. {
  529. ICSBaseSimpleCode.AppshowMessageBox("请选择要关联的数据, 且只能选择一条进行操作!");
  530. return;
  531. }
  532. string sql = @"SELECT
  533. a.[LotNO] AS ''
  534. ,b.INVCODE as ''
  535. ,a.[MuserName] AS ''
  536. FROM ICSITEMLot a
  537. LEFT JOIN ICSINVENTORY b ON a.ItemCode=b.INVCODE AND a.WorkPoint=b.WorkPoint
  538. WHERE a.LotNO NOT IN (SELECT LotNO from dbo.ICSPalletLotNO) and 1=1
  539. GROUP BY a.LotNO,a.[MuserName],b.INVCODE";
  540. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  541. FormDataRefer reForm = new FormDataRefer();
  542. reForm.FormTitle = "资源信息";
  543. DataTable menuData = data;
  544. reForm.DataSource = menuData;
  545. reForm.MSelectFlag = true;
  546. reForm.RowIndexWidth = 35;
  547. reForm.HideCols.Add("ID");
  548. reForm.FormWidth = 500;
  549. reForm.FormHeight = 500;
  550. reForm.FilterKey = "";
  551. if (reForm.ShowDialog() == DialogResult.OK)
  552. {
  553. DataTable retData = reForm.ReturnData;
  554. if (retData.Rows.Count == 0)
  555. {
  556. ICSBaseSimpleCode.AppshowMessageBox("请选择数据!");
  557. return;
  558. }
  559. string invcode = "";
  560. foreach (DataRow dr in retData.Rows)
  561. {
  562. if (invcode == "")
  563. {
  564. invcode = dr["存货编码"].ToString();
  565. }
  566. else if (invcode != dr["存货编码"].ToString())
  567. {
  568. ICSBaseSimpleCode.AppshowMessageBox("请选择数据!");
  569. return;
  570. }
  571. }
  572. DataRow[] drs = BodySource.Select("PalletCode='" + PalletCode + "'");
  573. if (drs.Length > 0)
  574. {
  575. if (invcode != drs[0]["INVCODE"].ToString())
  576. {
  577. ICSBaseSimpleCode.AppshowMessageBox("请选择物料编号相同的批次入箱!");
  578. return;
  579. }
  580. }
  581. ICSPalletBLL.AddandEdit(retData,PalletCode, AppConfig.AppConnectString);
  582. ICSBaseSimpleCode.AppshowMessageBox(0, "保存成功");
  583. FormDCT_Load(null, null);
  584. btnRefresh_Click(null, null);
  585. }
  586. }
  587. #endregion
  588. #region 新增
  589. private void btnADD_Click(object sender, EventArgs e)
  590. {
  591. SimpleButton btntemp = (SimpleButton)sender;
  592. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  593. {
  594. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  595. return;
  596. }
  597. FormICSPalletAdd add = new FormICSPalletAdd();
  598. add.ShowDialog();
  599. btnRefresh_Click(null, null);
  600. }
  601. #endregion
  602. #region 删除批次
  603. private void btnLotNo_Click(object sender, EventArgs e)
  604. {
  605. int Count = 0;
  606. gridView1.PostEditor();
  607. this.Validate();
  608. if (gridView1.RowCount == 0)
  609. return;
  610. SimpleButton btntemp = (SimpleButton)sender;
  611. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  612. {
  613. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  614. return;
  615. }
  616. for (int i = 0; i < gridView1.RowCount; i++)
  617. {
  618. if (gridView1.GetRowCellValue(i, colselecttwo).ToString() == "Y")
  619. {
  620. Count++;
  621. }
  622. }
  623. if (Count == 0)
  624. {
  625. ICSBaseSimpleCode.AppshowMessageBox("请选择数据!");
  626. return;
  627. }
  628. if (ICSBaseSimpleCode.AppshowMessageBoxRepose("确定删除该批次吗?批次删除后无法恢复,确定吗?") != DialogResult.OK)
  629. {
  630. return;
  631. }
  632. else
  633. {
  634. try
  635. {
  636. for (int i = 0; i < gridView1.RowCount; i++)
  637. {
  638. if (gridView1.GetRowCellValue(i, colselecttwo).ToString() == "Y")
  639. {
  640. FormICSPalletAdd add = new FormICSPalletAdd(gridView1.GetRowCellValue(i, colPallet2Code).ToString(), gridView1.GetRowCellValue(i, colLotNO).ToString(), gridView1.GetRowCellValue(i, MuserCode).ToString());
  641. }
  642. }
  643. ICSBaseSimpleCode.AppshowMessageBox(0, "删除成功");
  644. btnRefresh_Click(null, null);
  645. }
  646. catch (Exception ex)
  647. {
  648. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  649. return;
  650. }
  651. }
  652. }
  653. #endregion
  654. }
  655. }