Пример #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int Id = 0;

        if (!string.IsNullOrEmpty(Request["Id"]))
        {
            int.TryParse(Request["Id"].Replace(",", ""), out Id);
        }
        if (!string.IsNullOrEmpty(Request["dll"]))
        {
            NavigationTitle(Request["dll"]);
        }

        hddRoles_ID.Value = Convert.ToString(Id);

        if (!IsPostBack)
        {
            RolesBSO rolesBSO = new RolesBSO();
            IRoles   roles    = rolesBSO.GetRolesById(Id);
            ltlTitle.Text = roles.RolesName;

            initControl(Id);
            initControlCate(Id);
            initControlCateNews(Id);
        }
    }
Пример #2
0
    protected void initControl(int ID)
    {
        if (ID > 0)
        {
            //btn_add.Visible = false;
            //btn_edit.Visible = true;

            //btn_add1.Visible = false;
            //btn_edit1.Visible = true;

            hddRoles_ID.Value = Convert.ToString(ID);
            try
            {
                RolesBSO rolesBSO = new RolesBSO();
                IRoles   roles    = rolesBSO.GetRolesById(ID);
                txtRolesName.Text = roles.RolesName;

                if (Session["Admin_UserName"].ToString().Equals("administrator"))
                {
                    ViewModules();
                }
                else
                {
                    ViewModules(Session["Admin_UserName"].ToString());
                }

                string sModules = roles.RolesModules;
                if (!sModules.Equals(""))
                {
                    string[] sSlip = sModules.Split(new char[] { ',' });
                    foreach (string s in sSlip)
                    {
                        foreach (ListItem items in chklist.Items)
                        {
                            if (items.Value == s)
                            {
                                items.Selected = true;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                error.Text = ex.Message.ToString();
            }
        }
        else
        {
            hddRoles_ID.Value = "";
            //btn_add.Visible = true;
            //btn_edit.Visible = false;

            btn_add1.Visible = true;
            //btn_edit1.Visible = false;
            ViewModules();
        }
    }
Пример #3
0
        protected void ViewRoles()
        {
            RolesBSO rolesBSO = new RolesBSO();
            DataTable table = rolesBSO.GetAllRoles();
            DataView dataView = new DataView(table);
            dataView.RowFilter = "Roles_Name not in ('adminsys32','Administrators')";
            DataTable dataTable = dataView.ToTable();
            commonBSO commonBSO = new commonBSO();
            commonBSO.FillToGridView(grvRoles, dataTable);

        }
        private void ViewRolesAll()
        {
            RolesBSO rolesBSO = new RolesBSO();
            DataTable table = rolesBSO.GetAllRoles();
            DataView dataView = new DataView(table);
            dataView.RowFilter = "Roles_Name not in ('adminsys32','Administrators')";
            DataTable dataTable = dataView.ToTable();

            RadGrid1.DataSource = dataTable;
            RadGrid1.DataBind();

        }
Пример #5
0
    protected void ViewRoles()
    {
        RolesBSO  rolesBSO = new RolesBSO();
        DataTable table    = rolesBSO.GetAllRoles();
        DataView  dataView = new DataView(table);

        dataView.RowFilter = "Roles_Name not in ('adminsys32','Administrators')";
        DataTable dataTable = dataView.ToTable();
        commonBSO commonBSO = new commonBSO();

        commonBSO.FillToGridView(grvRoles, dataTable);
    }
Пример #6
0
    private void ViewRolesAll()
    {
        RolesBSO  rolesBSO = new RolesBSO();
        DataTable table    = rolesBSO.GetAllRoles();
        DataView  dataView = new DataView(table);

        dataView.RowFilter = "Roles_Name not in ('adminsys32','Administrators')";
        DataTable dataTable = dataView.ToTable();

        grvRoles.DataSource = dataTable;
        grvRoles.DataBind();
    }
Пример #7
0
        public void ViewRoles()
        {
            ddlRoles.Items.Clear();
            RolesBSO rolesBSO = new RolesBSO();
            DataTable table = rolesBSO.GetAllRoles();
            DataView dataView = new DataView(table);
            dataView.RowFilter = "Roles_Name NOT IN ('adminsys32','Administrators')";
            DataTable dataTable = dataView.ToTable();

            commonBSO commonBSO = new commonBSO();
            commonBSO.FillToDropDown(ddlRoles, dataTable, "~~ Trong tất cả các nhóm ~~", "0", "Roles_Name", "Roles_ID", "");

        }
Пример #8
0
    public void ViewRoles()
    {
        ddlRoles.Items.Clear();
        RolesBSO  rolesBSO = new RolesBSO();
        DataTable table    = rolesBSO.GetAllRoles();
        DataView  dataView = new DataView(table);

        dataView.RowFilter = "Roles_Name NOT IN ('adminsys32','Administrators')";
        DataTable dataTable = dataView.ToTable();

        commonBSO commonBSO = new commonBSO();

        commonBSO.FillToDropDown(ddlRoles, dataTable, "~~ Trong tất cả các nhóm ~~", "0", "Roles_Name", "Roles_ID", "");
    }
Пример #9
0
    protected void btn_add_Click(object sender, EventArgs e)
    {
        Admin admin = ReceiveHtml();

        try
        {
            AdminBSO adminBSO = new AdminBSO();
            if (adminBSO.CheckExist(admin.AdminName))
            {
                error.Text = "<div class='alert alert-sm alert-danger bg-gradient'>Tài khoản đã được đăng ký. Vui lòng đăng ký lại !</div>";
            }
            else
            if (adminBSO.CheckExistEmail(admin.AdminEmail))
            {
                error.Text = "<div class='alert alert-sm alert-danger bg-gradient'>Địa chỉ Email đã được đăng ký. Vui lòng đăng ký lại !</div>";
            }
            else
            {
                if (CheckedList().Equals(""))
                {
                    error.Text = "<div class='alert alert-sm alert-danger bg-gradient'>Lỗi: Phải lựa chọn ít nhất 1 quyền !</div>";
                }
                else
                {
                    int id = 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 = "<div class='alert alert-sm alert-danger bg-gradient'>Thêm mới thành công !</div>";
                    initControl(id);
                }
            }
        }
        catch (Exception ex)
        {
            error.Text = ex.Message.ToString();
        }
    }
Пример #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int Id = 0;
            if (Page.RouteData.Values["Id"] != null)
                int.TryParse(Page.RouteData.Values["Id"].ToString().Replace(",", ""), out Id);
            if (Page.RouteData.Values["dll"] != null)
                NavigationTitle(Page.RouteData.Values["dll"].ToString());

            hddRoles.Value = Convert.ToString(Id);

            if (!IsPostBack)
            {
                RolesBSO rolesBSO = new RolesBSO();
                IRoles roles = rolesBSO.GetRolesById(Id);
                ltlTitle.Text = roles.RolesName;

                initControl(Id);
            }
        }
Пример #11
0
        protected void initControl(int ID)
        {
            if (ID > 0)
            {
                btn_add.Visible = false;
                btn_edit.Visible = true;
                hddRoles_ID.Value = Convert.ToString(ID);
                try
                {
                    RolesBSO rolesBSO = new RolesBSO();
                    IRoles roles = rolesBSO.GetRolesById(ID);
                    txtRolesName.Text = roles.RolesName;
                    ViewModules();
                    string sModules = roles.RolesModules;
                    if (!sModules.Equals(""))
                    {
                        string[] sSlip = sModules.Split(new char[] { ',' });
                        foreach (string s in sSlip)
                        {
                            foreach (ListItem items in chklist.Items)
                            {
                                if (items.Value == s)
                                    items.Selected = true;
                            }
                        }
                    }

                }
                catch (Exception ex)
                {
                    error.Text = ex.Message.ToString();
                }
            }
            else
            {
                hddRoles_ID.Value = "";
                btn_add.Visible = true;
                btn_edit.Visible = false;
                ViewModules();
            }
        }
Пример #12
0
    protected void grvRoles_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        int    rId   = Convert.ToInt32(e.CommandArgument.ToString());
        string rName = e.CommandName.ToLower().Trim();

        switch (rName)
        {
        case "department":
            Response.Redirect("~/Admin/Editns_departmentpermission/" + rId + "/Default.aspx");
            break;

        case "user":
            Response.Redirect("~/Admin/EditRolesAddUser/" + rId + "/Default.aspx");
            break;

        case "rules":
            Response.Redirect("~/Admin/EditCateNewsPermission/" + rId + "/Default.aspx");
            break;

        case "rules0":
            Response.Redirect("~/Admin/EditCateNewsGroupPermission/" + rId + "/Default.aspx");
            break;

        case "module":
            Response.Redirect("~/Admin/EditRolesModule/" + rId + "/Default.aspx");
            break;

        case "_edit":
            Response.Redirect("~/Admin/EditRoles/" + rId + "/Default.aspx");
            break;

        case "_delete":
            RolesBSO rolesBSO = new RolesBSO();
            rolesBSO.DeleteRoles(rId);
            ViewRoles();
            break;
        }
    }
Пример #13
0
    protected void btn_edit_Click(object sender, EventArgs e)
    {
        RolesBSO rolesBSO = new RolesBSO();
        IRoles   roles    = ReceiveHtml();

        try
        {
            if (CheckedList().Equals(""))
            {
                error.Text = "<div class='alert alert-sm alert-danger bg-gradient'>Loi : Xin hay lua chon it nhat 1 quyen </div>";
            }
            else
            {
                rolesBSO.UpdateRoles(roles);
                error.Text = "<div class='alert alert-sm alert-danger bg-gradient'>Cập nhật thành công !</div>";
                initControl(roles.RolesID);
            }
        }
        catch (Exception ex)
        {
            error.Text = ex.Message.ToString();
        }
    }
Пример #14
0
        protected void grvRoles_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int rId = Convert.ToInt32(e.CommandArgument.ToString());
            string rName = e.CommandName.ToLower().Trim();
            switch (rName)
            {
                case "user":
                    Response.Redirect("~/Admin/editrolesadduser/" + rId + "/Default.aspx");
                    break;
                case "rules":
                    Response.Redirect("~/Admin/editcatenewspermission/" + rId + "/Default.aspx");
                    break;
                case "_edit":
                    Response.Redirect("~/Admin/editroles/" + rId + "/Default.aspx");
                    break;
                case "_delete":
                    RolesBSO rolesBSO = new RolesBSO();
                    rolesBSO.DeleteRoles(rId);
                    ViewRoles();
                    break;

            }
        }
Пример #15
0
    protected void btn_add_Click(object sender, EventArgs e)
    {
        RolesBSO rolesBSO = new RolesBSO();
        IRoles   roles    = ReceiveHtml();

        try
        {
            if (CheckedList().Equals(""))
            {
                error.Text = "<div class='alert alert-sm alert-danger bg-gradient'>Loi : Xin hay lua chon it nhat 1 quyen </div>";
            }
            else
            {
                if (hddRoles_ID.Value != "")
                {
                    if (rolesBSO.UpdateRoles(roles) > 0)
                    {
                        error.Text = error.Text = "<div class='alert alert-sm alert-danger bg-gradient'>Cập nhật Thành công !</div>";
                    }
                    else
                    {
                        error.Text = "<div class='alert alert-sm alert-danger bg-gradient'>Lưu thông tin không thành công</div>";
                    }
                }
                else
                {
                    int id = rolesBSO.CreateRoles(roles);
                    error.Text = error.Text = "<div class='alert alert-sm alert-danger bg-gradient'>Thêm mới Thành công !</div>";
                    initControl(id);
                }
            }
        }
        catch (Exception ex)
        {
            error.Text = ex.Message.ToString();
        }
    }
Пример #16
0
    public void ViewModules(string username)
    {
        ModulesBSO modulesBSO = new ModulesBSO();
        DataTable  table      = modulesBSO.MixModules();
        DataView   dataView   = new DataView(table);

        AdminRolesBSO adminRolesBSO = new AdminRolesBSO();
        string        strRoles      = adminRolesBSO.GetRoles(username);
        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();
            }
        }

        if (!strModules.Equals(""))
        {
            string sSlip = strModules.Remove(strModules.LastIndexOf(",")).Replace(",", "','");
            dataView.RowFilter = "Slug not in ('listmodules','editmodules') and Slug in ('" + sSlip + "')";
        }
        else
        {
            dataView.RowFilter = "Slug not in ('listmodules','editmodules') ";
        }

        DataTable dataTable = dataView.ToTable();
        commonBSO commonBSO = new commonBSO();

        commonBSO.FillToCheckBoxList(chklist, dataTable, "Modules_Name", "Slug");
    }
