LoadTags() public static method

public static LoadTags ( AutocompleteMenuNS autoCMenu = null ) : void
autoCMenu AutocompleteMenuNS
return void
示例#1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtAddQ.Text.Trim()) == true || string.IsNullOrEmpty(txtAddTags.Text.Trim()) == true || (dgvAnswerlist.Rows.Count < 1))
            {
                Utilities.notifyThem(ntfAdd, "You must fill some info about your question first", NotificationBox.Type.Error);
            }
            else
            {
                List <Answer> Answers = new List <Answer>();
                for (int i = 0; i < dgvAnswerlist.Rows.Count; i++)
                {
                    Answers.Add(new Answer(dgvAnswerlist.Rows[i].Cells[0].Value.ToString().TrimEnd().TrimStart(), bool.Parse(dgvAnswerlist.Rows[i].Cells[1].Value.ToString())));
                }
                Utilities.runInThread(() =>
                {
                    DB TempDB = Utilities.AsyncDB(true);
                    TempDB.bind(new string[] { "Question", txtAddQ.Text.TrimEnd().TrimStart(), "Answers", JsonConvert.SerializeObject(Answers).ToString(), "Dlevel", difficultyLvl.Value.ToString(), "Prive", (switchPrivate.isOn ? 1 : 0).ToString(), "UID", Globals.logUser.id.ToString() });
                    string qid = TempDB.single("INSERT INTO questions (question, answers, dlevel, prive, uid) VALUES (@Question, @Answers, @Dlevel, @Prive, @UID); select last_insert_id();");

                    int qAddTag   = 0;
                    string[] tags = txtAddTags.Text.TrimEnd(',').Split(',');
                    foreach (string tag in tags)
                    {
                        if (!string.IsNullOrEmpty(tag))
                        {
                            TempDB.bind(new string[] { "TAG", tag.ToLower(), "QID", qid });
                            qAddTag += TempDB.nQuery("INSERT INTO tags (nametag, qid) VALUES (@TAG, @QID)");
                        }
                    }

                    if (string.IsNullOrEmpty(qid) == false && qAddTag > 0)
                    {
                        Utilities.notifyThem(ntfAdd, "Successfull Added Question !", NotificationBox.Type.Success);
                        Functionality.RefreshMyQuestions();
                        Utilities.clearText(txtAddQ, txtAddTags, txtAnswer);
                        Utilities.InvokeMe(dgvAnswerlist, () =>
                        {
                            dgvAnswerlist.Rows.Clear();
                            dgvAnswerlist.Refresh();
                        });
                        Utilities.InvokeMe(difficultyLvl, () =>
                        {
                            difficultyLvl.Value = 1;
                        });
                        Utilities.InvokeMe(switchPrivate, () =>
                        {
                            switchPrivate.isOn = false;
                        });
                        Utilities.InvokeMe(switchCorrectAnswer, () =>
                        {
                            switchCorrectAnswer.isOn = true;
                        });

                        Functionality.LoadTags(autocompleteMenu1);
                    }
                }).Start();
            }
        }
示例#2
0
        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);
            }
        }
示例#3
0
 private void tabUser_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (tabUser.SelectedIndex == 7)
     {
         Globals.MyTestQids.Clear();
         Globals.formStart.Show();
         Globals.formMain.Close();
         Globals.formMain = new frmMain();
     }
     if (tabUser.SelectedIndex == 2 || tabUser.SelectedIndex == 3)
     {
         Utilities.runInThread(() =>
         {
             Functionality.LoadTags(autocompleteMenu1);
         }).Start();
     }
 }