protected void btn_add_Click(object sender, EventArgs e) { DataTable datatable = GetUserGrid(); try { AdminRolesBSO adminRolesBSO = new AdminRolesBSO(); DataTable table1 = adminRolesBSO.GetAdminRolesByUserName(hddUserName.Value); if (table1.Rows.Count > 0) adminRolesBSO.DeleteAdminRolesUserName(hddUserName.Value); AdminRoles adminRoles = new AdminRoles(); if (datatable.Rows.Count > 0) { foreach (DataRow subrow in datatable.Rows) { adminRoles.RolesID = Convert.ToInt32(subrow["Roles_ID"].ToString()); adminRoles.AdminUserName = hddUserName.Value; adminRoles.UserName = Session["Admin_UserName"].ToString(); //adminRoles.Permission = subrow["Permission"].ToString(); adminRoles.Permission = ""; adminRoles.Created = DateTime.Now; adminRolesBSO.CreateAdminRoles(adminRoles); error.Text = String.Format(Resources.StringAdmin.AddNewsSuccessful); } } } catch (Exception ex) { error.Text = ex.Message.ToString(); } }
public DataTable ViewMainModulesByRoles(string AdminName) { DataTable dataTable = new DataTable(); AdminRolesBSO adminRolesBSO = new AdminRolesBSO(); string strRoles = adminRolesBSO.GetRoles(AdminName); RolesBSO rolesBSO = new RolesBSO(); DataTable table1 = rolesBSO.GetRolesbyStrRolesID(strRoles); string strModules = ""; if (table1.Rows.Count > 0) { foreach (DataRow row in table1.Rows) { strModules += row["Roles_Modules"].ToString(); } } // string strModules = roles.RolesModules; strModules = strModules.Replace(",", "','"); ModulesBSO modulesBSO = new ModulesBSO(); DataTable table = modulesBSO.MixModulesAdmin(); if (AdminName.Equals("administrator")) { dataTable = table; } else { DataView dataView = new DataView(table); dataView.RowFilter = "Slug in ('" + strModules + "')"; dataView.Sort = "Modules_ID ASC"; dataTable = dataView.ToTable(); } return(dataTable); }
protected void btn_search_Click(object sender, EventArgs e) { int cId = Convert.ToInt32(ddlRoles.SelectedValue); AdminBSO adminBSO = new AdminBSO(); //DataTable table = adminBSO.AdminGetAllRolesByID(cId); DataTable dataTable = new DataTable(); commonBSO commonBSO = new commonBSO(); DataTable table = adminBSO.GetAllAdminRoles(); DataView dataView = new DataView(table); //dataView.RowFilter = "Admin_Username <> 'administrator' and Admin_Username <> 'Administrator'"; if (cId == 0) { dataView.RowFilter = "Admin_Username not in ('administrator','Administrator')"; dataTable = dataView.ToTable(); commonBSO.FillToGridView(grvAdmin, dataTable); } else { AdminRolesBSO adminRolesBSO = new AdminRolesBSO(); string strUser = adminRolesBSO.GetAdminUserName1(cId); if (strUser != "") { DataTable table1 = adminBSO.GetAdminBystrName(strUser); commonBSO.FillToGridView(grvAdmin, table1); } } }
public DataTable ViewMainModulesRoles(string AdminName) { DataTable dataTable = new DataTable(); string strRoles = new AdminRolesBSO().GetRoles(AdminName); DataTable table1 = new RolesBSO().GetRolesbyStrRolesID(strRoles); string strModules = ""; if (table1.Rows.Count > 0) { foreach (DataRow row in table1.Rows) { strModules = strModules + row["Roles_Modules"].ToString(); } } strModules = strModules.Replace(",", "','"); DataTable table = new ModulesBSO().MixModulesAdmin(); if (AdminName.Equals("administrator")) { return table; } DataView dataView = new DataView(table) { RowFilter = "Modules_Url in ('" + strModules + "')", Sort = "Modules_ID ASC" }; return dataView.ToTable(); }
private void VierUserRoles() { //PermissionBSO permissionBSO = new PermissionBSO(); //DataTable table = permissionBSO.GetPermissionAll(); //DataView dataView = new DataView(table); //dataView.Sort = "PermissionID ASC"; //DataTable dataTable = dataView.ToTable(); //commonBSO commonBSO = new commonBSO(); AdminRolesBSO adminRolesBSO = new AdminRolesBSO(); AdminRoles adminRoles = new AdminRoles(); foreach (GridDataItem dataItem in RadGrid1.MasterTableView.Items) { //CheckBoxList chklist = (CheckBoxList)dataItem.FindControl("chklist"); CheckBox chkId = (CheckBox)dataItem.FindControl("chkId"); //commonBSO.FillToCheckBoxList(chklist, dataTable, "PermissionName", "Value"); if (adminRolesBSO.CheckExitRolesUser(Convert.ToInt32(dataItem.GetDataKeyValue("Roles_ID")), hddUserName.Value)) { //Permission //adminRoles = adminRolesBSO.GetAdminRoles(Convert.ToInt32(dataItem["Roles_ID"].Text), hddUserName.Value); //if (adminRoles != null) //{ // string sPermission = adminRoles.Permission; // if (!sPermission.Equals("")) // { // string[] sSlip = sPermission.Split(new char[] { ',' }); // foreach (string s in sSlip) // { // foreach (ListItem items in chklist.Items) // { // if (items.Value == s) // items.Selected = true; // } // } // } //} //Admin_ID chkId.Checked = true; } } }
protected void btn_add_Click(object sender, EventArgs e) { try { CateNews catenews = ReceiveHtml(); CateNewsBSO catenewsBSO = new CateNewsBSO(); int catenews1 = catenewsBSO.CreateCateNewGet(catenews); if (!Session["Admin_UserName"].ToString().Equals("administrator")) { AdminRolesBSO adminRolesBSO = new AdminRolesBSO(); DataTable table = adminRolesBSO.GetAdminRolesByUserName(Session["Admin_UserName"].ToString()); CateNewsPermissionBSO catenewPermissionBSO = new CateNewsPermissionBSO(); CateNewsPermission cateNewsPermission = new CateNewsPermission(); if (table.Rows.Count > 0) { foreach (DataRow subrow in table.Rows) { cateNewsPermission.CateNewsID = catenews1; cateNewsPermission.RolesID = Convert.ToInt32(subrow["RolesID"].ToString()); //cateNewsPermission.Permission = subrow["Permission"].ToString(); cateNewsPermission.Permission = ""; cateNewsPermission.UserName = Session["Admin_UserName"].ToString(); cateNewsPermission.Created = DateTime.Now; catenewPermissionBSO.CreateCateNewsPermission(cateNewsPermission); } } } clientview.Text = String.Format(Resources.StringAdmin.AddNewsSuccessful); //ViewCateGroup(Convert.ToInt32(HddGroupCate.Value)); } catch (Exception ex) { clientview.Text = ex.Message.ToString(); } }
protected void btn_add_Click(object sender, EventArgs e) { ETO.Admin admin = ReceiveHtml(); try { AdminBSO adminBSO = new AdminBSO(); if (adminBSO.CheckExist(admin.AdminName)) { error.Text = String.Format(Resources.StringAdmin.CheckExist, admin.AdminName); } else if (adminBSO.CheckExistEmail(admin.AdminEmail)) { error.Text = "<font color = 'red'>Địa chỉ Email đã được đăng ký. Vui lòng đăng ký lại</font>"; } else { if (CheckedList().Equals("")) { error.Text = "Loi : Xin hay lua chon it nhat 1 quyen"; } else { adminBSO.CreateAdmin(admin); RolesBSO rolesBSO = new RolesBSO(); IRoles roles = rolesBSO.GetRolesByName("Guest"); AdminRolesBSO adminRolesBSO = new AdminRolesBSO(); AdminRoles adminRoles = new AdminRoles(); adminRoles.AdminUserName = admin.AdminName; adminRoles.RolesID = roles.RolesID; adminRoles.UserName = Session["Admin_UserName"].ToString(); adminRoles.Permission = ""; adminRoles.Created = DateTime.Now; adminRolesBSO.CreateAdminRoles(adminRoles); error.Text = String.Format(Resources.StringAdmin.AddNewsSuccessful); } } } catch (Exception ex) { error.Text = ex.Message.ToString(); } }