Exemple #1
0
        /// <summary>
        /// Metodo para cargar todos los precios de la base de datos en la tabla
        /// </summary>
        public void MostrarPrecios()
        {
            List <EnvioPaquete> _listPrecios        = new List <EnvioPaquete>();
            IBLLPrecioEnvio     _BLLPrecioKilometro = new BLLPrecioEnvio();

            dgvPrecios.AutoGenerateColumns = false;
            //dgvPrecios.RowTemplate.Height = 100;
            dgvPrecios.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells;

            try
            {
                _listPrecios          = _BLLPrecioKilometro.ListaPrecios();
                dgvPrecios.DataSource = _listPrecios;
            }
            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);
                _MyLogControlEventos.ErrorFormat("Error {0}", msg.ToString());
                MessageBox.Show("Se ha producido el siguiente error " + er.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #2
0
        /// <summary>
        /// Método que asigna el tipo de envio que es
        /// </summary>
        public void AsignarTipoEnvio()
        {
            IBLLPrecioEnvio     _BLLPrecioEnvio = new BLLPrecioEnvio();
            List <EnvioPaquete> _ListEnvio      = new List <EnvioPaquete>();

            _ListEnvio = _BLLPrecioEnvio.ListaPrecios();
            cboTipoEnvio.Items.Clear();
            double mayor = 0;

            double kilometros = Math.Round(Convert.ToDouble(txtKilometros.Text));

            foreach (EnvioPaquete item in _ListEnvio)
            {
                if (kilometros >= item.KilometroInicial && kilometros <= item.KilometroFinal)
                {
                    cboTipoEnvio.Items.Add(item.TipoEnvio);
                }
                else
                {
                    mayor = item.KilometroFinal;
                }
            }
            if (mayor == kilometros)
            {
                MessageBox.Show("Los kilometros del trayecto no esta entre los rangos permitidos en el programa");
                cboTipoEnvio.SelectedIndex = -1;
                lstUbicaciones.Items.Clear();
            }
            else
            {
                cboTipoEnvio.SelectedIndex = 0;
            }
        }
Exemple #3
0
        /// <summary>
        /// Metodo que elimina el precio seleccionado en la tabla
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            IBLLPrecioEnvio _BLLPrecioKilometro = new BLLPrecioEnvio();

            try
            {
                if (string.IsNullOrEmpty(dgvPrecios.SelectedRows[0].Cells[0].Value.ToString()))
                {
                    erpErrores.SetError(dgvPrecios, "Debe seleccionar un item de la tabla");
                }
                else
                {
                    _BLLPrecioKilometro.BorrarEnvio(dgvPrecios.SelectedRows[0].Cells[0].Value.ToString());
                    MessageBox.Show("Se eliminó con éxito");
                }
            }
            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);
                _MyLogControlEventos.ErrorFormat("Error {0}", msg.ToString());
                MessageBox.Show("Se ha producido el siguiente error " + er.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public void GetAllPrecio()
        {
            IBLLPrecioEnvio     _BLLPrecioEnvio = new BLLPrecioEnvio();
            List <EnvioPaquete> _ListPrecios    = new List <EnvioPaquete>();

            _ListPrecios = _BLLPrecioEnvio.ListaPrecios();
            System.Diagnostics.Debug.Write(_ListPrecios[0].TipoEnvio);
        }
        public void EliminarPrecio()
        {
            IBLLPrecioEnvio _BLLPrecioEnvio = new BLLPrecioEnvio();
            string          IDEnvio         = "T";
            string          pEnvio          = "";

            pEnvio = _BLLPrecioEnvio.BorrarEnvio(IDEnvio);
            System.Diagnostics.Debug.Write(pEnvio);
        }
        public void BuscarPrecioEnvioID()
        {
            IBLLPrecioEnvio _BLLPrecioEnvio = new BLLPrecioEnvio();
            string          IDEnvio         = "A";
            EnvioPaquete    pEnvio          = new EnvioPaquete();

            pEnvio = _BLLPrecioEnvio.MostrarXID(IDEnvio);
            System.Diagnostics.Debug.Write(pEnvio.TipoEnvio);
        }
        public void ModificarPrecioEnvio()
        {
            IBLLPrecioEnvio _BLLPrecioEnvio = new BLLPrecioEnvio();
            EnvioPaquete    oEnvio          = new EnvioPaquete();
            EnvioPaquete    pEnvio          = new EnvioPaquete();

            oEnvio.KilometroFinal   = 6598;
            oEnvio.KilometroInicial = 8798;
            oEnvio.PrecioRango      = 23235612;
            oEnvio.TipoEnvio        = "T";

            pEnvio = _BLLPrecioEnvio.ActualizarPrecioEnvio(oEnvio);
            System.Diagnostics.Debug.Write(pEnvio.TipoEnvio);
        }
        public void InsertarPrecioEnvio()
        {
            IBLLPrecioEnvio _BLLPrecioEnvio = new BLLPrecioEnvio();
            EnvioPaquete    oEnvio          = new EnvioPaquete();
            EnvioPaquete    pEnvio          = new EnvioPaquete();

            oEnvio.KilometroFinal   = 5641;
            oEnvio.KilometroInicial = 9874;
            oEnvio.PrecioRango      = 16515616;
            oEnvio.TipoEnvio        = "T";

            pEnvio = _BLLPrecioEnvio.InsertarPrecioEnvio(oEnvio);
            System.Diagnostics.Debug.Write(pEnvio.TipoEnvio);
        }
Exemple #9
0
        /// <summary>
        /// Metodo que modifica el precio que hay en la base de datos
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnModificar_Click(object sender, EventArgs e)
        {
            erpErrores.Clear();
            IBLLPrecioEnvio _BLLPrecioKilometro = new BLLPrecioEnvio();

            try
            {
                if (string.IsNullOrEmpty(txtTipoMod.Text))
                {
                    erpErrores.SetError(txtTipoMod, "No puede quedar vacío");
                }
                else
                {
                    if (nudKilometroInicialMod.Value == 0 && nudKilometroFinalMod.Value == 0)
                    {
                        erpErrores.SetError(nudKilometroFinalMod, "No puede ser cero a ambos lados");
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(mskPrecioMod.Text))
                        {
                            erpErrores.SetError(mskPrecioMod, "No puede quedar vacío");
                        }
                        else
                        {
                            EnvioPaquete oEnvio = new EnvioPaquete();
                            oEnvio.TipoEnvio        = txtTipoMod.Text;
                            oEnvio.KilometroInicial = (int)nudKilometroInicialMod.Value;
                            oEnvio.KilometroFinal   = (int)nudKilometroFinalMod.Value;
                            oEnvio.PrecioRango      = Convert.ToDouble(mskPrecioMod.Text);
                            _BLLPrecioKilometro.ActualizarPrecioEnvio(oEnvio);
                            EspaciosBlancoMod();
                        }
                    }
                }
            }
            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);
                _MyLogControlEventos.ErrorFormat("Error {0}", msg.ToString());
                MessageBox.Show("Se ha producido el siguiente error " + er.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #10
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);
            }
        }