示例#1
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 (ValidaDecimal(txtTemperatura.Text) == false)
            {
                MessageBox.Show("Temperatura ingresada no es valida");
                txtTemperatura.SelectAll();
                txtTemperatura.Focus();
                return;
            }

            if (ValidaPesoBruto() == false)
            {
                MessageBox.Show("Peso Bruto debe ser Mayor a Tara");
                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;
            }


            //    G Format Specifier      de-DE Culture                      01.10.2008 17:04:32
            //    G Format Specifier      en-US Culture                     10/1/2008 5:04:32 PM
            //    G Format Specifier      es-ES Culture                      01/10/2008 17:04:32
            //    G Format Specifier      fr-FR Culture                      01/10/2008 17:04:32
            //    s Format Specifier      de-DE Culture                      2008-10-01T17:04:32
            //    s Format Specifier      en-US Culture                      2008-10-01T17:04:32
            //    s Format Specifier      es-ES Culture                      2008-10-01T17:04:32
            //    s Format Specifier      fr-FR Culture                      2008-10-01T17:04:32
            //string fecha = DateTime.Now.ToString("G");
            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");

            //Random rnd = new Random();
            //int lote = rnd.Next(1, 99999);

            recepcion1.Encabezado                  = new E_Recepcion_Encabezado();
            recepcion1.Encabezado.Cliente          = cmbCliente.Text.ToString();
            recepcion1.Encabezado.ID_Cliente       = cmbCliente.SelectedValue.ToString();
            recepcion1.Encabezado.Productor        = cmbProductor.Text.ToString();
            recepcion1.Encabezado.Codigo_Productor = cmbProductor.SelectedValue.ToString();
            recepcion1.Encabezado.Chofer           = txtChofer.Text;
            recepcion1.Encabezado.Guia             = txtGuia.Text;
            recepcion1.Encabezado.ID_Especie       = cmbEspecie.SelectedValue.ToString();
            recepcion1.Encabezado.Especie          = cmbEspecie.Text.ToString();
            recepcion1.Encabezado.ID_Descarga      = cmbDescarga.SelectedValue.ToString();
            recepcion1.Encabezado.Descarga         = cmbDescarga.Text.ToString();
            recepcion1.Encabezado.Temperatura      = txtTemperatura.Text;
            recepcion1.Encabezado.ID_Destino       = cmbDestino.SelectedValue.ToString();
            recepcion1.Encabezado.Destino          = cmbDestino.Text.ToString();
            recepcion1.Encabezado.Responsable      = sesion.Nombre + " " + sesion.Apellido;
            recepcion1.Encabezado.ID_Tipo          = cmbTipo.SelectedValue.ToString();
            recepcion1.Encabezado.Tipo             = cmbTipo.Text.ToString();

            recepcion1.Encabezado.Fecha = fecha;
            recepcion1.Encabezado.Hora  = hora;
            //lote se obtiene en agregar encabezado
            // recepcion1.Encabezado.Lote = lote.ToString();
            if (txtTotalPallets.Text.Trim() != "")
            {
                recepcion1.Encabezado.Cantidad_Pallets = txtTotalPallets.Text;
            }
            else
            {
                recepcion1.Encabezado.Cantidad_Pallets = "0";
            }

            //if (!recepcion1.Validacion_Guia())
            //{
            bool estado = recepcion1.Agregar_Encabezado();

            if (estado == true)
            {
                txtTotalPallets.ReadOnly         = true;
                btnModificarTotalPallets.Visible = true;
                int ID = recepcion1.UltimoID;
                if (recepcion1.nuevo)
                {
                    numero_actual = 0;
                }
                else
                {
                    //txtTotalPallets.Text = recepcion1.Encabezado.Cantidad_Pallets;
                    numero_actual = recepcion1.Posicion;
                }

                if (Convert.ToInt32(recepcion1.Encabezado.Cantidad_Pallets) != 0)
                {
                    if (numero_actual < Convert.ToInt32(recepcion1.Encabezado.Cantidad_Pallets))
                    {
                        //Agrega detalle de recepcion
                        if (AgregarDetalle(ID, recepcion1.Encabezado.Codigo_Productor) == true)
                        {
                            especie1.Actualizar_Fecha_uso(recepcion1.Encabezado.ID_Especie);
                            //txtKilos.Text = string.Empty;
                            //txtFolio.Text = string.Empty;
                            //txtCantidadBandejas.Text = string.Empty;
                            //cmbBandeja.Focus();
                            //cmbBandeja.SelectedIndex = -1;
                            //cmbTipoPallet.SelectedIndex = -1;
                        }
                        else
                        {
                            //MessageBox.Show("Error al registrar el detalle de la recepcion");
                            //txtKilos.SelectAll();
                            //txtCantidadBandejas.SelectAll();
                            txtFolio.SelectAll();
                            //cmbBandeja.SelectedIndex = -1;
                            //cmbTipoPallet.SelectedIndex = -1;
                            //cmbBandeja.Focus();
                            txtFolio.Focus();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Ya se alcanzo la cantidad de pallets registrada");
                    }
                }
                else
                {
                    if (AgregarDetalle(ID, recepcion1.Encabezado.Codigo_Productor) == true)
                    {
                        especie1.Actualizar_Fecha_uso(recepcion1.Encabezado.ID_Especie);
                        //txtKilos.Text = string.Empty;
                        //txtFolio.Text = string.Empty;
                        //txtCantidadBandejas.Text = string.Empty;
                        //cmbBandeja.Focus();
                        //cmbBandeja.SelectedIndex = -1;
                        //cmbTipoPallet.SelectedIndex = -1;
                    }
                    else
                    {
                        //MessageBox.Show("Error al registrar el detalle de la recepcion");
                        //txtKilos.SelectAll();
                        //txtCantidadBandejas.SelectAll();
                        txtFolio.SelectAll();
                        //cmbBandeja.SelectedIndex = -1;
                        //cmbTipoPallet.SelectedIndex = -1;
                        //cmbBandeja.Focus();
                        txtFolio.Focus();
                    }
                }
            }
            else
            {
                MessageBox.Show(recepcion1.Mensaje);
                //txtFolio.Text = string.Empty;
                //txtFolio.Focus();
                //cmbCliente.Focus();
                txtGuia.SelectAll();
                txtGuia.Focus();
            }
            //}
            //else
            //{
            //    MessageBox.Show(recepcion1.Mensaje);
            //    txtGuia.SelectAll();
            //    txtGuia.Focus();
            //}
        }
