public static Firm EditFirm(Firm data) { var win = new FirmEditorForm(); win.SetData(data); if (win.ShowDialog() == DialogResult.OK) { return(win.GetData()); } return(null); }
private void butAddFirm_Click(object sender, EventArgs e) { var obj = FirmEditorForm.AddFirm(); if (obj != null) { DataManager.Firms.Add(obj); DataManager.SaveFirm(); lvFirms.Items.Add(CreateListViewItem(obj)); } }
public static Firm AddFirm() { var win = new FirmEditorForm(); var id = DataManager.FirmGetNewId(); win.lbId.Text = id.ToString(); win.cbSpec.SelectedIndex = 0; win.cbToo.SelectedIndex = 0; if (win.ShowDialog() == DialogResult.OK) { return(win.GetData()); } return(null); }
private void EditFirm() { if (lvFirms.Items == null || lvFirms.Items.Count == 0) { return; } Firm data = null; if (lvFirms.SelectedItems == null || lvFirms.SelectedItems.Count == 0) { lvFirms.Items[0].Selected = true; data = (Firm)lvFirms.Items[0].Tag; } else { data = (Firm)lvFirms.SelectedItems[0].Tag; } var obj = FirmEditorForm.EditFirm(data); if (obj != null) { for (var i = 0; i < DataManager.Firms.Count; i++) { if (DataManager.Firms[i].Id == obj.Id) { DataManager.Firms[i] = obj; break; } } DataManager.SaveFirm(); for (var i = 0; i < lvFirms.Items.Count; i++) { if (((Firm)lvFirms.Items[i].Tag).Id == obj.Id) { lvFirms.Items[i] = CreateListViewItem(obj); break; } } } }