コード例 #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
ファイル: Recepcion5.cs プロジェクト: diegocade1/Packing
        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();
            //}
        }