private void ultraGridMetrialDetial_ClickCellButton(object sender, CellEventArgs e) { if (e.Cell.Column.Key.ToUpper() == "FifoChcek".ToUpper()) { string fifoResult = "Y"; if (e.Cell.Row.Cells["FifoChcek"].Value.ToString() == "Y") { if (MessageBox.Show(UserControl.MutiLanguages.ParserMessage("$CS_YES_NO_CANCEL_FIFOCHECK"), this.Text, MessageBoxButtons.OKCancel) == DialogResult.OK) { fifoResult = "N"; } } else { if (MessageBox.Show(UserControl.MutiLanguages.ParserMessage("$CS_YES_NO_NEED_FIFOCHECK"), this.Text, MessageBoxButtons.OKCancel) != DialogResult.OK) { fifoResult = "N"; } } if (fifoResult != e.Cell.Row.Cells["FifoChcek"].Value.ToString()) { try { e.Cell.Row.Cells["FifoChcek"].Value = fifoResult; ultraGridMetrialDetial.UpdateData(); InventoryFacade inventoryFacade = new InventoryFacade(this.DataProvider); MaterialLot materialLot = (MaterialLot)inventoryFacade.GetMaterialLot(e.Cell.Row.Cells["MaterialLot"].Value.ToString().Trim().ToUpper()); string userCode = ApplicationService.Current().UserCode; DBDateTime dbDateTime = FormatHelper.GetNowDBDateTime(this.DataProvider); this.DataProvider.BeginTransaction(); materialLot.FIFOFlag = fifoResult; materialLot.MaintainUser = userCode; materialLot.MaintainDate = dbDateTime.DBDate; materialLot.MaintainTime = dbDateTime.DBTime; inventoryFacade.UpdateMaterialLot(materialLot); this.DataProvider.CommitTransaction(); this.ShowMessage(new UserControl.Message(MessageType.Success, "$CS_Save_Success")); } catch (System.Exception ex) { this.DataProvider.RollbackTransaction(); this.ShowMessage(new UserControl.Message(UserControl.MessageType.Error, ex.Message)); return; } } } }
private void edtMaterialLot_TxtboxKeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == '\r') { if (this.edtMaterialLot.Value.Trim() == string.Empty) { this.edtMaterialLot.TextFocus(false, true); return; } InventoryFacade inventoryFacade = new InventoryFacade(this.DataProvider); MaterialLot materialLot = (MaterialLot)inventoryFacade.GetMaterialLot(FormatHelper.CleanString(this.edtMaterialLot.Value.Trim().ToUpper())); if (materialLot == null) { ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$Error_CS_MaterialLot_Must_Exist")); this.edtMaterialLot.TextFocus(false, true); return; } this.edtReturnNumber.TextFocus(false, true); } }
private void btnSendMetrial_Click(object sender, EventArgs e) { //UI Check ultraGridMetrialDetial.Rows.Band.SortedColumns.Add("ReceiveDate", false); if (!ValidateInput()) { return; } string stockInStorage = FormatString(ucLabelComboxStorageIn.SelectedItemValue); string uiToItem = FormatString(ucLabelEditToItem.Value).Trim().ToUpper(); string moCode = FormatString(this.ucLabelEditIssueNo.Value); if (moCode == "") { moCode = " "; } //获取业务类型 string businesscode = FormatString(ucLabelComboxBusinessCode.SelectedItemValue); MaterialBusiness materialBusiness = (MaterialBusiness)this.WHFacade.GetMaterialBusiness(businesscode); //判断入库库别是否被管理 //tblsysparam.PARAMCODE维护的是需要管理的库别对应tblstorage.STORAGECODE //对应的tblsysparamgroup.PARAMGROUPCODE="DESTSTORAGEMANAGE" SystemSettingFacade systemFacade = new SystemSettingFacade(this.DataProvider); object para = systemFacade.GetParameter(stockInStorage, "DESTSTORAGEMANAGE"); bool isManageToStorage = false; if (para != null) { isManageToStorage = true; } List <string> lotNoList = new List <string>(); DBDateTime dBDateTime = FormatHelper.GetNowDBDateTime(this.DataProvider); bool saveData = true; try { this.DataProvider.BeginTransaction(); for (int i = 0; i < ultraGridMetrialDetial.Rows.Count; i++) { int lotSendNumber = ultraGridMetrialDetial.Rows[i].Cells["SendQty"].Value.ToString().Trim() == string.Empty ? 0 : Convert.ToInt32(ultraGridMetrialDetial.Rows[i].Cells["SendQty"].Value.ToString().Trim()); if (ultraGridMetrialDetial.Rows[i].Cells["Check"].Value.ToString().ToLower() == "true" && lotSendNumber > 0) { MaterialLot materialLot = (MaterialLot)this.InvFacade.GetMaterialLot(ultraGridMetrialDetial.Rows[i].Cells["MetrialLot"].Value.ToString().Trim().ToUpper()); //只有当目标库房没有被管理时,才需要做FIFO检查,就如同工单发料的库房没有被管理,在发料的时候是需要FIFO检查的 if (materialLot != null && materialLot.FIFOFlag == "Y" && isManageToStorage == false) { if (!CheckFiFo(lotNoList, ultraGridMetrialDetial.Rows[i].Cells["ItemCode"].Value.ToString(), ultraGridMetrialDetial.Rows[i].Cells["VendorCode"].Value.ToString(), Convert.ToInt32(ultraGridMetrialDetial.Rows[i].Cells["ReceiveDate"].Value), materialLot.StorageID.Trim().ToUpper())) { this.DataProvider.RollbackTransaction(); saveData = false; break; } } if (materialLot != null) { int orgIdStockOut = 0; int orgIdStockIn = 0; string fromSAPStorageID = " "; string toSAPStorageID = " "; string materialLotNoStockIn = " "; object storageStockIn = this.InvFacade.GetStorageByStorageCode(FormatString(ucLabelComboxStorageIn.SelectedItemValue)); if (storageStockIn != null) { orgIdStockIn = ((Storage)storageStockIn).OrgID; toSAPStorageID = ((Storage)storageStockIn).SAPStorage; } object storageStockOut = this.InvFacade.GetStorageByStorageCode(materialLot.StorageID); if (storageStockOut != null) { orgIdStockOut = ((Storage)storageStockOut).OrgID; fromSAPStorageID = ((Storage)storageStockOut).SAPStorage; } string toItemCode = uiToItem.Trim().Length == 0 ? materialLot.ItemCode : uiToItem.Trim().ToUpper(); //判断是否超发 int sendQty = Convert.ToInt32(ultraGridMetrialDetial.Rows[i].Cells["SendQty"].Value); if ((materialLot.LotQty - sendQty) < 0) { ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$CS_SendMaterialLot_Not_Enough")); this.DataProvider.RollbackTransaction(); saveData = false; break; } if (isManageToStorage == true) { //当目标库管理时 if (materialLot.LotQty == sendQty && materialLot.ItemCode == toItemCode) { materialLotNoStockIn = materialLot.MaterialLotNo; //当发料数量等于库存数量,直接修改TBLMaterialLot中的库别和ToItemCode MaterialLot materialLotStockIn = this.InvFacade.CreateNewMaterialLot(); materialLotStockIn.MaterialLotNo = materialLot.MaterialLotNo; materialLotStockIn.IQCNo = materialLot.IQCNo; materialLotStockIn.STLine = materialLot.STLine; materialLotStockIn.ItemCode = materialLot.ItemCode; materialLotStockIn.VendorCode = materialLot.VendorCode; materialLotStockIn.OrganizationID = orgIdStockIn; materialLotStockIn.StorageID = stockInStorage; materialLotStockIn.Unit = materialLot.Unit; //Modified By Nettie Chen 2009/09/24 //materialLotStockIn.CreateDate = dBDateTime.DBDate; materialLotStockIn.CreateDate = materialLot.CreateDate; //End Modified materialLotStockIn.LotInQty = materialLot.LotInQty; materialLotStockIn.LotQty = materialLot.LotQty; materialLotStockIn.FIFOFlag = materialLot.FIFOFlag; materialLotStockIn.MaintainUser = ApplicationService.Current().UserCode; materialLotStockIn.MaintainDate = dBDateTime.DBDate; materialLotStockIn.MaintainTime = dBDateTime.DBTime; this.InvFacade.UpdateMaterialLot(materialLotStockIn); } else { //当发料数量不等于库存数量,或Item有变化时,产生新的Lot string dateCode = this.InvFacade.GetMaterialLotDateCode(materialLot.CreateDate); string runningNumber = this.InvFacade.GetNewMaterialLotRunningNumber(materialLot.VendorCode, toItemCode, materialLot.CreateDate); materialLotNoStockIn = materialLot.VendorCode + "-" + toItemCode + "-" + dateCode + "-" + runningNumber; //修改出库的TBLMaterialLot materialLot.LotQty = materialLot.LotQty - sendQty; materialLot.MaintainDate = dBDateTime.DBDate; materialLot.MaintainTime = dBDateTime.DBTime; this.InvFacade.UpdateMaterialLot(materialLot); //新增入库的TBLMaterialLot MaterialLot materialLotStockIn = this.InvFacade.CreateNewMaterialLot(); materialLotStockIn.MaterialLotNo = materialLotNoStockIn; materialLotStockIn.IQCNo = materialLot.IQCNo; materialLotStockIn.STLine = materialLot.STLine; materialLotStockIn.ItemCode = toItemCode; materialLotStockIn.VendorCode = materialLot.VendorCode; materialLotStockIn.OrganizationID = orgIdStockIn; materialLotStockIn.StorageID = stockInStorage; materialLotStockIn.Unit = materialLot.Unit; materialLotStockIn.CreateDate = materialLot.CreateDate; materialLotStockIn.LotInQty = sendQty; materialLotStockIn.LotQty = sendQty; materialLotStockIn.FIFOFlag = materialLot.FIFOFlag; materialLotStockIn.MaintainUser = ApplicationService.Current().UserCode; materialLotStockIn.MaintainDate = dBDateTime.DBDate; materialLotStockIn.MaintainTime = dBDateTime.DBTime; this.InvFacade.AddMaterialLot(materialLotStockIn); } //入库的TBLMaterialTrans MaterialTrans materialTransStockIn = this.InvFacade.CreateNewMaterialTrans(); materialTransStockIn.Serial = 0; materialTransStockIn.FRMaterialLot = materialLot.MaterialLotNo; materialTransStockIn.FRMITEMCODE = materialLot.ItemCode; materialTransStockIn.FRMStorageID = materialLot.StorageID; materialTransStockIn.TOMaterialLot = materialLotNoStockIn; materialTransStockIn.TOITEMCODE = toItemCode; materialTransStockIn.TOStorageID = stockInStorage; materialTransStockIn.TransQTY = sendQty; materialTransStockIn.Memo = FormatString(this.ucLabelEditMemo.Value); materialTransStockIn.UNIT = materialLot.Unit; materialTransStockIn.VendorCode = materialLot.VendorCode; materialTransStockIn.IssueType = IssueType.IssueType_Receive; materialTransStockIn.TRANSACTIONCODE = moCode; materialTransStockIn.BusinessCode = materialBusiness.BusinessCode; materialTransStockIn.OrganizationID = orgIdStockIn; materialTransStockIn.MaintainUser = ApplicationService.Current().UserCode; materialTransStockIn.MaintainDate = dBDateTime.DBDate; materialTransStockIn.MaintainTime = dBDateTime.DBTime; this.InvFacade.AddMaterialTrans(materialTransStockIn); } else { //当目标库没有管理时,只更新出库的TBLMaterialLot.lotqty materialLotNoStockIn = materialLot.MaterialLotNo; materialLot.LotQty = materialLot.LotQty - sendQty; materialLot.MaintainUser = ApplicationService.Current().UserCode; materialLot.MaintainDate = dBDateTime.DBDate; materialLot.MaintainTime = dBDateTime.DBTime; this.InvFacade.UpdateMaterialLot(materialLot); } //出库的TBLMaterialTrans MaterialTrans materialTransStockOut = this.InvFacade.CreateNewMaterialTrans(); materialTransStockOut.Serial = 0; materialTransStockOut.FRMaterialLot = materialLot.MaterialLotNo; materialTransStockOut.FRMITEMCODE = materialLot.ItemCode; materialTransStockOut.FRMStorageID = materialLot.StorageID; materialTransStockOut.TOMaterialLot = materialLotNoStockIn; materialTransStockOut.TOITEMCODE = toItemCode; materialTransStockOut.TOStorageID = stockInStorage; materialTransStockOut.TransQTY = sendQty; materialTransStockOut.Memo = FormatString(this.ucLabelEditMemo.Value); materialTransStockOut.UNIT = materialLot.Unit; materialTransStockOut.VendorCode = materialLot.VendorCode; materialTransStockOut.IssueType = IssueType.IssueType_Issue; materialTransStockOut.TRANSACTIONCODE = moCode; materialTransStockOut.BusinessCode = materialBusiness.BusinessCode; materialTransStockOut.OrganizationID = orgIdStockOut; materialTransStockOut.MaintainUser = ApplicationService.Current().UserCode; materialTransStockOut.MaintainDate = dBDateTime.DBDate; materialTransStockOut.MaintainTime = dBDateTime.DBTime; this.InvFacade.AddMaterialTrans(materialTransStockOut); if (materialBusiness.SAPCODE.Trim().Length > 0) { SAPMaterialTrans sAPMaterialTrans = this.InvFacade.CreateNewSAPMaterialTrans(); sAPMaterialTrans.MaterialLotNo = materialLot.MaterialLotNo; sAPMaterialTrans.PostSeq = this.InvFacade.GetSAPMaterialTransMaxSeq(materialLot.MaterialLotNo); sAPMaterialTrans.OrganizationID = orgIdStockOut; sAPMaterialTrans.ItemCode = materialLot.ItemCode; sAPMaterialTrans.AccountDate = FormatHelper.TODateInt(ucDateAccount.Value); sAPMaterialTrans.VoucherDate = FormatHelper.TODateInt(ucDateVoucher.Value); sAPMaterialTrans.FRMStorageID = fromSAPStorageID; sAPMaterialTrans.TOStorageID = toSAPStorageID; sAPMaterialTrans.TransQTY = sendQty; sAPMaterialTrans.ReceiveMemo = FormatString(this.ucLabelEditMemo.Value); sAPMaterialTrans.Unit = materialLot.Unit; //当非即售时Vendor为空 if (radioButtonSaleDelay.Checked == true) { sAPMaterialTrans.VendorCode = " "; } else { sAPMaterialTrans.VendorCode = materialLot.VendorCode; } sAPMaterialTrans.MoCode = moCode; sAPMaterialTrans.Flag = FlagStatus.FlagStatus_MES; sAPMaterialTrans.TransactionCode = " "; sAPMaterialTrans.ToItemCode = toItemCode; sAPMaterialTrans.SAPCode = materialBusiness.SAPCODE; sAPMaterialTrans.MaintainUser = ApplicationService.Current().UserCode; sAPMaterialTrans.MaintainDate = dBDateTime.DBDate; sAPMaterialTrans.MaintainTime = dBDateTime.DBTime; this.InvFacade.AddSAPMaterialTrans(sAPMaterialTrans); } } lotNoList.Add(ultraGridMetrialDetial.Rows[i].Cells["MetrialLot"].Value.ToString()); } } if (saveData) { this.DataProvider.CommitTransaction(); ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Success, "$CS_SendMaterialLot_Success")); } } catch (Exception ex) { this.DataProvider.RollbackTransaction(); Messages msg = new Messages(); msg.Add(new UserControl.Message(ex)); ApplicationRun.GetInfoForm().Add(msg); } if (saveData) { //_DataTableLoadedPart.Clear(); //ucBtnQuery_Click ucBtnQuery_Click(this, null); } }
private void btnSendMetrial_Click(object sender, EventArgs e) { ultraGridMetrialDetial.Rows.Band.SortedColumns.Add("ReceiveDate", false); this.edtHeadText.TextFocus(false, true); if (this.edtMoCode.Value.Trim() == string.Empty) { ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$CS_CMPleaseInputMO")); this.edtMoCode.TextFocus(false, true); return; } //ucLabelComboxStorageIn if (FormatString(ucLabelComboxStorageIn.SelectedItemValue).Trim() == string.Empty) { ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$CS_CMPleaseInput_Receive_Place")); ucLabelComboxStorageIn.Focus(); return; } if (!this.CheckSendMetrialNumber()) { this.edtMoPlanQty.TextFocus(false, true); return; } if (!this.CheckGridChecked()) { ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$CS_Please_Take_OneMaterial")); return; } if (!this.CheckBufferDate()) { this.edtBufferDate.TextFocus(false, true); return; } if (!CheckGridSendNumber()) { return; } //检查收获地点没有被管理,因为如果是被管理的库别,就是库存转移了。工单发料目的是将料发到产线上 //因此收获地点一定是没有被管理的 //tblsysparam.PARAMCODE维护的是需要管理的库别对应tblstorage.STORAGECODE //对应的tblsysparamgroup.PARAMGROUPCODE="DESTSTORAGEMANAGE" string receiveStorage = FormatString(ucLabelComboxStorageIn.SelectedItemValue).ToUpper(); SystemSettingFacade systemFacade = new SystemSettingFacade(this.DataProvider); object para = systemFacade.GetParameter(receiveStorage, "DESTSTORAGEMANAGE"); bool isManageToStorage = false; if (para != null) { isManageToStorage = true; } if (isManageToStorage == true) { ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$INVALID_STORGE")); return; } List <string> lotNoList = new List <string>(); InventoryFacade inventoryFacade = new InventoryFacade(this.DataProvider); DBDateTime dBDateTime = FormatHelper.GetNowDBDateTime(this.DataProvider); bool saveData = true; try { this.DataProvider.BeginTransaction(); for (int i = 0; i < ultraGridMetrialDetial.Rows.Count; i++) { string stockOutStorage = ultraGridMetrialDetial.Rows[i].Cells["SorageID"].Value.ToString().Trim().ToUpper(); string stockInStorage = FormatString(ucLabelComboxStorageIn.SelectedItemValue).ToUpper(); int lotSendNumber = ultraGridMetrialDetial.Rows[i].Cells["SendQty"].Value.ToString().Trim() == string.Empty ? 0 : Convert.ToInt32(ultraGridMetrialDetial.Rows[i].Cells["SendQty"].Value.ToString().Trim()); if (ultraGridMetrialDetial.Rows[i].Cells["Check"].Value.ToString().ToLower() == "true" && lotSendNumber > 0) { MaterialLot materialLot = (MaterialLot)inventoryFacade.GetMaterialLot(ultraGridMetrialDetial.Rows[i].Cells["MetrialLot"].Value.ToString().Trim().ToUpper()); if (materialLot != null && materialLot.FIFOFlag == "Y") { if (!CheckFiFo(lotNoList, ultraGridMetrialDetial.Rows[i].Cells["ItemCode"].Value.ToString(), ultraGridMetrialDetial.Rows[i].Cells["VendorCode"].Value.ToString(), Convert.ToInt32(ultraGridMetrialDetial.Rows[i].Cells["ReceiveDate"].Value), stockOutStorage)) { this.DataProvider.RollbackTransaction(); saveData = false; break; } } //更新TBLMaterialLot.lotqty if (materialLot != null) { if (materialLot.LotQty - Convert.ToInt32(ultraGridMetrialDetial.Rows[i].Cells["SendQty"].Value) < 0) { ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$CS_SendMaterialLot_Not_Enough")); this.DataProvider.RollbackTransaction(); saveData = false; break; } materialLot.LotQty = materialLot.LotQty - Convert.ToInt32(ultraGridMetrialDetial.Rows[i].Cells["SendQty"].Value); materialLot.MaintainDate = dBDateTime.DBDate; materialLot.MaintainTime = dBDateTime.DBTime; inventoryFacade.UpdateMaterialLot(materialLot); } //tblmateriallot.STORAGEID <=> tblstorage.STORAGECODE Ex:2001-0002 //tblsapmaterialtrans.FRMSTORAGEID <=> tblstorage.SAPSTORAGE Ex:0002 //tblsapmaterialtrans.TOSTORAGEID <=> tblstorage.SAPSTORAGE Ex:0002 string stockOutSAPStorage = " "; string stockInSAPStorage = " "; object storageStockIn = inventoryFacade.GetStorageByStorageCode(stockInStorage); if (storageStockIn != null) { stockInSAPStorage = ((Storage)storageStockIn).SAPStorage; } object storageStockOut = inventoryFacade.GetStorageByStorageCode(stockOutStorage); if (storageStockOut != null) { stockOutSAPStorage = ((Storage)storageStockOut).SAPStorage; } //插入出库TBLMaterialTrans MaterialTrans materialTransStockOut = inventoryFacade.CreateNewMaterialTrans(); materialTransStockOut.Serial = 0; materialTransStockOut.FRMaterialLot = ultraGridMetrialDetial.Rows[i].Cells["MetrialLot"].Value.ToString().Trim().ToUpper(); materialTransStockOut.FRMITEMCODE = ultraGridMetrialDetial.Rows[i].Cells["ItemCode"].Value.ToString().Trim().ToUpper(); materialTransStockOut.FRMStorageID = stockOutStorage; materialTransStockOut.TOMaterialLot = ultraGridMetrialDetial.Rows[i].Cells["MetrialLot"].Value.ToString().Trim().ToUpper(); materialTransStockOut.TOITEMCODE = ultraGridMetrialDetial.Rows[i].Cells["ItemCode"].Value.ToString().Trim().ToUpper(); materialTransStockOut.TOStorageID = stockInStorage; materialTransStockOut.TransQTY = Convert.ToInt32(ultraGridMetrialDetial.Rows[i].Cells["SendQty"].Value); materialTransStockOut.Memo = FormatHelper.CleanString(this.edtHeadText.Value.Trim()); materialTransStockOut.UNIT = ultraGridMetrialDetial.Rows[i].Cells["Unit"].Value.ToString().Trim(); materialTransStockOut.VendorCode = ultraGridMetrialDetial.Rows[i].Cells["VendorCode"].Value.ToString().Trim().ToUpper(); materialTransStockOut.IssueType = IssueType.IssueType_Issue; materialTransStockOut.TRANSACTIONCODE = FormatHelper.CleanString(this.edtMoCode.Value.Trim()).ToUpper(); materialTransStockOut.BusinessCode = "MO"; materialTransStockOut.OrganizationID = GlobalVariables.CurrentOrganizations.First().OrganizationID; materialTransStockOut.MaintainUser = ApplicationService.Current().UserCode; materialTransStockOut.MaintainDate = dBDateTime.DBDate; materialTransStockOut.MaintainTime = dBDateTime.DBTime; inventoryFacade.AddMaterialTrans(materialTransStockOut); //插入TBLSAPMaterialTrans Domain.Material.SAPMaterialTrans sapMaterialTrans = new BenQGuru.eMES.Domain.Material.SAPMaterialTrans(); sapMaterialTrans.MaterialLotNo = ultraGridMetrialDetial.Rows[i].Cells["MetrialLot"].Value.ToString().Trim().ToUpper(); sapMaterialTrans.PostSeq = inventoryFacade.GetSAPMaterialTransMaxSeq(sapMaterialTrans.MaterialLotNo); sapMaterialTrans.OrganizationID = GlobalVariables.CurrentOrganizations.First().OrganizationID; sapMaterialTrans.ItemCode = ultraGridMetrialDetial.Rows[i].Cells["ItemCode"].Value.ToString().Trim().ToUpper(); sapMaterialTrans.AccountDate = FormatHelper.TODateInt(this.ucDateTimeStart.Value); sapMaterialTrans.VoucherDate = FormatHelper.TODateInt(this.ucDateTimeEnd.Value); sapMaterialTrans.FRMStorageID = stockOutSAPStorage; sapMaterialTrans.TOStorageID = stockInSAPStorage; sapMaterialTrans.TransQTY = Convert.ToInt32(ultraGridMetrialDetial.Rows[i].Cells["SendQty"].Value); sapMaterialTrans.ReceiveMemo = FormatHelper.CleanString(this.edtHeadText.Value.Trim()); sapMaterialTrans.Unit = ultraGridMetrialDetial.Rows[i].Cells["Unit"].Value.ToString().Trim(); //当非即售时Vendor为空 if (radioButtonSaleDelay.Checked == true) { sapMaterialTrans.VendorCode = " "; } else { sapMaterialTrans.VendorCode = ultraGridMetrialDetial.Rows[i].Cells["VendorCode"].Value.ToString().Trim().ToUpper(); } sapMaterialTrans.MoCode = FormatHelper.CleanString(this.edtMoCode.Value.Trim().ToUpper()); sapMaterialTrans.Flag = "MES"; sapMaterialTrans.TransactionCode = " "; sapMaterialTrans.SAPCode = "411"; sapMaterialTrans.ToItemCode = ultraGridMetrialDetial.Rows[i].Cells["ItemCode"].Value.ToString().Trim().ToUpper(); sapMaterialTrans.MaintainUser = ApplicationService.Current().UserCode; sapMaterialTrans.MaintainDate = dBDateTime.DBDate; sapMaterialTrans.MaintainTime = dBDateTime.DBTime; inventoryFacade.AddSAPMaterialTrans(sapMaterialTrans); lotNoList.Add(ultraGridMetrialDetial.Rows[i].Cells["MetrialLot"].Value.ToString()); } } if (saveData) { this.DataProvider.CommitTransaction(); ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Success, "$CS_SendMaterialLot_Success")); } } catch (Exception ex) { this.DataProvider.RollbackTransaction(); Messages msg = new Messages(); msg.Add(new UserControl.Message(ex)); ApplicationRun.GetInfoForm().Add(msg); } if (saveData) { _DataTableLoadedPart.Clear(); } }
private void bntStockIn_Click(object sender, EventArgs e) { try { DBDateTime dbDateTime = FormatHelper.GetNowDBDateTime(this.DataProvider); string itemDesc = string.Empty; string vendorDesc = string.Empty; bool result = ValidateInput(out itemDesc, out vendorDesc); if (result == false) { return; } string businesscode = FormatString(ucLabelComboxBusinessCode.SelectedItemValue); int qty = int.Parse(ucLabelEditQty.Value); //入库库别 string fromSAPStorageID = string.Empty; string toSAPStorageID = string.Empty; int orgId = 0; object storageStockIn = this.InvFacade.GetStorageByStorageCode(FormatString(ucLabelComboxStorageIn.SelectedItemValue)); if (storageStockIn != null) { orgId = ((Storage)storageStockIn).OrgID; toSAPStorageID = ((Storage)storageStockIn).SAPStorage; } object storageStockOut = this.InvFacade.GetStorageByStorageCode(FormatString(ucLabelComboxStorageOut.SelectedItemValue)); if (storageStockOut != null) { fromSAPStorageID = ((Storage)storageStockOut).SAPStorage; } //获取当前业务代码信息 MaterialBusiness materialBusiness = (MaterialBusiness)this.WHFacade.GetMaterialBusiness(businesscode); string iqcno = FormatString(this.ucLabelEditDoc.Value).ToUpper(); if (iqcno == "") { iqcno = " "; } //Config MaterialLot MaterialLot materialLot = this.InvFacade.CreateNewMaterialLot(); materialLot.IQCNo = iqcno; materialLot.STLine = FormatInt(this.ucLabelEditDocLine.Value); materialLot.ItemCode = FormatString(this.ucLEItemCode.Value); materialLot.VendorCode = FormatString(this.ucLabelEditVendor.Value); materialLot.OrganizationID = orgId; materialLot.StorageID = FormatString(ucLabelComboxStorageIn.SelectedItemValue); materialLot.Unit = FormatString(this.ucLabelEditUnit.Value); materialLot.CreateDate = FormatHelper.TODateInt(ucDateStockIn.Value); materialLot.LotInQty = qty; materialLot.LotQty = qty; materialLot.FIFOFlag = materialBusiness.ISFIFO; materialLot.MaintainUser = ApplicationService.Current().UserCode; materialLot.MaintainDate = dbDateTime.DBDate; materialLot.MaintainTime = dbDateTime.DBTime; //Set MaterialLotNo string dateCode = this.InvFacade.GetMaterialLotDateCode(materialLot.CreateDate); string runningNumber = this.InvFacade.GetNewMaterialLotRunningNumber(materialLot.VendorCode, materialLot.ItemCode, materialLot.CreateDate); materialLot.MaterialLotNo = materialLot.VendorCode + "-" + materialLot.ItemCode + "-" + dateCode + "-" + runningNumber; //Config MaterialTrans MaterialTrans materialTrans = this.InvFacade.CreateNewMaterialTrans(); materialTrans.Serial = 0; materialTrans.FRMaterialLot = " "; materialTrans.FRMITEMCODE = " "; materialTrans.FRMStorageID = " "; materialTrans.TOMaterialLot = materialLot.MaterialLotNo; materialTrans.TOITEMCODE = materialLot.ItemCode; materialTrans.TOStorageID = materialLot.StorageID; materialTrans.TransQTY = materialLot.LotInQty; materialTrans.Memo = FormatString(this.ucLabelEditMemo.Value); materialTrans.UNIT = materialLot.Unit; materialTrans.VendorCode = materialLot.VendorCode; materialTrans.IssueType = IssueType.IssueType_Receive; materialTrans.TRANSACTIONCODE = materialLot.IQCNo; materialTrans.BusinessCode = materialBusiness.BusinessCode; materialTrans.OrganizationID = materialLot.OrganizationID; materialTrans.MaintainUser = ApplicationService.Current().UserCode; materialTrans.MaintainDate = dbDateTime.DBDate; materialTrans.MaintainTime = dbDateTime.DBTime; //Config Sapmaterialtrans //分别获取入库库别和发货库别对应的SAP库别,在TBLsAPMaterialTrans中的StorageId存放的是SAP库别 SAPMaterialTrans sAPMaterialTrans = null; if (materialBusiness.SAPCODE.Trim().Length > 0) { sAPMaterialTrans = this.InvFacade.CreateNewSAPMaterialTrans(); sAPMaterialTrans.MaterialLotNo = materialLot.MaterialLotNo; sAPMaterialTrans.PostSeq = this.InvFacade.GetSAPMaterialTransMaxSeq(materialLot.MaterialLotNo); sAPMaterialTrans.OrganizationID = materialLot.OrganizationID; sAPMaterialTrans.ItemCode = materialLot.ItemCode; sAPMaterialTrans.AccountDate = FormatHelper.TODateInt(ucDateAccount.Value); sAPMaterialTrans.VoucherDate = FormatHelper.TODateInt(ucDateVoucher.Value); if (fromSAPStorageID == "" || fromSAPStorageID == null) { sAPMaterialTrans.FRMStorageID = " "; } else { sAPMaterialTrans.FRMStorageID = fromSAPStorageID; } if (toSAPStorageID == "" || toSAPStorageID == null) { sAPMaterialTrans.TOStorageID = " "; } else { sAPMaterialTrans.TOStorageID = toSAPStorageID; } sAPMaterialTrans.TransQTY = materialLot.LotInQty; sAPMaterialTrans.ReceiveMemo = FormatString(this.ucLabelEditMemo.Value); sAPMaterialTrans.Unit = materialLot.Unit; //当非即售时Vendor为空 if (radioButtonSaleDelay.Checked == true) { sAPMaterialTrans.VendorCode = " "; } else { sAPMaterialTrans.VendorCode = materialLot.VendorCode; } sAPMaterialTrans.MoCode = materialLot.IQCNo; sAPMaterialTrans.Flag = FlagStatus.FlagStatus_MES; sAPMaterialTrans.TransactionCode = " "; sAPMaterialTrans.ToItemCode = materialLot.ItemCode; if (materialBusiness.SAPCODE == null || materialBusiness.SAPCODE == "") { sAPMaterialTrans.SAPCode = " "; } else { sAPMaterialTrans.SAPCode = materialBusiness.SAPCODE; } sAPMaterialTrans.MaintainUser = ApplicationService.Current().UserCode; sAPMaterialTrans.MaintainDate = dbDateTime.DBDate; sAPMaterialTrans.MaintainTime = dbDateTime.DBTime; } bool saveData = this.InvFacade.MaterialStockIn(materialLot, materialBusiness, materialTrans, sAPMaterialTrans); if (saveData) { //向Grid上增加记录 DataRow dr = this._DataTable.NewRow(); dr["Check"] = false; dr["MaterialLot"] = materialLot.MaterialLotNo; dr["IQCNO"] = materialLot.IQCNo; dr["IQCLine"] = materialLot.STLine; dr["VendorCode"] = materialLot.VendorCode; dr["VendorDesc"] = vendorDesc; dr["ItemCode"] = materialLot.ItemCode; dr["ItemCodeDesc"] = itemDesc; dr["ReceiveDate"] = materialLot.CreateDate; dr["StockInQty"] = materialLot.LotInQty; dr["StockInStorage"] = materialLot.StorageID; dr["FifoChcek"] = materialBusiness.ISFIFO; dr["FrmMemo"] = FormatString(this.ucLabelEditMemo.Value).Replace("\n", " "); this._DataTable.Rows.Add(dr); ClearInputData(); ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Success, "$CS_StockIn_Success")); } } catch (Exception ex) { Messages msg = new Messages(); msg.Add(new UserControl.Message(ex)); ApplicationRun.GetInfoForm().Add(msg); } }
private void btnSendMetrial_Click(object sender, EventArgs e) { if (this.edtMaterialLot.Value.Trim() == string.Empty) { ApplicationRun.GetInfoForm().AddEx("$Please_Input_MaterialLot"); this.edtMaterialLot.TextFocus(false, true); return; } if (this.edtReturnNumber.Value.Trim() == string.Empty) { ApplicationRun.GetInfoForm().AddEx("$CS_InPut_ReturnNumber"); this.edtReturnNumber.TextFocus(false, true); return; } if (Convert.ToInt32(this.edtReturnNumber.Value.Trim()) < 1) { ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$Error_CS_Retun_Qty_Should_Over_Zero")); this.edtReturnNumber.TextFocus(false, true); return; } InventoryFacade inventoryFacade = new InventoryFacade(this.DataProvider); MaterialLot materialLot = (MaterialLot)inventoryFacade.GetMaterialLot(FormatHelper.CleanString(this.edtMaterialLot.Value.Trim().ToUpper())); if (materialLot == null) { ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$Error_CS_MaterialLot_Must_Exist")); this.edtMaterialLot.TextFocus(false, true); return; } if (materialLot.LotQty + Convert.ToInt32(this.edtReturnNumber.Value.Trim()) > materialLot.LotInQty) { ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$CS_MaterialLot_LotQty:" + materialLot.LotQty + "$CS_MaterialLot_LotInQty:" + materialLot.LotInQty)); this.edtReturnNumber.TextFocus(false, true); return; } DBDateTime dBDateTime = FormatHelper.GetNowDBDateTime(this.DataProvider); try { this.DataProvider.BeginTransaction(); materialLot.LotQty += Convert.ToInt32(this.edtReturnNumber.Value.Trim()); materialLot.MaintainUser = ApplicationService.Current().UserCode; materialLot.MaintainDate = dBDateTime.DBDate; materialLot.MaintainTime = dBDateTime.DBTime; inventoryFacade.UpdateMaterialLot(materialLot); MaterialReturn materialReturn = new MaterialReturn(); materialReturn.MaterialLotNo = materialLot.MaterialLotNo; materialReturn.PostSeq = inventoryFacade.GetMaterialReturnsMaxSeq(materialLot.MaterialLotNo); materialReturn.TransQty = Convert.ToInt32(this.edtReturnNumber.Value.Trim()); materialReturn.MaintainUser = ApplicationService.Current().UserCode; materialReturn.MaintainDate = dBDateTime.DBDate; materialReturn.MaintainTime = dBDateTime.DBTime; inventoryFacade.AddMaterialReturn(materialReturn); this.DataProvider.CommitTransaction(); ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Success, "$CS_ReturnMaterialLot_Success")); } catch (Exception ex) { this.DataProvider.RollbackTransaction(); Messages msg = new Messages(); msg.Add(new UserControl.Message(ex)); ApplicationRun.GetInfoForm().Add(msg); } this.edtMaterialLot.TextFocus(false, true); }