private void TsbGroupEditClick(object sender, EventArgs e) { using (GroupForm groupForm = new GroupForm()) { DataRowView currentGroup = _bsGroup.Current as DataRowView; groupForm.tbName.Text = currentGroup["Name"].ToString(); groupForm.tbDescription.Text = currentGroup["Description"].ToString(); if (groupForm.ShowDialog() == DialogResult.OK) { DataTable dtGrp = _dsSecurity.Tables["Group"]; DataRow currentGrp = dtGrp.Rows.Find(currentGroup["Name"]); currentGroup["Name"] = groupForm.tbName.Text; currentGroup["Description"] = groupForm.tbDescription.Text; _bsGroup.EndEdit(); _bsGroup.ResetCurrentItem(); currentGrp["Name"] = currentGroup["Name"]; currentGrp["Description"] = currentGroup["Description"]; } } }
private void TsbGroupNewClick(object sender, EventArgs e) { using (GroupForm groupForm = new GroupForm()) { if (groupForm.ShowDialog() == DialogResult.OK) { DataRowView currentUser = _bsUser.Current as DataRowView; DataRowView newGroup = _bsGroup.AddNew() as DataRowView; newGroup["UserName"] = currentUser["Name"]; newGroup["Name"] = groupForm.tbName.Text; newGroup["Description"] = groupForm.tbDescription.Text; _bsGroup.EndEdit(); _bsGroup.ResetCurrentItem(); DataTable dtGrp = _dsSecurity.Tables["Group"]; DataRow newGrp = dtGrp.NewRow(); newGrp["Name"] = newGroup["Name"]; newGrp["Description"] = newGroup["Description"]; dtGrp.Rows.Add(newGrp); DataTable dtUsrGrp = _dsSecurity.Tables["UsrGrp"]; DataRow newUsrGrp = dtUsrGrp.NewRow(); newUsrGrp["GroupName"] = newGroup["Name"]; newUsrGrp["UserName"] = newGroup["UserName"]; dtUsrGrp.Rows.Add(newUsrGrp); } } }