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

920 lines
40 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. namespace ICSSoft.Frame.APP
  27. {
  28. public partial class FormICSWareHouseLotInfoLog : DevExpress.XtraEditors.XtraForm
  29. {
  30. private string sqltxt = "";
  31. private string sqlconn = "";
  32. String guid = AppConfig.GetGuid();
  33. private DataTable dataSource = null;
  34. string receiptno = "";
  35. int receiptline;
  36. #region 构造函数
  37. public FormICSWareHouseLotInfoLog()
  38. {
  39. InitializeComponent();
  40. this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  41. this.WindowState = FormWindowState.Maximized;
  42. }
  43. #endregion
  44. #region 操作权限
  45. public DataTable RightOfExute()
  46. {
  47. DataTable rData = new DataTable();
  48. rData.Columns.Add("BtnName");
  49. rData.Columns.Add("ActionName");
  50. //查看权限(必须有)
  51. DataRow seeRow = rData.NewRow();
  52. seeRow["BtnName"] = "see";
  53. seeRow["ActionName"] = "查看";
  54. rData.Rows.Add(seeRow);
  55. List<Control> ControlList = new List<Control>();
  56. ControlList.Add(btnStorage);
  57. foreach (Control ctr in ControlList)
  58. {
  59. if (ctr.GetType() == typeof(SimpleButton))
  60. {
  61. DataRow dr = rData.NewRow();
  62. dr["BtnName"] = ctr.Name;
  63. dr["ActionName"] = ctr.Text;
  64. rData.Rows.Add(dr);
  65. }
  66. }
  67. rData.AcceptChanges();
  68. return rData;
  69. }
  70. public DataTable RightOfData()// 数据权限
  71. {
  72. DataTable rData = new DataTable();
  73. rData.Columns.Add("BodyName");
  74. rData.Columns.Add("ControlName");
  75. rData.Columns.Add("ControlCaption");
  76. rData.AcceptChanges();
  77. return rData;
  78. }
  79. #endregion
  80. #region 退出
  81. private void btnClose_Click(object sender, EventArgs e)
  82. {
  83. AppConfig.CloseFormShow(this.Text);
  84. this.Close();
  85. }
  86. private void btnExit_Click(object sender, EventArgs e)
  87. {
  88. AppConfig.CloseFormShow(this.Text);
  89. this.Close();
  90. }
  91. #endregion
  92. #region 移动窗体
  93. private const int WM_NCHITTEST = 0x84;
  94. private const int HTCLIENT = 0x1;
  95. private const int HTCAPTION = 0x2;
  96. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  97. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  98. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  99. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  100. //重写窗体,使窗体可以不通过自带标题栏实现移动
  101. protected override void WndProc(ref Message m)
  102. {
  103. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  104. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  105. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  106. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  107. switch (m.Msg)
  108. {
  109. case WM_NCHITTEST:
  110. base.WndProc(ref m);
  111. if ((int)m.Result == HTCLIENT)
  112. m.Result = (IntPtr)HTCAPTION;
  113. return;
  114. }
  115. //拦截双击标题栏、移动窗体的系统消息
  116. if (m.Msg != 0xA3)
  117. {
  118. base.WndProc(ref m);
  119. }
  120. }
  121. #endregion
  122. #region 列表
  123. private void grvDetail_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
  124. {
  125. if (e.Info.IsRowIndicator && e.RowHandle >= 0)
  126. e.Info.DisplayText = (e.RowHandle + 1).ToString();
  127. }
  128. #endregion
  129. #region 过滤
  130. private string tempTableName = "";
  131. private void btnFilter_Click(object sender, EventArgs e)
  132. {
  133. FormFilter filter = new FormFilter(AppConfig.GetSourceId(this.Tag.ToString(), btnConfig.Name));
  134. filter.OldTempTableName = tempTableName;
  135. if (filter.ShowDialog() == DialogResult.OK)
  136. {
  137. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在查找...请稍等...");
  138. try
  139. {
  140. _wait.Show();
  141. tempTableName = filter.NewTempTableName;
  142. sqltxt = filter.SqlText;
  143. sqlconn = filter.FilterConnectString;
  144. dataSource = filter.FilterData.Tables[0];
  145. grdDetail.DataSource = dataSource;
  146. grvDetail.BestFitColumns();
  147. rptPage.RecordNum = dataSource.Rows.Count;
  148. rptPage.PageSize = 499;
  149. rptPage.PageIndex = 1;
  150. rptPage.ReLoad();
  151. rptPage.PageSize = 500;
  152. rptPage.PageIndex = 1;
  153. rptPage.ReLoad();
  154. _wait.Close();
  155. }
  156. catch (Exception ex)
  157. {
  158. MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  159. _wait.Close();
  160. }
  161. }
  162. }
  163. #endregion
  164. #region 绑定数据源
  165. private void btnConfig_Click(object sender, EventArgs e)
  166. {
  167. if (AppConfig.UserCode.ToLower() != "demo")
  168. {
  169. ICSBaseSimpleCode.AppshowMessageBox("您没有权限设置数据源,请联系软件提供商!");
  170. return;
  171. }
  172. FormDataSource fdata = new FormDataSource(AppConfig.GetMenuId(this.Tag.ToString()), btnConfig.Name);
  173. fdata.ShowDialog();
  174. }
  175. #endregion
  176. #region 分页
  177. private void rptPage_PageIndexChanged(object Sender, EventArgs e)
  178. {
  179. DataTable data = AppConfig.GetPageData(dataSource, rptPage.PageIndex, rptPage.PageSize).Copy();
  180. //DataTable data = AppConfig.GetPageDataByDb(tempTableName, "pagerowindex", rptPage.PageSize, rptPage.PageIndex, dataSource.Rows.Count);
  181. grdDetail.DataSource = data;
  182. }
  183. #endregion
  184. #region 过滤方法
  185. private void FormContainerManager_FormClosing(object sender, FormClosingEventArgs e)
  186. {
  187. AppConfig.DropTemTable(tempTableName);
  188. }
  189. #endregion
  190. #region 全选
  191. private void btnSelectAll_Click(object sender, EventArgs e)
  192. {
  193. grvDetail.PostEditor();
  194. this.Validate();
  195. for (int i = 0; i < grvDetail.RowCount; i++)
  196. {
  197. grvDetail.SetRowCellValue(i, colisSelect, "Y");
  198. }
  199. }
  200. #endregion
  201. #region 全消
  202. private void btnCancelAll_Click(object sender, EventArgs e)
  203. {
  204. grvDetail.PostEditor();
  205. this.Validate();
  206. for (int i = 0; i < grvDetail.RowCount; i++)
  207. {
  208. grvDetail.SetRowCellValue(i, colisSelect, "");
  209. }
  210. }
  211. #endregion
  212. #region 双击
  213. private void grvDetail_DoubleClick(object sender, EventArgs e)
  214. {
  215. if (grvDetail.FocusedRowHandle < 0)
  216. {
  217. return;
  218. }
  219. if (grvDetail.FocusedColumn == colisSelect)
  220. {
  221. if (grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colisSelect).ToString() == "")
  222. {
  223. grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colisSelect, "Y");
  224. }
  225. else
  226. {
  227. grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colisSelect, "");
  228. }
  229. }
  230. }
  231. #endregion
  232. #region 导出
  233. private void btnOutPut_Click(object sender, EventArgs e)
  234. {
  235. FormOutExcel foe = new FormOutExcel(this.Tag.ToString(), grdDetail);
  236. foe.ShowDialog();
  237. }
  238. #endregion
  239. #region 刷新
  240. private void btnRefresh_Click(object sender, EventArgs e)
  241. {
  242. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在查找...请稍等...");
  243. try
  244. {
  245. _wait.Show();
  246. FormFilter filter = new FormFilter(AppConfig.GetSourceId(this.Tag.ToString(), btnConfig.Name), false);
  247. filter.OldTempTableName = tempTableName;
  248. //tempTableName = filter.NewTempTableName;
  249. //DataTable data = DBHelper.ExecuteDataset(AppConfig.FrameConnectString, CommandType.Text, "select * from " + tempTableName).Tables[0];
  250. dataSource = DBHelper.ExecuteDataset(sqlconn, CommandType.Text, sqltxt).Tables[0];
  251. grdDetail.DataSource = dataSource;
  252. grvDetail.BestFitColumns();
  253. rptPage.RecordNum = dataSource.Rows.Count;
  254. rptPage.PageIndex = 1;
  255. rptPage.ReLoad();
  256. _wait.Close();
  257. }
  258. catch (Exception ex)
  259. {
  260. MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  261. _wait.Close();
  262. }
  263. }
  264. #endregion
  265. #region 新增
  266. private void btnCreate_Click(object sender, EventArgs e)
  267. {
  268. SimpleButton btntemp = (SimpleButton)sender;
  269. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  270. {
  271. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  272. return;
  273. }
  274. FormDCTAdd add = new FormDCTAdd();
  275. add.ShowDialog();
  276. btnRefresh_Click(null, null);
  277. }
  278. #endregion
  279. private void grvDetail_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
  280. {
  281. if (e.RowHandle >= 0 && e.Column.FieldName == "DCTCODE")
  282. {
  283. //e.DisplayText = FormatHelper.
  284. e.CellValue = "cccc";
  285. }
  286. }
  287. private void FormDCT_Load(object sender, EventArgs e)
  288. {
  289. btnFilter_Click(sender, e);
  290. }
  291. #region 退出
  292. private void btnExit_Click_1(object sender, EventArgs e)
  293. {
  294. AppConfig.CloseFormShow(this.Text);
  295. this.Close();
  296. }
  297. #endregion
  298. #region 库位按钮
  299. private void repositoryItemButtonEdit1_BottonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  300. {
  301. string storageid = "";
  302. if (grvDetail.FocusedColumn == colStackCode)
  303. {
  304. DataTable dt1 = ICSSoft.Frame.Data.BLL.ICSWareHouseLotInfoLogBLL.SelectStorageID(grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colStorageCode).ToString());
  305. if (dt1 != null && dt1.Rows.Count > 0)
  306. {
  307. storageid = dt1.Rows[0][0].ToString();
  308. }
  309. }
  310. DataTable dt = ICSWareHouseLotInfoLogBLL.SearchStackInfoList(storageid, AppConfig.AppConnectString);
  311. FormDataRefer reForm = new FormDataRefer();
  312. reForm.FormTitle = "库位";
  313. reForm.DataSource = dt;
  314. reForm.MSelectFlag = false;
  315. reForm.RowIndexWidth = 35;
  316. reForm.HideCols.Add("guid");
  317. reForm.FormWidth = 500;
  318. reForm.FormHeight = 500;
  319. if (reForm.ShowDialog() == DialogResult.OK)
  320. {
  321. DataTable retData = reForm.ReturnData;
  322. foreach (DataRow dr in retData.Rows)
  323. {
  324. FormICSStackUIModel Item = new FormICSStackUIModel();
  325. //Item.Serial = dr["guid"].ToString();
  326. Item.StackCode = dr["库位代码"].ToString();
  327. Item.StackName = dr["库位名称"].ToString();
  328. if (grvDetail.FocusedRowHandle < 0)
  329. {
  330. return;
  331. }
  332. if (grvDetail.FocusedColumn == colStackCode)
  333. {
  334. grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colStackCode, Item.StackCode);
  335. }
  336. }
  337. }
  338. }
  339. #endregion
  340. #region 物料追溯信息按钮
  341. private void repositoryItemButtonEdit2_BottonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  342. {
  343. string receiptno = "";
  344. int receiptline;
  345. if (grvDetail.FocusedColumn == colITEMLot)
  346. {
  347. receiptno = grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colReceiptNO).ToString();
  348. receiptline = Convert.ToInt32(grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colReceiptLine));
  349. FormICSITEMLOTAdd linkDetail = new FormICSITEMLOTAdd(receiptno, receiptline);
  350. linkDetail.ShowDialog();
  351. }
  352. }
  353. #endregion
  354. #region 物料入库按钮
  355. private void btnStorage_Click(object sender, EventArgs e)
  356. {
  357. int count = 0;
  358. for (int j = 0; j < grvDetail.RowCount; j++)
  359. {
  360. if (grvDetail.GetRowCellValue(j, colisSelect).ToString() == "Y")
  361. {
  362. count++;
  363. }
  364. }
  365. if (count != 1)
  366. {
  367. ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行入库!!!");
  368. return;
  369. }
  370. int i = grvDetail.FocusedRowHandle;
  371. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  372. {
  373. receiptno = grvDetail.GetRowCellValue(i, colReceiptNO).ToString();
  374. receiptline = Convert.ToInt32(grvDetail.GetRowCellValue(i, colReceiptLine));
  375. #region 判断
  376. //物料的检验结果必须为合格:TBLINVReceiptDetail.IQCStatus=Qualified
  377. if (grvDetail.GetRowCellValue(i, colIQCStatus).ToString() != "合格")
  378. {
  379. ICSBaseSimpleCode.AppshowMessageBox("对不起,您选择的物料检验未合格不能入库!");
  380. return;
  381. }
  382. //检查入库数量不能为零
  383. if (Convert.ToInt32(grvDetail.GetRowCellValue(i, colACTQTY)) == 0)
  384. {
  385. ICSBaseSimpleCode.AppshowMessageBox("入库数量为零,不能入库!");
  386. return;
  387. }
  388. //检查库别和库位必须输入
  389. if (string.IsNullOrEmpty(grvDetail.GetRowCellValue(i, colStorageCode).ToString()) || string.IsNullOrEmpty(grvDetail.GetRowCellValue(i, colStackCode).ToString()))
  390. {
  391. ICSBaseSimpleCode.AppshowMessageBox("库别或库位不能为空");
  392. return;
  393. }
  394. //如果入库数量<>收货数量,提示用户
  395. if (!string.IsNullOrEmpty(grvDetail.GetRowCellValue(i, colACTQTY).ToString()) && !string.IsNullOrEmpty(grvDetail.GetRowCellValue(i, colRECEIVEQTY).ToString()))
  396. {
  397. if (Convert.ToDecimal(grvDetail.GetRowCellValue(i, colACTQTY)) != Convert.ToDecimal(grvDetail.GetRowCellValue(i, colRECEIVEQTY)))
  398. {
  399. if (ICSBaseSimpleCode.AppshowMessageBoxRepose("入库数量不等于收货数量,确认继续入库吗?") != DialogResult.OK)
  400. return;
  401. }
  402. }
  403. //如果物料是批管控料或单件管控料:(tblmaterial. MCONTROLTYPE)
  404. //检查TBLITEMLot. TransNO=@入库单号and TransLine=@入库单行的数量sum(TBLITEMLot.LOTQTY)是否等于入库数量,不等于则提示:请维护该物料的批号或单件号。
  405. if (!string.IsNullOrEmpty(grvDetail.GetRowCellValue(i, colACTQTY).ToString()) && !string.IsNullOrEmpty(grvDetail.GetRowCellValue(i, colRECEIVEQTY).ToString()) && !string.IsNullOrEmpty(grvDetail.GetRowCellValue(i, colQualifyQTY).ToString()))
  406. {
  407. if ((Convert.ToDecimal(grvDetail.GetRowCellValue(i, colACTQTY)) != Convert.ToDecimal(grvDetail.GetRowCellValue(i, colRECEIVEQTY))) && (Convert.ToDecimal(grvDetail.GetRowCellValue(i, colACTQTY)) != Convert.ToDecimal(grvDetail.GetRowCellValue(i, colQualifyQTY))))
  408. {
  409. if (ICSBaseSimpleCode.AppshowMessageBoxRepose("入库数量与收货数量、合格数量不相等,确认继续入库吗?") != DialogResult.OK)
  410. return;
  411. }
  412. }
  413. #endregion
  414. try
  415. {
  416. #region 存入库存信息表
  417. if (grvDetail.GetRowCellValue(i, colINVCONTROLTYPE).ToString() == "批次管控" ||
  418. grvDetail.GetRowCellValue(i, colINVCONTROLTYPE).ToString() == "单件管控" ||
  419. grvDetail.GetRowCellValue(i, colINVCONTROLTYPE).ToString() == "不管控")
  420. {
  421. ICSWareHouseInfo lotinfo = new ICSWareHouseInfo();
  422. DataTable dt1 = ICSSoft.Frame.Data.BLL.ICSWareHouseLotInfoLogBLL.SelectStorageID(grvDetail.GetRowCellValue(i, colStorageCode).ToString());
  423. if (dt1 != null && dt1.Rows.Count > 0)
  424. {
  425. lotinfo.WHGUID = dt1.Rows[0][0].ToString();
  426. }
  427. lotinfo.WHCode = grvDetail.GetRowCellValue(i, colStorageCode).ToString();
  428. DataTable dt2 = ICSSoft.Frame.Data.BLL.ICSWareHouseLotInfoLogBLL.SelectStsckID(grvDetail.GetRowCellValue(i, colStackCode).ToString());
  429. if (dt2 != null && dt2.Rows.Count > 0)
  430. {
  431. lotinfo.BinGUID = dt2.Rows[0][0].ToString();
  432. }
  433. lotinfo.BinCode = grvDetail.GetRowCellValue(i, colStackCode).ToString();
  434. DataTable dt3 = ICSSoft.Frame.Data.BLL.ICSWareHouseLotInfoLogBLL.SelectItemID(grvDetail.GetRowCellValue(i, colITEMCODE).ToString());
  435. if (dt3 != null && dt3.Rows.Count > 0)
  436. {
  437. lotinfo.INVGUID = dt3.Rows[0][0].ToString();
  438. }
  439. lotinfo.INVCode = grvDetail.GetRowCellValue(i, colITEMCODE).ToString();
  440. DataTable dt4 = ICSSoft.Frame.Data.BLL.ICSWareHouseLotInfoLogBLL.SelectQTY(lotinfo.WHGUID, lotinfo.BinGUID, lotinfo.INVGUID);
  441. if (dt4 == null || dt4.Rows.Count == 0)
  442. {
  443. if (!string.IsNullOrEmpty(grvDetail.GetRowCellValue(i, colACTQTY).ToString()))
  444. {
  445. lotinfo.QTY = Convert.ToDecimal(grvDetail.GetRowCellValue(i, colACTQTY));
  446. }
  447. }
  448. if (dt4 != null && dt4.Rows.Count > 0)
  449. {
  450. if (!string.IsNullOrEmpty(grvDetail.GetRowCellValue(i, colACTQTY).ToString()) && !string.IsNullOrEmpty(dt4.Rows[0]["QTY"].ToString()))
  451. {
  452. lotinfo.QTY = Convert.ToDecimal(dt4.Rows[0]["QTY"]) + Convert.ToDecimal(grvDetail.GetRowCellValue(i, colACTQTY));
  453. }
  454. }
  455. lotinfo.WorkPoint = AppConfig.WorkPointCode;
  456. lotinfo.MUSER = AppConfig.UserId;
  457. lotinfo.MUSERName = AppConfig.UserName;
  458. lotinfo.MTIME = DateTime.Now;
  459. lotinfo.EATTRIBUTE1 = null;
  460. ICSWareHouseLotInfoLogBLL.WareHouseInfo(lotinfo, AppConfig.AppConnectString);
  461. }
  462. #endregion
  463. #region 存入物料,产品批次的库存信息
  464. if (grvDetail.GetRowCellValue(i, colINVCONTROLTYPE).ToString() == "批次管控" || grvDetail.GetRowCellValue(i, colINVCONTROLTYPE).ToString() == "单件管控")
  465. {
  466. FormICSWareHouseLotInfoUIModel lotinfo2 = new FormICSWareHouseLotInfoUIModel();
  467. if (!string.IsNullOrEmpty(grvDetail.GetRowCellValue(i, colReceiptLine).ToString()))
  468. {
  469. DataTable ddt = ICSSoft.Frame.Data.BLL.ICSWareHouseLotInfoLogBLL.SelectLotNO(grvDetail.GetRowCellValue(i, colReceiptNO).ToString(), Convert.ToInt32(grvDetail.GetRowCellValue(i, colReceiptLine)));
  470. if (ddt != null && ddt.Rows.Count > 0)
  471. {
  472. for (int j = 0; j < ddt.Rows.Count; j++)
  473. {
  474. lotinfo2.ID = AppConfig.GetGuid();
  475. lotinfo2.LotNO = ddt.Rows[j][0].ToString();
  476. DataTable ddt1 = ICSSoft.Frame.Data.BLL.ICSWareHouseLotInfoLogBLL.SelectStorageID(grvDetail.GetRowCellValue(i, colStorageCode).ToString());
  477. if (ddt1 != null && ddt1.Rows.Count > 0)
  478. {
  479. lotinfo2.WHGUID = ddt1.Rows[0][0].ToString();
  480. }
  481. lotinfo2.WHCode = grvDetail.GetRowCellValue(i, colStorageCode).ToString();
  482. DataTable ddt2 = ICSSoft.Frame.Data.BLL.ICSWareHouseLotInfoLogBLL.SelectStsckID(grvDetail.GetRowCellValue(i, colStackCode).ToString());
  483. if (ddt2 != null && ddt2.Rows.Count > 0)
  484. {
  485. lotinfo2.BinGUID = ddt2.Rows[0][0].ToString();
  486. }
  487. lotinfo2.BinCode = grvDetail.GetRowCellValue(i, colStackCode).ToString();
  488. DataTable ddt3 = ICSSoft.Frame.Data.BLL.ICSWareHouseLotInfoLogBLL.SelectItemID(grvDetail.GetRowCellValue(i, colITEMCODE).ToString());
  489. if (ddt3 != null && ddt3.Rows.Count > 0)
  490. {
  491. lotinfo2.INVGUID = ddt3.Rows[0][0].ToString();
  492. }
  493. lotinfo2.INVCode = grvDetail.GetRowCellValue(i, colITEMCODE).ToString();
  494. DataTable ddt4 = ICSSoft.Frame.Data.BLL.ICSWareHouseLotInfoLogBLL.SelectLOTQTY(lotinfo2.LotNO);
  495. if (ddt4 != null && ddt4.Rows.Count > 0)
  496. {
  497. if (!string.IsNullOrEmpty(ddt4.Rows[0][0].ToString()))
  498. {
  499. lotinfo2.LotQty = Convert.ToDecimal(ddt4.Rows[0][0]);
  500. }
  501. }
  502. lotinfo2.ReceiveDate = DateTime.Now;
  503. lotinfo2.WorkPoint = AppConfig.WorkPointCode;
  504. lotinfo2.MUSER = AppConfig.UserId;
  505. lotinfo2.MUSERName = AppConfig.UserName;
  506. lotinfo2.MTIME = DateTime.Now;
  507. lotinfo2.EATTRIBUTE1 = null;
  508. ICSWareHouseLotInfoLogBLL.towh(lotinfo2, AppConfig.AppConnectString);
  509. }
  510. }
  511. }
  512. }
  513. #endregion
  514. #region 存入物料收发交易记录表
  515. if (grvDetail.GetRowCellValue(i, colINVCONTROLTYPE).ToString() == "批次管控" ||
  516. grvDetail.GetRowCellValue(i, colINVCONTROLTYPE).ToString() == "单件管控" ||
  517. grvDetail.GetRowCellValue(i, colINVCONTROLTYPE).ToString() == "不管控")
  518. {
  519. ICSITEMTrans lotinfo3 = new ICSITEMTrans();
  520. lotinfo3.ID = AppConfig.GetGuid();
  521. lotinfo3.TransNO = grvDetail.GetRowCellValue(i, colReceiptNO).ToString();
  522. if (!string.IsNullOrEmpty(grvDetail.GetRowCellValue(i, colReceiptLine).ToString()))
  523. {
  524. lotinfo3.TransLine = Convert.ToInt32(grvDetail.GetRowCellValue(i, colReceiptLine));
  525. }
  526. lotinfo3.ITEMCODE = grvDetail.GetRowCellValue(i, colITEMCODE).ToString();
  527. lotinfo3.FRMStorageCODE = "";
  528. lotinfo3.FRMStackCODE = "";
  529. lotinfo3.TOStorageCODE = grvDetail.GetRowCellValue(i, colStorageCode).ToString();
  530. lotinfo3.TOStackCODE = grvDetail.GetRowCellValue(i, colStackCode).ToString();
  531. if (!string.IsNullOrEmpty(grvDetail.GetRowCellValue(i, colACTQTY).ToString()))
  532. {
  533. lotinfo3.TransQTY = Convert.ToDecimal(grvDetail.GetRowCellValue(i, colACTQTY));
  534. }
  535. lotinfo3.Memo = grvDetail.GetRowCellValue(i, colMEMO).ToString();
  536. lotinfo3.TransType = "收";
  537. lotinfo3.BusinessCode = "";
  538. lotinfo3.WorkPoint = AppConfig.WorkPointCode;
  539. lotinfo3.MUSER = AppConfig.UserId;
  540. lotinfo3.MUSERName = AppConfig.UserName;
  541. lotinfo3.MTIME = DateTime.Now;
  542. lotinfo3.EATTRIBUTE1 = null;
  543. ICSWareHouseLotInfoLogBLL.trans(lotinfo3, AppConfig.AppConnectString);
  544. }
  545. #endregion
  546. #region 存入物料收发交易批号记录表
  547. if (grvDetail.GetRowCellValue(i, colINVCONTROLTYPE).ToString() == "批次管控" ||
  548. grvDetail.GetRowCellValue(i, colINVCONTROLTYPE).ToString() == "单件管控")
  549. {
  550. ICSITEMTransLot lotinfo4 = new ICSITEMTransLot();
  551. if (!string.IsNullOrEmpty(grvDetail.GetRowCellValue(i, colReceiptLine).ToString()))
  552. {
  553. DataTable ddt = ICSSoft.Frame.Data.BLL.ICSWareHouseLotInfoLogBLL.SelectLotNO(grvDetail.GetRowCellValue(i, colReceiptNO).ToString(), Convert.ToInt32(grvDetail.GetRowCellValue(i, colReceiptLine)));
  554. if (ddt != null && ddt.Rows.Count > 0)
  555. {
  556. for (int j = 0; j < ddt.Rows.Count; j++)
  557. {
  558. lotinfo4.ID = AppConfig.GetGuid();
  559. DataTable ddt1 = ICSSoft.Frame.Data.BLL.ICSWareHouseLotInfoLogBLL.SelectTransID(grvDetail.GetRowCellValue(i, colReceiptNO).ToString(), Convert.ToInt32(grvDetail.GetRowCellValue(i, colReceiptLine)));
  560. if (ddt1 != null && ddt1.Rows.Count > 0)
  561. {
  562. lotinfo4.ITEMTransID = ddt1.Rows[0][0].ToString();
  563. }
  564. lotinfo4.LotNO = ddt.Rows[j][0].ToString();
  565. lotinfo4.ITEMCODE = grvDetail.GetRowCellValue(i, colITEMCODE).ToString();
  566. DataTable ddt4 = ICSSoft.Frame.Data.BLL.ICSWareHouseLotInfoLogBLL.SelectLOTQTY(lotinfo4.LotNO);
  567. if (ddt4 != null && ddt4.Rows.Count > 0)
  568. {
  569. if (!string.IsNullOrEmpty(ddt4.Rows[0][0].ToString()))
  570. {
  571. lotinfo4.TransQTY = Convert.ToDecimal(ddt4.Rows[0][0]);
  572. }
  573. }
  574. lotinfo4.Memo = grvDetail.GetRowCellValue(i, colMEMO).ToString();
  575. lotinfo4.WorkPoint = AppConfig.WorkPointCode;
  576. lotinfo4.MUSER = AppConfig.UserId;
  577. lotinfo4.MUSERName = AppConfig.UserName;
  578. lotinfo4.MTIME = DateTime.Now;
  579. ICSWareHouseLotInfoLogBLL.transLOT(lotinfo4, AppConfig.AppConnectString);
  580. }
  581. }
  582. }
  583. }
  584. #endregion
  585. #region 存入物料收发交易详细记录表
  586. ICSITEMTransLotDetail lotinfo5 = new ICSITEMTransLotDetail();
  587. if (grvDetail.GetRowCellValue(i, colINVCONTROLTYPE).ToString() == "单件管控")
  588. {
  589. if (!string.IsNullOrEmpty(grvDetail.GetRowCellValue(i, colReceiptLine).ToString()))
  590. {
  591. DataTable ddt = ICSSoft.Frame.Data.BLL.ICSWareHouseLotInfoLogBLL.SelectLotNO(grvDetail.GetRowCellValue(i, colReceiptNO).ToString(), Convert.ToInt32(grvDetail.GetRowCellValue(i, colReceiptLine)));
  592. if (ddt != null && ddt.Rows.Count > 0)
  593. {
  594. for (int j = 0; j < ddt.Rows.Count; j++)
  595. {
  596. DataTable ddt1 = ICSSoft.Frame.Data.BLL.ICSWareHouseLotInfoLogBLL.SelectSeriaNO(ddt.Rows[j][0].ToString());
  597. if (ddt1 != null && ddt1.Rows.Count > 0)
  598. {
  599. for (int m = 0; m < ddt1.Rows.Count; m++)
  600. {
  601. lotinfo5.ID = AppConfig.GetGuid();
  602. DataTable ddt2 = ICSSoft.Frame.Data.BLL.ICSWareHouseLotInfoLogBLL.SelectTransLotID(ddt.Rows[j][0].ToString());
  603. if (ddt2 != null && ddt2.Rows.Count > 0)
  604. {
  605. lotinfo5.ITEMTransLotID = ddt2.Rows[0][0].ToString();
  606. }
  607. lotinfo5.LotNO = ddt.Rows[j][0].ToString();
  608. lotinfo5.ITEMCODE = grvDetail.GetRowCellValue(i, colITEMCODE).ToString();
  609. lotinfo5.SERIALNO = ddt1.Rows[m][0].ToString();
  610. lotinfo5.WorkPoint = AppConfig.WorkPointCode;
  611. lotinfo5.MUSER = AppConfig.UserId;
  612. lotinfo5.MUSERName = AppConfig.UserName;
  613. lotinfo5.MTIME = DateTime.Now;
  614. lotinfo5.EATTRIBUTE1 = null;
  615. ICSWareHouseLotInfoLogBLL.transLOTDetail(lotinfo5, AppConfig.AppConnectString);
  616. #region 更新物料产品详细信息产品状态
  617. ICSITEMLotDetail itemlotdetail = ICSWareHouseLotInfoLogBLL.selectitemlotdetail(lotinfo5.SERIALNO, lotinfo5.ITEMCODE, AppConfig.AppConnectString);
  618. ICSWareHouseLotInfoLogBLL.updateSerialStatus(lotinfo5.SERIALNO, lotinfo5.ITEMCODE);
  619. try
  620. {
  621. ICSWareHouseLotInfoLogBLL.iqcdetail(itemlotdetail, AppConfig.AppConnectString);
  622. }
  623. catch (Exception ex)
  624. {
  625. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  626. }
  627. #endregion
  628. }
  629. }
  630. }
  631. }
  632. }
  633. }
  634. #endregion
  635. //CloseStatus(receiptno, receiptline);
  636. ICSWareHouseLotInfoLogBLL.updatestatus(receiptno, receiptline);
  637. ICSBaseSimpleCode.AppshowMessageBox("操作成功");
  638. btnRefresh_Click(null, null);
  639. }
  640. catch (Exception ex)
  641. {
  642. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  643. }
  644. }
  645. }
  646. #endregion
  647. #region
  648. // private void CloseStatus(string stno, int stline)
  649. // {
  650. // #region 更新送检单子表的行状态
  651. // ICSASNIQCDETAIL iqcdetail = ICSWareHouseLotInfoLogBLL.selectIQCDetail(stno, stline, AppConfig.AppConnectString);
  652. // ICSWareHouseLotInfoLogBLL.updateSTDSTATUS(stno, stline);
  653. // try
  654. // {
  655. // ICSWareHouseLotInfoLogBLL.iqcdetail(iqcdetail, AppConfig.AppConnectString);
  656. // }
  657. // catch (Exception ex)
  658. // {
  659. // ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  660. // }
  661. // #endregion
  662. // #region 更新送到货单详细表的到货单状态
  663. // ICSINVReceiptDetail receiptdetail = ICSWareHouseLotInfoLogBLL.selectReceiptDetail(stno, stline, AppConfig.AppConnectString);
  664. // ICSWareHouseLotInfoLogBLL.updateRECSTATUS(stno, stline);
  665. // try
  666. // {
  667. // ICSWareHouseLotInfoLogBLL.Receiptdetail(receiptdetail, AppConfig.AppConnectString);
  668. // }
  669. // catch (Exception ex)
  670. // {
  671. // ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  672. // }
  673. // #endregion
  674. // #region 更新送检单主表单据状态
  675. //// string sql = @"select STDSTATUS
  676. //// from ICSASNIQCDETAIL
  677. //// where STNO='" + stno + "' and WorkPoint='" + AppConfig.WorkPointCode + "'";
  678. //// sql = string.Format(sql);
  679. //// DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  680. //// int flag = 0;
  681. //// foreach (DataRow dr in data.Rows)
  682. //// {
  683. //// if (!dr["STDSTATUS"].ToString().Equals("已检已入"))
  684. //// flag = 1;
  685. //// }
  686. //// if (flag == 0)
  687. //// {
  688. // ICSASNIQC iqc = ICSWareHouseLotInfoLogBLL.selectASNIQC(stno, stline, AppConfig.AppConnectString);
  689. // ICSWareHouseLotInfoLogBLL.updateSTATUS(stno, stline);
  690. // try
  691. // {
  692. // ICSWareHouseLotInfoLogBLL.asniqc(iqc, AppConfig.AppConnectString);
  693. // }
  694. // catch (Exception ex)
  695. // {
  696. // ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  697. // }
  698. // //}
  699. // #endregion
  700. // #region 更新到货单主表单据状态
  701. // string sql1 = @"select RECSTATUS
  702. // from ICSINVReceiptDetail
  703. // where ReceiptNO='" + stno + "' and WorkPoint='" + AppConfig.WorkPointCode + "'";
  704. // sql1 = string.Format(sql1);
  705. // DataTable data1 = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql1).Tables[0];
  706. // int flag1 = 0;
  707. // foreach (DataRow dr in data1.Rows)
  708. // {
  709. // if (!dr["RECSTATUS"].ToString().Equals("已经完成"))
  710. // flag1 = 1;
  711. // }
  712. // if (flag1 == 0)
  713. // {
  714. // ICSINVReceipt invreceipt = ICSWareHouseLotInfoLogBLL.selectreceipt(stno, AppConfig.AppConnectString);
  715. // ICSWareHouseLotInfoLogBLL.updatereceiptRECSTATUS(stno);
  716. // try
  717. // {
  718. // ICSWareHouseLotInfoLogBLL.invreceipt(invreceipt, AppConfig.AppConnectString);
  719. // }
  720. // catch (Exception ex)
  721. // {
  722. // ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  723. // }
  724. // }
  725. // #endregion
  726. // }
  727. #endregion
  728. /// <summary>
  729. /// 关闭单据
  730. /// </summary>
  731. /// <param name="sender"></param>
  732. /// <param name="e"></param>
  733. private void btnCancle_Click(object sender, EventArgs e)
  734. {
  735. #region 更新送到货单详细表的到货单状态
  736. List<string> guidList = new List<string>();
  737. for (int i = 0; i < grvDetail.RowCount; i++)
  738. {
  739. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  740. {
  741. guidList.Add(grvDetail.GetRowCellValue(i, colReceiptNO).ToString());
  742. }
  743. }
  744. if (guidList.Count == 0)
  745. {
  746. ICSBaseSimpleCode.AppshowMessageBox("请选择数据!");
  747. return;
  748. }
  749. if (grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colisSelect).ToString() == "Y")
  750. {
  751. string no = grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colReceiptNO).ToString();
  752. int line = Convert.ToInt32(grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colReceiptLine));
  753. ICSINVReceiptDetail receiptdetail = ICSWareHouseLotInfoLogBLL.selectReceiptDetail(no, line, AppConfig.AppConnectString);
  754. ICSWareHouseLotInfoLogBLL.updateRECSTATUS(no, line);
  755. try
  756. {
  757. ICSWareHouseLotInfoLogBLL.Receiptdetail(receiptdetail, AppConfig.AppConnectString);
  758. ICSBaseSimpleCode.AppshowMessageBox("关闭成功");
  759. btnRefresh_Click(null, null);
  760. }
  761. catch (Exception ex)
  762. {
  763. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  764. }
  765. }
  766. #endregion
  767. }
  768. }
  769. }