public IssueCascoPreview(Insurance insure, Vehicle veh, Customer cust) { InitializeComponent(); //Check for null onjects passed to the constructor if (null != insure && null != veh && null != cust) { //Fill preview window FillPreview(insure, veh, cust); } }
void FillPreview(Insurance arg, Vehicle arg2, Customer arg3) { PolicyNmb.Content = arg.Id; OwnerName.Content = arg3.Name; VehType.Content = arg2.VehType.ToString(); Make.Content = arg2.Brand; Model.Content = arg2.Model; Year.Content = arg2.Year; Month.Content = arg2.Month; Vin.Content = arg2.VIN; ValidFrom.Content = arg.IssueDate; ValidDue.Content = arg.DueDate; Price.Content = arg.PolicyPrice + "лв."; }
void FillPreview(Insurance arg, Vehicle arg2, Customer arg3) { PolicyTxt.Content = arg.Id; OwnerTxt.Content = arg3.Name; CoupeTypeTxt.Content = arg2.CoupeType.ToString(); VehTypeTxt.Content = arg2.VehType.ToString(); BrandTxt.Content = arg2.Brand; ModelTxt.Content = arg2.Model; ColorTxt.Content = arg2.Color; PriceTxt.Content = arg.InsuranceMoney; YearsTxt.Content = DateTime.Now.Year - arg2.Year; VINTxt.Content = arg2.VIN; ValidFrom.Content = arg.IssueDate; ValidDue.Content = arg.DueDate; CascoPrice.Content = arg.PolicyPrice + "лв."; }
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("Въведени са некоректни данни!"); } }