public JsonResult Login(User_Property objuser) { try { objUserBll = new User_BLL(objuser); var data = objUserBll.SelectByIDPassword(); if (data.Rows.Count > 0) { for (int i = 0; i < data.Rows.Count; i++) { Session["UID"] = data.Rows[0]["idx"].ToString(); Session["LOGINID"] = data.Rows[0]["loginId"].ToString(); Session["COMPANYID"] = data.Rows[0]["companyIdx"].ToString(); Session["BRANCHID"] = data.Rows[0]["branchIdx"].ToString(); Session["LOGGEDIN"] = true; Session["ISADMIN"] = data.Rows[0]["Is_Admin"].ToString(); } return(Json(new { data = "", msg = "Login Successfull", success = true, statuscode = 200, count = data.Rows.Count }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { data = "", msg = "Login Failed", success = true, statuscode = 200, count = 0 }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { return(Json(new { data = ex.Message, success = false, statuscode = 400, count = 0 }, JsonRequestBehavior.AllowGet)); } }
public JsonResult AddUser(User_Property objUserProp) { if (ModelState.IsValid) { if (objUserProp.ID <= 0 || objUserProp.ID == null) { objUserProp.Status = "Active"; objUserProp.Active = 1; objUserProp.Operated_By = SessionManager.CurrentUser.ID; objUserBll = new User_BLL(objUserProp); DataTable d = objUserBll.CheckUserExistance(); if (d.Rows.Count > 0) { return(Json(new { success = false, statuscode = 501, msg = "Failed" }, JsonRequestBehavior.AllowGet)); } var flag = objUserBll.Insert(); if (flag) { return(Json(new { success = true, statuscode = 200, msg = "Successfully inserted" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false, statuscode = 500, msg = "Failed" }, JsonRequestBehavior.AllowGet)); } } else { //objClientBLL = new Client_BLL(objClientProp); //var flag = objClientBLL.Update(); //if (flag) //{ // return Json(new { success = true, statuscode = 200, msg = "Successfully inserted" }, JsonRequestBehavior.AllowGet); //} //else //{ // return Json(new { success = false, statuscode = 500, msg = "Failed" }, JsonRequestBehavior.AllowGet); //} return(Json(new { success = false, statuscode = 500, msg = "Failed" }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { success = false, statuscode = 500, msg = "Please Enter According To Instructions" }, JsonRequestBehavior.AllowGet)); } }
public JsonResult AddUpdate(User_Property objuser) { if (Session["LOGGEDIN"] != null) { try { if (objuser.idx > 0) { objuser.lastModifiedByUserIdx = 1; objuser.lastModificationDate = DateTime.Now.ToString("dd/MM/yyyy"); objUser = new User_BLL(objuser); bool flag = objUser.Update(); return(Json(new { data = "Updated", success = flag, statuscode = 200 }, JsonRequestBehavior.AllowGet)); } else { objuser.companyIdx = 1; objuser.createdByUserIdx = 1; objUser = new User_BLL(objuser); //if (objUser.isMainBranch == 1) //{ // var check = objUser.MainBranch(); // if (check.Rows.Count > 0) // { // return Json(new { data = "Main Branch Already Exist", success = false, statuscode = 500 }, JsonRequestBehavior.AllowGet); // } //} bool flag = objUser.Insert(); return(Json(new { data = "Inserted", success = flag, statuscode = 200 }, 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 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")); } }
public JsonResult Login(User_Property objuser) { try { objUserBll = new User_BLL(objuser); var data = objUserBll.SelectByIDPassword(); if (data.Rows.Count > 0) { for (int i = 0; i < data.Rows.Count; i++) { Session["UID"] = data.Rows[0]["idx"].ToString(); Session["LOGINID"] = data.Rows[0]["loginId"].ToString(); Session["COMPANYID"] = data.Rows[0]["companyIdx"].ToString(); Session["BRANCHID"] = data.Rows[0]["branchIdx"].ToString(); Session["LOGGEDIN"] = true; Session["ISADMIN"] = data.Rows[0]["Is_Admin"].ToString(); } int userid = Convert.ToInt32(Session["UID"].ToString()); objuserproperty = new User_Property(); objuserproperty.idx = userid; objUserBll = new User_BLL(objuserproperty); List <LP_Pages_Property> pagelist = new List <LP_Pages_Property>(); pagelist = Helper.ConvertDataTable <LP_Pages_Property>(objUserBll.GetUserPagsAccess()); Session["PageList"] = pagelist; return(Json(new { data = "", msg = "Login Successfull", success = true, statuscode = 200, count = data.Rows.Count }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { data = "", msg = "Login Failed", success = true, statuscode = 200, count = 0 }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { return(Json(new { data = ex.Message, success = false, statuscode = 400, count = 0 }, JsonRequestBehavior.AllowGet)); } }
public JsonResult GetUserAccesspages(int id) { try { int userid = id; objuserproperty = new User_Property(); objuserproperty.idx = id; objUserBll = new User_BLL(objuserproperty); var useraccesspages = JsonConvert.SerializeObject(objUserBll.GetUserPagsAccess()); return(Json(new { success = true, statuscode = 200, url = "/Pages/Index", data = useraccesspages }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false }, JsonRequestBehavior.AllowGet)); } }
public JsonResult GetAllUsers() { if (Session["LOGGEDIN"] != null) { try { objUserProperty = new User_Property(); objUserProperty.branchIdx = 1;//user logged in session branchIdx objUser = new User_BLL(objUserProperty); var Data = JsonConvert.SerializeObject(objUser.ViewAll()); return(Json(new { data = Data, success = true, statuscode = 200, count = Data.Length }, 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 PageUser() { string actionName = this.ControllerContext.RouteData.Values["action"].ToString(); string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); string pagename = @"/" + controllerName + @"/" + actionName; var page = (List <LP_Pages_Property>)Session["PageList"]; if (Session["LoggedIn"] != null && Helper.CheckPageAccess(pagename, page) && Session["ISADMIN"] != null && Convert.ToBoolean(Session["ISADMIN"].ToString()) == true) // if (Session["LOGGEDIN"] != null) { LP_PageUser_Property objpage = new LP_PageUser_Property(); objUserBll = new User_BLL(); objpage.PageList = Helper.ConvertDataTable <LP_Pages_Property>(objUserBll.GetAllPages()); User_Property objUserProperty = new User_Property(); objUserProperty.branchIdx = 1;//user logged in session branchIdx User_BLL objUser = new User_BLL(objUserProperty); var Data = JsonConvert.SerializeObject(objUser.ViewAll()); objpage.UserList = Helper.ConvertDataTable <User_Property>(objUser.ViewAll()); ViewBag.Pagelist = objpage.PageList; return(View(objpage)); } else { if (Session["LoggedIn"] == null) { return(RedirectToAction("Login", "Account")); } else { return(RedirectToAction("NotAuthorized", "Account")); } } }
public User_BLL(User_Property userProperty) { objUserProperty = userProperty; }
//private ErrorTracer objErrorTrace; public User_DAL(User_Property objUser_Property) { objUserProperty = objUser_Property; }
public User_BLL(User_Property obCompany_Property) { objUserProperty = obCompany_Property; }
public JsonResult Login(User_Property objUserPropertyNew) { objUserProperty = new User_Property(); objUserProperty.UserName = objUserPropertyNew.UserName.Trim(); objUserProperty.Password = objUserPropertyNew.Password.Trim(); objUserProperty.PageSize = 9999999; objUserProperty.PageNum = 1; objUserBLL = new User_BLL(objUserProperty); DataTable userDT = objUserBLL.ViewAll(); if (userDT.Rows.Count == 0) { //lblError.Visible = true; //lblError.Text = "Invalid Username Or Password"; return(Json(new { success = true, Login = false, statuscode = 404, msg = "Invaid Credentials" }, JsonRequestBehavior.AllowGet)); } else { try { SessionManager.CurrentUser.ID = Convert.ToInt32(userDT.Rows[0]["ID"].ToString()); //SessionManager.CurrentUser.LocationID = Convert.ToInt32(userDT.Rows[0]["Location_Setup_ID"].ToString()); //SessionManager.CurrentUser.Code = Convert.ToInt32(userDT.Rows[0]["code"].ToString()); //SessionManager.CurrentUser.DistributorID = Convert.ToInt32(userDT.Rows[0]["DistributorID"].ToString()); //SessionManager.CurrentUser.CompanyID = Convert.ToInt32(userDT.Rows[0]["CompanyID"].ToString()); SessionManager.CurrentUser.UserName = userDT.Rows[0]["UserName"].ToString(); SessionManager.CurrentUser.FirstName = userDT.Rows[0]["FirstName"].ToString(); SessionManager.CurrentUser.LastName = userDT.Rows[0]["LastName"].ToString(); SessionManager.CurrentUser.Email = userDT.Rows[0]["Email"].ToString(); SessionManager.CurrentUser.Password = userDT.Rows[0]["Password"].ToString(); //SessionManager.CurrentUser.Active = Convert.ToInt32(userDT.Rows[0]["IsActive"].ToString()); SessionManager.CurrentUser.InsertBy = Convert.ToInt32(userDT.Rows[0]["CreatedBy"].ToString()); SessionManager.CurrentUser.InsertionDate = Convert.ToDateTime(userDT.Rows[0]["DateCreated"]); SessionManager.CurrentUser.EmployeeID = Convert.ToInt32(userDT.Rows[0]["EmployeeID"]); Session["RoleID"] = Convert.ToInt32(userDT.Rows[0]["RoleId"].ToString()); Session["Emp_ID"] = Convert.ToInt32(userDT.Rows[0]["EmployeeID"]); //objUserRegionProperty = new User_Region_Property(); //objUserRegionProperty.UserId = Convert.ToInt32(SessionManager.CurrentUser.ID); //objUserRegionBLL = new User_Region_BLL(objUserRegionProperty); //DataTable dtRegionalUserLocations = objUserRegionBLL.GetRegionalUserLocationByUserIdBLL(); //if (dtRegionalUserLocations.Rows.Count > 0) //{ // SessionManager.CurrentUser.IsRegionalUser = true; // SessionManager.CurrentUser.RegionalLocationsDT = dtRegionalUserLocations; // locations = new List<string>(); // for (int i = 0; i < dtRegionalUserLocations.Rows.Count; i++) // { // locations.Add(Convert.ToString(dtRegionalUserLocations.Rows[i]["Location_Code"] + " - " + dtRegionalUserLocations.Rows[i]["Location_Name"])); // } // SessionManager.CurrentUser.RegionalLocations = locations; //} //else //{ // SessionManager.CurrentUser.IsRegionalUser = false; // SessionManager.CurrentUser.RegionalLocations = null; //} //Response.Redirect("/myHomePage.aspx"); objloginrecordproperty = new Login_Record_Property(); objloginrecordproperty.Employee_ID = Convert.ToInt32(userDT.Rows[0]["EmployeeID"]); objloginrecordproperty.Login_Time = DateTime.Now; objloginrecordproperty.Location_Name = ""; objloginrecordproperty.latitude = objUserPropertyNew.Latitude; objloginrecordproperty.longitude = objUserPropertyNew.Longitude; objloginrecordbll = new Login_Records_BLL(objloginrecordproperty); var flag = objloginrecordbll.Insert(); FormsAuthentication.SetAuthCookie(objUserPropertyNew.UserName, objUserPropertyNew.RemeberMe); //return RedirectToAction("Profile"); return(Json(new { success = true, Login = true, statuscode = 200, msg = "Login Successfull" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { //Trace.Write("Testtt"); //Trace.Write(ex.Message); //lblError.Visible = true; //lblError.Text = "Invalid Username Or Password"; return(Json(new { success = false, Login = false, statuscode = 500, msg = "err" + ex }, JsonRequestBehavior.AllowGet)); } } }