Пример #1
0
        public List <Pedido> ListarPorMedicamento(Medicamento Med, string estado)
        {
            List <Pedido> lista = new List <Pedido>();
            SqlConnection c     = Conexion.Conectar();

            SqlCommand cmd = new SqlCommand("PedidosporMedicamento", c);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.Add(new SqlParameter("CodMEd", Med.Codigo));
            cmd.Parameters.Add(new SqlParameter("rut", Med.Farmaceutica.Ruc));
            cmd.Parameters.Add(new SqlParameter("estado", estado));

            SqlDataReader dr = cmd.ExecuteReader();

            Pedido     pe   = null;
            perCliente pcli = new perCliente();

            while (dr.Read())
            {
                pe = new Pedido(Med, pcli.Buscar(dr["username"].ToString()), Convert.ToInt32(dr["numero"].ToString()), Convert.ToInt32(dr["cantidad"].ToString()), (dr["estado"].ToString()));
                lista.Add(pe);
            }

            dr.Close();
            Conexion.Desconectar(c);

            return(lista);
        }
Пример #2
0
        public List <Pedido> ListarPedido()
        {
            List <Pedido> lista = new List <Pedido>();
            SqlConnection c     = Conexion.Conectar();

            SqlCommand cmd = new SqlCommand("ListarPedido", c);

            cmd.CommandType = CommandType.StoredProcedure;

            SqlDataReader dr = cmd.ExecuteReader();

            Pedido          p    = null;
            perCliente      pcli = new perCliente();
            perMedicamento  pmed = new perMedicamento();
            perFarmaceutica pfar = new perFarmaceutica();

            while (dr.Read())
            {
                p = new Pedido(pmed.Buscar(pfar.Buscar(Convert.ToInt64(dr["Rut"].ToString())), Convert.ToInt32(dr["codMedicamento"].ToString())), pcli.Buscar(dr["username"].ToString()), Convert.ToInt32(dr["numero"].ToString()), Convert.ToInt32(dr["cantidad"].ToString()), (dr["estado"].ToString()));

                lista.Add(p);
            }

            dr.Close();
            Conexion.Desconectar(c);

            return(lista);
        }
Пример #3
0
        public Pedido Buscar(int pCodigo)
        {
            SqlConnection c = Conexion.Conectar();

            SqlCommand cmd = new SqlCommand("BuscarPedido", c);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.Add(new SqlParameter("num", pCodigo));

            SqlDataReader dr = cmd.ExecuteReader();

            Pedido          p    = null;
            perMedicamento  pmed = new perMedicamento();
            perCliente      pcli = new perCliente();
            perFarmaceutica pfar = new perFarmaceutica();

            while (dr.Read())
            {
                p = new Pedido(pmed.Buscar(pfar.Buscar(Convert.ToInt64(dr["Rut"].ToString())), Convert.ToInt32(dr["codMedicamento"].ToString())), pcli.Buscar(dr["username"].ToString()), pCodigo, Convert.ToInt32(dr["cantidad"].ToString()), (dr["estado"].ToString()));
            }

            dr.Close();
            Conexion.Desconectar(c);

            if (p == null)
            {
                throw new Exception("No existe el pedido");
            }

            return(p);
        }