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

819 lines
34 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.ReferForm.AppReferForm;
  16. using ICSSoft.Frame.Data.Entity;
  17. using ICSSoft.Frame.Data.BLL;
  18. using ICSSoft.Base.Lable.PrintTool;
  19. using System.Data.SqlClient;
  20. namespace ICSSoft.Frame.APP
  21. {
  22. public partial class FormICSWBSSpecailEdit : DevExpress.XtraEditors.XtraForm
  23. {
  24. private string sqltxt = "";
  25. private string sqlconn = "";
  26. private DataTable dataSource = null;
  27. private DataTable dtNewRcard = null;
  28. public List<Dictionary<string, object>> Rows = new List<Dictionary<string, object>>();
  29. public FormICSWBSSpecailEdit()
  30. {
  31. InitializeComponent();
  32. this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  33. this.WindowState = FormWindowState.Maximized;
  34. txtInvCode.Enabled = false;
  35. txtBatch.ReadOnly = true;
  36. txtBatch.Enabled = false;
  37. }
  38. #region SystemOptition
  39. /// <summary>
  40. /// 操作权限
  41. /// </summary>
  42. /// <returns></returns>
  43. public DataTable RightOfExute()
  44. {
  45. DataTable rData = new DataTable();
  46. rData.Columns.Add("BtnName");
  47. rData.Columns.Add("ActionName");
  48. //查看权限(必须有)
  49. DataRow seeRow = rData.NewRow();
  50. seeRow["BtnName"] = "see";
  51. seeRow["ActionName"] = "查看";
  52. rData.Rows.Add(seeRow);
  53. List<Control> ControlList = new List<Control>();
  54. ControlList.Add(btnSearch);
  55. ControlList.Add(btnOk);
  56. ControlList.Add(simpleButton4);
  57. ControlList.Add(btnConfig);
  58. foreach (Control ctr in ControlList)
  59. {
  60. if (ctr.GetType() == typeof(SimpleButton))
  61. {
  62. DataRow dr = rData.NewRow();
  63. dr["BtnName"] = ctr.Name;
  64. dr["ActionName"] = ctr.Text;
  65. rData.Rows.Add(dr);
  66. }
  67. }
  68. rData.AcceptChanges();
  69. return rData;
  70. }
  71. /// <summary>
  72. /// 数据权限
  73. /// </summary>
  74. /// <returns></returns>
  75. public DataTable RightOfData()
  76. {
  77. DataTable rData = new DataTable();
  78. rData.Columns.Add("BodyName");
  79. rData.Columns.Add("ControlName");
  80. rData.Columns.Add("ControlCaption");
  81. rData.AcceptChanges();
  82. return rData;
  83. }
  84. #endregion
  85. #region 绑定数据源
  86. private void btnConfig_Click(object sender, EventArgs e)//绑定数据源
  87. {
  88. if (AppConfig.UserCode.ToLower() != "demo")
  89. {
  90. //ICSBaseSimpleCode.AppshowMessageBox("您没有权限设置数据源,请联系软件提供商!");
  91. return;
  92. }
  93. FormDataSource fdata = new FormDataSource(AppConfig.GetMenuId(this.Tag.ToString()), btnConfig.Name);
  94. fdata.ShowDialog();
  95. }
  96. #endregion
  97. #region 过滤
  98. private string tempTableName = "";
  99. private void btnFilter_Click(object sender, EventArgs e)
  100. {
  101. FormFilter filter = new FormFilter(AppConfig.GetSourceId(this.Tag.ToString(), btnConfig.Name));
  102. filter.OldTempTableName = tempTableName;
  103. if (filter.ShowDialog() == DialogResult.OK)
  104. {
  105. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在查找...请稍等...");
  106. try
  107. {
  108. _wait.Show();
  109. tempTableName = filter.NewTempTableName;
  110. sqltxt = filter.SqlText;
  111. sqlconn = filter.FilterConnectString;
  112. dataSource = filter.FilterData.Tables[0];
  113. grdDetail.DataSource = dataSource;
  114. grvDetail.BestFitColumns();
  115. _wait.Close();
  116. }
  117. catch (Exception ex)
  118. {
  119. MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  120. _wait.Close();
  121. }
  122. }
  123. }
  124. #endregion
  125. public static string searchSQl()
  126. {
  127. string sql = @" SELECT CAST ('' AS NVARCHAR(50)) AS 选择,b.POCode,b.PORow,b.VenName,
  128. b.PersonName,b.POType,b.InvCode,c.INVNAME,c.INVSTD,a.LotNO,a.LOTQTY
  129. FROM dbo.ICSITEMLot a
  130. INNER JOIN dbo.ICSPO_PoMain b ON a.TransNO = b.POCode AND a.TransLine = b.PORow
  131. INNER JOIN dbo.ICSINVENTORY c ON b.InvCode = c.INVCODE
  132. WHERE a.Status = '' ";
  133. return sql;
  134. }
  135. #region 移动窗体
  136. private const int WM_NCHITTEST = 0x84;
  137. private const int HTCLIENT = 0x1;
  138. private const int HTCAPTION = 0x2;
  139. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  140. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  141. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  142. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  143. //重写窗体,使窗体可以不通过自带标题栏实现移动
  144. protected override void WndProc(ref Message m)
  145. {
  146. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  147. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  148. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  149. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  150. switch (m.Msg)
  151. {
  152. case WM_NCHITTEST:
  153. base.WndProc(ref m);
  154. if ((int)m.Result == HTCLIENT)
  155. m.Result = (IntPtr)HTCAPTION;
  156. return;
  157. }
  158. //拦截双击标题栏、移动窗体的系统消息
  159. if (m.Msg != 0xA3)
  160. {
  161. base.WndProc(ref m);
  162. }
  163. }
  164. #endregion
  165. private void btnClose_Click(object sender, EventArgs e)
  166. {
  167. AppConfig.CloseFormShow(this.Text);
  168. this.DialogResult = DialogResult.Cancel;
  169. }
  170. private void grvDetail_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
  171. {
  172. if (e.Info.IsRowIndicator && e.RowHandle >= 0)
  173. e.Info.DisplayText = (e.RowHandle + 1).ToString();
  174. }
  175. private void btnDel_Click(object sender, EventArgs e)
  176. {
  177. grvDetail.PostEditor();
  178. this.Validate();
  179. if (grvDetail.FocusedRowHandle < 0)
  180. {
  181. return;
  182. }
  183. grvDetail.DeleteRow(grvDetail.FocusedRowHandle);
  184. }
  185. private void grvDetail_DoubleClick(object sender, EventArgs e)
  186. {
  187. if (grvDetail.RowCount == 0)
  188. {
  189. return;
  190. }
  191. if (grvDetail.FocusedRowHandle < 0)
  192. {
  193. return;
  194. }
  195. if (grvDetail.FocusedColumn == coSelect)
  196. {
  197. if (grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, coSelect).ToString() == "")
  198. {
  199. grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, coSelect, "Y");
  200. // txtInvCode.Text = grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, whCode).ToString();
  201. }
  202. else
  203. {
  204. grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, coSelect, "");
  205. }
  206. }
  207. //int count = 0;
  208. //for (int i = 0; i < grvDetail.RowCount; i++)
  209. //{
  210. // if (grvDetail.GetRowCellValue(i, coSelect).ToString() == "Y")
  211. // {
  212. // count++;
  213. // }
  214. //}
  215. //if (count != 1 && count != 0)
  216. //{
  217. // ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  218. // grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, coSelect, "");
  219. // return;
  220. //}
  221. }
  222. private void btnSearch_Click(object sender, EventArgs e)
  223. {
  224. // string wareHouse = txtInvCode.Text;
  225. // string InvCode = txtInvCode.Text;
  226. // string sqlWhere = "";
  227. // string sql = @" select A.ID
  228. // ,'' as 选择
  229. // ,'' as TransferType
  230. // ,'' as NEWWBS
  231. // ,'' as Reason
  232. // ,WHCode as whCode
  233. // ,A.LotNO as LotNO
  234. // ,B.INVCODE AS ItemCode
  235. // ,B.INVUOM as InvUom
  236. // ,B.INVNAME as INVNAME
  237. // ,B.INVSTD as INVSTD
  238. // ,A.ORDERNO as oldWBS
  239. // ,A.LotQty as WBSQty
  240. // from ICSWareHouseLotInfo A
  241. // INNER join ICSITEMLot C
  242. // on C.LotNo=A.LotNO
  243. // left join ICSINVENTORY B
  244. // on B.INVCODE=C.itemCODE
  245. // left join Sys_EnumValues D
  246. // ON D.EnumValue=B.INVTYPE
  247. // where A.LotQty!=0 ";
  248. // if (wbsOld == " ALL")
  249. // { }
  250. // if (wbsOld == "")
  251. // {
  252. // sql += " and (A.ORDERNO is null or A.ORDERNO='')";
  253. // }
  254. // if (wbsOld != "" && wbsOld != " ALL")
  255. // {
  256. // sql += " and A.ORDERNO='" + wbsOld + "'";
  257. // }
  258. // if (wareHouse != "")
  259. // {
  260. // sql += " and WHCode='" + wareHouse + "'";
  261. // }
  262. // if (InvCode != "")
  263. // {
  264. // string[] InvCodeList = InvCode.Split(',');
  265. // string ItemCodeList = "";
  266. // for (int i = 0; i < InvCodeList.Length; i++)
  267. // {
  268. // if (ItemCodeList == "")
  269. // {
  270. // ItemCodeList = "'" + InvCodeList[i] + "'";
  271. // }
  272. // else
  273. // {
  274. // ItemCodeList += ",'" + InvCodeList[i] + "'";
  275. // }
  276. // }
  277. // sql += " and A.InvCode in (" + ItemCodeList + ")";
  278. // }
  279. // DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  280. // if (data.Rows.Count != 0)
  281. // {
  282. // grdDetail.DataSource = data;
  283. // grvDetail.BestFitColumns();
  284. // }
  285. // else
  286. // {
  287. // grdDetail.DataSource = null;
  288. // grvDetail.BestFitColumns();
  289. // }
  290. }
  291. private void btnSelectAll_Click(object sender, EventArgs e)
  292. {
  293. for (int i = 0; i < grvDetail.RowCount; i++)
  294. {
  295. grvDetail.SetRowCellValue(i, coSelect, true);
  296. }
  297. }
  298. #region 刷新
  299. private void btnRefresh_Click(object sender, EventArgs e)
  300. {
  301. if (sqlconn == null || sqlconn == "")
  302. {
  303. return;
  304. }
  305. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在查找...请稍等...");
  306. try
  307. {
  308. _wait.Show();
  309. FormFilter filter = new FormFilter(AppConfig.GetSourceId(this.Tag.ToString(), btnConfig.Name), false);
  310. filter.OldTempTableName = tempTableName;
  311. dataSource = DBHelper.ExecuteDataset(sqlconn, CommandType.Text, sqltxt).Tables[0];
  312. grdDetail.DataSource = dataSource;
  313. grvDetail.BestFitColumns();
  314. _wait.Close();
  315. }
  316. catch (Exception ex)
  317. {
  318. MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  319. _wait.Close();
  320. }
  321. }
  322. #endregion
  323. private void btnOk_Click(object sender, EventArgs e)
  324. {
  325. bool isXT = false;
  326. int count = 0;
  327. string invnew = "";
  328. string batch = "";
  329. ///手动填写的数据
  330. if (checkInv.Checked)
  331. {
  332. invnew = txtInvCode.Text.Trim();
  333. if (txtInvCode.Text.Trim() == "")
  334. {
  335. ICSBaseSimpleCode.AppshowMessageBox("请选择转换物料!!!");
  336. return;
  337. }
  338. isXT = true;
  339. }
  340. if (checkBatch.Checked)
  341. {
  342. batch = txtBatch.Text.Trim();
  343. if (txtBatch.Text.Trim() == "")
  344. {
  345. ICSBaseSimpleCode.AppshowMessageBox("请选择转换批次!!!");
  346. return;
  347. }
  348. isXT = true;
  349. }
  350. string reason = txtReason.Text.Trim();
  351. string WMSErrorMessage = "";
  352. List<ICSWBSSpecialTransfer> InfoList = new List<ICSWBSSpecialTransfer>();
  353. List<ICSITEMLot> lotList = new List<ICSITEMLot>();
  354. DataTable dtNewRcard = new DataTable();
  355. dtNewRcard.Columns.Add("IsSelect", typeof(bool));
  356. dtNewRcard.Columns.Add("ID", typeof(string));
  357. dtNewRcard.Columns.Add("whCode", typeof(string));
  358. dtNewRcard.Columns.Add("LotNO", typeof(string));
  359. dtNewRcard.Columns.Add("WBSQty", typeof(Decimal));
  360. dtNewRcard.Columns.Add("INVCOENew", typeof(string));
  361. dtNewRcard.Columns.Add("INVCOEOld", typeof(string));
  362. dtNewRcard.Columns.Add("INVNAME", typeof(string));
  363. dtNewRcard.Columns.Add("INVSTD", typeof(string));
  364. dtNewRcard.Columns.Add("BATCHNew", typeof(string));
  365. dtNewRcard.Columns.Add("BATCHOld", typeof(string));
  366. dtNewRcard.Columns.Add("Reason", typeof(string));
  367. dtNewRcard.Columns.Add("Itype", typeof(string));
  368. dtNewRcard.Columns.Add("Idesc", typeof(string));
  369. dtNewRcard.Columns.Add("Ipersetype", typeof(string));
  370. dtNewRcard.Columns.Add("MTIME", typeof(DateTime));
  371. try
  372. {
  373. int NewLot = 0;
  374. string sql = "SELECT TOP 1 LotNO FROM ICSITEMLot WHERE 1=1 AND LotNO LIKE '{0}' AND WorkPoint = '{1}' ORDER BY LotNO DESC";
  375. sql = string.Format(sql, "XT" + DateTime.Now.ToString("yyyyMMdd") + "%", AppConfig.WorkPointCode);
  376. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  377. if (data.Rows.Count > 0 && data != null)
  378. {
  379. NewLot = Convert.ToInt16(data.Rows[0]["LotNO"].ToString().Substring(data.Rows[0]["LotNO"].ToString().Length - 3, 3));
  380. }
  381. else
  382. {
  383. NewLot = 0;
  384. }
  385. if (isXT)
  386. {
  387. bool isBatch = false;//判断是否要有批次号
  388. for (int i = 0; i < grvDetail.RowCount; i++)
  389. {
  390. if (Convert.ToBoolean(grvDetail.GetRowCellValue(i, coSelect).ToString()))
  391. {
  392. count++;
  393. ///带出的数据
  394. string WHCODE = grvDetail.GetRowCellValue(i, whCode).ToString();
  395. string lotno = grvDetail.GetRowCellValue(i, LotNO).ToString();
  396. string ItemLotNo = grvDetail.GetRowCellValue(i, LotNO).ToString();
  397. string invold = grvDetail.GetRowCellValue(i, colItemCode).ToString();
  398. decimal LotQTY = Convert.ToDecimal(grvDetail.GetRowCellValue(i, WBSQty).ToString());
  399. string cBatch = grvDetail.GetRowCellValue(i, colVenderLotNO).ToString();
  400. string invname = grvDetail.GetRowCellValue(i, colInvName).ToString();
  401. string invstd = grvDetail.GetRowCellValue(i, colINVSTD).ToString();
  402. ICSWBSSpecialTransfer transferinfo = new ICSWBSSpecialTransfer();
  403. transferinfo.WareHouseCode = WHCODE;
  404. transferinfo.LotNo = lotno;
  405. if (checkInv.Checked)
  406. {
  407. transferinfo.INVCOENew = invnew;
  408. }
  409. else
  410. {
  411. transferinfo.INVCOENew = invold;
  412. }
  413. transferinfo.INVCOEOld = invold;
  414. isBatch = CheckData(transferinfo.INVCOENew);
  415. if (checkBatch.Checked)
  416. {
  417. transferinfo.BATCHNew = batch;
  418. if (isBatch)
  419. {
  420. if (batch == "")
  421. {
  422. ICSBaseSimpleCode.AppshowMessageBox("转换物料已启用批号,批号信息不能为空!!!");
  423. return;
  424. }
  425. }
  426. else
  427. {
  428. if (batch != "")
  429. {
  430. ICSBaseSimpleCode.AppshowMessageBox("转换物料未启用批号,批号信息应为空!!!");
  431. return;
  432. }
  433. }
  434. }
  435. else
  436. {
  437. transferinfo.BATCHNew = cBatch;
  438. }
  439. transferinfo.BATCHOld = cBatch;
  440. transferinfo.TransferReason = reason;
  441. transferinfo.MUSER = AppConfig.UserId;
  442. transferinfo.MUSERNAME = AppConfig.UserName;
  443. transferinfo.MTIME = DateTime.Now;
  444. transferinfo.WorkPoint = AppConfig.WorkPointCode;
  445. transferinfo.NewLotNo = "XT" + DateTime.Now.ToString("yyyyMMdd") + (NewLot + count).ToString().PadLeft(3, '0');
  446. transferinfo.LotStatus = "待审核";
  447. InfoList.Add(transferinfo);
  448. ICSITEMLot Info = new ICSITEMLot();
  449. Info.LOTQTY = LotQTY;
  450. Info.LotNO = "XT" + DateTime.Now.ToString("yyyyMMdd") + (NewLot + count).ToString().PadLeft(3, '0');
  451. if (checkInv.Checked)
  452. {
  453. Info.ItemCode = invnew;
  454. }
  455. else
  456. {
  457. Info.ItemCode = invold;
  458. }
  459. Info.TransNO = "";
  460. Info.TransLine = "";
  461. Info.VENDORITEMCODE = "";
  462. if (checkBatch.Checked)
  463. {
  464. Info.VenderLotNO = batch;
  465. }
  466. else
  467. {
  468. Info.VenderLotNO = cBatch;
  469. }
  470. Info.PRODUCTDATE = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
  471. Info.ACTIVE = "Y";
  472. Info.Exdate = Convert.ToDateTime("2999-12-31");
  473. Info.TYPE = "形态转换";
  474. Info.EATTRIBUTE3 = Convert.ToDecimal(grvDetail.GetRowCellValue(i, EATTRIBUTE3).ToString());
  475. lotList.Add(Info);
  476. //写入内存
  477. DataRow row = dtNewRcard.NewRow();
  478. row["IsSelect"] = false;
  479. row["whCode"] = WHCODE;
  480. row["LotNO"] = lotno;
  481. row["WBSQty"] = LotQTY;
  482. if (checkInv.Checked)
  483. {
  484. row["INVCOENew"] = invnew;
  485. }
  486. else
  487. {
  488. row["INVCOENew"] = invold;
  489. }
  490. row["INVCOEOld"] = invold;
  491. row["INVNAME"] = invname;
  492. row["INVSTD"] = invstd;
  493. row["BATCHOld"] = cBatch;
  494. if (checkBatch.Checked)
  495. {
  496. row["BATCHNew"] = batch;
  497. }
  498. else
  499. {
  500. row["BATCHNew"] = cBatch;
  501. }
  502. row["Reason"] = reason;
  503. row["MTIME"] = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
  504. dtNewRcard.Rows.Add(row);
  505. }
  506. }
  507. if (count == 0)
  508. {
  509. ICSBaseSimpleCode.AppshowMessageBox("请至少选择一条数据进行保存!");
  510. return;
  511. }
  512. using (SqlConnection conn = new SqlConnection(AppConfig.AppConnectString))
  513. {
  514. conn.Open();
  515. using (SqlTransaction trans = conn.BeginTransaction())
  516. {
  517. try
  518. {
  519. ICSWBSSpecailTransferBLL.UpdateTransWMS(conn, trans, InfoList, lotList, AppConfig.AppConnectString);
  520. trans.Commit();
  521. }
  522. catch (Exception ex)
  523. {
  524. trans.Rollback();
  525. MessageBox.Show("转换异常:" + ex.Message);
  526. return;
  527. }
  528. }
  529. conn.Close();
  530. }
  531. }
  532. else
  533. {
  534. ICSBaseSimpleCode.AppshowMessageBox("未选择转换的信息!");
  535. return;
  536. }
  537. //ICSWBSSpecailTransferBLL.Add(transferinfo, AppConfig.AppConnectString);
  538. }
  539. catch (Exception ex)
  540. {
  541. MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  542. return;
  543. }
  544. if (WMSErrorMessage == "")
  545. {
  546. ICSBaseSimpleCode.AppshowMessageBox("保存成功!");
  547. gridControlDetail.DataSource = dtNewRcard;
  548. grvDetailView.BestFitColumns();
  549. btnRefresh_Click(null, null);
  550. }
  551. else
  552. {
  553. MessageBox.Show(WMSErrorMessage);
  554. }
  555. }
  556. private void btncancle_Click(object sender, EventArgs e)
  557. {
  558. this.DialogResult = DialogResult.Cancel;
  559. this.Close();
  560. }
  561. private void FormCartonProtectSelect_Load(object sender, EventArgs e)
  562. {
  563. LanguageConvert.ChangeLanguage(this, "1");
  564. init();
  565. btnFilter_Click(sender, e);
  566. }
  567. private bool CheckData(string cInvCode)
  568. {
  569. #region 判断是否要有批次号
  570. DataTable dt = ICSPOArriveBLL.GetBatch(cInvCode, AppConfig.WorkPointCode, AppConfig.AppConnectString);
  571. if (dt != null && dt.Rows.Count > 0)
  572. {
  573. if (dt.Rows[0]["INVCONTROLTYPE"].ToString().Trim().ToUpper() == "TRUE")
  574. {
  575. return true;
  576. }
  577. else
  578. {
  579. return false;
  580. }
  581. }
  582. else
  583. {
  584. throw new Exception("物料存货信息取得失败");
  585. }
  586. #endregion
  587. }
  588. private void init()
  589. {
  590. string sql = @"select distinct INVCODE AS 物料编号,INVNAME AS 物料名称 from ICSINVENTORY";
  591. sql = string.Format(sql);
  592. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  593. txtInvCode.Properties.ValueMember = "物料编号";
  594. txtInvCode.Properties.DisplayMember = "物料编号";
  595. txtInvCode.Properties.DataSource = dt;
  596. txtInvCode.Properties.NullText = "";//空时的值
  597. txtInvCode.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
  598. txtInvCode.Properties.ValidateOnEnterKey = true;//回车确认
  599. txtInvCode.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
  600. txtInvCode.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
  601. //自适应宽度
  602. txtInvCode.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
  603. }
  604. private void txtPORow_Click(object sender, EventArgs e)
  605. {
  606. //if (txtWBS.Text.Trim() == "") return;
  607. //try
  608. //{
  609. // if (txtWBS.Text.Trim() == "") return;
  610. // string sql = @"SELECT DISTINCT PORow FROM [dbo].[ICSPO_PoMain]
  611. // WHERE POCode = '" + txtWBS.Text.Trim()+ @"'
  612. // ORDER BY PORow";
  613. // DataTable InvTypeDt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  614. // txtPORow.DataSource = InvTypeDt;
  615. // txtPORow.ValueMember = "PORow";
  616. // txtPORow.DisplayMember = "PORow";
  617. //}
  618. //catch (Exception ex)
  619. //{
  620. // ICSBaseSimpleCode.AppshowMessageBox(ex.ToString());
  621. //}
  622. }
  623. private void txtWHCode_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  624. {
  625. ButtonEdit btn = (ButtonEdit)sender;
  626. string sql = @" SELECT Serial,StorageCode AS 仓库编码,StorageName AS 仓库名称
  627. FROM dbo.ICSStorage";
  628. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  629. FormDataRefer reForm = new FormDataRefer();
  630. reForm.FormTitle = "人员信息";
  631. DataTable menuData = data;
  632. reForm.DataSource = menuData;
  633. reForm.MSelectFlag = false;
  634. reForm.RowIndexWidth = 35;
  635. reForm.HideCols.Add("Serial");
  636. reForm.FormWidth = 500;
  637. reForm.FormHeight = 500;
  638. if (reForm.ShowDialog() == DialogResult.OK)
  639. {
  640. DataTable retData = reForm.ReturnData;
  641. foreach (DataRow dr in retData.Rows)
  642. {
  643. txtInvCode.Text = dr["仓库名称"].ToString();
  644. txtInvCode.Tag = dr["Serial"].ToString();
  645. }
  646. }
  647. }
  648. private void labelControl7_Click(object sender, EventArgs e)
  649. {
  650. }
  651. private void txtInvCode_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  652. {
  653. ButtonEdit btn = (ButtonEdit)sender;
  654. string sql = @"select distinct INVCODE AS 物料编号,INVNAME AS 物料名称 from ICSINVENTORY";
  655. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  656. FormDataRefer reForm = new FormDataRefer();
  657. reForm.FormTitle = "物料列表";
  658. DataTable menuData = data;
  659. reForm.DataSource = menuData;
  660. reForm.MSelectFlag = false;
  661. reForm.RowIndexWidth = 35;
  662. reForm.FormWidth = 500;
  663. reForm.FormHeight = 500;
  664. if (reForm.ShowDialog() == DialogResult.OK)
  665. {
  666. DataTable retData = reForm.ReturnData;
  667. foreach (DataRow dr in retData.Rows)
  668. {
  669. txtInvCode.Text = dr["物料编号"].ToString();
  670. //txtQTY.Text = dr["库存"].ToString();
  671. //txtUnit.Text = dr["物料单位"].ToString();
  672. }
  673. }
  674. }
  675. private void txtTransferQTY_KeyPress(object sender, KeyPressEventArgs e)
  676. {
  677. if (!(Char.IsNumber(e.KeyChar)) && e.KeyChar != (char)8)
  678. {
  679. e.Handled = true;
  680. }
  681. }
  682. private void btnCancelAll_Click(object sender, EventArgs e)
  683. {
  684. for (int i = 0; i < grvDetail.RowCount; i++)
  685. {
  686. grvDetail.SetRowCellValue(i, coSelect, false);
  687. }
  688. }
  689. private void simpleButton4_Click(object sender, EventArgs e)
  690. {
  691. try
  692. {
  693. SimpleButton btntemp = (SimpleButton)sender;
  694. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  695. {
  696. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  697. return;
  698. }
  699. List<PrintPara> parasList = new List<PrintPara>();
  700. List<ICSITEMLot> InfoList = new List<ICSITEMLot>();
  701. for (int i = 0; i < grvDetail.RowCount; i++)
  702. {
  703. if (grvDetail.GetRowCellValue(i, coSelect).ToString() == "Y")
  704. {
  705. PrintPara para = new PrintPara();
  706. para.PrintKey = "LOTNO";
  707. para.PrintValues = new object[] { grvDetail.GetRowCellValue(i, LotNO).ToString() };
  708. parasList.Add(para);
  709. ICSITEMLot Info = new ICSITEMLot();
  710. Info.LotNO = grvDetail.GetRowCellValue(i, LotNO).ToString();
  711. Info.lastPrintUSERID = AppConfig.UserId;
  712. Info.lastPrintTime = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss");
  713. Info.WorkPoint = AppConfig.WorkPointCode;
  714. InfoList.Add(Info);
  715. }
  716. }
  717. if (parasList.Count == 0)
  718. {
  719. ICSBaseSimpleCode.AppshowMessageBox("请选择数据!");
  720. return;
  721. }
  722. FormPrintDialog f = new FormPrintDialog("015", this.Text, parasList, false, null);
  723. f.ShowDialog();
  724. //更新打印信息
  725. //ICSRdrecord2LOTBLL.updatePrint(InfoList, AppConfig.AppConnectString);
  726. }
  727. catch (Exception ex)
  728. {
  729. MessageBox.Show(ex.ToString());
  730. }
  731. }
  732. private void checkInv_CheckedChanged(object sender, EventArgs e)
  733. {
  734. if (checkInv.Checked)
  735. {
  736. txtInvCode.Enabled = true;
  737. }
  738. else
  739. {
  740. txtInvCode.Enabled = false;
  741. txtInvCode.Text = null;
  742. }
  743. }
  744. private void checkBatch_CheckedChanged(object sender, EventArgs e)
  745. {
  746. if (checkBatch.Checked)
  747. {
  748. txtBatch.ReadOnly = false;
  749. txtBatch.Enabled = true;
  750. }
  751. else
  752. {
  753. txtBatch.ReadOnly = true;
  754. txtBatch.Enabled = false;
  755. txtBatch.Text = null;
  756. }
  757. }
  758. private void grvDetail_CellValueChanging(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
  759. {
  760. }
  761. }
  762. }