This commit is contained in:
BlubbFish 2013-07-09 18:32:02 +00:00
parent 1bf6fe008f
commit 157c0048ac
7 changed files with 80 additions and 24 deletions

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="com_display" value="COM17" />
<add key="com_rfid" value="COM19" />
<add key="com_display" value="COM1" />
<add key="com_rfid" value="COM11" />
<add key="mysql_server" value="127.0.0.1"/>
<add key="mysql_user" value="root"/>
<add key="mysql_db" value="matomat"/>

View File

@ -12,7 +12,7 @@ namespace Matomat
{
class Automat
{
private bool shutdown = false;
//private bool shutdown = false;
public delegate void stopEvent(bool stop);
@ -73,7 +73,7 @@ namespace Matomat
if (prod.GetProdType() == EAN13.ProdType.instruction)
{
switch (prod.GetFunctName().ToLower())
switch (prod.GetFunctName())
{
case "exit();": this.stopThread(true); break;
case "showStats();": Instruction.InsShowStats(); break;
@ -94,7 +94,7 @@ namespace Matomat
long id = prod.GetProdId();
double price = prod.GetProdPrice();
string name = prod.GetProdName();
Factory.getLCD().printb("Produkt: " + name + "\nPreis: " + price + "€ EAN13: " + id, 2);
Factory.getLCD().printb("Produkt: " + name + "\nPreis: " + price.ToString("N2") + "€ EAN13: " + id, 2);
}
if (prod.GetProdType() == EAN13.ProdType.instruction)
{
@ -106,10 +106,10 @@ namespace Matomat
private void showUserInfo(RfidCode user)
{
string name = user.GetUserName();
int konto = user.GetUserKonto();
double konto = user.GetUserKonto();
long id = user.GetUserId();
long all = user.GetUserAll();
Factory.getLCD().printb("User: " + name + " Betrag: " + konto + " €\nUserID: " + id + " Gesamt: " + all + " €", 5);
double all = user.GetUserAll();
Factory.getLCD().printb("User: " + name + " Betrag: " + konto.ToString("N2") + " €\nUserID: " + id + " Gesamt: " + all.ToString("N2") + " €", 5);
}
internal void GetInitStatus()

View File

@ -76,7 +76,7 @@ namespace Matomat.Data
internal double GetProdPrice()
{
return this.price;
return ((double)this.price)/100;
}
internal string GetProdName()
@ -93,5 +93,17 @@ namespace Matomat.Data
{
return this.id;
}
public bool vaild(bool silent)
{
if (silent)
{
return found;
}
else
{
return vaild();
}
}
}
}

View File

@ -14,7 +14,7 @@ namespace Matomat.Data
private long userId;
private bool found;
private string username;
private string shrotname;
private string shortname;
private int credits;
private long all;
private bool admin;
@ -36,7 +36,7 @@ namespace Matomat.Data
}
TBest b = new Tables().getUserMax(u.id);
this.found = true;
this.shrotname = u.shortname;
this.shortname = u.shortname;
this.credits = u.credits;
this.all = b.num;
this.admin = u.admin;
@ -70,12 +70,12 @@ namespace Matomat.Data
internal string GetUserName()
{
return this.shrotname;
return this.shortname;
}
internal int GetUserKonto()
internal double GetUserKonto()
{
return this.credits;
return ((double)this.credits) / 100;
}
internal long GetUserId()
@ -88,9 +88,9 @@ namespace Matomat.Data
return this.id;
}
internal long GetUserAll()
internal double GetUserAll()
{
return this.all;
return ((double)this.all) / 100;
}
internal bool IsAdmin()
@ -98,8 +98,9 @@ namespace Matomat.Data
return this.admin;
}
internal void SetUserKonto(int p)
internal void SetUserKonto(double cost)
{
int p = (int)(cost * 100);
TDatabase db = Factory.getDBO();
this.credits = p;
db.query("UPDATE `user` SET `credits` = '" + db.quote(p.ToString())+"' WHERE "+

View File

@ -124,7 +124,7 @@ namespace Matomat
public static void sell(EAN13 prod, RfidCode user)
{
if (Factory.getConfig().sell && user.GetUserKonto() > 19)
if (Factory.getConfig().sell && user.GetUserKonto() > 1900)
{
Factory.getLCD().printb("Du hast zu viel Geld auf dem Konto\nBITTE bezahlen! | Grenze 20€", LCDDisplay.Status.Error, 5);
return;
@ -135,7 +135,7 @@ namespace Matomat
"NOW())");
if (Factory.getConfig().sell)
{
Factory.getDBO().query("UPDATE `user` SET `credits` = `credits`+1 WHERE `user`.`id` = '" +
Factory.getDBO().query("UPDATE `user` SET `credits` = `credits`+" + Factory.getDBO().quote((prod.GetProdPrice() * 100).ToString("N0")) + " WHERE `user`.`id` = '" +
Factory.getDBO().quote(user.GetDbId().ToString()) + "'");
}
Factory.getLCD().printb("Guten Durst mit der\n" + prod.GetProdName() + "!", 4);
@ -147,9 +147,52 @@ namespace Matomat
throw new NotImplementedException();
}
internal static void InsAddProd(RfidCode user)
internal static void InsAddProd(RfidCode admin)
{
throw new NotImplementedException();
if (!admin.IsAdmin())
{
Factory.getLCD().printb("Du bist kein Admin,\ndu kannst nichts Hinzufügen!", LCDDisplay.Status.Error, 5);
System.Threading.Thread.Sleep(4500);
return;
}
Factory.getLCD().printb("Bitte das neue Produkt\nüber den Barcodeleser ziehen.");
InputData target = Factory.getInput().getProdInput(20);
if (target.type == InputData.types.None)
return;
EAN13 code = new EAN13(target.id);
if (code.vaild(true))
{
Factory.getLCD().printb("Dieser Produkt ist schon\nRegistriert", LCDDisplay.Status.Warn, 5);
System.Threading.Thread.Sleep(4500);
return;
}
Factory.getLCD().printb("Bitte den Produktnamen [255] eingeben:");
string name = Console.ReadLine();
Factory.getLCD().printb("Produktname:\n" + name);
System.Threading.Thread.Sleep(4500);
Factory.getLCD().printb("Bitte Preis [Cent] eingeben:");
string preis = Console.ReadLine();
Factory.getLCD().printb("Preis:\n" + preis + " €Cent");
System.Threading.Thread.Sleep(4500);
Factory.getLCD().printb("Bitte Koffeingehalt [mg] eingeben:");
string coffeine = Console.ReadLine();
Factory.getLCD().printb("Koffeingehalt:\n" + coffeine + " mg");
System.Threading.Thread.Sleep(4500);
string sql = "INSERT INTO `product` (`barcode`,`name`,`cost`,`caffeine`) VALUES (" +
"'" + Factory.getDBO().quote(target.id.ToString()) + "'," +
"'" + Factory.getDBO().quote(name) + "'," +
"'" + Factory.getDBO().quote(preis) + "'," +
"'" + Factory.getDBO().quote(coffeine) + "')";
Factory.getDBO().query(sql);
Factory.getLCD().printb("Neues Produkt eingefügt:\n" + name);
System.Threading.Thread.Sleep(4500);
}
internal static void InsDelProd(RfidCode user)

View File

@ -77,10 +77,10 @@
</ItemGroup>
<ItemGroup>
<Content Include="exe\librfid-tool.exe">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="dll\RfidClass.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="dll\mysql.data.dll" />
<Content Include="dll\mysql.data.entity.dll" />