Ejemplo n.º 1
0
        public List <PedidoBebida> ListarBebidasPedido(Int64 idMesa)
        {
            SqlConnection       conexion = new SqlConnection();
            SqlCommand          comando  = new SqlCommand();
            SqlDataReader       lector;
            List <PedidoBebida> listado = new List <PedidoBebida>();
            PedidoBebida        nuevo;

            try
            {
                conexion.ConnectionString = AccesoDatosManager.cadenaConexion;
                comando.CommandType       = System.Data.CommandType.Text;
                //MSF-20190420: agregué todos los datos del heroe. Incluso su universo, que lo traigo con join.
                comando.CommandText = "bebidaxmesa " + idMesa;
                comando.Connection  = conexion;
                conexion.Open();
                lector = comando.ExecuteReader();

                while (lector.Read())
                {
                    nuevo           = new PedidoBebida();
                    nuevo.Id        = lector.GetInt64(0);
                    nuevo.Cantiadad = lector.GetInt64(4);
                    nuevo.Nombre    = lector.GetString(1);
                    nuevo.Precio    = Math.Round(lector.GetDecimal(3), 2);

                    if (lector.GetBoolean(5))
                    {
                        nuevo.Estado = "Entregado";
                    }
                    else
                    {
                        nuevo.Estado = "Pendiente";
                    }

                    if (!Convert.IsDBNull(lector["descripcion"]))
                    {
                        nuevo.Descripcion = (string)lector["descripcion"];
                    }

                    listado.Add(nuevo);
                }

                return(listado);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                conexion.Close();
            }
        }
Ejemplo n.º 2
0
        public List <PedidoBebida> CobrarBebidas(Int64 idMesa)
        {
            SqlConnection       conexion = new SqlConnection();
            SqlCommand          comando  = new SqlCommand();
            SqlDataReader       lector;
            List <PedidoBebida> listado = new List <PedidoBebida>();
            PedidoBebida        nuevo;

            try
            {
                conexion.ConnectionString = AccesoDatosManager.cadenaConexion;
                comando.CommandType       = System.Data.CommandType.Text;
                //MSF-20190420: agregué todos los datos del heroe. Incluso su universo, que lo traigo con join.
                comando.CommandText = "SpCobrarBebidas " + idMesa;
                comando.Connection  = conexion;
                conexion.Open();
                lector = comando.ExecuteReader();

                while (lector.Read())
                {
                    nuevo             = new PedidoBebida();
                    nuevo.Id          = lector.GetInt64(0);
                    nuevo.Cantiadad   = lector.GetInt64(4);
                    nuevo.Nombre      = lector.GetString(1);
                    nuevo.Precio      = Math.Round(lector.GetDecimal(3), 2);
                    nuevo.Descripcion = lector.GetString(2);


                    listado.Add(nuevo);
                }

                return(listado);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                conexion.Close();
            }
        }