Example #1
0
        private void cargarDatos(Comprobante_Remito remito)
        {
            txtNroRemito.Text        = remito.numero.ToString();
            dtpFecha.Value           = remito.fechaIngreso;
            txtPlanta.Text           = remito.Planta.nombre;
            txtRazonSocial.Text      = remito.Planta.Cliente.razonSocial;
            txtObs.Text              = remito.observacion;
            txtOrdenCompra.Text      = remito.ordenCompra;
            txtEnviarA.Text          = planta.direccion;
            cboTipoRem.SelectedIndex = cboTipoRem.FindStringExact(remito.tipo);
            txtDomicilio.Text        = remito.Planta.Cliente.direccion;
            txtLocalidad.Text        = remito.Planta.Cliente.Localidad.nombre;
            txtSitIva.Text           = remito.Planta.Cliente.SituacionFrenteIva.nombre;
            txtCUIT.Text             = remito.Planta.Cliente.cuit;
            txtCantBultos.Text       = remito.cantidadBultos.ToString();
            cboUnidad.SelectedIndex  = cboUnidad.FindStringExact(remito.Unidad.nombre);
            txtPeso.Text             = remito.pesoTotalKg.ToString("0.00");
            cboMoneda.SelectedIndex  = cboMoneda.FindStringExact(remito.Moneda.nombre);
            txtTotal.Text            = remito.importe.ToString("0.00");
            chkNF.Checked            = !remito.facturable;

            int i = 0;

            dgvItems.Rows.Clear();
            foreach (VentaArticuloPlanta itemRem in remito.VentaArticuloPlanta)
            {
                decimal precioCalc;
                precioCalc = Global.Servicio.ConviertePrecio(itemRem.precio, itemRem.Moneda, (Moneda)((ComboBoxItem)cboMoneda.SelectedItem).Value);
                dgvItems.Rows.Add();
                ArticuloPlanta artPla = remito.Planta.ArticuloPlanta.Where(a => a.idArticulo == itemRem.TipoArticulo.id).First();
                dgvItems.Rows[i].Tag = artPla;
                dgvItems.Rows[i].Cells["clmArt"].Value    = remito.Planta.codigo + artPla.contador.ToString();
                dgvItems.Rows[i].Cells["clmCant"].Value   = itemRem.cantidad.ToString("0.00");
                dgvItems.Rows[i].Cells["clmUnidad"].Value = itemRem.TipoArticulo.Unidad.abreviatura;
                dgvItems.Rows[i].Cells["clmDesc"].Value   = itemRem.TipoArticulo.nombre;
                dgvItems.Rows[i].Cells["clmLote"].Value   = itemRem.lote;
                dgvItems.Rows[i].Cells["clmLote"].Tag     = Global.Servicio.obtenerLote(itemRem.lote);
                Presentacion present;
                if (itemRem.idPresentacion != null)
                {
                    present = Global.Servicio.obtenerPresentacion((int)itemRem.idPresentacion);
                    dgvItems.Rows[i].Cells["clmPresent"].Value = "x " + present.litrosEnvase.ToString();
                    dgvItems.Rows[i].Cells["clmPresent"].Tag   = present;
                }
                else
                {
                    dgvItems.Rows[i].Cells["clmPresent"].Value = "";
                    dgvItems.Rows[i].Cells["clmPresent"].Tag   = null;
                }

                dgvItems.Rows[i].Cells["clmMon"].Value    = ((Moneda)((ComboBoxItem)cboMoneda.SelectedItem).Value).simbologia;
                dgvItems.Rows[i].Cells["clmPrecio"].Value = precioCalc;
                dgvItems.Rows[i].Cells["clmPrecio"].Tag   = itemRem.precio;
                dgvItems.Rows[i].Cells["clmImp"].Value    = (itemRem.cantidad * precioCalc);

                i++;
            }
        }
