92 lines
2.4 KiB
C#
92 lines
2.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace Matomat
|
|
{
|
|
class User
|
|
{
|
|
private long userId;
|
|
private bool found;
|
|
private string username;
|
|
private string shrotname;
|
|
private int credits;
|
|
private long all;
|
|
private bool admin;
|
|
private int id;
|
|
|
|
public User(long userId)
|
|
{
|
|
this.userId = userId;
|
|
load();
|
|
}
|
|
|
|
private void load()
|
|
{
|
|
TUser u = new Tables().getUserTable(this.userId);
|
|
if (u == null)
|
|
{
|
|
this.found = false;
|
|
return;
|
|
}
|
|
TBest b = new Tables().getUserMax(u.id);
|
|
this.found = true;
|
|
this.shrotname = u.shortname;
|
|
this.credits = u.credits;
|
|
this.all = b.num;
|
|
this.admin = u.admin;
|
|
this.id = u.id;
|
|
}
|
|
|
|
internal bool vaild()
|
|
{
|
|
LCDDisplay lcd = Factory.getLCDDisplay();
|
|
if (!found)
|
|
{
|
|
lcd.print("²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²" +
|
|
"² User wurde nicht gefunden ²" +
|
|
"² UserID: " + (this.GetUserId().ToString() + " unbekannt").PadRight(28, ' ') + " ²" +
|
|
"²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²", LCDDisplay.Status.Error, 5);
|
|
System.Threading.Thread.Sleep(4500);
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
|
|
internal string GetUserName()
|
|
{
|
|
return this.shrotname;
|
|
}
|
|
|
|
internal int GetUserKonto()
|
|
{
|
|
return this.credits;
|
|
}
|
|
|
|
internal long GetUserId()
|
|
{
|
|
return this.userId;
|
|
}
|
|
|
|
internal long GetUserAll()
|
|
{
|
|
return this.all;
|
|
}
|
|
|
|
internal bool IsAdmin()
|
|
{
|
|
return this.admin;
|
|
}
|
|
|
|
internal void SetUserKonto(int p)
|
|
{
|
|
Database db = Factory.getDBO();
|
|
this.credits = p;
|
|
db.query("UPDATE `user` SET `credits` = '" + db.quote(p.ToString())+"' WHERE "+
|
|
"`id` = '"+db.quote(this.id.ToString())+"'");
|
|
}
|
|
}
|
|
}
|