private void OnAdd() { dlgAddUser dlg = new dlgAddUser(_dtBranch); if (dlg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { DataTable dt = dgUser.DataSource as DataTable; DataRow row = dt.NewRow(); row["LogonKey"] = dlg.LogonKey; row["Username"] = dlg.Username; row["Password"] = dlg.Password; row["BranchKey"] = dlg.BranchKey; row["Note"] = dlg.Notes; dt.Rows.Add(row); dgUser.Rows[dgUser.RowCount - 1].Selected = true; } }
private void OnEdit() { if (dgUser.SelectedRows == null || dgUser.SelectedRows.Count <= 0) { MessageBox.Show("Please select one user.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } DataRow dataRow = (dgUser.SelectedRows[0].DataBoundItem as DataRowView).Row; dlgAddUser dlg = new dlgAddUser(dataRow, _dtBranch); if (dlg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { dataRow["Username"] = dlg.Username; dataRow["Password"] = dlg.Password; dataRow["BranchKey"] = dlg.BranchKey; dataRow["Note"] = dlg.Notes; } }