Ejemplo n.º 1
0
        public List <ConectarBD> ConsultarIdBd(string id)
        {
            List <ConectarBD> lista = new List <ConectarBD>();
            //List<Servicio> listaServicio = new List<Servicio>();
            SqlCeCommand cmd = conn.CreateCommand();

            cmd.Parameters.AddWithValue("@id", id);
            //cmd.CommandText = "SELECT * FROM Pedidos WHERE num_pedido = @num_pedido";
            cmd.CommandText = "SELECT * FROM Pedidos WHERE Id = @id";

            SqlCeDataReader lector = cmd.ExecuteReader();

            while (lector.Read())
            {
                ConectarBD datos = new ConectarBD();
                datos.Id                   = lector[0].ToString();
                datos.Num_pedido           = lector[1].ToString();
                datos.Num_key              = lector[2].ToString();
                datos.Ref_producto         = lector[3].ToString();
                datos.Fecha_pedido         = lector[4].ToString();
                datos.Destinatario         = lector[5].ToString();
                datos.Direccion            = lector[6].ToString();
                datos.Poblacion            = lector[7].ToString();
                datos.Cod_postal           = lector[8].ToString();
                datos.Telefono             = lector[9].ToString();
                datos.Proveedor            = lector[10].ToString();
                datos.Descripcion_producto = lector[11].ToString();
                datos.Bultos               = lector[12].ToString();
                datos.Peso                 = lector[13].ToString();
                datos.Cod_tarifa           = lector[14].ToString();
                datos.Reembolso            = lector[15].ToString();
                datos.retorno              = lector[16].ToString();
                datos.Observaciones        = lector[17].ToString();
//***INI*** MOD 01/03/2018 ***INI***//
                //datos.Stock = lector[18].ToString();
                datos.Stock    = lector[18].ToString();
                datos.Etiqueta = lector[19].ToString();
                datos.Servicio = lector[20].ToString();
                //  datos.listaServicios.Add(lector[20]);
//***FIN*** MOD 01/03/2018 ***FIN***//
//***INI*** MOD 21/11/2019 ***INI***//
                datos.Email = lector[21].ToString();
//***FIN*** MOD 21/11/2019 ***FIN***//

                lista.Add(datos);
            }
            return(lista);
        }
Ejemplo n.º 2
0
        public List <ConectarBD> PedidosServicios()
        {
            List <ConectarBD> lista = new List <ConectarBD>();

//***INI*** MOD 21/11/2019 ***INI***//
            //string consulta = "SELECT P.Id, P.num_pedido, P.num_key, P.ref_producto, P.fecha_pedido, P.destinatario, P.direccion, P.poblacion, P.cod_postal, P.telefono, P.proveedor, P.descripcion_producto, P.bultos, P.peso, P.cod_tarifa, P.reembolso, P.retorno, P.observaciones, P.stock, P.etiquetas, S.IdServicios FROM Pedidos P inner join Servicios S on P.tipo_servicio = S.IdServicios Order by P.num_pedido"; string consulta = "SELECT P.Id, P.num_pedido, P.num_key, P.ref_producto, P.fecha_pedido, P.destinatario, P.direccion, P.poblacion, P.cod_postal, P.telefono, P.proveedor, P.descripcion_producto, P.bultos, P.peso, P.cod_tarifa, P.reembolso, P.retorno, P.observaciones, P.stock, P.etiquetas, S.IdServicios FROM Pedidos P inner join Servicios S on P.tipo_servicio = S.IdServicios Order by P.num_pedido";
            string consulta = "SELECT P.Id, P.num_pedido, P.num_key, P.ref_producto, P.fecha_pedido, P.destinatario, P.direccion, P.poblacion, P.cod_postal, P.telefono, P.proveedor, P.descripcion_producto, P.bultos, P.peso, P.cod_tarifa, P.reembolso, P.retorno, P.observaciones, P.stock, P.etiquetas, P.Email, S.IdServicios FROM Pedidos P inner join Servicios S on P.tipo_servicio = S.IdServicios Order by P.num_pedido";
//***FIN*** MOD 21/11/2019 ***FIN***//
            SqlCeCommand cmd = conn.CreateCommand();

            cmd.CommandText = consulta;
            SqlCeDataReader lector = cmd.ExecuteReader();

            while (lector.Read())
            {
                ConectarBD datos = new ConectarBD();
                datos.Id                   = lector[0].ToString();
                datos.Num_pedido           = lector[1].ToString();
                datos.Num_key              = lector[2].ToString();
                datos.Ref_producto         = lector[3].ToString();
                datos.Fecha_pedido         = lector[4].ToString();
                datos.Destinatario         = lector[5].ToString();
                datos.Direccion            = lector[6].ToString();
                datos.Poblacion            = lector[7].ToString();
                datos.Cod_postal           = lector[8].ToString();
                datos.Telefono             = lector[9].ToString();
                datos.Proveedor            = lector[10].ToString();
                datos.Descripcion_producto = lector[11].ToString();
                datos.Bultos               = lector[12].ToString();
                datos.Peso                 = lector[13].ToString();
                datos.Cod_tarifa           = lector[14].ToString();
                datos.Reembolso            = lector[15].ToString();
                datos.retorno              = lector[16].ToString();
                datos.Observaciones        = lector[17].ToString();
                datos.Stock                = lector[18].ToString();
                datos.Etiqueta             = lector[19].ToString();
                datos.tipo_servicio        = lector[20].ToString();
//***INI*** MOD 21/11/2019 ***INI***//
                datos.Email = lector[21].ToString();
//***FIN*** MOD 21/11/2019 ***FIN***//

                lista.Add(datos);
            }

            return(lista);
        }
