Beispiel #1
0
        private void btnFiltrar_Click(object sender, EventArgs e)
        {
            List <Modelos.Oferta> ofertas;

            String[] searchables = loadSearchInputs();

            if (searchables.All(searchable => string.IsNullOrEmpty(searchable) || string.IsNullOrWhiteSpace(searchable)))
            {
                ofertas = DB_Ofertas.getOfertas();
                if (ofertas == null)
                {
                    MessageBox.Show("No hay ofertas disponibles", "Compra Ofertas", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                showOfertas(ofertas);
                return;
            }

            ofertas = DB_Ofertas.getOfertasWithCondition(txtProveedor.Text, txtDescripcion.Text, txtPrecioMin.Text, txtPrecioMax.Text);
            if (ofertas == null)
            {
                MessageBox.Show("No hay ofertas que coincidan con su busqueda", "Compra Ofertas", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            showOfertas(ofertas);
            return;
        }
Beispiel #2
0
 public CargaCredito()
 {
     InitializeComponent();
     Decoracion.Reorganizar(this);
     this.loadTiposDePago();
     lblCredito.Text = DB_Ofertas.getCreditoCliente(Session.getUser().getUsername()).ToString();
 }
Beispiel #3
0
        private void proveedoresGrid_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            int i = e.RowIndex;

            DataGridViewRow selectedRow = proveedoresGrid.Rows[i];

            Modelos.Proveedor proveedor = ((Modelos.Proveedor)selectedRow.DataBoundItem);
            username                      = proveedor.Username;
            textRazonSocial.Text          = proveedor.RazonSocial.ToString();
            razonProvActual               = proveedor.RazonSocial.ToString();
            textCUIT.Text                 = proveedor.Cuit;
            textMail.Text                 = proveedor.Mail;
            mailProvActual                = proveedor.Mail;
            textNombreContacto.Text       = proveedor.NombreContacto;
            ddRubros.Text                 = DB_Ofertas.nombreRubro(proveedor.Rubro_Id);
            textTel.Text                  = proveedor.Telefono.ToString();
            textPiso.Text                 = proveedor.Piso.ToString();
            textCalle.Text                = proveedor.Direccion;
            textCP.Text                   = proveedor.Cp.ToString();
            textDpto.Text                 = proveedor.Dpto;
            textLoc.Text                  = proveedor.Localidad;
            comboHabilitado.SelectedIndex = comboHabilitado.FindString(habilitadoToString(proveedor));

            foreach (TextBox input in modificableInputs())
            {
                input.Enabled = true;
            }
            enableButtons();
        }
Beispiel #4
0
        private void buttonGuardar_Click(object sender, EventArgs e)
        {
            String     nombreNuevoRol, nombreViejoRol;
            List <int> funcionalidades = new List <int>();


            foreach (DataGridViewRow row in tablaFuncionalidades.Rows)
            {
                if (row.Cells[0].Value.Equals("True"))
                {
                    funcionalidades.Add(int.Parse(row.Cells[1].Value.ToString()));
                }
            }
            nombreViejoRol = textNombreRol.Text;
            nombreNuevoRol = textNombreNuevo.Text;
            bool habilitado = habilitadoToBool(ddEstado.Text);
            bool update     = DB_Ofertas.updateRol(nombreNuevoRol, nombreViejoRol, funcionalidades, habilitado);

            if (update)
            {
                MessageBox.Show("Rol modificado correctamente", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            textNombreNuevo.Clear();
            textNombreRol.Clear();
            ddEstado.Items.Clear();
            tablaFuncionalidades.DataSource = null;
        }
Beispiel #5
0
        public ComprarOferta()
        {
            InitializeComponent();
            Decoracion.Reorganizar(this);
            List <Modelos.Oferta> ofertas = DB_Ofertas.getOfertas();

            showOfertas(ofertas);
        }
Beispiel #6
0
        private void Alta_Load(object sender, EventArgs e)
        {
            List <Modelos.Funcionalidad> funcionalidades = DB_Ofertas.getFuncionalidades();

            showFuncionalidades(funcionalidades);
            tablaFuncionalidades.Columns["id_funcionalidad"].ReadOnly = true;
            tablaFuncionalidades.Columns["funcionalidad"].ReadOnly    = true;
            tablaFuncionalidades.Columns["descripcion"].ReadOnly      = true;
        }
Beispiel #7
0
 private String habilitadoToString(int id_rol)
 {
     if (DB_Ofertas.habilitado(id_rol))
     {
         return("Habilitado");
     }
     else
     {
         return("Deshabilitado");
     }
 }
Beispiel #8
0
        private void btnLimpiar_Click(object sender, EventArgs e)
        {
            this.txtDescripcion.Clear();
            this.txtProveedor.Clear();
            this.txtPrecioMin.Clear();
            this.txtPrecioMax.Clear();
            this.numCantidad.Value = 0;
            List <Modelos.Oferta> ofertas = DB_Ofertas.getOfertas();

            showOfertas(ofertas);
        }
Beispiel #9
0
 private void btnFacturar_Click(object sender, EventArgs e)
 {
     if (dataGridCupones.Rows != null && dataGridCupones.Rows.Count != 0)
     {
         Modelos.Factura factura = DB_Ofertas.facturarCupones(proveedorSeleccionado, desde, hasta);
         dataGridCupones.DataSource = null;
         textFacturaN.Text          = factura.numero.ToString();
         textMonto.Text             = factura.monto.ToString();
         return;
     }
     MessageBox.Show("No hay nada que facturar", "Facturar", MessageBoxButtons.OK, MessageBoxIcon.Warning);
 }
Beispiel #10
0
        private void btnBaja_Click(object sender, EventArgs e)
        {
            DialogResult res = MessageBox.Show("¿Desea canjear el cupon n°" + current.Id + "?", "Consumir Ofertas", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);

            if (res == DialogResult.OK)
            {
                DB_Ofertas.consumirOferta(current, Properties.Settings.Default.Fecha);
            }

            List <Modelos.Cupon> cupones = DB_Ofertas.getCupones(Session.getUser().getUsername());

            showCupones(cupones);
        }
Beispiel #11
0
        public ConsumirOferta()
        {
            InitializeComponent();
            Decoracion.Reorganizar(this);
            List <Modelos.Cupon> cupones = DB_Ofertas.getCupones(Session.getUser().getUsername());

            if (cupones == null)
            {
                exit = true;
                return;
            }
            showCupones(cupones);
        }
Beispiel #12
0
        private void btnLimpiar_Click(object sender, EventArgs e)
        {
            this.txtCliente.Clear();
            this.txtDescripcion.Clear();
            this.txtIdCupon.Clear();
            this.txtIdOferta.Clear();
            List <Modelos.Cupon> cupones = DB_Ofertas.getCupones(Session.getUser().getUsername());

            if (cupones != null)
            {
                showCupones(cupones);
            }
        }
Beispiel #13
0
        private void listRoles()
        {
            roles = DB_Ofertas.getAllRoles();

            if (roles.Count != 0)
            {
                ddRoles.Enabled       = true;
                ddRoles.DataSource    = roles;
                ddRoles.DisplayMember = "nombre";
                //ddRoles.ValueMember = "nombre";
                ddRoles.SelectedItem = roles.First();
            }
        }
Beispiel #14
0
        private void listRubros()
        {
            rubros = DB_Ofertas.getRubros();

            if (rubros.Count != 0)
            {
                ddRubros.Enabled       = true;
                ddRubros.DataSource    = rubros;
                ddRubros.DisplayMember = "nombre";
                ddRubros.ValueMember   = "id_rubro";
                ddRubros.SelectedItem  = rubros.First();
            }
        }
Beispiel #15
0
        private void listProveedores()
        {
            proveedores = DB_Ofertas.getProveedoresFacturacion();

            if (proveedores.Count != 0)
            {
                ddProveedor.Enabled       = true;
                ddProveedor.DataSource    = proveedores;
                ddProveedor.DisplayMember = "razonSocial";
                ddProveedor.ValueMember   = "username";
                ddProveedor.SelectedItem  = proveedores.First();
            }
        }
Beispiel #16
0
        private void buttonAlta_Click(object sender, EventArgs e)
        {
            //valida vacios
            String[] inputs = loadInputs();
            if (inputs.Any(input => String.IsNullOrEmpty(input)))
            {
                MessageBox.Show("Faltan llenar campos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            //valido formato de mails
            if (!Validar.validateEmail(this.textMail.Text))
            {
                MessageBox.Show("Formato invalido de Email", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (string.IsNullOrEmpty(textCP.Text))
            {
                textCP.Text = "-";
            }
            if (string.IsNullOrEmpty(textPiso.Text))
            {
                textPiso.Text = "-";
            }
            if (string.IsNullOrEmpty(textDpto.Text))
            {
                textDpto.Text = "-";
            }

            bool alta = DB_Ofertas.altaCliente(this.textUsuario.Text,
                                               this.textContra.Text,
                                               this.textNombre.Text,
                                               this.textApellido.Text,
                                               this.textMail.Text,
                                               this.textTelefono.Text,
                                               Convert.ToDateTime(this.textFN.Text),
                                               this.textCalle.Text,
                                               this.textPiso.Text,
                                               this.textDpto.Text,
                                               this.textLocalidad.Text,
                                               this.textCP.Text,
                                               this.textDNI.Text);

            if (alta)
            {
                MessageBox.Show("Usuario dado de alta correctamente", "Alta cliente", MessageBoxButtons.OK, MessageBoxIcon.Information);
                cleanInputs();
            }
        }
Beispiel #17
0
        private void PublicarOferta_Load(object sender, EventArgs e)
        {
            calendarFechaPublicacion.MinDate = DateTime.Now;
            bool admin = DB_Ofertas.esAdmin(Session.getUser().getUsername());

            if (admin)
            {
                this.textProveedor.Enabled = true;
            }
            else
            {
                this.textProveedor.Text = Session.getUser().getUsername();
            }
        }
Beispiel #18
0
        private void showTarjetas()
        {
            List <Modelos.Tarjeta> tarjetas = DB_Ofertas.getTarjetasParaCliente(Session.getUser().getUsername());

            gridTarjetas.DataSource = tarjetas;
            if (tarjetas != null)
            {
                gridTarjetas.Rows[0].Selected = true;
                actual = getRow(0);
            }
            else
            {
                actual = null;
            }
        }
Beispiel #19
0
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            //Validaciones:
            //valida vacios
            String[] inputs = loadInputs();
            if (inputs.Any(input => String.IsNullOrEmpty(input)))
            {
                MessageBox.Show("Faltan llenar campos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (txtCodigo.TextLength != 3)
            {
                MessageBox.Show("El codigo de seguridad no es correcto", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            int intMes = int.Parse(txtMes.Text);

            if (intMes > 12 || intMes < 0)
            {
                MessageBox.Show("Error en el campo mes", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            int intAnio = int.Parse(txtAnio.Text);

            if (intAnio < 0 || intAnio / 100 >= 1) //Negativo o mas de 2 digitos
            {
                MessageBox.Show("Error en el campo anio", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            int mesActual  = Properties.Settings.Default.Fecha.Month;
            int anioActual = Properties.Settings.Default.Fecha.Year;

            if ((2000 + intAnio) < anioActual || intMes < mesActual && (2000 + intAnio) == anioActual)
            {
                MessageBox.Show("Error, la tarjeta esta vencida", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }


            DB_Ofertas.agregarTarjetasParaCliente(Session.getUser().getUsername(), txtNumero.Text, txtTitular.Text, intMes, int.Parse(txtAnio.Text), txtCodigo.Text);
            CargaCredito cc = new CargaCredito();

            cc.Show();
            this.Hide();
        }
Beispiel #20
0
        //Boton de logueo
        private void button1_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(this.username) || String.IsNullOrEmpty(this.password))
            {
                MessageBox.Show("El Usuario o la Contrasena no pueden estar vacios", "Error");
                return;
            }

            if (this.usuarioBloqueado == this.username)
            {
                MessageBox.Show("Usuario: " + this.username + " inhabilitado por multiples intentos fallidos", "Error");
                return;
            }

            //consulta  a la DB
            Modelos.Usuario usuario = DB_Ofertas.login(this.username, this.password);

            if (usuario != null && usuario.habilitado)
            {
                //pantalla de seleccion de rol
                Rol r = new Rol(usuario);
                r.Show();
                this.Hide();
            }
            else if (usuario != null && !usuario.habilitado)
            {
                MessageBox.Show("El usuario se encuentra deshabilitado", "Error");
            }
            else
            {
                if (this.intentos <= 3)
                {
                    this.intentos++;
                }

                if (this.intentos > 3)
                {
                    this.usuarioBloqueado = this.username;
                    MessageBox.Show("Se ha inhabilitado el usuario: " + this.username + " por superar la cantidad de intentos", "Error");
                    return;
                }
                else
                {
                    MessageBox.Show("Usuario o contrasena invalida, intentos restantes: " + (3 - this.intentos) + "", "Error");
                    return;
                }
            }
        }
Beispiel #21
0
        private void btnBuscar_Click(object sender, EventArgs e)
        {
            textMonto.Clear();
            textFacturaN.Clear();

            proveedorSeleccionado = proveedores.Where(p => p.RazonSocial == ddProveedor.Text).ToList().First();

            cupones = DB_Ofertas.getCupones(proveedorSeleccionado.Username, dateTimeDesde.Value, dateTimeHasta.Value);

            dataGridCupones.DataSource = cupones;

            desde = dateTimeDesde.Value;
            hasta = dateTimeHasta.Value;

            dataGridCupones.AutoResizeColumns();
        }
Beispiel #22
0
 private void showFuncionalidades(List <Modelos.Funcionalidad> funcionalidades, int idRol)
 {
     tablaFuncionalidades.DataSource = funcionalidades;
     tablaFuncionalidades.AutoResizeColumns();
     tablaFuncionalidades.Rows[0].Selected = true;
     foreach (DataGridViewRow row in tablaFuncionalidades.Rows)
     {
         if (DB_Ofertas.tieneFuncionalidad(row.Cells[1].Value.ToString(), idRol))
         {
             row.Cells[0].Value = "True";
         }
         else
         {
             row.Cells[0].Value = "False";
         }
     }
 }
Beispiel #23
0
        private void buttonBuscar_Click(object sender, EventArgs e)
        {
            int idRol = DB_Ofertas.getIdRol(textNombreRol.Text);

            if (idRol == 0)
            {
                MessageBox.Show("El rol ingresado no existe", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            List <Modelos.Funcionalidad> funcionalidades = DB_Ofertas.getFuncionalidades();

            showFuncionalidades(funcionalidades, idRol);
            textNombreNuevo.Text   = textNombreRol.Text;
            ddEstado.SelectedIndex = ddEstado.FindString(habilitadoToString(idRol));
            return;
        }
Beispiel #24
0
        private void loadTiposDePago()
        {
            this.tiposPago = DB_Ofertas.getTiposDePago();

            if (tiposPago.Count == 0)
            {
                MessageBox.Show("No existen medios de pago disponible", "Aviso");
            }
            else
            {
                cbxTipoPago.DataSource    = tiposPago;
                cbxTipoPago.DisplayMember = "nombre";
                cbxTipoPago.ValueMember   = "id_tipo";

                cbxTipoPago.SelectedItem = tiposPago.First();
            }
        }
Beispiel #25
0
        private void button1_Click(object sender, EventArgs e)
        {
            DialogResult boton = MessageBox.Show("Estas seguro que quieres borrar el rol?", "Alerta", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);

            if (boton == DialogResult.OK)
            {
                bool eliminar = DB_Ofertas.eliminarRol(ddRoles.Text);
                if (eliminar)
                {
                    MessageBox.Show("Se borro el rol seleccionado", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    listRoles();
                    ddRoles.ResetText();
                }
            }
            else
            {
                //se deberia quedar en esta pantalla
            }
        }
Beispiel #26
0
        private void btnComprar_Click(object sender, EventArgs e)
        {
            if (numCantidad.Value == 0)
            {
                MessageBox.Show("Seleccione una cantidad mayor a 0", "Compra Ofertas", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            DialogResult res = MessageBox.Show("¿Desea comprar " + numCantidad.Value + " de estas ofertas?", "Compra Ofertas", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);

            if (res == DialogResult.OK)
            {
                DB_Ofertas.comprarOferta(Session.getUser(), current, (int)numCantidad.Value, Properties.Settings.Default.Fecha);
            }

            List <Modelos.Oferta> ofertas = DB_Ofertas.getOfertas();

            showOfertas(ofertas);
        }
Beispiel #27
0
        private void btnCargar_Click(object sender, EventArgs e)
        {
            if (txtMonto.Text == "")
            {
                MessageBox.Show("Complete el campo credito", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            double monto = double.Parse(txtMonto.Text);

            if (monto < 0)
            {
                MessageBox.Show("Error en el monto", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (actual == null && cbxTipoPago.Text == "Crédito")
            {
                MessageBox.Show("Seleccione una tarjeta o cambie el tipo de pago", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            DateTime localDate = Properties.Settings.Default.Fecha;

            String tarjetaNum = null;

            if (actual != null)
            {
                tarjetaNum = actual.Numero;
            }

            Modelos.TipoPago tp = tiposPago.Where(p => p.nombre == cbxTipoPago.Text).ToList().First();

            DB_Ofertas.generarCarga(Session.getUser().getUsername(), tp.id_tipo, localDate, monto, tarjetaNum);

            DB_Ofertas.actualizarMontoCliente(Session.getUser().getUsername(), monto);

            MessageBox.Show("Credito actualizado con exito", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information);
            txtMonto.Text   = "";
            lblCredito.Text = DB_Ofertas.getCreditoCliente(Session.getUser().getUsername()).ToString();
        }
Beispiel #28
0
        private void btnFiltrar_Click(object sender, EventArgs e)
        {
            List <Modelos.Cupon> cupones;

            String[] searchables = loadSearchInputs();

            if (searchables.All(searchable => string.IsNullOrEmpty(searchable) || string.IsNullOrWhiteSpace(searchable)))
            {
                cupones = DB_Ofertas.getCupones(Session.getUser().getUsername());
                showCupones(cupones);
                return;
            }

            cupones = DB_Ofertas.getCuponesWithCondition(Session.getUser().getUsername(), txtCliente.Text, txtDescripcion.Text, txtIdCupon.Text, txtIdOferta.Text);
            if (cupones == null)
            {
                MessageBox.Show("No hay cupones que coincidan con su busqueda", "Consumir Oferta", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            showCupones(cupones);
            return;
        }
Beispiel #29
0
        private void buttonGuardar_Click(object sender, EventArgs e)
        {
            String     nombreRol;
            List <int> funcionalidades = new List <int>();


            foreach (DataGridViewRow row in tablaFuncionalidades.Rows)
            {
                if (row.Cells[0].Value.Equals("True"))
                {
                    funcionalidades.Add(int.Parse(row.Cells[1].Value.ToString()));
                }
            }

            nombreRol = textNombre.Text;

            bool alta = DB_Ofertas.crearRol(nombreRol, funcionalidades);

            if (alta)
            {
                MessageBox.Show("Rol creado correctamente", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Beispiel #30
0
        private void buttonPublicar_Click(object sender, EventArgs e)
        {
            //valida vacios
            String[] inputs = loadInputs();
            if (inputs.Any(input => String.IsNullOrEmpty(input)))
            {
                MessageBox.Show("Faltan llenar campos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (DB_Ofertas.esAdmin(Session.getUser().getUsername()))
            {
                if (!DB_Ofertas.usuarioEsProveedor(this.textProveedor.Text))
                {
                    MessageBox.Show("El usuario ingresado no es un proveedor", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }


            //valida proveedor

            bool alta = DB_Ofertas.crearOferta(this.textDescripcion.Text,
                                               Convert.ToDecimal(this.textPrecioOferta.Text),
                                               Convert.ToDecimal(this.textPrecioLista.Text),
                                               Convert.ToInt32(this.textStockDisp.Text),
                                               Convert.ToInt32(this.textCantMax.Text),
                                               this.calendarFechaPublicacion.SelectionStart,
                                               this.calendarFechaVencimiento.SelectionStart,
                                               this.textProveedor.Text);

            if (alta)
            {
                MessageBox.Show("Oferta creada correctamente", "Publicar Oferta", MessageBoxButtons.OK, MessageBoxIcon.Information);
                cleanInputs();
            }
        }