private void button3_Click(object sender, EventArgs e) { if (dgCust.SelectedRows.Count != 1) { MessageBox.Show("Не выбрано ни одной строки!"); return; } EditUser eu = new EditUser(dgCust.SelectedRows[0].Cells["ID"].Value.ToString()); eu.ShowDialog(); DBUser dbu = new DBUser(); dgCust.DataSource = dbu.GetAllUsers(); }
public Users() { InitializeComponent(); DBUser dbu = new DBUser(); dgCust.DataSource = dbu.GetAllUsers(); dgCust.Columns["ID"].Visible = false; dgCust.Columns["FIO"].Width = 200; dgCust.Columns["FIO"].HeaderText = "ФИО"; dgCust.Columns["LOGIN"].Width = 100; dgCust.Columns["LOGIN"].HeaderText = "Логин"; dgCust.Columns["PASS"].Width = 100; dgCust.Columns["PASS"].HeaderText = "Пароль"; dgCust.Columns["ROLENAME"].Width = 150; dgCust.Columns["ROLENAME"].HeaderText = "Роль"; }
public EditUser(string idu) { InitializeComponent(); this.IDU = idu; DBUser dbu = new DBUser(); DataTable user = dbu.GetUser(idu); cbRole.ValueMember = "ID"; cbRole.DisplayMember = "ROLENAME"; cbRole.DataSource = dbu.GetAllRoles(); cbRole.SelectedValue = (int)user.Rows[0]["ROLE"]; textBox1.Text = user.Rows[0]["FIO"].ToString(); textBox2.Text = user.Rows[0]["LOGIN"].ToString(); textBox3.Text = user.Rows[0]["PASS"].ToString(); }