Esempio n. 1
0
        public bool Modificar(E_Pallet pallet1)
        {
            string       query;
            MySqlCommand cmd;

            query = "update tbl_pallet set descripcion=@descripcion, peso = @peso WHERE ID=@ID";

            try
            {
                if (Conectar() == true)
                {
                    cmd = new MySqlCommand(query, MySQLConexion);
                    cmd.Parameters.AddWithValue("@ID", pallet1.Codigo);
                    cmd.Parameters.AddWithValue("@descripcion", pallet1.Descripcion);
                    cmd.Parameters.AddWithValue("@peso", pallet1.Peso);

                    cmd.ExecuteNonQuery();
                }
            }
            catch (Exception ex)
            {
                Mensaje = ex.Message;
                Desconectar();
                return(false);
            }

            Desconectar();
            return(true);
        }
Esempio n. 2
0
        public bool Agregar(E_Pallet pallet1)
        {
            string       query;
            MySqlCommand cmd;

            query = "insert into tbl_pallet(descripcion, peso) values " +
                    "(@descripcion,@peso)";
            try
            {
                if (Conectar() == true)
                {
                    cmd = new MySqlCommand(query, MySQLConexion);
                    cmd.Parameters.AddWithValue("@descripcion", pallet1.Descripcion);
                    cmd.Parameters.AddWithValue("@peso", pallet1.Peso);

                    cmd.ExecuteNonQuery();
                }
            }
            catch (Exception ex)
            {
                Mensaje = ex.Message;
                Desconectar();
                return(false);
            }

            Desconectar();
            return(true);
        }
Esempio n. 3
0
        }        //Fin funcion

        public E_Pallet ObtenerPallet(string id)
        {
            string       query;
            MySqlCommand cmd;

            query = "select * from tbl_pallet where id = @id";
            try
            {
                if (Conectar() == true)
                {
                    cmd = new MySqlCommand(query, MySQLConexion);
                    cmd.Parameters.AddWithValue("@id", id);
                    MySqlDataReader reader = cmd.ExecuteReader();
                    E_Pallet        objeto1;

                    if (reader.Read())
                    {
                        objeto1 = new E_Pallet();

                        objeto1.Codigo      = Convert.ToString(reader["ID"]);
                        objeto1.Descripcion = Convert.ToString(reader["descripcion"]);
                        try
                        {
                            objeto1.Peso = Convert.ToDouble(reader["peso"]);
                        }
                        catch
                        {
                            objeto1.Peso = 0;
                        }

                        Desconectar();
                        return(objeto1);
                    }
                    else
                    {
                        Desconectar();
                        Mensaje = "No se encontraron registros";
                        return(null);
                    }
                }
                else
                {
                    Desconectar();
                    Mensaje = "Error en la conexion";
                    return(null);
                }
            }
            catch (Exception ex)
            {
                Mensaje = ex.Message;
                Desconectar();
                return(null);
            }
        }        //Fin funcion
Esempio n. 4
0
        void AgregarPallet()
        {
            N_Pallet pallet1 = new N_Pallet();
            E_Pallet pallet2 = new E_Pallet();

            pallet2.Codigo      = "0";
            pallet2.Descripcion = txtDescripcionPallet.Text;
            pallet2.Peso        = Convert.ToDouble(txtPeso.Text.Replace(".", ","));
            if (pallet1.Agregar(pallet2) == true)
            {
                dgvLista.DataSource = pallet1.Lista();
            }
            else
            {
                MessageBox.Show("Error: No se pudo crear el registro", "Agregar");
            }
        }
Esempio n. 5
0
        public List <E_Pallet> Lista()
        {
            string          query;
            MySqlCommand    cmd;
            List <E_Pallet> lista1 = new List <E_Pallet>();

            query = "select * from tbl_pallet";
            try
            {
                if (Conectar() == true)
                {
                    cmd = new MySqlCommand(query, MySQLConexion);
                    MySqlDataReader reader = cmd.ExecuteReader();
                    E_Pallet        objeto1;

                    while (reader.Read())
                    {
                        objeto1 = new E_Pallet();

                        objeto1.Codigo      = Convert.ToString(reader["ID"]);
                        objeto1.Descripcion = Convert.ToString(reader["descripcion"]);
                        try
                        {
                            objeto1.Peso = Convert.ToDouble(reader["peso"]);
                        }
                        catch
                        {
                            objeto1.Peso = 0;
                        }


                        lista1.Add(objeto1);
                    }
                }
            }
            catch (Exception ex)
            {
                Mensaje = ex.Message;
                Desconectar();
            }

            Desconectar();
            return(lista1);
        }        //Fin funcion
