Exemple #1
0
        // Loading XML to database
        private void loadDataFromFiles()
        {
            this.repairs.Clear();
            this.clients.Clear();

            try
            {
                // Load clients
                TextReader textReader = new StreamReader(path + @"\klienci.xml");
                clients = (List<Client>)clientSerializer.Deserialize(textReader);

                // Load repairs
                textReader = new StreamReader(path + @"\naprawy.xml");
                repairs = (List<Repair>)repairSerializer.Deserialize(textReader);

                // Load settings
                textReader = new StreamReader(path + @"\ustawienia.xml");
                settings = (Settings)settingsSerializer.Deserialize(textReader);

                // Load archive repairs
                textReader = new StreamReader(path + @"\archiwum.xml");
                archiveRepairs = (List<Repair>)archiveSerializer.Deserialize(textReader);
                textReader.Close();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.GetBaseException().Message.ToString() + "\nCzy jesteś pewien, że podana ścieżka jest dobra?");
            }
        }
        public NewRepairWindow(ref List<Repair> repairs, List<Client> clients, Settings settings)
        {
            this.newRepair = new Repair();
            this.settings = settings;
            this.newRepair.id = getNextId();
            this.repairs = repairs;

            InitializeComponent();

            this.brandComboBox.Items.AddRange(settings.brands.ToArray());
            this.brandComboBox.SelectedIndex = 0;
            this.typeComboBox.SelectedIndex = 0;
            foreach (Client client in clients)
                this.clientComboBox.Items.Add(client.name);
        }