public ActionResult Edit(ACC_ALL2 CLIENT) { if (ModelState.IsValid) { var GetCLIENT = db.ACC_ALL2.Where(stu => stu.CODE == CLIENT.CODE).FirstOrDefault(); if (GetCLIENT != null) { if (GetCLIENT.Account_Level != CLIENT.Account_Level) { GetCLIENT.NAME = CLIENT.NAME; GetCLIENT.LIQ_CR = CLIENT.LIQ_CR; GetCLIENT.liq_bal = CLIENT.liq_bal; GetCLIENT.LIQ_DR = CLIENT.LIQ_DR; GetCLIENT.SORTBY = CLIENT.SORTBY; GetCLIENT.FLAG_TR = CLIENT.FLAG_TR; GetCLIENT.FL = CLIENT.FL; GetCLIENT.CHK_NAV = CLIENT.CHK_NAV; GetCLIENT.s_type_____ = CLIENT.s_type_____; GetCLIENT.Account_Level = GetCLIENT.Account_Level; db.SaveChanges(); return(RedirectToAction("Index")); /*db.Entry(student).State = EntityState.Modified; * db.SaveChanges();*/ } } } else { return(View(CLIENT)); } return(View(CLIENT)); }
public ActionResult Edit(string code) { if (code.Length == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ACC_ALL2 CLIENT = db.ACC_ALL2.Find(code); if (CLIENT == null) { return(HttpNotFound()); } return(View(CLIENT)); }
public ActionResult Create_Check_Code(ACC_ALL2 Acc) { if (((Acc.CODE).ToString()).Length / 3.00 == Convert.ToInt64(Acc.Account_Level)) { var allacc = db.ACC_ALL2.ToList(); //level 1 if (Convert.ToInt32(Acc.Account_Level) == 1) { foreach (var item in allacc) { if (item.CODE == Acc.CODE) { return(Content("already exists")); } } db.ACC_ALL2.Add(Acc); db.SaveChanges(); return(Json(new { result = 1 })); } //end level one ////level 2 else if (Convert.ToInt32(Acc.Account_Level) == 2) { foreach (var item in allacc) { if ((item.CODE).ToString() == takeNDigits((Acc.CODE).ToString(), 3)) //function to get first 3 digit { foreach (var AllCode in allacc) { if (AllCode.CODE == Acc.CODE) { return(Json(new { result = 0 })); } } db.ACC_ALL2.Add(Acc); db.SaveChanges(); return(Json(new { result = 1 })); } } } //end level two ////level 3 else if (Convert.ToInt32(Acc.Account_Level) == 3) { foreach (var item in allacc) { if ((item.CODE).ToString() == takeNDigits((Acc.CODE).ToString(), 6)) //function to get first 6 digit { foreach (var AllCode in allacc) { if (AllCode.CODE == Acc.CODE) { return(Json(new { result = 0 })); //return Content("already exists"); } } db.ACC_ALL2.Add(Acc); db.SaveChanges(); return(Json(new { result = 1 })); //return Content("insertion done"); } } } //end level three //level 4 else if (Convert.ToInt32(Acc.Account_Level) == 4) { foreach (var item in allacc) { if ((item.CODE).ToString() == takeNDigits((Acc.CODE).ToString(), 9)) //function to get first 9 digit { foreach (var AllCode in allacc) { if (AllCode.CODE == Acc.CODE) { return(Json(new { result = 0 })); } } db.ACC_ALL2.Add(Acc); db.SaveChanges(); return(Json(new { result = 1 })); } } } //end level four } else { return(Json(new { error = 1 })); } return(View()); }