public ActionResult SaveUserRight(MenuItemRUVM Users) { List <SessionListnew> list = Session["SesDet"] as List <SessionListnew>; if (list == null) { return(Redirect("Login/InLogin")); } else { Users.CmpyCode = list[0].CmpyCode.ToString(); Users.UserName = list[0].user_name; return(Json(_MenuRights.SaveUsers(Users), JsonRequestBehavior.AllowGet)); } }
public MenuItemRUVM GetUsersRightsEdit(string CmpyCode, string user_name) { ds = _EzBusinessHelper.ExecuteDataSet("Select * from Users where CmpyCode='" + CmpyCode + "' and user_name='" + user_name + "' "); dt = ds.Tables[0]; MenuItemRUVM UMenu = new MenuItemRUVM(); foreach (DataRow dr in dt.Rows) { UMenu.EmpCode = dr["EmpCode"].ToString(); UMenu.user_name = dr["user_name"].ToString(); UMenu.passwords = dr["passwords"].ToString(); UMenu.Utype = dr["Utype"].ToString(); } return(UMenu); }
public MenuItemRUVM SaveUsers(MenuItemRUVM Users) { return(_MenuPayrollRepo.SaveUsers(Users)); }
public MenuItemRUVM SaveUsers(MenuItemRUVM Users) { int n; if (!Users.EditFlag) { users pt = new users(); List <UserRights> ObjList = new List <UserRights>(); ObjList.AddRange(Users.UserRightsnews.Select(m => new UserRights { FormId = m.FormId, FormName = m.FormName, PostIt = m.PostIt, SelAll = m.SelAll, NewIt = m.NewIt, DeleteIt = m.DeleteIt, EditIt = m.EditIt, ViewIt = m.ViewIt }).ToList()); Users.SaveFlag = _EzBusinessHelper.ExecuteNonQuery1("insert into users(CmpyCode,user_name,passwords,EmpCode,Utype) values('" + Users.CmpyCode + "','" + Users.user_name + "','" + Users.passwords + "','" + Users.EmpCode + "','" + Users.Utype + "')"); n = ObjList.Count; while (n > 0 && Users.SaveFlag == true) { _EzBusinessHelper.ExecuteNonQuery("insert into UserRights(CmpyCode,user_name,FormId,FormName,PostIt,SelAll,NewIt,DeleteIt,EditIt,ViewIt) values('" + Users.CmpyCode + "','" + Users.user_name + "','" + ObjList[n - 1].FormId + "','" + ObjList[n - 1].FormName + "','" + ObjList[n - 1].PostIt + "','" + ObjList[n - 1].SelAll + "','" + ObjList[n - 1].NewIt + "','" + ObjList[n - 1].DeleteIt + "','" + ObjList[n - 1].EditIt + "','" + ObjList[n - 1].ViewIt + "')"); n = n - 1; } _EzBusinessHelper.ActivityLog(Users.CmpyCode, Users.UserName, "Add User Rights", Environment.MachineName, Users.user_name); Users.SaveFlag = true; Users.ErrorMessage = string.Empty; } else { int k = 0; k = _EzBusinessHelper.ExecuteScalar("Select count(*) from users where CmpyCode='" + Users.CmpyCode + "' and user_name='" + Users.user_name + "'"); n = _EzBusinessHelper.ExecuteScalar("Select count(*) from UserRights where CmpyCode='" + Users.CmpyCode + "' and user_name='" + Users.user_name + "' "); if (n != 0 && k != 0) { _EzBusinessHelper.ExecuteNonQuery("delete from users where CmpyCode='" + Users.CmpyCode + "' and user_name='" + Users.user_name + "'"); _EzBusinessHelper.ExecuteNonQuery("delete from UserRights where CmpyCode='" + Users.CmpyCode + "' and user_name='" + Users.user_name + "'"); users pt = new users(); List <UserRights> ObjList = new List <UserRights>(); ObjList.AddRange(Users.UserRightsnews.Select(m => new UserRights { FormId = m.FormId, FormName = m.FormName, PostIt = m.PostIt, SelAll = m.SelAll, NewIt = m.NewIt, DeleteIt = m.DeleteIt, EditIt = m.EditIt, ViewIt = m.ViewIt }).ToList()); Users.SaveFlag = _EzBusinessHelper.ExecuteNonQuery1("insert into users(CmpyCode,user_name,passwords,EmpCode,Utype) values('" + Users.CmpyCode + "','" + Users.user_name + "','" + Users.passwords + "','" + Users.EmpCode + "','" + Users.Utype + "')"); n = ObjList.Count; while (n > 0 && Users.SaveFlag == true) { _EzBusinessHelper.ExecuteNonQuery("insert into UserRights(CmpyCode,user_name,FormId,FormName,PostIt,SelAll,NewIt,DeleteIt,EditIt,ViewIt) values('" + Users.CmpyCode + "','" + Users.user_name + "','" + ObjList[n - 1].FormId + "','" + ObjList[n - 1].FormName + "','" + ObjList[n - 1].PostIt + "','" + ObjList[n - 1].SelAll + "','" + ObjList[n - 1].NewIt + "','" + ObjList[n - 1].DeleteIt + "','" + ObjList[n - 1].EditIt + "','" + ObjList[n - 1].ViewIt + "')"); n = n - 1; } _EzBusinessHelper.ActivityLog(Users.CmpyCode, Users.user_name, "Update User Rights", Users.UserName, Environment.MachineName); Users.SaveFlag = true; Users.ErrorMessage = string.Empty; } else { Users.SaveFlag = true; Users.ErrorMessage = "Error occur"; } } return(Users); }