Exemple #1
0
        public AddAdmin()
        {
            InitializeComponent();
            tbRegDate.Text = DateTime.Now.ToString("");
            TypeUserDB obj = new TypeUserDB();

            obj.Fill();

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

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

            cbGroup.DataSource    = new BindingSource(user_types, null);
            cbGroup.DisplayMember = "Value";
            cbGroup.ValueMember   = "Key";
            cbGroup.SelectedIndex = 0;
        }
Exemple #2
0
        public EditAdmin(int _id_admin)
        {
            InitializeComponent();
            this.id_admin = _id_admin;
            AdminDB obj = new AdminDB(_id_admin);

            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;
            int selected_index = 0;

            TypeUserDB tu_obj = new TypeUserDB();

            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;
        }