public bool ModificarEtiqueta(E_Etiqueta_PTI etiqueta)
        {
            string       query = "update tbl_pti_etiqueta set nombre_etiqueta = @nombre_etiqueta, importador = @importador, producto = @producto, embalaje = @embalaje, gtin = @gtin, categoria=@categoria  where id = @id;";
            MySqlCommand cmd;

            try
            {
                if (Conectar())
                {
                    cmd = new MySqlCommand(query, MySQLConexion);
                    cmd.Parameters.AddWithValue("@nombre_etiqueta", etiqueta.Nombre_etiqueta);
                    cmd.Parameters.AddWithValue("@importador", etiqueta.Importador);
                    cmd.Parameters.AddWithValue("@producto", etiqueta.Producto);
                    cmd.Parameters.AddWithValue("@embalaje", etiqueta.Embalaje);
                    cmd.Parameters.AddWithValue("@gtin", etiqueta.Gtin);
                    cmd.Parameters.AddWithValue("@id", etiqueta.ID);
                    cmd.Parameters.AddWithValue("@categoria", etiqueta.Categoria);

                    cmd.ExecuteNonQuery();
                    Desconectar();
                    return(true);
                }
                else
                {
                    _mensaje = "Error en la conexion a la base de datos";
                    return(false);
                }
            }
            catch (Exception ex)
            {
                _mensaje = ex.Message;
                Desconectar();
                return(false);
            }
        }
示例#2
0
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            if (txtNombreEtiqueta.Text.Trim() == "")
            {
                MessageBox.Show("Ingrese nombre Etiqueta");
                return;
            }

            if (txtImportador.Text.Trim() == "")
            {
                MessageBox.Show("Ingrese Importador");
                return;
            }

            if (txtProducto.Text.Trim() == "")
            {
                MessageBox.Show("Ingrese Producto");
                return;
            }

            if (txtEmbalaje.Text.Trim() == "")
            {
                MessageBox.Show("Ingrese Embalaje");
                return;
            }

            if (txtCategoria.Text.Trim() == "")
            {
                MessageBox.Show("Ingrese Categoria");
                return;
            }

            if (txtGTIN.Text.Trim() == "")
            {
                MessageBox.Show("Ingrese GTIN");
                return;
            }

            E_Etiqueta_PTI etiqueta = new E_Etiqueta_PTI();

            etiqueta.Nombre_etiqueta = txtNombreEtiqueta.Text;
            etiqueta.Importador      = txtImportador.Text;
            etiqueta.Producto        = txtProducto.Text;
            etiqueta.Embalaje        = txtEmbalaje.Text;
            etiqueta.Categoria       = txtCategoria.Text;
            etiqueta.Gtin            = txtGTIN.Text;

            etiquetaPTI.CrearEtiqueta(etiqueta);

            CargarLista();
            LimpiarCampos();
        }
