private void EditSelectedEmployee() { if (dgvEmployees.SelectedCells.Count > 0) { Employee employee = (Employee)dgvEmployees.SelectedCells[0].OwningRow.DataBoundItem; EmployeeForm form = new EmployeeForm(employee); for (int i = 0; i < dgvRewards.RowCount; i++) { bool b = true; if (employee.Rewards == null) { b = false; } else { if (!employee.Rewards.Contains(dgvRewards[0, i].Value.ToString())) { b = false; } } form.chRewards.Items.Add(dgvRewards[0, i].Value, b); } if (form.ShowDialog(this) == DialogResult.OK) { employee.LastName = form.LastName; employee.FirstName = form.FirstName; employee.Birth = form.Birth; employee.Rewards = Ch(form); DisplayEmployee(); } } }
private void RegisterNewEmployee() { EmployeeForm form = new EmployeeForm(null, rewards); if (form.ShowDialog(this) == DialogResult.OK) { employees.Add(form.LastName, form.FirstName, form.Birth, Checked(form)); DisplayEmployee(); } }
private string Ch(EmployeeForm form) { string text = ""; for (int i = 0; i < form.chRewards.CheckedItems.Count; i++) { text = text + " " + form.chRewards.CheckedItems[i].ToString(); } return(text); }
// private void RegisterNewEmployee() { EmployeeForm form = new EmployeeForm(); for (int i = 0; i < dgvRewards.RowCount; i++) { form.chRewards.Items.Add(dgvRewards[0, i].Value); } if (form.ShowDialog(this) == DialogResult.OK) { employees.Add(form.LastName, form.FirstName, form.Birth, Ch(form));/////// DisplayEmployee(); } }
private void EditSelectedEmployee() { if (dgvEmployees.SelectedCells.Count > 0) { Employee employee = (Employee)dgvEmployees.SelectedCells[0].OwningRow.DataBoundItem; EmployeeForm form = new EmployeeForm(employee, rewards); if (form.ShowDialog(this) == DialogResult.OK) { employee.LastName = form.LastName; employee.FirstName = form.FirstName; employee.Birth = form.Birth; employee.Rewards = Checked(form); employees.Edit(employee); DisplayEmployee(); } } }
private List <Reward> Checked(EmployeeForm form) { var allRewards = rewards.GetList();// var rewards_ = new List <Reward> { }; if (form.chRewards.CheckedItems.Count != 0) { for (int i = 0; i < form.chRewards.CheckedItems.Count; i++) { string checkedItem = (string)form.chRewards.CheckedItems[i]; Reward reward = rewards.GetList().FirstOrDefault(it => it.Title == checkedItem); rewards_.Add(reward); } } return(rewards_); }