コード例 #1
0
 protected void btnEdit_Click(object sender, EventArgs e)
 {
     if (lstRoles.SelectedIndex >= 0 && lstCat.SelectedIndex >= 0 && lstPer.SelectedIndex >= 0)
     {
         ResetCategory();
         string strPer = "";
         foreach (ListItem item in lstPer.Items)
         {
             strPer += item.Value + ",";
         }
         /// nếu có chuyên mục : channel,role;category:permission
         string id = 1 + "," + lstRoles.SelectedValue + ";" + lstCat.SelectedValue + ":" + strPer.Substring(0, strPer.Length - 1);
         ViewState["id"] = id;
         Business.User user    = new Business.User();
         int           Role_ID = Int32.Parse(user.GetRoleID(id));
         using (MainDB db = new MainDB())
         {
             lbxRole.SelectedIndex = 0;
             LoadPermission(db, Role_ID);
         }
         ResetPermission();
         //set category selected
         if (user.GetCategoryID(id) != "")
         {
             SetListSelected(user.GetCategoryID(id), clbCategory);
             SetListSelected("," + id.Split(':')[1] + ",", clbPermission);
             lbxRole.SelectedValue = Role_ID.ToString();
         }
         else
         {
             lbxRole.SelectedValue = RoleConst.QuanTriKenh.ToString();
             clbPermission.Enabled = false;
             clbCategory.Enabled   = false;
         }
         btnAssignPermission.Visible = false;
         btnUpdate.Visible           = true;
         btnCancel.Visible           = true;
         lblMessage.Visible          = false;
     }
     else
     {
         lblMessageXoa.Text = "Bạn phải chọn vài trò , chuyên mục , quyền muốn sửa";
         return;
     }
 }