示例#3
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (cmbEtiqueta.SelectedIndex == -1)
            {
                MessageBox.Show("Seleccione Etiqueta");
                return;
            }

            if (txtLote.Text.Trim() == "")
            {
                MessageBox.Show("Ingrese Lote");
                return;
            }

            int    i;
            string ID_etiqueta = cmbEtiqueta.SelectedValue.ToString();

            E_Etiqueta_PTI etiqueta1 = etiqueta.ObtenerEtiqueta(ID_etiqueta);
            // string sLoteaux;
            string      sFecha            = dateTimePicker1.Value.Date.ToString("dd-MM-yyyy");
            EtiquetaZPL ImpresionEtiqueta = new EtiquetaZPL();


            ImpresionEtiqueta.Impresora = "Etiquetas";              //nombre de la impresora
            ImpresionEtiqueta.Archivo   = @"C:\Temp\Impresion.txt"; // Ruta del archivo zpl
            ImpresionEtiqueta.NuevaImpresion();                     //borra el archivo zpl para nueva impresion


            for (i = 1; i <= Convert.ToInt32(txtCantidad.Text); i++)
            {
                // sLoteaux = lLoteaux.ToString().PadLeft(txtLote.Text.Trim.Length, "0");

                ImpresionEtiqueta.EtiquetaExportacion(etiqueta1.Producto, etiqueta1.Embalaje, etiqueta1.Categoria, etiqueta1.Importador, etiqueta1.Gtin,
                                                      txtLote.Text, sFecha, "1", true);

                //ImpresionEtiqueta.EtiquetaExportacion(sDescripcion, sEmbalaje, sCategoria, sImportador, sGTIN,
                //                sLoteaux, sFecha, sCopias, FechaEmpaque);
                //lLoteaux++;
            }

            try
            {
                ImpresionEtiqueta.Imprimir();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            Application.DoEvents();
        }
        public List <E_Etiqueta_PTI> ListaEtiquetas()
        {
            string                query = "select * from tbl_pti_etiqueta;";
            MySqlCommand          cmd;
            List <E_Etiqueta_PTI> temp = new List <E_Etiqueta_PTI>();

            try
            {
                if (Conectar())
                {
                    cmd = new MySqlCommand(query, MySQLConexion);

                    MySqlDataReader reader = cmd.ExecuteReader();
                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            E_Etiqueta_PTI etiqueta = new E_Etiqueta_PTI();

                            etiqueta.ID = Convert.ToString(reader["id"]);
                            etiqueta.Nombre_etiqueta = Convert.ToString(reader["nombre_etiqueta"]);
                            etiqueta.Importador      = Convert.ToString(reader["importador"]);
                            etiqueta.Producto        = Convert.ToString(reader["producto"]);
                            etiqueta.Embalaje        = Convert.ToString(reader["embalaje"]);
                            etiqueta.Categoria       = Convert.ToString(reader["categoria"]);
                            etiqueta.Gtin            = Convert.ToString(reader["gtin"]);

                            temp.Add(etiqueta);
                        }
                        Desconectar();
                        return(temp);
                    }
                    else
                    {
                        _mensaje = "No se encontraron resultados";
                        Desconectar();
                        return(null);
                    }
                }
                else
                {
                    _mensaje = "Error en la conexion a la base de datos";
                    return(null);
                }
            }
            catch (Exception ex)
            {
                _mensaje = ex.Message;
                Desconectar();
                return(null);
            }
        }
        public E_Etiqueta_PTI ObtenerEtiqueta(string id)
        {
            string         query = "select * from tbl_pti_etiqueta where id = @id;";
            MySqlCommand   cmd;
            E_Etiqueta_PTI etiqueta = new E_Etiqueta_PTI();;

            try
            {
                if (Conectar())
                {
                    cmd = new MySqlCommand(query, MySQLConexion);
                    cmd.Parameters.AddWithValue("@id", id);

                    MySqlDataReader reader = cmd.ExecuteReader();
                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            etiqueta.ID = Convert.ToString(reader["id"]);
                            etiqueta.Nombre_etiqueta = Convert.ToString(reader["nombre_etiqueta"]);
                            etiqueta.Importador      = Convert.ToString(reader["importador"]);
                            etiqueta.Producto        = Convert.ToString(reader["producto"]);
                            etiqueta.Embalaje        = Convert.ToString(reader["embalaje"]);
                            etiqueta.Gtin            = Convert.ToString(reader["gtin"]);
                            etiqueta.Categoria       = Convert.ToString(reader["categoria"]);
                        }
                        Desconectar();
                        return(etiqueta);
                    }
                    else
                    {
                        _mensaje = "No se encontraron resultados";
                        Desconectar();
                        return(null);
                    }
                }
                else
                {
                    _mensaje = "Error en la conexion a la base de datos";
                    return(null);
                }
            }
            catch (Exception ex)
            {
                _mensaje = ex.Message;
                Desconectar();
                return(null);
            }
        }
        public bool ModificarEtiqueta(E_Etiqueta_PTI etiqueta)
        {
            D_Etiqueta_PTI etiqueta2 = new D_Etiqueta_PTI();

            if (!etiqueta2.ModificarEtiqueta(etiqueta))
            {
                _mensaje = etiqueta2.Mensaje;
                return(false);
            }
            else
            {
                _mensaje = "Etiqueta modificada";
                return(true);
            }
        }
        public E_Etiqueta_PTI ObtenerEtiqueta(string id)
        {
            D_Etiqueta_PTI etiqueta2 = new D_Etiqueta_PTI();
            E_Etiqueta_PTI temp      = new E_Etiqueta_PTI();

            if ((temp = etiqueta2.ObtenerEtiqueta(id)) != null)
            {
                return(temp);
            }
            else
            {
                _mensaje = etiqueta2.Mensaje;
                return(null);
            }
        }
        public bool CrearEtiqueta(E_Etiqueta_PTI etiqueta)
        {
            string query = "insert into tbl_pti_etiqueta(nombre_etiqueta,importador,producto,embalaje,gtin,categoria) " +
                           "values (@nombre_etiqueta,@importador,@producto,@embalaje,@gtin,@categoria);";
            MySqlCommand cmd;

            try
            {
                if (Conectar())
                {
                    cmd = new MySqlCommand(query, MySQLConexion);
                    cmd.Parameters.AddWithValue("@nombre_etiqueta", etiqueta.Nombre_etiqueta);
                    cmd.Parameters.AddWithValue("@importador", etiqueta.Importador);
                    cmd.Parameters.AddWithValue("@producto", etiqueta.Producto);
                    cmd.Parameters.AddWithValue("@embalaje", etiqueta.Embalaje);
                    cmd.Parameters.AddWithValue("@gtin", etiqueta.Gtin);
                    cmd.Parameters.AddWithValue("@categoria", etiqueta.Categoria);

                    cmd.ExecuteNonQuery();
                    etiqueta.ID = cmd.LastInsertedId.ToString();
                    Desconectar();
                    return(true);
                }
                else
                {
                    _mensaje = "Error en la conexion a la base de datos";
                    return(false);
                }
            }
            catch (Exception ex)
            {
                _mensaje = ex.Message;
                Desconectar();
                return(false);
            }
        }