Ejemplo n.º 3
0
        public List <ConectarBD> CargarDatos()
        {
            List <ConectarBD> lista = new List <ConectarBD>();

            string       consulta = "SELECT * FROM Pedidos Order by num_pedido";
            SqlCeCommand cmd      = conn.CreateCommand();

            cmd.CommandText = consulta;
            SqlCeDataReader lector = cmd.ExecuteReader();

            while (lector.Read())
            {
                ConectarBD datos = new ConectarBD();
                datos.Id                   = lector[0].ToString();
                datos.Num_pedido           = lector[1].ToString();
                datos.Num_key              = lector[2].ToString();
                datos.Ref_producto         = lector[3].ToString();
                datos.Fecha_pedido         = lector[4].ToString();
                datos.Destinatario         = lector[5].ToString();
                datos.Direccion            = lector[6].ToString();
                datos.Poblacion            = lector[7].ToString();
                datos.Cod_postal           = lector[8].ToString();
                datos.Telefono             = lector[9].ToString();
                datos.Proveedor            = lector[10].ToString();
                datos.Descripcion_producto = lector[11].ToString();
                datos.Bultos               = lector[12].ToString();
                datos.Peso                 = lector[13].ToString();
                datos.Cod_tarifa           = lector[14].ToString();
                datos.Reembolso            = lector[15].ToString();
                datos.retorno              = lector[16].ToString();
                datos.Observaciones        = lector[17].ToString();
                datos.Stock                = lector[18].ToString();
                datos.Etiqueta             = lector[19].ToString();
                datos.tipo_servicio        = lector[20].ToString();
                //***INI*** MOD 21/11/2019 ***INI***//
                datos.Email = lector[21].ToString();
                //***FIN*** MOD 21/11/2019 ***FIN***//

                lista.Add(datos);
            }

            return(lista);
        }
Ejemplo n.º 4
0
        /****************************************************************************/
        /********                                                            ********/
        /********                      BOTÓN - GUARDAR                       ********/
        /********                                                            ********/
        /****************************************************************************/
        private void button1_Click(object sender, EventArgs e)
        {
            ConectarBD con = new ConectarBD();

            con.ConexionBd();
            string retorno = "";
            string stock   = "";

            try
            {
                if (cb_retorno.Checked == true)
                {
                    retorno = "SI";
                }
                else
                {
                    retorno = "NO";
                }

                if (cb_stock.Checked == true)
                {
                    stock = "SI";
                }
                else
                {
                    stock = "NO";
                }

                con.UpdateBd(tb_id.Text, tb_pedido.Text, tb_key.Text, tb_referencia.Text, tb_destinatario.Text, tb_direccion.Text, tb_poblacion.Text, tb_codigo_postal.Text, tb_telefono.Text,
                             tb_proveedor.Text, tb_descripcion.Text, tb_bultos.Text, tb_peso.Text, tb_codigo_tarifa.Text, tb_reembolso.Text, retorno, tb_observaciones.Text, tb_etiqueta.Text, stock,
                             tb_tiposervicio.Text, tb_email.Text);
                MessageBox.Show("El registro se ha modificado correctamente");
            }
            catch (Exception ex)
            {
                String msg = "Error al modificar los datos" + "Details:" + '\n' + ex.ToString();
                MessageBox.Show(msg);
            }

            con.DesconectarBd();
            this.Close();
        }
