private void SaveLots(StockDetail entityDetail, StockHead entityStockHead) { //update into in_phy_lot PhyLot entityPhyLot = ServiceProvider.PhyLotService.GetPhyLot(entityDetail.material_id, entityStockHead.warehouse_id, entityDetail.lot_no, false); entityPhyLot.bal_qty = entityDetail.bal_qty; entityPhyLot.bf_qty = entityDetail.bf_qty; entityPhyLot.bf_date = entityDetail.bf_date; ServiceProvider.PhyLotService.Update(entityPhyLot); //update into in_log_lot LogLot entityLogLot = ServiceProvider.LogLotService.GetLogLot(entityDetail.material_id, entityStockHead.warehouse_id); entityLogLot.bal_qty = entityDetail.bal_qty; entityLogLot.bf_qty = entityDetail.bf_qty; entityLogLot.bf_date = entityDetail.bf_date; ServiceProvider.LogLotService.Update(entityLogLot); //Insert BFLogical bfLogical = new BFLogical(); bfLogical.period_id = entityStockHead.period_id; bfLogical.warehouse_id = entityStockHead.warehouse_id; bfLogical.material_id = entityDetail.material_id; bfLogical.bf_qty = entityDetail.bf_qty; bfLogical.bal_qty = entityDetail.bal_qty; ServiceProvider.BFLogicalService.Insert(bfLogical); BFPhysical bfPhysical = new BFPhysical(); bfPhysical.period_id = entityStockHead.period_id; bfPhysical.warehouse_id = entityStockHead.warehouse_id; bfPhysical.material_id = entityDetail.material_id; bfPhysical.bf_qty = entityDetail.bf_qty; bfPhysical.bal_qty = entityDetail.bal_qty; bfPhysical.lot_no = entityDetail.lot_no; ServiceProvider.BFPhysicalService.Insert(bfPhysical); }
private void ValidationDetail(StockDetail entity) { ValidationResults results = new ValidationResults(); if (string.IsNullOrEmpty(txtAdjust.Text)) { ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Adjust"), this, string.Empty, string.Empty, null); results.AddResult(result); } else if (Converts.ParseDecimalNullable(txtAdjust.Text) == null) { ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IncorrectFormatOne, "Adjust"), this, string.Empty, string.Empty, null); results.AddResult(result); } else if (entity.bal_qty <= 0) { ValidationResult result = new ValidationResult(string.Format(ErrorMessage.CompareValueMore, "Adjust", "0"), this, string.Empty, string.Empty, null); results.AddResult(result); } else { Material entityMaterial = new Material() { material_id = entity.material_id }; entityMaterial = ServiceProvider.MaterialService.FindByKeys(entityMaterial, false); if (entity.bal_qty > entityMaterial.max_stock) { ValidationResult result = new ValidationResult(string.Format(ErrorMessage.CompareValueLessOrEqual, "Adjust", "Max Stock"), this, string.Empty, string.Empty, null); results.AddResult(result); } } if (results.Count > 0) { throw new ValidationException(results); } }
private void SaveTransactionDetail(StockHead entityStockHead) { foreach (DataRow dr in this.dsStockDetail.Tables[0].Rows) { StockDetail entityDetail = new StockDetail(); entityDetail.material_id = dr["material_id"].ToLong(); entityDetail.bal_qty = dr["Adjust"].ToDecimal(); entityDetail.bf_qty = dr["Count"].ToDecimal(); entityDetail.bf_date = DateTime.Now; entityDetail.lot_no = dr["Lot No."].ToDecimal(); entityDetail.remark = dr["Remark"].ToStringNullable(); entityDetail.stock_head_id = entityStockHead.stock_head_id; ServiceProvider.StockDetailService.Insert(entityDetail); SaveLots(entityDetail, entityStockHead); } }
private StockDetail GetDetailData() { StockDetail entity = new StockDetail(); entity.material_id = ddlMaterial.SelectedValue.ToLong(); entity.lot_no = txtLotNo.Text.ToDecimal(); entity.bf_qty = txtCount.Text.ToDecimal(); entity.bal_qty = txtAdjust.Text.ToDecimal(); entity.remark = txtRemarkDetails.Text; entity.created_by = "SYSTEM"; entity.created_date = DateTime.Now; entity.updated_by = "SYSTEM"; entity.updated_date = DateTime.Now; return entity; }