public BureauForm(Bureau bureau) { InitializeComponent(); _bureau = bureau; EditButton.Enabled = false; DeleteButton.Enabled = false; Services[] services = (Services[])Enum.GetValues(typeof(Services)); foreach (Services service in services) { ServicesText.Items.Add(service.ToString()); } if (_bureau != null && _bureau.BureauName != null && bureau.Service != null) { ServicesText.SelectedIndex = ServicesText.Items.IndexOf(bureau.Service.ToString()); BureauNameText.Text = bureau.BureauName; _bureau.CalculateCostOrderAndPerformers(); if (bureau.Customers != null) { bureau.Customers.ForEach(customer => { ListOfCustomers.Items.Add(customer); }); } } }
public static List <Bureau> ReadBureauList(string fileName) { List <Bureau> bureaus = new List <Bureau>(); if (File.Exists(fileName)) { using (XmlReader reader = XmlReader.Create(fileName)) { reader.MoveToContent(); while (reader.Read()) { if (reader.IsStartElement() && !reader.Name.Equals("Bureaus")) { Bureau bureau = new Bureau(); bureau.ReadXml(reader); bureaus.Add(bureau); } else { break; } } } } return(bureaus); }
public MainForm() { InitializeComponent(); EditButton.Enabled = false; InfoButton.Enabled = false; DeleteButton.Enabled = false; _bureaus = Bureau.ReadBureauList("bureaus"); _bureaus.ForEach(bureauListInfo => { ListOfBureaus.Items.Add(bureauListInfo.ToShortString()); }); }
private void SaveButton_Click(object sender, EventArgs e) { if (_bureaus != null) { Bureau.WriteBureausToFile("bureaus", _bureaus); MessageBox.Show("Saved successfully!"); } else { MessageBox.Show("There are nothing to save"); } DialogResult = DialogResult.OK; Close(); }
private void NewButton_Click(object sender, EventArgs e) { Bureau bureau = new Bureau(); BureauForm bureauForm = new BureauForm(bureau); if (bureauForm.ShowDialog() == DialogResult.OK) { ListOfBureaus.Items.Add(bureau.ToShortString()); _bureaus.Add(bureau); } else { MessageBox.Show("Changes was not saved"); } }