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();
            }
        }
Example #2
0
 public void CreateAdminRoles(AdminRoles adminRoles)
 {
     using (SqlConnection connection = base.GetConnection())
     {
         SqlCommand command = new SqlCommand("_AdminRolesUpdate", connection) {
             CommandType = CommandType.StoredProcedure
         };
         command.Parameters.AddWithValue("@Type", 0);
         command.Parameters.AddWithValue("@AdminRolesID", 0);
         command.Parameters.AddWithValue("@RolesID", adminRoles.RolesID);
         command.Parameters.AddWithValue("@Admin_UserName", adminRoles.AdminUserName);
         command.Parameters.AddWithValue("@Permission", adminRoles.Permission);
         command.Parameters.AddWithValue("@Created", adminRoles.Created);
         command.Parameters.AddWithValue("@UserName", adminRoles.UserName);
         connection.Open();
         if (command.ExecuteNonQuery() <= 0)
         {
             throw new DataAccessException("Khong them duoc quang cao");
         }
         command.Dispose();
     }
 }
        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;
                }

            }


        }
Example #4
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();
            }
        }
Example #5
0
 public void UpdateAdminRoles(AdminRoles adminRoles)
 {
     new AdminRolesDAO().UpdateAdminRoles(adminRoles);
 }
Example #6
0
 public void CreateAdminRoles(AdminRoles adminRoles)
 {
     new AdminRolesDAO().CreateAdminRoles(adminRoles);
 }