Пример #1
0
        public CreateUser(string currentDB)
        {
            InitializeComponent();

            var logins = LoginQueries.GetLogins(LoginInformation.Server, LoginInformation.User, LoginInformation.Password);

            cbLogins.Items.AddRange(logins.ToArray());

            CurrentDatabase = currentDB;

            if (CurrentDatabase == "master")
            {
                clbRoles.Items.Add("loginmanager");
                clbRoles.Items.Add("dbmanager");
            }
            else
            {
                clbRoles.Items.Add("db_owner");
                clbRoles.Items.Add("db_securityadmin");
                clbRoles.Items.Add("db_accessadmin");
                clbRoles.Items.Add("db_backupoperator");
                clbRoles.Items.Add("db_ddladmin");
                clbRoles.Items.Add("db_datawriter");
                clbRoles.Items.Add("db_datareader");
                clbRoles.Items.Add("db_denydatawriter");
                clbRoles.Items.Add("db_denydatareader");
            }
        }
        public void RefreshView()
        {
            listView1.Items.Clear();

            try
            {
                var logins = LoginQueries.GetLogins(LoginInformation.Server, LoginInformation.User, LoginInformation.Password);

                foreach (var item in logins)
                {
                    listView1.Items.Add(item.Name, 0);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Database Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }