예제 #1
0
        public BindingList <Orden> listarOrdenes()
        {
            BindingList <Orden> lista = new BindingList <Orden>();
            String          cadena    = "server=50.62.209.188;" + "user=fpaz; password=123456; database=LP2;" + "port=3306";
            MySqlConnection conn      = new MySqlConnection(cadena);

            conn.Open();
            MySqlCommand comando = new MySqlCommand();

            comando.CommandText = "SELECT * FROM ORDEN";
            comando.Connection  = conn;

            MesaDA             mesaDA   = new MesaDA();
            BindingList <Mesa> lstMesas = new BindingList <Mesa>();

            lstMesas = mesaDA.listarMesas();

            OrdenMenuDetalleDA detalleDA = new OrdenMenuDetalleDA();
            BindingList <Orden_Menu_Detalle> lstDetalle = new BindingList <Orden_Menu_Detalle>();

            lstDetalle = detalleDA.listarDetalleDeOrden();

            MySqlDataReader reader = comando.ExecuteReader();

            while (reader.Read())
            {
                Orden o = new Orden();
                o.Id = reader.GetInt32(0);
                int idMesa = reader.GetInt32(1);
                for (int i = 0; i < lstMesas.Count(); i++)
                {
                    if (lstMesas.ElementAt(i).Id == o.Id)
                    {
                        o.Mesa = lstMesas.ElementAt(i);
                        break;
                    }
                }
                for (int i = 0; i < lstDetalle.Count(); i++)
                {
                    if (lstDetalle.ElementAt(i).IdOrden == o.Id)
                    {
                        o.DetalleOrden.Add(lstDetalle.ElementAt(i));
                    }
                }
                o.Hora_orden = reader.GetDateTime(2);
                o.PreioTotal = reader.GetDouble(3);
                lista.Add(o);
            }
            conn.Close();
            return(lista);
        }
예제 #2
0
        public bool registrarOrden(Orden o)
        {
            String          cadena = "server=50.62.209.188;" + "user=fpaz; password=123456; database=LP2;" + "port=3306";
            MySqlConnection conn   = new MySqlConnection(cadena);

            conn.Open();
            MySqlCommand comando = new MySqlCommand();

            comando.CommandText = "INSERT INTO ORDEN(ID_ORDEN,FID_NUMERO_MESA,FECHA_HORA_ORDEN,PRECIO_TOTAL) VALUES ('NULL','" + o.Mesa.Id + "','" + o.Hora_orden + "','" + o.PreioTotal + "')";
            comando.Connection  = conn;
            comando.ExecuteNonQuery();
            OrdenMenuDetalleDA detalleDA = new OrdenMenuDetalleDA();

            for (int i = 0; i < o.DetalleOrden.Count(); i++)
            {
                detalleDA.registrarDetallePedido(o.DetalleOrden.ElementAt(i));
            }
            return(true);
        }