private void button2_Click(object sender, EventArgs e)
        {
            //con.Open();
            if (textBox11.Text != "" && textBox12.Text != "")
            {
                if (textBox11.Text != null && textBox12.Text != null)
                {
                    if (con.State == ConnectionState.Open)
                    {
                        String     str = "insert into Booking(CustomerId,DateofJourney,FlightId,Seatno) values('" + Convert.ToInt32(textBox3.Text) + "', '" + Convert.ToString(dateTimePicker1.Text) + "','" + Convert.ToInt32(textBox11.Text) + "','" + Convert.ToInt32(textBox12.Text) + "' )";
                        SqlCommand cmd = new SqlCommand(str, con);
                        cmd.ExecuteNonQuery();
                        String     st = "update  Flight_Details set Seats= Seats-@x where Id='" + Convert.ToInt32(textBox11.Text) + "') ";
                        SqlCommand cm = new SqlCommand(str, con);
                        cm.ExecuteNonQuery();
                        MessageBox.Show("Your seat is booked");
                        this.Hide();
                        Ticket_Reservation lgn = new Ticket_Reservation();
                        lgn.Show();

                        //Ticket_Reservation_Load(sender,e);
                    }
                }
                else
                {
                    MessageBox.Show("Enter all required DATA !!!");
                }
            }
            else
            {
                label11.Visible = true;
            }
        }
Esempio n. 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection  con = new SqlConnection(@"Data Source=DESKTOP-PRPMMA8\HASANDB;Initial Catalog=Flight_booking;Integrated Security=True");
            SqlDataAdapter sda = new SqlDataAdapter("Select Count(*)From customer_detail where name='" + textBox1.Text + "' and password='******'", con);
            DataTable      dt  = new DataTable();

            sda.Fill(dt);
            if (dt.Rows[0][0].ToString() == "1")
            {
                //x = dt.Rows[0][0].ToString();
                // MessageBox.Show(x);
                con.Open();
                String        s   = "Select id From customer_detail where name='" + textBox1.Text + "' and password='******'";
                SqlCommand    cmd = new SqlCommand(s, con);
                SqlDataReader dr  = cmd.ExecuteReader();
                if (dr.Read())
                {
                    x = (dr["id"].ToString());
                    MessageBox.Show(x);
                }
                else
                {
                    MessageBox.Show("error in inner");
                }
                this.Hide();
                Ticket_Reservation lgn = new Ticket_Reservation(x);
                lgn.Show();
            }
            else if (textBox1.Text == "Admin" && textBox2.Text == "Admin")
            {
                MessageBox.Show("You are login as Admin");
                this.Hide();
                Admin lgn = new Admin();
                lgn.Show();
            }
            else
            {
                MessageBox.Show("Please check Your Username and password");
            }
        }