Exemple #1
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (lblID.Text != null)
     {
         var frm = new New_Trip(int.Parse(lblID.Text));
         frm.Show();
     }
 }
Exemple #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            var cmd = DBConn.CreateCommand();

            cmd.CommandText = "INSERT INTO trip (date, place) VALUES (@date, @place)";
            cmd.Parameters.AddWithValue("@date", dtp.Value);
            cmd.Parameters.AddWithValue("@place", txtPlace.Text);
            var recs = cmd.ExecuteNonQuery();

            if (recs > 0)
            {
                cmd.CommandText = "SELECT MAX(tripID) FROM trip";
                var tripID = int.Parse(cmd.ExecuteScalar().ToString());

                var frm = new New_Trip(tripID);
                frm.Show();
            }
            else
            {
                MessageBox.Show("Couldn't create new trip." + Environment.NewLine + "Please try again.", "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }