Exemple #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            DataSet          ds    = new DataSet();
            string           query = "Select * from Guest";
            OleDbDataAdapter da    = new OleDbDataAdapter(query, con.Connect());

            da.Fill(ds, "Guest");
            string           query3 = "Select * from Reservation";
            OleDbDataAdapter db     = new OleDbDataAdapter(query3, con.Connect());

            db.Fill(ds, "Reservation");

            string           indate   = dateTimePicker1.Text;
            string           outdate  = dateTimePicker2.Text;
            string           resvdate = dateTimePicker3.Text;
            string           guestid  = "select guestId from Guest where nic=" + textBox1.Text;
            OleDbDataAdapter dc       = new OleDbDataAdapter(guestid, con.Connect());

            dc.Fill(ds, "GuestId");
            string query2 = "Insert into Reservation(guestId,reservationDate,noOfGuests," +
                            "noOfServices,checkIn,checkOut,advance,due)" +
                            "values('" + ds.Tables["GuestId"].Rows[0]["guestId"] + "','" + resvdate + "','" + Convert.ToInt32(textBox2.Text) + "','" + Convert.ToInt32(textBox3.Text) + "','"
                            + indate + "','" + outdate + "','" + Convert.ToInt32(textBox4.Text) + "','" + Convert.ToInt32(textBox5.Text) + "')";

            OleDbCommand com = new OleDbCommand(query2, con.Connect());

            com.ExecuteNonQuery();
            MessageBox.Show("Reservation Has Been Made!");
            home bi = new home();

            bi.Show();
            this.Hide();
        }
Exemple #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            home bi = new home();

            bi.Show();
            this.Hide();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            DataSet          ds    = new DataSet();
            string           query = "Select * from Guest";
            OleDbDataAdapter da    = new OleDbDataAdapter(query, con.Connect());

            da.Fill(ds, "Guest");
            string           query3 = "Select * from Bill";
            OleDbDataAdapter db     = new OleDbDataAdapter(query3, con.Connect());

            db.Fill(ds, "Bill");
            string           query4 = "Select * from Penalty";
            OleDbDataAdapter dc     = new OleDbDataAdapter(query4, con.Connect());

            dc.Fill(ds, "Penalty");

            string           date    = dateTimePicker1.Text;
            string           guestid = "select guestId from Guest where nic=" + textBox3.Text;
            OleDbDataAdapter de      = new OleDbDataAdapter(guestid, con.Connect());

            de.Fill(ds, "GuestId");
            if (textBox7.Text == "" && textBox8.Text == "")
            {
                string query2 = "Insert into Bill(guestId,rentOfServices,rentOfHouse," +
                                "totalCharges,penaltyId,creditcardNo,paymentMethod,paymentDate)" +
                                "values('" + ds.Tables["GuestId"].Rows[0]["guestId"] + "','" + Convert.ToInt32(textBox2.Text) + "','" + Convert.ToInt32(textBox1.Text) +
                                "','" + Convert.ToInt32(textBox4.Text) + "','" + null + "','" + Convert.ToInt32(textBox6.Text) +
                                "','" + textBox5.Text + "','" + date + "')";
                OleDbCommand com = new OleDbCommand(query2, con.Connect());
                com.ExecuteNonQuery();
            }
            else
            {
                string query8 = "Insert into Penalty penaltyName,penaltyCharges) " +
                                "values('" + textBox7.Text + "','" + textBox8.Text + "')";
                OleDbCommand com2 = new OleDbCommand(query8, con.Connect());
                com2.ExecuteNonQuery();
                string           penaltyId = "select max(penaltyId) from Penalty";
                OleDbDataAdapter dp        = new OleDbDataAdapter(penaltyId, con.Connect());
                dp.Fill(ds, "PenId");
                string query2 = "Insert into Bill(guestId,rentOfServices,rentOfHouse," +
                                "totalCharges,penaltyId,creditcardNo,paymentMethod,paymentDate)" +
                                "values('" + ds.Tables["GuestId"].Rows[0]["guestId"] + "','" + Convert.ToInt32(textBox2.Text) + "','" + Convert.ToInt32(textBox1.Text) +
                                "','" + Convert.ToInt32(textBox4.Text) + "','" + ds.Tables["PenId"].Rows[0]["penaltyId"]
                                + "','" + Convert.ToInt32(textBox6.Text) + "','" + textBox5.Text + "','" + date + "')";

                OleDbCommand com = new OleDbCommand(query2, con.Connect());
                com.ExecuteNonQuery();
            }
            home bi = new home();

            bi.Show();
            this.Hide();
        }