public IHttpActionResult SaveGrn(whgr1 Grn) { if (!ModelState.IsValid) { return(BadRequest()); } int trxNo = GrnHelper.SaveGrn(Grn); if (trxNo <= 0) { return(InternalServerError()); } return(Ok(trxNo)); }
public IHttpActionResult GetStatusCode(int TrxNo) { if (!ModelState.IsValid) { return(BadRequest()); } whgr1 myGrn = GrnHelper.GetGrn(TrxNo); if (myGrn == null) { return(InternalServerError()); } return(Ok(myGrn.StatusCode)); }
public static whgr1 GetGrn(int TrxNo) { whgr1 myGrn = null; using (var connection = new ConnectionProvider(ApiService.Site).CreateDbConnection()) { try { connection.Open(); myGrn = connection.QuerySingleOrDefault <whgr1>(qryGoodsReceiptNote.selectGrn, new { TrxNo }); } catch (Exception) { throw; } finally { connection.Close(); } } return(myGrn); }
public static List <whgr2> AssignBinNos(int TrxNo) { whgr1 myGrn = GetGrn(TrxNo); List <whgr2> myGrnDetails = GetGrnDetails(TrxNo); var emptyBinGrnDetails = myGrnDetails.Where(r => string.IsNullOrEmpty(r.BinNo)); // save goods receipt note details try { foreach (var myGrnDetail in emptyBinGrnDetails) { string binNo = AssignBinNo(myGrnDetail.TrxNo, myGrnDetail.LineItemNo); myGrnDetail.BinNo = binNo; } } catch (Exception) { throw; } return(myGrnDetails); }
public static int SaveGrn(whgr1 Grn) { int TrxNo = 0; using (var connection = new ConnectionProvider(ApiService.Site).CreateDbConnection()) { try { connection.Open(); string storeProcName; if (Grn.TrxNo <= 0) { // set audit values Grn.WorkStation = ApiService.HostName; Grn.CreateBy = ApiService.UserId; Grn.CreateDateTime = ApiService.ClientDate; Grn.UpdateBy = ApiService.UserId; Grn.UpdateDateTime = ApiService.ClientDate; // set insert store procedure storeProcName = qryGoodsReceiptNote.insertGrn; } else { // set audit values Grn.WorkStation = ApiService.HostName; Grn.UpdateBy = ApiService.UserId; Grn.UpdateDateTime = ApiService.ClientDate; // set update store procedure storeProcName = qryGoodsReceiptNote.updateGrn; } var param = connection.GetStoreProcParams(storeProcName, Grn); TrxNo = connection.ExecuteScalar <int>(storeProcName, param, null, null, CommandType.StoredProcedure); } catch (Exception) { throw; } finally { connection.Close(); } } return(TrxNo); }
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); }