public async Task <IActionResult> CreateOrder([FromBody] OrderIn orderIn) { if (ModelState.IsValid) { var summoner = await _riotApiClient.GetSummonerDetailsAsync(orderIn.AccountUsername, orderIn.SummonerServer); var summonerLeagues = await _riotApiClient.GetLeagueDetailsAsync(summoner); //TODO: Store the summoner and league info in DB??? var order = orderIn.ToOrder(); if (order.IsValid(summoner, summonerLeagues)) { var user = await _userManager.FindByNameAsync(this.User.Identity.Name); order.CustomerId = user.Id; order.OrderStatus = EOrderStatus.WaitingVerification; _orderRepository.Add(order); await _orderRepository.SaveChangesAsync(); var orderOut = new OrderOut { ClientId = order.Customer.Id, AccountUsername = order.AccountUsername, AccountPassword = order.AccountPassword }; return(Created($"{ControllerContext.ActionDescriptor.ControllerName}/{order.OrderId}", orderOut)); } } return(BadRequest()); }
public async Task <IActionResult> GetOrder(int id) { var order = _orderRepository.Find(id); //TODO: create mapping order -> orderOut var orderOut = new OrderOut(); return(Ok(orderOut)); }
private void SaveToDB(object obj) { List <OrderLineOut> lines = new List <OrderLineOut>(); foreach (var item in ProductsOrdered) { lines.Add(new OrderLineOut() { EAN_Product = item.EAN, UnitPrice = item.UnitPrice, NumberOfProducts = item.Count, }); } DateTime nu = DateTime.Now; OrderOut bestelling = new OrderOut() { Id_Client = SelectedClient.Id, OrderLineOuts = lines, Id_InvoiceCreatedBy = _appDbRespository.Employee.InloggedEmployee.Id, Id_PreparedBy = _appDbRespository.Employee.InloggedEmployee.Id, Id_SoldBy = _appDbRespository.Employee.InloggedEmployee.Id, InvoiceCreatedAt = nu, PreparedAt = nu, SoldAt = nu, }; try { _appDbRespository.OrderOut.Add(bestelling); } catch (Exception ex) { MessageBox.Show(ex.Message + ex.InnerException); return; } string filename = PDFinvoice.Create(bestelling.Id, _appDbRespository); if (MessageBoxResult.Yes == MessageBox.Show("Verkoop met succes geregistreerd\n wil je het factuur openen?", "openen", MessageBoxButton.YesNo, MessageBoxImage.Question)) { Process.Start(filename); } //enkel als effectief gesaved is _isSavedToDB = true; }
public async Task <ActionResult> Customer(CustomerModel customer) { var customerResponse = await customerService.CreateCustomer(customer); if (customerResponse == null) { HttpResponseModel resp = new HttpResponseModel(); resp.ReasonMessage = "Something went wrong."; return(View("Failure", resp)); } OrderOut order = new OrderOut(); List <CartProduct> products = ((List <CartProduct>)Session["cart"]); order.CustomerId = customerResponse.Id; order.ShopId = customer.ShopId; order.ShippingAddress = customer.Address; order.BillingAddress = customer.Address; order.Products = products; var orderResponse = await orderService.CreateOrder(order); if (orderResponse == null) { HttpResponseModel resp = new HttpResponseModel(); resp.ReasonMessage = "Something went wrong."; return(View("Failure", resp)); } Session["cart"] = null; var Configuration = await service.GetShopConfig(customer.ShopId); ViewBag.BgColor = Configuration.BgColor; ViewBag.MenuColor = Configuration.MenuColor; ViewBag.MenuTextColor = Configuration.MenuTextColor; ViewBag.ProductsInCart = 0; return(View("Order", orderResponse)); }
public static void LoadTestData(AppRepository <KfsContext> appRespository) { //als deze gebruiker bestaat, returnen, data moet niet opnieuw opgeslagen worden EmployeeRepository.EmployeeLoggedInDTO tmpTest = appRespository.Employee.LogIn("Tom_0123", "Tom_0123"); if (tmpTest != null) { return; } #region =============================== MIN APPLICATIE VEREISTE ==================================== #region ------------------------------------------- Add Departments------------------------------ EmpDepartment newDep_admin = new EmpDepartment() { DefaultPermissions = 0b0111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111, DescriptionNL = "Administrator", DescriptionEN = "Administrator" }; appRespository.EmpDepartment.Add(newDep_admin); EmpDepartment newDep_Sales = new EmpDepartment() { DefaultPermissions = 0b0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_1111_1111_1111_1111_1111, DescriptionEN = "Sales", DescriptionNL = "Verkoop" }; appRespository.EmpDepartment.Add(newDep_Sales); EmpDepartment newDep_Warehouse = new EmpDepartment() { DefaultPermissions = 0b0000_0000_0000_0000_1111_1111_1111_1111_1111_1111_0000_0000_0000_0000_0000_0000, DescriptionEN = "Ware House", DescriptionNL = "Magazijn" }; appRespository.EmpDepartment.Add(newDep_Warehouse); #endregion -------------------------------------------------------------------------------------- #region ------------------------------------------- Add Contract types--------------------------- EmpContractType newContrType_onbDuur = new EmpContractType() { DescriptionEN = "Indefinitely", DescriptionNL = "Onbepaalde duur" }; appRespository.EmpContractType.Add(newContrType_onbDuur); EmpContractType newContrType_jobstudent = new EmpContractType() { DescriptionEN = "Student job", DescriptionNL = "Jobstudent" }; appRespository.EmpContractType.Add(newContrType_jobstudent); EmpContractType newContrType_interim = new EmpContractType() { DescriptionEN = "Interim", DescriptionNL = "Interim" }; appRespository.EmpContractType.Add(newContrType_interim); #endregion -------------------------------------------------------------------------------------- #region ------------------------------------------- Add EmpContractStatuutType------------------- EmpContractStatuutType empContrStatuutType_arbeider = new EmpContractStatuutType { DescriptionEN = "Worker", DescriptionNL = "Arbeider" }; appRespository.EmpContractStatuutType.Add(empContrStatuutType_arbeider); EmpContractStatuutType empContrStatuutType_bediende = new EmpContractStatuutType { DescriptionEN = "Servant", DescriptionNL = "Bediende" }; appRespository.EmpContractStatuutType.Add(empContrStatuutType_bediende); EmpContractStatuutType empContrStatuutType_Ambtenaar = new EmpContractStatuutType { DescriptionEN = "Civil servant", DescriptionNL = "Ambtenaar" }; appRespository.EmpContractStatuutType.Add(empContrStatuutType_Ambtenaar); #endregion -------------------------------------------------------------------------------------- #region ------------------------------------------- Add ProductType------------------------------ ProductType productType_Dranken = new ProductType() { DescriptionNL = "Dranken", DescriptionEN = "Drinks" }; appRespository.ProductType.Add(productType_Dranken); ProductType productType_Speelgoed = new ProductType() { DescriptionNL = "Speelgoed", DescriptionEN = "Toys" }; appRespository.ProductType.Add(productType_Speelgoed); ProductType productType_Voedingswaren = new ProductType() { DescriptionNL = "Voedingswaren", DescriptionEN = "Foodstuffs" }; appRespository.ProductType.Add(productType_Voedingswaren); ProductType productType_AutoOnderdelen = new ProductType() { DescriptionNL = "Auto onderdelen", DescriptionEN = "Car parts" }; appRespository.ProductType.Add(productType_AutoOnderdelen); #endregion -------------------------------------------------------------------------------------- #region employee_TomDilen amdin met alle rechten Employee employee_TomDilen = new Employee() { //-------------------personMin--------- FirstName = "Tom", //NameAddition = "niet vereist", LastName = "Dilen", Email = "*****@*****.**", MobileNumber = "0123 11 22 33", //PhoneNumber = "niet vereist", //navprops //-------------------Person------------ DateOfBirth = new DateTime(1981, 04, 22), IsMale = true, //nav props EmpAddress = new EmpAddress() { Street = "Duivenstraat", HouseNumber = 55, //HouseNumberAddition = "nvt", Zipcode = "2300", City = "Turnhout", Country = "Belgium" }, //-------------------Employee---------- PassPortID = "0122222111", IBAN = "12220132145545", JobInfo = "waarken lak een biest", ExtraInfo = "zag er ne toffe gast uit bij de sollicitatie", //navProps //id voor departement is genoeg :-) Id_EmpDepartment = 1, //1=Administrator, 2=Verkoop, 3=Magazijn EmpContract = new EmpContract() { MonthSalary = 2222.22f, DateOfStart = new DateTime(2020, 12, 2), Id_EmpContractStatuutType = 1, // 1=Arbeider, 2=Bediende, 3=Ambtenaar Id_EmpContractType = 1 // 1=Onbepaalde duur, 2=Jobstudent, 3=Interim }, EmpAppAccount = new EmpAppAccount { //AppPermissions = 0b0100_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_1111_1111_1111_1111_1111, AppPermissions = 0b0111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111, Password = "******", UserName = "******", IsPaswordResseted = true, LastResetted = DateTime.Now, IsBlocked = false, InlogAttempts = 0, } }; appRespository.Employee.Add(employee_TomDilen); //inloggen EmployeeRepository.EmployeeLoggedInDTO IngelogdGebruiker = appRespository.Employee.LogIn("Tom_0123", "Tom_0123"); if (IngelogdGebruiker == null) { System.Windows.Forms.MessageBox.Show("null"); } else { System.Windows.Forms.MessageBox.Show("joepi, ingelogd"); } #endregion #endregion ================================================================================================== #region ------------------------------------------- Add Employees ------------------------------ #region employee_MaggieDeBlock Employee employee_MaggieDeBlock = new Employee() { //-------------------personMin--------- FirstName = "Maggie", NameAddition = "De", LastName = "Block", Email = "*****@*****.**", MobileNumber = "0123 45 67 89", PhoneNumber = "23 23 23 23 23", //navprops //-------------------Person------------ DateOfBirth = new DateTime(1981, 04, 22), IsMale = true, //nav props EmpAddress = new EmpAddress() { Street = "vetstraat", HouseNumber = 55, //HouseNumberAddition = "nvt", Zipcode = "1000", City = "Brussel", Country = "Belgium" }, //-------------------Employee---------- PassPortID = "01222244444", IBAN = "12220132148888", JobInfo = "mondmaskers verbranden", ExtraInfo = "toffe griet yoh", //navProps //id voor departement is genoeg :-) Id_EmpDepartment = 3, //1=Administrator, 2=Verkoop, 3=Magazijn EmpContract = new EmpContract() { MonthSalary = 1400.22f, DateOfStart = new DateTime(1950, 11, 22), Id_EmpContractStatuutType = 2, // 1=Arbeider, 2=Bediende, 3=Ambtenaar Id_EmpContractType = 2 // 1=Onbepaalde duur, 2=Jobstudent, 3=Interim }, //EmpAppAccount = new EmpAppAccount //{ // AppPermissions = Int64.MaxValue, // Password = "******", // UserName = "******", // IsPaswordResseted = true, // LastResetted = DateTime.Now, // IsBlocked = false, // InlogAttempts = 0, //} }; appRespository.Employee.Add(employee_MaggieDeBlock); #endregion #region employee_AlexanderDeCroo Employee employee_AlexanderDeCroo = new Employee() { //-------------------personMin--------- FirstName = "Alexander", NameAddition = "De", LastName = "Kraai", Email = "*****@*****.**", MobileNumber = "0123 45 67 40", PhoneNumber = "23 23 23 23 98", //navprops //-------------------Person------------ DateOfBirth = new DateTime(1982, 04, 1), IsMale = true, //nav props EmpAddress = new EmpAddress() { Street = "wetstraat", HouseNumber = 55, //HouseNumberAddition = "nvt", Zipcode = "1040", City = "Vettigem", Country = "Duitsland" }, //-------------------Employee---------- PassPortID = "5555555555", IBAN = "121212121212", JobInfo = "Graaien in de vetpot", ExtraInfo = "nen echte fille de papa", //navProps //id voor departement is genoeg :-) Id_EmpDepartment = 2, //1=Administrator, 2=Verkoop, 3=Magazijn EmpContract = new EmpContract() { MonthSalary = 1200.22f, DateOfStart = new DateTime(1970, 11, 22), Id_EmpContractStatuutType = 3, // 1=Arbeider, 2=Bediende, 3=Ambtenaar Id_EmpContractType = 3 // 1=Onbepaalde duur, 2=Jobstudent, 3=Interim }, EmpAppAccount = new EmpAppAccount { AppPermissions = Int64.MaxValue, Password = "******", UserName = "******", IsPaswordResseted = true, LastResetted = DateTime.Now, IsBlocked = false, InlogAttempts = 0, } }; appRespository.Employee.Add(employee_AlexanderDeCroo); #endregion #endregion -------------------------------------------------------------------------------------- #region ------------------------------------------- Add Suppliers-------------------------------- Supplier supPConderdelen = new Supplier() { CmpManagers = new List <CmpManager>() { new CmpManager() { FirstName = "TomsupPConderdelen", //NameAddition = "van", LastName = "ManagersupPConderdelen", Email = "*****@*****.**", MobileNumber = "0114", PhoneNumber = "222222244522" } }, CompanyNumber = "551555555", Name = "supPConderdelen Turnhout", Website = "supPConderdelenTurnhout.be", BtwNumber = "BE 4555555", Email = "*****@*****.**", ExtraInfo = "dit is extrainfo over supPConderdelen turnhout", CmpIBANs = new List <CmpIBAN>() { new CmpIBAN { Number = "222-22222-22-222", IsDefault = true } }, CmpSites = new List <CmpSite>() { new CmpSite() { IsDefault = true, CmpSiteAddress = new CmpSiteAddress() { Street = "gasthuissstraat", HouseNumber = 55, HouseNumberAddition = "22", Country = "Belgie", Zipcode = "2000", City = "Antwerpen" }, Fax = "222222222", PhoneNumber = "012345678", PhoneNumber_2 = "555220", MobileNumber = "014556699", Email = "*****@*****.**", ExtraInfo = "extra info over hoofdsite van supPConderdelen Turnhout", CmpSiteContactPersons = new List <CmpSiteContactPerson>() { new CmpSiteContactPerson() { FirstName = "TomsupPConderdelenContact", //NameAddition = "van", LastName = "DilenContact", Email = "*****@*****.**", MobileNumber = "0111111111121", PhoneNumber = "2222222222", IsDefault = true, ExtraInfo = "geen extra info over dez contactpersoon van supPConderdelen" } }, }, }, }; appRespository.Supplier.Add(supPConderdelen); Supplier supCocaCola = new Supplier() { CmpManagers = new List <CmpManager>() { new CmpManager() { FirstName = "TomCocaCola", //NameAddition = "van", LastName = "DilenManager", Email = "*****@*****.**", MobileNumber = "011111111111", PhoneNumber = "222222222" } }, CompanyNumber = "55555555", Name = "Cocacola Turnhout", Website = "CocColaTurnhout.be", BtwNumber = "BE 444444444", Email = "*****@*****.**", ExtraInfo = "dit is extrainfo over coca cola turnhout", CmpIBANs = new List <CmpIBAN>() { new CmpIBAN { Number = "222-22222-22-222", IsDefault = true } }, CmpSites = new List <CmpSite>() { new CmpSite() { IsDefault = true, CmpSiteAddress = new CmpSiteAddress() { Street = "druivenstraat", HouseNumber = 55, HouseNumberAddition = "22", Country = "Belgie", Zipcode = "2300", City = "Turnhout" }, Fax = "1111111111", PhoneNumber = "4444444444", PhoneNumber_2 = "2222222222", MobileNumber = "55555555", Email = "*****@*****.**", ExtraInfo = "extra info over hoofdsite van cococola Turnhout", CmpSiteContactPersons = new List <CmpSiteContactPerson>() { new CmpSiteContactPerson() { FirstName = "TomCocaColaContact", //NameAddition = "van", LastName = "DilenContact", Email = "*****@*****.**", MobileNumber = "011111111111", PhoneNumber = "222222222", IsDefault = true, ExtraInfo = "geen extra info over dez contactpersoon" } }, }, }, }; appRespository.Supplier.Add(supCocaCola); //======================================================================================== Supplier supKenField = new Supplier() { CmpManagers = new List <CmpManager>() { new CmpManager() { FirstName = "Ken", //NameAddition = "van", LastName = "Field", Email = "*****@*****.**", MobileNumber = "0478670924", //PhoneNumber = "222222244522" } }, CompanyNumber = "000111222", Name = "KenFieldSupplier", Website = "KenFieldSupplier.be", BtwNumber = "BE 4555588", Email = "*****@*****.**", ExtraInfo = "Teacher .Net developper at Multimedi", CmpIBANs = new List <CmpIBAN>() { new CmpIBAN { Number = "2222222222", IsDefault = true } }, CmpSites = new List <CmpSite>() { new CmpSite() { IsDefault = true, CmpSiteAddress = new CmpSiteAddress() { Street = "Avenue de Kenfield", HouseNumber = 55, //HouseNumberAddition = "22", Country = "KenLand", Zipcode = "9999", City = "Fieldegem" }, Fax = "222222222", PhoneNumber = "0478670924", }, }, }; appRespository.Supplier.Add(supKenField); #endregion -------------------------------------------------------------------------------------- #region ------------------------------------------- Add Clients --------------------------------- Client client_TimAudenaarde = new Client { IsActive = true, CltWebCredentials = new CltWebCredentials() { Password = "******", UserName = "******", InlogAttempts = 0, IsBlocked = false, IsPaswordResseted = false, LastResetted = DateTime.Now, }, FirstName = "Tim", //NameAddition , LastName = "Audenaarde", Email = "*****@*****.**", MobileNumber = "0123456", PhoneNumber = "", DateOfBirth = new DateTime(1980, 04, 01), IsMale = true, CltAddresss = new List <CltAddress>() { new CltAddress() { Street = "TimseSteenweg", HouseNumber = 33, HouseNumberAddition = "b3", Country = "Belgie", Zipcode = "1000", City = "Bornem" } }, }; appRespository.Client.Add(client_TimAudenaarde); //================================================================================== Client client_KennyBruwier = new Client { IsActive = true, CltWebCredentials = new CltWebCredentials() { Password = "******", UserName = "******", InlogAttempts = 0, IsBlocked = false, IsPaswordResseted = false, LastResetted = DateTime.Now, }, FirstName = "Kenny", //NameAddition , LastName = "Bruwier", Email = "kweetnognie", MobileNumber = "2222222", PhoneNumber = "014555555", DateOfBirth = new DateTime(1975, 04, 01), IsMale = true, CltAddresss = new List <CltAddress>() { new CltAddress() { Street = "Avenue le Kennedy", HouseNumber = 66, //HouseNumberAddition = "b3", Country = "Belgie", Zipcode = "1000", City = "RupelMonde" } }, }; appRespository.Client.Add(client_KennyBruwier); #endregion -------------------------------------------------------------------------------------- #region ------------------------------------------- Add Products--------------------------------- Product product_Spaghetti = new Product() { //--------- id = EAN (geen oplopend nummer) EAN = "1111111111", ProductTitle = "Spaghetti Bolognaise", //ExtraInfo = "", SellingPriceRecommended = 5.22f, CountInStock = 0, MinCountInStock = 100, MaxCountInStock = 500, WareHouseLocation = "H44,01", BTWpercentage = 6, Id_ProductType = 2, //producType 1=Speelgoed, 2=Voedingswaren 3=Autoonderdelen //Image }; appRespository.Product.Add(product_Spaghetti); Product product_Ballenbad = new Product() { //--------- id = EAN (geen oplopend nummer) EAN = "222222222", ProductTitle = "Ballen bad", //ExtraInfo = "", SellingPriceRecommended = 105.22f, CountInStock = 0, MinCountInStock = 5, MaxCountInStock = 10, WareHouseLocation = "H44,02", BTWpercentage = 21, Id_ProductType = 1, //producType 1=Speelgoed, 2=Voedingswaren 3=Autoonderdelen //Image }; appRespository.Product.Add(product_Ballenbad); Product product_DoosLego = new Product() { //--------- id = EAN (geen oplopend nummer) EAN = "33333333", ProductTitle = "Lego StormMinds", //ExtraInfo = "", SellingPriceRecommended = 205.22f, CountInStock = 0, MinCountInStock = 6, MaxCountInStock = 20, WareHouseLocation = "H20,01", BTWpercentage = 21, Id_ProductType = 1, //producType 1=Speelgoed, 2=Voedingswaren 3=Autoonderdelen //Image Supplier_Product_Prices = new List <Supplier_Product_Price>() { new Supplier_Product_Price() { UnitPrice = 44.44f, Id_Supplier = 1, EAN_Product = "222222222" } } }; appRespository.Product.Add(product_DoosLego); Product product_NummerPlatenAuto = new Product() { //--------- id = EAN (geen oplopend nummer) EAN = "444444444", ProductTitle = "Nummerplaat", //ExtraInfo = "", SellingPriceRecommended = 15.99f, CountInStock = 0, MinCountInStock = 20, MaxCountInStock = 80, WareHouseLocation = "H47,02", BTWpercentage = 21, Id_ProductType = 3, //producType 1=Speelgoed, 2=Voedingswaren 3=Autoonderdelen //Image }; appRespository.Product.Add(product_NummerPlatenAuto); #endregion -------------------------------------------------------------------------------------- #region ------------------------------------------- Add OrdersIn -------------------------------- OrderIn bestellengOut_1 = new OrderIn() { Id_OrderedBy = 1, Id_Supplier = 1, OrderedAt = DateTime.Now, OrderLineIns = new List <OrderLineIn>() { new OrderLineIn() { EAN_Product = "222222222", UnitPrice = 22.2f, NumberOfProducts = 5 }, new OrderLineIn() { EAN_Product = "444444444", UnitPrice = 33.2f, NumberOfProducts = 5 } } }; appRespository.OrderIn.Add(bestellengOut_1); #endregion -------------------------------------------------------------------------------------- #region ------------------------------------------- Add OrdersOut-------------------------------- OrderOut bestelling_In1 = new OrderOut() { Id_Client = 1, OrderLineOuts = new List <OrderLineOut>() { new OrderLineOut() { EAN_Product = "222222222", UnitPrice = 22.33f, NumberOfProducts = 4 }, new OrderLineOut() { EAN_Product = "444444444", UnitPrice = 22.33f, NumberOfProducts = 4 } } }; appRespository.OrderOut.Add(bestelling_In1); #endregion -------------------------------------------------------------------------------------- #region ------------------------------------------- Add Quatations------------------------------- ProductQuotation quotation1 = new ProductQuotation() { UnitPrice = 10.20f, DateQuatation = DateTime.Now, ExtraInfo = "goei materiaal", EAN_Product = "8888888", Id_Supplier = 1 }; appRespository.ProductQuotation.Add(quotation1); //ProductQuotation quotation2 = new ProductQuotation() //{ // UnitPrice = 10.20f, // DateQuatation = DateTime.Now, // //DateRegistered = // ExtraInfo = "", // Id_Product = 2 //}; //appRespository.ProductQuotation.Add(quotation2); #endregion -------------------------------------------------------------------------------------- #region ------------------------------------------- Add Departments------------------------------ #endregion -------------------------------------------------------------------------------------- #region ------------------------------------------- Add Departments------------------------------ #endregion -------------------------------------------------------------------------------------- #region ------------------------------------------- Add Departments------------------------------ #endregion -------------------------------------------------------------------------------------- #region ------------------------------------------- Add Departments------------------------------ #endregion -------------------------------------------------------------------------------------- #region ------------------------------------------- Add Departments------------------------------ #endregion -------------------------------------------------------------------------------------- #region ------------------------------------------- Add Departments------------------------------ #endregion -------------------------------------------------------------------------------------- #region ------------------------------------------- Add Departments------------------------------ #endregion -------------------------------------------------------------------------------------- //} //catch (Exception ex) //{ // System.Windows.Forms.MessageBox.Show(ex.Message); //} } } }
//============================================================================= public static string Create(OrderOut aOrderOut) { if (aOrderOut == null) { throw new KeyNotFoundException("kan order niet vinden in DB"); } string filename = PATH_TO_INVOICES + aOrderOut.Id.ToString("D8") + ".pdf"; if (File.Exists(filename)) { return(filename); } PdfDocument document = new PdfDocument(); PdfPage page = document.AddPage(); XGraphics g = XGraphics.FromPdfPage(page); XBrush zwart = XBrushes.Black; XFont font = new XFont("Arial", 10, XFontStyle.Bold); const string FONT_FAMILYNAME = "Arial"; //write heading g.DrawString("Factuur ", font, zwart, 20, 20); const double X_EAN_LIJN = 40; const double X_BESCHRIJVING_LIJN = 130; const double X_AANTAL_LIJN = 290; const double X_EENHEIDSPRIJS_LIJN = 330; const double X_EXC_BTW_LIJN = 380; const double X_BTWpercent_LIJN = 430; const double X_BTW_LIJN = 460; const double X_INC_BTW_LIJN = 510; const double Y_TABEL = 320; const double Y_SPACE_BETWEEN_HEADER_AND_FIRST_ROW = 20; const double Y_SPACE_BETWEEN_ROWS = 15; const double RANDMARGE_IN_CELL = 3; XFont FONT_HEADER = new XFont(FONT_FAMILYNAME, 10, XFontStyle.Bold); XFont FONT_ROWS = new XFont(FONT_FAMILYNAME, 8); XFont FONT_CLIENT = new XFont(FONT_FAMILYNAME, 14); XTextFormatter textRechts = new XTextFormatter(g); textRechts.Alignment = XParagraphAlignment.Right; XTextFormatter textLinks = new XTextFormatter(g); textLinks.Alignment = XParagraphAlignment.Left; XTextFormatter textMidden = new XTextFormatter(g); textMidden.Alignment = XParagraphAlignment.Center; //================================================================================================================================ //teken images XImage logo = XImage.FromFile(@"C:\Users\Tompie_HD2\source\repos\KFSolutions\KFSolutionsWPF\bin\Debug\images\PDFhoofding.jpg"); g.DrawImage(logo, new XRect(0, 0, 600, 200)); //teken klantgegevens textRechts.DrawString("KLANT:", FONT_CLIENT, XBrushes.DarkGreen, new XRect(0, 65, 550, 20)); textRechts.DrawString(aOrderOut.Client.FirstName + " " + aOrderOut.Client.NameAddition + " " + aOrderOut.Client.LastName, FONT_CLIENT, XBrushes.DarkGreen, new XRect(0, 92, 550, 20)); textRechts.DrawString(aOrderOut.Client.CltAddresss.ToList()[0].Street + " " + aOrderOut.Client.CltAddresss.ToList()[0].HouseNumber + " " + aOrderOut.Client.CltAddresss.ToList()[0].HouseNumberAddition, FONT_CLIENT, XBrushes.DarkGreen, new XRect(0, 115, 550, 20)); textRechts.DrawString(aOrderOut.Client.CltAddresss.ToList()[0].Zipcode + " " + aOrderOut.Client.CltAddresss.ToList()[0].City, FONT_CLIENT, XBrushes.DarkGreen, new XRect(0, 138, 550, 20)); textRechts.DrawString( aOrderOut.Client.CltAddresss.ToList()[0].Country, FONT_CLIENT, XBrushes.DarkGreen, new XRect(0, 161, 550, 20)); //factuur en nummer textMidden.DrawString("FAKTUUR: " + aOrderOut.Id.ToString("D8"), new XFont(FONT_FAMILYNAME, 18, XFontStyle.Bold), XBrushes.DarkGreen, new XRect(20, 250, 550, 20)); //factuurdatum //------------ textLinks.DrawString("Faktuurdatum:" + aOrderOut.InvoiceCreatedAt, FONT_HEADER, XBrushes.Black, new XRect(X_EAN_LIJN, Y_TABEL - 19, 90, 0)); //tabelhoofdings //-------------- textMidden.DrawString("EAN", FONT_HEADER, XBrushes.Black, new XRect(X_EAN_LIJN, Y_TABEL, 90, 0)); textMidden.DrawString("Omschrijving", FONT_HEADER, XBrushes.Black, new XRect(X_BESCHRIJVING_LIJN, Y_TABEL, 160, 0)); textMidden.DrawString("Aantal", FONT_HEADER, XBrushes.Black, new XRect(X_AANTAL_LIJN, Y_TABEL, 40, 0)); textMidden.DrawString("Prijs/st", FONT_HEADER, XBrushes.Black, new XRect(X_EENHEIDSPRIJS_LIJN, Y_TABEL, 50, 0)); textMidden.DrawString("Excl. Btw", FONT_HEADER, XBrushes.Black, new XRect(X_EXC_BTW_LIJN, Y_TABEL, 50, 0)); textMidden.DrawString("%", FONT_HEADER, XBrushes.Black, new XRect(X_BTWpercent_LIJN, Y_TABEL, 30, 0)); textMidden.DrawString("Btw", FONT_HEADER, XBrushes.Black, new XRect(X_BTW_LIJN, Y_TABEL, 50, 0)); textMidden.DrawString("Incl. Btw", FONT_HEADER, XBrushes.Black, new XRect(X_INC_BTW_LIJN, Y_TABEL, 50, 0)); //tabel tekenen //------------- double TTwithoutBTW = 0; double TTwithBTW = 0; double ypos = Y_TABEL + Y_SPACE_BETWEEN_HEADER_AND_FIRST_ROW; foreach (var item in aOrderOut.OrderLineOuts) { double lineWithoutBTW = item.NumberOfProducts * item.UnitPrice; double btwAdd = lineWithoutBTW / 100.0f * item.Product.BTWpercentage; double lineWithBTW = lineWithoutBTW + btwAdd; TTwithBTW += lineWithBTW; TTwithoutBTW += lineWithoutBTW; textLinks.DrawString(item.Product.EAN, FONT_ROWS, XBrushes.Black, new XRect(X_EAN_LIJN + RANDMARGE_IN_CELL, ypos, 100, 0)); textLinks.DrawString(item.Product.ProductTitle, FONT_ROWS, XBrushes.Black, new XRect(X_BESCHRIJVING_LIJN + RANDMARGE_IN_CELL, ypos, 100, 0)); textMidden.DrawString(item.NumberOfProducts.ToString(), FONT_ROWS, XBrushes.Black, new XRect(X_AANTAL_LIJN, ypos, 40, 0)); textRechts.DrawString(String.Format("{0:0.00}", item.UnitPrice), FONT_ROWS, XBrushes.Black, new XRect(X_EENHEIDSPRIJS_LIJN - RANDMARGE_IN_CELL, ypos, 50, 0)); textRechts.DrawString(String.Format("{0:0.00}", lineWithoutBTW), FONT_ROWS, XBrushes.Black, new XRect(X_EXC_BTW_LIJN - RANDMARGE_IN_CELL, ypos, 50, 0)); textRechts.DrawString(String.Format("{0:0.00}", item.Product.BTWpercentage), FONT_ROWS, XBrushes.Black, new XRect(X_BTWpercent_LIJN - RANDMARGE_IN_CELL, ypos, 30, 0)); textRechts.DrawString(String.Format("{0:0.00}", btwAdd), FONT_ROWS, XBrushes.Black, new XRect(X_BTW_LIJN - RANDMARGE_IN_CELL, ypos, 50, 0)); textRechts.DrawString(String.Format("{0:0.00}", lineWithBTW), FONT_ROWS, XBrushes.Black, new XRect(X_INC_BTW_LIJN - RANDMARGE_IN_CELL, ypos, 50, 0)); ypos += Y_SPACE_BETWEEN_ROWS; } //---------------------------------------------------------- //kader tekenen //---------------------------------------------------------- XPen kaderPen = new XPen(XColors.Black, 1); double Y_CORRECTY_KADER_BEGIN = -5; double Y_CORRECTY_KADER_EIND = 0; double X_CORRECTY_KADER = 0; //vertikale lijnen g.DrawLine(kaderPen, X_EAN_LIJN + X_CORRECTY_KADER, Y_TABEL + Y_CORRECTY_KADER_BEGIN, X_EAN_LIJN + X_CORRECTY_KADER, ypos + Y_CORRECTY_KADER_EIND); g.DrawLine(kaderPen, X_BESCHRIJVING_LIJN + X_CORRECTY_KADER, Y_TABEL + Y_CORRECTY_KADER_BEGIN, X_BESCHRIJVING_LIJN + X_CORRECTY_KADER, ypos + Y_CORRECTY_KADER_EIND); g.DrawLine(kaderPen, X_AANTAL_LIJN + X_CORRECTY_KADER, Y_TABEL + Y_CORRECTY_KADER_BEGIN, X_AANTAL_LIJN + X_CORRECTY_KADER, ypos + Y_CORRECTY_KADER_EIND); g.DrawLine(kaderPen, X_EENHEIDSPRIJS_LIJN + X_CORRECTY_KADER, Y_TABEL + Y_CORRECTY_KADER_BEGIN, X_EENHEIDSPRIJS_LIJN + X_CORRECTY_KADER, ypos + Y_CORRECTY_KADER_EIND); g.DrawLine(kaderPen, X_EXC_BTW_LIJN + X_CORRECTY_KADER, Y_TABEL + Y_CORRECTY_KADER_BEGIN, X_EXC_BTW_LIJN + X_CORRECTY_KADER, ypos + Y_CORRECTY_KADER_EIND); g.DrawLine(kaderPen, X_BTWpercent_LIJN + X_CORRECTY_KADER, Y_TABEL + Y_CORRECTY_KADER_BEGIN, X_BTWpercent_LIJN + X_CORRECTY_KADER, ypos + Y_CORRECTY_KADER_EIND); g.DrawLine(kaderPen, X_BTW_LIJN + X_CORRECTY_KADER, Y_TABEL + Y_CORRECTY_KADER_BEGIN, X_BTW_LIJN + X_CORRECTY_KADER, ypos + Y_CORRECTY_KADER_EIND); g.DrawLine(kaderPen, X_INC_BTW_LIJN + X_CORRECTY_KADER, Y_TABEL + Y_CORRECTY_KADER_BEGIN, X_INC_BTW_LIJN + X_CORRECTY_KADER, ypos + Y_CORRECTY_KADER_EIND); //laatste hor lijn g.DrawLine(kaderPen, 50 + X_INC_BTW_LIJN + X_CORRECTY_KADER, Y_TABEL + Y_CORRECTY_KADER_BEGIN, 50 + X_INC_BTW_LIJN + X_CORRECTY_KADER, ypos + Y_CORRECTY_KADER_EIND); //horizontale lijnen g.DrawLine(kaderPen, X_EAN_LIJN, Y_TABEL + Y_CORRECTY_KADER_BEGIN, 50 + X_INC_BTW_LIJN, Y_TABEL + Y_CORRECTY_KADER_BEGIN); double YhorLijn = Y_SPACE_BETWEEN_HEADER_AND_FIRST_ROW + Y_TABEL + Y_CORRECTY_KADER_BEGIN; g.DrawLine(kaderPen, X_EAN_LIJN, YhorLijn, 50 + X_INC_BTW_LIJN, YhorLijn); //ypos is de positie waar de vertikale lijnen stopte met tekenen g.DrawLine(kaderPen, X_EAN_LIJN, ypos, 50 + X_INC_BTW_LIJN, ypos); textLinks.DrawString("Order aangemaakt door: " + aOrderOut.SoldBy.FirstName + " " + aOrderOut.SoldBy.NameAddition + " " + aOrderOut.SoldBy.LastName, FONT_HEADER, XBrushes.Black, new XRect(X_EAN_LIJN, ypos + 12, 600, 0)); ypos += 10; g.DrawLine(kaderPen, X_EAN_LIJN, ypos, 50 + X_INC_BTW_LIJN, ypos); ypos += 6; textRechts.DrawString("Excl BTW:", FONT_ROWS, XBrushes.Black, new XRect(0, ypos, 480, 20)); textRechts.DrawString(String.Format("{0:0.00}", TTwithoutBTW) + "€", FONT_ROWS, XBrushes.Black, new XRect(0, ypos, 560, 20)); ypos += 11; textRechts.DrawString("BTW:", FONT_ROWS, XBrushes.Black, new XRect(0, ypos, 480, 20)); textRechts.DrawString(String.Format("{0:0.00}", TTwithBTW - TTwithoutBTW) + "€", FONT_ROWS, XBrushes.Black, new XRect(0, ypos, 560, 20)); ypos += 15; g.DrawLine(kaderPen, X_EAN_LIJN, ypos, 50 + X_INC_BTW_LIJN, ypos); ypos += 8; textRechts.DrawString("Totaal:", FONT_HEADER, XBrushes.Black, new XRect(0, ypos, 480, 20)); textRechts.DrawString(String.Format("{0:0.00}", TTwithBTW) + "€", FONT_HEADER, XBrushes.Black, new XRect(0, ypos, 560, 20)); ypos += 18; g.DrawLine(kaderPen, X_EAN_LIJN, ypos, 50 + X_INC_BTW_LIJN, ypos); //footer tekenen g.DrawLine(kaderPen, X_EAN_LIJN, 750, 50 + X_INC_BTW_LIJN, 750); g.DrawLine(kaderPen, X_EAN_LIJN, 800, 50 + X_INC_BTW_LIJN, 800); g.DrawLine(kaderPen, X_EAN_LIJN, 800, 50 + X_INC_BTW_LIJN, 800); document.Save(filename); return(filename); }