Ejemplo n.º 1
0
        /// <summary>
        ///Grab all the information into dataset rows and fill it in the requisite tables
        /// to be fetched later by the trip request form.
        /// </summary>
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            TripDataset td = new TripDataset();

            TripDatasetTableAdapters.CustomerTableAdapter tdCustomer
                = new TripDatasetTableAdapters.CustomerTableAdapter();

            TripDatasetTableAdapters.TripTableAdapter tdTrip
                = new TripDatasetTableAdapters.TripTableAdapter();

            TripDatasetTableAdapters.TripBookedTableAdapter tdBooked
                = new TripDatasetTableAdapters.TripBookedTableAdapter();

            tdCustomer.Fill(td.Customer);
            tdTrip.Fill(td.Trip);

            TripDataset.CustomerRow   rowCust   = td.Customer.NewCustomerRow();
            TripDataset.TripRow       rowTrip   = td.Trip.NewTripRow();
            TripDataset.TripBookedRow rowBooked = td.TripBooked.NewTripBookedRow();

            rowCust.CName  = tbName.Text;
            rowCust.CEmail = tbEmail.Text;
            rowCust.CPhone = Convert.ToDecimal(tbPhone.Text);

            rowTrip.Origin      = tbOrigin.Text;
            rowTrip.Destination = tbDestination.Text;
            var dateAndTime = DateTime.Now.ToString("yyyy-MM-dd");

            rowTrip.BookingDate   = DateTime.Now.Date.ToString("yyyy-MM-dd");
            rowTrip.TripStartDate = tripSD.Value.ToString();
            rowTrip.TripEndDate   = tripED.Value.ToString();
            rowTrip.TotalPrice    = Convert.ToDecimal(tbPrice.Text);



            //System.Diagnostics.Debug.WriteLine("Hotel: " + rowBooked.HotelID);

            if (cbInsurance.Text.Equals("YES"))
            {
                rowTrip.TripInsurance = "Y";
            }
            else
            {
                rowTrip.TripInsurance = "N";
            }

            td.Customer.Rows.Add(rowCust);
            td.Trip.Rows.Add(rowTrip);

            tdCustomer.Update(td.Customer);
            tdTrip.Update(td.Trip);

            rowBooked.HotelID = cbHotel.SelectedIndex;

            DataRow[] dr         = td.Tables[2].Select("CName=" + "'" + tbName.Text + "'");
            int       customerId = Convert.ToInt32(dr[0]["CustomerId"]);

            DataRow[] dr2 = td.Tables[0].Select("BookingDate='" + DateTime.Now.Date.ToString("yyyy-MM-dd") + "' AND Origin='" + tbOrigin.Text + "' AND Destination='" + tbDestination.Text + "'");

            System.Diagnostics.Debug.WriteLine(dr2[0]);

            int tripId = Convert.ToInt32(dr2[0]["TripID"]);


            rowBooked.RoomsBooked  = 1;
            rowBooked.CheckInDate  = tripSD.Value.ToString();
            rowBooked.CheckOutDate = tripED.Value.ToString();

            rowBooked.TripID     = tripId;
            rowBooked.Status     = "Approved";
            rowBooked.CustomerID = customerId;

            td.TripBooked.Rows.Add(rowBooked);
            tdBooked.Update(td.TripBooked);

            DialogResult dialogSuccess = MessageBox.Show("Trip has been booked successfully!!!", "Request Submitted!!!", MessageBoxButtons.OK);

            this.Hide();
            form2.Show();
            System.Diagnostics.Debug.WriteLine("Cname: " + tbName.Text + " " + tbEmail.Text
                                               + tbOrigin.Text + rowTrip.Destination + DateTime.Now.Date + tripSD.Value + tbPhone.Text + " CustomerID: " + customerId + " Trip ID: " + tripId + " Origin: " + tbOrigin.Text + " Destination: " + tbDestination.Text);
            //regRow.CEmail =
        }
Ejemplo n.º 2
0
        /// <summary>
        /// btnBookdeal method executes the code which will grab values
        /// from the prebooked deals and grabs the new information
        /// and sends it to the trip table
        /// </summary>

        private void btnBookdeal_Click(object sender, EventArgs e)
        {
            var dateAndTime = DateTime.Now.ToString("yyyy-MM-dd");

            int     tripId      = ShowDeals.tripID;
            string  tsd         = ShowDeals.tsd;
            string  ted         = ShowDeals.ted;
            string  origin      = ShowDeals.tOrigin;
            string  destination = ShowDeals.destination;
            decimal price       = ShowDeals.price;
            string  bookingDate = dateAndTime;

            System.Diagnostics.Debug.WriteLine("Trip ID: " + tripId);

            TripDataset  td  = new TripDataset();
            TripDataSet2 td2 = new TripDataSet2();

            TripDatasetTableAdapters.CustomerTableAdapter tdCustomer
                = new TripDatasetTableAdapters.CustomerTableAdapter();

            TripDatasetTableAdapters.TripBookedTableAdapter tdBooked
                = new TripDatasetTableAdapters.TripBookedTableAdapter();

            TripDatasetTableAdapters.TripTableAdapter tdTrip
                = new TripDatasetTableAdapters.TripTableAdapter();


            TripDataset.TripBookedRow rowBook = td.TripBooked.NewTripBookedRow();
            TripDataset.CustomerRow   rowCust = td.Customer.NewCustomerRow();


            //row[0]["BookingDate"] = bookingDate.ToString();
            tdTrip.Update(td.Trip);

            rowCust.CName  = tbName.Text;
            rowCust.CEmail = tbEmail.Text;
            rowCust.CPhone = Convert.ToDecimal(tbPhone.Text);

            td.Customer.Rows.Add(rowCust);
            tdCustomer.Update(td.Customer);

            DataRow[] dr         = td.Tables[2].Select("CEmail=" + "'" + tbEmail.Text + "'");
            int       customerId = Convert.ToInt32(dr[0]["CustomerId"]);

            /// <summary>
            /// After inserting all the data into the dataset rows of different table
            /// we grab the ids from those tables and insdert into a
            /// new table
            /// The status which is pending is changed to approve and the gridview
            /// is updates in the finally block
            /// </summary>

            rowBook.TripID     = tripId;
            rowBook.CustomerID = customerId;
            rowBook.HotelID    = cbHotel.SelectedIndex;
            if (Convert.ToInt32(cbRooms.SelectedValue) == 0)
            {
                rowBook.RoomsBooked = 1;
            }
            else
            {
                rowBook.RoomsBooked = Convert.ToInt32(cbRooms.SelectedValue);
            }
            rowBook.Status       = "Pending";
            rowBook.CheckInDate  = tsd;
            rowBook.CheckOutDate = ted;

            td.TripBooked.Rows.Add(rowBook);
            tdBooked.Update(td.TripBooked);

            System.Diagnostics.Debug.WriteLine("Rooms: " + cbRooms.SelectedValue);
            MessageBox.Show("Deal Made!!!");
            this.Hide();
            Form2 form2 = new Form2();

            form2.Show();
        }