private void UserEditBtn_Click(object sender, EventArgs e) { User user = new User(); if (dataGridViewUsers.CurrentRow != null) { user.SetValues( Convert.ToInt32(dataGridViewUsers.CurrentRow.Cells["Id"].Value), Convert.ToInt32(dataGridViewUsers.CurrentRow.Cells["PositionId"].Value), dataGridViewUsers.CurrentRow.Cells["Nick"].Value.ToString(), dataGridViewUsers.CurrentRow.Cells["Password"].Value.ToString() ); UserForm pf = new UserForm(user, _db._ds.Tables["Position"], _db._ds.Tables["User"]); pf.ShowDialog(); if (user.Id != 0) { _db._ds.Tables["User"].Rows[dataGridViewUsers.CurrentRow.Index]["Id"] = user.Id; _db._ds.Tables["User"].Rows[dataGridViewUsers.CurrentRow.Index]["PositionId"] = user.PositionId; _db._ds.Tables["User"].Rows[dataGridViewUsers.CurrentRow.Index]["Nick"] = user.Nick; _db._ds.Tables["User"].Rows[dataGridViewUsers.CurrentRow.Index]["Password"] = user.Password; _db._adapterUser.Update(_db._ds.Tables["User"]); } } else { MessageBox.Show(@"Выделите строку с пользователем!"); } }