Example #2
0
 protected override void agregar()
 {
     remito  = new Comprobante_Remito();
     cliente = null;
     planta  = null;
     limpiarControles(gpbDatos);
     limpiarControles(gpbDatosRem);
     limpiarControles(gpbTotales);
     limpiarControles(gpbOtros);
     cboMoneda.SelectedIndex = cboMoneda.FindStringExact("Peso");
     cboUnidad.SelectedIndex = 0;
     dgvItems.Rows.Clear();
     gpbDatos.Enabled    = true;
     gpbDatosRem.Enabled = true;
     gpbOtros.Enabled    = true;
     gpbTotales.Enabled  = true;
     txtNroRemito.Text   = Global.Servicio.BuscaNroRemito().ToString();
 }
Example #3
0
 protected override void limpiar()
 {
     remito = null;
     if (Estado != Estados.Modificar)
     {
         // Limpia los datos del formulario
         limpiarControles(gpbDatos);
         limpiarControles(gpbDatosRem);
         limpiarControles(gpbTotales);
         limpiarControles(gpbOtros);
         dgvItems.Rows.Clear();
     }
     gpbDatos.Enabled    = false;
     gpbDatosRem.Enabled = false;
     gpbOtros.Enabled    = false;
     gpbTotales.Enabled  = false;
     dgvItems.Enabled    = false;
 }
Example #4
0
        protected override bool cargarBusqueda()
        {
            frmBusquedaComp frmBusquedaComp = new frmBusquedaComp();

            frmBusquedaComp.Tipo = "remito";
            DialogResult res = frmBusquedaComp.ShowDialog();

            if (res == DialogResult.OK)
            {
                remito  = (Comprobante_Remito)frmBusquedaComp.comprobanteSeleccionado;
                planta  = remito.Planta;
                cliente = remito.Planta.Cliente;
                cargarDatos(remito);

                return(true);
            }

            return(false);
        }
