示例#1
0
        protected void Button_MakePayment_Click(object sender, EventArgs e)
        {
            //************************ Insertar reservacion en tabla
            //Creo objeto de table adapter
            DataSet_dbFlightHotelTableAdapters.tbFlightBookingTableAdapter taBooking = new DataSet_dbFlightHotelTableAdapters.tbFlightBookingTableAdapter();

            //Creo objeto de tabla formato flight booking
            DataSet_dbFlightHotel.tbFlightBookingDataTable dtBooking = new DataSet_dbFlightHotel.tbFlightBookingDataTable();

            //Primero genero objeto de fecha de hoy
            DateTime dtDateOfBooking = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);

            //Genero objeto de fecha de ida
            DateTime dtDateOfDeparture = new DateTime(int.Parse(Request.Cookies["DatosVuelo"]["Year"]),
                                                      int.Parse(Request.Cookies["DatosVuelo"]["Month"]),
                                                      int.Parse(Request.Cookies["DatosVuelo"]["Day"]), 0, 0, 0);

            //Ahora inserto
            taBooking.Insert(int.Parse(Request.Cookies["DatosVuelo"]["FlightNo"]),
                             int.Parse(Request.Cookies["DatosVuelo"]["CustomerID"]),
                             dtDateOfBooking,
                             dtDateOfDeparture,
                             int.Parse(Request.Cookies["DatosVuelo"]["NoOfAdults"]),
                             int.Parse(Request.Cookies["DatosVuelo"]["NoOfChildren"]));

            //####################################


            ////************************************************ Inserto los pasajeros

            //Creo table adapter de pasajeros
            DataSet_dbFlightHotelTableAdapters.tbPassengersListTableAdapter taPassenger = new DataSet_dbFlightHotelTableAdapters.tbPassengersListTableAdapter();

            //Inserto adultos
            int i = 0;
            //string sAlgo = Request.Cookies["PassengerAdults"][i.ToString()].ToString();

            //Primero obtengo e imprimo su booking ID, ya que lo necesito para insertar el pasajero
            int?iBookingID = taBooking.MaxBooking();

            Response.Write("<script LANGUAGE='JavaScript' >alert('Your booking id is: " + iBookingID.ToString() + " ')</script>");

            for (i = 0; i < int.Parse(Request.Cookies["DatosVuelo"]["NoOfAdults"]); i++)
            {
                int?iSiguiente;
                //Calculo el siguiente pasajero
                if (taPassenger.SiguientePasajero() == null)
                {
                    iSiguiente = 1;
                }
                else
                {
                    iSiguiente = int.Parse(taPassenger.SiguientePasajero().ToString()) + 1;
                }

                //Inserto el pasajero
                taPassenger.Insert(int.Parse(Request.Cookies["DatosVuelo"]["FlightNo"]),
                                   dtDateOfDeparture,
                                   int.Parse(iSiguiente.ToString()),
                                   iBookingID,
                                   "A",
                                   Session[i.ToString()].ToString().Split('*')[0].ToString(),
                                   Session[i.ToString()].ToString().Split('*')[1].ToString(),
                                   Session[i.ToString()].ToString().Split('*')[2].ToString());
            }

            //Inserto ninos
            //sAlgo = Request.Cookies["PassengerChildren"]["1"].ToString();
            for (int r = i; r <= int.Parse(Request.Cookies["DatosVuelo"]["NoOfChildren"]); r++)
            {
                int?iSiguiente;
                //Calculo el siguiente pasajero
                if (taPassenger.SiguientePasajero() == null)
                {
                    iSiguiente = 1;
                }
                else
                {
                    iSiguiente = int.Parse(taPassenger.SiguientePasajero().ToString()) + 1;
                }

                //Inserto el pasajero
                taPassenger.Insert(int.Parse(Request.Cookies["DatosVuelo"]["FlightNo"]),
                                   dtDateOfDeparture,
                                   int.Parse(iSiguiente.ToString()),
                                   iBookingID,
                                   "A",
                                   "CHL",
                                   Session[r.ToString()].ToString().Split('*')[0].ToString(),
                                   Session[r.ToString()].ToString().Split('*')[1].ToString());
            }
            //************************************************


            //#################################### Inserto el pago

            //Inserto el payment en la tabla de payment

            //Table adapter de Flight
            DataSet_dbFlightHotelTableAdapters.tbFlightPaymentTableAdapter taPayment = new DataSet_dbFlightHotelTableAdapters.tbFlightPaymentTableAdapter();
            string a = (Request.Cookies["Totals"]["BaseFareAdults"]);

            a = (Request.Cookies["Totals"]["BaseFareChildren"]);
            a = Request.Cookies["Totals"]["TaxAdult"];
            a = Request.Cookies["Totals"]["TaxChildren"];
            decimal?dTotalTax = decimal.Parse(Request.Cookies["Totals"]["TaxAdult"]);

            dTotalTax = decimal.Parse(Request.Cookies["Totals"]["TaxChildren"]) + dTotalTax;
            decimal?dBaseAdults   = decimal.Parse(Request.Cookies["Totals"]["BaseFareAdults"]);
            decimal?dBaseChildren = decimal.Parse(Request.Cookies["Totals"]["BaseFareChildren"]);
            int     iNextPayment;

            if ((taPayment.GetNextPaymentID() == null))
            {
                iNextPayment = 1;
            }
            else
            {
                iNextPayment = int.Parse(taPayment.GetNextPaymentID().ToString()) + 1;
            }

            //Inserto el pago
            taPayment.Insert(iNextPayment,
                             "F",
                             int.Parse(iBookingID.ToString()),
                             dBaseAdults,
                             dBaseChildren,
                             dTotalTax,
                             decimal.Parse("0"));
            //####################################
            Button_BookHotel.Visible   = true;
            Button_MakePayment.Visible = false;
            Button_Cancel.Text         = "Return";
        }
        protected void Button_MakePayment_Click(object sender, EventArgs e)
        {
            int?iHotelId = int.Parse(Session["HotelID"].ToString());
            // Obtener CustomerId
            int?iCustomerId = int.Parse(Session["CustomerId"].ToString());
            // Obtener date of booking
            DateTime dDateOfBooking = DateTime.Parse(Session["CheckInDate"].ToString());
            // Obtener DLXRooms
            int?iDLXRooms = int.Parse(Session["DLXRooms"].ToString());
            // Obtener EXERooms
            int?iEXERooms = int.Parse(Session["EXERooms"].ToString());
            // obtener checkInDate
            DateTime dCheckInDate = DateTime.Parse(Session["CheckInDate"].ToString());
            //Fecha de hoy
            DateTime?dtNow = DateTime.Now;
            //Fecha de salida
            DateTime?dCheckOutDate = DateTime.Parse(Session["CheckOutDate"].ToString());

            // crear tableadapter de tabla tbHotelBooking
            DataSet_dbFlightHotelTableAdapters.tbHotelBookingTableAdapter taHotelBooking = new DataSet_dbFlightHotelTableAdapters.tbHotelBookingTableAdapter( );

            //Ejecuta el sp para insertar el booking
            taHotelBooking.prcInsertHotelBooking(iHotelId, iCustomerId, dtNow, iDLXRooms, iEXERooms, dCheckInDate, dCheckOutDate);

            //Objeto de payment table adapter
            DataSet_dbFlightHotelTableAdapters.tbFlightPaymentTableAdapter taPayment = new DataSet_dbFlightHotelTableAdapters.tbFlightPaymentTableAdapter();

            //Obtengo el siguiente payment ID
            string PaymentID = taPayment.GetNextPaymentID().ToString();

            if (PaymentID == "" || string.IsNullOrEmpty(PaymentID))
            {
                PaymentID = "1";
            }
            int iNextPaymentID = int.Parse(PaymentID) + 1;


            //Obtengo el booking id
            string sBookingID = taHotelBooking.GetMaxBookingID().ToString();

            if (sBookingID == "" || string.IsNullOrEmpty(sBookingID))
            {
                sBookingID = "1";
            }

            int iBookingID = int.Parse(sBookingID);

            //Inserto el pago
            //string dlx = Session["DLXFarPerDay"].ToString();
            //string exe =
            //taPayment.prcInsertHotelPayment( iBookingID,
            //                                decimal.Parse(Session["DLXFarPerDay"].ToString()),
            //                                decimal.Parse(Session["EXEFarPerDay"].ToString()),
            //                                decimal.Parse(Label_TotalTaxAmount.Text),
            //                                decimal.Parse(Label_DiscountPct.Text)
            //);

            taPayment.Insert(iNextPaymentID,
                             "H",
                             iBookingID,
                             decimal.Parse(Session["DLXFarPerDay"].ToString()),
                             decimal.Parse(Session["EXEFarPerDay"].ToString()),
                             decimal.Parse(Label_TotalTaxAmount.Text),
                             decimal.Parse(Label_GrandTotal.Text));
            Response.Write("<script LANGUAGE='JavaScript' >alert('Your booking id is: " + iBookingID.ToString() + " ')</script>");
            Button_MakePayment.Visible = false;
        }