public void Fill()
        {
            SqlConnection connection = new SqlConnection(connectionString);

            try
            {
                connection.Open();
                SqlDataReader dataReader;
                string        sql     = "SELECT * FROM users_group";
                SqlCommand    command = new SqlCommand(sql, connection);
                dataReader = command.ExecuteReader();
                while (dataReader.Read())
                {
                    UsersGroupDB obj = new UsersGroupDB();
                    obj.id          = Convert.ToInt32(dataReader.GetValue(0));
                    obj.name        = Convert.ToString(dataReader.GetValue(1));
                    obj.description = Convert.ToString(dataReader.GetValue(2));
                    obj.comment     = Convert.ToString(dataReader.GetValue(3));
                    list_objects.Add(obj);
                    obj = null;
                }
                connection.Close();
            }
            catch (Exception ex)
            {
            }
        }
Beispiel #2
0
        private void btnConfirm_Click_1(object sender, EventArgs e)
        {
            string group_name = "";

            group_name = tbName.Text;
            UsersGroupDB ug = new UsersGroupDB();

            ug.name         = tbName.Text;
            ug.description  = tbDescription.Text;
            ug.comment      = tbComment.Text;
            ug.date_created = tbRegDate.Text;
            ug.AddToDB();

            this.Close();
            MessageBox.Show("Группа " + group_name + " создана!");
        }
Beispiel #3
0
        public EditUser(int _id_user)
        {
            InitializeComponent();
            this.id_user = _id_user;
            UserDB obj = new UserDB(_id_user);

            tbName.Text         = obj.name;
            tbSername.Text      = obj.last_name;
            tbMiddleName.Text   = obj.middle_name;
            tbLogin.Text        = obj.login;
            tbPassword.Text     = obj.password;
            tbRegDate.Text      = obj.register_time;
            tbComment.Text      = obj.comment;
            tbPhone.Text        = obj.phone;
            tbEmail.Text        = obj.email;
            tbAddress.Text      = obj.address;
            cbConfirmed.Checked = Convert.ToBoolean(obj.confirmed);
            cbBlock.Checked     = Convert.ToBoolean(obj.block);

            int selected_index = 0;

            UsersGroupDB tu_obj = new UsersGroupDB();

            tu_obj.Fill();

            Dictionary <string, string> user_types = new Dictionary <string, string>();

            for (int i = 0; i < tu_obj.list_objects.Count; i++)
            {
                user_types.Add(tu_obj.list_objects[i].id.ToString(), tu_obj.list_objects[i].name);
                // Определим selected_index для выбранного типа
                if (obj.type_user == tu_obj.list_objects[i].id)
                {
                    selected_index = i;
                }
            }

            cbGroup.DataSource    = new BindingSource(user_types, null);
            cbGroup.DisplayMember = "Value";
            cbGroup.ValueMember   = "Key";
            cbGroup.SelectedIndex = selected_index;
            obj = null;
        }
Beispiel #4
0
        public AddUser()
        {
            InitializeComponent();
            tbRegDate.Text = DateTime.Now.ToString("");
            UsersGroupDB obj = new UsersGroupDB();

            obj.Fill();

            Dictionary <string, string> user_group_list = new Dictionary <string, string>();

            for (int i = 0; i < obj.list_objects.Count; i++)
            {
                user_group_list.Add(obj.list_objects[i].id.ToString(), obj.list_objects[i].name);
            }

            cbGroup.DataSource    = new BindingSource(user_group_list, null);
            cbGroup.DisplayMember = "Value";
            cbGroup.ValueMember   = "Key";
            cbGroup.SelectedIndex = 0;
        }
Beispiel #5
0
        private void btnConfirm_Click_1(object sender, EventArgs e)
        {
            this.Close();
            DialogResult dr = MessageBox.Show("Вы уверены, что хотите удалить объект?", "Вопрос", MessageBoxButtons.YesNo);

            switch (dr)
            {
            case DialogResult.Yes:
                // Получим список юзеров данной группы
                UsersDB udb           = new UsersDB();
                int     group_from_id = Convert.ToInt32(((KeyValuePair <string, string>)cbUserGroupDelete.SelectedItem).Key);
                // Если удаляем пользователей вместе с группой
                if (rbDeleteUser.Checked == true)
                {
                    udb.DeleteByGroupId(group_from_id);
                }

                // Если перемещаем пользователей группы в другую группу
                if (rbMoveUser.Checked == true)
                {
                    int group_to_move_id = Convert.ToInt32(((KeyValuePair <string, string>)cbUserGroupMove.SelectedItem).Key);
                    udb.MoveToGroupId(group_from_id, group_to_move_id);
                }
                // Затем удаляем группу из user_group
                UsersGroupDB obj = new UsersGroupDB();
                obj.Delete(Convert.ToInt32(((KeyValuePair <string, string>)cbUserGroupDelete.SelectedItem).Key));

                // Обновим dgv
                MainForm main_fm = (MainForm)Application.OpenForms["MainForm"];
                main_fm.UpdateDGV_Users();

                break;

            case DialogResult.No:
                break;
            }
            this.Close();
        }
