public Boolean checkMatchExist(string match) { try { var db = new SQLiteDatabase(); DataTable recipe; String query = "SELECT * FROM Match WHERE (MatId=" + match + ")"; recipe = db.GetDataTable(query); if (recipe.Rows.Count > 0) { return true; } return false; } catch (Exception) { return false; } }
public void FillFromMatch(NumericUpDown nmrNumberMatch) { //ClearCombobox(); string figIdRed = ""; string figIdBlue = ""; string match = nmrNumberMatch.Value.ToString(); try { var db = new SQLiteDatabase(); DataTable recipe; String query = "SELECT * FROM Match WHERE (MatId=" + match + ")"; recipe = db.GetDataTable(query); if (recipe.Rows.Count > 0) { foreach (DataRow r in recipe.Rows) { figIdRed = r["FigIdRed"].ToString(); figIdBlue = r["FigIdBlue"].ToString(); } if (checkIsNumber(figIdRed)) figIdRed = setMSSVFromMath(figIdRed); if (checkIsNumber(figIdBlue)) figIdBlue = setMSSVFromMath(figIdBlue); setValuesTextboxRed(figIdRed); setValuesTextboxBlue(figIdBlue); //setValuesCombobox(idRed, idblue); } else { //FillFromSexAndWeight(cbbSex,cbbWeight); //ClearCombobox(); ClearTexbox(); } } catch (Exception fail) { String error = "The following error has occurred:\n\n"; error += fail.Message.ToString() + "\n\n"; MessageBox.Show(error); } }
private string setMSSVFromMath(string NumberMathWin) { string figIWin = ""; try { var db = new SQLiteDatabase(); DataTable recipe; String query = "SELECT * FROM Match WHERE (MatId=" + NumberMathWin + ")"; recipe = db.GetDataTable(query); if (recipe.Rows.Count > 0) { foreach (DataRow r in recipe.Rows) { figIWin = r["FigIdWin"].ToString(); } } } catch (Exception fail) { String error = "The following error has occurred:\n\n"; error += fail.Message.ToString() + "\n\n"; MessageBox.Show(error); } return figIWin; }
private void setValuesTextboxRed(string figIdRed) { try { string sex = ""; string weight = ""; string name = ""; string id = ""; string classs = ""; var db = new SQLiteDatabase(); DataTable recipe; String query = "SELECT * FROM Fighter WHERE (FigId='" + figIdRed + "')"; recipe = db.GetDataTable(query); foreach (DataRow r in recipe.Rows) { sex = r["FigSex"].ToString(); weight = r["FigWeight"].ToString(); name = r["FigName"].ToString(); id = r["FigId"].ToString(); classs = r["FigClass"].ToString(); } cbbSex.Text = sex; cbbWeight.Text = weight; txtNameRed.Text = name; txtIdRed.Text = id; txtClassRed.Text = classs; } catch (Exception fail) { String error = "The following error has occurred:\n\n"; error += fail.Message.ToString() + "\n\n"; MessageBox.Show(error); } }
public void SaveMath(string winId) { var db = new SQLiteDatabase(); //Nếu đã tồn tại Match này thì xóa if (checkMatchExist(nmrNumberMatch.Value.ToString())) { string match = nmrNumberMatch.Value.ToString(); db.Delete("Match", String.Format("MatId = {0}", match)); } Dictionary<String, String> data = new Dictionary<String, String>(); data.Add("MatId", nmrNumberMatch.Value.ToString()); data.Add("FigIdRed", txtIdRed.Text); data.Add("FigIdBlue", txtIdBlue.Text); data.Add("FigIdWin", winId); try { db.Insert("Match", data); } catch (Exception crap) { MessageBox.Show(crap.Message); } }