Example #5
0
        protected override bool guardar()
        {
            try
            {
                if (cliente != null && planta != null)
                {
                    if (txtEnviarA.Text.Trim() == "")
                    {
                        Mensaje unMensaje = new Mensaje("Debe ingresar una dirección de envío", Mensaje.TipoMensaje.Error, Mensaje.Botones.OK);
                        unMensaje.ShowDialog();
                        return(false);
                    }

                    if (Estado == Estados.Agregar)
                    {
                        remito = new Comprobante_Remito();
                    }

                    if (txtNroRemito.Text != "")
                    {
                        remito.numero = long.Parse(txtNroRemito.Text);
                    }
                    else
                    {
                        remito.numero = 0;
                    }

                    remito.Moneda       = (Moneda)((ComboBoxItem)cboMoneda.SelectedItem).Value;
                    remito.Planta       = planta;
                    remito.observacion  = txtObs.Text;
                    remito.anulado      = false;
                    remito.tipo         = cboTipoRem.Text;
                    remito.fechaIngreso = dtpFecha.Value;
                    remito.ordenCompra  = txtOrdenCompra.Text;
                    remito.idUnidad     = ((Unidad)((ComboBoxItem)cboUnidad.SelectedItem).Value).id;
                    remito.importe      = 0;
                    remito.facturable   = !chkNF.Checked;

                    remito.VentaArticuloPlanta.Clear();

                    foreach (DataGridViewRow fila in dgvItems.Rows)
                    {
                        if (!fila.IsNewRow)
                        {
                            ArticuloPlanta      artPla = (ArticuloPlanta)fila.Tag;
                            VentaArticuloPlanta venta  = new VentaArticuloPlanta();
                            if (artPla != null)
                            {
                                remito.importe    += decimal.Parse(fila.Cells["clmImp"].Value.ToString());
                                venta.TipoArticulo = artPla.TipoArticulo;
                                venta.Moneda       = artPla.Moneda;
                                decimal precio;
                                if (fila.Cells["clmPrecio"].Tag != null)
                                {
                                    precio = (decimal)fila.Cells["clmPrecio"].Tag;
                                }
                                else
                                {
                                    precio = artPla.precio;
                                }

                                venta.precio     = precio;
                                venta.cotizacion = artPla.Moneda.cotizacion;
                                venta.cantidad   = decimal.Parse(fila.Cells["clmCant"].FormattedValue.ToString());
                                venta.lote       = fila.Cells["clmLote"].FormattedValue.ToString();
                                Presentacion present = (Presentacion)fila.Cells["clmPresent"].Tag;
                                if (present != null)
                                {
                                    venta.idPresentacion = present.id;
                                }
                                remito.VentaArticuloPlanta.Add(venta);

                                //genera salidas de los productos remitados
                                Salida salida = new Salida();
                                salida.idCliente = planta.idCliente;
                                salida.fecha     = remito.fechaIngreso;
                                salida.cantidad  = venta.cantidad;
                                //si ingresó lote
                                if (fila.Cells["clmLote"].Tag != null)
                                {
                                    salida.Lote = (Lote)fila.Cells["clmLote"].Tag;
                                }
                                else
                                {
                                    salida.Lote = Global.Servicio.obtenerLoteProductoFinal(artPla.TipoArticulo, Global.DatosSesion);
                                }
                                //si ingresó presentación
                                if (fila.Cells["clmPresent"].Tag != null)
                                {
                                    salida.idPresentacion = ((Presentacion)fila.Cells["clmPresent"].Tag).id;
                                }

                                venta.Salida.Add(salida);           //para que se grabe en el add del remito
                                salida.VentaArticuloPlanta = venta; //para que lo hereden las salidas hijas en el cálculo
                                Global.Servicio.ObtenerSalidasMateriasPrimas(salida, Global.DatosSesion);
                            }
                        }
                    }

                    if (txtPeso.Text.Trim() == "")
                    {
                        DialogResult pregunta = MessageBox.Show("¿Está seguro que desea dejar la cantidad medida en 0?", "Atención", MessageBoxButtons.YesNo);
                        if (pregunta == DialogResult.Yes)
                        {
                            remito.pesoTotalKg = 0;
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        remito.pesoTotalKg = decimal.Parse(txtPeso.Text);
                    }

                    if (txtCantBultos.Text.Trim() == "")
                    {
                        DialogResult pregunta = MessageBox.Show("¿Está seguro que desea dejar la cantidad de bultos en 0?", "Atención", MessageBoxButtons.YesNo);
                        if (pregunta == DialogResult.Yes)
                        {
                            remito.cantidadBultos = 0;
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        remito.cantidadBultos = int.Parse(txtCantBultos.Text);
                    }

                    if (Estado == Estados.Agregar)
                    {
                        Global.Servicio.agregarRemito(remito, Global.DatosSesion);
                    }
                    else
                    {
                        Global.Servicio.actualizarRemito(remito, Global.DatosSesion);
                    }

                    Mensaje msj = new Mensaje("Remito guardado con éxito", Mensaje.TipoMensaje.Exito, Mensaje.Botones.OK);
                    msj.ShowDialog();

                    if (Estado == Estados.Agregar)
                    {
                        Global.Servicio.imprimirRemito(remito, txtEnviarA.Text, chkImprimirPrecios.Checked);
                        Global.Servicio.imprimirRemito(remito, txtEnviarA.Text, chkImprimirPrecios.Checked);
                        Global.Servicio.imprimirRemito(remito, txtEnviarA.Text, chkImprimirPrecios.Checked);

                        Global.Servicio.imprimirRemitoDigital(remito, txtEnviarA.Text, chkImprimirPrecios.Checked);
                    }

                    return(true);
                }
                else
                {
                    Mensaje unMensaje = new Mensaje("Debe seleccionar un cliente y una planta.", Mensaje.TipoMensaje.Error, Mensaje.Botones.OK);
                    unMensaje.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                Mensaje unMensaje = new Mensaje(ex.Message, Mensaje.TipoMensaje.Error, Mensaje.Botones.OK);
                unMensaje.ShowDialog();
                return(false);
            }
            return(false);
        }