示例#1
0
        private Dictionary <int, string> ShowAllRoles()
        {
            Classes.CRoles           cu       = new Classes.CRoles();
            Dictionary <int, string> Get      = new Dictionary <int, string>();
            List <Models.MRoles>     GetUsers = new List <Models.MRoles>();

            GetUsers = cu.GetAll();
            Get.Add(-1, "Please Select");
            for (int i = 0; i < GetUsers.Count; i++)
            {
                int    Key   = Convert.ToInt32(GetUsers[i].id);
                string Value = GetUsers[i].RoleName;
                Get.Add(Key, Value);
            }
            return(Get);
        }
        private void BindDropDown()
        {
            Dictionary <int, string> Get      = new Dictionary <int, string>();
            List <Models.MRoles>     GetRoles = new List <Models.MRoles>();

            Classes.CRoles cr = new Classes.CRoles();
            GetRoles = cr.GetAll();
            Get.Add(-1, "Please Select");
            for (int i = 0; i < GetRoles.Count; i++)
            {
                Get.Add(Convert.ToInt32(GetRoles[i].id), GetRoles[i].RoleName);
            }
            ddlRoles.DataValueField = "Key";
            ddlRoles.DataTextField  = "Value";
            ddlRoles.DataSource     = Get;
            ddlRoles.DataBind();
        }
示例#3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                string RoleName = txtRoleName.Text;

                Models.MRoles  mr = new Models.MRoles();
                Classes.CRoles cr = new Classes.CRoles();
                mr.RoleName = RoleName;
                if (cr.Save(mr) < 0)
                {
                    ShowFailMessage();
                }
                else
                {
                    ShowSuccessMessage();
                    ClearTextBoxes(Page);
                }
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string RoleId      = ddlRoles.SelectedValue;
            string RolesString = ComposeRolesString();

            if (Convert.ToInt32(RoleId) < 0)
            {
                ShowFailMessage();
            }
            else
            {
                Classes.CRoles cr = new Classes.CRoles();
                if (cr.AssignPermissionsToRoles(Convert.ToInt32(RoleId), RolesString) < 0)
                {
                    ShowFailMessage();
                }
                else
                {
                    ShowSuccessMessage();
                }
            }
        }
 private void BindData()
 {
     Classes.CRoles cb = new Classes.CRoles();
     grdRoles.DataSource = cb.GetAll();
     grdRoles.DataBind();
 }