107 lines
3.9 KiB
C#
107 lines
3.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace Matomat
|
|
{
|
|
class Automat
|
|
{
|
|
private User user;
|
|
private Prod prod;
|
|
private bool shutdown = false;
|
|
private LCDDisplay lcd;
|
|
private Input inp;
|
|
|
|
public Automat() {
|
|
lcd = Factory.getLCDDisplay();
|
|
inp = Factory.getInput();
|
|
}
|
|
internal void doJob(InputData input)
|
|
{
|
|
if (input.type == InputData.types.Card)
|
|
{
|
|
user = this.findUser(input.id);
|
|
if (!user.vaild())
|
|
return;
|
|
this.showUserInfo(user);
|
|
lcd.print("Bitte Produkt / Code über den Barcodeleser halten.");
|
|
InputData prodid = inp.getProdInput(20);
|
|
if (prodid.type == InputData.types.None)
|
|
return;
|
|
prod = this.findProd(prodid.id);
|
|
if(!prod.vaild())
|
|
return;
|
|
this.showProdInfo(prod);
|
|
if (prod.GetProdType() == Prod.ProdType.product)
|
|
{
|
|
this.sell(prod, user);
|
|
}
|
|
|
|
|
|
}
|
|
else if (input.type == InputData.types.Prod)
|
|
{
|
|
prod = this.findProd(input.id);
|
|
if (!prod.vaild())
|
|
return;
|
|
this.showProdInfo(prod);
|
|
}
|
|
}
|
|
|
|
private void sell(Prod prod, User user)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
private void showProdInfo(Prod prod)
|
|
{
|
|
if (prod.GetProdType() == Prod.ProdType.product)
|
|
{
|
|
long id = prod.GetProdId();
|
|
double price = prod.GetProdPrice();
|
|
string name = prod.GetProdName();
|
|
this.lcd.print("²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²" +
|
|
"² Produkt: " + name.PadRight(27, ' ') + " ²" +
|
|
"² Preis: " + price.ToString(2).PadLeft(6, ' ') + "€ EAN13: " + id.ToString().PadRight(14, ' ') + " ²" +
|
|
"²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²", 5);
|
|
}
|
|
if (prod.GetProdType() == Prod.ProdType.instruction)
|
|
{
|
|
string name = prod.GetFunctName();
|
|
this.lcd.print("²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²" +
|
|
"² Instruktion: " + name.PadRight(23, ' ') + " ²" +
|
|
"² AdminCard + Instruction + TargetCard ²" +
|
|
"²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²", 5);
|
|
}
|
|
}
|
|
|
|
private Prod findProd(long prodid)
|
|
{
|
|
return new Prod(prodid);
|
|
}
|
|
|
|
private void showUserInfo(User user)
|
|
{
|
|
string name = user.GetUserName();
|
|
int konto = user.GetUserKonto();
|
|
long id = user.GetUserId();
|
|
int all = user.GetUserAll();
|
|
lcd.print("²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²" +
|
|
"² User: " + name.PadRight(8, ' ') + " Betrag: " + (konto.ToString() + " €").PadRight(7, ' ') + " ²" +
|
|
"² UserID: " + id.ToString().PadRight(12, ' ') + " Gesamt: " + (all.ToString() + " €").PadRight(7, ' ') + " ²" +
|
|
"²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²", 5);
|
|
}
|
|
|
|
private User findUser(long userId)
|
|
{
|
|
return new User(userId);
|
|
}
|
|
|
|
internal bool die()
|
|
{
|
|
return shutdown;
|
|
}
|
|
}
|
|
}
|