public async Task <ActionResult> Edit([Bind(Include = "TranID,Updated,Updator,DemurrageFreeDays,DemurrageOverDays,DemurrageCost,DemurrageCostCurrencyID,CollectDate,RemainingAmountNotes,PaymentFinished,AdditionalField1Label,AdditionalField2Label,StatusID")] TranDetail trandetail) { if (ModelState.IsValid) { db.Entry(trandetail).State = EntityState.Modified; await db.SaveChangesAsync(); Calculations.CalcTran(trandetail.TranID, 0); return(RedirectToAction("Details", "Tran", new { id = trandetail.TranID })); } ViewBag.DemurrageCostCurrencyID = new SelectList(db.Currency, "CurrencyID", "CurrencyCode", trandetail.DemurrageCostCurrencyID); ViewBag.TranID = new SelectList(db.Tran, "TranID", "Updator", trandetail.TranID); return(RedirectToAction("Details", "Tran", new { id = trandetail.TranID })); }
// GET: /TranDetail/Details/5 public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TranDetail trandetail = await db.TranDetail.FindAsync(id); if (trandetail == null) { return(HttpNotFound()); } return(View(trandetail)); }
// GET: /TranDetail/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TranDetail trandetail = await db.TranDetail.FindAsync(id); if (trandetail == null) { return(HttpNotFound()); } ViewBag.DemurrageCostCurrencyID = new SelectList(db.Currency, "CurrencyID", "CurrencyCode", trandetail.DemurrageCostCurrencyID); ViewBag.TranID = new SelectList(db.Tran, "TranID", "Updator", trandetail.TranID); return(View(trandetail)); }
private void baseAddEditMasterDetail_saveHandler() { TranDetail entity = this.GetDetailData(); try { this.ValidationDetail(entity); string lotNo = string.Format(Format.DecimalNumberFormat, txtLotNo.Text.ToDouble()); string quantity = string.Format(Format.DecimalNumberFormat, txtQuantity.Text.ToDouble()); if (baseGridDetail.FormMode == ObjectState.Edit) { DataRow dr = this.GetDataRowDetail(baseGridDetail.DataKeyValue[1].ToLong(), baseGridDetail.DataKeyValue[2].ToLong()).First(); dr["Quantity"] = quantity; dr["Remark"] = txtRemarkDetails.Text; dr["Lot No."] = lotNo; } else if (baseGridDetail.FormMode == ObjectState.Add || baseGridDetail.FormMode == ObjectState.Nothing) { DataRow dr = this.dsTranDetail.Tables[0].NewRow(); if (!string.IsNullOrEmpty(base.FormKeyCode)) { dr["tran_head_id"] = base.FormKeyCode.ToLong(); } dr["material_code"] = txtMaterialCode.Text; dr["material_id"] = baseAddEditMasterDetail.FormKeyCode.ToLong(); dr["warehouse_id_dest"] = ddlWarehouseDetails.SelectedValue.ToLong(); dr["Quantity"] = quantity; dr["Remark"] = txtRemarkDetails.Text; dr["Material"] = txtMaterialName.Text; dr["Warehouse"] = ddlWarehouseDetails.Text.Substring(ddlWarehouseDetails.Text.LastIndexOf(":") + 1); dr["Lot No."] = lotNo; dr["UOM"] = lblUOM.Text; this.dsTranDetail.Tables[0].Rows.Add(dr); } this.ClearDataDetail(); txtMaterialCode.Focus(); baseGridDetail.FormMode = ObjectState.Add; baseGridDetail.DataKeyValue = null; EnableModeDetailEdit(); } catch (ValidationException ex) { throw ex; } }
private TranDetail GetDetailData() { TranDetail entity = new TranDetail(); entity.material_id = Converts.ParseLong(txtMaterialCode.Text.ToString()); entity.lot_no = Converts.ParseDecimalNullable(txtLotNo.Text); entity.quantity = Converts.ParseDecimalNullable(txtQuantity.Text); entity.remark = txtRemarkDetails.Text; if (base.FormMode == ObjectState.Add) { entity.created_by = "SYSTEM"; entity.created_date = DateTime.Now; } entity.updated_by = "SYSTEM"; entity.updated_date = DateTime.Now; return(entity); }
private void SaveTransactionDetail(TranHead entityTranHead) { foreach (DataRow dr in this.dsTranDetail.Tables[0].Rows) { TranDetail entityDetail = new TranDetail(); if (dr.RowState == DataRowState.Added) { entityDetail.material_id = dr["material_id"].ToLong(); entityDetail.warehouse_id_dest = dr["warehouse_id_dest"].ToLong(); entityDetail.quantity = dr["Quantity"].ToDecimal(); entityDetail.remark = dr["Remark"].ToStringNullable(); entityDetail.lot_no = dr["Lot No."].ToDecimal(); entityDetail.tran_head_id = entityTranHead.tran_head_id; ServiceProvider.TranDetailService.Insert(entityDetail); SaveLots(entityDetail, entityTranHead); } } }
private TranDetail GetDetailData() { TranDetail entity = new TranDetail(); entity.material_id = ServiceProvider.MaterialService.GetIDByCode(txtMaterialCode.Text).ToLong(); entity.warehouse_id_dest = Converts.ParseLong(ddlWarehouseDetails.SelectedValue.ToString()); entity.lot_no = Converts.ParseDecimalNullable(txtLotNo.Text); entity.quantity = Converts.ParseDecimalNullable(txtQuantity.Text); entity.remark = txtRemarkDetails.Text; if (base.FormMode == ObjectState.Add) { entity.created_by = "SYSTEM"; entity.created_date = DateTime.Now; } entity.updated_by = "SYSTEM"; entity.updated_date = DateTime.Now; return(entity); }
private void SaveLots(TranDetail entityDetail, TranHead entityTranHead) { //get in_material Material entityMaterial = new Material() { material_id = entityDetail.material_id }; entityMaterial = ServiceProvider.MaterialService.FindByKeys(entityMaterial, false); //update into in_phy_lot PhyLot entityPhyLot = ServiceProvider.PhyLotService.GetPhyLot(entityDetail.material_id, entityDetail.warehouse_id_dest, entityDetail.lot_no.Value); entityPhyLot.bal_qty = (entityPhyLot.bal_qty - entityDetail.quantity.Value); ServiceProvider.PhyLotService.Update(entityPhyLot); //update into in_log_lot LogLot entityLogLot = ServiceProvider.LogLotService.GetLogLot(entityDetail.material_id, entityDetail.warehouse_id_dest); entityLogLot.bal_qty = (entityLogLot.bal_qty - entityDetail.quantity.Value); ServiceProvider.LogLotService.Update(entityLogLot); }
private void ValidationDetail(TranDetail entity) { ValidationResults results = new ValidationResults(); if (baseGridDetail.FormMode == ObjectState.Add) { if (entity.material_id == 0) { ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Material"), this, string.Empty, string.Empty, null); results.AddResult(result); } else { if (entity.warehouse_id_dest != 0) { DataRow[] drs = this.GetDataRowDetail(entity.material_id, entity.warehouse_id_dest); if (drs.Count() >= 1) { ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsDuplicate, "Material"), this, string.Empty, string.Empty, null); results.AddResult(result); } } } if (entity.warehouse_id_dest == 0) { ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Warehouse"), this, string.Empty, string.Empty, null); results.AddResult(result); } } if (string.IsNullOrEmpty(txtLotNo.Text)) { ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Lot No."), this, string.Empty, string.Empty, null); results.AddResult(result); } else if (Converts.ParseDoubleNullable(txtLotNo.Text) == null) { ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IncorrectFormatOne, "Lot No."), this, string.Empty, string.Empty, null); results.AddResult(result); } else if (entity.lot_no == 0) { ValidationResult result = new ValidationResult(string.Format(ErrorMessage.CompareValueMore, "Lot No.", "0"), this, string.Empty, string.Empty, null); results.AddResult(result); } if (string.IsNullOrEmpty(txtQuantity.Text)) { ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Quantity"), this, string.Empty, string.Empty, null); results.AddResult(result); } else if (Converts.ParseDoubleNullable(txtQuantity.Text) == null) { ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IncorrectFormatOne, "Quantity"), this, string.Empty, string.Empty, null); results.AddResult(result); } else if (entity.quantity == 0) { ValidationResult result = new ValidationResult(string.Format(ErrorMessage.CompareValueMore, "Quantity", "0"), this, string.Empty, string.Empty, null); results.AddResult(result); } else { if (entity.warehouse_id_dest != 0 && entity.material_id != 0) { if (!ServiceProvider.PhyLotService.CheckLimitMaterial(entity.material_id, entity.warehouse_id_dest, entity.quantity.Value)) { ValidationResult result = new ValidationResult(string.Format(ErrorMessage.CompareValueLessOrEqual, "Quantity", "Max Stock"), this, string.Empty, string.Empty, null); results.AddResult(result); } } } if (results.Count > 0) { throw new ValidationException(results); } }