Adding document generation
This commit is contained in:
parent
39a61b8655
commit
2748d3c1fe
Binary file not shown.
91
BuechermarktClient/Bills.cs
Normal file
91
BuechermarktClient/Bills.cs
Normal file
@ -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<string, string>();
|
||||
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<decimal>("Price") : 0m;
|
||||
tableBooks.Rows.Add(rowBook);
|
||||
books++;
|
||||
}
|
||||
rowPerson["Total"] = total;
|
||||
|
||||
if (books <= 0) rowPerson.Delete();
|
||||
}
|
||||
WordReportGeneratorOpenXml.BuildDoc(@"Vorlage.docx", "Rechnungen.docx", ds, false);
|
||||
}
|
||||
}
|
||||
}
|
@ -43,6 +43,10 @@
|
||||
<Reference Include="MongoDB.Driver.Core, Version=2.4.4.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MongoDB.Driver.Core.2.4.4\lib\net45\MongoDB.Driver.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MSOfficeUtils, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>bin\Debug\MSOfficeUtils.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
@ -111,6 +115,7 @@
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Backup.cs" />
|
||||
<Compile Include="Bills.cs" />
|
||||
<Compile Include="Books.xaml.cs">
|
||||
<DependentUpon>Books.xaml</DependentUpon>
|
||||
</Compile>
|
||||
|
@ -8,14 +8,19 @@
|
||||
Title="Buechermarkt" Height="350" Width="525" Loaded="Window_Loaded">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"></ColumnDefinition>
|
||||
<ColumnDefinition Width="Auto"></ColumnDefinition>
|
||||
<ColumnDefinition Width="Auto"></ColumnDefinition>
|
||||
<ColumnDefinition Width="Auto"></ColumnDefinition>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Button Grid.Column="0" Content="Buchtypen" HorizontalAlignment="Left" Height="75" Margin="10,10,0,0" VerticalAlignment="Top" Width="100" Click="BookTypes_Click"/>
|
||||
<Button Grid.Column="1" Content="Schüler" HorizontalAlignment="Left" Height="75" Margin="10,10,0,0" VerticalAlignment="Top" Width="100" Click="Students_Click"/>
|
||||
<Button Grid.Column="2" Content="Bücher" HorizontalAlignment="Left" Height="75" Margin="10,10,0,0" VerticalAlignment="Top" Width="100" Click="Books_Click"/>
|
||||
<Button Grid.Column="3" Content="Verkauf" HorizontalAlignment="Left" Height="75" Margin="10,10,0,0" VerticalAlignment="Top" Width="100" Click="Sell_Click"/>
|
||||
<Button Grid.Column="0" Grid.Row="1" Content="Rechnungen" HorizontalAlignment="Left" Height="75" Margin="10,10,0,0" VerticalAlignment="Top" Width="100" Click="Bills_Click"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
@ -190,5 +190,10 @@ namespace BuechermarktClient
|
||||
{
|
||||
SellWindow = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void Bills_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Bills.GenerateBills();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
Binary file not shown.
BIN
BuechermarktClient/bin/Debug/DocumentFormat.OpenXml.dll
Normal file
BIN
BuechermarktClient/bin/Debug/DocumentFormat.OpenXml.dll
Normal file
Binary file not shown.
BIN
BuechermarktClient/bin/Debug/MSOfficeUtils.dll
Normal file
BIN
BuechermarktClient/bin/Debug/MSOfficeUtils.dll
Normal file
Binary file not shown.
BIN
BuechermarktClient/bin/Debug/Vorlage.docx
Normal file
BIN
BuechermarktClient/bin/Debug/Vorlage.docx
Normal file
Binary file not shown.
BIN
BuechermarktClient/bin/Debug/VorlageOK.docx
Normal file
BIN
BuechermarktClient/bin/Debug/VorlageOK.docx
Normal file
Binary file not shown.
BIN
BuechermarktClient/bin/Debug/VorlageReleasebackup.docx
Normal file
BIN
BuechermarktClient/bin/Debug/VorlageReleasebackup.docx
Normal file
Binary file not shown.
BIN
BuechermarktClient/bin/Debug/Vorlage_NOK1.docx
Normal file
BIN
BuechermarktClient/bin/Debug/Vorlage_NOK1.docx
Normal file
Binary file not shown.
BIN
BuechermarktClient/bin/Debug/Vorlage_nok2.docx
Normal file
BIN
BuechermarktClient/bin/Debug/Vorlage_nok2.docx
Normal file
Binary file not shown.
BIN
BuechermarktClient/bin/Debug/libeay32.dll
Normal file
BIN
BuechermarktClient/bin/Debug/libeay32.dll
Normal file
Binary file not shown.
BIN
BuechermarktClient/bin/Debug/ssleay32.dll
Normal file
BIN
BuechermarktClient/bin/Debug/ssleay32.dll
Normal file
Binary file not shown.
@ -1,4 +1,4 @@
|
||||
#pragma checksum "..\..\Books.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "44BD7615D26D5FEC9EFA881E8C45705C6284CAD1"
|
||||
#pragma checksum "..\..\Books.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "481E063FEC297502455DF4EB43DDEC60F85C900E"
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Dieser Code wurde von einem Tool generiert.
|
||||
@ -41,7 +41,7 @@ namespace BuechermarktClient {
|
||||
public partial class Books : System.Windows.Window, System.Windows.Markup.IComponentConnector, System.Windows.Markup.IStyleConnector {
|
||||
|
||||
|
||||
#line 30 "..\..\Books.xaml"
|
||||
#line 32 "..\..\Books.xaml"
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||
internal System.Windows.Controls.ListView BooksList;
|
||||
|
||||
@ -80,18 +80,26 @@ namespace BuechermarktClient {
|
||||
{
|
||||
case 1:
|
||||
|
||||
#line 28 "..\..\Books.xaml"
|
||||
((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Search_Click);
|
||||
#line 27 "..\..\Books.xaml"
|
||||
((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Button_Click);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
return;
|
||||
case 2:
|
||||
|
||||
#line 30 "..\..\Books.xaml"
|
||||
((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Search_Click);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
return;
|
||||
case 3:
|
||||
this.BooksList = ((System.Windows.Controls.ListView)(target));
|
||||
return;
|
||||
case 4:
|
||||
case 5:
|
||||
|
||||
#line 46 "..\..\Books.xaml"
|
||||
#line 48 "..\..\Books.xaml"
|
||||
((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.AddNew_Click);
|
||||
|
||||
#line default
|
||||
@ -111,11 +119,11 @@ namespace BuechermarktClient {
|
||||
System.Windows.EventSetter eventSetter;
|
||||
switch (connectionId)
|
||||
{
|
||||
case 3:
|
||||
case 4:
|
||||
eventSetter = new System.Windows.EventSetter();
|
||||
eventSetter.Event = System.Windows.Controls.Control.PreviewMouseDoubleClickEvent;
|
||||
|
||||
#line 42 "..\..\Books.xaml"
|
||||
#line 44 "..\..\Books.xaml"
|
||||
eventSetter.Handler = new System.Windows.Input.MouseButtonEventHandler(this.ListViewItem_PreviewMouseUp);
|
||||
|
||||
#line default
|
||||
|
@ -1,4 +1,4 @@
|
||||
#pragma checksum "..\..\Books.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "44BD7615D26D5FEC9EFA881E8C45705C6284CAD1"
|
||||
#pragma checksum "..\..\Books.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "481E063FEC297502455DF4EB43DDEC60F85C900E"
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Dieser Code wurde von einem Tool generiert.
|
||||
@ -41,7 +41,7 @@ namespace BuechermarktClient {
|
||||
public partial class Books : System.Windows.Window, System.Windows.Markup.IComponentConnector, System.Windows.Markup.IStyleConnector {
|
||||
|
||||
|
||||
#line 30 "..\..\Books.xaml"
|
||||
#line 32 "..\..\Books.xaml"
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||
internal System.Windows.Controls.ListView BooksList;
|
||||
|
||||
@ -80,18 +80,26 @@ namespace BuechermarktClient {
|
||||
{
|
||||
case 1:
|
||||
|
||||
#line 28 "..\..\Books.xaml"
|
||||
((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Search_Click);
|
||||
#line 27 "..\..\Books.xaml"
|
||||
((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Button_Click);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
return;
|
||||
case 2:
|
||||
|
||||
#line 30 "..\..\Books.xaml"
|
||||
((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Search_Click);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
return;
|
||||
case 3:
|
||||
this.BooksList = ((System.Windows.Controls.ListView)(target));
|
||||
return;
|
||||
case 4:
|
||||
case 5:
|
||||
|
||||
#line 46 "..\..\Books.xaml"
|
||||
#line 48 "..\..\Books.xaml"
|
||||
((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.AddNew_Click);
|
||||
|
||||
#line default
|
||||
@ -111,11 +119,11 @@ namespace BuechermarktClient {
|
||||
System.Windows.EventSetter eventSetter;
|
||||
switch (connectionId)
|
||||
{
|
||||
case 3:
|
||||
case 4:
|
||||
eventSetter = new System.Windows.EventSetter();
|
||||
eventSetter.Event = System.Windows.Controls.Control.PreviewMouseDoubleClickEvent;
|
||||
|
||||
#line 42 "..\..\Books.xaml"
|
||||
#line 44 "..\..\Books.xaml"
|
||||
eventSetter.Handler = new System.Windows.Input.MouseButtonEventHandler(this.ListViewItem_PreviewMouseUp);
|
||||
|
||||
#line default
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user