Exemplo n.º 1
0
        /// <summary>
        /// Metodo load del form
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frmProcesos_Load(object sender, EventArgs e)
        {
            IBLLFactura _BLLFactura = new BLLFactura();

            try
            {
                ComponentesIniciales();
                Utilitarios.CulturaInfo();
                this.txtNoFactura.Text = _BLLFactura.GetNextNumeroFactura().ToString();
                llenarCombos();
                Control.CheckForIllegalCrossThreadCalls = false;
            }
            catch (Exception er)
            {
                StringBuilder msg = new StringBuilder();
                msg.AppendFormat("Mensaje    :{0}\n", er.Message);
                msg.AppendFormat("Source     :{0}\n", er.Source);
                msg.AppendFormat("StackTrace :{0}\n", er.StackTrace);

                MessageBox.Show(msg.ToString(), "Atención");
            }

            //Marcadores();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Método que guarda el detalle de factura en el encabezado
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            IBLLImpuesto    _BLLImpuesto       = new BLLImpuesto();
            IBLLPrecioEnvio _BLLPrecioEnvio    = new BLLPrecioEnvio();
            IBLLFactura     _BLLFactura        = new BLLFactura();
            DetFactura      oDetFactura        = new DetFactura();
            string          descripcionPaquete = "";
            string          descripcionruta    = "";

            try
            {
                erpErrores.Clear();
                if (_EncabezadoFactura == null)
                {
                    MessageBox.Show("Debe agregar los datos del encabezado de la factura para continuar", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    if (string.IsNullOrEmpty(txtIDMensajero.Text))
                    {
                        erpErrores.SetError(txtIDMensajero, "Debe ingresar la identificación del mensajero");
                        return;
                    }
                    if (string.IsNullOrEmpty(txtNombreMensajero.Text))
                    {
                        erpErrores.SetError(txtNombreMensajero, "Debe ingresar el nombre del mensajero");
                        return;
                    }
                    if (string.IsNullOrEmpty(mskNoTarjeta.Text))
                    {
                        erpErrores.SetError(mskNoTarjeta, "Debe ingresar el número de tarjeta");
                        return;
                    }
                    int cantidad = 0;
                    foreach (var item in mskNoTarjeta.Text)
                    {
                        cantidad++;
                    }
                    if (cantidad < 16)
                    {
                        erpErrores.SetError(mskNoTarjeta, "Debe ingresar un número válido");
                        return;
                    }
                    if (Convert.ToInt32(txtCantidadPaquetes.Text) == 0 || string.IsNullOrEmpty(txtCantidadPaquetes.Text))
                    {
                        erpErrores.SetError(txtCantidadPaquetes, "Debe ingresar un paquete");
                        return;
                    }
                    if ((Convert.ToDouble(txtKilometros.Text) == 0 || string.IsNullOrEmpty(txtKilometros.Text)))
                    {
                        erpErrores.SetError(txtKilometros, "Debe ingresar una ruta válida");
                        return;
                    }
                    if (lstUbicaciones.Items.Count <= 1)
                    {
                        erpErrores.SetError(lstUbicaciones, "Debe ingresar una ruta válida");
                        return;
                    }
                    oDetFactura.CantidadKilometros = (int)Math.Round(Convert.ToDouble(txtKilometros.Text));
                    for (int i = 0; i < lstPaquetes.Items.Count; i++)
                    {
                        descripcionPaquete += lstPaquetes.Items[i].ToString() + "\n";
                    }
                    oDetFactura.DescripcionPaquete = descripcionPaquete;
                    for (int i = 0; i < lstUbicaciones.Items.Count; i++)
                    {
                        descripcionruta += lstUbicaciones.Items[i].ToString() + "\n";
                    }
                    oDetFactura.DescripcionRuta  = descripcionruta;
                    oDetFactura.Impuesto         = Convert.ToDouble(txtImpuesto.Text);
                    oDetFactura.NoFactura        = _EncabezadoFactura.IDEncFactura;
                    oDetFactura.PrecioKilometro  = _BLLPrecioEnvio.MostrarXID(cboTipoEnvio.SelectedItem.ToString()).PrecioRango;
                    oDetFactura.Secuencial       = _BLLFactura.GetNextNumeroFactura();
                    oDetFactura.CantidadPaquetes = Convert.ToInt32(txtCantidadPaquetes.Text);
                    oDetFactura.TipoEnvio        = _BLLPrecioEnvio.MostrarXID(cboTipoEnvio.SelectedItem.ToString());
                    _EncabezadoFactura.AgregrarDetalle(oDetFactura);
                    txtSubTotal.Text       = _EncabezadoFactura.SubTotal() + "";
                    txtTotal.Text          = _EncabezadoFactura.SubTotal() + ((_EncabezadoFactura.SubTotal() * _EncabezadoFactura.Impuesto())) + "";
                    oDetFactura.Total      = _EncabezadoFactura.SubTotal() + ((_EncabezadoFactura.SubTotal() * _EncabezadoFactura.Impuesto()));
                    _EncabezadoFactura.XML = _EncabezadoFactura.GenerarXML();
                    File.WriteAllText(@"c:\temp\proyecto.xml", _EncabezadoFactura.GenerarXML());
                }
            }
            catch (Exception er)
            {
                StringBuilder msg = new StringBuilder();
                msg.AppendFormat("Message        {0}\n", er.Message);
                msg.AppendFormat("Source         {0}\n", er.Source);
                msg.AppendFormat("InnerException {0}\n", er.InnerException);
                msg.AppendFormat("StackTrace     {0}\n", er.StackTrace);
                msg.AppendFormat("TargetSite     {0}\n", er.TargetSite);
                // Log error
                _MyLogControlEventos.ErrorFormat("Error {0}", msg.ToString());
                // Mensaje de Error
                MessageBox.Show("Se ha producido el siguiente error " + er.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }