Exemplo n.º 1
0
        private void MDIContenedorPrincipal_Load(object sender, EventArgs e)
        {
            NameValueCollection settings = ConfigurationManager.GetSection("ImpresorasGroup/Impresora") as NameValueCollection;

            if (settings != null)
            {
                foreach (string key in settings.AllKeys)
                {
                    Console.Write(key + ": " + settings[key]);
                    bool predeterminada = Convert.ToBoolean(settings[key]);
                    if (predeterminada != false)
                    {
                        N_Impresora.Nombre = key;
                    }
                }
            }
            this.Text = "Principal" + " " + Usuario.Usuario;
            HideAll();
            N_Tipo_Usuario_Permiso permisos_usuario_actual1 = new N_Tipo_Usuario_Permiso();
            E_Tipo_Usuario_Permiso permisos_usuario_actual2 = permisos_usuario_actual1.ObtenerPermisos(Usuario.Tipo_usuario);

            string[] arrayPermisos = permisos_usuario_actual2.Permisos.Split(',');
            ShowControlsByPermission(arrayPermisos);

            //N_Impresora.Nombre = "Microsoft Print to PDF";
            //N_Impresora.Nombre = "OKI DATA CORP ML320/1TURBO";

            //asignar prefijo general para validar

            N_Pallet pallet1 = new N_Pallet();

            pallet1.SetPrefijoActivo();
        }
Exemplo n.º 2
0
        private void frmLista_Load(object sender, EventArgs e)
        {
            N_Bandeja bandeja1 = new N_Bandeja();
            N_Pallet  pallet1  = new N_Pallet();

            dgvLista.Visible = false;

            dgvLista1.DataSource = recepcion1.Obtener_Detalles_Recepcion().Select(ob => new
            {
                ID                = ob.ID,
                Bandeja           = ob.Bandeja,
                Peso_Bandeja      = ob.Peso_Bandeja,
                Cantidad_bandejas = ob.Cantidad_Bandejas,
                Folio             = ob.Folio,
                Kilos_Brutos      = ob.Kilos_Brutos,
                Tara              = ob.Tara,
                Kilos_netos       = ob.Kilos_Netos,
                Tipo_pallet       = ob.Tipo_Pallet,
                Peso_pallet       = ob.Peso_Pallet,
                Fecha             = ob.Fecha,
                Usuario           = ob.Usuario,
                Posicion          = ob.Posicion
            }).ToList();

            //dgvLista1.DataBindingComplete += (o, _) =>
            //{
            //    var dataGridView = o as DataGridView;
            //    if (dataGridView != null)
            //    {
            //        dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
            //        dataGridView.Columns[dataGridView.ColumnCount - 1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            //    }
            //};

            cmbBandeja.DataSource    = bandeja1.Lista();
            cmbBandeja.DisplayMember = "descripcion";
            cmbBandeja.ValueMember   = "codigo";
            cmbBandeja.SelectedIndex = -1;

            cmbTipoPallet.DataSource    = pallet1.Lista();
            cmbTipoPallet.DisplayMember = "descripcion";
            cmbTipoPallet.ValueMember   = "codigo";
            cmbTipoPallet.SelectedIndex = -1;

            btnEliminar.Visible = false;
            btnImportar.Visible = false;
            btnAgregar.Visible  = false;
        }
Exemplo n.º 3
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");
            }
        }
Exemplo n.º 4
0
        bool ValidaPesoBruto()
        {
            double kilos_brutos;
            double tara, pesoBandeja, pesoPallet;

            kilos_brutos = Convert.ToDouble(txtKilos.Text);

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

            pesoBandeja = bandeja1.Peso(cmbBandeja.SelectedValue.ToString());
            pesoBandeja = pesoBandeja * Convert.ToInt32(txtCantidadBandejas.Text);
            pesoPallet  = pallet1.Peso(cmbTipoPallet.SelectedValue.ToString());
            tara        = pesoBandeja + pesoPallet;

            if (kilos_brutos <= tara)
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 5
0
        void ModificarDetalle()
        {
            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());

            recepcion1.Detalle    = new E_Recepcion_Detalle();
            recepcion1.Detalle.ID = lblID.Text;
            recepcion1.Obtener_Detalle();
            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.Kilos_Brutos      = txtKilos.Text;
            tara = (pesoBandeja * Convert.ToInt32(txtCantidadBandejas.Text)) + pesoPallet;
            recepcion1.Detalle.Tara = tara.ToString();
            double kilos_brutos = Convert.ToDouble(txtKilos.Text.Replace(".", ","));

            pesoNeto = kilos_brutos - 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();

            if (recepcion1.Modificar_Detalle() == true)
            {
                LlenarGrilla();
            }
            else
            {
                MessageBox.Show("Error: No se pudo modificar el registro", "Modificar");
            }
        }
