public IActionResult AddControlAccount(int id) { GL_CONTROL_ACCOUNTS model = new GL_CONTROL_ACCOUNTS(); model.PARENT_CONTROL_ACCOUNT_ID = id; return(PartialView("~/Views/ChartOfAccount/_AddControlAccount.cshtml", model)); }
public IActionResult AddControl(int id, string desc) { var IS = _db.GL_CONTROL_ACCOUNTs.Where(x => x.PARENT_CONTROL_ACCOUNT_ID == null || x.PARENT_CONTROL_ACCOUNT_ID == 0).Max(x => x.CHART_OF_ACCOUNT_CODE); GL_CONTROL_ACCOUNTS obj = new GL_CONTROL_ACCOUNTS(); Random n = new Random(); int num = n.Next(10); var f = _db.GL_CONTROL_ACCOUNTs.Find(id); var p = _db.GL_CONTROL_ACCOUNTs.Find(f.PARENT_CONTROL_ACCOUNT_ID); if (f != null) { var pid = f.PARENT_CONTROL_ACCOUNT_ID; if (pid == null || pid == 0) { obj.PARENT_CONTROL_ACCOUNT_ID = 0; obj.CHART_OF_ACCOUNT_CODE = (Convert.ToInt32(IS) + 1).ToString(); } else { var SubCode = _db.GL_CONTROL_ACCOUNTs.Where(x => x.PARENT_CONTROL_ACCOUNT_ID == p.CHART_OF_ACCOUNT_ID).Max(x => x.CHART_OF_ACCOUNT_CODE); obj.PARENT_CONTROL_ACCOUNT_ID = pid; //obj.CHART_OF_ACCOUNT_CODE = p.CHART_OF_ACCOUNT_CODE + "" + (Convert.ToInt32(SubCode) + 1).ToString(); obj.CHART_OF_ACCOUNT_CODE = (Convert.ToInt32(SubCode) + 1).ToString(); } obj.DESCRIPTION = desc; obj.CREATED_BY = 1; obj.CREATION_DATE = DateTime.Now; obj.Lavel = f.Lavel; _db.GL_CONTROL_ACCOUNTs.Add(obj); _db.SaveChanges(); } return(Redirect("/Home/ChartAccountsList")); }
public IActionResult AddControl(int id) { var model = new GL_CONTROL_ACCOUNTS(); model.CHART_OF_ACCOUNT_ID = id; return(PartialView("~/Views/ChartOfAccount/_AddContorlSubling.cshtml", model)); }
public IActionResult UpdateControlAccount(int id, string desc) { GL_CONTROL_ACCOUNTS data = _db.GL_CONTROL_ACCOUNTs.Find(id); if (data != null) { data.DESCRIPTION = desc; _db.Entry(data).State = EntityState.Modified; _db.SaveChanges(); } return(Redirect("/Home/ChartAccountsList")); }
public IActionResult AddControlAccount(int id, string desc) { var parent = _db.GL_CONTROL_ACCOUNTs.Find(id); var getchild = _db.GL_CONTROL_ACCOUNTs.Where(x => x.PARENT_CONTROL_ACCOUNT_ID == id).Count(); GL_CONTROL_ACCOUNTS obj = new GL_CONTROL_ACCOUNTS(); // Find Lavel var lavel = CheckLavel(id); if (lavel >= 3) { AddChartAccount(id, desc); // return new JsonResult("Add Succesfully"); return(Redirect("/Home/ChartAccountsList")); } if (getchild == 0) { obj.CHART_OF_ACCOUNT_CODE = parent.CHART_OF_ACCOUNT_CODE + "" + 1.ToString("D2"); } else { var Child_Code = _db.GL_CONTROL_ACCOUNTs.Where(x => x.PARENT_CONTROL_ACCOUNT_ID == id).Max(x => x.CHART_OF_ACCOUNT_CODE); // obj.CHART_OF_ACCOUNT_CODE = parent.CHART_OF_ACCOUNT_CODE + "" + (Convert.ToInt32(Child_Code) + 1).ToString("D2"); obj.CHART_OF_ACCOUNT_CODE = (Convert.ToInt32(Child_Code) + 1).ToString("D2"); } obj.PARENT_CONTROL_ACCOUNT_ID = id; obj.DESCRIPTION = desc; Random n = new Random(); int num = n.Next(100); obj.CREATED_BY = 1; obj.CREATION_DATE = DateTime.Now; obj.Lavel = lavel; _db.GL_CONTROL_ACCOUNTs.Add(obj); _db.SaveChanges(); //return StatusCode(200); return(Redirect("/Home/ChartAccountsList")); }
// Control Account Update Start from here.... public IActionResult UpdateControlAccount(int id) { GL_CONTROL_ACCOUNTS data = _db.GL_CONTROL_ACCOUNTs.Find(id); return(PartialView("~/Views/ChartOfAccount/_UpdateContorlAccount.cshtml", data)); }