Sevral bugs ar efixed, like braodcast spamming
This commit is contained in:
parent
51d1119776
commit
ebb86f46e6
@ -17,7 +17,7 @@ namespace BuechermarktClient
|
||||
|
||||
var ts = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
|
||||
var process = new Process();
|
||||
process.StartInfo.FileName = "mongodump.exe";
|
||||
process.StartInfo.FileName = ".\\mongodump.exe";
|
||||
process.StartInfo.Arguments = "--host " + MainWindow.MongoHost + " --db " + MainWindow.DatabaseName + " --gzip --out .\\backups\\" + ts;
|
||||
process.StartInfo.RedirectStandardOutput = true;
|
||||
process.StartInfo.UseShellExecute = false;
|
||||
|
@ -75,7 +75,7 @@ namespace BuechermarktClient
|
||||
list = MainWindow.BookTypeCollection.FindSync((b) => true).ToList();
|
||||
not = false;
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (MongoExecutionTimeoutException)
|
||||
{
|
||||
Thread.Sleep(200);
|
||||
}
|
||||
@ -84,11 +84,25 @@ namespace BuechermarktClient
|
||||
var show = new List<BookType>();
|
||||
if(SearchField != null && SearchField != String.Empty)
|
||||
{
|
||||
foreach(var e in list)
|
||||
if (SearchField == "%d%")
|
||||
{
|
||||
if (e.ISBN.ToLower().Contains(SearchField.ToLower()) || e.Name.ToLower().Contains(SearchField.ToLower()))
|
||||
foreach (var e in list)
|
||||
{
|
||||
show.Add(e);
|
||||
foreach (var e2 in list)
|
||||
{
|
||||
if (e.ID == e2.ID) continue;
|
||||
if (e.ISBN == e2.ISBN) show.Add(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var e in list)
|
||||
{
|
||||
if (e.ISBN.ToLower().Contains(SearchField.ToLower()) || e.Name.ToLower().Contains(SearchField.ToLower()))
|
||||
{
|
||||
show.Add(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -87,7 +87,7 @@ namespace BuechermarktClient
|
||||
}
|
||||
Close();
|
||||
return;
|
||||
} catch (Exception)
|
||||
} catch (MongoExecutionTimeoutException)
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
@ -106,7 +106,7 @@ namespace BuechermarktClient
|
||||
}
|
||||
Close();
|
||||
return;
|
||||
} catch (Exception)
|
||||
} catch (MongoExecutionTimeoutException)
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
|
@ -24,7 +24,7 @@
|
||||
<ColumnDefinition Width="Auto"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Content="Search:" Grid.Column="0"></Label>
|
||||
<TextBox Grid.Column="1" Text="{Binding SearchField, Mode=OneWayToSource}"></TextBox>
|
||||
<TextBox Grid.Column="1" Text="{Binding SearchField, Mode=Default, UpdateSourceTrigger=PropertyChanged}"></TextBox>
|
||||
<Button Content="S" Grid.Column="2" Width="25" Click="Search_Click"/>
|
||||
</Grid>
|
||||
<ListView Grid.Row="1" Margin="0,0,0,0" Name="BooksList">
|
||||
|
@ -9,6 +9,7 @@ using System.Windows.Data;
|
||||
using System.Globalization;
|
||||
using MongoDB.Bson;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace BuechermarktClient
|
||||
{
|
||||
@ -61,12 +62,33 @@ namespace BuechermarktClient
|
||||
/// <summary>
|
||||
/// Interaktionslogik für Books.xaml
|
||||
/// </summary>
|
||||
public partial class Books : Window
|
||||
public partial class Books : Window, INotifyPropertyChanged
|
||||
{
|
||||
public Thread RefreshThread = null;
|
||||
private bool ThreadRunning = true;
|
||||
|
||||
public string SearchField { get; set; }
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
protected void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
private string _SearchField;
|
||||
public string SearchField
|
||||
{
|
||||
get
|
||||
{
|
||||
return _SearchField;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != _SearchField)
|
||||
{
|
||||
_SearchField = value;
|
||||
OnPropertyChanged("SearchField");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Books()
|
||||
{
|
||||
@ -75,6 +97,7 @@ namespace BuechermarktClient
|
||||
RefreshThread.Start();
|
||||
RefreshThread.IsBackground = true;
|
||||
Closing += Book_Closing;
|
||||
DataContext = this;
|
||||
}
|
||||
|
||||
private void Book_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
@ -102,7 +125,7 @@ namespace BuechermarktClient
|
||||
{
|
||||
list = MainWindow.BookCollection.FindSync((b) => true).ToList();
|
||||
not = false;
|
||||
} catch (Exception e)
|
||||
} catch (MongoExecutionTimeoutException)
|
||||
{
|
||||
Thread.Sleep(200);
|
||||
}
|
||||
@ -111,11 +134,25 @@ namespace BuechermarktClient
|
||||
var show = new List<Models.Book>();
|
||||
if (SearchField != null && SearchField != String.Empty)
|
||||
{
|
||||
foreach (var e in list)
|
||||
if (SearchField == "%d%")
|
||||
{
|
||||
if (e.LabelId.ToLower().Contains(SearchField.ToLower()) || e.Price.ToString().ToLower().Contains(SearchField.ToLower()) || e.Student.ToString().ToLower().Contains(SearchField.ToLower()) || e.BookType.ToString().ToLower().Contains(SearchField.ToLower()) || e.State.ToString().ToLower().Contains(SearchField.ToLower()))
|
||||
foreach (var e in list)
|
||||
{
|
||||
show.Add(e);
|
||||
foreach (var e2 in list)
|
||||
{
|
||||
if (e.ID == e2.ID) continue;
|
||||
if (e.LabelId == e2.LabelId) show.Add(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var e in list)
|
||||
{
|
||||
if (e.LabelId.ToLower().Contains(SearchField.ToLower()) || e.Price.ToString().ToLower().Contains(SearchField.ToLower()) || e.Student.ToString().ToLower().Contains(SearchField.ToLower()) || e.BookType.ToString().ToLower().Contains(SearchField.ToLower()) || e.State.ToString().ToLower().Contains(SearchField.ToLower()))
|
||||
{
|
||||
show.Add(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -123,7 +160,7 @@ namespace BuechermarktClient
|
||||
{
|
||||
if(list.Count > 100)
|
||||
{
|
||||
for(int i = 0; i < 150; i++)
|
||||
for(int i = 0; i < 100; i++)
|
||||
{
|
||||
show.Add(list[i]);
|
||||
}
|
||||
|
@ -17,6 +17,10 @@ namespace BuechermarktClient
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if((double)value == 0)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return value?.ToString();
|
||||
}
|
||||
|
||||
@ -25,6 +29,7 @@ namespace BuechermarktClient
|
||||
var style = NumberStyles.AllowDecimalPoint;
|
||||
var c = CultureInfo.CreateSpecificCulture("de-DE");
|
||||
if (value == null) return null;
|
||||
if ((string)value == "") return 0;
|
||||
if (!double.TryParse((string)value, style, c, out double outD)) return null;
|
||||
return outD;
|
||||
}
|
||||
@ -62,7 +67,7 @@ namespace BuechermarktClient
|
||||
try
|
||||
{
|
||||
return MainWindow.StudentCollection.Find(s => s.ID == Book.Student).FirstOrDefault();
|
||||
} catch (Exception)
|
||||
} catch (MongoExecutionTimeoutException)
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
@ -76,7 +81,7 @@ namespace BuechermarktClient
|
||||
OnPropertyChanged("Student");
|
||||
} else if(value == null)
|
||||
{
|
||||
Book.Student = new MongoDB.Bson.ObjectId(string.Empty);
|
||||
Book.Student = new MongoDB.Bson.ObjectId();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -98,7 +103,8 @@ namespace BuechermarktClient
|
||||
try
|
||||
{
|
||||
Student = MainWindow.StudentCollection.Find(s => s.LabelId.Equals(value)).FirstOrDefault();
|
||||
} catch (Exception)
|
||||
f = false;
|
||||
} catch (MongoExecutionTimeoutException)
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
@ -162,7 +168,7 @@ namespace BuechermarktClient
|
||||
try
|
||||
{
|
||||
return MainWindow.BookTypeCollection.Find(b => b.ID == Book.BookType).FirstOrDefault();
|
||||
} catch (Exception)
|
||||
} catch (MongoExecutionTimeoutException)
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
@ -177,7 +183,7 @@ namespace BuechermarktClient
|
||||
}
|
||||
else if (value == null)
|
||||
{
|
||||
Book.BookType = new ObjectId("0");
|
||||
Book.BookType = new ObjectId();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -199,9 +205,10 @@ namespace BuechermarktClient
|
||||
try
|
||||
{
|
||||
BookType = MainWindow.BookTypeCollection.Find(b => b.ISBN == value).FirstOrDefault();
|
||||
//ToDO Fehler wenn buch nicht vorhanden
|
||||
OnPropertyChanged("BookTypeISBN");
|
||||
return;
|
||||
} catch (Exception)
|
||||
} catch (MongoExecutionTimeoutException)
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
@ -249,13 +256,15 @@ namespace BuechermarktClient
|
||||
try
|
||||
{
|
||||
MainWindow.BookCollection.InsertOne(Book);
|
||||
var oldStudent = Student;
|
||||
//var oldStudent = Student;
|
||||
var oldIsbn = BookTypeISBN;
|
||||
Book = new Book();
|
||||
Student = oldStudent;
|
||||
BookTypeISBN = oldIsbn;
|
||||
//Student = oldStudent;
|
||||
Book.State = BookState.InStock;
|
||||
OnPropertyChanged(string.Empty);
|
||||
return;
|
||||
} catch (Exception)
|
||||
} catch (MongoExecutionTimeoutException)
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
@ -275,7 +284,7 @@ namespace BuechermarktClient
|
||||
.Set(b => b.LabelId, Book.LabelId));
|
||||
Close();
|
||||
return;
|
||||
} catch (Exception)
|
||||
} catch (MongoExecutionTimeoutException)
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
@ -291,11 +300,11 @@ namespace BuechermarktClient
|
||||
{
|
||||
try
|
||||
{
|
||||
MainWindow.StudentCollection.DeleteOne(bt => bt.ID == Student.ID);
|
||||
MainWindow.StudentCollection.DeleteOne(bt => bt.ID == Book.ID);
|
||||
Close();
|
||||
return;
|
||||
}
|
||||
catch (Exception)
|
||||
catch (MongoExecutionTimeoutException)
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
|
@ -86,6 +86,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Sell.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Students.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
@ -119,6 +123,9 @@
|
||||
<Compile Include="GetConnection.xaml.cs">
|
||||
<DependentUpon>GetConnection.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Sell.xaml.cs">
|
||||
<DependentUpon>Sell.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="SigningService.cs" />
|
||||
<Compile Include="Students.xaml.cs">
|
||||
<DependentUpon>Students.xaml</DependentUpon>
|
||||
|
@ -11,9 +11,11 @@
|
||||
<ColumnDefinition Width="Auto"></ColumnDefinition>
|
||||
<ColumnDefinition Width="Auto"></ColumnDefinition>
|
||||
<ColumnDefinition Width="Auto"></ColumnDefinition>
|
||||
<ColumnDefinition Width="Auto"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
<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"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
@ -55,6 +55,7 @@ namespace BuechermarktClient
|
||||
public BookTypes BookTypesWindow = null;
|
||||
public Students StudentsWindow = null;
|
||||
public Books BooksWindow = null;
|
||||
public Sell SellWindow = null;
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
@ -65,22 +66,9 @@ namespace BuechermarktClient
|
||||
//ToDo get server informations
|
||||
}
|
||||
|
||||
public void ConnectionTester()
|
||||
{
|
||||
Mongo.Cluster.DescriptionChanged += (object sender, ClusterDescriptionChangedEventArgs e) =>
|
||||
{
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
public void OnConnectionEstablised()
|
||||
{
|
||||
Mongo = new MongoClient("mongodb://" + MongoHost + ":27017");
|
||||
//Database = Mongo.GetDatabase(DatabaseName);
|
||||
//BookTypeCollection =
|
||||
//BookCollection = Database.GetCollection<Book>("books");
|
||||
//StudentCollection = Database.GetCollection<Student>("students");
|
||||
|
||||
var t = new Thread(BackupService);
|
||||
t.Start();
|
||||
}
|
||||
@ -180,5 +168,27 @@ namespace BuechermarktClient
|
||||
{
|
||||
BooksWindow = null;
|
||||
}
|
||||
|
||||
private void Sell_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (SellWindow == null)
|
||||
{
|
||||
SellWindow = new Sell()
|
||||
{
|
||||
Owner = this
|
||||
};
|
||||
SellWindow.Show();
|
||||
SellWindow.Closed += SellWindow_Closes;
|
||||
}
|
||||
else
|
||||
{
|
||||
BringWindowOnTop(SellWindow);
|
||||
}
|
||||
}
|
||||
|
||||
private void SellWindow_Closes(object sender, EventArgs e)
|
||||
{
|
||||
SellWindow = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
62
BuechermarktClient/Sell.xaml
Normal file
62
BuechermarktClient/Sell.xaml
Normal file
@ -0,0 +1,62 @@
|
||||
<Window x:Class="BuechermarktClient.Sell"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:BuechermarktClient"
|
||||
mc:Ignorable="d"
|
||||
Title="Sell" Height="300" Width="300">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"></RowDefinition>
|
||||
<RowDefinition Height="*"></RowDefinition>
|
||||
<RowDefinition Height="Auto"></RowDefinition>
|
||||
<RowDefinition Height="Auto"></RowDefinition>
|
||||
<RowDefinition Height="Auto"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"></ColumnDefinition>
|
||||
<ColumnDefinition Width="*"></ColumnDefinition>
|
||||
<ColumnDefinition Width="Auto"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Content="Hinzufügen:" Grid.Column="0"></Label>
|
||||
<TextBox Grid.Column="1" Text="{Binding AddField, Mode=Default}" ForceCursor="True"></TextBox>
|
||||
<Button Content="A" Grid.Column="2" Width="25" Click="Add_Click"/>
|
||||
</Grid>
|
||||
<ListView Grid.Row="1" Name="BooksList">
|
||||
<ListView.View>
|
||||
<GridView>
|
||||
<GridViewColumn Header="SID" DisplayMemberBinding="{Binding StudentId}" Width="Auto"></GridViewColumn>
|
||||
<GridViewColumn Header="BID" DisplayMemberBinding="{Binding LabelId}" Width="Auto"></GridViewColumn>
|
||||
<GridViewColumn Header="Buchtyp" DisplayMemberBinding="{Binding bookType}" Width="Auto"></GridViewColumn>
|
||||
<GridViewColumn Header="Preis" DisplayMemberBinding="{Binding Price}" Width="Auto"></GridViewColumn>
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
<ListView.ItemContainerStyle>
|
||||
<Style TargetType="ListViewItem">
|
||||
<EventSetter Event="PreviewMouseDoubleClick" Handler="ListViewItem_PreviewMouseUp"></EventSetter>
|
||||
</Style>
|
||||
</ListView.ItemContainerStyle>
|
||||
</ListView>
|
||||
<Grid Grid.Row="2">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Grid.Column="0" Content="SV: " HorizontalContentAlignment="Right"></Label>
|
||||
<Label Grid.Column="1" Content="{Binding Path=SvSum, Mode=TwoWay}"></Label>
|
||||
</Grid>
|
||||
<Grid Grid.Row="3">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Grid.Column="0" Content="Gesamt: " HorizontalContentAlignment="Right"></Label>
|
||||
<Label Grid.Column="1" Content="{Binding Path=TotalSum, Mode=TwoWay}" FontSize="16" FontWeight="Bold"></Label>
|
||||
</Grid>
|
||||
<Button Grid.Row="4" Content="Abschließen" VerticalAlignment="Center" Click="SellAll_Click">
|
||||
|
||||
</Button>
|
||||
</Grid>
|
||||
</Window>
|
286
BuechermarktClient/Sell.xaml.cs
Normal file
286
BuechermarktClient/Sell.xaml.cs
Normal file
@ -0,0 +1,286 @@
|
||||
using BuechermarktClient.Models;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using MongoDB.Driver;
|
||||
using MongoDB.Bson;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Data;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Threading;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Controls;
|
||||
using System.Collections.Specialized;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace BuechermarktClient
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Interaktionslogik für Sell.xaml
|
||||
/// </summary>
|
||||
public partial class Sell : Window, INotifyPropertyChanged
|
||||
{
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
protected void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
private Dictionary<char, char> _Dictionary;
|
||||
private Dictionary<char, char> _ReverseDictionary;
|
||||
|
||||
private string _AddField;
|
||||
public string AddField
|
||||
{
|
||||
get
|
||||
{
|
||||
return _AddField;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if(value != _AddField)
|
||||
{
|
||||
_AddField = value;
|
||||
OnPropertyChanged("AddField");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int _SvSum;
|
||||
public int SvSum
|
||||
{
|
||||
get
|
||||
{
|
||||
return _SvSum;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != _SvSum)
|
||||
{
|
||||
_SvSum = value;
|
||||
OnPropertyChanged("SvSum");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private double _TotalSum;
|
||||
public double TotalSum
|
||||
{
|
||||
get
|
||||
{
|
||||
return _TotalSum;
|
||||
}
|
||||
set
|
||||
{
|
||||
if(value != _TotalSum)
|
||||
{
|
||||
_TotalSum = value;
|
||||
OnPropertyChanged("TotalSum");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private readonly ObservableCollection<SellBook> _SellBooks;
|
||||
|
||||
|
||||
public ObservableCollection<SellBook> SellBooks { get { return _SellBooks; } }
|
||||
|
||||
private void listChanged(object sender, NotifyCollectionChangedEventArgs args)
|
||||
{
|
||||
SvSum = SellBooks.Count;
|
||||
var pr = 0.0;
|
||||
foreach(var sb in SellBooks)
|
||||
{
|
||||
pr += sb.Price;
|
||||
}
|
||||
TotalSum = SvSum + pr;
|
||||
}
|
||||
|
||||
public Sell()
|
||||
{
|
||||
InitializeComponent();
|
||||
DataContext = this;
|
||||
_SellBooks = new ObservableCollection<SellBook>();
|
||||
_SellBooks.CollectionChanged += listChanged;
|
||||
_Dictionary = new Dictionary<char, char>();
|
||||
_Dictionary.Add('a', 'A');
|
||||
_Dictionary.Add('b', 'B');
|
||||
_Dictionary.Add('c', 'C');
|
||||
_Dictionary.Add('d', 'D');
|
||||
_Dictionary.Add('e', 'E');
|
||||
_Dictionary.Add('f', 'F');
|
||||
_Dictionary.Add('g', 'G');
|
||||
_Dictionary.Add('h', 'H');
|
||||
_Dictionary.Add('i', 'I');
|
||||
_Dictionary.Add('j', 'J');
|
||||
_Dictionary.Add('k', 'K');
|
||||
_Dictionary.Add('l', 'L');
|
||||
_Dictionary.Add('m', 'M');
|
||||
_Dictionary.Add('n', 'N');
|
||||
_Dictionary.Add('o', 'O');
|
||||
_Dictionary.Add('p', 'P');
|
||||
_Dictionary.Add('q', 'Q');
|
||||
_Dictionary.Add('r', 'R');
|
||||
_Dictionary.Add('s', 'S');
|
||||
_Dictionary.Add('t', 'T');
|
||||
_Dictionary.Add('u', 'U');
|
||||
_Dictionary.Add('v', 'V');
|
||||
_Dictionary.Add('w', 'W');
|
||||
_Dictionary.Add('x', 'X');
|
||||
_Dictionary.Add('y', 'Y');
|
||||
_Dictionary.Add('z', 'Z');
|
||||
_Dictionary.Add('1', '!');
|
||||
_Dictionary.Add('2', '"');
|
||||
_Dictionary.Add('3', '§');
|
||||
_Dictionary.Add('4', '$');
|
||||
_Dictionary.Add('5', '%');
|
||||
_Dictionary.Add('6', '&');
|
||||
_Dictionary.Add('7', '/');
|
||||
_Dictionary.Add('8', '(');
|
||||
_Dictionary.Add('9', ')');
|
||||
_Dictionary.Add('0', '=');
|
||||
_Dictionary.Add('ß', '?');
|
||||
_Dictionary.Add('-', '_');
|
||||
|
||||
_ReverseDictionary = new Dictionary<char, char>();
|
||||
foreach(var entry in _Dictionary)
|
||||
{
|
||||
_ReverseDictionary.Add(entry.Value, entry.Key);
|
||||
}
|
||||
}
|
||||
|
||||
private void Add_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
try
|
||||
{
|
||||
var reverse = ReverseString(AddField);
|
||||
var case1 = ReverseUnderscore(AddField);
|
||||
var case2 = ReverseUnderscore(reverse);
|
||||
foreach (var s in SellBooks)
|
||||
{
|
||||
if(s.LabelId == AddField || s.LabelId == reverse || s.LabelId == case1 ||s.LabelId == case2)
|
||||
{
|
||||
MessageBox.Show("Das Buch ist bereits in der Liste");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var item = MainWindow.BookCollection.FindSync<Models.Book>(b => b.LabelId == AddField || b.LabelId == reverse || b.LabelId == case1 || b.LabelId == case2).FirstOrDefault();
|
||||
if (item == null)
|
||||
{
|
||||
MessageBox.Show("Das Buch ist nicht vorhanden bitte überprüfen");
|
||||
return;
|
||||
}
|
||||
|
||||
var stud = MainWindow.StudentCollection.FindSync<Models.Student>(s => s.ID == item.Student).FirstOrDefault();
|
||||
if (stud == null)
|
||||
{
|
||||
MessageBox.Show("Der Schüler ist nicht vorhanden bitte überprüfen");
|
||||
return;
|
||||
}
|
||||
|
||||
var type = MainWindow.BookTypeCollection.FindSync<Models.BookType>(bt => bt.ID == item.BookType).FirstOrDefault();
|
||||
if (type == null)
|
||||
{
|
||||
MessageBox.Show("Der Buchtyp (ObjId: " + item.BookType + ") ist nicht vorhanden bitte überprüfen");
|
||||
return;
|
||||
}
|
||||
|
||||
var sb = new SellBook();
|
||||
sb.StudentId = stud.LabelId;
|
||||
sb.LabelId = item.LabelId;
|
||||
sb.Price = item.Price;
|
||||
sb.Type = type.Name;
|
||||
|
||||
AddField = String.Empty;
|
||||
|
||||
SellBooks.Add(sb);
|
||||
Dispatcher.BeginInvoke(new Action(delegate () {
|
||||
BooksList.ItemsSource = SellBooks;
|
||||
}));
|
||||
return;
|
||||
} catch (MongoExecutionTimeoutException)
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ListViewItem_PreviewMouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (sender is ListViewItem item && item.IsSelected)
|
||||
{
|
||||
SellBooks.Remove(item.DataContext as SellBook);
|
||||
Dispatcher.BeginInvoke(new Action(delegate () {
|
||||
BooksList.ItemsSource = SellBooks;
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
private void SellAll_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var sb in SellBooks)
|
||||
{
|
||||
MainWindow.BookCollection.FindOneAndUpdate<Models.Book>(b => b.LabelId == sb.LabelId, Builders<Book>.Update.Set(b => b.State, Models.BookState.Selled));
|
||||
}
|
||||
SellBooks.Clear();
|
||||
Dispatcher.BeginInvoke(new Action(delegate () {
|
||||
BooksList.ItemsSource = SellBooks;
|
||||
}));
|
||||
return;
|
||||
} catch (MongoExecutionTimeoutException)
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string ReverseString(string s)
|
||||
{
|
||||
var res = String.Empty;
|
||||
foreach(var i in s)
|
||||
{
|
||||
char v;
|
||||
if(_Dictionary.TryGetValue(i, out v) || _ReverseDictionary.TryGetValue(i, out v))
|
||||
{
|
||||
res += v;
|
||||
} else {
|
||||
MessageBox.Show(string.Format("Das Label enthält ungültige Zeichen ( {0} ), {1}", i, s));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
private string ReverseUnderscore(string s)
|
||||
{
|
||||
if(s.IndexOf("_") >= 0 || s.IndexOf("-") >= 0)
|
||||
{
|
||||
s = s.Replace("_", "?").Replace("-", "ß");
|
||||
} else
|
||||
{
|
||||
s = s.Replace("?", "_").Replace("ß", "-");
|
||||
}
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
public class SellBook
|
||||
{
|
||||
public string StudentId { get; set; }
|
||||
public string LabelId { get; set; }
|
||||
public string Type { get; set; }
|
||||
public double Price { get; set; }
|
||||
}
|
||||
}
|
@ -79,7 +79,7 @@ namespace BuechermarktClient
|
||||
list = MainWindow.StudentCollection.FindSync((b) => true).ToList();
|
||||
not = false;
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (MongoExecutionTimeoutException)
|
||||
{
|
||||
Thread.Sleep(200);
|
||||
}
|
||||
@ -88,11 +88,24 @@ namespace BuechermarktClient
|
||||
var show = new List<Student>();
|
||||
if (SearchField != null && SearchField != String.Empty)
|
||||
{
|
||||
foreach (var e in list)
|
||||
if(SearchField == "%d%")
|
||||
{
|
||||
if (e.Forname.ToLower().Contains(SearchField.ToLower()) || e.Lastname.ToLower().Contains(SearchField.ToLower()) || e.PhoneNumber.ToLower().Contains(SearchField.ToLower()) || e.EMail.ToLower().Contains(SearchField.ToLower()) || e.Form.ToLower().Contains(SearchField.ToLower()))
|
||||
foreach (var e in list)
|
||||
{
|
||||
show.Add(e);
|
||||
foreach (var e2 in list)
|
||||
{
|
||||
if (e.ID == e2.ID) continue;
|
||||
if (e.LabelId == e2.LabelId) show.Add(e);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach (var e in list)
|
||||
{
|
||||
//
|
||||
if (e.Forname.ToLower().Contains(SearchField.ToLower()) || e.Lastname.ToLower().Contains(SearchField.ToLower()) || e.EMail.ToLower().Contains(SearchField.ToLower()) || e.Form.ToLower().Contains(SearchField.ToLower()) || e.LabelId.ToLower().Contains(SearchField.ToLower()))
|
||||
{
|
||||
show.Add(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -157,9 +157,9 @@ namespace BuechermarktClient
|
||||
.Set(s => s.Form, Student.Form));
|
||||
|
||||
Close();
|
||||
return;
|
||||
}
|
||||
} catch (Exception)
|
||||
return;
|
||||
} catch (MongoExecutionTimeoutException)
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
@ -177,8 +177,9 @@ namespace BuechermarktClient
|
||||
MainWindow.StudentCollection.DeleteOne(bt => bt.ID == Student.ID);
|
||||
}
|
||||
Close();
|
||||
return;
|
||||
}
|
||||
catch (Exception)
|
||||
catch (MongoExecutionTimeoutException)
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
|
BIN
BuechermarktClient/bin/Debug/Client.zip
Normal file
BIN
BuechermarktClient/bin/Debug/Client.zip
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user