protected object GetEditObject() { if (_TransferFacade == null) { _TransferFacade = new WarehouseFacade(this.DataProvider); } DBDateTime DBDateTimeNow = FormatHelper.GetNowDBDateTime(this.DataProvider); InvTransfer transfer = new InvTransfer(); if (ViewState["operate"].ToString() == "Edit") { transfer = (InvTransfer)this._TransferFacade.GetInvTransfer(FormatHelper.CleanString(this.txtTransferNoEdit.Text)); if (transfer == null) { return(null); } } transfer.TransferNO = FormatHelper.CleanString(this.txtTransferNoEdit.Text.Trim().ToUpper(), 40); transfer.Rectype = FormatHelper.CleanString(this.DrpRECTypeEdit.SelectedValue); transfer.FromStorageID = FormatHelper.CleanString(this.txtFromStorageIDQueryEdit.Text.Trim().ToUpper(), 40); transfer.ToStorageID = FormatHelper.CleanString(this.txtToStorageIDQueryEdit.Text.Trim().ToUpper(), 40); transfer.Memo = FormatHelper.CleanString(this.txtRemark.Text, 2000); transfer.Mdate = DBDateTimeNow.DBDate; transfer.Mtime = DBDateTimeNow.DBTime; transfer.Muser = this.GetUserCode(); return(transfer); }
public string RetriveInventoryTransfer(RetrieveFromStorage objPallet) { string msg = ""; try { InventoryTransferServices it = new InventoryTransferServices(); InvTransfer invTransfer = new InvTransfer(); invTransfer.company = objPallet.Company; invTransfer.plant = objPallet.Plant; //invTransfer.id = objPallet.Id; //invTransfer.id = objPallet.Id.ToString(); invTransfer.id = "Loose Picking : Retrieve " + objPallet.Id.ToString(); invTransfer.partNum = objPallet.PartNum; invTransfer.qty = objPallet.Qty; invTransfer.uom = objPallet.UOMCode; invTransfer.frmWarehouse = objPallet.FromWareHouse; invTransfer.frmBinNum = objPallet.FromBinNum; invTransfer.frmLotNum = objPallet.LotNum; invTransfer.toWarehouse = objPallet.ToWareHouse; invTransfer.toBinNum = objPallet.ToBinNum; invTransfer.toLotNum = objPallet.LotNum; it.doInvTransfer(invTransfer); } catch (Exception ex) { msg = ex.Message.ToString(); } return(msg); }
public string LooseInventoryTransfer(LoosePickingHd objPallet, LotWarehouseDetails _lotWhseDtls) { string msg = ""; try { InventoryTransferServices it = new InventoryTransferServices(); InvTransfer invTransfer = new InvTransfer(); invTransfer.company = objPallet.Company; invTransfer.partNum = objPallet.PartNum; invTransfer.qty = objPallet.Qty; invTransfer.frmWarehouse = _lotWhseDtls.FromWarehouse; invTransfer.frmBinNum = _lotWhseDtls.FromBinNum; invTransfer.frmLotNum = objPallet.LotNum; invTransfer.toWarehouse = _lotWhseDtls.ToWarehouse; invTransfer.toBinNum = _lotWhseDtls.ToBinNum; invTransfer.toLotNum = objPallet.LotNum; it.doInvTransfer(invTransfer); } catch (Exception ex) { msg = ex.Message.ToString(); } return(msg); }
public ActionResult DeleteConfirmed(int id) { InvTransfer invTransfer = db.InvTransfers.Find(id); db.InvTransfers.Remove(invTransfer); db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <string> CreateInvTransfer(int?FromWhId, int?ToWhId, List <InvTransfer> InvTrans) { InvTransferHeader NewHeader = new InvTransferHeader { FromWhId = FromWhId, ToWhId = ToWhId, TransferStatus = SD.Approved, CreatedById = GetLoggedInUserId(), CreatedDateTime = DateTime.Now }; _db.InvTransferHeader.Add(NewHeader); await _db.SaveChangesAsync(); int ProdId; foreach (var InvTr in InvTrans) { ProdId = _db.ProdInfo.FirstOrDefault(pro => pro.ProdCode == InvTr.ProdInfo.ProdCode).Id; // Check if the warehouse has enough qty of that product bool CheckQty = CheckQtyInWh(ProdId, FromWhId ?? 0, InvTr.Qty); if (CheckQty == false) { _db.InvTransferHeader.Remove(NewHeader); await _db.SaveChangesAsync(); return("Error! لايوجد كمية كافية للمادة: " + InvTr.ProdInfo.ProdCode); } InvTransfer InvTransfer = new InvTransfer { HeaderId = NewHeader.Id, ProdId = ProdId, Qty = InvTr.Qty, Note = InvTr.Note }; //Decrease Qty of From Warehouse ChangeStockQty(ProdId, FromWhId ?? 0, InvTr.Qty, "Out"); // Increase Qty of To Warehouse ChangeStockQty(ProdId, ToWhId ?? 0, InvTr.Qty, "In"); _db.InvTransfer.Add(InvTransfer); // Create Inv Transaction with Negative Qty of From Warehouse CreateInvTransaction(ProdId, FromWhId ?? 0, InvTr.Qty * -1, SD.TransferOut); // Create Inv Transaction with Positive Qty of To Warehouse CreateInvTransaction(ProdId, ToWhId ?? 0, InvTr.Qty, SD.TransferIn); } await _db.SaveChangesAsync(); return("تمت عملية التحويل"); }
public ActionResult Edit([Bind(Include = "InvTransferId,TransferDateTime,InvLocationId,FinishInvLocationId,CustomerPn,PartDescription,TransferFromQty,TransferToQty,Carrier,TrackingInfo,ShipToAddress,Notes")] InvTransfer invTransfer) { if (ModelState.IsValid) { db.Entry(invTransfer).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(invTransfer)); }
// This function is called when a Store User wants to transfer from a warehouse to another. So this function // Will create a request for the Admin to approve public async Task <string> CreateInvTransferRequest(int?FromWhId, int?ToWhId, string Note, List <InvTransfer> InvTrans, IHubContext <NotificationHub> hubContext) { // Create Transfer Header InvTransferHeader NewHeader = new InvTransferHeader { FromWhId = FromWhId, ToWhId = ToWhId, TransferStatus = SD.Pending, CreatedById = GetLoggedInUserId(), CreatedDateTime = DateTime.Now, Note = Note }; _db.InvTransferHeader.Add(NewHeader); await _db.SaveChangesAsync(); int ProdId; foreach (var InvTr in InvTrans) { ProdId = _db.ProdInfo.FirstOrDefault(pro => pro.ProdCode == InvTr.ProdInfo.ProdCode).Id; // Check if the warehouse has enough qty of that product bool CheckQty = CheckQtyInWh(ProdId, FromWhId ?? 0, InvTr.Qty); if (CheckQty == false) { _db.InvTransferHeader.Remove(NewHeader); await _db.SaveChangesAsync(); return("Error! لايوجد كمية كافية للمادة: " + InvTr.ProdInfo.ProdCode); } InvTransfer InvTransfer = new InvTransfer { HeaderId = NewHeader.Id, ProdId = ProdId, Qty = InvTr.Qty, Note = InvTr.Note }; _db.InvTransfer.Add(InvTransfer); } await _db.SaveChangesAsync(); await hubContext.Clients.All.SendAsync("NewTransferRequest", _db.Warehouse.Find(NewHeader.FromWhId).WhName, _db.Warehouse.Find(NewHeader.ToWhId).WhName, NewHeader.Id); return("تم ارسال طلب التحويل بنجاح"); //return "Request Added Successfully"; }
// GET: InvTransfers/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } InvTransfer invTransfer = db.InvTransfers.Find(id); if (invTransfer == null) { return(HttpNotFound()); } return(View(invTransfer)); }
private ReportMaterialNonConformance.Response ReportMaterialNonConformanceHandler(ReportMaterialNonConformance command) { var response = new ReportMaterialNonConformance.Response(); bool customized = Platform.Query <IMaterialDefinitionExt>().Where(cust => cust.MaterialDefinitionId == command.MaterialDefinitionId).Select(cust => cust.Customized).FirstOrDefault(); if (command.InforIntegration) { InvTransfer reportMaterialNonConformance = new InvTransfer(command.OrderNumber, command.RefNum, command.StorageUnit, command.StorageQuantity, command.Plant, command.MaterialDefinitionNId, customized); var result = InforConnector.ReportMaterialNonConformance(reportMaterialNonConformance); if (result.InforCallSucceeded == false) { response.SetError(-1001, result.Error); return(response); } else if (!string.IsNullOrEmpty(result.Error)) { response.SetError(-1002, result.Error); return(response); } } var createTBEResponse = Platform.CallCommand <CreateToBeConsumedMaterialExt, CreateToBeConsumedMaterialExt.Response>(new CreateToBeConsumedMaterialExt { ToBeConsumedMaterials = new List <Types.ToBeConsumedMaterialExtParameter> { new Types.ToBeConsumedMaterialExtParameter { Sequence = command.Sequence, ToBeConsumedMaterialId = command.ToBeConsumedMaterialId } }, WorkOrderOperationId = command.WorkOrderOperationid }); var declareTBEQuantityResponse = Platform.CallCommand <DeclareQuantity, DeclareQuantity.Response>(new DeclareQuantity { ToBeConsumedMaterialId = command.ToBeConsumedMaterialId, DeclaredQuantity = command.StorageQuantity, WorkOrderOperationId = command.WorkOrderOperationid }); return(response); }
public clsPMCTransfer Confirm(clsPMCTransfer objPMCTransfer) { string StatusMsg = string.Empty; clsPMCTransfer objValidatePart = new clsPMCTransfer(); // copy class from incoming class to return class objValidatePart = objPMCTransfer; string errMsg = ValidateToWHAndToBin(objPMCTransfer.ToWH, objPMCTransfer.ToBin, objPMCTransfer.Part, objPMCTransfer.Company); if (errMsg != "0") { objValidatePart.TranStatus = errMsg; return(objValidatePart); } // Inventory Transfer //check WH is ProdLine bool ValidProdLineWH = ValidateProdAreaWH(objPMCTransfer.ToWH, objPMCTransfer.Company); if (ValidProdLineWH) { try { InvTransfer invTransfer = new InvTransfer(); invTransfer.company = objPMCTransfer.Company; invTransfer.frmWarehouse = objPMCTransfer.FromWH; invTransfer.frmBinNum = objPMCTransfer.FromBin; invTransfer.frmLotNum = objPMCTransfer.LotNum; invTransfer.partNum = objPMCTransfer.ActualPart; invTransfer.toBinNum = objPMCTransfer.ToBin; invTransfer.toWarehouse = objPMCTransfer.ToWH; invTransfer.toLotNum = objPMCTransfer.LotNum; invTransfer.uom = objPMCTransfer.UOM; invTransfer.qty = objPMCTransfer.Qty; invTransfer.id = "PMCTransfer"; // Req by Tsen in the email subject FW: Part Transaction History Tracker InventoryTransferServices inventoryTransferServices = new InventoryTransferServices(); inventoryTransferServices.doInvTransfer(invTransfer); } catch (Exception e) { StatusMsg = string.Concat(StatusMsg, " ", e.ToString()); } // Insert Into UD19 try { //UD19Model uD19Model = new UD19Model(); //uD19Model.RunningNo = FindUD19Key(objPMCTransfer.Company); //uD19Model.Company = objPMCTransfer.Company; //uD19Model.EnteredBy = "Handheld"; //uD19Model.Lot = objPMCTransfer.LotNum; //uD19Model.PartNum = objPMCTransfer.ActualPart; //uD19Model.Qty = objPMCTransfer.Qty; //uD19Model.ToBin = objPMCTransfer.ToBin; //uD19Model.ToWH = objPMCTransfer.ToWH; //uD19Model.TranDate = DateTime.Today; //uD19Model.TranTime = DateTime.Today; //uD19Model.UOM = objPMCTransfer.UOM; //UD19Services uD19Services = new UD19Services(); //uD19Services.Begin(uD19Model); // Update Part Bin - Fields to update not defined don't execute //StatusMsg= UpdatePartBin(objPMCTransfer.Company, objPMCTransfer.ActualPart, // objPMCTransfer.FromWH, objPMCTransfer.FromBin,objPMCTransfer.LotNum, // objPMCTransfer.Qty); } catch (Exception e) { StatusMsg = string.Concat(StatusMsg, " ", e.ToString()); } } else { StatusMsg = "To Warehouse Not A Produciton Line WH"; } if (StatusMsg == string.Empty) { StatusMsg = "Success"; } objValidatePart.TranStatus = StatusMsg; return(objValidatePart); }
protected void cmdMerge_ServerClick(object sender, EventArgs e) { ArrayList array = this.GetCheckedRows(); //A:检查Grid中至少选择2笔以上记录 //marked by seven 2010-12-22 //if (array.Count < 2) //{ // WebInfoPublish.PublishInfo(this, "$Error_Row_Selected_More_Two", this.languageComponent1); // return; //} //B:检查选择的入库单类型,源库别,收货库别,组织必须一致。 Hashtable htRecType = new Hashtable(); Hashtable htFromStorageNo = new Hashtable(); Hashtable htToStorageNo = new Hashtable(); Hashtable htOrgID = new Hashtable(); foreach (Infragistics.WebUI.UltraWebGrid.UltraGridRow row in array) { string RecType = row.Cells.FromKey("RECType").ToString(); string FromStorageNo = row.Cells.FromKey("FromStorageID").ToString(); string ToStorageNo = row.Cells.FromKey("ToStorageID").ToString(); string OrgID = row.Cells.FromKey("Check").ToString(); if (!htRecType.ContainsKey(RecType)) { htRecType.Add(RecType, ""); } if (!htFromStorageNo.ContainsKey(FromStorageNo)) { htFromStorageNo.Add(FromStorageNo, ""); } if (!htToStorageNo.ContainsKey(ToStorageNo)) { htToStorageNo.Add(ToStorageNo, ""); } if (!htOrgID.ContainsKey(OrgID)) { htOrgID.Add(OrgID, ""); } } if (htRecType.Count != 1) { WebInfoPublish.PublishInfo(this, "$Error_RecType_Different", this.languageComponent1); return; } if (htFromStorageNo.Count != 1) { WebInfoPublish.PublishInfo(this, "$Error_FromStorageNo_Different", this.languageComponent1); return; } if (htToStorageNo.Count != 1) { WebInfoPublish.PublishInfo(this, "$Error_ToStorageNo_Different", this.languageComponent1); return; } if (htOrgID.Count != 1) { WebInfoPublish.PublishInfo(this, "$Error_OrgID_Different", this.languageComponent1); return; } if (_TransferFacade == null) { _TransferFacade = new WarehouseFacade(this.DataProvider); } try { this.DataProvider.BeginTransaction(); //将选择的几个移转单的Detail信息按料号Sum(PLANQTY)重新计算数量后放在该新生成的移转单下。 Hashtable detailHT = new Hashtable(); decimal totalQty = 0; foreach (Infragistics.WebUI.UltraWebGrid.UltraGridRow row in array) { string TransferNO = row.Cells.FromKey("TransferNO").ToString(); decimal qty = _TransferFacade.QueryTransferQty(TransferNO); totalQty += qty; object[] objs = _TransferFacade.GetInvTransferDetailByTransferNO(TransferNO); if (objs != null) { foreach (InvTransferDetail tranferDetail in objs) { if (!detailHT.ContainsKey(tranferDetail.ItemCode)) { detailHT.Add(tranferDetail.ItemCode, tranferDetail.Planqty); } else { detailHT[tranferDetail.ItemCode] = decimal.Parse(detailHT[tranferDetail.ItemCode].ToString()) + tranferDetail.Planqty; } } } } //C:按规则 MESXXXXXXX(MES + 7位数字)生成新的移转单号(可以利用TblSerialBook表) string newTransNo = this.CreateNewTransNo(); DBDateTime dbDateTime = FormatHelper.GetNowDBDateTime(this.DataProvider); InvTransfer invTransfer = new InvTransfer(); invTransfer.TransferNO = newTransNo; invTransfer.TransferStatus = RecordStatus.RecordStatus_NEW; invTransfer.CreateDate = dbDateTime.DBDate; invTransfer.CreateTime = dbDateTime.DBTime; invTransfer.CreateUser = this.GetUserCode(); invTransfer.FromStorageID = (array[0] as Infragistics.WebUI.UltraWebGrid.UltraGridRow).Cells.FromKey("FromStorageID").Value.ToString(); invTransfer.ToStorageID = (array[0] as Infragistics.WebUI.UltraWebGrid.UltraGridRow).Cells.FromKey("ToStorageID").Value.ToString(); invTransfer.Rectype = (array[0] as Infragistics.WebUI.UltraWebGrid.UltraGridRow).Cells.FromKey("RECType").Value.ToString(); invTransfer.Memo = ""; invTransfer.Mdate = dbDateTime.DBDate; invTransfer.Mtime = dbDateTime.DBTime; invTransfer.Muser = this.GetUserCode(); invTransfer.OrgID = int.Parse((array[0] as Infragistics.WebUI.UltraWebGrid.UltraGridRow).Cells.FromKey("OrganizationID").Value.ToString()); _TransferFacade.AddInvTransfer(invTransfer); int i = 1; foreach (DictionaryEntry de in detailHT) { //ORDERNO,ORDERLINE,MEMO,MOCODE,CustomerCode,CUSTOMERNAME都为空,ACTQTY=0 InvTransferDetail detail = new InvTransferDetail(); detail.TransferNO = newTransNo; detail.TransferLine = i++; detail.OrderNO = ""; detail.OrderLine = 0; detail.Memo = ""; detail.MOCode = ""; detail.CustomerCode = ""; detail.CustomerName = ""; detail.Actqty = 0; detail.Muser = this.GetUserCode(); detail.Mdate = dbDateTime.DBDate; detail.Mtime = dbDateTime.DBTime; detail.TransferDate = dbDateTime.DBDate; detail.TransferTime = dbDateTime.DBTime; detail.TransferUser = this.GetUserCode(); detail.TransferStatus = RecordStatus.RecordStatus_NEW; detail.ItemCode = de.Key.ToString(); detail.Planqty = decimal.Parse(de.Value.ToString()); _TransferFacade.AddInvTransferDetail(detail); } //D:将关联关系插入table:TBLInvTransferMerge foreach (Infragistics.WebUI.UltraWebGrid.UltraGridRow row in array) { InvTransferMerge merge = new InvTransferMerge(); merge.Transferno = newTransNo; //merge.Frmtransferno = (array[0] as Infragistics.WebUI.UltraWebGrid.UltraGridRow).Cells.FromKey("FromStorageID").ToString(); //modify by li 2011.1.19 merge.Frmtransferno = row.Cells.FromKey("TransferNO").ToString(); merge.Muser = this.GetUserCode(); merge.Mdate = dbDateTime.DBDate; merge.Mtime = dbDateTime.DBTime; _TransferFacade.AddInvTransferMerge(merge); } this.DataProvider.CommitTransaction(); cmdQuery_ServerClick(null, null); WebInfoPublish.PublishInfo(this, string.Format("$Success_Merge_Transfer {0}", newTransNo), this.languageComponent1); } catch (Exception ex) { this.DataProvider.RollbackTransaction(); } }
// GET: api/ProdPMCReceipientVerify/5 //public string Get(int id) //{ // return "value"; //} // POST: api/ProdPMCReceipientVerify public HttpResponseMessage Post([FromBody] PMCReceipientVerificationModel obj) { try { if (obj != null) { PMCReceipientVerification objPMCRV = new PMCReceipientVerification { PickRawMtrlFKId = obj.PickRawMtrlFKId, Company = obj.Company, Plant = obj.Plant, JobNum = obj.JobNum, RequestDate = obj.RequestDate, PartNum = obj.PartNum, PartDesc = obj.PartDesc, LotNo = obj.LotNo, TuId = obj.TuId, ActQty = obj.ActQty, Qty = obj.Qty, UOM = obj.UOM, PickQty = obj.PickQty, PickUOM = obj.PickUOM, FromWarehse = obj.FromWarehse, FromBinNum = obj.FromBinNum, ToWarehse = obj.ToWarehse, ToBinNum = obj.ToBinNum, //PalletType = obj.PalletType, //PalletQty = obj.PalletQty, ReasonCode = obj.ReasonCode, ReasonDesc = obj.ReasonDesc, RejQty = obj.RejQty, //Status = "Accepted", UserId = obj.UserId, CreatedUtc = DateTime.Now }; StagingDbContext stagingDbContext = new StagingDbContext(); List <PMCReceipientVerification> objPMCRVs = new List <PMCReceipientVerification>(); if (objPMCRV.RejQty <= 0) { objPMCRV.Status = "Accepted"; //TODO if (objPMCRV.Status == "Accepted") { if (string.IsNullOrEmpty(objPMCRV.ToBinNum)) { throw new Exception("No To Bin Num!"); } //Normal InvTrans BO - If Accept only InvTransfer objInvTran = new InvTransfer(); objInvTran.company = objPMCRV.Company; objInvTran.frmBinNum = objPMCRV.FromBinNum; objInvTran.frmLotNum = objPMCRV.LotNo; objInvTran.frmWarehouse = objPMCRV.FromWarehse; objInvTran.toBinNum = objPMCRV.ToBinNum; objInvTran.toLotNum = objPMCRV.LotNo; objInvTran.toWarehouse = objPMCRV.ToWarehse; objInvTran.partNum = objPMCRV.PartNum; objInvTran.plant = objPMCRV.Plant; objInvTran.qty = objPMCRV.Qty; objInvTran.uom = objPMCRV.UOM; objInvTran.id = "PMCReceipientVer"; InventoryTransferServices objInvTranService = new InventoryTransferServices(); objInvTranService.doInvTransfer(objInvTran); } //Savedata to staging db PMCReceipientVerification objNewPMCRV = stagingDbContext.PMCReceipientVerifications.Add(objPMCRV); stagingDbContext.SaveChanges(); } else { PMCReceipientVerification tempDataReject = new PMCReceipientVerification(); PMCReceipientVerification tempDataAccept = new PMCReceipientVerification(); //Create accepted one tempDataAccept = objPMCRV; decimal normalQty = objPMCRV.Qty; decimal rejQty = objPMCRV.RejQty; decimal Qty = normalQty - rejQty; if (Qty > 0) { tempDataAccept.Qty = Qty; tempDataAccept.Status = "Accepted"; tempDataAccept.RejQty = 0; tempDataAccept.ReasonCode = ""; tempDataAccept.ReasonDesc = ""; //TODO if (tempDataAccept.Status == "Accepted") { if (string.IsNullOrEmpty(tempDataAccept.ToBinNum)) { throw new Exception("No To Bin Num!"); } //Normal InvTrans BO - If Accept only InvTransfer objInvTran = new InvTransfer(); objInvTran.company = tempDataAccept.Company; objInvTran.frmBinNum = tempDataAccept.FromBinNum; objInvTran.frmLotNum = tempDataAccept.LotNo; objInvTran.frmWarehouse = tempDataAccept.FromWarehse; objInvTran.toBinNum = tempDataAccept.ToBinNum; objInvTran.toLotNum = tempDataAccept.LotNo; objInvTran.toWarehouse = tempDataAccept.ToWarehse; objInvTran.partNum = tempDataAccept.PartNum; objInvTran.plant = tempDataAccept.Plant; objInvTran.qty = tempDataAccept.Qty; objInvTran.uom = tempDataAccept.UOM; objInvTran.id = "PMCReceipientVer"; InventoryTransferServices objInvTranService = new InventoryTransferServices(); objInvTranService.doInvTransfer(objInvTran); } PMCReceipientVerification objNewPMCRVAcc = stagingDbContext.PMCReceipientVerifications.Add(tempDataAccept); stagingDbContext.SaveChanges(); } //Create rejected one tempDataReject = objPMCRV; tempDataReject.RejQty = obj.RejQty; tempDataReject.ReasonCode = obj.ReasonCode; tempDataReject.Status = "Rejected"; DAL dal = new DAL(); string rejBin = dal.GetRejBin(obj.Company); tempDataReject.ToBinNum = rejBin; tempDataReject.ToWarehse = obj.ToWarehse; if (string.IsNullOrEmpty(tempDataReject.ToBinNum)) { throw new Exception("No Reject Bin!"); } PMCReceipientVerification objNewPMCRV = stagingDbContext.PMCReceipientVerifications.Add(tempDataReject); stagingDbContext.SaveChanges(); } BusinessLayer BL = new BusinessLayer(); string PalletType = ""; decimal PalletQty = 0; BL.GetPalletDetails(objPMCRV.PickRawMtrlFKId, out PalletType, out PalletQty); string PalletWareHouse = ""; string PalletBinNum = ""; BL.GetPalletWarehouse(objPMCRV.Company, out PalletWareHouse, out PalletBinNum); //TODO // PalletType InvTrans BO - If Rej Or Accept have to do if (!obj.IsEpiRow && !string.IsNullOrEmpty(PalletType)) { InvTransfer objInvTranPalletType = new InvTransfer(); objInvTranPalletType.company = objPMCRV.Company; objInvTranPalletType.frmBinNum = PalletBinNum; //objInvTranPalletType.frmLotNum = objPMCRV.LotNo; objInvTranPalletType.frmWarehouse = PalletWareHouse; objInvTranPalletType.toBinNum = objPMCRV.ToBinNum; //objInvTranPalletType.toLotNum = objPMCRV.LotNo; objInvTranPalletType.toWarehouse = objPMCRV.ToWarehse; objInvTranPalletType.partNum = PalletType; objInvTranPalletType.plant = objPMCRV.Plant; objInvTranPalletType.qty = PalletQty; //objInvTranPalletType.uom = objPMCRV.UOM; objInvTranPalletType.id = "PMCReceipientVer"; InventoryTransferServices objInvTranService = new InventoryTransferServices(); objInvTranService.doInvTransfer(objInvTranPalletType); } //Validate obj.ts with db to know any one changed data or not // 1) PalletType InvTrans BO - If Rej Or Accept have to do // 2) Normal InvTrans BO - If Accept only // 3) Insert Recrod in to Staging DB // 4) Update Status (isPMCVerify=true or false And isPalletTypeInvTranBO = true or not) in PickRawMtrl table of Staging DB string UpdQry = $"Update [" + ConnectionLibrary.Conn.HandHeldDB + $"].[dbo].[WIPickRawMtrlTbl] Set [IsPMCVerify]=1 , IsPalletTypeInvTransBO={(!obj.IsEpiRow?1:0)} Where Id={obj.PickRawMtrlFKId} "; int i = stagingDbContext.Database.ExecuteSqlCommand(UpdQry); return(Request.CreateResponse(HttpStatusCode.OK, "Inserted Successfully!")); } else { throw new Exception("PMCReceipientVerification Model is Null!"); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message.ToString())); } }
// POST: api/PickRawMtrl public HttpResponseMessage Post([FromBody] PickRawMtrlModel objPickRawMtrlModel) { try { if (objPickRawMtrlModel != null) { if (string.IsNullOrEmpty(objPickRawMtrlModel.ToBinNum)) { throw new Exception("To Bin is required!"); //No Transit Bin } PickRawMtrl objPRM = new PickRawMtrl { Company = objPickRawMtrlModel.Company, Plant = objPickRawMtrlModel.Plant, JobNum = objPickRawMtrlModel.JobNum, RequestDate = objPickRawMtrlModel.RequestDate, PartNum = objPickRawMtrlModel.PartNum, PartDesc = objPickRawMtrlModel.PartDesc, LotNo = objPickRawMtrlModel.LotNo, TuId = objPickRawMtrlModel.TuId, ActQty = objPickRawMtrlModel.ActQty, Qty = objPickRawMtrlModel.Qty, UOM = objPickRawMtrlModel.UOM, PickQty = objPickRawMtrlModel.PickQty, PickUOM = objPickRawMtrlModel.PickUOM, FromWarehse = objPickRawMtrlModel.FromWarehse, //Must from Transit Bin. To here is refer to UD21. ShortChar08 FromBinNum = objPickRawMtrlModel.FromBinNum, //Must from Transit Bin. To here is refer to UD21. ShortChar08 ToWarehse = objPickRawMtrlModel.ToWarehse, //To PMC Wh . Refer to UD21. ShortChar03 ToBinNum = objPickRawMtrlModel.ToBinNum, //TO PMC Bin . Refer to UD21. ShortChar04 //FromWarehse = objPickRawMtrlModel.FromWarehse, //FromBinNum = objPickRawMtrlModel.FromBinNum, //ToWarehse = objPickRawMtrlModel.ToWarehse, //ToBinNum = objPickRawMtrlModel.ToBinNum, PalletType = objPickRawMtrlModel.PalletType, PalletQty = objPickRawMtrlModel.PalletQty, UserId = objPickRawMtrlModel.UserId, SysRowId = objPickRawMtrlModel.SysRowId, CreatedUtc = DateTime.Now, ConvFactor = objPickRawMtrlModel.ConvFactor, DynamicPick = objPickRawMtrlModel.DynamicPick }; //Validation if (string.IsNullOrEmpty(objPRM.Company)) { throw new Exception("Company is Require!"); } if (string.IsNullOrEmpty(objPRM.PartNum)) { throw new Exception("PartNum is Require!"); } if (string.IsNullOrEmpty(objPRM.LotNo)) { throw new Exception("LotNum is Require!"); } if (string.IsNullOrEmpty(objPRM.FromWarehse)) { throw new Exception("FromWarehse is Require!"); } if (string.IsNullOrEmpty(objPRM.FromBinNum)) { throw new Exception("FromBinNum is Require!"); } if (objPRM.Qty <= 0) { throw new Exception("Qty is Require!"); } if (string.IsNullOrEmpty(objPRM.PalletType)) { //throw new Exception("PalletType is Require!"); } if (!string.IsNullOrEmpty(objPRM.PalletType) && objPRM.PalletQty <= 0) { throw new Exception("PalletQty is Require!"); } EpicorDbContext epicorDbContext = new EpicorDbContext(); //DBValidation for (Lot,FromWH and FromBin,OnHandQty,ToWH ,ToBin) And Also for (PalletType and Qty) StringBuilder sbVQry = new StringBuilder(); sbVQry.Append(" select case "); sbVQry.Append($" When (select top 1 LotNum from PartLot where Company='{objPRM.Company}' and PartNum='{objPRM.PartNum}' and LotNum='{objPRM.LotNo}' ) is null then 'LotNum {objPRM.LotNo} was not found!' "); sbVQry.Append($" When (select top 1 WarehouseCode as FromWH from erp.PartWhse where Company='{objPRM.Company}' and PartNum='{objPRM.PartNum}' and WarehouseCode='{objPRM.FromWarehse}' ) is null then 'FromWarehouse {objPRM.FromWarehse} not found!' "); sbVQry.Append($" When (select top 1 b.BinNum as FromBin from erp.PartWhse a inner join WhseBin b on a.Company=b.Company and a.WarehouseCode=b.WarehouseCode where a.Company='{objPRM.Company}' and a.PartNum='{objPRM.PartNum}' and a.WarehouseCode='{objPRM.FromWarehse}' and b.BinNum='{objPRM.FromBinNum}' ) is null then 'FromBinNum {objPRM.FromBinNum} not found!' "); sbVQry.Append($" When (select Top 1 (OnhandQty-AllocatedQty) as Qty from erp.PartBin where Company='{objPRM.Company}' and PartNum='{objPRM.PartNum}' and LotNum='{objPRM.LotNo}' and OnhandQty-AllocatedQty >= {objPRM.Qty} ) is null then 'OnHandQty not Enough!' "); sbVQry.Append($" When (select top 1 WarehouseCode as ToWH from erp.PartWhse where Company='{objPRM.Company}' and PartNum='{objPRM.PartNum}' and WarehouseCode='{objPRM.ToWarehse}' ) is null then 'ToWarehouse {objPRM.ToWarehse} not found!' "); sbVQry.Append($" When (select top 1 b.BinNum as ToBin from erp.PartWhse a inner join WhseBin b on a.Company=b.Company and a.WarehouseCode=b.WarehouseCode where a.Company='{objPRM.Company}' and a.PartNum='{objPRM.PartNum}' and a.WarehouseCode='{objPRM.ToWarehse}' and b.BinNum='{objPRM.ToBinNum}' ) is null then 'ToBinNum {objPRM.ToBinNum} not found!' "); sbVQry.Append(" else '0' end "); string errMsg = epicorDbContext.Database.SqlQuery <string>(sbVQry.ToString()).SingleOrDefault(); if (errMsg != "0") { throw new Exception(errMsg); } //Validation of SysRevId //string revQry = "Select SysRevId from erp.JobMtl Where SysRowId=@SysRowId"; //EpicorDbContext epicorDbContext = new EpicorDbContext(); //Type obj=null; //epicorDbContext.Database.SqlQuery(obj, revQry, new SqlParameter("@SysRowId", objPickRawMtrlModel.SysRowId.ToString())); //string epiSysRevId = obj.ToString(); //Do Inventory Transfer to PMC Warehouse Transit Bin (Table WhseBin, Column FS_PMCTransit_c) InvTransfer objInvTran = new InvTransfer(); objInvTran.company = objPickRawMtrlModel.Company; objInvTran.frmBinNum = objPickRawMtrlModel.FromBinNum; objInvTran.frmLotNum = objPickRawMtrlModel.LotNo; objInvTran.frmWarehouse = objPickRawMtrlModel.FromWarehse; objInvTran.toBinNum = objPickRawMtrlModel.ToBinNum; //move to transit bin objInvTran.toLotNum = objPickRawMtrlModel.LotNo; objInvTran.toWarehouse = objPickRawMtrlModel.ToWarehse; objInvTran.partNum = objPickRawMtrlModel.PartNum; objInvTran.plant = objPickRawMtrlModel.Plant; objInvTran.qty = objPickRawMtrlModel.Qty; objInvTran.uom = objPickRawMtrlModel.UOM; objInvTran.id = "PickRawMtl"; InventoryTransferServices objInvTranService = new InventoryTransferServices(); objInvTranService.doInvTransfer(objInvTran); //Inventory Transfer End StagingDbContext stagingDbContext = new StagingDbContext(); PickRawMtrl objNewPRM = stagingDbContext.PickRawMtrls.Add(objPRM); stagingDbContext.SaveChanges(); string QryCheckQty = $"IF NOT EXISTS (Select Top 1 Qty from dbo.vwHH_WIPickRawMtrl Where SysRowID='{objPickRawMtrlModel.SysRowId}' ) BEGIN Select 0.0 as Qty END ELSE (Select Top 1 Qty from dbo.vwHH_WIPickRawMtrl Where SysRowID='{objPickRawMtrlModel.SysRowId}')"; decimal pickedQty = epicorDbContext.Database.SqlQuery <decimal>(QryCheckQty.ToString()).SingleOrDefault(); if (pickedQty - objPRM.Qty <= 0) { string Qry = $"Update [Ice].[UD21] Set [CheckBox01]=1 Where SysRowID='{objPickRawMtrlModel.SysRowId}' "; int i = epicorDbContext.Database.ExecuteSqlCommand(Qry); } return(Request.CreateResponse(HttpStatusCode.OK, pickedQty - objPRM.Qty)); } else { throw new Exception("PickRawMtrl is Null!"); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message.ToString())); } }
public string UpdateFGReduce(FGReduceLotDetails obj) { string msg = ""; if (obj == null) { return("Empty object."); } string newLotNum = obj.LotNum; /* * if (newLotNum.Length > 15) * newLotNum = newLotNum.Substring(0, 15) + DateTime.Now.ToString("yyyyMMddHHmmss"); * else * newLotNum = newLotNum + DateTime.Now.ToString("yyyyMMddHHmmss"); */ newLotNum = newLotNum + 'X'; //Check If Lot+X already exist or not in PartTran FGReduceLotDetails fgDetails = new FGReduceLotDetails(); DAL objDAL = new DAL(); fgDetails = objDAL.CheckLotInPartTran(obj.Company, newLotNum, obj.PartNum); //If not exist, create lot if (string.IsNullOrEmpty(fgDetails.LotNum)) { //Lot Creation LotCreationServices lc = new LotCreationServices(); lc.Begin(newLotNum, obj.Company, obj.Plant, obj.PartNum); } msg = $"{obj.LotNum} -> {newLotNum}"; //TEST if (obj.Plant == null) { obj.Plant = ""; } try { //Inventory Transfer InventoryTransferServices it = new InventoryTransferServices(); InvTransfer invTransfer = new InvTransfer(); invTransfer.company = obj.Company; invTransfer.plant = obj.Plant; invTransfer.id = "FG Reduce : " + msg; invTransfer.partNum = obj.PartNum; invTransfer.qty = obj.ModifiedQty; invTransfer.uom = obj.Uom; invTransfer.frmWarehouse = obj.FromWarehouse; invTransfer.frmBinNum = obj.FromBinNum; invTransfer.frmLotNum = obj.LotNum; invTransfer.toWarehouse = obj.ToWarehouse; invTransfer.toBinNum = obj.ToBinNum; invTransfer.toLotNum = newLotNum; it.doInvTransfer(invTransfer); msg = $"Successfully reduce. {obj.LotNum} -> {newLotNum}"; //Ashraf Start Here List <FGReduceLotDetails> objFGReduceInvTransList = new List <FGReduceLotDetails>(); FGReduceLotDetails objFG = new FGReduceLotDetails(); objFG.LotNum = obj.LotNum; objFG.Company = obj.Company; objFG.PartNum = obj.PartNum; objFGReduceInvTransList.Add(objFG); FGReduceLotDetails objFGNew = new FGReduceLotDetails(); objFGNew.LotNum = newLotNum; objFGNew.Company = obj.Company; objFGNew.PartNum = obj.PartNum; objFGReduceInvTransList.Add(objFGNew); msg = msg + GenerateFGReduceCSV(objFGReduceInvTransList); //Ashraf End Here } catch (Exception ex) { msg = ex.Message.ToString(); } return(msg); }
//##### Chen's Version Starts##### public string Begin(InvTransfer objInvTransfer, out string sErrMsg) { string sMsg = string.Empty; sErrMsg = string.Empty; EndpointBindingType bindingType = EndpointBindingType.BasicHttp; string epicorUserID = Conn.epicorUserID; string epiorUserPassword = Conn.epiorUserPassword; Guid sessionId = Guid.Empty; svcSessionMod.SessionModSvcContractClient sessionModClient = null; string comp = "", plant = ""; comp = string.IsNullOrEmpty(objInvTransfer.company) ? Conn.Company : objInvTransfer.company; plant = string.IsNullOrEmpty(objInvTransfer.plant) ? Conn.Plant : objInvTransfer.plant; string scheme = "https"; if (bindingType == EndpointBindingType.SOAPHttp) { scheme = "http"; } UriBuilder builder = new UriBuilder(scheme, Conn.hostName); builder.Path = $"{Conn.environment}/Ice/Lib/SessionMod.svc"; try { sessionModClient = GetClient <svcSessionMod.SessionModSvcContractClient, svcSessionMod.SessionModSvcContract> ( builder.Uri.ToString(), epicorUserID, epiorUserPassword, bindingType ); string siteID = "", siteName = "", workstationID = "", workstationDesc = ""; string employeeID = "", countryGroupCode = "", countryCode = "", tenantID = ""; sessionId = sessionModClient.Login(); builder.Path = $"{Conn.environment}/Ice/Lib/SessionMod.svc"; sessionModClient = GetClient <svcSessionMod.SessionModSvcContractClient, svcSessionMod.SessionModSvcContract>(builder.Uri.ToString(), epicorUserID, epiorUserPassword, bindingType); sessionModClient.Endpoint.EndpointBehaviors.Add(new HookServiceBehavior(sessionId, epicorUserID)); //** CHANGE configCompany & configPlant to read from input **// sessionModClient.SetCompany(comp, out siteID, out siteName, out workstationID, out workstationDesc, out employeeID, out countryGroupCode, out countryCode, out tenantID); sessionModClient.SetPlant(plant); if (sessionId != Guid.Empty) { // ##### TEST DATA ##### // List <InvTransfer> invTransfers = new List <InvTransfer>(); invTransfers.Add(objInvTransfer); //invTransfers.Add(new InvTransfer //{ // company = configCompany, // plant = configPlant, // id = 1, // partNum = "1-BAG-GEN-000000-002", // qty = 1, // uom = "KG", // frmWarehouse = "L05", // frmBinNum = "RS_BTL", // frmLotNum = "Lot 04", // All from details i can get from PartBin - LotNum // toWarehouse = "L09", // Default boolean value in Warehse // toBinNum = "L09", // Default boolean value in WarehseBin // toLotNum = "Lot 01" // Same as fromLotNum //}); sMsg = InventoryTransfer_TranPK(epicorUserID, epiorUserPassword, builder, sessionId, invTransfers, out sErrMsg); } else { //Sessionid is Empty! } } catch (Exception ex) { sErrMsg = ex.Message.ToString(); //throw new Exception($"Epicor Error : {ex.Message.ToString()}"); } finally { if (sessionId != Guid.Empty) { sessionModClient.Logout(); } } return(sMsg); }
static void Main(string[] args) { Console.Write("Inserire ERPOrder (string): "); string erpOrder = Console.ReadLine(); Console.Write("Inserire Sequence (int): "); int sequence = Int32.Parse(Console.ReadLine()); InforResult result = new InforResult(); while (true) { Console.WriteLine("Selezionare richiesta:\n\n 1) Report Production\n 2) Unplanned Material\n 3) Material Non Conformance \n 4) Operation Progress\n"); int choice = Int32.Parse(Console.ReadLine()); InvTransfer materialNonConf = new InvTransfer("TestOrderNumber", "TransIdTest;ToWarehouseTest", "StorageUnitTest", Convert.ToDecimal(1.2), "100", "002612155", true); try { if ((choice > 0) && (choice < 5)) { if (choice == 1) { ReportProduction reportProd = new ReportProduction(erpOrder, true, "100"); result = InforConnector.ReportProducedQuantity(reportProd); } else if (choice == 2) { Console.Write("\nDammi il consumedMaterialSequence (int): "); int consumedMaterialSequence = Int32.Parse(Console.ReadLine()); Console.Write("Dammi il consumedMaterialDef (string): "); string consumedMaterialDef = (Console.ReadLine()); Console.Write("Dammi la UoM (string): "); string unit = (Console.ReadLine()); Console.Write("Dammi il customized (0/1): "); bool customized = Console.ReadLine() == "0" ? false : true; Console.Write("Dammi la quantity (decimal): "); decimal qty = decimal.Parse(Console.ReadLine()); UnplannedMat unplannedMat = new UnplannedMat(erpOrder, sequence, consumedMaterialDef, customized, consumedMaterialSequence, Convert.ToDecimal(qty), unit, "100"); result = InforConnector.ReportConsumedMaterial(unplannedMat); } else if (choice == 3) { result = InforConnector.ReportMaterialNonConformance(materialNonConf); } else if (choice == 4) { Console.Write("\nDammi il closeOrder (0/1): "); bool closeOrder = Console.ReadLine() == "0" ? false : true; OperatorOperation operationProg = new OperatorOperation(erpOrder, sequence, 1, "100", closeOrder); result = InforConnector.ReportOperationProgress(operationProg); } Console.WriteLine("Test passed: " + result.InforCallSucceeded.ToString() + " with message: " + result.Error); } else { Console.WriteLine("\nScelta errata"); } } catch (Exception e) { Console.WriteLine(e.ToString()); } } }