using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using WMS.Frm.Base; using WMS.Model.RK; using WMS.Common; using WMS.Ctrl; using WMS.Model.Base; using DevExpress.XtraEditors.Repository; using WMS.Business; using WMS.Business.Base; using WMS.Business.Common; using WMS.Business.RK; namespace WMS.FrmRK { public partial class FrmReceive : FormBase { #region 参数列表 /// /// 收货MODEL /// ReceivingModel receModel = new ReceivingModel(); /// /// 通知单MODEL /// WareNoticeModel noticeModel = new WareNoticeModel(); /// /// 通知单MODEL /// WareNoticeModel noticeMessModel = new WareNoticeModel(); /// /// 通知单集合 /// List noticeListModel = new List(); /// /// 通知单明细集合 /// List noticeTabListModel = new List(); /// /// 码盘明细集合 /// List CodeDiskListModel = new List(); /// /// 收货单 /// List receListModel = new List(); /// /// 收货明细数据源 /// List InfoList = new List(); /// /// 收货明细数据源Copy /// List CopyList = new List(); /// /// 明细增加 /// List AddList = new List(); /// /// 明细修改 /// List UpList = new List(); /// /// 明细删除 /// List DelList = new List(); /// /// 入库批次Model /// StorageLotModel stoModel = new StorageLotModel(); /// /// 入库批次MODEL /// List lotList = new List(); /// /// 入库批次明细Model /// StorageLotInfoModel stoInfomodel = new StorageLotInfoModel(); /// /// 入库批次明细集合 /// List stoInfoList = new List(); List stoCopyList = new List(); List stoAddList = new List(); List stoUpList = new List(); List stoDelList = new List(); /// /// 商品MODEL集合 /// List goodsListModel = new List(); /// /// 商品MODEL /// JWGoodsInfoModel goodModel = new JWGoodsInfoModel(); /// /// LEP菜单对象 /// private DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit lueUnits = new RepositoryItemLookUpEdit(); private string unit = string.Empty;//记录原单位 /// /// 业务类型 /// int workflag = 3;//0 增加 1 修改 2 删除 ; int gvNoticeFocid = -1;//通知单当前列索引 int gvReveFocid = -1;//收货单单当前列索引 public string wareNoticeID = string.Empty; bool load = true; #endregion public FrmReceive() { InitializeComponent(); } #region 页面绑定操作 /// /// 页面加载 /// /// /// public void FrmReceive_Load(object sender, EventArgs e) { FrmSelectModle = new ReceivingModel(); bindLEP(); LEPProvater.LoadData(); LEPTeam.LoadData(); DicReceMan.TextBoxFlag = userData.USER_ID; DicReceMan.TextBoxValue = userData.NAME; PageRece.PageEnabled = false; DicNotice.selSql = string.Format(@"select t.WAREHOUSING_ID,d.PROVIDER_NAME from t_rk_ware_notice t LEFT JOIN T_BASE_PROVIDER_DICTIONARY d ON t.PROVIDER_ID = d.PROVIDER_ID where PURCHASE_COUNT>AMOUNT order by WAREHOUSING_ID desc"); if (!string.IsNullOrEmpty(wareNoticeID)) { PageRece.PageEnabled = true; xtraTab.SelectedTabPage = PageRece; bingNotieceGrid(); DicNotice.TextBoxFlag = wareNoticeID; DicNotice.TextBoxValue = wareNoticeID; BSReceive.DataSource = receModel; DicPrintMan.TextBoxFlag = userData.USER_ID; DicPrintMan.TextBoxValue = userData.NAME; DicReceMan.TextBoxFlag = userData.USER_ID; DicReceMan.TextBoxValue = userData.NAME; DateRece.EditValue = DateTime.Now; workflag = 0; } else { bingReceveGrid(new WareNoticeModel()); } } /// /// 通用查询 /// /// public override void LoadListData(DataTable table) { receListModel = ConvertHelper.ConvertToList(table); GCReceive.DataSource = receListModel; GVReceive.RefreshData(); if (receListModel.Count > 0) { receModel = receListModel[0]; } } /// /// 绑定下拉框 /// private void bindLEP() { try { goodsListModel = IBussFactory.Instance().GetGoodsList("", "", "", ""); if (goodsListModel != null) { repositoryItemLookUpEdit1.DataSource = goodsListModel; repositoryItemLookUpEdit1.DisplayMember = "GOODS_NAME"; repositoryItemLookUpEdit1.ValueMember = "GOODS_ID"; } List palletModelList = IBussFactory.Instance().GetPalletList(new PalletModel()); if (palletModelList != null) { repositoryItemLookUpEdit2.DataSource = palletModelList; repositoryItemLookUpEdit2.DisplayMember = "PALLET_NAME"; repositoryItemLookUpEdit2.ValueMember = "PALLET_ID"; } //string errtext = ""; ////string dic = Newtonsoft.Json.JsonConvert.SerializeObject(new WMS.Model.SystemManage.DictionaryTabModel() { VC_DICTIONARY_ID = "vc_uom" }); //string diclist = WebLockConfig.Instance.DictionaryTab.GetDictionaryTab("vc_uom", ref errtext); //List list = Newtonsoft.Json.JsonConvert.DeserializeObject>(diclist); //repositoryItemLookUpEdit3.DataSource = list; //repositoryItemLookUpEdit3.DisplayMember = "VC_DICTIONARY_NAME"; //repositoryItemLookUpEdit3.ValueMember = "VC_CHAR_VALUE"; repositoryItemLookUpEdit3.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("VC_DICTIONARY_NAME", "单位")); repositoryItemLookUpEdit3.ValueMember = "VC_CHAR_VALUE"; repositoryItemLookUpEdit3.DisplayMember = "VC_DICTIONARY_NAME"; DataTable ds = IBussFactory.Instance().GetCustomCtrlData("t_sys_dictionary_tab", "VC_CHAR_VALUE", "VC_DICTIONARY_NAME", " VC_DICTIONARY_TYPE = 'vc_uom' and c_flag = '1'", ""); if(ds!=null) repositoryItemLookUpEdit3.DataSource = ds; lueUnits.NullText = ""; lueUnits.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("UNIT_NAME", "单位")); lueUnits.ValueMember = "UNIT"; lueUnits.DisplayMember = "UNIT_NAME"; repositoryItemLookUpEdit4.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("VC_DICTIONARY_NAME", "重量单位")); repositoryItemLookUpEdit4.ValueMember = "VC_CHAR_VALUE"; repositoryItemLookUpEdit4.DisplayMember = "VC_DICTIONARY_NAME"; DataTable dsResult = IBussFactory.Instance().GetCustomCtrlData("t_sys_dictionary_tab", "VC_CHAR_VALUE", "VC_DICTIONARY_NAME", " VC_DICTIONARY_TYPE = 'kg_unit' and c_flag = '1'", ""); if (dsResult != null) repositoryItemLookUpEdit4.DataSource = dsResult; } catch { SystemCommon.ShowErrorMessageBox("未知错误,请检查网络连接!如仍无法解决问题请联系我们!"); } } /// /// 通知单绑定 /// private void bingNotieceGrid() { string errstr = ""; if (!string.IsNullOrEmpty(DicNotice.TextBoxValue)) { noticeModel = new WareNoticeModel() { WAREHOUSING_ID = DicNotice.TextBoxValue }; } else { noticeModel = new WareNoticeModel() { WAREHOUSING_ID = wareNoticeID }; } try { noticeListModel= IBussFactory.Instance().GetWareNoticeList(noticeModel); if (noticeListModel.Count > 0) { noticeModel = noticeListModel[0]; bingReceveGrid(noticeModel); } } catch { SystemCommon.ShowErrorMessageBox("未知错误,请检查网络连接!如仍无法解决问题请联系我们!"); } } /// /// 收货单绑定 /// /// 通知单 private void bingReceveGrid(WareNoticeModel Notice) { receModel = new ReceivingModel(); receModel.NOTICE_ID = Notice.WAREHOUSING_ID; receModel.CAR_ID = Notice.CARNO; receModel.DRIVER = Notice.DRIVER; receModel.PROVIDER_ID = Notice.PROVIDER_ID; receModel.SHIPPERS = Notice.SHIPPERS; receModel.BUY_NUM_SUM = Notice.PURCHASE_COUNT; receModel.RECE_DATE = DateTime.Now; receModel.ORI_BILL = Notice.PURCHASE_ID; try { receListModel = IBussFactory.Instance().GetList(receModel); } catch { SystemCommon.ShowErrorMessageBox("未知错误,请检查网络连接!如仍无法解决问题请联系我们!"); } GCReceive.DataSource = receListModel; GVReceive.RefreshData(); if (receListModel.Count > 0) { receModel = receListModel[0]; } bingInfoGrid(Notice, receModel); } /// /// 绑定收货明细 /// /// 通知单 /// 入库单 private void bingInfoGrid(WareNoticeModel Notice,ReceivingModel Receve) { string errtxt = ""; if (!string.IsNullOrEmpty(Receve.RECE_ID)) { if (!string.IsNullOrEmpty(Receve.RECE_ID)) { try { InfoList = IBussFactory.Instance().GetInfoList(Receve.RECE_ID); } catch { SystemCommon.ShowErrorMessageBox("未知错误,请检查网络连接!如仍无法解决问题请联系我们!"); } } } else if (Notice.TRAY_STATE == "0" || Notice.TRAY_STATE == null) { WareNoticeTabModel model = new WareNoticeTabModel(); model.WAREHOUSING_ID = Notice.WAREHOUSING_ID; try { noticeTabListModel = IBussFactory.Instance().GetWareNoticeTabList(model); } catch { SystemCommon.ShowErrorMessageBox("未知错误,请检查网络连接!如仍无法解决问题请联系我们!"); } if (noticeTabListModel.Count > 0) { InfoList.Clear(); foreach (WareNoticeTabModel tabmodel in noticeTabListModel) { ReceivingInfoModel imodel = new ReceivingInfoModel(); imodel.BUY_NUM = tabmodel.AMOUNT; imodel.GOODS_ID = tabmodel.GOODS_ID; imodel.GOODS_NAME = tabmodel.GOODS_NAME; imodel.GRO_WEIGHT = tabmodel.TOTAL_ROUGH_WEIGHT; imodel.MADE_DATE = tabmodel.PRODUCTION_DATE; imodel.NET_WEIGHT = tabmodel.TOTAL_NET_WEIGH; imodel.RECE_MONEY = tabmodel.TOTAL_MONEY; imodel.RECE_VOLUEM = tabmodel.TOTAL_VOLUME; imodel.STO_TRAY = tabmodel.PACKAGE_ID; imodel.OPERATORID = userData.USER_ID; imodel.OPERATORNAME = userData.NAME; imodel.OPERATEDATE = DateTime.Now; imodel.VOLUME_UNIT = tabmodel.GVOLUME; imodel.UNIT = tabmodel.UNIT; imodel.PRICE = tabmodel.PRICE; imodel.SCALE_UNIT = tabmodel.SCALE_UNIT; InfoList.Add(imodel); } } } else { CodeDiskModel model = new CodeDiskModel(); model.Warehousing_id = Notice.WAREHOUSING_ID; try { CodeDiskListModel = IBussFactory.Instance().GetCodeDisk(model); } catch { SystemCommon.ShowErrorMessageBox("未知错误,请检查网络连接!如仍无法解决问题请联系我们!"); } if (CodeDiskListModel.Count > 0) { InfoList.Clear(); foreach (CodeDiskModel codeDisk in CodeDiskListModel) { ReceivingInfoModel imodel = new ReceivingInfoModel(); imodel.BUY_NUM = codeDisk.Goods_Num; imodel.GOODS_ID = codeDisk.Goods_id; imodel.GOODS_NAME = codeDisk.Goods_name; imodel.GRO_WEIGHT = codeDisk.Total_rough_weight; imodel.MADE_DATE = codeDisk.Production_date; imodel.NET_WEIGHT = codeDisk.Total_net_weigh; imodel.RECE_MONEY = codeDisk.Total_money; imodel.RECE_VOLUEM = codeDisk.Total_volume; imodel.STO_TRAY = codeDisk.Pallet_id; imodel.OPERATORID = userData.USER_ID; imodel.OPERATORNAME = userData.NAME; imodel.OPERATEDATE = DateTime.Now; imodel.VOLUME_UNIT = codeDisk.Gvolume; imodel.UNIT = codeDisk.Unit; imodel.SCALE_UNIT = codeDisk.Scale_unit; imodel.PRICE = codeDisk.Price; InfoList.Add(imodel); } } } GCReceiveInfo.DataSource = InfoList; GVReceiveInfo.RefreshData(); CopyList = InfoList.ToList(); } /// /// GV单击 /// /// /// private void GVReceive_Click(object sender, EventArgs e) { if (GVReceive.FocusedRowHandle < 0) { return; } receModel = GVReceive.GetFocusedRow() as ReceivingModel; } /// /// GV双击 /// /// /// private void GCReceive_DoubleClick(object sender, EventArgs e) { if (GVReceive.FocusedRowHandle < 0) { return; } LoadForm load = new LoadForm(); DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(load, load.GetType(), false, true, false, 50); DevExpress.XtraSplashScreen.SplashScreenManager.Default.SetWaitFormDescription("正加载窗体...."); receModel = GVReceive.GetFocusedRow() as ReceivingModel; BSReceive.DataSource = receModel; if (!string.IsNullOrEmpty(receModel.RECE_MAN)) { DicReceMan.TextBoxValue = receModel.RECE_MAN_NAME; DicReceMan.TextBoxFlag = receModel.RECE_MAN; } else { DicReceMan.TextBoxValue = userData.NAME; DicReceMan.TextBoxFlag = userData.USER_ID; } if (!string.IsNullOrEmpty(receModel.PRINT_MAN)) { DicPrintMan.TextBoxValue = receModel.PRINT_MAN_NAME; DicPrintMan.TextBoxFlag = receModel.PRINT_MAN; } else { DicPrintMan.TextBoxValue = userData.NAME; DicPrintMan.TextBoxFlag = userData.USER_ID; } DicCar.TextBoxFlag = receModel.CAR_ID; DicCar.TextBoxValue = receModel.CAR_ID; DicNotice.TextBoxFlag = receModel.NOTICE_ID; DicNotice.TextBoxValue = receModel.NOTICE_ID; bingInfoGrid(noticeMessModel, receModel); PageRece.PageEnabled = true; xtraTab.SelectedTabPage = PageRece; DevExpress.XtraSplashScreen.SplashScreenManager.CloseForm(); } #endregion #region 以下是继承的按钮事件 /// /// 新增按钮 /// public void Add() { PageRece.PageEnabled = true; xtraTab.SelectedTabPage = PageRece; DicNotice.Enabled = true; workflag = 0; frmButtonItem["Save"].Enabled = true; frmButtonItem["Rebreak"].Enabled = true; frmButtonItem["Clear"].Enabled = true; frmButtonItem["Audit"].Enabled = true; receModel = new ReceivingModel(); BSReceive.DataSource = receModel; DicCar.TextBoxFlag = null; DicCar.TextBoxValue = null; DicNotice.TextBoxValue = null; DicNotice.TextBoxFlag = null; DicPrintMan.TextBoxFlag = userData.USER_ID; DicPrintMan.TextBoxValue = userData.NAME; DicReceMan.TextBoxFlag = userData.USER_ID; DicReceMan.TextBoxValue = userData.NAME; if (string.IsNullOrEmpty(DicNotice.TextBoxValue)) { InfoList.Clear(); CopyList.Clear(); GVReceiveInfo.RefreshData(); } } /// /// 保存按钮 /// public void Save() { if (workflag == 3) { return; } FrmOperator(workflag); } /// /// 删除按钮 /// public void Del() { if (GVReceive.FocusedRowHandle < 0) { return; } receModel = GVReceive.GetFocusedRow() as ReceivingModel; if (receModel.PRINT_NUM > 0 || receModel.STO_NUM_SUM > 0) { SystemCommon.ShowInfoMessageBox("该单据已不能作废!"); return; } workflag = 2; frmButtonItem["Save"].Enabled = true; } /// /// 修改按钮 /// public void Edit() { if (GVReceive.FocusedRowHandle < 0) { return; } receModel = GVReceive.GetFocusedRow() as ReceivingModel; if (receModel.STO_NUM_SUM > 0) { SystemCommon.ShowErrorMessageBox("该单据已做过入库,不能再修改!"); return; } if (receModel.PRINT_NUM > 0) { SystemCommon.ShowErrorMessageBox("该单据已经派发,不能再修改!"); return; } GCReceive_DoubleClick(null, null); workflag = 1; frmButtonItem["Rebreak"].Enabled = true; frmButtonItem["Clear"].Enabled = true; frmButtonItem["Audit"].Enabled = true; frmButtonItem["Save"].Enabled = true; frmButtonItem["Confirm"].Enabled = false; PageRece.PageEnabled = true; xtraTab.SelectedTabPage = PageRece; } /// /// 确定按钮 /// public void Confirm() { if (receModel.NOTICE_ID == null || InfoList.Count <= 0) { return; } if (receModel.ARR_NUM_SUM != 0) { if (receModel.STO_NUM_SUM == receModel.ARR_NUM_SUM) { SystemCommon.ShowInfoMessageBox("该单据已完成入库!"); return; } } else { SystemCommon.ShowInfoMessageBox("该单据还未到货!"); return; } FormBase formBase = OpenFrmTable("WMS.FrmRK", "FrmStorage");//创建窗体 if (formBase != null) { FrmStorageLot frmStorage = formBase as FrmStorageLot; frmStorage.receModel = receModel; frmStorage.receInfoList = InfoList; if (!OpenTabAddFrm("0306", "FrmStorage", "确认入库-" + receModel.NOTICE_ID)) { frmStorage.FrmStorage_Load (null, null);//如果已经被打开,执行一下窗体加载方法 } } } /// /// 查询按钮 /// public void Search() { bingNotieceGrid(); } /// /// 忙收 /// public void Refresh() { receModel = new ReceivingModel() { RECE_DATE = DateTime.Now }; InfoList.Clear(); CopyList.Clear(); BSReceive.DataSource = receModel; DicNotice.TextBoxFlag = string.Empty; DicNotice.TextBoxValue = string.Empty; BSReceive.ResetBindings(true); GVReceiveInfo.RefreshData(); DicPrintMan.TextBoxFlag = userData.USER_ID; DicPrintMan.TextBoxValue = userData.NAME; DicReceMan.TextBoxFlag = userData.USER_ID; DicReceMan.TextBoxValue = userData.NAME; DateRece.EditValue = DateTime.Now; PageRece.PageEnabled = true; xtraTab.SelectedTabPage = PageRece; workflag = 0; frmButtonItem["Save"].Enabled = true; frmButtonItem["Audit"].Enabled = false; frmButtonItem["Rebreak"].Enabled = true; frmButtonItem["Clear"].Enabled = true; DicNotice.Enabled = false; } /// /// 明细增加 /// public void Rebreak() { if (workflag == 3) { return; } ReceivingInfoModel infomodel = new ReceivingInfoModel() { RECE_ID = receModel.RECE_ID }; InfoList.Add(infomodel); GCReceiveInfo.DataSource = InfoList; GVReceiveInfo.RefreshData(); } /// /// 明细删除 /// public void Clear() { if (GVReceiveInfo.FocusedRowHandle < 0 || InfoList.Count == 0) { return; } ReceivingInfoModel mod = InfoList[GVReceiveInfo.FocusedRowHandle]; InfoList.Remove(mod); if (AddList.Contains(mod)) { AddList.Remove(mod); } if (!string.IsNullOrEmpty(mod.GOODS_ID)) { DelList.Add(mod); } GCReceiveInfo.DataSource = InfoList; GVReceiveInfo.RefreshData(); } /// /// 明细保存 /// public void Audit() { if (AddList.Count > 0 || DelList.Count > 0) { decimal num = receModel.ARR_NUM_SUM; receModel.ARR_NUM_SUM = 0; foreach (ReceivingInfoModel model in AddList) { receModel.ARR_NUM_SUM += model.ARR_NUM; } foreach (ReceivingInfoModel model in DelList) { receModel.ARR_NUM_SUM -= model.ARR_NUM; } string err = IBussFactory.Instance().newReceivingInfoFuc(UpList, AddList, DelList, receModel); if (!string.IsNullOrEmpty(err)) { receModel.ARR_NUM_SUM = num; SystemCommon.ShowErrorMessageBox(err); } else { SystemCommon.ShowInfoMessageBox("明细修改成功!"); receModel.ARR_NUM_SUM = num; } } } /// /// 打印按钮 /// public void Print() { if (!string.IsNullOrEmpty(DicPrintMan.TextBoxFlag)) { receModel.PRINT_MAN = DicPrintMan.TextBoxFlag; } else { receModel.PRINT_MAN = userData.USER_ID; } receModel.PRINT_DATE = DateTime.Now; receModel.PRINT_NUM += 1; string err = IBussFactory.Instance().Update(receModel); if (!string.IsNullOrEmpty(err)) { SystemCommon.ShowErrorMessageBox(err); } else { SystemCommon.ShowInfoMessageBox("打印成功!"); } } /// /// 审核 /// public void AuditDataButton() { } /// /// 反审核 /// public void ReturnAuditDataButton() { } #endregion #region 操作(增、改、删) /// /// 操作(增、改、删) /// /// 0 新增 1修改 2删除 3停用 4启用/param> private void FrmOperator(int flag) { try { GVReceiveInfo.CloseEditor(); GVReceiveInfo.UpdateCurrentRow(); string err = ""; if (flag == 0) { if (InfoList.Count == 0) { return; } foreach (ReceivingInfoModel infomodel in InfoList) { if (infomodel.ARR_NUM == 0) { SystemCommon.ShowInfoMessageBox("商品的到货数量不能为0!"); return; } } receModel = BSReceive.DataSource as ReceivingModel; //string num = WebLockConfig.Instance.WebReceve.execGetSerialNum(); //receModel.RECE_ID = "SH" + DateTime.Now.ToString("yyyyMMdd") + num; receModel.STATIC = "0"; receModel.BUY_NUM_SUM = Convert.ToDecimal(colBUY_NUM.SummaryText); receModel.ARR_NUM_SUM = Convert.ToDecimal(colARR_NUM.SummaryText); receModel.STO_NUM_SUM = Convert.ToDecimal(colSTO_NUM.SummaryText); receModel.SHELVE_NUM_SUM = Convert.ToDecimal(colSHELVE_NUM.SummaryText); receModel.RECE_MAN = DicReceMan.TextBoxFlag; receModel.PRINT_MAN = DicPrintMan.TextBoxFlag; receModel.NOTICE_ID = DicNotice.TextBoxValue; receModel.CAR_ID = DicNotice.TextBoxValue; receModel.ENTRY_MAN = userData.USER_ID; receModel.ENTRY_MAN_NAME = userData.NAME; receModel.ENTRY_DATE = DateTime.Now; //foreach (ReceivingInfoModel infomodel in InfoList) //{ // infomodel.RECE_ID = receModel.RECE_ID; //} string receveModel = Newtonsoft.Json.JsonConvert.SerializeObject(receModel); string receveInfoList = Newtonsoft.Json.JsonConvert.SerializeObject(InfoList); //try //{ // err = WebLockConfig.Instance.WebReceve.execReceveAdd(receveModel, receveInfoList); //} //catch //{ // SystemCommon.ShowErrorMessageBox("未知错误,请检查网络连接!如仍无法解决问题请联系我们!"); //} } else if (flag == 1) { if (InfoList.Count == 0) { return; } receModel.BUY_NUM_SUM = Convert.ToDecimal(colBUY_NUM.SummaryText); receModel.ARR_NUM_SUM = Convert.ToDecimal(colARR_NUM.SummaryText) - receModel.ARR_NUM_SUM; receModel.STO_NUM_SUM = Convert.ToDecimal(colSTO_NUM.SummaryText); receModel.SHELVE_NUM_SUM = Convert.ToDecimal(colSHELVE_NUM.SummaryText); receModel.RECE_MAN = DicReceMan.TextBoxFlag; receModel.PRINT_MAN = DicPrintMan.TextBoxFlag; receModel.ENTRY_MAN = userData.USER_ID; receModel.ENTRY_MAN_NAME = userData.NAME; receModel.ENTRY_DATE = DateTime.Now; receModel.NOTICE_ID = DicNotice.TextBoxValue; receModel.CAR_ID = DicNotice.TextBoxValue; foreach (ReceivingInfoModel infomodel in InfoList) { infomodel.RECE_ID = receModel.RECE_ID; if (infomodel.ARR_NUM == 0) { SystemCommon.ShowInfoMessageBox("到货数量不能为0!"); return; } } try { err = IBussFactory.Instance().Update(receModel, InfoList); } catch { SystemCommon.ShowErrorMessageBox("未知错误,请检查网络连接!如仍无法解决问题请联系我们!"); } } else if (flag == 2) { if (string.IsNullOrEmpty(receModel.RECE_ID) || InfoList.Count == 0) { return; } if (SystemCommon.ShowMessageBoxResult("确定要删除收货单:" + receModel.RECE_ID) == System.Windows.Forms.DialogResult.Yes) { try { err = IBussFactory.Instance().Cancel(receModel); } catch { SystemCommon.ShowErrorMessageBox("未知错误,请检查网络连接!如仍无法解决问题请联系我们!"); } } else { return; } } if (!string.IsNullOrEmpty(err)) { SystemCommon.ShowErrorMessageBox(err); } else { SystemCommon.ShowInfoMessageBox("操作成功!"); LoadForm load = new LoadForm(); DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(load, load.GetType(), false, true, false, 50); DevExpress.XtraSplashScreen.SplashScreenManager.Default.SetWaitFormDescription("正加载窗体...."); bingReceveGrid(noticeMessModel); bingInfoGrid(noticeMessModel,receModel); frmButtonItem["Save"].Enabled = false; frmButtonItem["Rebreak"].Enabled = false; frmButtonItem["Clear"].Enabled = false; frmButtonItem["Audit"].Enabled = false; workflag = 3; PageRece.PageEnabled = true; xtraTab.SelectedTabPage = PageNotice; DicNotice.Enabled = true; AddList.Clear(); DelList.Clear(); DevExpress.XtraSplashScreen.SplashScreenManager.CloseForm(); } } catch (Exception e) { SystemCommon.ShowInfoMessageBox("您的操作出错:" + Environment.NewLine + e.Message); } } /// /// GV 值显示 /// /// /// private void GVReceive_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e) { if (e.Column.FieldName == "STATIC") { if (e.Value != null && e.Value != DBNull.Value) { switch (e.Value.ToString().Trim()) { case "1": e.DisplayText = "已确认"; break; default: e.DisplayText = "未确认"; break; } } } } #endregion /// /// gv 值改变后 /// /// /// private void GVReceiveInfo_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { if (e.RowHandle < 0) { return; } ReceivingInfoModel focModel = GVReceiveInfo.GetRow(e.RowHandle) as ReceivingInfoModel; if (!AddList.Contains(focModel) && !CopyList.Contains(focModel)) { AddList.Add(focModel); } if (e.Column.FieldName == "ARR_NUM") { decimal ARR_NUM = Convert.ToDecimal(GVReceiveInfo.GetFocusedRowCellValue("ARR_NUM")); decimal BUY_NUM = Convert.ToDecimal(GVReceiveInfo.GetFocusedRowCellValue("BUY_NUM")); if (ARR_NUM > BUY_NUM && BUY_NUM != 0) { SystemCommon.ShowInfoMessageBox("请注意:" + Environment.NewLine + "您输入的接收数量大于采购数量!"); } //goodModel = goodsListModel.Find(r => r.GOODS_ID == focModel.GOODS_ID); //focModel.RECE_MONEY = goodModel.PRICE * focModel.ARR_NUM; //focModel.GRO_WEIGHT = goodModel.GROSS_WEIGHT * focModel.ARR_NUM; //focModel.NET_WEIGHT = goodModel.NET_WEIGHT * focModel.ARR_NUM; //focModel.RECE_VOLUEM = goodModel.GVOLUME * focModel.ARR_NUM; //focModel.VOLUME_UNIT = goodModel.GVOLUME; //if (string.IsNullOrEmpty(focModel.UNIT)) //{ // focModel.UNIT = goodModel.UNIT; //} } else { if (e.Column.FieldName == "GOODS_ID") { if (InfoList.Count(r => r.GOODS_ID == focModel.GOODS_ID) >1) { SystemCommon.ShowInfoMessageBox("通知单明细中已包含商品:" + focModel.GOODS_ID); focModel.GOODS_ID = null; GVReceiveInfo.RefreshData(); } } if (e.Column.FieldName == "GOODS_ID" && !string.IsNullOrEmpty(focModel.GOODS_ID)) { //goodModel = goodsListModel.Find(r => r.GOODS_ID == focModel.GOODS_ID); //focModel.PRICE = goodModel.PRICE; //focModel.SCALE_UNIT = goodModel.SCALE_UNIT; //focModel.VOLUME_UNIT = goodModel.GVOLUME; //focModel.UNIT = goodModel.UNIT; if (focModel.ARR_NUM > 0) { //focModel.RECE_MONEY = goodModel.PRICE * focModel.ARR_NUM; //focModel.GRO_WEIGHT = goodModel.GROSS_WEIGHT * focModel.ARR_NUM; //focModel.NET_WEIGHT = goodModel.NET_WEIGHT * focModel.ARR_NUM; //focModel.RECE_VOLUEM = goodModel.GVOLUME * focModel.ARR_NUM; //focModel.VOLUME_UNIT = goodModel.GVOLUME; } else { //focModel.RECE_MONEY = isnullnum(goodModel.PRICE) * focModel.BUY_NUM; //focModel.GRO_WEIGHT = isnullnum(goodModel.GROSS_WEIGHT)* focModel.BUY_NUM; //focModel.NET_WEIGHT = isnullnum(goodModel.NET_WEIGHT) * focModel.BUY_NUM; //focModel.RECE_VOLUEM = isnullnum(goodModel.GVOLUME) * focModel.BUY_NUM; //focModel.VOLUME_UNIT = isnullnum(goodModel.GVOLUME); if (string.IsNullOrEmpty(focModel.UNIT)) { //focModel.UNIT = goodModel.UNIT; } } } else if (e.Column.FieldName == "VOLUME_UNIT") { DialogResult result = SystemCommon.ShowMessageBoxResultCancel("您修改了商品:" + focModel.GOODS_ID + "的单位体积!" + Environment.NewLine + "是否修改商品资料内相关信息?"); if (result == DialogResult.Yes) { JWGoodsInfoModel goods = goodsListModel.Find(r => r.INVENTORY_ITEM_ID == focModel.GOODS_ID); //goods.GVOLUME = Convert.ToDecimal(e.Value); IBussFactory.Instance().UpdateGoodsInfo(goods); //if (num <= 0) //{ // SystemCommon.ShowErrorMessageBox("修改失败,请确定相关信息是否准确!"); //} //else //{ // SystemCommon.ShowInfoMessageBox("修改商品信息成功!"); // decimal STO_NUM = Convert.ToDecimal(GVReceiveInfo.GetFocusedRowCellValue("STO_NUM")); // focModel.RECE_VOLUEM = STO_NUM * focModel.VOLUME_UNIT; //} } } else if (e.Column.FieldName == "UNIT") { DataTable dt = lueUnits.DataSource as DataTable; decimal oldUnit = 0; decimal newUnit = 0; foreach (DataRow row in dt.Rows) { if (row[0].ToString() == unit) { oldUnit = decimal .Parse(row[2].ToString()); } if (row[0].ToString() == e.Value.ToString()) { newUnit = decimal.Parse(row[2].ToString()); } } if (focModel.BUY_NUM != 0 && oldUnit != 0) { focModel.BUY_NUM = focModel.BUY_NUM / oldUnit * newUnit; } if (focModel.ARR_NUM != 0 && oldUnit != 0) { focModel.ARR_NUM = focModel.ARR_NUM / oldUnit * newUnit; } //if (focModel.STO_NUM != 0 && oldUnit != 0) //{ // focModel.STO_NUM = focModel.STO_NUM / oldUnit * newUnit; //} } } } private decimal isnullnum(object num) { if (num == null || num == DBNull.Value) { return 0; } else { return Convert.ToDecimal(num); } } /// /// GV值改变时 /// /// /// private void GVReceiveInfo_CellValueChanging(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { ReceivingInfoModel focModel = GVReceiveInfo.GetRow(e.RowHandle) as ReceivingInfoModel; if (CopyList.Contains(focModel)) { if (e.Column.FieldName != "ARR_NUM") { //GVReceiveInfo.SetRowCellValue(e.RowHandle, e.Column, GVReceive.GetFocusedRowCellValue(e.Column.FieldName)); } else if (e.Column.FieldName == "UNIT") { unit = GVReceiveInfo.GetFocusedRowCellValue("UNIT").ToString(); } } } /// /// 通知单选择 /// /// /// private void DicNotice_Button_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(DicNotice.TextBoxValue)) { LoadForm load = new LoadForm(); DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(load, load.GetType(), false, true, false, 50); DevExpress.XtraSplashScreen.SplashScreenManager.Default.SetWaitFormDescription("正在加载数据,请等待...."); bingNotieceGrid(); BSReceive.DataSource = receModel; DicCar.TextBoxFlag = receModel.CAR_ID; DicCar.TextBoxValue = receModel.CAR_ID; DevExpress.XtraSplashScreen.SplashScreenManager.CloseForm(); } } /// /// TAB页切换 /// /// /// private void xtraTab_SelectedPageChanged(object sender, DevExpress.XtraTab.TabPageChangedEventArgs e) { //if (e.Page == PageNotice) //{ // frmButtonItem["Rebreak"].Enabled = false; // frmButtonItem["Clear"].Enabled = false; // frmButtonItem["Audit"].Enabled = false; //} //else //{ // frmButtonItem["Rebreak"].Enabled = true; // frmButtonItem["Clear"].Enabled = true; // frmButtonItem["Audit"].Enabled = true; //} } /// /// 车辆选择 /// /// /// private void DicCar_Button_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(DicCar.TextBoxValue)) { try { LoadForm load = new LoadForm(); DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(load, load.GetType(), false, true, false, 50); DevExpress.XtraSplashScreen.SplashScreenManager.Default.SetWaitFormDescription("正在加载数据,请等待...."); CapacityModel ca = new CapacityModel() { CAR_ID = DicCar.TextBoxValue }; List caList = IBussFactory.Instance().GetList(ca); if (caList != null) { if (caList.Count > 0) { receModel.DRIVER = caList[0].CAR_DRIVER; receModel.CAR_ID = caList[0].CAR_ID; receModel.SHIPPERS = caList[0].CAR_CARRIER; BSReceive.DataSource = receModel; BSReceive.ResetBindings(true); } } DevExpress.XtraSplashScreen.SplashScreenManager.CloseForm(); } catch(Exception ex) { SystemCommon.ShowErrorMessageBox(ex.Message); } } } private void GVReceiveInfo_CustomRowCellEditForEditing(object sender, DevExpress.XtraGrid.Views.Grid.CustomRowCellEditEventArgs e) { if (e.RowHandle < 0) { return; } if (e.Column.FieldName == "UNIT") { ReceivingInfoModel info = GVReceiveInfo.GetFocusedRow() as ReceivingInfoModel; if (info != null && info.GOODS_ID != null) { try { DataTable strResult =IBussFactory.Instance().GetGoodsUnit(info.GOODS_ID); if (strResult != null) { lueUnits.DataSource = strResult; } } catch (Exception) { //SystemCommon.ShowInfoMessageBox("未知错误,请检查网络连接!如仍无法解决问题请联系我们!"); } // Newtonsoft.Json.JsonConvert.DeserializeObject(strResult); } e.RepositoryItem = lueUnits;//当前单元格绑定控件 } } private void repositoryItemLookUpEdit1_EditValueChanged(object sender, EventArgs e) { } } }