public JsonResult DeleteUser(int?id) { if (Session["LOGGEDIN"] != null) { try { if (id > 0) { User_Property branchProperty = new User_Property(); branchProperty.idx = int.Parse(id.ToString()); objUser = new User_BLL(id); User_BLL branhcBll = new User_BLL(branchProperty); var flag1 = branhcBll.GetById(); //if (flag1.Rows.Count > 0) //{ if (true) { bool flag = objUser.Delete(id); return(Json(new { data = "Deleted", success = flag, statuscode = 200 }, JsonRequestBehavior.AllowGet)); } //else //{ // return Json(new { data = "Mian Branch Cannot be Delete ", success = false, statuscode = 400, count = 0 }, JsonRequestBehavior.AllowGet); //} //} // return Json(new { data = "Process Completed ", success = true, statuscode = 200 }, JsonRequestBehavior.AllowGet); } else { return(Json(new { data = "Error Occur", success = false, statuscode = 400, count = 0 }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { return(Json(new { data = ex.Message, success = false, statuscode = 400, count = 0 }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { data = "Session Expired", success = false, statuscode = 400, count = 0 }, JsonRequestBehavior.AllowGet)); } }
public ActionResult AddNewUser(int?id) { if (Session["LOGGEDIN"] != null) { objUserProperty = new User_Property(); objUserProperty.idx = Convert.ToInt32(id); objUserProperty.branchIdx = 1;//It will have the value of session branchIdx objUser = new User_BLL(objUserProperty); DataTable dtt = objUser.SelectBranch(); List <Branch_Property> BranchList = new List <Branch_Property>(); foreach (DataRow dr in dtt.Rows) { Branch_Property objbranch = new Branch_Property(); objbranch.branchName = dr["branchname"].ToString(); objbranch.idx = Convert.ToInt32(dr["idx"].ToString()); BranchList.Add(objbranch); } ViewBag.branchList = BranchList; if (id != null && id != 0) { var dt = objUser.GetById(); objUserProperty.companyIdx = 1; objUserProperty.idx = int.Parse(dt.Rows[0]["idx"].ToString()); objUserProperty.companyIdx = int.Parse(dt.Rows[0]["companyIdx"].ToString()); objUserProperty.branchIdx = int.Parse(dt.Rows[0]["branchIdx"].ToString()); objUserProperty.firstName = dt.Rows[0]["firstName"].ToString(); objUserProperty.lastName = dt.Rows[0]["lastName"].ToString(); objUserProperty.CNIC = (dt.Rows[0]["CNIC"].ToString()); objUserProperty.cellNumber = (dt.Rows[0]["cellNumber"].ToString()); objUserProperty.loginId = (dt.Rows[0]["loginId"].ToString()); objUserProperty.password = dt.Rows[0]["password"].ToString(); } return(PartialView("_AddNewUser", objUserProperty)); } else { return(RedirectToAction("Login", "Account")); } }