Exemple #1
0
 private void FillSubBattaryInfoForm(Battary battary)
 {
     subBattaryTypeTextBox.Text               = battary.Type.ToString();
     subBattarySerialNumberTextBox.Text       = battary.SerialNumber;
     subBattaryNomenclatureNumberTextBox.Text = battary.NomenclatureNumber;
     subBattarySetDateTextBox.Text            = battary.SetDate?.ToString("dd.MM.yyyy");
 }
Exemple #2
0
        public MainWindow()
        {
            //CodeSamples.TestOledbConnection();

            var fileUpdater = new FileUpdater();

            fileUpdater.CopyBattaryTableToLocalDirectory();
            fileUpdater.CopyCarTableToLocalDirectory();
            //using (var databaseOperations = new OleDatabaseOperations(Properties.Settings.Default.tableName))
            //{
            //    databaseOperations.UpdateSourceTable();
            //}


            InitializeComponent();

            documentManager = new DocumentManager();

            selectedCar        = null;
            selectedBattary    = null;
            selectedSubBattary = null;

            InitCarCollection();
            InitSubBattariesCollection();
        }
        public static List <Battary> GetBattaryCollection()
        {
            var battaryList = new List <Battary>();

            var databaseOperations = new OleDatabaseOperations();
            var battatiesQuery     = databaseOperations.GetBattariesQuery();

            foreach (var row in battatiesQuery)
            {
                if (row["llist"].ToString() == "False")
                {
                    var battary = new Battary
                    {
                        Type               = row["tipa"].ToString(),
                        SerialNumber       = row["nomak"].ToString(),
                        NomenclatureNumber = row["nnomak"].ToString()
                    };

                    DateTime setDate      = default(DateTime);
                    DateTime writeOffDate = default(DateTime);

                    if (DateTime.TryParse(row["datspis"].ToString(), out writeOffDate))
                    {
                        battary.WriteOffDate = writeOffDate;
                        if (writeOffDate.Year < 1900)
                        {
                            var a = 1;
                        }
                    }
                    else
                    {
                        battary.WriteOffDate = null;
                    }

                    if (DateTime.TryParse(row["datpol"].ToString(), out setDate))
                    {
                        battary.SetDate = setDate;
                    }
                    else
                    {
                        battary.SetDate = null;
                    }

                    if (battary.WriteOffDate != null)
                    {
                        if (battary.WriteOffDate?.Year != 1899)
                        {
                            continue;
                        }
                    }

                    battaryList.Add(battary);
                }
            }
            return(battaryList);
        }
Exemple #4
0
        private void SubBattaryListView_Click(object sender, RoutedEventArgs e)
        {
            ClearSubBattaryInfoForm();
            var item = (sender as ListView).SelectedItem;

            if (item != null)
            {
                var battary = item as Battary;
                selectedSubBattary = battary;
                FillSubBattaryInfoForm(battary);
            }
        }
        public static List <Car> GetCarCollection()
        {
            var databaseOperations = new OleDatabaseOperations();
            var carsQuery          = databaseOperations.GetDistinctCarsQuery();
            var battatiesQuery     = databaseOperations.GetBattariesQuery();

            var cars = new List <Car>();


            foreach (var row in carsQuery)
            {
                if (row["llist"].ToString() != "False")
                {
                    var car = new Car
                    {
                        Id        = int.Parse(row["gnaid"].ToString()),
                        Number    = row["gn"].ToString(),
                        Model     = row["nm"].ToString(),
                        Battaries = new List <Battary>()
                    };
                    cars.Add(car);
                }
            }

            foreach (var row in battatiesQuery)
            {
                if (row["llist"].ToString() != "False")
                {
                    var battary = new Battary
                    {
                        Type               = row["tipa"].ToString(),
                        SerialNumber       = row["nomak"].ToString(),
                        NomenclatureNumber = row["nnomak"].ToString()
                    };

                    DateTime setDate      = default(DateTime);
                    DateTime writeOffDate = default(DateTime);

                    if (DateTime.TryParse(row["datspis"].ToString(), out writeOffDate))
                    {
                        battary.WriteOffDate = writeOffDate;
                    }
                    else
                    {
                        battary.WriteOffDate = null;
                    }

                    if (DateTime.TryParse(row["datpol"].ToString(), out setDate))
                    {
                        battary.SetDate = setDate;
                    }
                    else
                    {
                        battary.SetDate = null;
                    }

                    if (battary.WriteOffDate != null)
                    {
                        continue;
                    }

                    int carId = int.Parse(row["gnaid"].ToString());
                    cars.Where(car => car.Id == carId).First().Battaries.Add(battary);
                }
            }
            return(cars);
        }