示例#1
0
        public List <cmHabitacion> fnlsRecuperaOpciones(cmHabitacion oHabitacion)
        {
            List <cmHabitacion> LsOpcioHab = new List <cmHabitacion>();

            using (SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["SQLConn"]))
            {
                using (SqlCommand cmd = new SqlCommand("spsObtPropuestas", con))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.Add("@IdViaje", SqlDbType.VarChar).Value    = oHabitacion.idViaje;
                    cmd.Parameters.Add("@Total", SqlDbType.VarChar).Value      = oHabitacion.iPasajeros;
                    cmd.Parameters.Add("@Decremento", SqlDbType.VarChar).Value = oHabitacion.iDecremento;

                    con.Open();
                    SqlDataReader rdr = cmd.ExecuteReader();
                    while (rdr.Read())
                    {
                        LsOpcioHab.Add(new cmHabitacion
                        {
                            idTipoHab     = rdr.GetInt32(0),
                            nvDescripcion = rdr.GetString(1),
                            icapMax       = rdr.GetInt32(2),
                            inumHab       = rdr.GetInt32(3),
                            dCosto        = rdr.GetDecimal(4)
                        });
                    }
                }
            }
            return(LsOpcioHab);


            /* using (var contexto = new TravelOKEntitiesQAModelEntities())
             * {
             *   List<cmHabitacion> LsOpcioHab = new List<cmHabitacion>();
             *   //LsOpcioHab = (from salida in contexto.spsObtPropuestas(oHabitacion.idViaje,oHabitacion.iPasajeros,oHabitacion.iDecremento)).ToList();
             * }*/
        }
示例#2
0
        public ActionResult InsertaViajeros(List <cmViajeros> oUsrViajeros)
        {
            if (Session["UserName"] == null)
            {
                return(RedirectToAction("TravelInicio", "Logueo"));
            }
            JObject resultado = new JObject();

            if (oUsrViajeros.Count > 0)
            {
                CD_Viajeros cdViajeros = new CD_Viajeros();
                oUsrViajeros.ToList().ForEach(cc => cc.idUsuario = Session["UserID"].ToString());
                cmHabitacion oHabitacion = new cmHabitacion
                {
                    iPasajeros = oUsrViajeros.Count,
                    idViaje    = oUsrViajeros[0].idViaje
                };
                CD_DetVenta odVenta = new CD_DetVenta();
                decimal     tot     = 0;
                switch (oUsrViajeros[0].sOpcionTour)
                {
                case "btnOp-0":
                    oHabitacion.iDecremento = 0;
                    foreach (cmHabitacion hab in odVenta.fnlsRecuperaOpciones(oHabitacion))
                    {
                        tot += hab.dCosto;
                    }
                    oUsrViajeros.ToList().ForEach(cc => cc.dCostoTotal = tot);
                    break;

                case "btnOp-1":
                    oHabitacion.iDecremento = 1;
                    foreach (cmHabitacion hab in odVenta.fnlsRecuperaOpciones(oHabitacion))
                    {
                        tot += hab.dCosto;
                    }
                    oUsrViajeros.ToList().ForEach(cc => cc.dCostoTotal = tot);
                    break;

                case "btnOp-2":
                    oHabitacion.iDecremento = 2;
                    foreach (cmHabitacion hab in odVenta.fnlsRecuperaOpciones(oHabitacion))
                    {
                        tot += hab.dCosto;
                    }
                    oUsrViajeros.ToList().ForEach(cc => cc.dCostoTotal = tot);
                    break;

                case "btnOp-3":
                    oHabitacion.iDecremento = 0;
                    foreach (cmHabitacion hab in odVenta.fnlsRecuperaOpciones(oHabitacion))
                    {
                        tot += hab.dCosto;
                    }
                    oUsrViajeros.ToList().ForEach(cc => cc.dCostoTotal = tot);
                    break;
                }

                if (cdViajeros.InsertaViajeros(oUsrViajeros))
                {
                    resultado["Exito"]  = true;
                    Session["UserID"]   = Session["UserID"];
                    Session["UserName"] = Session["UserName"];
                    Session["dCosto"]   = tot;
                }
                else
                {
                    resultado["Exito"] = false;
                }
            }
            else
            {
                resultado["Exito"] = false;
            }
            return(Content(resultado.ToString()));
        }
示例#3
0
        public ActionResult ObtienePropuestas(cmHabitacion oHabitacion)
        {
            if (Session["UserName"] == null)
            {
                return(RedirectToAction("TravelInicio", "Logueo"));
            }
            var resultado = new JObject();

            try
            {
                CD_DetVenta         odVenta        = new CD_DetVenta();
                List <cmHabitacion> lsHabitaciones = new List <cmHabitacion>();
                int count = 0;
                if (oHabitacion.iPasajeros > 2)
                {
                    while (count < 3)
                    {
                        oHabitacion.iDecremento = count;
                        lsHabitaciones          = odVenta.fnlsRecuperaOpciones(oHabitacion);
                        decimal tot = 0;
                        foreach (cmHabitacion hab in lsHabitaciones)
                        {
                            tot += hab.dCosto;
                        }
                        if (count == 0)
                        {
                            resultado["Opcion0"] = JToken.FromObject(lsHabitaciones);
                            resultado["Total0"]  = tot;
                        }
                        if (count == 1)
                        {
                            resultado["Opcion1"] = JToken.FromObject(lsHabitaciones);
                            resultado["Total1"]  = tot;
                        }
                        if (count == 2)
                        {
                            resultado["Opcion2"] = JToken.FromObject(lsHabitaciones);
                            resultado["Total2"]  = tot;
                        }
                        count++;
                    }
                }
                else
                {
                    oHabitacion.iDecremento = 0;
                    lsHabitaciones          = odVenta.fnlsRecuperaOpciones(oHabitacion);
                    decimal tot = 0;
                    foreach (cmHabitacion hab in lsHabitaciones)
                    {
                        tot += hab.dCosto;
                    }
                    resultado["Opcion"] = JToken.FromObject(lsHabitaciones);
                    resultado["Total"]  = tot;
                }
                if (lsHabitaciones.Count > 0)
                {
                    resultado["Exito"] = true;
                }

                /*lsHabitaciones = odVenta.fnlsRecuperaOpciones(new cmHabitacion
                 * {
                 *  iPasajeros = 10,
                 *  idViaje = 2,
                 *  iDecremento = 0
                 * });*/
            }
            catch (Exception ex)
            {
                resultado["Exito"] = false;
            }
            return(Content(resultado.ToString()));
        }