Ejemplo n.º 5
0
        public void RecogerDatosExcel(string ruta)
        {
            ConectarBD         con   = new ConectarBD();
            List <LineaPedido> lista = new List <LineaPedido>();

            //Declaro las variables necesarias
            Microsoft.Office.Interop.Excel._Application xlApp;
            Microsoft.Office.Interop.Excel._Workbook    xlLibro;
            Microsoft.Office.Interop.Excel._Worksheet   xlHoja1;
            Microsoft.Office.Interop.Excel.Sheets       xlHojas;
            Microsoft.Office.Interop.Excel.Range        range;
            //asigno la ruta dónde se encuentra el archivo
            string fileName = ruta;

            //inicializo la variable xlApp (referente a la aplicación)
            xlApp = new Microsoft.Office.Interop.Excel.Application();
            //Muestra la aplicación Excel si está en true
            xlApp.Visible = false;
            //Abrimos el libro a leer (documento excel)
            xlLibro = xlApp.Workbooks.Open(fileName, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);
            try
            {
                //Asignamos las hojas
                xlHojas = xlLibro.Sheets;
                //Asignamos la hoja con la que queremos trabajar:
                xlHoja1 = (Microsoft.Office.Interop.Excel._Worksheet)xlHojas["Hoja1"];
                int j = 2;
                //Rango
                range = xlHoja1.UsedRange;

                //recorremos las celdas que queremos y sacamos los datos
                for (int i = 0; i < range.Rows.Count; i++)
                {
                    string id            = (string)xlHoja1.get_Range("A" + j, Missing.Value).Text;
                    string numero_pedido = (string)xlHoja1.get_Range("B" + j, Missing.Value).Text;
                    string key           = (string)xlHoja1.get_Range("C" + j, Missing.Value).Text;
                    string fecha         = (string)xlHoja1.get_Range("D" + j, Missing.Value).Text;
                    string nombre        = (string)xlHoja1.get_Range("E" + j, Missing.Value).Text;
                    string direccion     = (string)xlHoja1.get_Range("F" + j, Missing.Value).Text;
                    string poblacion     = (string)xlHoja1.get_Range("G" + j, Missing.Value).Text;
                    string cod_postal    = (string)xlHoja1.get_Range("H" + j, Missing.Value).Text;
                    string telefono      = (string)xlHoja1.get_Range("I" + j, Missing.Value).Text;
                    string proveedor     = (string)xlHoja1.get_Range("J" + j, Missing.Value).Text;
                    string descripcion   = (string)xlHoja1.get_Range("K" + j, Missing.Value).Text;
                    string bultos        = (string)xlHoja1.get_Range("L" + j, Missing.Value).Text;
                    string peso          = (string)xlHoja1.get_Range("M" + j, Missing.Value).Text;
                    string referencia    = (string)xlHoja1.get_Range("N" + j, Missing.Value).Text;
                    string cod_tarifa    = (string)xlHoja1.get_Range("O" + j, Missing.Value).Text;
                    string reembolso     = (string)xlHoja1.get_Range("P" + j, Missing.Value).Text;
                    string retorno       = (string)xlHoja1.get_Range("Q" + j, Missing.Value).Text;
                    string observaciones = (string)xlHoja1.get_Range("R" + j, Missing.Value).Text;
                    string etiquetas     = (string)xlHoja1.get_Range("S" + j, Missing.Value).Text;
                    string stock         = (string)xlHoja1.get_Range("T" + j, Missing.Value).Text;
                    string tipo_servicio = (string)xlHoja1.get_Range("U" + j, Missing.Value).Text;
//***INI*** MOD 21/11/2019 ***INI***//
                    string email = (string)xlHoja1.get_Range("V" + j, Missing.Value).Text;
//***FIN*** MOD 21/11/2019 ***FIN***//

                    Entrega     entrega = new Entrega();
                    Bulto       bulto   = new Bulto();
                    Notas       nota    = new Notas();
                    LineaPedido linea   = new LineaPedido(numero_pedido, key, fecha, entrega, proveedor, bulto, nota, retorno);

                    if (id != "")
                    {
                        con.ConexionBd();
                        //***INI*** MOD 21/11/2019 ***INI***//
                        //con.InsertarBd(numero_pedido, key, referencia, fecha, nombre, direccion, poblacion, cod_postal, telefono, proveedor,
                        //               descripcion, bultos, peso,cod_tarifa, reembolso, retorno, observaciones, stock, etiquetas, tipo_servicio);
                        con.InsertarBd(numero_pedido, key, referencia, fecha, nombre, direccion, poblacion, cod_postal, telefono, proveedor,
                                       descripcion, bultos, peso, cod_tarifa, reembolso, retorno, observaciones, stock, etiquetas, tipo_servicio, email);
                        //***FIN*** MOD 21/11/2019 ***FIN***//

                        /*linea.NumeroPedido = numero_pedido;
                         * linea.ReferenciaPedido = key;
                         * linea.FechaPedido = fecha;
                         * linea.Entrega.Nombre = nombre;
                         * linea.Entrega.Direccion = direccion;
                         * linea.Entrega.Ciudad = poblacion;
                         * linea.Entrega.Cp = cod_postal;
                         * linea.Entrega.Telefonos[0] = telefono;
                         * linea.NombreProveedor = proveedor;
                         * linea.Bulto.Descripcion = descripcion;
                         * linea.Bulto.Numero = bultos;
                         * linea.Bulto.Peso = peso;
                         * linea.Bulto.Referencia = referencia;
                         * linea.Bulto.CodigoAgencia = cod_tarifa;
                         * linea.Nota.Nota[0] = reembolso;
                         * linea.Nota.Nota[1] = observaciones;
                         *
                         * lista.Add(cli);*/
                        j++;
                        con.DesconectarBd();
                    }
                }
            }

            finally
            {
                //Cerrar el Libro
                xlLibro.Close(false, Missing.Value, Missing.Value);
                //Cerrar la Aplicación
                xlApp.Quit();
            }

            //return lista;
        }