示例#1
0
        private void btnAceptar_Click(object sender, EventArgs e)
        {
            if (pallet1.ValidaPrefijoActivo(txtFolio.Text) == false)
            {
                MessageBox.Show("Folio Ingresado no contiene prefijo activo [" + pallet1.GetPrefijoActivo() + "]");
                txtFolio.SelectAll();
                txtFolio.Focus();
                return;
            }
            string fecha = DateTime.Now.ToString("s");

            //    T Format Specifier      de-DE Culture                                 17:04:32
            //    T Format Specifier      en-US Culture                               5:04:32 PM
            //    T Format Specifier      es-ES Culture                                 17:04:32
            //    T Format Specifier      fr-FR Culture                                 17:04:32
            string hora   = DateTime.Now.ToString("T");
            bool   estado = false;
            List <E_Exportacion> lista_Exportacion = new List <E_Exportacion>();

            recepcion1.Detalle       = new E_Recepcion_Detalle();
            recepcion1.Detalle.Folio = txtFolio.Text;

            comercial1.Detalle       = new E_Comercial();
            comercial1.Detalle.Folio = txtFolio.Text;

            if (!recepcion1.Validacion_Folio())
            {
                if (!comercial1.Validacion_Folio())
                {
                    exportacion1.Exportacion       = new E_Exportacion();
                    exportacion1.Exportacion.Folio = txtFolio.Text;

                    if (!exportacion1.Validacion_Folio())
                    {
                        for (int i = dgvLista.Rows.Count - 1; i >= 0; i--)
                        {
                            DataGridViewRow row  = dgvLista.Rows[i];
                            DateTime        date = Convert.ToDateTime(row.Cells["fecha"].Value.ToString());
                            exportacion1.Exportacion = new E_Exportacion
                            {
                                ID_Cliente     = cmbCliente.SelectedValue.ToString(),
                                Cliente        = cmbCliente.Text.ToString(),
                                ID_Especie     = cmbEspecie.SelectedValue.ToString(),
                                Especie        = cmbEspecie.Text.ToString(),
                                ID_Embalaje    = cmbEmbalaje.SelectedValue.ToString(),
                                Embalaje       = cmbEmbalaje.Text.ToString(),
                                ID_Etiqueta    = cmbEtiqueta.SelectedValue.ToString(),
                                Etiqueta       = cmbEtiqueta.Text.ToString(),
                                ID_TipoArmado  = cmbTipoArmado.SelectedValue.ToString(),
                                TipoArmado     = cmbTipoArmado.Text.ToString(),
                                ID_TipoMercado = cmbTipoMercado.SelectedValue.ToString(),
                                TipoMercado    = cmbTipoMercado.Text.ToString(),
                                Folio          = txtFolio.Text,
                                ID_Productor   = row.Cells["ID_productor"].Value.ToString(), //cmbProductor.SelectedValue.ToString(),
                                Productor      = row.Cells["productor"].Value.ToString(),
                                ID_Variedad    = row.Cells["ID_variedad"].Value.ToString(),
                                Variedad       = row.Cells["variedad"].Value.ToString(),
                                Fecha          = date.ToString("dd-MM-yyyy"),
                                Cantidad_Cajas = row.Cells["cantidad_bandejas"].Value.ToString(),
                                Documento      = row.Cells["documento"].Value.ToString(),
                                Responsable    = sesion.Nombre + " " + sesion.Apellido,
                                Usuario        = sesion.Usuario
                            };
                            //dgvLista.Columns.Add("item", "Item");
                            //dgvLista.Columns.Add("fecha", "Fecha");
                            //dgvLista.Columns.Add("productor", "Productor");
                            //dgvLista.Columns.Add("variedad", "Variedad");
                            //dgvLista.Columns.Add("cantidad_bandejas", "cantidad_bandejas");
                            //dgvLista.Columns.Add("documento", "Documento");
                            estado = exportacion1.Agregar();
                            if (estado != false)
                            {
                                especie1.Actualizar_Fecha_uso(exportacion1.Exportacion.ID_Especie);
                            }
                            lista_Exportacion.Add(exportacion1.Exportacion);
                        }
                        if (estado == true)
                        {
                            Imprimir_Exportacion(lista_Exportacion);
                        }
                    }
                    else
                    {
                        MessageBox.Show(exportacion1.Mensaje);
                        //txtFolio.Text = string.Empty;
                        txtFolio.SelectionStart  = 0;
                        txtFolio.SelectionLength = txtFolio.Text.Length;
                        txtFolio.Focus();
                    }
                }
                else
                {
                    MessageBox.Show(comercial1.Mensaje);
                    //txtFolio.Text = string.Empty;
                    txtFolio.SelectionStart  = 0;
                    txtFolio.SelectionLength = txtFolio.Text.Length;
                    txtFolio.Focus();
                }
            }
            else
            {
                MessageBox.Show(recepcion1.Mensaje);
                //txtFolio.Text = string.Empty;
                txtFolio.SelectionStart  = 0;
                txtFolio.SelectionLength = txtFolio.Text.Length;
                txtFolio.Focus();
            }
        }
