private void UpdateSelections(object sender, ListViewItemSelectionChangedEventArgs e) { CheckBox[] selections = new CheckBox[7] { sun, mon, tue, wed, thur, fri, sat }; ComponentResourceManager res = new ComponentResourceManager(typeof(ProjectForm)); listView1.ContextMenu = new ContextMenu(); if (listView1.SelectedItems.Count == 1) { SyncWorkdaySelections(); foreach (CheckBox checkBox in selections) { checkBox.Checked = false; checkBox.Enabled = true; } DailyAdmin modify = dailyAdmins.Find((it) => it.Name == listView1.SelectedItems[0].Text); listView1.Tag = modify; modify.WorkingDays.ForEach((day) => { selections[(int)day].Checked = true; }); listView1.ContextMenu.MenuItems.Add(res.GetString("properities"), (s, ea) => { DailyAdminForm form = new DailyAdminForm(modify); form.ShowDialog(); form.Dispose(); } ); } else { SyncWorkdaySelections(); foreach (CheckBox checkBox in selections) { checkBox.Enabled = false; } } listView1.ContextMenu.MenuItems.Add(res.GetString("remove"), (s, ea) => { ListView.SelectedListViewItemCollection selected = listView1.SelectedItems; foreach (ListViewItem item in selected) { listView1.Items.Remove(item); dailyAdmins.RemoveAll((it) => it.Name == item.Text); } } ); }
private void addAdmin_Click(object sender, EventArgs e) { DailyAdminForm form = new DailyAdminForm(); if (form.ShowDialog() == DialogResult.OK) { if (dailyAdmins.Exists((it) => it.Name == form.ValueReturn.Name)) { ComponentResourceManager res = new ComponentResourceManager(typeof(ProjectForm)); MessageBox.Show(res.GetString("error.DualAdmin"), res.GetString("error"), MessageBoxButtons.OK, MessageBoxIcon.Error); } else { dailyAdmins.Add(form.ValueReturn); DrawAdmins(); } } form.Dispose(); }