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;
        }
Exemple #2
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;
        }
Exemple #3
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;
        }
        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;
        }