Esempio n. 6
0
        public bool Existe_Pallet(E_Pallet pallet)
        {
            bool            estado = false;
            string          query;
            MySqlDataReader rst;


            query = "select * from v_recepcion_maquila where Folio = '" + pallet.Codigo + "' and ID_Cliente = " + pallet.ID_Cliente + " and ID_Productor = " + pallet.ID_Productor;
            try
            {
                if (Conectar())
                {
                    MySqlCommand cmd = new MySqlCommand(query, MySQLConexion);
                    rst = cmd.ExecuteReader();
                    if (rst.Read())
                    {
                        pallet.Descripcion = rst["bandeja"].ToString();
                        pallet.Peso        = Convert.ToDouble(rst["kilos_netos"]);
                        pallet.Cajas       = Convert.ToInt32(rst["cantidad_bandejas"]);
                        pallet.Estado      = rst["estado"].ToString();
                        pallet.Guia        = rst["guia"].ToString();
                        estado             = true;
                    }
                    else
                    {
                        estado = false;
                    }
                    rst.Close();
                    cmd.Dispose();
                    Desconectar();
                }
            }
            catch (Exception ex)
            {
                Mensaje = ex.Message;
                estado  = false;
            }

            return(estado);
        }
Esempio n. 7
0
        public bool Existe_Pallet(E_Pallet pallet)
        {
            D_Recepcion recepcion1 = new D_Recepcion();

            return(recepcion1.Existe_Pallet(pallet));
        }
Esempio n. 8
0
        //uso sublote busca solo por folio
        public bool Existe_Pallet(string folio, E_Pallet pallet)
        {
            D_Recepcion recepcion1 = new D_Recepcion();

            return(recepcion1.Existe_Pallet(folio, pallet));
        }
Esempio n. 9
0
        private void Imprimir_Comercial(E_Comercial detalle_comercial)
        {
            double pesobandeja = 0;
            double pesopallet = 0;
            double tara, pesoNeto, pesopromedio;

            N_Bandeja       bandeja1   = new N_Bandeja();
            N_Pallet        pallet1    = new N_Pallet();
            N_Especie       especie1   = new N_Especie();
            N_Productor     productor1 = new N_Productor();
            N_Cliente       cliente1   = new N_Cliente();
            N_TipoComercial tipo1      = new N_TipoComercial();

            E_Bandeja       bandeja2   = bandeja1.ObtenerBandeja(detalle_comercial.ID_Tipo.ToString());
            E_Pallet        pallet2    = pallet1.ObtenerPallet(detalle_comercial.ID_Pallet.ToString());
            E_Especie       especie2   = especie1.ObtenerEspecie(detalle_comercial.ID_Especie.ToString());
            E_Productor     productor2 = productor1.ObtenerProductor(detalle_comercial.ID_Productor);
            E_Cliente       cliente2   = cliente1.ObtenerCliente(detalle_comercial.ID_Cliente.ToString());
            E_TipoComercial tipo2      = tipo1.ObtenerTipoComercial(detalle_comercial.ID_Tipo.ToString());

            detalle_comercial.Bandeja   = bandeja2.Descripcion;
            detalle_comercial.Pallet    = pallet2.Descripcion;
            detalle_comercial.Especie   = especie2.Descripcion;
            detalle_comercial.Productor = productor2.Descripcion;
            detalle_comercial.Cliente   = cliente2.Cliente;
            detalle_comercial.Tipo      = tipo2.Descripcion;

            pesobandeja  = bandeja1.Peso(detalle_comercial.ID_Bandeja);
            pesopallet   = pallet1.Peso(detalle_comercial.ID_Pallet);
            tara         = (pesobandeja * Convert.ToInt32(detalle_comercial.Cantidad_Bandejas)) + pesopallet;
            pesoNeto     = Convert.ToDouble(detalle_comercial.Kilos_Brutos) - tara;
            pesopromedio = pesoNeto / Convert.ToInt32(detalle_comercial.Cantidad_Bandejas);

            DateTime fecha = Convert.ToDateTime(detalle_comercial.Fecha);
            string   hora  = fecha.ToString("HH:mm:ss");
            /*---------------------------------------------------------------------------*/
            N_Imprimir             imprimir   = new N_Imprimir();
            N_Recepcion_Encabezado encabezado = new N_Recepcion_Encabezado()
            {
                Chofer           = detalle_comercial.Tipo,
                Codigo_productor = detalle_comercial.ID_Productor,
                Correlativo      = "",
                Exportador       = detalle_comercial.Cliente,
                Fecha            = fecha.ToString("dd/MM/yyyy"),
                Guia_despacho    = "",
                Hora             = fecha.ToString("h:mm:ss tt"),
                Productor        = detalle_comercial.Productor,
                Especie          = detalle_comercial.Especie,
                Responsable      = sesion.Nombre + " " + sesion.Apellido
            };
            N_Recepcion_Detalle detalle = new N_Recepcion_Detalle()
            {
                Cantidad             = detalle_comercial.Cantidad_Bandejas.ToString(),
                Comentario           = "",
                Descarga             = "",
                Destino              = "",
                Folio                = detalle_comercial.Folio,
                Hora_recepcion       = hora,
                Kilos_brutos         = detalle_comercial.Kilos_Brutos.ToString(),
                Tara                 = detalle_comercial.Tara.ToString(),
                Kilos_netos          = detalle_comercial.Kilos_Netos.ToString(),
                Numero_lote          = "",
                Peso_pallet          = pesopallet.ToString(),
                Peso_promedio        = pesopromedio.ToString(),
                Peso_rejillas        = pesobandeja.ToString(),
                Responsable          = sesion.Nombre + " " + sesion.Apellido,
                Sub_lote             = "",
                Temperatura          = "",
                Tipo_rejilla_bandeja = detalle_comercial.Bandeja
            };
            N_Coordenadas_Impresion coordenadas = new N_Coordenadas_Impresion()
            {
                PosicionX = "-3",
                PosicionY = "0"
            };

            imprimir.Detalle               = detalle;
            imprimir.Encabezado            = encabezado;
            imprimir.Fuente                = new Font("Verdana", 10);
            imprimir.Coordenadas_impresion = coordenadas;
            PrintDocument pd = new PrintDocument();

            pd.PrintPage += new PrintPageEventHandler(imprimir.PrintTextFileHandlerComercial);
            pd.DefaultPageSettings.PrinterSettings.PrinterName = N_Impresora.Nombre;
            if (pd.PrinterSettings.IsValid)
            {
                pd.Print();
            }
            else
            {
                MessageBox.Show("Impresora " + N_Impresora.Nombre + " no esta instalada");
                return;
            }
            //para utilizar con printdialog
            //printDialog1.Document = pd;
            //Llamar al printDialog
            //if (printDialog1.ShowDialog() == DialogResult.OK) pd.Print();
        }
