protected void btnUpdate_Click(object sender, EventArgs e) { string loginID = "1"; try { if (Session["Login"] == null) { Session["PreviousPage"] = HttpContext.Current.Request.Url.AbsoluteUri; Response.Redirect("../LoginPage.aspx"); } loginID = ((Login)Session["Login"]).LoginID.ToString(); } catch (Exception ex) { } PageRole pageRole = new PageRole(); pageRole = PageRoleManager.GetPageRoleByID(Int32.Parse(Request.QueryString["pageRoleID"])); PageRole tempPageRole = new PageRole(); tempPageRole.PageRoleID = pageRole.PageRoleID; tempPageRole.PageID = Int32.Parse(ddlPage.SelectedValue); tempPageRole.RoleID = Int32.Parse(ddlRole.SelectedValue); tempPageRole.AddedDate = DateTime.Now; tempPageRole.AddedBy = loginID; tempPageRole.ModifyDate = DateTime.Now; tempPageRole.ModifyBy = loginID; tempPageRole.RowStatusID = Int32.Parse(ddlRowStatus.SelectedValue); bool result = PageRoleManager.UpdatePageRole(tempPageRole); Response.Redirect("AdminPageRoleDisplay.aspx"); }
public static PageRole GetPageRoleByID(int id) { PageRole pageRole = new PageRole(); SqlPageRoleProvider sqlPageRoleProvider = new SqlPageRoleProvider(); pageRole = sqlPageRoleProvider.GetPageRoleByID(id); return pageRole; }
protected void btnAdd_Click(object sender, EventArgs e) { string loginID = "1"; try { if (Session["Login"] == null) { Session["PreviousPage"] = HttpContext.Current.Request.Url.AbsoluteUri; Response.Redirect("../LoginPage.aspx"); } loginID = ((Login)Session["Login"]).LoginID.ToString(); } catch (Exception ex) { } PageRole pageRole = new PageRole(); pageRole.PageID = Int32.Parse(ddlPage.SelectedValue); pageRole.RoleID = Int32.Parse(ddlRole.SelectedValue); pageRole.AddedDate = DateTime.Now; pageRole.AddedBy = loginID; pageRole.ModifyDate = DateTime.Now; pageRole.ModifyBy = loginID; pageRole.RowStatusID = Int32.Parse(ddlRowStatus.SelectedValue); int resutl = PageRoleManager.InsertPageRole(pageRole); Response.Redirect("AdminPageRoleDisplay.aspx"); }
protected void btnUpdate_Click(object sender, EventArgs e) { string loginID = "1"; try { if (Session["Login"] == null) { Session["PreviousPage"] = HttpContext.Current.Request.Url.AbsoluteUri; Response.Redirect("../LoginPage.aspx"); } loginID = ((Login)Session["Login"]).LoginID.ToString(); } catch (Exception ex) { } PageRole pageRole = new PageRole(); pageRole = PageRoleManager.GetPageRoleByID(Int32.Parse(Request.QueryString["pageRoleID"])); PageRole tempPageRole = new PageRole(); tempPageRole.PageRoleID = pageRole.PageRoleID; tempPageRole.PageID = Int32.Parse(ddlPage.SelectedValue); tempPageRole.RoleID = Int32.Parse(ddlRole.SelectedValue); tempPageRole.AddedDate = DateTime.Now; tempPageRole.AddedBy = loginID; tempPageRole.ModifyDate = DateTime.Now; tempPageRole.ModifyBy = loginID; tempPageRole.RowStatusID = Int32.Parse(ddlRowStatus.SelectedValue); bool result = PageRoleManager.UpdatePageRole(tempPageRole); Response.Redirect("AdminPageRoleDisplay.aspx"); }
public static PageRole GetPageRoleByID(int id) { PageRole pageRole = new PageRole(); SqlPageRoleProvider sqlPageRoleProvider = new SqlPageRoleProvider(); pageRole = sqlPageRoleProvider.GetPageRoleByID(id); return(pageRole); }
private void showPageRoleData() { PageRole pageRole = new PageRole(); pageRole = PageRoleManager.GetPageRoleByID(Int32.Parse(Request.QueryString["pageRoleID"])); ddlPage.SelectedValue = pageRole.PageID.ToString(); ddlRole.SelectedValue = pageRole.RoleID.ToString(); txtAddedBy.Text = pageRole.AddedBy; txtModifyDate.Text = pageRole.ModifyDate.ToString("dd MMM yyyy hh:mm tt"); txtModifyBy.Text = pageRole.ModifyBy; ddlRowStatus.SelectedValue = pageRole.RowStatusID.ToString(); }
public IHttpActionResult Create(RolePage model) { var db = new VidlyDbFirstEntities1(); //the linq below would translate to //select * from productstable where Id in(value1, value2, value3) var pages = db.Pages.Where(m => model.pageIds.Contains(m.Id)); foreach (var page in pages) { var vm = new PageRole { RoleId = model.roleId, PageID = page.Id }; db.PageRoles.Add(vm); } db.SaveChanges(); return(Ok()); }
public bool UpdatePageRole(PageRole pageRole) { using (SqlConnection connection = new SqlConnection(this.ConnectionString)) { SqlCommand cmd = new SqlCommand("Login_UpdatePageRole", connection); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@PageRoleID", SqlDbType.Int).Value = pageRole.PageRoleID; cmd.Parameters.Add("@PageID", SqlDbType.Int).Value = pageRole.PageID; cmd.Parameters.Add("@RoleID", SqlDbType.Int).Value = pageRole.RoleID; cmd.Parameters.Add("@AddedDate", SqlDbType.DateTime).Value = pageRole.AddedDate; cmd.Parameters.Add("@AddedBy", SqlDbType.NVarChar).Value = pageRole.AddedBy; cmd.Parameters.Add("@ModifyDate", SqlDbType.DateTime).Value = pageRole.ModifyDate; cmd.Parameters.Add("@ModifyBy", SqlDbType.NVarChar).Value = pageRole.ModifyBy; cmd.Parameters.Add("@RowStatusID", SqlDbType.Int).Value = pageRole.RowStatusID; connection.Open(); int result = cmd.ExecuteNonQuery(); return(result == 1); } }
public ActionResult AssignRoleToPage(PageRole model, AssignRoleViewModel pgr) { var db = new VidlyDbFirstEntities1(); //next line is to get at the items in the list i have on my view, thats what i am yet to achieve foreach (var item in pgr.ListOfPages) { var page = db.Pages.SingleOrDefault(c => c.Name == item); var pg = new PageRole { RoleId = model.RoleId, PageID = page.Id }; db.PageRoles.Add(pg); } return(View()); }
public PageRole GetPageRoleFromReader(IDataReader reader) { try { PageRole pageRole = new PageRole ( (int)reader["PageRoleID"], (int)reader["PageID"], (int)reader["RoleID"], (DateTime)reader["AddedDate"], reader["AddedBy"].ToString(), (DateTime)reader["ModifyDate"], reader["ModifyBy"].ToString(), (int)reader["RowStatusID"] ); return(pageRole); } catch (Exception ex) { return(null); } }
/// <summary> /// 插入页面权限数据 /// </summary> /// <param name="model">实体类</param> /// <returns></returns> public int InsertPageRole(PageRole model) { int flag = 0; StringBuilder sbtemp = new StringBuilder(); sbtemp.AppendFormat("select * from MS_Page where PageCode='{0}'", model._PageCode); DbCommand cmdtemp = db.GetSqlStringCommond(sbtemp.ToString()); DataTable dt = db.ExecuteDataTable(cmdtemp); if (dt.Rows.Count > 0) { flag = 100; } else { StringBuilder sb = new StringBuilder(); sb.AppendFormat("insert into MS_Page(PageCode,CodeName,Flag)values('{0}','{1}','{2}')", model._PageCode, model._CodeName, model._Flag); DbCommand cmd = db.GetSqlStringCommond(sb.ToString()); flag = db.ExecuteNonQuery(cmd); } return(flag); }
/// <summary> /// 修改页面权限数据 /// </summary> /// <param name="model">实体类</param> /// <param name="id">主键ID</param> /// <returns></returns> public int UpdatePageRole(PageRole model, int id) { int flag = 0; StringBuilder sbtemp = new StringBuilder(); sbtemp.AppendFormat("select * from MS_Page where PageCode='{0}' and ID not in({1})", model._PageCode, id); DbCommand cmdtemp = db.GetSqlStringCommond(sbtemp.ToString()); DataTable dt = db.ExecuteDataTable(cmdtemp); if (dt.Rows.Count > 0) { flag = 100; } else { StringBuilder sb = new StringBuilder(); sb.AppendFormat("update MS_Page set PageCode='{0}',CodeName='{1}',Flag='{2}' where ID={3}", model._PageCode, model._CodeName, model._Flag, id); DbCommand cmd = db.GetSqlStringCommond(sb.ToString()); flag = db.ExecuteNonQuery(cmd); } return(flag); }
protected void btnAdd_Click(object sender, EventArgs e) { string loginID = "1"; try { if (Session["Login"] == null) { Session["PreviousPage"] = HttpContext.Current.Request.Url.AbsoluteUri; Response.Redirect("../LoginPage.aspx"); } loginID = ((Login)Session["Login"]).LoginID.ToString(); } catch (Exception ex) { } PageRole pageRole = new PageRole(); pageRole.PageID = Int32.Parse(ddlPage.SelectedValue); pageRole.RoleID = Int32.Parse(ddlRole.SelectedValue); pageRole.AddedDate = DateTime.Now; pageRole.AddedBy = loginID; pageRole.ModifyDate = DateTime.Now; pageRole.ModifyBy = loginID; pageRole.RowStatusID = Int32.Parse(ddlRowStatus.SelectedValue); int resutl = PageRoleManager.InsertPageRole(pageRole); Response.Redirect("AdminPageRoleDisplay.aspx"); }
public static void SeedRoles(RoleManager <PageRole> roleManager) { if (!roleManager.RoleExistsAsync("NormalUser").Result) { PageRole role = new PageRole(); role.Name = "NormalUser"; IdentityResult roleResult = roleManager.CreateAsync(role).Result; } if (!roleManager.RoleExistsAsync("Administrator").Result) { PageRole role = new PageRole(); role.Name = "Administrator"; IdentityResult roleResult = roleManager.CreateAsync(role).Result; } if (!roleManager.RoleExistsAsync("Banned").Result) { PageRole role = new PageRole(); role.Name = "Banned"; IdentityResult roleResult = roleManager.CreateAsync(role).Result; } }
protected void btnRoleWisePageNMenuAccess_Click(object sender, EventArgs e) { string loginID = "1"; try { if (Session["Login"] == null) { Session["PreviousPage"] = HttpContext.Current.Request.Url.AbsoluteUri; Response.Redirect("../LoginPage.aspx"); } loginID = ((Login)Session["Login"]).LoginID.ToString(); } catch (Exception ex) { } RoleManager.DeleteModuleMenuPageButtonRole(int.Parse(ddlRole.SelectedValue)); int resutl = 0; foreach (GridViewRow grModule in gvModule.Rows) { CheckBox chkSelect = (CheckBox)grModule.FindControl("chkSelect"); if (chkSelect.Checked) { ModuleRole moduleRole = new ModuleRole(); moduleRole.ModuleID = Int32.Parse(chkSelect.ToolTip); moduleRole.RoleID = Int32.Parse(ddlRole.SelectedValue); moduleRole.AddedDate = DateTime.Now; moduleRole.AddedBy = loginID; moduleRole.ModifyDate = DateTime.Now; moduleRole.ModifyBy = loginID; moduleRole.RowStatusID = 1; resutl = ModuleRoleManager.InsertModuleRole(moduleRole); GridView gvPagenMenu = (GridView)grModule.FindControl("gvPagenMenu"); foreach (GridViewRow grPageNMenu in gvPagenMenu.Rows) { CheckBox chkSelectPageNMenu = (CheckBox)grPageNMenu.FindControl("chkSelectPageNMenu"); if (chkSelectPageNMenu.Checked) { PageRole pageRole = new PageRole(); pageRole.PageID = Int32.Parse(chkSelectPageNMenu.ToolTip); pageRole.RoleID = Int32.Parse(ddlRole.SelectedValue); pageRole.AddedDate = DateTime.Now; pageRole.AddedBy = loginID; pageRole.ModifyDate = DateTime.Now; pageRole.ModifyBy = loginID; pageRole.RowStatusID = 1; resutl = PageRoleManager.InsertPageRole(pageRole); if (chkSelectPageNMenu.ValidationGroup != "0") { MenuRole menuRole = new MenuRole(); menuRole.MenuID = Int32.Parse(chkSelectPageNMenu.ValidationGroup); menuRole.RoleID = Int32.Parse(ddlRole.SelectedValue); menuRole.AddedDate = DateTime.Now; menuRole.AddedBy = loginID; menuRole.ModifyDate = DateTime.Now; menuRole.ModifyBy = loginID; menuRole.RowStatusID = 1; resutl = MenuRoleManager.InsertMenuRole(menuRole); } DataList dlButton = (DataList)grPageNMenu.FindControl("dlButton"); foreach (DataListItem dliButton in dlButton.Items) { CheckBox chkSelectButton = (CheckBox)dliButton.FindControl("chkSelectButton"); if (chkSelectButton.Checked) { ButtonRole buttonRole = new ButtonRole(); buttonRole.RoleID = Int32.Parse(ddlRole.SelectedValue); buttonRole.ButtonID = Int32.Parse(chkSelectButton.ToolTip); buttonRole.AddedDate = DateTime.Now; buttonRole.AddedBy = loginID; buttonRole.ModifyDate = DateTime.Now; buttonRole.ModifyBy = loginID; buttonRole.RowStatusID = 1; resutl = ButtonRoleManager.InsertButtonRole(buttonRole); } } } } } { GridView gvPagenMenu = (GridView)grModule.FindControl("gvPagenMenu"); foreach (GridViewRow grPageNMenu in gvPagenMenu.Rows) { CheckBox chkSelectPageNMenu = (CheckBox)grPageNMenu.FindControl("chkSelectPageNMenu"); if (!chkSelectPageNMenu.Checked) { DataList dlButton = (DataList)grPageNMenu.FindControl("dlButton"); foreach (DataListItem dliButton in dlButton.Items) { CheckBox chkSelectButton = (CheckBox)dliButton.FindControl("chkSelectButton"); if (chkSelectButton.Checked) { ButtonRole buttonRole = new ButtonRole(); buttonRole.RoleID = Int32.Parse(ddlRole.SelectedValue); buttonRole.ButtonID = Int32.Parse(chkSelectButton.ToolTip); buttonRole.AddedDate = DateTime.Now; buttonRole.AddedBy = loginID; buttonRole.ModifyDate = DateTime.Now; buttonRole.ModifyBy = loginID; buttonRole.RowStatusID = 1; resutl = ButtonRoleManager.InsertButtonRole(buttonRole); } } } } } } Response.Redirect(HttpContext.Current.Request.Url.AbsoluteUri); }
public PageRole GetPageRoleFromReader(IDataReader reader) { try { PageRole pageRole = new PageRole ( (int)reader["PageRoleID"], (int)reader["PageID"], (int)reader["RoleID"], (DateTime)reader["AddedDate"], reader["AddedBy"].ToString(), (DateTime)reader["ModifyDate"], reader["ModifyBy"].ToString(), (int)reader["RowStatusID"] ); return pageRole; } catch(Exception ex) { return null; } }
public bool UpdatePageRole(PageRole pageRole) { using (SqlConnection connection = new SqlConnection(this.ConnectionString)) { SqlCommand cmd = new SqlCommand("Login_UpdatePageRole", connection); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@PageRoleID", SqlDbType.Int).Value = pageRole.PageRoleID; cmd.Parameters.Add("@PageID", SqlDbType.Int).Value = pageRole.PageID; cmd.Parameters.Add("@RoleID", SqlDbType.Int).Value = pageRole.RoleID; cmd.Parameters.Add("@AddedDate", SqlDbType.DateTime).Value = pageRole.AddedDate; cmd.Parameters.Add("@AddedBy", SqlDbType.NVarChar).Value = pageRole.AddedBy; cmd.Parameters.Add("@ModifyDate", SqlDbType.DateTime).Value = pageRole.ModifyDate; cmd.Parameters.Add("@ModifyBy", SqlDbType.NVarChar).Value = pageRole.ModifyBy; cmd.Parameters.Add("@RowStatusID", SqlDbType.Int).Value = pageRole.RowStatusID; connection.Open(); int result = cmd.ExecuteNonQuery(); return result == 1; } }
public static bool UpdatePageRole(PageRole pageRole) { SqlPageRoleProvider sqlPageRoleProvider = new SqlPageRoleProvider(); return sqlPageRoleProvider.UpdatePageRole(pageRole); }
private void showPageRoleData() { PageRole pageRole = new PageRole(); pageRole = PageRoleManager.GetPageRoleByID(Int32.Parse(Request.QueryString["pageRoleID"])); ddlPage.SelectedValue = pageRole.PageID.ToString(); ddlRole.SelectedValue = pageRole.RoleID.ToString(); txtAddedBy.Text = pageRole.AddedBy; txtModifyDate.Text = pageRole.ModifyDate.ToString("dd MMM yyyy hh:mm tt"); txtModifyBy.Text = pageRole.ModifyBy; ddlRowStatus.SelectedValue = pageRole.RowStatusID.ToString(); }
public static int InsertPageRole(PageRole pageRole) { SqlPageRoleProvider sqlPageRoleProvider = new SqlPageRoleProvider(); return sqlPageRoleProvider.InsertPageRole(pageRole); }
private void SetPageRole(PageRole role) { ViewBag.PageRole = role; }
protected void btnRoleWisePageNMenuAccess_Click(object sender, EventArgs e) { string loginID = "1"; try { if (Session["Login"] == null) { Session["PreviousPage"] = HttpContext.Current.Request.Url.AbsoluteUri; Response.Redirect("../LoginPage.aspx"); } loginID = ((Login)Session["Login"]).LoginID.ToString(); } catch (Exception ex) { } RoleManager.DeleteModuleMenuPageButtonRole(int.Parse(ddlRole.SelectedValue)); int resutl = 0; foreach (GridViewRow grModule in gvModule.Rows) { CheckBox chkSelect = (CheckBox)grModule.FindControl("chkSelect"); if (chkSelect.Checked) { ModuleRole moduleRole = new ModuleRole(); moduleRole.ModuleID = Int32.Parse(chkSelect.ToolTip); moduleRole.RoleID = Int32.Parse(ddlRole.SelectedValue); moduleRole.AddedDate = DateTime.Now; moduleRole.AddedBy = loginID; moduleRole.ModifyDate = DateTime.Now; moduleRole.ModifyBy = loginID; moduleRole.RowStatusID = 1; resutl = ModuleRoleManager.InsertModuleRole(moduleRole); GridView gvPagenMenu = (GridView)grModule.FindControl("gvPagenMenu"); foreach (GridViewRow grPageNMenu in gvPagenMenu.Rows) { CheckBox chkSelectPageNMenu = (CheckBox)grPageNMenu.FindControl("chkSelectPageNMenu"); if (chkSelectPageNMenu.Checked) { PageRole pageRole = new PageRole(); pageRole.PageID = Int32.Parse(chkSelectPageNMenu.ToolTip); pageRole.RoleID = Int32.Parse(ddlRole.SelectedValue); pageRole.AddedDate = DateTime.Now; pageRole.AddedBy = loginID; pageRole.ModifyDate = DateTime.Now; pageRole.ModifyBy = loginID; pageRole.RowStatusID = 1; resutl = PageRoleManager.InsertPageRole(pageRole); if (chkSelectPageNMenu.ValidationGroup != "0") { MenuRole menuRole = new MenuRole(); menuRole.MenuID = Int32.Parse(chkSelectPageNMenu.ValidationGroup); menuRole.RoleID = Int32.Parse(ddlRole.SelectedValue); menuRole.AddedDate = DateTime.Now; menuRole.AddedBy = loginID; menuRole.ModifyDate = DateTime.Now; menuRole.ModifyBy = loginID; menuRole.RowStatusID = 1; resutl = MenuRoleManager.InsertMenuRole(menuRole); } DataList dlButton = (DataList)grPageNMenu.FindControl("dlButton"); foreach (DataListItem dliButton in dlButton.Items) { CheckBox chkSelectButton = (CheckBox)dliButton.FindControl("chkSelectButton"); if (chkSelectButton.Checked) { ButtonRole buttonRole = new ButtonRole(); buttonRole.RoleID = Int32.Parse(ddlRole.SelectedValue); buttonRole.ButtonID = Int32.Parse(chkSelectButton.ToolTip); buttonRole.AddedDate = DateTime.Now; buttonRole.AddedBy = loginID; buttonRole.ModifyDate = DateTime.Now; buttonRole.ModifyBy = loginID; buttonRole.RowStatusID = 1; resutl = ButtonRoleManager.InsertButtonRole(buttonRole); } } } } } { GridView gvPagenMenu = (GridView)grModule.FindControl("gvPagenMenu"); foreach (GridViewRow grPageNMenu in gvPagenMenu.Rows) { CheckBox chkSelectPageNMenu = (CheckBox)grPageNMenu.FindControl("chkSelectPageNMenu"); if (!chkSelectPageNMenu.Checked) { DataList dlButton = (DataList)grPageNMenu.FindControl("dlButton"); foreach (DataListItem dliButton in dlButton.Items) { CheckBox chkSelectButton = (CheckBox)dliButton.FindControl("chkSelectButton"); if (chkSelectButton.Checked) { ButtonRole buttonRole = new ButtonRole(); buttonRole.RoleID = Int32.Parse(ddlRole.SelectedValue); buttonRole.ButtonID = Int32.Parse(chkSelectButton.ToolTip); buttonRole.AddedDate = DateTime.Now; buttonRole.AddedBy = loginID; buttonRole.ModifyDate = DateTime.Now; buttonRole.ModifyBy = loginID; buttonRole.RowStatusID = 1; resutl = ButtonRoleManager.InsertButtonRole(buttonRole); } } } } } } Response.Redirect(HttpContext.Current.Request.Url.AbsoluteUri); }
public static int InsertPageRole(PageRole pageRole) { SqlPageRoleProvider sqlPageRoleProvider = new SqlPageRoleProvider(); return(sqlPageRoleProvider.InsertPageRole(pageRole)); }
public static bool UpdatePageRole(PageRole pageRole) { SqlPageRoleProvider sqlPageRoleProvider = new SqlPageRoleProvider(); return(sqlPageRoleProvider.UpdatePageRole(pageRole)); }