Exemplo n.º 1
0
        private void button2_Click(object sender, EventArgs e)
        {
            validate val = new validate();

            val.ShowDialog();

            if (val.upflag == "1")
            {
                try
                {
                    using (SQLiteConnection conn = new SQLiteConnection(DBConn.LoadConnectionString()))
                    {
                        string qry = @"delete from todo where code = @code";
                        conn.Open();
                        SQLiteCommand cmd = new SQLiteCommand(qry, conn);
                        cmd.Parameters.AddWithValue("@code", this.label2.Text);
                        cmd.ExecuteNonQuery();
                        MessageBox.Show("Task Deleted!");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
            else
            {
                MessageBox.Show("Oops, Wrong Password");
                return;
            }
            loadTask();
        }
Exemplo n.º 2
0
        private void clearDatabaseToolStripMenuItem_Click(object sender, EventArgs e)
        {
            validate val = new validate();

            val.ShowDialog();

            if (val.upflag == "1")
            {
                try
                {
                    using (SQLiteConnection conn = new SQLiteConnection(DBConn.LoadConnectionString()))
                    {
                        string qry = @"DELETE FROM todo;    
                                        DELETE FROM sqlite_sequence WHERE name = 'todo';";
                        conn.Open();
                        SQLiteCommand cmd = new SQLiteCommand(qry, conn);
                        cmd.ExecuteNonQuery();
                        MessageBox.Show("DATABASE CLEARED!");
                        loadTask();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
            else
            {
                MessageBox.Show("Oops, Wrong Password");
                return;
            }
        }
Exemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            string strPending  = "update todo set done_flag = 'Done' where code = @code";
            string strDone     = "update todo set done_flag = 'Pending' where code = @code";
            string messPending = "Task Marked as Done!";
            string messDone    = "Task Marked as Pending!";
            string qry         = null;
            string mess        = null;

            if (comboBox1.Text == "Pending")
            {
                qry  = strPending;
                mess = messPending;
            }
            else if (comboBox1.Text == "Done")
            {
                validate val = new validate();
                val.ShowDialog();

                if (val.upflag == "1")
                {
                    qry  = strDone;
                    mess = messDone;
                }
                else
                {
                    MessageBox.Show("Oops, Wrong Password");
                    return;
                }
            }
            else
            {
                return;
            }
            try
            {
                using (SQLiteConnection conn = new SQLiteConnection(DBConn.LoadConnectionString()))
                {
                    conn.Open();
                    SQLiteCommand cmd = new SQLiteCommand(qry, conn);
                    cmd.Parameters.AddWithValue("@code", label2.Text);
                    cmd.ExecuteNonQuery();
                    MessageBox.Show(mess);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                label2.Text = "*";
                loadTask();
            }
        }
Exemplo n.º 4
0
        private void button3_Click(object sender, EventArgs e)
        {
            validate val = new validate();

            val.ShowDialog();

            if (val.upflag == "1")
            {
                alterTask a = new alterTask(this);
                a.ShowDialog();
            }
            else
            {
                MessageBox.Show("Oops, Wrong Password");
                return;
            }
            loadTask();
        }