Пример #17
0
        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();
            }
        }
Пример #18
0
        protected void btn_edit_Click(object sender, EventArgs e)
        {
            RolesBSO rolesBSO = new RolesBSO();
            IRoles roles = ReceiveHtml();
            try
            {
                if (CheckedList().Equals(""))
                {
                    error.Text = "Loi : Xin hay lua chon it nhat 1 quyen";
                }
                else
                {
                    rolesBSO.UpdateRoles(roles);
                    error.Text = String.Format(Resources.StringAdmin.UpdateSuccessful, "Roles", roles.RolesName);
                }

            }
            catch (Exception ex)
            {
                error.Text = ex.Message.ToString();
            }
        }
Пример #19
0
 public string RolesNameByUserName(string userName)
 {
     string strRolesID = new AdminRolesDAO().GetRoles1(userName);
     DataTable dt = new DataTable();
     RolesBSO roleBSO = new RolesBSO();
     DataTable dt2 = new DataView(roleBSO.GetAllRoles()) { RowFilter = "Roles_ID IN(" + strRolesID + ")" }.ToTable();
     if (dt2.Rows.Count == 0)
     {
         return "Administrators";
     }
     if ((dt2.Rows.Count == 1) && (dt2.Rows[0]["Roles_Name"].ToString().ToLower() == "guest"))
     {
         return "Guest";
     }
     string strRoles = "";
     for (int i = 0; i < dt2.Rows.Count; i++)
     {
         strRoles = strRoles + dt2.Rows[i]["Roles_Name"].ToString();
     }
     if (strRoles.ToLower().Contains("admin"))
     {
         return "admin";
     }
     return "mod";
 }