Beispiel #6
0
        public DeleteUserGroup()
        {
            InitializeComponent();
            UsersGroupDB obj = new UsersGroupDB();

            rbDeleteUser.Checked = true;
            obj.Fill();

            // list групп для удаления
            Dictionary <string, string> user_groups_list_delete = new Dictionary <string, string>();

            for (int i = 0; i < obj.list_objects.Count; i++)
            {
                user_groups_list_delete.Add(obj.list_objects[i].id.ToString(), obj.list_objects[i].name);
            }
            // list групп для перемещения в неё
            Dictionary <string, string> user_group_list_move = new Dictionary <string, string>();

            for (int i = 0; i < obj.list_objects.Count; i++)
            {
                // Исключим из списка удаляемую группу, как?
                user_group_list_move.Add(obj.list_objects[i].id.ToString(), obj.list_objects[i].name);
            }


            cbUserGroupDelete.DataSource    = new BindingSource(user_groups_list_delete, null);
            cbUserGroupDelete.DisplayMember = "Value";
            cbUserGroupDelete.ValueMember   = "Key";
            cbUserGroupDelete.SelectedIndex = 0;


            cbUserGroupMove.DataSource    = new BindingSource(user_group_list_move, null);
            cbUserGroupMove.DisplayMember = "Value";
            cbUserGroupMove.ValueMember   = "Key";
            cbUserGroupMove.SelectedIndex = 0;
        }
Beispiel #7
0
        public AddRules()
        {
            InitializeComponent();

            // ТЕСТЫ ------------------------------------------------------------------------------
            dgvTests.Rows.Clear();
            TestsGroupDB obj = new TestsGroupDB();

            obj.Fill();

            Dictionary <string, string> test_group_list = new Dictionary <string, string>();

            for (int i = 0; i < obj.list_objects.Count; i++)
            {
                test_group_list.Add(obj.list_objects[i].id.ToString(), obj.list_objects[i].name);
            }

            cbTests.DataSource    = new BindingSource(test_group_list, null);
            cbTests.DisplayMember = "Value";
            cbTests.ValueMember   = "Key";
            cbTests.SelectedIndex = 0;

            tests = new TestsDB();
            tests.Fill(Convert.ToInt32(((KeyValuePair <string, string>)cbTests.SelectedItem).Key));
            for (int i = 0; i < tests.objects.Count; i++)
            {
                dgvTests.Rows.Add(
                    tests.objects[i].id,
                    false,
                    img_test,
                    tests.objects[i].name
                    );
            }
            // ПОЛЬЗОВАТЕЛИ -------------------------------------------------------------------------
            dgvUsers.Rows.Clear();
            UsersGroupDB obj_user = new UsersGroupDB();

            obj_user.Fill();

            Dictionary <string, string> user_group_list = new Dictionary <string, string>();

            for (int i = 0; i < obj_user.list_objects.Count; i++)
            {
                user_group_list.Add(obj_user.list_objects[i].id.ToString(), obj_user.list_objects[i].name);
            }

            cbUsers.DataSource    = new BindingSource(user_group_list, null);
            cbUsers.DisplayMember = "Value";
            cbUsers.ValueMember   = "Key";
            cbUsers.SelectedIndex = 0;

            users = new UsersDB();
            users.Fill(Convert.ToInt32(((KeyValuePair <string, string>)cbUsers.SelectedItem).Key));
            for (int i = 0; i < users.objects.Count; i++)
            {
                dgvUsers.Rows.Add(
                    users.objects[i].id,
                    false,
                    img_test,
                    users.objects[i].last_name
                    );
            }
            // ГРУППА ПРАВИЛ -------------------------------------------------------------------------
            RulesGroupDB obj_rules = new RulesGroupDB();

            obj_rules.Fill();

            Dictionary <string, string> rules_group_list = new Dictionary <string, string>();

            for (int i = 0; i < obj_rules.list_objects.Count; i++)
            {
                rules_group_list.Add(obj_rules.list_objects[i].id.ToString(), obj_rules.list_objects[i].name);
            }

            cbRulesGroup.DataSource    = new BindingSource(rules_group_list, null);
            cbRulesGroup.DisplayMember = "Value";
            cbRulesGroup.ValueMember   = "Key";
            cbRulesGroup.SelectedIndex = 0;
            // РАСПИСАНИЕ ----------------------------------------------------------------------------
            rbRaspType2.Checked           = true;
            rasp1_dateStart.CustomFormat  = "dd.MM.yyyy hh:mm:ss";
            rasp1_dateFinish.CustomFormat = "dd.MM.yyyy hh:mm:ss";
            // КОЛИЧЕСТВО ПОПЫТОК --------------------------------------------------------------------

            //cbNumberAttemptValue.SelectedIndex = 0;
        }