Example #1
0
 private void btnEliminarDescuento_Click(object sender, EventArgs e)
 {
     try
     {
         if (dgvDescuento.SelectedRows.Count == 0)
         {
             MessageBox.Show("Error: Debe seleccionar un descuento para Eliminar.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else
         {
             DialogResult result = MessageBox.Show("¿Está seguro que desea eliminar " + dgvDescuento.SelectedRows[0].Cells[2].Value.ToString() + "?", "Eliminar " + dgvDescuento.SelectedRows[0].Cells[2].Value.ToString(), MessageBoxButtons.YesNo);
             if (result == DialogResult.Yes)
             {
                 long         codigoDescuento = long.Parse(dgvDescuento.SelectedRows[0].Cells[0].Value.ToString());
                 DescuentoDAO descuentoDAO    = new DescuentoDAO();
                 descuentoDAO.eliminarDescuentoPorId(codigoDescuento);
                 listaDescuentos = new BindingList <DescuentoGridVO>(descuentoDAO.getAllDescuentosGrid());
                 this.dgvDescuento.DataSource = listaDescuentos;
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error grave eliminando Descuento.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Example #2
0
        private void btnActualizar_Click(object sender, EventArgs e)
        {
            DescuentoDAO descDAO = new DescuentoDAO();

            listaDescuentos = new BindingList <DescuentoGridVO>(descDAO.getAllDescuentosGrid());
            this.dgvDescuento.DataSource = listaDescuentos;
        }
Example #3
0
        private void btnModificar_Click(object sender, EventArgs e)
        {
            try
            {
                if (dgvDescuento.SelectedRows.Count == 0)
                {
                    MessageBox.Show("Error: Debe seleccionar un descuento para editar.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    OfertaDAO    ofertaDAO    = new OfertaDAO();
                    DescuentoDAO descuentoDAO = new DescuentoDAO();
                    WindowsFormsApp1.Model.Negocio.Entities.Descuento descuentoSeleccionado = descuentoDAO.obtenerDescuentoPorID(long.Parse(dgvDescuento.SelectedRows[0].Cells[0].Value.ToString()));
                    WindowsFormsApp1.Model.Negocio.Entities.Oferta    oferta = ofertaDAO.getOfertaVigenteByCodigoProducto(descuentoSeleccionado.idProducto);

                    if (oferta != null)
                    {
                        MessageBox.Show("Error: Existe una oferta activa para este descuento, no puede ser editado.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    ModificarDescuento modif = new ModificarDescuento();
                    modif.descuentoSeleccionado = descuentoSeleccionado;
                    modif.ShowDialog();
                    listaDescuentos = new BindingList <DescuentoGridVO>(descuentoDAO.getAllDescuentosGrid());
                    this.dgvDescuento.DataSource = listaDescuentos;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error grave editando Descuento.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #4
0
        private void btnNuevo_Click(object sender, EventArgs e)
        {
            CrearDescuento cdescuento = new CrearDescuento();

            cdescuento.ShowDialog();
            DescuentoDAO descDAO = new DescuentoDAO();

            listaDescuentos = new BindingList <DescuentoGridVO>(descDAO.getAllDescuentosGrid());
            this.dgvDescuento.DataSource = listaDescuentos;
        }
Example #5
0
        private void ListarDescuentos_Load(object sender, EventArgs e)
        {
            lblUsuarioIngreso.Text = "Bienvenido(a): " + objetoPaso.pasoUsuario;
            DescuentoDAO descDAO = new DescuentoDAO();

            listaDescuentos = new BindingList <DescuentoGridVO>(descDAO.getAllDescuentosGrid());
            this.dgvDescuento.DataSource = listaDescuentos;

            foreach (Funcionalidad func in SesionBag.usuarioSesionado.funcionalidadesUsuario)
            {
                ToolStripMenuItem itm = new ToolStripMenuItem(func.nombre);
                itm.Click += new EventHandler(genericHandler);
                itm.Name   = func.idFuncionalidad.ToString();
                if (itm.Name.Equals("4"))
                {
                    itm.ForeColor = Color.Gray;
                }
                this.menuStrip1.Items.Add(itm);
            }
        }
Example #6
0
        private string obtenerResumen()
        {
            ConsumidorDAO consumidorDAO = new ConsumidorDAO();
            TrabajadorDAO trabajadorDAO = new TrabajadorDAO();
            ValoracionDAO valoracionDAO = new ValoracionDAO();
            DescuentoDAO  descuentoDAO  = new DescuentoDAO();
            LogEmailDAO   logEmailDAO   = new LogEmailDAO();
            UsuarioDAO    usuarioDAO    = new UsuarioDAO();
            TiendaDAO     tiendaDAO     = new TiendaDAO();
            RubroDAO      rubroDAO      = new RubroDAO();

            StringBuilder resumen = new StringBuilder();

            resumen.AppendLine("Usuarios ");
            resumen.AppendLine();
            resumen.Append("Total de usuarios registrados: ");
            resumen.AppendLine(usuarioDAO.getTotalUsuariosRegistrados().ToString());
            resumen.Append("Trabajadores registrados: ");
            resumen.AppendLine(trabajadorDAO.getTotalTrabajadoresRegistrados().ToString());
            resumen.Append("Consumidores registrados: ");
            resumen.AppendLine(consumidorDAO.getTotalConsumidoresRegistrados().ToString());
            resumen.AppendLine();
            resumen.Append("Correos enviados: ");
            resumen.AppendLine(logEmailDAO.getTotalLogEmailEnviados().ToString());
            resumen.AppendLine();
            resumen.Append("Cantidad valoraciones: ");
            resumen.AppendLine(valoracionDAO.getTotalValoracionesRegistradas().ToString());
            resumen.AppendLine();
            resumen.AppendLine("Total de descuentos entregados por rubro");
            foreach (Rubro rubro in rubroDAO.listarRubros())
            {
                resumen.Append(rubro.nombre);
                resumen.Append(": ");
                resumen.AppendLine(descuentoDAO.getTotalDescuentosRegistradosPorRubro(rubro.idRubro).ToString());
            }

            consumidorDAO.getTotalConsumidoresRegistrados();
            label1.Text = resumen.ToString();
            return(resumen.ToString());
        }
Example #7
0
        private void btnCrearProducto_Click(object sender, EventArgs e)
        {
            try
            {
                //Validaciones varias
                if (txtNombre.Text == null || txtNombre.Text.Trim().Equals(string.Empty) || (txtNombre.Text.Trim().Equals("Nombre") && txtNombre.ForeColor == Color.Gray))
                {
                    MessageBox.Show("Error: El Nombre del descuento es obligatorio.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtNombre.Focus();
                }
                else if (txtDescripcion.Text == null || txtDescripcion.Text.Trim().Equals(string.Empty) || (txtDescripcion.Text.Trim().Equals("Descripción") && txtDescripcion.ForeColor == Color.Gray))
                {
                    MessageBox.Show("Error: La Descripción del descuento es obligatoria.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtDescripcion.Focus();
                }
                else if (cbxProducto.SelectedIndex == -1)
                {
                    MessageBox.Show("Error: Debe seleccionar un producto", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (!chkDescuentoPorcentaje.Checked && !chkDescuentoPrecio.Checked)
                {
                    MessageBox.Show("Error: Debe seleccionar un tipo de descuento.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (chkDescuentoPorcentaje.Checked && (txtPorcentajeDescuento.Text == null || txtPorcentajeDescuento.Text.Trim().Equals(string.Empty) || (txtPorcentajeDescuento.Text.Trim().Equals("0%"))))
                {
                    MessageBox.Show("Error: Debe ingresar un porcentaje de descuento.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (chkDescuentoPrecio.Checked && (txtPrecioDescuento.Text == null || txtPrecioDescuento.Text.Trim().Equals(string.Empty) || (txtPrecioDescuento.Text.Trim().Equals("$0"))))
                {
                    MessageBox.Show("Error: Debe ingresar un precio de descuento.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    ProductoDAO  productoDAO  = new ProductoDAO();
                    DescuentoDAO descuentoDAO = new DescuentoDAO();
                    Productos    prod         = productoDAO.getProductoPorID(long.Parse(cbxProducto.SelectedValue.ToString()));

                    if (chkDescuentoPrecio.Checked && (prod.precio < int.Parse(txtPrecioDescuento.Text)))
                    {
                        MessageBox.Show("Error: El descuento por precio ingresado no puede superar el precio del producto: " + prod.precio + ".", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    else if (chkDescuentoPorcentaje.Checked && (double.Parse(txtPorcentajeDescuento.Text) == 0 || double.Parse(txtPorcentajeDescuento.Text) > 100))
                    {
                        MessageBox.Show("Error: El Porcentaje de Descuento debe estar entre 1 y 100.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    WindowsFormsApp1.Model.Negocio.Entities.Descuento descOriginal = descuentoDAO.obtenerDescuentoPorProducto(prod.idProducto);

                    if (descOriginal == null)
                    {
                        WindowsFormsApp1.Model.Negocio.Entities.Descuento desc = new WindowsFormsApp1.Model.Negocio.Entities.Descuento();
                        desc.nombre              = txtNombre.Text.Trim();
                        desc.descripcion         = txtDescripcion.Text.Trim();
                        desc.isPorcentaje        = chkDescuentoPorcentaje.Checked ? (short)1 : (short)0;
                        desc.porcentajeDescuento = desc.isPorcentaje == 1 ? double.Parse(txtPorcentajeDescuento.Text) : 0;
                        desc.isPrecioDirecto     = chkDescuentoPrecio.Checked ? (short)1 : (short)0;
                        desc.precioDescuento     = desc.isPrecioDirecto == 1 ? int.Parse(txtPrecioDescuento.Text) : 0;
                        desc.idProducto          = prod.idProducto;
                        descuentoDAO.crearDescuento(desc);

                        this.Dispose();

                        MessageBox.Show("Descuento creado exitosamente.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Error: Ya existe un descuento creado para este Producto.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }catch (Exception ex)
            {
                MessageBox.Show("Error grave creando Descuento.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #8
0
 public ProductoService(ProductoDAO productoDAO, DescuentoDAO descuentoDAO, IMapper mapper)
 {
     this.productoDAO  = productoDAO;
     this.descuentoDAO = descuentoDAO;
     this.mapper       = mapper;
 }