public ActionResult EditForm(TR01CModel item) { if (item.TR01C_ID == 0) { item.DtARR_DT = DateTime.UtcNow.AddHours(07); var entity = new PURSysEntities(); var TR01B = entity.TR01B.First(x => x.TR01B_ID == item.TR01B_ID); var tr01cList = entity.TR01C.Where(x => x.TR01B_ID == item.TR01B_ID).ToList();//.Sum(x => x.ARR_QT); var total = new decimal(); if (tr01cList.Count > 0) { total = tr01cList.Sum(x => x.ARR_QT); } item.ARR_QT = TR01B.PUR_QT - total; item.ARR_QT = decimal.Parse(item.ARR_QT.ToString("G29")); var TR01A = entity.TR01A.FirstOrDefault(x => x.TR01A_ID == TR01B.TR01A_ID); if (TR01A != null) { item.INV_MY = TR01B.PUR_PR * item.ARR_QT; if (TR01A.TAX_RT.HasValue) { item.INV_MY = item.INV_MY * Convert.ToDecimal(TR01A.TAX_RT.Value); } item.INV_MY = decimal.Parse(item.INV_MY.Value.ToString("G29")); item.CUR_RT = entity.BA03A.First(x => x.BA03A_ID == TR01A.BA03A_ID).CUR_RT; item.CUR_RT = decimal.Parse(item.CUR_RT.ToString("G29")); } ModelState.Clear(); } return(PartialView("_EditForm", item)); }
public ActionResult TR01CUpdate(int TR01B_ID, TR01CModel master) { //Validation List <string> errList = TR01Business.Validation(master, ModelState); //BeforeSave + Save if (errList.Count == 0) { //BeforeSave var TR01A = TR01Business.BeforSave(master); TR01A.TR01B_ID = TR01B_ID; System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); TR01A.ARR_DT = (master.DtARR_DT != null ? master.DtARR_DT.Value.ToString("yyyyMMdd") : ""); //Save if (errList.Count == 0) { var result = _Service.Update(TR01A); master = TR01Business.FromEntity(result.Data); if (!string.IsNullOrWhiteSpace(result.Message)) { errList.Add(result.Message); } } } if (errList.Count > 0) { ViewData["ErrMsg"] = string.Join("<br />", errList); master.ModelState = ModelState; ViewData["ErrorData"] = master; } else { CheckStatus(TR01B_ID); ViewData["IsEdit"] = true; ViewData["Success"] = true; } return(PartialView("_GridTR01C", TR01Business.FromEntity(_Service.GetC(x => x.TR01B_ID == TR01B_ID).ToList()))); }