public static int DeleteGrnDetail(int TrxNo, int LineItemNo) { int afRecCnt = 0; using (var connection = new ConnectionProvider(ApiService.Site).CreateDbConnection()) { try { connection.Open(); // delete grn detail afRecCnt += connection.Execute(qryGoodsReceiptNote.deleteGrnDetail, new { TrxNo, LineItemNo, UpdateBy = ApiService.UserId }, null, null, CommandType.StoredProcedure); } catch (Exception) { throw; } finally { connection.Close(); } } var myGrn = GetGrn(TrxNo); InventoryHelper.DeleteInvByBatch(myGrn.GoodsReceiptNoteNo, LineItemNo, myGrn.WarehouseCode); return(afRecCnt); }
public IHttpActionResult GetBalanceStoreSpaceByBinNo(string WarehouseCode, string BinNo) { if (!ModelState.IsValid) { return(BadRequest()); } decimal?balanceStoreSpace = InventoryHelper.GetBalanceStoreSpaceByBinNo(WarehouseCode, BinNo); return(Ok(balanceStoreSpace)); }
public static bool SaveToInv(int TrxNo) { bool isDone = false; // configure automapper var config = new MapperConfiguration(cfg => cfg.CreateMap <whgi2, whiv1>() .ForMember(dest => dest.BatchLineItemNo, opt => opt.MapFrom(src => src.LineItemNo)) .ForMember(dest => dest.TrxNo, opt => opt.Ignore()) ); var mapper = config.CreateMapper(); // get gin, gindetails whgi1 gin = GetGin(TrxNo); IEnumerable <whgi2> ginDetails = GetGinDetails(TrxNo); using (var connection = new ConnectionProvider(ApiService.Site).CreateDbConnection()) { try { connection.Open(); foreach (var ginDetail in ginDetails) { // set minus values ginDetail.Length = -1 * ginDetail.Length; ginDetail.Width = -1 * ginDetail.Width; ginDetail.Height = -1 * ginDetail.Height; ginDetail.Weight = -1 * ginDetail.Weight; ginDetail.Volume = -1 * ginDetail.Volume; ginDetail.SpaceArea = -1 * ginDetail.SpaceArea; ginDetail.Qty = -1 * ginDetail.Qty; // map gin to inv whiv1 myInv = mapper.Map <whiv1>(ginDetail); myInv.BatchNo = gin.GoodsIssueNoteNo; myInv.WarehouseCode = gin.WarehouseCode; myInv.WorkStation = ApiService.HostName; myInv.CreateBy = ApiService.UserId; myInv.CreateDateTime = ApiService.ClientDate; myInv.UpdateBy = ApiService.UserId; myInv.UpdateDateTime = ApiService.ClientDate; // save to inventory isDone = InventoryHelper.SaveInv(myInv); } } catch (Exception) { throw; } finally { connection.Close(); } } return(isDone); }
public IHttpActionResult GetItems(string WarehouseCode, string SupplierCode, [FromUri] int[] ExcludeTrxNos = null) { if (!ModelState.IsValid) { return(BadRequest()); } var items = InventoryHelper.GetItemsBySupplierCode(WarehouseCode, SupplierCode, ExcludeTrxNos); if (items == null) { return(InternalServerError()); } return(Ok(items)); }
public IHttpActionResult getInvRefCount(string GrnNo) { if (!ModelState.IsValid) { return(BadRequest()); } int?invRefCnt = InventoryHelper.GetBatchRefCount(GrnNo); if (invRefCnt == null) { return(InternalServerError()); } return(Ok(invRefCnt)); }
public IHttpActionResult GetItemsByBinNo(string WarehouseCode, string BinNo) { if (!ModelState.IsValid) { return(BadRequest()); } var items = InventoryHelper.GetItemsByBinNo(WarehouseCode, BinNo); if (items == null) { return(InternalServerError()); } return(Ok(items)); }
public IHttpActionResult TransferBinNos(JObject data) { if (!ModelState.IsValid) { return(BadRequest()); } List <whiv1> items = data["Items"].ToObject <List <whiv1> >(); string transferBinNo = data["TransferBinNo"].ToObject <string>(); bool isDone = InventoryHelper.UpdateBinNos(items, transferBinNo); if (!isDone) { return(InternalServerError()); } return(Ok()); }
public static bool DeleteFromInv(int TrxNo) { bool isDone = false; // get gin, gindetails whgi1 gin = GetGin(TrxNo); using (var connection = new ConnectionProvider(ApiService.Site).CreateDbConnection()) { try { connection.Open(); isDone = InventoryHelper.DeleteInvBatch(gin.GoodsIssueNoteNo); } catch (Exception) { throw; } finally { connection.Close(); } } return(isDone); }
public static IEnumerable <string> generatePickList(IEnumerable <whiv1> InvItemList, string WarehouseCode, string WaveBy) { List <string> pickNos = new List <string>(); switch (WaveBy) { case "A": var aisleList = (from item in InvItemList select item.BinNo.Substring(0, 2)).Distinct(); foreach (string aisle in aisleList) { IEnumerable <whiv1> invItemGroup = from item in InvItemList where item.BinNo.Substring(0, 2) == aisle select item; string pickNo = PickListHelper.getNewPickNo(DateTime.Today); whpl1 pickList = new whpl1 { TrxNo = 0, PickNo = pickNo, PickDate = DateTime.Today, WarehouseCode = WarehouseCode, PickBy = null, Remark = "", WorkStation = ApiService.HostName, StatusCode = "USE", CreateBy = ApiService.UserId, CreateDateTime = ApiService.ClientDate, UpdateBy = ApiService.UserId, UpdateDateTime = ApiService.ClientDate }; pickList.TrxNo = PickListHelper.savePickList(pickList); int lineItemNo = 1; List <whpl2> pickListDetails = new List <whpl2>(); foreach (whiv1 invItem in invItemGroup) { whpl2 pickListDetail = new whpl2 { TrxNo = pickList.TrxNo, LineItemNo = lineItemNo, BatchNo = invItem.BatchNo, BinNo = invItem.BinNo, Description = invItem.Description, DimensionFlag = invItem.DimensionFlag, ExpiryDate = invItem.ExpiryDate, Height = -1 * invItem.Height, Length = -1 * invItem.Length, Qty = -1 * invItem.Qty, ManufactureDate = invItem.ManufactureDate, ItemCode = invItem.ItemCode, SpaceArea = -1 * invItem.SpaceArea, UomCode = invItem.UomCode, Volume = -1 * invItem.Volume, Weight = -1 * invItem.Weight, Width = -1 * invItem.Width }; pickListDetails.Add(pickListDetail); lineItemNo++; invItem.StatusCode = "CLS"; InventoryHelper.SaveInv(invItem); } PickListHelper.savePickListDetails(pickListDetails); pickNos.Add(pickList.PickNo); } break; case "S": var sectionList = (from item in InvItemList select item.BinNo.Substring(2, 2)).Distinct(); foreach (string section in sectionList) { IEnumerable <whiv1> invItemGroup = from item in InvItemList where item.BinNo.Substring(2, 2) == section select item; string pickNo = PickListHelper.getNewPickNo(DateTime.Today); whpl1 pickList = new whpl1 { TrxNo = 0, PickNo = pickNo, PickBy = null, PickDate = DateTime.Today, WarehouseCode = WarehouseCode, Remark = "", WorkStation = ApiService.HostName, StatusCode = "USE", CreateBy = ApiService.UserId, CreateDateTime = ApiService.ClientDate, UpdateBy = ApiService.UserId, UpdateDateTime = ApiService.ClientDate }; pickList.TrxNo = PickListHelper.savePickList(pickList); int lineItemNo = 1; List <whpl2> pickListDetails = new List <whpl2>(); foreach (whiv1 invItem in invItemGroup) { whpl2 pickListDetail = new whpl2 { TrxNo = pickList.TrxNo, LineItemNo = lineItemNo, BatchNo = invItem.BatchNo, BinNo = invItem.BinNo, Description = invItem.Description, DimensionFlag = invItem.DimensionFlag, ExpiryDate = invItem.ExpiryDate, Height = -1 * invItem.Height, Length = -1 * invItem.Length, Qty = -1 * invItem.Qty, ManufactureDate = invItem.ManufactureDate, ItemCode = invItem.ItemCode, SpaceArea = -1 * invItem.SpaceArea, UomCode = invItem.UomCode, Volume = -1 * invItem.Volume, Weight = -1 * invItem.Weight, Width = -1 * invItem.Width }; pickListDetails.Add(pickListDetail); lineItemNo++; invItem.StatusCode = "CLS"; InventoryHelper.SaveInv(invItem); } PickListHelper.savePickListDetails(pickListDetails); pickNos.Add(pickList.PickNo); } break; default: var shelfList = (from item in InvItemList select item.BinNo.Substring(4, 2)).Distinct(); foreach (string shelf in shelfList) { IEnumerable <whiv1> invItemGroup = from item in InvItemList where item.BinNo.Substring(4, 2) == shelf select item; string pickNo = PickListHelper.getNewPickNo(DateTime.Today); whpl1 pickList = new whpl1 { TrxNo = 0, PickNo = pickNo, PickBy = null, PickDate = DateTime.Today, WarehouseCode = WarehouseCode, Remark = "", WorkStation = ApiService.HostName, StatusCode = "USE", CreateBy = ApiService.UserId, CreateDateTime = ApiService.ClientDate, UpdateBy = ApiService.UserId, UpdateDateTime = ApiService.ClientDate }; pickList.TrxNo = PickListHelper.savePickList(pickList); int lineItemNo = 1; List <whpl2> pickListDetails = new List <whpl2>(); foreach (whiv1 invItem in invItemGroup) { whpl2 pickListDetail = new whpl2 { TrxNo = pickList.TrxNo, LineItemNo = lineItemNo, BatchNo = invItem.BatchNo, BinNo = invItem.BinNo, Description = invItem.Description, DimensionFlag = invItem.DimensionFlag, ExpiryDate = invItem.ExpiryDate, Height = -1 * invItem.Height, Length = -1 * invItem.Length, Qty = -1 * invItem.Qty, ManufactureDate = invItem.ManufactureDate, ItemCode = invItem.ItemCode, SpaceArea = -1 * invItem.SpaceArea, UomCode = invItem.UomCode, Volume = -1 * invItem.Volume, Weight = -1 * invItem.Weight, Width = -1 * invItem.Width }; pickListDetails.Add(pickListDetail); lineItemNo++; invItem.StatusCode = "CLS"; InventoryHelper.SaveInv(invItem); } PickListHelper.savePickListDetails(pickListDetails); pickNos.Add(pickList.PickNo); } break; } return(pickNos); }
public static string AssignBinNo(int TrxNo, int LineItemNo) { int afRecCnt = 0; whgr1 myGrn = GetGrn(TrxNo); whgr2 myGrnDetail = GetGrnDetail(TrxNo, LineItemNo); string WarehouseCode = myGrn.WarehouseCode; decimal?StoreSpace = myGrnDetail.SpaceArea; string BinNo; using (var connection = new ConnectionProvider(ApiService.Site).CreateDbConnection()) { try { connection.Open(); // get bin no BinNo = connection.ExecuteScalar <string>(qryGoodsReceiptNote.selectAvalBinNo, new { WarehouseCode, StoreSpace }, null, null, CommandType.StoredProcedure); if (!string.IsNullOrEmpty(BinNo)) { // update bin no afRecCnt = connection.Execute(qryGoodsReceiptNote.updateBinNo, new { TrxNo, LineItemNo, BinNo, UpdateBy = ApiService.UserId }); myGrnDetail.BinNo = BinNo; } } catch (Exception) { throw; } finally { connection.Close(); } } // update inventory if (afRecCnt > 0) { var config = new MapperConfiguration(cfg => cfg.CreateMap <whgr2, whiv1>() .ForMember(dest => dest.BatchLineItemNo, opt => opt.MapFrom(src => src.LineItemNo)) .ForMember(dest => dest.TrxNo, opt => opt.Ignore()) ); var mapper = config.CreateMapper(); var myInv = mapper.Map <whiv1>(myGrnDetail); myInv.BatchNo = myGrn.GoodsReceiptNoteNo; myInv.WarehouseCode = myGrn.WarehouseCode; myInv.WorkStation = ApiService.HostName; myInv.CreateBy = ApiService.UserId; myInv.CreateDateTime = ApiService.ClientDate; myInv.UpdateBy = ApiService.UserId; myInv.UpdateDateTime = ApiService.ClientDate; InventoryHelper.SaveInv(myInv); } return(BinNo); }