Exemple #1
0
        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);
                    });
                }
            }
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        public MainForm()
        {
            InitializeComponent();
            EditButton.Enabled   = false;
            InfoButton.Enabled   = false;
            DeleteButton.Enabled = false;

            _bureaus = Bureau.ReadBureauList("bureaus");
            _bureaus.ForEach(bureauListInfo =>
            {
                ListOfBureaus.Items.Add(bureauListInfo.ToShortString());
            });
        }
Exemple #4
0
 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();
 }
Exemple #5
0
        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");
            }
        }