public CostoExtra leerPorId(int id)
        {
            string query = string.Format("select * from costo_extra where id_costo_extra = {0};", id);

            string descripcion = "";
            double importe     = 0;

            foreach (List <Object> unRegistro in dBConector.consultarQuery(query))
            {
                Console.WriteLine("id:" + unRegistro.ElementAt(0));
                Console.WriteLine("descr:" + unRegistro.ElementAt(1));
                Console.WriteLine("importe:" + Convert.ToDouble(unRegistro.ElementAt(2)));


                descripcion = (string)unRegistro.ElementAt(1);

                importe = Convert.ToDouble(unRegistro.ElementAt(2));
                CostoExtra costoExtra = new CostoExtra(descripcion, importe);
                costoExtra.idCostoExtra = (int)unRegistro.ElementAt(0);

                return(costoExtra);
            }

            return(null);
        }
        public void registrar(CostoExtra t)
        {
            t.idCostoExtra = idContador;
            idContador++;

            todosLosCostosExtras.Add(t);
        }
        public void registrar(CostoExtra t)
        {
            string query = String.Format("insert into costo_extra (descripcion, importe) values (\'{0}\', {1});",
                                         t.descripcion,
                                         t.importe.ToString(CultureInfo.InvariantCulture));

            dBConector.ejectuarQuery(query);
        }
        public void actualizar(CostoExtra t)
        {
            string query = String.Format("update costo_extra set descripcion=\'{0}\', importe={1} where id_costo_extra = {2}",
                                         t.descripcion,
                                         t.importe.ToString(CultureInfo.InvariantCulture),
                                         t.idCostoExtra);

            dBConector.ejectuarQuery(query);
        }
 public void actualizar(CostoExtra t)
 {
     for (int i = 0; i < todosLosCostosExtras.Count; i++)
     {
         if (todosLosCostosExtras.ElementAt(i).idCostoExtra == t.idCostoExtra)
         {
             todosLosCostosExtras[i] = t;
         }
     }
 }
        public List <CostoExtra> listarTodos()
        {
            string query = "select * from costo_extra";

            List <CostoExtra> listaCostosExtras = new List <CostoExtra>();

            List <List <Object> > registros = dBConector.consultarQuery(query);

            string descripcion = "";
            double importe     = 0;

            foreach (List <Object> unRegistro in registros)
            {
                descripcion = (string)unRegistro.ElementAt(1);
                importe     = Convert.ToDouble(unRegistro.ElementAt(2));
                CostoExtra unCostoExtra = new CostoExtra(descripcion, importe);
                unCostoExtra.idCostoExtra = (int)unRegistro.ElementAt(0);
                listaCostosExtras.Add(unCostoExtra);
            }

            return(listaCostosExtras);
        }
Exemplo n.º 7
0
        public Pedido parse(List <Object> unRegistro)
        {
            int      id_pedido    = (int)unRegistro.ElementAt(0);
            DateTime fechaPedido  = DateTime.Parse(unRegistro.ElementAt(1).ToString());
            DateTime fechaEntrega = DateTime.Parse(unRegistro.ElementAt(2).ToString());
            string   estado       = (string)unRegistro.ElementAt(3);
            double   importe      = Convert.ToDouble(unRegistro.ElementAt(4));
            int      idCliente    = (int)unRegistro.ElementAt(5);

            IClienteDAO clienteDao = new ClienteDaoImpl();
            Cliente     cliente    = clienteDao.leerPorId(idCliente);


            Pedido pedido = new Pedido();

            pedido.idPedido       = id_pedido;
            pedido.fechaDePedido  = fechaPedido;
            pedido.fechaDeEntrega = fechaEntrega;
            pedido.estado         = estado;
            pedido.cliente        = cliente;


            //lineas de pedido de producto
            ILineaPedidoDao lineaPedidoDao = new LineaPedidoDaoImpl();

            foreach (LineaPedido linea in lineaPedidoDao.listarTodos())
            {
                if (linea.IdPedido == id_pedido)
                {
                    pedido.lineasDePedido.Add(linea);
                }
            }

            String queryLineaCostos = string.Format("select * from linea_costo_extra;");

            //lineas de costos extras
            int            idPedidoCostoExtra;
            int            idCostoExtra;
            ICostoExtraDao costoExtraDao = new CostoExtraDaoImpl();

            foreach (List <Object> unRegistroCostoExtra in db.consultarQuery(queryLineaCostos))
            {
                idPedidoCostoExtra = (int)unRegistroCostoExtra.ElementAt(2);
                idCostoExtra       = (int)unRegistroCostoExtra.ElementAt(3);

                if (id_pedido == idPedidoCostoExtra)
                {
                    CostoExtra costoExtra = costoExtraDao.leerPorId(idCostoExtra);
                    pedido.costosExtras.Add(costoExtra);
                }
            }

            //lineas de materiales necesarios
            IListaMaterialDao listaMaterialDao = new ListaMaterialDaoImpl();

            foreach (ListaMaterial unaLinea in listaMaterialDao.listarTodos())
            {
                if (unaLinea.idPedido == id_pedido)
                {
                    pedido.ListaDeMateriales.Add(unaLinea);
                }
            }

            return(pedido);
        }