Esempio n. 10
0
        private void txtPalletRecepcion_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (panelErrorRecepcion.Visible == true)
            {
                panelErrorRecepcion.Visible = false;
            }

            if (ValidarCamposClienteProductor() == false)
            {
                e.Handled = true;
                return;
            }


            if (e.KeyChar == Convert.ToChar(Keys.Enter))
            {
                if (txtPalletRecepcion.Text.Trim() == "")
                {
                    lblMensajeRecepcion.Text    = "Ingrese Pallet";
                    panelErrorRecepcion.Visible = true;
                    return;
                }

                if (txtGuia.Text.Trim() == "")
                {
                    MessageBox.Show("Ingrese Guia", "Guia");
                    txtGuia.Focus();
                    return;
                }

                txtPalletRecepcion.Text = txtPalletRecepcion.Text.ToUpper();

                //revisa si  se agrego folio en grilla
                if (Existe_Pallet_Lista(dgvListaRecepcion, txtPalletRecepcion.Text) == true)
                {
                    lblMensajeRecepcion.Text    = "Pallet ya esta en la Lista";
                    panelErrorRecepcion.Visible = true;
                    txtPalletRecepcion.SelectAll();
                    return;
                }

                N_Recepcion recepcion1 = new N_Recepcion();
                E_Pallet    pallet1    = new E_Pallet();

                pallet1.Codigo       = txtPalletRecepcion.Text;
                pallet1.ID_Cliente   = cmbExportador.SelectedValue.ToString();
                pallet1.ID_Productor = cmbProductor.SelectedValue.ToString();

                if (recepcion1.Existe_Pallet(pallet1) == true)
                {
                    if (pallet1.Estado != "0")
                    {
                        lblMensajeRecepcion.Text    = "Pallet fue asignado";
                        panelErrorRecepcion.Visible = true;
                        txtPalletRecepcion.SelectAll();
                        return;
                    }

                    if (pallet1.Guia != txtGuia.Text)
                    {
                        lblMensajeRecepcion.Text    = "Pallet pertenece a otra Guia";
                        panelErrorRecepcion.Visible = true;
                        txtPalletRecepcion.SelectAll();
                        return;
                    }

                    int rowNuevo;
                    rowNuevo = 0;                        //dgvLista.Rows.Count;

                    dgvListaRecepcion.Rows.Insert(0, 1); //  .Add(1);
                    dgvListaRecepcion.Rows[rowNuevo].Cells["item"].Value        = (dgvListaRecepcion.Rows.Count);
                    dgvListaRecepcion.Rows[rowNuevo].Cells["folio"].Value       = pallet1.Codigo;
                    dgvListaRecepcion.Rows[rowNuevo].Cells["kilos_netos"].Value = pallet1.Peso;
                    //  dgvListaRecepcion.Rows[rowNuevo].Cells["cantidad_bandejas"].Value = pallet1.Cajas;
                    //  dgvListaRecepcion.Rows[rowNuevo].Cells["descripcion"].Value = pallet1.Descripcion;
                    dgvListaRecepcion.Rows[0].Selected = true;
                    lblKilosRecepcion.Text             = Total_Kilos_Lista(dgvListaRecepcion, "kilos_netos").ToString();
                }
                else
                {
                    lblMensajeRecepcion.Text    = "Pallet no Existe";
                    panelErrorRecepcion.Visible = true;
                }
                txtPalletRecepcion.Text = "";
                txtPalletRecepcion.Focus();
            }
        }
Esempio n. 11
0
        public bool Modificar(E_Pallet pallet1)
        {
            D_Pallet pallet = new D_Pallet();

            return(pallet.Modificar(pallet1));
        }
Esempio n. 12
0
        public bool Agregar(E_Pallet pallet1)
        {
            D_Pallet pallet = new D_Pallet();

            return(pallet.Agregar(pallet1));
        }