public query ( string query, string bindings = null ) : |
||
query | string | |
bindings | string | |
Résultat |
private bool securityCodeCheck(String username, String securityCodeCompare) { bool checkPass = false; Thread t = Utilities.runInThread(() => { DB TempLogUser = Utilities.AsyncDB(); TempLogUser.bind(new string[] { "user", username }); DataTable dt = TempLogUser.query("select securitycode from users where user=@user"); if (dt.Rows.Count == 1) { String securityCode = dt.Rows[0][0].ToString(); if (securityCode.Equals(securityCodeCompare)) { checkPass = true; } else { checkPass = false; } } else { checkPass = false; } }); t.Start(); t.Join(); return(checkPass); }
private void frmEdit_Load(object sender, EventArgs e) { autocompleteMenu1.Items = Globals.colTags.ToArray(); string questtags = ""; txtAddQ.Text = _quest.question; Utilities.runInThread(() => { DB TempDB = Utilities.AsyncDB(true); DataTable dt = new DataTable(); dt = TempDB.query("select nametag from tags where qid='" + _quest.id + "'"); for (int i = 0; i < dt.Rows.Count; i++) { if (i == dt.Rows.Count - 1) { questtags += dt.Rows[i][0].ToString(); } else { questtags += dt.Rows[i][0].ToString() + ","; } } Utilities.InvokeMe(txtAddTags, () => { txtAddTags.Text = "" + questtags; }); }).Start(); for (int k = 0; k < _quest.anwsers.Count; k++) { dgvAnswerlist.Rows.Add(_quest.anwsers[k].text.ToString(), _quest.anwsers[k].correct); } }
private void btnLogin_Click(object sender, EventArgs e) { if (Globals.Connected) { txtLUser.Text = txtLUser.Text.Trim(); if (string.IsNullOrEmpty(txtLUser.Text) || string.IsNullOrEmpty(txtLPass.Text)) { Utilities.notifyThem(ntfBox1, "Empty username or password!", NotificationBox.Type.Warning); } else { Utilities.runInThread(() => { String HashPass = Utilities.MD5Hash(txtLPass.Text); DB TempLogUser = Utilities.AsyncDB(); TempLogUser.bind(new string[] { "user", txtLUser.Text, "pass", HashPass }); DataTable dt = TempLogUser.query("select * from users where user = @user and pass = @pass"); if (dt.Rows.Count == 1) { if (ckbLRemember.Checked) { Settings.save("StoredAccount", ckbLRemember.Checked.ToString(), txtLUser.Text, txtLPass.Text); } else { Settings.delete("StoredAccount"); } //Load Tags Functionality.LoadTags(); int id = int.Parse(dt.Rows[0][0].ToString()); string user = dt.Rows[0][1].ToString(); string pass = dt.Rows[0][2].ToString(); string mail = dt.Rows[0][3].ToString(); string scode = dt.Rows[0][4].ToString(); Globals.logUser = new User(id, user, pass, mail, scode); Utilities.InvokeMe(this, () => { ntfBox1.Visible = false; this.Hide(); Globals.formMain.Show(); }); } else { Utilities.notifyThem(ntfBox1, "Username or Password were incorrect", NotificationBox.Type.Error); } }).Start(); } } else { Utilities.notifyThem(ntfBox1, "Not connected to DB!", NotificationBox.Type.Warning); } }
private void btnSearch_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtTags.Text)) { Utilities.notifyThem(ntbfindQ, "You must add some tags first", NotificationBox.Type.Error); } else { Utilities.runInThread(() => { DB TempDB = Utilities.AsyncDB(true); string[] tags = txtTags.Text.TrimEnd(',').Split(','); string conQuery = ""; for (int i = 0; i < tags.Length; i++) { conQuery += "@" + i + ","; } string fromall = ""; if (switchFindAll.isOn) { fromall = "(prive = 0 and uid != " + Globals.logUser.id + ") or "; } DataTable dt = new DataTable(); TempDB.qBind(tags); if (!switchAllTags.isOn) { dt = TempDB.query("select * from questions where (" + fromall + "uid = " + Globals.logUser.id + ") and dlevel >= " + numericMin.Value + " and dlevel <= " + numericMax.Value + " and id in(select distinct qid from tags where nametag in (" + conQuery.TrimEnd(',') + "));"); } else { dt = TempDB.query("SELECT * FROM `questions` WHERE (" + fromall + "uid = " + Globals.logUser.id + ") and dlevel >= " + numericMin.Value + " and dlevel <= " + numericMax.Value + " and id IN (SELECT qid FROM `tags` WHERE nametag IN (SELECT nametag FROM tags WHERE nametag IN (" + conQuery.TrimEnd(',') + ")) GROUP BY qid HAVING COUNT( qid ) = " + tags.Length + ")"); } for (int i = 0; i < dt.Columns.Count; i++) { dt.Columns[i].ReadOnly = true; } Utilities.InvokeMe(dgvFoundQ, () => { dgvFoundQ.DataSource = dt; dgvFoundQ.Columns[0].Visible = true; dgvFoundQ.Columns[0].Width = 50; dgvFoundQ.Columns[1].Visible = false; dgvFoundQ.Columns[2].HeaderText = "Questions"; dgvFoundQ.Columns[2].SortMode = DataGridViewColumnSortMode.NotSortable; dgvFoundQ.Columns[2].Width = 390; dgvFoundQ.Columns[3].Visible = false; dgvFoundQ.Columns[4].HeaderText = "Difficulty"; dgvFoundQ.Columns[4].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dgvFoundQ.Columns[4].SortMode = DataGridViewColumnSortMode.NotSortable; dgvFoundQ.Columns[4].Width = 80; dgvFoundQ.Columns[5].Visible = false; dgvFoundQ.Columns[6].Visible = false; for (int i = 0; i < dgvFoundQ.Rows.Count; i++) { dgvFoundQ.Rows[i].Cells[0].Value = "False"; } }); if (dt.Rows.Count < 1) { DataTable da = new DataTable(); Utilities.InvokeMe(dgvFoundQ, () => { dgvFoundQ.DataSource = da; dgvFoundQ.Columns[0].Visible = false; }); } Utilities.notifyThem(ntbfindQ, "Found " + dt.Rows.Count + " Questions", NotificationBox.Type.Notice); }).Start(); } }