示例#2
0
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            if (txtKilos.Text.Trim() == "")
            {
                MessageBox.Show("Ingrese Kilos", "");
                txtKilos.Focus();
                return;
            }
            if (txtCantidadBandejas.Text.Trim() == "")
            {
                MessageBox.Show("Ingrese Cantidad Bandejas", "");
                txtCantidadBandejas.Focus();
                return;
            }
            if (cmbTipoPallet.Text.Trim() == "")
            {
                MessageBox.Show("Seleccione Tipo Pallet", "");
                cmbTipoPallet.Focus();
                return;
            }

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

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

            pesoBandeja = bandeja1.Peso(cmbBandeja.SelectedValue.ToString());
            pesoPallet  = pallet1.Peso(cmbTipoPallet.SelectedValue.ToString());
            tara        = (pesoBandeja * Convert.ToInt32(txtCantidadBandejas.Text)) + pesoPallet;
            pesoNeto    = Convert.ToDouble(txtKilos.Text) - tara;
            //    G Format Specifier      de-DE Culture                      01.10.2008 17:04:32
            //    G Format Specifier      en-US Culture                     10/1/2008 5:04:32 PM
            //    G Format Specifier      es-ES Culture                      01/10/2008 17:04:32
            //    G Format Specifier      fr-FR Culture                      01/10/2008 17:04:32
            //    s Format Specifier      de-DE Culture                      2008-10-01T17:04:32
            //    s Format Specifier      en-US Culture                      2008-10-01T17:04:32
            //    s Format Specifier      es-ES Culture                      2008-10-01T17:04:32
            //    s Format Specifier      fr-FR Culture                      2008-10-01T17:04:32
            //string fecha = DateTime.Now.ToString("G");
            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");
            Random rnd  = new Random();

            int lote = rnd.Next(1, 99999);

            recepcion1.Encabezado                  = new E_Recepcion_Encabezado();
            recepcion1.Encabezado.Cliente          = cmbCliente.Text.ToString();
            recepcion1.Encabezado.ID_Cliente       = cmbCliente.SelectedValue.ToString();
            recepcion1.Encabezado.Productor        = cmbProductor.Text.ToString();
            recepcion1.Encabezado.Codigo_Productor = cmbProductor.SelectedValue.ToString();
            recepcion1.Encabezado.Chofer           = txtChofer.Text;
            recepcion1.Encabezado.Guia             = txtGuia.Text;
            recepcion1.Encabezado.ID_Especie       = cmbEspecie.SelectedValue.ToString();
            recepcion1.Encabezado.Especie          = cmbEspecie.Text.ToString();
            recepcion1.Encabezado.ID_Descarga      = cmbDescarga.SelectedValue.ToString();
            recepcion1.Encabezado.Descarga         = cmbDescarga.Text.ToString();
            recepcion1.Encabezado.Temperatura      = txtTemperatura.Text;
            recepcion1.Encabezado.ID_Destino       = cmbDestino.SelectedValue.ToString();
            recepcion1.Encabezado.Destino          = cmbDestino.Text.ToString();

            recepcion1.Encabezado.Fecha = fecha;
            recepcion1.Encabezado.Hora  = hora;
            recepcion1.Encabezado.Lote  = lote.ToString();

            bool estado = recepcion1.Agregar_Encabezado();


            if (estado == true)
            {
                int ID = recepcion1.UltimoID;

                //DataGridViewRow row = dgvLista.Rows[i];
                recepcion1.Detalle = new E_Recepcion_Detalle();
                recepcion1.Detalle.ID_Recepcion = ID.ToString();
                //recepcion1.Detalle.Item = row.Cells["item"].Value.ToString();
                recepcion1.Detalle.ID_bandeja        = cmbBandeja.SelectedValue.ToString();
                recepcion1.Detalle.Bandeja           = cmbBandeja.Text.ToString();
                recepcion1.Detalle.Peso_Bandeja      = pesoBandeja.ToString();
                recepcion1.Detalle.Cantidad_Bandejas = txtCantidadBandejas.Text;
                recepcion1.Detalle.Folio             = txtFolio.Text;
                recepcion1.Detalle.Kilos_Brutos      = txtKilos.Text;
                recepcion1.Detalle.Tara        = tara.ToString();
                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();

                recepcion1.Agregar_Detalle("recepcion");
                Imprimir_Recepcion(recepcion1.Encabezado, recepcion1.Detalle);
            }

            //AgregarGrilla2();
            txtKilos.Text            = "";
            txtCantidadBandejas.Text = "";
            cmbBandeja.Focus();
            cmbBandeja.SelectedIndex    = -1;
            cmbTipoPallet.SelectedIndex = -1;
            txtFolio.Text = "";
        }