private void ButtonConfirm_Click(object sender, EventArgs e)
        {
            try {
                foreach (string el in l)
                {
                    Console.WriteLine(el);
                    SqlConnection con   = Database_Connection.OpenCon();
                    string        query = @"UPDATE seat_status SET status = 'sold' WHERE Seat_no='" + el + "' and trip_id=" + trip_id + "";
                    SqlCommand    cmd   = new SqlCommand(query, con);
                    MessageBox.Show("Successfull\n Thank You.");
                    cmd.ExecuteNonQuery();


                    query = @"insert into user_history (trip_id, seat_no, date, price , user_id) values (" + trip_id + " , '" + el + "', '" + date1 + "', 500 , '" + userId + "')";
                    cmd   = new SqlCommand(query, con);
                    //MessageBox.Show("Successfull\n Thank You.");
                    cmd.ExecuteNonQuery();

                    Database_Connection.CloseCon();
                }
            }
            catch (Exception ex) {
                // MessageBox.Show(Convert.ToString(trip_id));
                MessageBox.Show(ex.ToString());
            }
        }
        private void ButtonConfirm_Click(object sender, EventArgs e)
        {
            try {
                foreach (string el in l)
                {
                    Console.WriteLine(el);
                    SqlConnection con = Database_Connection.OpenCon();

                    string     query = @"UPDATE seat_status SET status = 'sold' WHERE Seat_no='" + el + "' and trip_id=" + trip_id + "";
                    SqlCommand cmd   = new SqlCommand(query, con);

                    cmd.ExecuteNonQuery();

                    Database_Connection.CloseCon();
                }

                SqlConnection con1 = Database_Connection.OpenCon();

                MessageBox.Show("Successfull\n Thank You.");
                string query1 = @"update Bus_info set seat=(seat-" + i + ") where ID=" + trip_id + "";

                SqlCommand cmd1 = new SqlCommand(query1, con1);
                //MessageBox.Show("Successfull\n Thank You.");
                cmd1.ExecuteNonQuery();
                Database_Connection.CloseCon();
            }
            catch (Exception ex) {
                // MessageBox.Show(Convert.ToString(trip_id));
                MessageBox.Show(ex.ToString());
            }
        }
Beispiel #3
0
        public void display()
        {
            SqlConnection  con   = Database_Connection.OpenCon();
            string         query = "select trip_id,seat_no,date,price from user_history where user_id='" + user_id + "'";
            SqlCommand     cmd   = new SqlCommand(query, con);
            DataTable      dt    = new DataTable();
            SqlDataAdapter da    = new SqlDataAdapter(cmd);

            da.Fill(dt);
            dataGridView1.DataSource = dt;
            cmd.ExecuteNonQuery();
            Database_Connection.CloseCon();
        }