Ejemplo n.º 1
0
        void FillAvgPrice_Age()
        {
            //Calculate average price of the vehicles in the database
            double temp = ManageDB.CalcAvgPriceOfVehicles();

            if (0 == temp)
            {
                AvgPriceLbl.Content = "";
            }
            else
            {
                AvgPriceLbl.Content = temp.ToString("F") + "лв.";
            }

            //Calculate average age of the vehicles in the database
            temp = ManageDB.CalcAvgAgeOfVehicles();
            if (0 == temp)
            {
                AvgAgeLbl.Content = "";
            }
            else
            {
                AvgAgeLbl.Content = temp.ToString("F") + "г.";
            }
        }
Ejemplo n.º 2
0
        void CheckClientInsurancesPreview()
        {
            int count = -1;

            //Check data validity in Egn text control
            if (null == EgnTxt.Text)
            {
                //Egn text control is empty
                MessageBox.Show("Невалидно ЕГН!");
            }
            else if (10 != EgnTxt.Text.Length)
            {
                //Egn text control contains invalid input
                MessageBox.Show("Невалидно ЕГН!");
            }
            else
            {
                //Get the number of insurances for current client
                count = ManageDB.GetInsuranceCountByEgn(EgnTxt.Text);

                //Check the number of insurances found
                if (count == -1)
                {
                    //No insurances found - no need to open preview
                    //Display error msg
                    MessageBox.Show("Няма застраховки на този клиент!");
                }
                else
                {
                    //Open preview of client insurances
                    CheckClientInsurancesPreview preview = new CheckClientInsurancesPreview(count, EgnTxt.Text);
                    preview.Show();
                }
            }
        }
Ejemplo n.º 3
0
        private void IssueLiabBtn_Click(object sender, RoutedEventArgs e)
        {
            //Check input first
            if (false != CheckLiabData())
            {
                Customer tempCust = new Customer();
                Vehicle  tempVeh  = new Vehicle();
                //Check for existing owner in DB
                if (false == ManageDB.CheckForOwnerInDB(EgnTxt.Text, ref tempCust))
                {
                    tempCust = new Customer(OwnerNameTxt.Text, EgnTxt.Text);
                    ManageDB.AddCustInDB(tempCust);
                }
                //Check for existing car in DB
                if (false == ManageDB.CheckForVehInDB(VinTxt.Text, ref tempVeh))
                {
                    tempVeh = new Vehicle(MakeTxt.Text, ModelTxt.Text, int.Parse(YearTxt.Text), int.Parse(MonthTxt.Text), " ",
                                          (VehicleType)VehTypeCmb.SelectedIndex, (CoupeType)7, int.Parse(PowerTxt.Text), " ", VinTxt.Text, tempCust.CustomerId);
                    ManageDB.AddVehInDB(tempVeh);
                }

                //Calculate Liability Insurance price
                double price = Calculations.CalcLiabPrice((VehicleType)VehTypeCmb.SelectedIndex, int.Parse(ExpTxt.Text), int.Parse(PowerTxt.Text),
                                                          int.Parse(EngCapTxt.Text), FuelTypeCmb.SelectedIndex, int.Parse(YearTxt.Text));
                DateTime issueDate = DateTime.Now;
                DateTime dueDate   = DateTime.Now.AddYears(1);
                //Get the id of the new policy
                int insuranceNumb = ManageDB.GetInsuranceCount() + 1;

                Insurance tempIns = new Insurance(insuranceNumb, tempCust.CustomerId, tempVeh.VehicleId, price, issueDate, dueDate, (InsuranceType)1, 0);
                //Save insurance in DB
                ManageDB.AddInsuranceInDB(tempIns);
                //Preview insurance
                IssueLiabPreview previewWin = new IssueLiabPreview(tempIns, tempVeh, tempCust);
                previewWin.Show();
                ClearAllControls();
            }
            else
            {
                //Invalid input -> show error msg
                MessageBox.Show("Въведени са некоректни данни!");
            }
        }
Ejemplo n.º 4
0
 void CheckInsurancesByVinPreview()
 {
     //Check Vin text control for invalid data
     if (VinTxt.Text.Length != 0)
     {
         List <Insurance> tempInsurances = new List <Insurance>();
         //Check if vehicle is in the database
         if (false != ManageDB.CheckForValidInsurancesByVIN(VinTxt.Text, ref tempInsurances))
         {
             //Check if there are insurances for the current vehicle
             if (null != tempInsurances)
             {
                 //Open preview of the insurances
                 CheckInsurancesByVinPreview preview = new CheckInsurancesByVinPreview(VinTxt.Text, tempInsurances);
                 preview.Show();
             }
             else
             {
                 //No insurances found - no need to open preview
                 //Show error msg
                 MessageBox.Show("Няма валидни застраховки за това МПС!");
             }
         }
         else
         {
             //Vehicle is not in database
             //Show error msg
             MessageBox.Show("Несъществуващ VIN!");
         }
     }
     else
     {
         //Input in Vin text control is invalid
         //Show error msg
         MessageBox.Show("Некоректен VIN!");
     }
 }
Ejemplo n.º 5
0
        public void FillData(int count, string Egn)
        {
            //count and Egn are not checked for validity, since they are checked in RefPage.xaml.cs
            Customer         temp             = new Customer();
            List <Insurance> listOfInsurances = new List <Insurance>();

            //Check for the owner in the Database
            if (ManageDB.CheckForOwnerInDB(Egn, ref temp))
            {
                ClientNameLbl.Content = temp.Name;

                //Get list of the insurances for the current client by EGN from Database
                ManageDB.GetClientInsurances(Egn, ref listOfInsurances);
                DataGrid.ItemsSource = listOfInsurances;

                //Display only needed columns from Database
                var col = new DataGridTextColumn();
                col.Header  = "Застраховка №";
                col.Binding = new Binding("Id");
                DataGrid.Columns.Add(col);

                col         = new DataGridTextColumn();
                col.Header  = "МПС №";
                col.Binding = new Binding("VehicleID");
                DataGrid.Columns.Add(col);

                col         = new DataGridTextColumn();
                col.Header  = "Премия(лв.)";
                col.Binding = new Binding("PolicyPrice");
                DataGrid.Columns.Add(col);

                col         = new DataGridTextColumn();
                col.Header  = "Валидна от";
                col.Binding = new Binding("IssueDate");
                DataGrid.Columns.Add(col);

                col         = new DataGridTextColumn();
                col.Header  = "Валидна до";
                col.Binding = new Binding("DueDate");
                DataGrid.Columns.Add(col);

                col         = new DataGridTextColumn();
                col.Header  = "Тип застраховка";
                col.Binding = new Binding("TypeOfInsurance");
                DataGrid.Columns.Add(col);

                col         = new DataGridTextColumn();
                col.Header  = "Застрахователна сума в лв. (Каско)";
                col.Binding = new Binding("InsuranceMoney");
                DataGrid.Columns.Add(col);

                //Set the data grid to read only to prevent change of the data from Database
                DataGrid.IsReadOnly = true;
            }
            else
            {
                ClientNameLbl.Content = "";
                DataGrid.Visibility   = Visibility.Hidden;
                PrintBtn.IsEnabled    = false;
                MessageBox.Show("Няма намерени застраховки за този клиент!");
            }
        }