Exemplo n.º 1
0
        public Form1()
        {
            InitializeComponent();

            sort = Sort.ID;
            goal = 100;

            dbConnection = new SQLiteConnection("Data Source=GradeDatabase.db;Version=3;");
            dbConnection.Open();

            // Test for grades table
            try
            {
                string           sql     = "select * from grades";
                SQLiteCommand    command = new SQLiteCommand(sql, dbConnection);
                SQLiteDataReader reader  = command.ExecuteReader();
            }
            catch
            {
                string        sql     = GradeItem.MakeTableText();
                SQLiteCommand command = new SQLiteCommand(sql, dbConnection);
                command.ExecuteNonQuery();
            }

            label7.Text = "";

            RefreshDisplay();
        }
Exemplo n.º 2
0
        private void InsertClick(object sender, EventArgs e)
        {
            // read in and validate values, then add new item to database
            if (textBox1.Text == "")
            {
                MessageBox.Show("Please enter Class ID");
                textBox1.Focus();
                return;
            }
            if (textBox2.Text == "")
            {
                MessageBox.Show("Please enter Assignment");
                textBox2.Focus();
                return;
            }

            int count;
            int finished;
            int length;
            int priority;

            if (!numTextBox1.GetValue(out count))
            {
                MessageBox.Show("Please enter number of items");
                numTextBox1.Focus();
                return;
            }
            if (!numTextBox2.GetValue(out finished))
            {
                MessageBox.Show("Please enter number finished");
                numTextBox2.Focus();
                return;
            }
            if (!numTextBox3.GetValue(out length))
            {
                MessageBox.Show("Please enter task length");
                numTextBox3.Focus();
                return;
            }
            if (!numTextBox4.GetValue(out priority))
            {
                MessageBox.Show("Please enter task priority");
                numTextBox4.Focus();
                return;
            }

            string classId    = textBox1.Text;
            string assignment = textBox2.Text;

            bool done = checkBox1.Checked ? true : false;

            Item      = new GradeItem(classId, assignment, count, finished, length, priority);
            Item.Done = done;

            this.DialogResult = DialogResult.OK;
        }
Exemplo n.º 3
0
        private void AddItemClick(object sender, EventArgs e)
        {
            GradeItemDialog gid = new GradeItemDialog();

            if (gid.ShowDialog() == DialogResult.OK)
            {
                GradeItem i = gid.Item;

                string        sql     = i.SQLiteInsert();
                SQLiteCommand command = new SQLiteCommand(sql, dbConnection);
                command.ExecuteNonQuery();

                RefreshDisplay();
            }
            else
            {
                //MessageBox.Show("Task Add Canceled");
            }
        }
Exemplo n.º 4
0
        private void NewDatabaseClick(object sender, EventArgs e)
        {
            if (MessageBox.Show("Would you like to drop all tables and rebuild the database?", "Drop Tables", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                if (MessageBox.Show("Are you REALLY sure you want to drop all tables and rebuild the database?", "Drop Tables", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    string        sql;
                    SQLiteCommand command;
                    sql     = "DROP TABLE IF EXISTS grades";
                    command = new SQLiteCommand(sql, dbConnection);
                    command.ExecuteNonQuery();

                    sql = GradeItem.MakeTableText();
                    richTextBox1.Text = sql;
                    command           = new SQLiteCommand(sql, dbConnection);
                    command.ExecuteNonQuery();

                    MessageBox.Show("done.");
                }
            }
        }