示例#1
0
        public List <PedidoPlato> ListarPlatosXmesa(Int64 idMesa)
        {
            SqlConnection      conexion = new SqlConnection();
            SqlCommand         comando  = new SqlCommand();
            SqlDataReader      lector;
            List <PedidoPlato> listado = new List <PedidoPlato>();
            PedidoPlato        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 = "platoxmesa " + idMesa;
                comando.Connection  = conexion;
                conexion.Open();
                lector = comando.ExecuteReader();

                while (lector.Read())
                {
                    nuevo          = new PedidoPlato();
                    nuevo.Id       = lector.GetInt64(0);
                    nuevo.Cantidad = lector.GetInt64(1);
                    nuevo.Plato    = lector.GetString(2);
                    nuevo.Precio   = Math.Round(lector.GetDecimal(4), 2);
                    if (lector.GetBoolean(6))
                    {
                        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();
            }
        }
示例#2
0
        public List <PedidoPlato> ListarPlatoPendiente(Int64 idMesa)
        {
            SqlConnection      conexion = new SqlConnection();
            SqlCommand         comando  = new SqlCommand();
            SqlDataReader      lector;
            List <PedidoPlato> listado = new List <PedidoPlato>();
            PedidoPlato        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 = "spPlatosPendientes " + idMesa;
                comando.Connection  = conexion;
                conexion.Open();
                lector = comando.ExecuteReader();

                while (lector.Read())
                {
                    nuevo          = new PedidoPlato();
                    nuevo.Id       = lector.GetInt64(0);
                    nuevo.Cantidad = lector.GetInt64(3);
                    nuevo.Plato    = lector.GetString(1);
                    nuevo.Precio   = Math.Round(lector.GetDecimal(2), 2);
                    nuevo.Estado   = "Pendiente";


                    listado.Add(nuevo);
                }

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