示例#2
0
        private bool AgregarDetalle()
        {
            //numero_actual += 1;

            double pesoBandeja = 0;
            double pesoPallet = 0;
            double tara, pesoNeto;
            double peso_promedio;
            int    item_posicion;

            N_Bandeja bandeja1 = new N_Bandeja();
            N_Pallet  pallet1  = new N_Pallet();


            try
            {
                pesoBandeja = bandeja1.Peso(cmbBandeja.SelectedValue.ToString());
                pesoPallet  = pallet1.Peso(cmbTipoPallet.SelectedValue.ToString());

                item_posicion = recepcion1.Posicion_Pallet(recepcionDetalleSublote.ID_Registro); //PENDIENTE: obtener la ultima posicion y agregar siguiente

                recepcion1.Detalle = new E_Recepcion_Detalle();
                recepcion1.Detalle.ID_Recepcion      = recepcionDetalleSublote.ID_Registro;
                recepcion1.Detalle.Item              = item_posicion.ToString(); //obtener de la base de datos el ultimo registro
                recepcion1.Detalle.ID_bandeja        = cmbBandeja.SelectedValue.ToString();
                recepcion1.Detalle.Bandeja           = cmbBandeja.Text;
                recepcion1.Detalle.Peso_Bandeja      = pesoBandeja.ToString();
                recepcion1.Detalle.Cantidad_Bandejas = txtCantidad_Bandejas.Text;
                recepcion1.Detalle.Folio             = txtFolioNuevo.Text;
                recepcion1.Detalle.Usuario           = sesion.Usuario;
                //recepcion1.Detalle.su
                recepcion1.Detalle.Kilos_Brutos = txtKilos.Text;
                tara = (pesoBandeja * Convert.ToInt32(txtCantidad_Bandejas.Text)) + pesoPallet;
                recepcion1.Detalle.Tara = tara.ToString();
                pesoNeto = Convert.ToDouble(txtKilos.Text) - tara;
                recepcion1.Detalle.Kilos_Netos = pesoNeto.ToString();
                recepcion1.Detalle.ID_Pallet   = cmbTipoPallet.SelectedValue.ToString();
                recepcion1.Detalle.Tipo_Pallet = cmbTipoPallet.Text;
                recepcion1.Detalle.Peso_Pallet = pesoPallet.ToString();
                peso_promedio = pesoNeto / Convert.ToInt32(txtCantidad_Bandejas.Text);
                peso_promedio = Math.Round(peso_promedio, 2);                //redondea a 2 decimales
                recepcion1.Detalle.Peso_Promedio = peso_promedio.ToString();
                recepcion1.Detalle.Posicion      = item_posicion.ToString(); // numero_actual.ToString();
                //recepcion1.detalle.posion = contador posicion numero actual
                //para validar que no se repita folio
                exportacion1.Exportacion       = new E_Exportacion();
                exportacion1.Exportacion.Folio = txtFolioNuevo.Text;

                comercial1.Detalle       = new E_Comercial();
                comercial1.Detalle.Folio = txtFolioNuevo.Text;

                if (!recepcion1.Validacion_Folio())
                {
                    if (!exportacion1.Validacion_Folio())
                    {
                        if (!comercial1.Validacion_Folio())
                        {
                            bool estado = recepcion1.Agregar_Detalle("sublote");
                            if (estado == true)
                            {
                                txtKilos.Text             = string.Empty;
                                txtGuia.Text              = string.Empty;
                                txtCantidad_Bandejas.Text = string.Empty;
                                txtGuia.Focus();
                                cmbBandeja.SelectedIndex    = -1;
                                cmbTipoPallet.SelectedIndex = -1;
                                txtKilos.Text             = string.Empty;
                                txtCantidad_Bandejas.Text = string.Empty;
                                txtFolioNuevo.Text        = string.Empty;


                                //PENDIENTE: Imprimir formato recepcion
                                Imprimir_Recepcion(recepcion1.Encabezado, recepcion1.Detalle);
                                return(true);
                            }
                            else
                            {
                                MessageBox.Show("Error al Guardar Datos " + recepcion1.Mensaje);
                                return(false);
                            }
                        }
                        else
                        {
                            MessageBox.Show(comercial1.Mensaje);
                            //txtFolio.Text = string.Empty;
                            //txtFolio.Focus();
                            return(false);
                        }
                    }
                    else
                    {
                        MessageBox.Show(exportacion1.Mensaje);
                        //txtFolio.Text = string.Empty;
                        //txtFolio.Focus();
                        return(false);
                    }
                }
                else
                {
                    MessageBox.Show(recepcion1.Mensaje);
                    //txtFolio.Text = string.Empty;
                    //txtFolio.Focus();
                    return(false);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(false);
            }
        }
示例#3
0
        private void btnAceptar_Click(object sender, EventArgs e)
        {
            if (ValidarCampos() == false)
            {
                return;
            }

            if (ValidaDecimal(txtKilos.Text) == false)
            {
                MessageBox.Show("Kilos ingresados no son Validos");
                txtKilos.SelectAll();
                txtKilos.Focus();
                return;
            }
            if (pallet1.ValidaPrefijoActivo(txtFolio.Text) == false)
            {
                MessageBox.Show("Folio Ingresado no contiene prefijo activo [" + pallet1.GetPrefijoActivo() + "]");
                txtFolio.SelectAll();
                txtFolio.Focus();
                return;
            }
            string fecha = DateTime.Now.ToString("s");

            //    T Format Specifier      de-DE Culture                                 17:04:32
            //    T Format Specifier      en-US Culture                               5:04:32 PM
            //    T Format Specifier      es-ES Culture                                 17:04:32
            //    T Format Specifier      fr-FR Culture                                 17:04:32
            string hora = DateTime.Now.ToString("HH:mm:ss");

            double pesoBandeja = 0;
            double pesoPallet = 0;
            double tara, pesoNeto, peso_promedio;

            N_Bandeja bandeja1 = new N_Bandeja();
            N_Pallet  pallet2  = new N_Pallet();

            pesoBandeja   = bandeja1.Peso(cmbBandeja.SelectedValue.ToString());
            pesoPallet    = pallet2.Peso(cmbTipoPallet.SelectedValue.ToString());
            tara          = (pesoBandeja * Convert.ToInt32(txtCantidadBandejas.Text)) + pesoPallet;
            pesoNeto      = Convert.ToDouble(txtKilos.Text) - tara;
            peso_promedio = pesoNeto / Convert.ToInt32(txtCantidadBandejas.Text);

            comercial1.Detalle              = new E_Comercial();
            comercial1.Detalle.ID_Cliente   = cmbCliente.SelectedValue.ToString();
            comercial1.Detalle.Cliente      = cmbCliente.Text.ToString();
            comercial1.Detalle.ID_Productor = cmbProductor.SelectedValue.ToString();
            comercial1.Detalle.Productor    = cmbProductor.Text.ToString();
            comercial1.Detalle.ID_Tipo      = cmbTipo.SelectedValue.ToString();
            comercial1.Detalle.Tipo         = cmbTipo.Text.ToString();
            //comercial1.Detalle.Total_Pallet = Convert.ToInt32(txtTotalPallet.Text);
            comercial1.Detalle.ID_Bandeja        = cmbBandeja.SelectedValue.ToString();
            comercial1.Detalle.Bandeja           = cmbBandeja.Text.ToString();
            comercial1.Detalle.ID_Pallet         = cmbTipoPallet.SelectedValue.ToString();
            comercial1.Detalle.Pallet            = cmbTipoPallet.Text.ToString();
            comercial1.Detalle.Fecha             = fecha;
            comercial1.Detalle.ID_Especie        = cmbEspecie.SelectedValue.ToString();
            comercial1.Detalle.Especie           = cmbEspecie.Text.ToString();
            comercial1.Detalle.Kilos_Brutos      = Convert.ToDouble(txtKilos.Text);
            comercial1.Detalle.Cantidad_Bandejas = Convert.ToInt32(txtCantidadBandejas.Text);
            comercial1.Detalle.Folio             = txtFolio.Text;
            comercial1.Detalle.Tara        = tara;
            comercial1.Detalle.Kilos_Netos = pesoNeto;
            comercial1.Detalle.Usuario     = sesion.Usuario;
            /*------------------------------------------*/
            recepcion1.Detalle             = new E_Recepcion_Detalle();
            recepcion1.Detalle.Folio       = comercial1.Detalle.Folio;
            exportacion1.Exportacion       = new E_Exportacion();
            exportacion1.Exportacion.Folio = comercial1.Detalle.Folio;

            if (!recepcion1.Validacion_Folio())
            {
                if (!exportacion1.Validacion_Folio())
                {
                    if (!comercial1.Validacion_Folio())
                    {
                        bool estado = comercial1.Agregar();
                        if (estado == true)
                        {
                            Imprimir_Comercial(comercial1.Detalle, hora, pesoPallet.ToString(), peso_promedio.ToString(), pesoBandeja.ToString());
                            Limpiar();
                        }
                        else
                        {
                            MessageBox.Show("Error al Guardar Datos " + comercial1.Mensaje);
                            Limpiar();
                        }
                    }
                    else
                    {
                        MessageBox.Show(comercial1.Mensaje);
                        txtFolio.Text = string.Empty;
                        txtFolio.Focus();
                    }
                }
                else
                {
                    MessageBox.Show(exportacion1.Mensaje);
                    txtFolio.Text = string.Empty;
                    txtFolio.Focus();
                }
            }
            else
            {
                MessageBox.Show(recepcion1.Mensaje);
                txtFolio.Text = string.Empty;
                txtFolio.Focus();
            }

            /*........................................--*/
        }