Example #1
0
        // edit
        private void button3_Click(object sender, EventArgs e)
        {
            button3.Enabled = false;
            button1.Enabled = false;
            button2.Enabled = false;
            string type = "";
            string desc = "";
            double fare = 0.0;

            if (dataGridView1.RowCount > 0)
            {
                int              rowIndex   = dataGridView1.CurrentCell.RowIndex;
                string           item       = dataGridView1.Rows[rowIndex].Cells[0].Value.ToString();
                string           sql        = "SELECT * from TransportationData where Type like '" + item + "'";
                SQLiteCommand    sqlCommand = new SQLiteCommand(sql, transportData);
                SQLiteDataReader reader     = sqlCommand.ExecuteReader();
                while (reader.Read())
                {
                    type = reader["Type"].ToString();
                    desc = reader["Description"].ToString();
                    fare = Convert.ToDouble(reader["Fares"]);
                }

                AddTransportData add = new AddTransportData(item, desc, fare);
                add.ShowDialog();

                if (add.type != "" && add.description != "" && add.fare != 0.0)
                {
                    string        test_update = "UPDATE TransportationData SET Type = @Type, Description = @Description , Fares = @Fares Where Type = @itemToSearch";
                    SQLiteCommand command     = new SQLiteCommand(test_update, transportData);
                    db.updateSpecificDataInDB(command, add.oldType, add.type, add.description, add.fare);
                    dataGridView1.Rows.Clear();
                    dataGridView1.Refresh();
                    displayDataFromDB(transportData);
                }
            }

            button3.Enabled = true;
            button1.Enabled = true;
            button2.Enabled = true;
            this.Cursor     = Cursors.Default;
        }
Example #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            button1.Enabled = false;
            AddTransportData add = new AddTransportData();

            add.ShowDialog();

            string        t       = "insert into TransportationData (Type, Description, Fares) values ( @Type, @Description, @Fares)";
            SQLiteCommand command = new SQLiteCommand(t, transportData);

            this.Cursor = Cursors.WaitCursor;
            if (add.type != "" && add.description != "" && add.fare != 0.0)
            {
                db.addDataToTransportation(add.type, add.description, add.fare, command);
                dataGridView1.Rows.Clear();
                dataGridView1.Refresh();
                displayDataFromDB(transportData);
            }
            button1.Enabled = true;
            this.Cursor     = Cursors.Default;
        }