private void SetPrices(OfferteDTO dto, Offerte retVal) { var voorschot = retVal.Voorschot / 100m; var totalePrijs = retVal.GetTotalePrijs(); var btw = retVal.GetBtw(); dto.TotaalNettoPrijs = totalePrijs.ToString("#.00"); if (btw == 0.00m) { dto.PrijsIfBtw0 = "-"; dto.TotaalPrijsIncBtw = totalePrijs.ToString("#.00"); } if (btw == 0.06m) { var tax = totalePrijs * 0.06m; dto.PrijsIfBtw6 = tax.ToString("#.00"); dto.TotaalPrijsIncBtw = (totalePrijs + tax).ToString("#.00"); } if (btw == 0.21m) { var tax = totalePrijs * 0.21m; dto.PrijsIfBtw21 = tax.ToString("#.00"); dto.TotaalPrijsIncBtw = (totalePrijs + tax).ToString("#.00"); } dto.PrijsVoorschot = (decimal.Parse(dto.TotaalPrijsIncBtw) * voorschot).ToString("0.00"); dto.PrijsLeftOver = (decimal.Parse(dto.TotaalPrijsIncBtw) - decimal.Parse(dto.PrijsVoorschot)).ToString("0.00"); }
public EditOfferteViewModel(FestiSpecProvider dataServer, OfferteViewModel previousPage) { _dataServer = dataServer; _previousPage = previousPage; _offerte = previousPage.SelectedOfferte.OfferteModel; SaveDataCommand = new RelayCommand(SaveData); }
public static void UpdateOfferte(Offerte o) { using (var context = new FestiSpecDBEntities()) { context.Entry(o).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } }
public void UpdateDecision(int quotationId, string decision) { using (FestispecContext context = new FestispecContext()) { Offerte toUpdate = context.Offerte.FirstOrDefault(q => q.OfferteID == quotationId); toUpdate.KlantbeslissingReden = decision; context.SaveChanges(); } }
public void CreateQuotation(Offerte quotation) { using (FestispecContext context = new FestispecContext()) { Opdracht job = context.Opdracht.FirstOrDefault(j => j.OpdrachtID == quotation.OpdrachtID); job.Offerte.Add(quotation); context.SaveChanges(); } }
public static void RemoveOfferte(Offerte o) { using (var context = new FestiSpecDBEntities()) { context.Offerte.Attach(o); context.Offerte.Remove(o); context.SaveChanges(); } }
public void UpdateQuotation(Offerte quotation) { using (FestispecContext context = new FestispecContext()) { Offerte toUpdate = context.Offerte.FirstOrDefault(q => q.OfferteID == quotation.OfferteID); quotation.Aanmaakdatum = toUpdate.Aanmaakdatum; context.Entry(toUpdate).CurrentValues.SetValues(quotation); context.SaveChanges(); } }
private void SetWorkItems(OfferteDTO dto, Offerte retVal) { var max = retVal.Werklijnen.Count(); dto.WorkItems = new WerkLine[6]; for (int i = 0; i < 6; i++) { if (i < max) { dto.WorkItems[i] = retVal.Werklijnen[i]; } else { dto.WorkItems[i] = null; } } }
private OfferteDTO ConvertToTemplate(Offerte retVal) { var klantNummer = string.Format($"{retVal?.Klant?.Adres?.StraatNaam} {retVal?.Klant?.Adres?.HuisNummer} {retVal?.Klant?.Adres?.BusNummer}"); var dto = new OfferteDTO { Datum = retVal.Datum.Date.ToString("dd-MM-yyyy"), VervalDatum = retVal.VervalDatum.Date.ToString("dd-MM-yyyy"), KlantBtw = retVal?.Klant?.Contact?.BtwNummer ?? "", KlantEmail = retVal?.Klant?.Contact?.Email, KlantNaam = retVal?.Klant?.Naam, KlantPostcodeGemeente = $"{retVal?.Klant?.Adres?.Postcode} {retVal?.Klant?.Adres?.Gemeente}", KlantRef = retVal?.Klant?.KlantenRef.ToString("00000"), KlantStraatNummer = klantNummer.Trim(), KlantTelefoon = retVal?.Klant?.Contact?.TelefoonNummer, OfferteNummer = retVal.OfferteNummer, PrijsIfBtw0 = "", PrijsIfBtw21 = "", PrijsIfBtw6 = "", PrijsLeftOver = "", PrijsVoorschot = "", TotaalNettoPrijs = "", TotaalPrijsIncBtw = "", }; SetWorkItems(dto, retVal); SetPrices(dto, retVal); dto.Item1 = dto.WorkItems[0]?.Omschrijving?.Omschrijving; dto.Item2 = dto.WorkItems[1]?.Omschrijving?.Omschrijving; dto.Item3 = dto.WorkItems[2]?.Omschrijving?.Omschrijving; dto.Item4 = dto.WorkItems[3]?.Omschrijving?.Omschrijving; dto.Item5 = dto.WorkItems[4]?.Omschrijving?.Omschrijving; dto.Item6 = dto.WorkItems[5]?.Omschrijving?.Omschrijving; dto.Item1Prijs = dto.WorkItems[0]?.BrutoPrijs.ToString("#.00"); dto.Item2Prijs = dto.WorkItems[1]?.BrutoPrijs.ToString("#.00"); dto.Item3Prijs = dto.WorkItems[2]?.BrutoPrijs.ToString("#.00"); dto.Item4Prijs = dto.WorkItems[3]?.BrutoPrijs.ToString("#.00"); dto.Item5Prijs = dto.WorkItems[4]?.BrutoPrijs.ToString("#.00"); dto.Item6Prijs = dto.WorkItems[5]?.BrutoPrijs.ToString("#.00"); return(dto); }
public OfferteVM() { OfferteModel = new Offerte(); }
public OfferteVM(Offerte offerte) { OfferteModel = offerte; }
private InspectieVM CreateTemplate() { //id of current user int GebruikerId = dataServer._gebruiker.Id; Klant klant = new Klant { Bedrijfsnaam = "Template bedrijf", Email = "*****@*****.**", Telefoonnummer = "0612345678", Postcode = "4581FJ", Huisnummer = 68 }; Offerte offerte = new Offerte { Prijs = 100.15, Toelichting = "Template offerte", Betaald = 0 }; Inspectie newInspectie = new Inspectie { RegistrantId = GebruikerId, Klant = klant, Status = new Status { Naam = "Geregistreerd" }, Offerte = offerte }; //does the offerte template already exist? int offertecount = dataServer.GetOfferte().Count(o => o.Toelichting.Equals("Template offerte")); //add offerte template to database if (offertecount == 0) { this.dataServer.AddOfferte(offerte); } //add template klant to database try { this.dataServer.AddKlant(klant); } catch (Exception e) { } //get id of TemplateKlant int templateKlantId = 0; var templateklant = dataServer.GetKlanten().Where(t => t.Bedrijfsnaam.Equals("Template bedrijf")); foreach (KlantVM t in templateklant) { templateKlantId = t.Id; } //get id of TemplateOfferte int templateOfferteId = 0; var templateOfferte = dataServer.GetOfferte().Where(o => o.Toelichting.Equals("Template offerte")); foreach (OfferteVM t in templateOfferte) { templateOfferteId = t.Id; } //set Id's for new inspectie newInspectie.Offerte.Id = templateOfferteId; newInspectie.OfferteId = templateOfferteId; newInspectie.Klant.Id = templateKlantId; newInspectie.KlantId = templateKlantId; //new inspection with template values InspectieVM inspectie = new InspectieVM(newInspectie) { Id = 0, Postcode = "5302XC", Datum = new DateTime(2019, 1, 1), StatusNaam = "Geregistreerd", Huisnummer = 52, Wens = "Het inspecteren van het festival", Inspecteur = new GebruikerVM { Id = GebruikerId, Naam = "Template", Achternaam = "van Festispec", Wachtwoord = "Template", Postcode = "5308LJ", Telefoonnummer = "0645781296", Huisnummer = 61, GeboorteDatum = new DateTime(1996, 1, 1), Email = "*****@*****.**", }, InspectieDatum = new DateTime(2019, 2, 1), Naam = "Template Inspectie" }; //does the template already exist? int templatecount = dataServer.GetInspecties().Count(i => i.Naam.Equals("Template Inspectie")); //add template to database if (templatecount == 0) { this.dataServer.AddInspection(inspectie); } return(inspectie); }