Пример #20
0
    private string BindMenu(string strMenuSub, int iCate)
    {
        if (Session["Admin_Username"] != null)
        {
            DataTable table  = new DataTable();
            commonBSO common = new commonBSO();
            String    SQL    = "";

            string        AdminName     = Session["Admin_Username"].ToString();
            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();
                }
                strModules = strModules.Remove(strModules.LastIndexOf(",")).Replace(",", "','");
            }

            if (AdminName.Equals("administrator"))
            {
                SQL   = "SELECT * FROM tblModules Where [IsMenu] =1 And [Modules_Parent] = " + iCate + " Order by [Modules_Order] ASC";
                table = common.CreateDataView(SQL);
            }
            else
            {
                SQL   = "SELECT * FROM tblModules Where [IsMenu] =1 And [Modules_Parent] = " + iCate + " And Slug in ('" + strModules + "') Order by [Modules_Order] ASC";
                table = common.CreateDataView(SQL);
            }
            //strMenuSub += "<ul>";
            //strMenuSub += "<li class='sidebar-label pt20'><a href='" + ResolveUrl("~/") + "Admin/home/Default.aspx'>Trang chủ</a></li>";
            if (table.Rows.Count > 0)
            {
                foreach (DataRow dataRow in table.Rows)
                {
                    strMenuSub += "<li class='sidebar-label pt20'>";
                    //strMenuSub += "<a href='" + ResolveUrl("~/") + "Admin/" + dataRow["Modules_Url"] + "/Default.aspx'>" + dataRow["Modules_Name"].ToString() + "</a>";

                    //if (checkActive(Request["dll"].ToString(), dataRow["Slug"].ToString()))
                    //{
                    //strMenuSub += "<a href='" + ResolveUrl("~/") + "Admin/" + dataRow["Slug"] + "/Default.aspx'>" + dataRow["Modules_Name"].ToString() + "</a>";
                    strMenuSub += dataRow["Modules_Name"].ToString();
                    //strMenuSub += "<span class='closed opened'></span>";
                    //strMenuSub += "<div style='display: block;'>";
                    //}
                    //else
                    //{
                    //    strMenuSub += "<a href='" + ResolveUrl("~/") + "Admin/" + dataRow["Slug"] + "/Default.aspx'>" + dataRow["Modules_Name"].ToString() + "</a>";

                    //    //strMenuSub += "<span class='closed'></span>";
                    //    //strMenuSub += "<div style='display: none;'>";
                    //}
                    strMenuSub += "</li>";
                    strMenuSub += GetSubMenu("", Convert.ToInt32(dataRow["Modules_ID"].ToString()), Session["Admin_Username"].ToString(), strModules);

                    //strMenuSub += "</div>";
                }
            }
            //strMenuSub += "</ul>";
        }
        else
        {
            Response.Redirect("~/Default.aspx");
        }



        return(strMenuSub);
    }
Пример #21
0
 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();
 }
Пример #22
0
 public DataTable ViewMainModules(string AdminName)
 {
     DataTable dataTable = new DataTable();
     Admin admin = new AdminBSO().GetAdminById(AdminName);
     RolesBSO rolesBSO = new RolesBSO();
     string strModules = rolesBSO.GetRolesById(admin.RolesID).RolesModules.Replace(",", "','");
     DataTable table = new ModulesBSO().MixModules();
     if (AdminName.Equals("administrator"))
     {
         return table;
     }
     DataView dataView = new DataView(table) {
         RowFilter = "Modules_Url in ('" + strModules + "')",
         Sort = "Modules_ID ASC"
     };
     return dataView.ToTable();
 }