Exemplo n.º 6
0
        public override void Borrar()
        {
            if (dgvLista.SelectedRows.Count != 0)
            {
                int    pos = dgvLista.CurrentRow.Index;
                string ID;
                ID = dgvLista.Rows[pos].Cells["codigo"].Value.ToString();
                if (MessageBox.Show("¿Borrar Registro Seleccionado?", "Eliminar", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
                {
                    return;
                }

                N_Pallet pallet1 = new N_Pallet();
                if (pallet1.Borrar(ID) == true)
                {
                    dgvLista.DataSource = pallet1.Lista();
                }
            }
            else
            {
                MessageBox.Show("Seleccione Item", "Borrar");
            }
        }
Exemplo n.º 7
0
        private void frmMantenedorPallet_Load(object sender, EventArgs e)
        {
            N_Pallet pallet1 = new N_Pallet();

            dgvLista.DataSource = pallet1.Lista();
        }
Exemplo n.º 8
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();
        }
Exemplo n.º 9
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);
            }
        }
Exemplo n.º 10
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            decimal total_peso_teorico             = Convert.ToDecimal(lblPesoTeorico.Text);
            decimal total_kilos_Comercial          = Convert.ToDecimal(lblKilosSalidaComercial.Text);
            decimal total_kilos_Merma              = Convert.ToDecimal(lblKilosSalidaMerma.Text);
            decimal total_kilos_Recepcion          = Convert.ToDecimal(lblKilosRecepcion.Text);
            decimal total_kilos_descuentos_sublote = 0;

            if (ValidaCampos() == false)
            {
                return;
            }
            N_SubLote                  sublote1        = new N_SubLote();
            N_Maquila                  maquila1        = new N_Maquila();
            List <E_Maquila>           lista_Maquila   = new List <E_Maquila>();
            List <E_Recepcion_Detalle> lista_Recepcion = new List <E_Recepcion_Detalle>();
            E_Recepcion_Detalle        recepcion1;
            bool estado = false;



            maquila1.Maquila              = new E_Maquila();
            maquila1.Maquila.ID_Cliente   = cmbExportador.SelectedValue.ToString();
            maquila1.Maquila.Cliente      = cmbExportador.Text;
            maquila1.Maquila.ID_Productor = cmbProductor.SelectedValue.ToString();
            maquila1.Maquila.Productor    = cmbProductor.Text;
            maquila1.Maquila.Lote         = lblLote.Text; //Falta Lote txtlote.text;
            maquila1.Maquila.Documento    = txtGuia.Text;

            //descuento de sublote si existe
            total_kilos_descuentos_sublote = sublote1.Descuento_por_Guia(maquila1.Maquila.ID_Productor, maquila1.Maquila.Documento);
            if (total_kilos_descuentos_sublote != 0)
            {
                sublote1.ModificarSublotePorGuia(maquila1.Maquila.ID_Productor, maquila1.Maquila.Documento);
            }
            maquila1.Maquila.Fecha_Recepcion   = dtpFechaRecepcion.Value;
            maquila1.Maquila.Fecha_Proceso     = dtpFechaProceso.Value;
            maquila1.Maquila.OrdenEmbalaje     = txtOrdenEmbalaje.Text;
            maquila1.Maquila.Linea             = cmbLinea.Text;
            maquila1.Maquila.Hora_Inicio       = dtpHoraInicio.Value;
            maquila1.Maquila.Hora_Termino      = dtpHoraFin.Value;
            maquila1.Maquila.Rendimiento       = txtRedimiento.Text;
            maquila1.Maquila.Kilos_PesoTeorico = total_peso_teorico;
            maquila1.Maquila.Kilos_Comerciales = total_kilos_Comercial;
            maquila1.Maquila.Kilos_Merma       = total_kilos_Merma;
            maquila1.Maquila.Descuento_SubLote = total_kilos_descuentos_sublote;
            maquila1.Maquila.Kilos_Recepcion   = total_kilos_Recepcion - total_kilos_descuentos_sublote;


            maquila1.Maquila.Usuario = sesion.Usuario;

            //05-02-2019 se debe permitir ingresar mas maquilas con la misma guia si es
            //parcial se deshabilita para revisar a futuro si es necesario bloquear
            //if (maquila1.ValidarGuia())
            //{
            //    MessageBox.Show(maquila1.Mensaje);
            //    return;
            //}

            estado = maquila1.Agregar();
            if (estado == true)
            {
                List <E_Pallet> lista_pallet1 = new List <E_Pallet>();
                for (int i = dgvListaRecepcion.Rows.Count - 1; i >= 0; i--)
                {
                    DataGridViewRow row = dgvListaRecepcion.Rows[i];
                    recepcion1 = new E_Recepcion_Detalle();
                    // maquila1.Maquila_Recepcion = new E_Maquila();

                    recepcion1.Folio       = row.Cells["Folio"].Value.ToString();
                    recepcion1.Kilos_Netos = row.Cells["Kilos_Netos"].Value.ToString();
                    lista_Recepcion.Add(recepcion1);

                    maquila1.Modificar_Estado(recepcion1.Folio, maquila1.Maquila.ID.ToString());
                }

                E_Pallet_Exportacion        exportacion1;
                List <E_Pallet_Exportacion> lista_Exportacion = new List <E_Pallet_Exportacion>();
                int totalCajas = 0;
                int totalPotes = 0;
                for (int i = dgvListaExportacion.Rows.Count - 1; i >= 0; i--)
                {
                    DataGridViewRow row = dgvListaExportacion.Rows[i];
                    exportacion1 = new E_Pallet_Exportacion();
                    //  maquila1.Maquila_Recepcion = new E_Maquila();

                    exportacion1.Codigo       = row.Cells["folio"].Value.ToString();
                    exportacion1.Peso         = Convert.ToDouble(row.Cells["Peso_Teorico"].Value);
                    exportacion1.Cajas        = Convert.ToInt32(row.Cells["cantidad_cajas"].Value);
                    exportacion1.Total_Peso   = Convert.ToDouble(row.Cells["total_peso"].Value);
                    exportacion1.Potes        = Convert.ToInt32(row.Cells["cantidad_potes"].Value);
                    exportacion1.ID_Cliente   = cmbExportador.SelectedValue.ToString();
                    exportacion1.ID_Productor = cmbProductor.SelectedValue.ToString();

                    lista_Exportacion.Add(exportacion1);
                    totalCajas = totalCajas + exportacion1.Cajas;
                    totalPotes = totalPotes + exportacion1.Potes;
                    maquila1.Modificar_Estado_Exportacion(exportacion1, maquila1.Maquila.ID.ToString());
                }

                E_Pallet_Comercial        pallet1;
                List <E_Pallet_Comercial> lista_comercial = new List <E_Pallet_Comercial>();
                for (int i = dgvListaComercial.RowCount - 1; i >= 0; i--)
                {
                    DataGridViewRow row = dgvListaComercial.Rows[i];
                    pallet1             = new E_Pallet_Comercial();
                    pallet1.Codigo      = row.Cells["folio"].Value.ToString();
                    pallet1.Tipo        = row.Cells["tipo"].Value.ToString();
                    pallet1.Kilos_Netos = Convert.ToDouble(row.Cells["kilos_netos"].Value);
                    lista_comercial.Add(pallet1);
                    maquila1.Modificar_Estado_Comercial(pallet1.Codigo, maquila1.Maquila.ID.ToString());
                }

                decimal kilos_exportacion      = maquila1.Maquila.Kilos_Recepcion - (maquila1.Maquila.Kilos_Comerciales + maquila1.Maquila.Kilos_Merma);
                decimal total_sobrepeso        = kilos_exportacion - maquila1.Maquila.Kilos_PesoTeorico;
                decimal total_sobrepesoCajas   = total_sobrepeso / totalCajas;
                decimal total_sobrepesoPotes   = total_sobrepeso / totalPotes;
                decimal porcentaje_rendimiento = kilos_exportacion / maquila1.Maquila.Kilos_Recepcion;
                Imprimir_Maquila(maquila1.Maquila, lista_Recepcion, lista_Exportacion, lista_comercial, maquila1.Maquila.Kilos_Recepcion.ToString(), maquila1.Maquila.Kilos_Comerciales.ToString(), maquila1.Maquila.Kilos_Merma.ToString(), kilos_exportacion.ToString(), total_sobrepeso.ToString("N2"), total_sobrepesoCajas.ToString("N2"), total_sobrepesoPotes.ToString("N2"), maquila1.Maquila.Kilos_PesoTeorico.ToString("N2"), porcentaje_rendimiento.ToString("N2"));
                Limpiar();
            }
            else
            {
                MessageBox.Show("No se pudo registrar el proceso. Detalle: " + maquila1.Mensaje);
            }
        }
Exemplo n.º 11
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 = "";
        }
Exemplo n.º 12
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();
            }

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