From 2748d3c1fe9d31871d8931f394fe3821962bd5b8 Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 13 Dec 2017 21:04:00 +0100 Subject: [PATCH] Adding document generation --- .vs/BuechermarktClient/v15/.suo | Bin 119808 -> 136192 bytes BuechermarktClient/Bills.cs | 91 ++++++++++++++++++ BuechermarktClient/BuechermarktClient.csproj | 5 + BuechermarktClient/MainWindow.xaml | 13 ++- BuechermarktClient/MainWindow.xaml.cs | 7 +- .../bin/Debug/BuechermarktClient.exe | Bin 69632 -> 74240 bytes .../bin/Debug/BuechermarktClient.pdb | Bin 142848 -> 148992 bytes .../bin/Debug/DocumentFormat.OpenXml.dll | Bin 0 -> 5697312 bytes .../bin/Debug/MSOfficeUtils.dll | Bin 0 -> 24064 bytes BuechermarktClient/bin/Debug/Vorlage.docx | Bin 0 -> 20300 bytes BuechermarktClient/bin/Debug/VorlageOK.docx | Bin 0 -> 20008 bytes .../bin/Debug/VorlageReleasebackup.docx | Bin 0 -> 20300 bytes .../bin/Debug/Vorlage_NOK1.docx | Bin 0 -> 20901 bytes .../bin/Debug/Vorlage_nok2.docx | Bin 0 -> 20764 bytes BuechermarktClient/bin/Debug/libeay32.dll | Bin 0 -> 2000384 bytes BuechermarktClient/bin/Debug/ssleay32.dll | Bin 0 -> 325120 bytes BuechermarktClient/obj/Debug/Books.g.cs | 24 +++-- BuechermarktClient/obj/Debug/Books.g.i.cs | 24 +++-- .../obj/Debug/BuechermarktClient.exe | Bin 69632 -> 74240 bytes 19 files changed, 143 insertions(+), 21 deletions(-) create mode 100644 BuechermarktClient/Bills.cs create mode 100644 BuechermarktClient/bin/Debug/DocumentFormat.OpenXml.dll create mode 100644 BuechermarktClient/bin/Debug/MSOfficeUtils.dll create mode 100644 BuechermarktClient/bin/Debug/Vorlage.docx create mode 100644 BuechermarktClient/bin/Debug/VorlageOK.docx create mode 100644 BuechermarktClient/bin/Debug/VorlageReleasebackup.docx create mode 100644 BuechermarktClient/bin/Debug/Vorlage_NOK1.docx create mode 100644 BuechermarktClient/bin/Debug/Vorlage_nok2.docx create mode 100644 BuechermarktClient/bin/Debug/libeay32.dll create mode 100644 BuechermarktClient/bin/Debug/ssleay32.dll diff --git a/.vs/BuechermarktClient/v15/.suo b/.vs/BuechermarktClient/v15/.suo index 2b7e5ff321cfbd8d90a3fabbad5703eba121adea..25e50198882d1d1df623b08cf0a56da00d1a5e75 100644 GIT binary patch delta 17471 zcmeG@3v^Rew)dtm5*;d6-JiMsN++rMS&R^fw%WfQqt0-<+)tTaeBIT z&bjCAv(G+f@3YT2d*Al$cJ13O>W`0gVHk#oz$Gt+`4twZ?&`H`*Qk!la}eh3H$2A< z@`_jqg!4k@jAZAyYEAF5Vtl2{1vAgg3uNIEuUI0&8aD)Ne+|4B#6XYBQUS}y8n{y$ z0ZBYJ52E=r0wp(K`N4O1V95tzD}pNm_3no`5xYW^tVxK^eF*Ldfe8KxggYPe00b$5 z4R?b#9ouTgx7p&#{)h zF!#2WeKGg5mi;jgu$Jdy9%L9@(0L*g>`J}S86(D>QA6mt5nHTMn%*b&? z&4ZDkG=V41@Lu?icPrMWjMw^L?PJ#3Bui~DUlN8S79!aC5=as4*`eg^>{1x;OT>ld zF&LEX!Ned=ls(@4_@EzJ%SXJ|gh}juLl^mMFMBU^1>;a@5vAB+3rq1~%mXgpQsBXo zov>*<%>$UCbskJ4*4|>*1TIAP3BSdP^TA-gwZMa0l%)JNPCZCd@tI4K0YjvKlQIsko8(F%9^neYRRoSnY@=hk7!%XXG%~H= z?joH|WWjuXI<~e6TQG(Ef*i?@#LOl`_-H7n5P{hHKKL%O5RM9y!4%cU8sK7-PC~Xp zMjT?|G*S;;S9(KqSVc2U>E94GAZ$d~gaBS{fiX5aLHRbUw0|D7K0ipvdN-xw87z>Q z{w>081VVn!n(x8<-x2mAJa4VrZ_S6^;IYaOd(u>X9pAoT!-#TWv)B)Yj4rI~rX)&) z>?KNS=18I>MVmx9X7HIbfI%o{T2Y>DjFG7U_e&X)1gs80K=R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0EZ= z1GlHdfI+<81}(zX22SsJr}Bv>J_!@ibKW_KbU9);=1dAESH$obdOOU3S4l1@kIG5~ zeWr`0h4i8J+3|?3cK8%l@hPiToY+VwO4k!GNBpdfPEnR8VZBK2fOWRo#fxrPzTm<8 zR@}k~z=cN*sz=Q1gj>DVV|w0N=uoW?+Z*F$CCpyJd+8VrW_DGi&|t3CswpB@@9B91 z>=R6=VAj%0uEduBrEDian^=!YjH<8DCY^^Q7C*(|tYx;LY6v$|96liopg2Tec-If6 zL%KhZKqWoA-35~#bf+c|<;pek_CN(JFavdXzLAGv)3BDX$)qidFC*Z1AEo1cieIYg zC%Ut{l=x%@3H^*pG>1d8LU|QBwVG-;F((uMK=KHiCcJ^Bw0Pwwj(71&nla-r$&L_? z5||GChVI7*ZxW6Z-XfeJpd-lvA7Rb#QIV|nF^SF+&JpOxfZEQX;4*TaF||`&?IqT@ zGH#lY4^PQKT?)}|fk&`uayh!J4wxdkqhQj1g5Y&pVVZoKqhPEkx58&PnchvNca!P; z-!MJij4w#xCgZ!w_y+L88)STxS?Yy9 zjva@mH5MV;AfL{1di0#K^aG{7@7SqNOgLH-p(UEf2R*Sio_5bFp@!7 z23bVo%1ATke?j3gVq?gaA>Ipj;riH-MB@xHw#JUf$>$E-S)ZJxIkf?8)8Rm=m(D%^UD9_asLFolyk@c diff --git a/BuechermarktClient/Bills.cs b/BuechermarktClient/Bills.cs new file mode 100644 index 0000000..ae91d5b --- /dev/null +++ b/BuechermarktClient/Bills.cs @@ -0,0 +1,91 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using MongoDB.Driver; +using MSOfficeUtils.Word; + +namespace BuechermarktClient +{ + class Bills + { + public static void GenerateBills() + { + var ds = new DataSet(); + var tableRechnung = new DataTable("Rechnung"); + tableRechnung.Columns.Add("ID", typeof(bool)); + ds.Tables.Add(tableRechnung); + + var tablePerson = new DataTable("Person"); + tablePerson.Columns.Add("ID", typeof(string)); + tablePerson.Columns.Add("Forname", typeof(string)); + tablePerson.Columns.Add("Lastname", typeof(string)); + tablePerson.Columns.Add("EMail", typeof(string)); + tablePerson.Columns.Add("PhoneNumber", typeof(string)); + tablePerson.Columns.Add("Form", typeof(string)); + tablePerson.Columns.Add("Total", typeof(decimal)); + tablePerson.Columns.Add("Rechnung", typeof(bool)); + ds.Tables.Add(tablePerson); + + var tableBooks = new DataTable("Books"); + tableBooks.Columns.Add("Student", typeof(string)); + tableBooks.Columns.Add("Title", typeof(string)); + tableBooks.Columns.Add("LabelId", typeof(string)); + tableBooks.Columns.Add("Price", typeof(decimal)); + ds.Tables.Add(tableBooks); + + ds.Relations.Add(new DataRelation("Person", tableRechnung.Columns["ID"], tablePerson.Columns["Rechnung"])); + ds.Relations.Add(new DataRelation("Books", tablePerson.Columns["ID"], tableBooks.Columns["Student"])); + + var types = MainWindow.BookTypeCollection.AsQueryable(); + var typesDict = new Dictionary(); + foreach(var type in types) + { + typesDict.Add(type.ID.ToString(), type.Name); + } + + var rowRechung = tableRechnung.NewRow(); + rowRechung["ID"] = true; + tableRechnung.Rows.Add(rowRechung); + + foreach (var student in MainWindow.StudentCollection.AsQueryable().OrderBy(r => r.Form).ThenBy(r => r.Lastname)) + { + var rowPerson = tablePerson.NewRow(); + rowPerson["ID"] = student.ID.ToString(); + rowPerson["Forname"] = student.Forname; + rowPerson["Lastname"] = student.Lastname; + rowPerson["EMail"] = student.EMail; + rowPerson["PhoneNumber"] = student.PhoneNumber; + rowPerson["Form"] = student.Form; + rowPerson["Rechnung"] = true; + tablePerson.Rows.Add(rowPerson); + + var total = 0m; + var books = 0; + foreach (var book in MainWindow.BookCollection.AsQueryable().Where(r=>r.Student == student.ID).OrderBy(r=>r.Price)) + { + var rowBook = tableBooks.NewRow(); + rowBook["Student"] = rowPerson["ID"]; + try + { + rowBook["Title"] = typesDict[book.BookType.ToString()]; + } catch + { + rowBook["Title"] = "Unbekannt"; + } + rowBook["LabelId"] = book.LabelId; + rowBook["Price"] = book.State == Models.BookState.BackToStudent ? (object)DBNull.Value : book.Price; + total += !rowBook.IsNull("Price") ? rowBook.Field("Price") : 0m; + tableBooks.Rows.Add(rowBook); + books++; + } + rowPerson["Total"] = total; + + if (books <= 0) rowPerson.Delete(); + } + WordReportGeneratorOpenXml.BuildDoc(@"Vorlage.docx", "Rechnungen.docx", ds, false); + } + } +} diff --git a/BuechermarktClient/BuechermarktClient.csproj b/BuechermarktClient/BuechermarktClient.csproj index f727c7a..0df5113 100644 --- a/BuechermarktClient/BuechermarktClient.csproj +++ b/BuechermarktClient/BuechermarktClient.csproj @@ -43,6 +43,10 @@ ..\packages\MongoDB.Driver.Core.2.4.4\lib\net45\MongoDB.Driver.Core.dll + + False + bin\Debug\MSOfficeUtils.dll + ..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll @@ -111,6 +115,7 @@ Code + Books.xaml diff --git a/BuechermarktClient/MainWindow.xaml b/BuechermarktClient/MainWindow.xaml index 806dbfc..20e686e 100644 --- a/BuechermarktClient/MainWindow.xaml +++ b/BuechermarktClient/MainWindow.xaml @@ -8,14 +8,19 @@ Title="Buechermarkt" Height="350" Width="525" Loaded="Window_Loaded"> - - - - + + + + + + + +