private void Button_Click_2(object sender, RoutedEventArgs e)
 {
     if (tbx1.Text == "")
     {
         var var_name = new MessageDialog("Please add a question.");
         var_name.Commands.Add(new UICommand("OK"));
         var_name.ShowAsync();
     }
     else
     {
         var db = new SQLite.SQLiteConnection(App.DBPath);
         qna q  = new qna();
         q.question = tbx1.Text;
         db.Insert(q);
         var var_name = new MessageDialog("Question added successfully");
         var_name.Commands.Add(new UICommand("OK"));
         var_name.ShowAsync();
         tbx1.Text = "";
     }
 }
Beispiel #2
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            try
            {
                var db = new SQLite.SQLiteConnection(App.DBPath);
                qna qa = new qna();

                int a      = Convert.ToInt32(textbox1.Text);
                var emptab = (db.Table <qna>().Where(em => em.qno == a)).Single();

                if (emptab.ans1 == null)
                {
                    qa.ans1 = textbox3.Text;
                    goto l3;
                }
                else if (emptab.ans2 == null)
                {
                    qa.ans2 = textbox3.Text;
                    goto l3;
                }
                else if (emptab.ans3 == null)
                {
                    qa.ans3 = textbox3.Text;
                    goto l3;
                }
                else if (emptab.ans4 == null)
                {
                    qa.ans4 = textbox3.Text;
                    goto l3;
                }
                else if (emptab.ans5 == null)
                {
                    qa.ans5 = textbox3.Text;
                    goto l3;
                }
                else if (emptab.ans6 == null)
                {
                    qa.ans6 = textbox3.Text;
                    goto l3;
                }
                else if (emptab.ans7 == null)
                {
                    qa.ans7 = textbox3.Text;
                    goto l3;
                }
                else if (emptab.ans8 == null)
                {
                    qa.ans8 = textbox3.Text;
                    goto l3;
                }
                else if (emptab.ans9 == null)
                {
                    qa.ans9 = textbox3.Text;
                    goto l3;
                }
                else if (emptab.ans10 == null)
                {
                    qa.ans10 = textbox3.Text;
                    goto l3;
                }
                else
                {
                    var var_name = new MessageDialog("Answer is not sent !! try again");
                    var_name.Commands.Add(new UICommand("OK"));
                    var_name.ShowAsync();
                }

                l3 :   db.Insert(qa);
                var d = new MessageDialog("Your answer is send.Thank you");
                d.Commands.Add(new UICommand("OK"));
                d.ShowAsync();
            }
            catch (Exception ex)
            {
                textbox3.Text = ex.Message;
            }
        }