bugfixing

This commit is contained in:
BlubbFish 2013-07-12 01:09:35 +00:00
parent 7d07741e2c
commit 0b4631e1ad
8 changed files with 32 additions and 15 deletions

View File

@ -32,7 +32,7 @@ namespace Matomat
} }
catch (ArgumentException e) catch (ArgumentException e)
{ {
Factory.getLCD().print(e.ToString(), 5, LCDDisplay.Status.OK); Factory.getLCD().print(e.Message, 5, LCDDisplay.Status.OK);
System.Threading.Thread.Sleep(4500); System.Threading.Thread.Sleep(4500);
return; return;
} }
@ -52,7 +52,7 @@ namespace Matomat
} }
catch (ArgumentException e) catch (ArgumentException e)
{ {
Factory.getLCD().print(e.ToString(), 5, LCDDisplay.Status.OK); Factory.getLCD().print(e.Message, 5, LCDDisplay.Status.OK);
System.Threading.Thread.Sleep(4500); System.Threading.Thread.Sleep(4500);
return; return;
} }
@ -90,7 +90,7 @@ namespace Matomat
} }
catch (ArgumentException e) catch (ArgumentException e)
{ {
Factory.getLCD().print(e.ToString(), 5, LCDDisplay.Status.OK); Factory.getLCD().print(e.Message, 5, LCDDisplay.Status.OK);
System.Threading.Thread.Sleep(4500); System.Threading.Thread.Sleep(4500);
return; return;
} }

View File

@ -34,9 +34,9 @@ namespace Matomat.Database
this.err = e; this.err = e;
return false; return false;
} }
this.startPing();
this.query("SET NAMES 'UTF8'"); this.query("SET NAMES 'UTF8'");
this.query("SET CHARACTER SET 'UTF8'"); this.query("SET CHARACTER SET 'UTF8'");
this.startPing();
return true; return true;
} }
@ -55,6 +55,11 @@ namespace Matomat.Database
} }
public override void query(string sql) public override void query(string sql)
{ {
this.pingThread.Abort();
while (this.pingThread.IsAlive)
{
Thread.Sleep(1);
}
this.err = null; this.err = null;
if (this.data is MySqlDataReader && !this.data.IsClosed) if (this.data is MySqlDataReader && !this.data.IsClosed)
this.data.Close(); this.data.Close();
@ -80,6 +85,7 @@ namespace Matomat.Database
{ {
Console.WriteLine("SQL: " + sql + ((err != null) ? " Err" + err.Message : "")); Console.WriteLine("SQL: " + sql + ((err != null) ? " Err" + err.Message : ""));
} }
this.startPing();
} }
private void set(string sql) private void set(string sql)

View File

@ -51,7 +51,7 @@ namespace Matomat.Database.Query
{ {
if (this.name.Substring(this.name.Length - 2) == "()") if (this.name.Substring(this.name.Length - 2) == "()")
{ {
return "\n" + this.name.Substring(this.name.Length - 2) + "(" + String.Join(this.glue, this.elements) + ")"; return "\n" + this.name.Substring(0, this.name.Length - 2) + "(" + String.Join(this.glue, this.elements) + ")";
} }
else else
{ {

View File

@ -114,7 +114,14 @@ namespace Matomat.Database
foreach (System.Reflection.PropertyInfo item in p) foreach (System.Reflection.PropertyInfo item in p)
{ {
fields.Add(this.quoteName(item.Name)); fields.Add(this.quoteName(item.Name));
values.Add(item.GetValue(row, null).ToString()); if (item.GetValue(row, null).GetType() == DateTime.Now.GetType())
{
values.Add(this.quote(((DateTime)item.GetValue(row, null)).ToString("s")));
}
else
{
values.Add(this.quote(item.GetValue(row, null).ToString()));
}
} }
if (p.Length == 0) if (p.Length == 0)
@ -122,8 +129,8 @@ namespace Matomat.Database
return true; return true;
} }
query.columns(String.Join("", fields)); query.columns(String.Join(",", fields));
query.values(String.Join("", values)); query.values(String.Join(",", values));
this.setQuery(query); this.setQuery(query);
return true; return true;

View File

@ -44,7 +44,7 @@ namespace Matomat
} }
catch (ArgumentException e) catch (ArgumentException e)
{ {
Factory.getLCD().print(e.ToString(), 5, LCDDisplay.Status.OK); Factory.getLCD().print(e.Message, 5, LCDDisplay.Status.OK);
System.Threading.Thread.Sleep(4500); System.Threading.Thread.Sleep(4500);
return; return;
} }
@ -135,7 +135,7 @@ namespace Matomat
} }
catch (ArgumentException e) catch (ArgumentException e)
{ {
Factory.getLCD().print(e.ToString(), 5, LCDDisplay.Status.OK); Factory.getLCD().print(e.Message, 5, LCDDisplay.Status.OK);
System.Threading.Thread.Sleep(4500); System.Threading.Thread.Sleep(4500);
return; return;
} }

View File

@ -73,6 +73,10 @@ namespace Matomat.Model
Console.WriteLine(Factory.getDBO().getError()); Console.WriteLine(Factory.getDBO().getError());
return 0; return 0;
} }
if ((double)row[0] == 0.0)
{
return 0;
}
return (int)((double)row[0]/ double.Parse(((decimal)row[1]).ToString())); return (int)((double)row[0]/ double.Parse(((decimal)row[1]).ToString()));
} }

View File

@ -26,7 +26,7 @@ namespace Matomat.Model
{ {
this.table = new TableUser(); this.table = new TableUser();
Dictionary<string, string> load = new Dictionary<string, string>(); Dictionary<string, string> load = new Dictionary<string, string>();
load.Add("barcode", userid.ToString()); load.Add("userid", userid.ToString());
this.table.load(load); this.table.load(load);
return (this.table.userid == this.userid); return (this.table.userid == this.userid);
} }
@ -63,7 +63,7 @@ namespace Matomat.Model
Console.WriteLine(Factory.getDBO().getError()); Console.WriteLine(Factory.getDBO().getError());
return 0.0; return 0.0;
} }
return ((double)row[0])/100; return (double.Parse(row[0].ToString()))/100;
} }
public bool GetAdmin() public bool GetAdmin()
@ -71,9 +71,9 @@ namespace Matomat.Model
return this.table.admin; return this.table.admin;
} }
public void SetUserKonto(double p) public void SetUserKonto(double cost)
{ {
p = (int)(p * 100); int p = (int)(cost * 100);
Dictionary<string, object> k = new Dictionary<string, object>(); Dictionary<string, object> k = new Dictionary<string, object>();
k.Add("credits", this.table.credits + p); k.Add("credits", this.table.credits + p);
this.table.bind(k); this.table.bind(k);