public IHttpActionResult SaveGrnDetail(whgr2 grnDetail) { if (!ModelState.IsValid) { return(BadRequest()); } int afRecCnt = GrnHelper.SaveGrnDetail(grnDetail); if (afRecCnt <= 0) { return(InternalServerError()); } return(Ok()); }
public static whgr2 GetGrnDetail(int TrxNo, int LineItemNo) { whgr2 myGrnDetail = null; using (var connection = new ConnectionProvider(ApiService.Site).CreateDbConnection()) { try { connection.Open(); myGrnDetail = connection.QuerySingleOrDefault <whgr2>(qryGoodsReceiptNote.selectGrnDetail, new { TrxNo, LineItemNo }); } catch (Exception) { throw; } finally { connection.Close(); } } return(myGrnDetail); }
public static int SaveGrnDetail(whgr2 GrnDetail) { int afRecCnt = 0; using (var connection = new ConnectionProvider(ApiService.Site).CreateDbConnection()) { try { connection.Open(); int grnDetailCnt = connection.ExecuteScalar <int>(qryGoodsReceiptNote.selectGrnDetailCount, new { TrxNo = GrnDetail.TrxNo, LineItemNo = GrnDetail.LineItemNo }); string storeProcName; if (grnDetailCnt <= 0) { // set insert store procedure storeProcName = qryGoodsReceiptNote.insertGrnDetail; } else { // set update store procedure storeProcName = qryGoodsReceiptNote.updateGrnDetail; } var param = connection.GetStoreProcParams(storeProcName, GrnDetail); afRecCnt = connection.Execute(storeProcName, param, null, null, CommandType.StoredProcedure); } catch (Exception) { throw; } finally { connection.Close(); } } return(afRecCnt); }
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); }