コード例 #1
0
        private void listFacturacion_Load(object sender, EventArgs e)
        {
            grid.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells;

            year.Value            = Properties.Settings.Default.fecha.Year;
            semestre.SelectedItem = "Primero";

            string query = "select top 5 p.proveedor_id,p.proveedor_cuit as Cuit, p.proveedor_razon_social as Razon_social, sum(f.factura_monto_total) as Facturacion," +
                           "avg(f.factura_monto_total) as Promedio_Facturado_Por_Mes " +
                           "from " + Properties.Settings.Default.Schema + ".Proveedor p " +
                           "inner join " + Properties.Settings.Default.Schema + ".Factura f on f.proveedor_id = p.proveedor_id " +
                           "where (f.factura_fecha between '" + new DateTime(int.Parse(year.Value.ToString()), 1, 1).ToShortDateString() + "' and '" +
                           new DateTime(int.Parse(year.Value.ToString()), 7, 1).ToShortDateString() + "') and year(f.factura_fecha) = " + year.Value.ToString() +
                           " group by p.proveedor_id,p.proveedor_cuit, p.proveedor_razon_social " +
                           "order by sum(f.factura_monto_total) desc";

            ConexionBD.Conexion conection = new ConexionBD.Conexion().getInstance();
            proveedores     = conection.selectReturnMultiplyRowsByQuery(query);
            grid.DataSource = proveedores;

            if (proveedores.Rows.Count == 0)
            {
                vacioMsg.Visible = true;
            }
        }
コード例 #2
0
ファイル: AbmRol.cs プロジェクト: AxelFulop/TpGDD20192C
        private void cargarRoles()
        {
            string query = "select rol_nombre from " + Properties.Settings.Default.Schema + ".Rol ";

            for (int i = 0; i < rolesBorradosLogicamente.Count; i++)
            {
                if (i == 0)
                {
                    query += "where rol_nombre <> '" + rolesBorradosLogicamente.ElementAt(i) + "'";
                }
                else
                {
                    query += " and rol_nombre <> '" + rolesBorradosLogicamente.ElementAt(i) + "'";
                }
            }

            ConexionBD.Conexion conection       = new ConexionBD.Conexion().getInstance();
            List <Object>       funcionalidades = conection.executeAdvancedSelectQuery(query);

            if (funcionalidades.Count > 0)
            {
                roles.Items.Clear();
            }

            funcionalidades.ForEach(f =>
            {
                roles.Items.Add(f.ToString());
            });
        }
コード例 #3
0
ファイル: Editar.cs プロジェクト: AxelFulop/TpGDD20192C
        private void button1_Click_2(object sender, EventArgs e)
        {
            if (this.nombreRol.Text == "")
            {
                MessageBox.Show("Nombre de rol no permitido");
                return;
            }

            try
            {
                ConexionBD.Conexion conection = new ConexionBD.Conexion().getInstance();
                conection.executeProcedure(Properties.Settings.Default.Schema + ".cambiarNombreRol",
                                           new List <String>()
                {
                    "@nombreRol", "@nuevoNombre"
                },
                                           new String[] {
                    this.rol, this.nombreRol.Text
                }
                                           );

                MessageBox.Show("Rol '" + this.rol + "' ahora se llama '" + this.nombreRol.Text + "'");
                this.Hide();
                new Editar(this.nombreRol.Text).Show();
            }
            catch (Exception)
            {
                MessageBox.Show("Error al cambiar de nombre de rol '" + this.rol + "'" + " a '" + this.nombreRol.Text + "'. " +
                                "Podría ya existir un rol con ese nombre.", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #4
0
ファイル: Editar.cs プロジェクト: AxelFulop/TpGDD20192C
        private void button1_Click_1(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("¿Desea inhabilitar el rol '" + this.rol + "'?",
                                                  "Inhabilitar rol",
                                                  MessageBoxButtons.YesNo,
                                                  MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                try
                {
                    ConexionBD.Conexion conection = new ConexionBD.Conexion().getInstance();
                    conection.executeProcedure(Properties.Settings.Default.Schema + ".inhabilitarRol",
                                               new List <String>()
                    {
                        "@nombreRol"
                    },
                                               new String[] {
                        this.rol
                    }
                                               );

                    MessageBox.Show("Rol '" + this.rol + "' inhabilitado correctamente");
                    this.Hide();
                    new Editar(this.rol).Show();
                }
                catch (Exception)
                {
                    MessageBox.Show("Error al inhabilitar el rol '" + this.rol + "'");
                }
            }
        }
コード例 #5
0
        private void listDescuento_Load(object sender, EventArgs e)
        {
            grid.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells;
            year.Value            = Properties.Settings.Default.fecha.Year;
            semestre.SelectedItem = "Primero";

            string query = "SELECT top 5 p.proveedor_id,p.proveedor_cuit, p.proveedor_razon_social," +
                           "avg(100-o.oferta_precio*100/o.oferta_precio_lista) as Porcentaje_Descuento_Promedio," +
                           "count(o.oferta_codigo) as Cantidad_ofertas " +
                           "FROM " + Properties.Settings.Default.Schema + ".Proveedor p " +
                           "inner join " + Properties.Settings.Default.Schema + ".Oferta o on p.proveedor_id = o.proveedor_id " +
                           "where (o.oferta_fecha_publicacion between '" + new DateTime(int.Parse(year.Value.ToString()), 1, 1).ToShortDateString() + "' and '" +
                           new DateTime(int.Parse(year.Value.ToString()), 7, 1).ToShortDateString() + "') " +
                           "group by p.proveedor_id,p.proveedor_cuit, p.proveedor_razon_social " +
                           "order by Porcentaje_Descuento_Promedio desc";

            ConexionBD.Conexion conection = new ConexionBD.Conexion().getInstance();
            proveedores     = conection.selectReturnMultiplyRowsByQuery(query);
            grid.DataSource = proveedores;

            if (proveedores.Rows.Count == 0)
            {
                vacioMsg.Visible = true;
            }
        }
コード例 #6
0
        private void registrarCompra()
        {
            if (cantidad.Value < 1)
            {
                MessageBox.Show("Cantidad no puede ser menor a 1");
                return;
            }

            if (cantidad.Value > maxCantidad)
            {
                MessageBox.Show("La cantidad excede el limite de compra (" + maxCantidad + ")");
                return;
            }

            if ((comboBoxTarjeta.SelectedItem != null && !comboBoxTarjeta.Items.Contains(comboBoxTarjeta.SelectedItem)) || comboBoxTarjeta.SelectedItem == null)
            {
                MessageBox.Show("Tarjeta inválida");
                return;
            }

            if (tarj_fechaVencimiento.Value.CompareTo(Properties.Settings.Default.fecha) < 0)
            {
                MessageBox.Show("Tarjeta ya vencida");
                return;
            }

            decimal saldo       = decimal.Parse(tarj_saldo.Text);
            decimal totalAPagar = decimal.Parse(o_precio.Text) * cantidad.Value;

            if (saldo < totalAPagar)
            {
                MessageBox.Show("Saldo insuficiente.\n Total a pagar: $ " + totalAPagar + "\n Saldo tarjeta: $ " + saldo);
                return;
            }

            try
            {
                int cantProcs = 2 + int.Parse(cantidad.Value.ToString());
                Tuple <string, List <string>, Object[]>[] procs = new Tuple <string, List <string>, object[]> [cantProcs];

                for (int i = 0; i < cantProcs - 2; i++)
                {
                    procs[i] = altaCompra();
                }
                procs[cantProcs - 2] = reduccionSaldoTarjeta(totalAPagar);
                procs[cantProcs - 1] = reducirOfertaProv();

                ConexionBD.Conexion conection = new ConexionBD.Conexion().getInstance();
                conection.executeStoredTransaction(procs);

                MessageBox.Show("Compra realizada correctamente");
                this.Hide();
                pantallaOfertas.Hide();
                new ComprarOfertaABM().Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error al realizar la compra.\n" + ex.Message);
            }
        }
コード例 #7
0
ファイル: Nuevo.cs プロジェクト: AxelFulop/TpGDD20192C
        private void button1_Click(object sender, EventArgs e)
        {
            if (razonSocial.Text == "" || cuit.Text == "")
            {
                MessageBox.Show("Campos 'Razon social' y 'CUIT' son obligatorios");
                return;
            }

            DateTime fechaVenc = Properties.Settings.Default.fecha;
            string   schema    = Properties.Settings.Default.Schema;

            Tuple <string, List <string>, Object[]>[] procs = new Tuple <string, List <string>, object[]> [2];
            procs[1] = altaProveedor();
            procs[0] = altaUsuario();

            try
            {
                ConexionBD.Conexion conection = new ConexionBD.Conexion().getInstance();
                conection.executeStoredTransaction(procs);

                MessageBox.Show("Proveedor creado correctamente\nUsuario:'" + cuit.Text + "'\nContraseña:'" + razonSocial.Text + "'");
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
コード例 #8
0
ファイル: AbmCliente.cs プロジェクト: AxelFulop/TpGDD20192C
        private void cargarClientes()
        {
            string listaDni      = obtenerListaBorradosQueryDni();
            string listaNombre   = obtenerListaBorradosQueryNombre();
            string listaApellido = obtenerListaBorradosQueryApellido();

            string query = "SELECT cliente_id, cliente_nombre, cliente_apellido, cliente_numero_dni, cliente_email, cliente_telefono, " +
                           "cliente_direccion,cliente_direccion_piso,cliente_direccion_depto,cliente_direccion_localidad, cliente_codigo_postal, cliente_fecha_nacimiento" +
                           " FROM " + Properties.Settings.Default.Schema + ".Cliente";

            if (listaDni != "()" || listaNombre != "()" || listaApellido != "()")
            {
                query += " WHERE ";
                if (listaDni != "()")
                {
                    query += "cliente_numero_dni NOT IN " + listaDni;
                    if (listaNombre != "()")
                    {
                        query += " AND cliente_nombre NOT IN " + listaNombre;
                    }
                    if (listaApellido != "()")
                    {
                        query += " AND cliente_apellido NOT IN " + listaApellido;
                    }
                }
                else if (listaNombre != "()")
                {
                    query += "cliente_nombre NOT IN " + listaNombre;
                    if (listaApellido != "()")
                    {
                        query += " AND cliente_apellido NOT IN " + listaApellido;
                    }
                }
                else
                {
                    query += "cliente_apellido NOT IN " + listaApellido;
                }
            }

            ConexionBD.Conexion conection = new ConexionBD.Conexion().getInstance();
            clientes        = conection.selectReturnMultiplyRowsByQuery(query);
            grid.DataSource = clientes;

            DataGridViewButtonColumn colEditar = new DataGridViewButtonColumn();

            colEditar.UseColumnTextForButtonValue = true;
            colEditar.Text = "Editar";
            colEditar.Name = "";
            grid.Columns.Add(colEditar);

            DataGridViewButtonColumn colEliminar = new DataGridViewButtonColumn();

            colEliminar.UseColumnTextForButtonValue = true;
            colEliminar.Text = "Eliminar";
            colEliminar.Name = "";
            grid.Columns.Add(colEliminar);
        }
コード例 #9
0
ファイル: AbmProveedor.cs プロジェクト: AxelFulop/TpGDD20192C
        private void AbmProveedor_Load(object sender, EventArgs e)
        {
            Object estaHabilitado = new ConexionBD.Conexion().executeScalarFunction("rolEstaHabilitadoPorId", "3");

            if (estaHabilitado.ToString() == "1") //Si no está habilitado
            {
                NuevoProvBtn.Enabled    = false;
                msgInhabilitado.Visible = true;
            }
        }
コード例 #10
0
ファイル: AbmCliente.cs プロジェクト: AxelFulop/TpGDD20192C
        private void button1_Click(object sender, EventArgs e)
        {
            string nombre   = this.nombre.Text;
            string apellido = this.apellido.Text;
            string mail     = this.mail.Text;
            string dni      = this.dni.Text;

            string listaDni      = obtenerListaBorradosQueryDni();
            string listaNombre   = obtenerListaBorradosQueryNombre();
            string listaApellido = obtenerListaBorradosQueryApellido();

            string query = "SELECT cliente_id, cliente_nombre, cliente_apellido,cliente_numero_dni,cliente_email,cliente_telefono," +
                           "cliente_direccion,cliente_direccion_piso,cliente_direccion_depto,cliente_direccion_localidad,cliente_codigo_postal,cliente_fecha_nacimiento" +
                           " FROM " + Properties.Settings.Default.Schema + ".Cliente WHERE " +
                           "cliente_nombre LIKE '%" + nombre + "%' AND cliente_apellido LIKE '%" + apellido + "%' AND " +
                           "cliente_email LIKE '%" + mail + "%'";

            if (dni != "")
            {
                query += " AND cliente_numero_dni=" + dni;
            }

            if (listaDni != "()" || listaNombre != "()" || listaApellido != "()")
            {
                if (listaDni != "()")
                {
                    query += " AND cliente_numero_dni NOT IN " + listaDni;
                    if (listaNombre != "()")
                    {
                        query += " AND cliente_nombre NOT IN " + listaNombre;
                    }
                    if (listaApellido != "()")
                    {
                        query += " AND cliente_apellido NOT IN " + listaApellido;
                    }
                }
                else if (listaNombre != "()")
                {
                    query += " AND cliente_nombre NOT IN " + listaNombre;
                    if (listaApellido != "()")
                    {
                        query += " AND cliente_apellido NOT IN " + listaApellido;
                    }
                }
                else
                {
                    query += " AND cliente_apellido NOT IN " + listaApellido;
                }
            }

            ConexionBD.Conexion conection = new ConexionBD.Conexion().getInstance();
            clientes        = conection.selectReturnMultiplyRowsByQuery(query);
            grid.DataSource = clientes;
        }
コード例 #11
0
        private void button3_Click(object sender, EventArgs e)
        {
            filtroDescripcion.Text = "";

            string query = "SELECT oferta_codigo,oferta_descripcion,oferta_fecha_publicacion,oferta_fecha_vencimiento,oferta_limite_compra,oferta_stock_disponible,oferta_precio "
                           + "FROM GESTION_DE_GATOS.Oferta WHERE '" + Properties.Settings.Default.fecha.ToShortDateString() +
                           "' BETWEEN oferta_fecha_publicacion and oferta_fecha_vencimiento";

            ConexionBD.Conexion conection = new ConexionBD.Conexion().getInstance();
            ofertas         = conection.selectReturnMultiplyRowsByQuery(query);
            grid.DataSource = ofertas;
        }
コード例 #12
0
ファイル: Nuevo.cs プロジェクト: AxelFulop/TpGDD20192C
        private void cargarFuncionalidadesAAgregar()
        {
            string query = "select funcionalidad_descripcion from " + Properties.Settings.Default.Schema + ".Funcionalidad";

            ConexionBD.Conexion conection       = new ConexionBD.Conexion().getInstance();
            List <Object>       funcionalidades = conection.executeAdvancedSelectQuery(query);

            funcionalidades.ForEach(f =>
            {
                func_disp.Items.Add(f.ToString());
            });
        }
コード例 #13
0
ファイル: AbmCliente.cs プロジェクト: AxelFulop/TpGDD20192C
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            var senderGrid = (DataGridView)sender;

            if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn &&
                e.RowIndex >= 0 && e.RowIndex < grid.Rows.Count)
            {
                try
                {
                    if (e.ColumnIndex == 0) //Editar
                    {
                        DataRow row = (grid.CurrentRow.DataBoundItem as DataRowView).Row;
                        Dictionary <string, string> datos = ajustarDatosRow(row);
                        this.Hide();
                        new Editar(datos).Show();
                    }
                    else if (e.ColumnIndex == 1) //Eliminar
                    {
                        DataRow row = (grid.CurrentRow.DataBoundItem as DataRowView).Row;
                        Dictionary <string, string> datos = ajustarDatosRow(row);
                        DialogResult result = MessageBox.Show("¿Desea eliminar el cliente '" + datos["nombre"] + " "
                                                              + datos["apellido"] + "'?",
                                                              "",
                                                              MessageBoxButtons.YesNo,
                                                              MessageBoxIcon.Question);
                        if (result == DialogResult.Yes)
                        {
                            try
                            {
                                MessageBox.Show("Cliente eliminado correctamente", "",
                                                MessageBoxButtons.OK,
                                                MessageBoxIcon.Information);
                                Object user_cliente = new ConexionBD.Conexion().executeScalarFunction("obtenerUsuarioCliente", datos["id"]);

                                Logeo.usuariosEliminadosLogicamente.Add(user_cliente.ToString());
                                this.Hide();
                                new AbmCliente(Tuple.Create <string, string, string>(
                                                   datos["dni"], datos["nombre"], datos["apellido"]
                                                   )).Show();
                            }
                            catch (Exception)
                            {
                                MessageBox.Show("Error al eliminar el cliente", "",
                                                MessageBoxButtons.OK,
                                                MessageBoxIcon.Error);
                            }
                        }
                    }
                }
                catch (Exception) { }
            }
        }
コード例 #14
0
ファイル: consumoCupon.cs プロジェクト: AxelFulop/TpGDD20192C
        private string obtenerRazonSocial()
        {
            Object ret = new ConexionBD.Conexion().executeScalarFunction("obtenerRazonSocialProveedor", Logeo.username);

            if (ret == DBNull.Value)
            {
                return("");
            }
            else
            {
                return(ret.ToString());
            }
        }
コード例 #15
0
ファイル: AbmCliente.cs プロジェクト: AxelFulop/TpGDD20192C
        private void Form1_Load(object sender, EventArgs e)
        {
            Object estaHabilitado = new ConexionBD.Conexion().executeScalarFunction("rolEstaHabilitadoPorId", "2");

            if (estaHabilitado.ToString() == "1") //Si no está habilitado
            {
                button3.Enabled         = false;
                msgInhabilitado.Visible = true;
            }
            this.MinimumSize  = new System.Drawing.Size(this.Width, this.Height);
            this.AutoSize     = true;
            this.AutoSizeMode = AutoSizeMode.GrowAndShrink;
        }
コード例 #16
0
ファイル: Editar.cs プロジェクト: AxelFulop/TpGDD20192C
        private void seleccionarBotonHabilitacion()
        {
            ConexionBD.Conexion conection = new ConexionBD.Conexion().getInstance();
            Object habilitado             = conection.executeScalarFunction("rolEstaHabilitado", this.rol);

            if (habilitado.ToString() == "1")
            {
                this.btn_habilitar.Visible = true;
            }
            else
            {
                this.btn_inhabilitar.Visible = true;
            }
        }
コード例 #17
0
ファイル: Form1.cs プロジェクト: AxelFulop/TpGDD20192C
        private void button2_Click(object sender, EventArgs e)
        {
            if (cuit.Text == "" || razonSocial.Text == "")
            {
                MessageBox.Show("Complete todos los campos");
                return;
            }

            if (fechaInicio.Value.CompareTo(FechaFin.Value) > 0)
            {
                MessageBox.Show("La fecha final no puede ser menor a la inicial");
                return;
            }

            string idProv = new ConexionBD.Conexion().
                            executeScalarFunction("obtenerIdProveedorPorCuitYRs", cuit.Text, razonSocial.Text).ToString();

            if (idProv == "")
            {
                MessageBox.Show("Proveedor inexistente");
                return;
            }

            string query = "SELECT c.compra_fecha, cli.cliente_numero_dni," +
                           "lower(concat(cli.cliente_nombre, ' ', cli.cliente_apellido)) as nom_y_apellido_cliente," +
                           "o.oferta_codigo, o.oferta_descripcion, o.oferta_precio " +
                           "FROM " + Properties.Settings.Default.Schema + ".Compra c " +
                           "inner join " + Properties.Settings.Default.Schema + ".Cliente cli on cli.cliente_id = c.cliente_id " +
                           "inner join " + Properties.Settings.Default.Schema + ".Oferta o on o.oferta_id = c.oferta_id " +
                           "where o.proveedor_id = " + idProv + " AND compra_facturada = '0' " +
                           "AND c.compra_fecha BETWEEN '" + fechaInicio.Value.ToShortDateString() + "' AND '" +
                           FechaFin.Value.ToShortDateString() + "'";


            ConexionBD.Conexion conection = new ConexionBD.Conexion().getInstance();
            cupones         = conection.selectReturnMultiplyRowsByQuery(query);
            grid.DataSource = cupones;

            if (cupones.Rows.Count <= 0)
            {
                MessageBox.Show("No hay ofertas compradas para ese proveedor en ese intervalo");
                facturarBtn.Enabled = false;
                return;
            }
            else
            {
                cantComprasMsg.Text = cupones.Rows.Count + tailMsgCantidad;
                facturarBtn.Enabled = true;
            }
        }
コード例 #18
0
ファイル: Editar.cs プロジェクト: AxelFulop/TpGDD20192C
        private void cargarRol(string rol)
        {
            this.nombreRol.Text = rol;

            string query = "select f.funcionalidad_descripcion from " + Properties.Settings.Default.Schema + ".Rol r " +
                           "inner join " + Properties.Settings.Default.Schema + ".FuncionalidadXRol fxr on fxr.rol_id = r.rol_id " +
                           "inner join " + Properties.Settings.Default.Schema + ".Funcionalidad f on f.funcionalidad_id = fxr.funcionalidad_id " +
                           "where r.rol_nombre = '" + rol + "'";

            ConexionBD.Conexion conection       = new ConexionBD.Conexion().getInstance();
            List <Object>       funcionalidades = conection.executeAdvancedSelectQuery(query);

            mostrarFuncionalidades(funcionalidades);
        }
コード例 #19
0
ファイル: AbmProveedor.cs プロジェクト: AxelFulop/TpGDD20192C
        private void cargarProveedores()
        {
            string listaRazonSocial = obtenerListaBorradosQueryRazonSocial();
            string listaCuit        = obtenerListaBorradosQueryCuit();

            string query = "SELECT proveedor_id, proveedor_razon_social, proveedor_email, proveedor_telefono, proveedor_direccion," +
                           "proveedor_direccion_piso,proveedor_direccion_depto,proveedor_direccion_localidad," +
                           "proveedor_codigo_postal,proveedor_cuit, proveedor_rubro, proveedor_contacto, proveedor_ciudad" +
                           " FROM " + Properties.Settings.Default.Schema + ".Proveedor";

            if (listaRazonSocial != "()" || listaCuit != "()")
            {
                query += " WHERE ";
                if (listaRazonSocial != "()")
                {
                    query += "proveedor_razon_social NOT IN " + listaRazonSocial;
                    if (listaCuit != "()")
                    {
                        query += " AND proveedor_cuit NOT IN " + listaCuit;
                    }
                }
                else
                {
                    if (listaCuit != "()")
                    {
                        query += "proveedor_cuit NOT IN " + listaCuit;
                    }
                }
            }

            ConexionBD.Conexion conection = new ConexionBD.Conexion().getInstance();
            proveedores     = conection.selectReturnMultiplyRowsByQuery(query);
            grid.DataSource = proveedores;

            DataGridViewButtonColumn colEditar = new DataGridViewButtonColumn();

            colEditar.UseColumnTextForButtonValue = true;
            colEditar.Text = "Editar";
            colEditar.Name = "";
            grid.Columns.Add(colEditar);

            DataGridViewButtonColumn colEliminar = new DataGridViewButtonColumn();

            colEliminar.UseColumnTextForButtonValue = true;
            colEliminar.Text = "Eliminar";
            colEliminar.Name = "";
            grid.Columns.Add(colEliminar);
        }
コード例 #20
0
        private Tuple <string, List <string>, object[]> altaCompra()
        {
            string idCliente = new ConexionBD.Conexion().
                               executeScalarFunction("obtenerIdCliente", user_cliente.Text).ToString();

            return(new Tuple <string, List <string>, Object[]>(
                       Properties.Settings.Default.Schema + ".altaCompra",
                       new List <String>()
            {
                "@nombreUsuario", "@id_cliente", "@codigo_oferta", "@fecha"
            },
                       new Object[] {
                user_cliente.Text, int.Parse(idCliente), datos["codigo"],
                Properties.Settings.Default.fecha.ToShortDateString()
            }
                       ));
        }
コード例 #21
0
        private void cargarOfertas()
        {
            string query = "SELECT oferta_codigo,oferta_descripcion,oferta_fecha_publicacion,oferta_fecha_vencimiento,oferta_limite_compra,oferta_stock_disponible,oferta_precio "
                           + "FROM GESTION_DE_GATOS.Oferta WHERE '" + Properties.Settings.Default.fecha.ToShortDateString() +
                           "' BETWEEN oferta_fecha_publicacion and oferta_fecha_vencimiento AND oferta_stock_disponible > 0";

            ConexionBD.Conexion conection = new ConexionBD.Conexion().getInstance();
            ofertas         = conection.selectReturnMultiplyRowsByQuery(query);
            grid.DataSource = ofertas;

            DataGridViewButtonColumn colEditar = new DataGridViewButtonColumn();

            colEditar.UseColumnTextForButtonValue = true;
            colEditar.Text = "Comprar";
            colEditar.Name = "";
            grid.Columns.Add(colEditar);
        }
コード例 #22
0
ファイル: consumoCupon.cs プロジェクト: AxelFulop/TpGDD20192C
        private void verCuponesBtn_Click(object sender, EventArgs e)
        {
            try
            {
                string idProv = new ConexionBD.Conexion().
                                executeScalarFunction("obtenerIdProveedorPorCuitYRs", cuit.Text, razonSocial.Text).ToString();

                if (idProv == DBNull.Value.ToString())
                {
                    MessageBox.Show("Proveedor inexistente");
                    return;
                }

                string query = "SELECT c.cupon_id,c.cupon_precio,c.cupon_fecha_vencimiento,cp.compra_fecha,cli.cliente_numero_dni" +
                               ",lower(concat(cli.cliente_nombre, ' ', cli.cliente_apellido)) as nom_y_apellido_cliente" +
                               ",o.oferta_codigo,o.oferta_descripcion FROM GESTION_DE_GATOS.Cupon c " +
                               "inner join GESTION_DE_GATOS.Oferta o on o.oferta_id = c.oferta_id " +
                               "inner join GESTION_DE_GATOS.Compra cp on c.compra_id = cp.compra_id " +
                               "inner join GESTION_DE_GATOS.Cliente cli on cli.cliente_id = cp.cliente_id " +
                               "where c.cupon_canjeado = '0' AND o.proveedor_id = " + idProv;

                ConexionBD.Conexion conection = new ConexionBD.Conexion().getInstance();
                cupones         = conection.selectReturnMultiplyRowsByQuery(query);
                grid.DataSource = cupones;

                if (grid.ColumnCount == 8)
                {
                    DataGridViewButtonColumn colEditar = new DataGridViewButtonColumn();
                    colEditar.UseColumnTextForButtonValue = true;
                    colEditar.Text = "Notificar consumición";
                    colEditar.Name = "";
                    grid.Columns.Add(colEditar);
                }

                if (cupones.Rows.Count == 0)
                {
                    MessageBox.Show("No hay cupones que mostrar");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Error al cargar cupones");
            }
        }
コード例 #23
0
ファイル: Form1.cs プロジェクト: AxelFulop/TpGDD20192C
        private void facturarBtn_Click(object sender, EventArgs e)
        {
            string idProv = new ConexionBD.Conexion().
                            executeScalarFunction("obtenerIdProveedorPorCuitYRs", cuit.Text, razonSocial.Text).ToString();

            string query = "SELECT sum(o.oferta_precio) FROM " + Properties.Settings.Default.Schema + ".Compra c " +
                           "inner join " + Properties.Settings.Default.Schema + ".Oferta o on o.oferta_id = c.oferta_id " +
                           "where c.compra_facturada = '0' AND o.proveedor_id = " + idProv +
                           " AND c.compra_fecha BETWEEN '" + fechaInicio.Value.ToShortDateString() +
                           "' AND '" + FechaFin.Value.ToShortDateString() + "'";

            ConexionBD.Conexion conection = new ConexionBD.Conexion().getInstance();
            Object sumaFacturacion        = conection.selectReturnOnlyObject(query);

            DialogResult result = MessageBox.Show("¿Desea facturar al proveedor?\nTotal a facturar: $ " + sumaFacturacion.ToString(),
                                                  "Facturación",
                                                  MessageBoxButtons.YesNo,
                                                  MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                try
                {
                    new ConexionBD.Conexion().getInstance().executeProcedure(Properties.Settings.Default.Schema + ".facturarProveedor",
                                                                             new List <string>()
                    {
                        "@id_proveedor", "@fecha_inicio", "@fecha_fin", "@monto"
                    },
                                                                             new Object[] {
                        int.Parse(idProv), fechaInicio.Value, FechaFin.Value,
                        sumaFacturacion
                    }
                                                                             );

                    MessageBox.Show("Facturación completa");
                    this.Hide();
                    new MenuPrincipal().Show();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error al realizar la facturación. \n" + ex.Message);
                }
            }
        }
コード例 #24
0
ファイル: AbmProveedor.cs プロジェクト: AxelFulop/TpGDD20192C
        private void button1_Click(object sender, EventArgs e)
        {
            string razonSocial = this.razonSocial.Text;
            string cuit        = this.cuit.Text;
            string mail        = this.mail.Text;

            string listaRazonSocial = obtenerListaBorradosQueryRazonSocial();
            string listaCuit        = obtenerListaBorradosQueryCuit();

            string query = "SELECT proveedor_id, proveedor_razon_social, proveedor_email, proveedor_telefono, proveedor_direccion,proveedor_direccion_piso,proveedor_direccion_depto,proveedor_direccion_localidad, proveedor_codigo_postal, " +
                           "proveedor_cuit, proveedor_rubro, proveedor_contacto, proveedor_ciudad" +
                           " FROM " + Properties.Settings.Default.Schema + ".Proveedor WHERE " +
                           "isnull(proveedor_email, '') LIKE '%" + mail + "%' AND proveedor_razon_social LIKE '%" + razonSocial + "%'";

            if (cuit != "")
            {
                query += " AND proveedor_cuit='" + cuit + "'";
            }

            if (listaRazonSocial != "()" || listaCuit != "()")
            {
                if (listaRazonSocial != "()")
                {
                    query += " AND proveedor_razon_social NOT IN " + listaRazonSocial;
                    if (listaCuit != "()")
                    {
                        query += " AND proveedor_cuit NOT IN " + listaCuit;
                    }
                }
                else
                {
                    if (listaCuit != "()")
                    {
                        query += " AND proveedor_cuit NOT IN " + listaCuit;
                    }
                }
            }

            ConexionBD.Conexion conection = new ConexionBD.Conexion().getInstance();
            proveedores     = conection.selectReturnMultiplyRowsByQuery(query);
            grid.DataSource = proveedores;
        }
コード例 #25
0
        private void boxCompraOferta_Load(object sender, EventArgs e)
        {
            Object ret = new ConexionBD.Conexion().executeScalarFunction("obtenerIdCliente", Logeo.username);

            if (ret == DBNull.Value) // Entra alguien que no es cliente
            {
                comprarBtn.Enabled = false;
            }
            else
            {
                verTarjetasBtn.Visible = false;
                user_cliente.Text      = Logeo.username;
                user_cliente.Enabled   = false;
                string query = "SELECT tarjeta_numero FROM GESTION_DE_GATOS.Tarjeta t " +
                               "JOIN GESTION_DE_GATOS.Cliente c on t.cliente_id = c.cliente_id " +
                               "JOIN GESTION_DE_GATOS.Usuario u on u.usuario_id = c.usuario_id " +
                               "WHERE u.usuario_nombre = " + "'" + Logeo.username + "'";
                comboBoxTarjeta = new ConexionBD.Conexion().populateComboBox(comboBoxTarjeta, query);

                if (comboBoxTarjeta.Items.Count == 0)
                {
                    comboBoxTarjeta.Text = "Sin tarjetas registradas";
                    comprarBtn.Enabled   = false;
                }
            }

            o_codigo.Text      = datos["codigo"];
            o_descripcion.Text = datos["descripcion"];
            o_precio.Text      = datos["precio"];

            decimal limiteCompra    = decimal.Parse(datos["limiteCompra"]);
            decimal stockDisponible = decimal.Parse(datos["stock"]);

            if (stockDisponible >= limiteCompra)
            {
                maxCantidad = limiteCompra;
            }
            else
            {
                maxCantidad = stockDisponible;
            }
        }
コード例 #26
0
ファイル: consumoCupon.cs プロジェクト: AxelFulop/TpGDD20192C
        private void button3_Click(object sender, EventArgs e)
        {
            filtroDescripcion.Text = "";

            string idProv = new ConexionBD.Conexion().
                            executeScalarFunction("obtenerIdProveedor", Logeo.username).ToString();

            string query = "SELECT c.cupon_id,c.cupon_precio,c.cupon_fecha_vencimiento,cp.compra_fecha,cli.cliente_numero_dni" +
                           ",lower(concat(cli.cliente_nombre, ' ', cli.cliente_apellido)) as nom_y_apellido_cliente" +
                           ",o.oferta_codigo,o.oferta_descripcion FROM GESTION_DE_GATOS.Cupon c " +
                           "inner join GESTION_DE_GATOS.Oferta o on o.oferta_id = c.oferta_id " +
                           "inner join GESTION_DE_GATOS.Compra cp on c.compra_id = cp.compra_id " +
                           "inner join GESTION_DE_GATOS.Cliente cli on cli.cliente_id = cp.cliente_id " +
                           "where c.cupon_canjeado = '0' AND o.proveedor_id = " + idProv;


            ConexionBD.Conexion conection = new ConexionBD.Conexion().getInstance();
            cupones         = conection.selectReturnMultiplyRowsByQuery(query);
            grid.DataSource = cupones;
        }
コード例 #27
0
ファイル: Nuevo.cs プロジェクト: AxelFulop/TpGDD20192C
        private bool ejecutarTransaccion()
        {
            ConexionBD.Conexion conection = new ConexionBD.Conexion().getInstance();

            Tuple <string, List <string>, Object[]> procAltaRol = obtenerProcAltaRol();

            Tuple <string, List <string>, Object[]>[] procFuncs = obtenerProcAgregarFuncionalidades();
            procFuncs[0] = procAltaRol;

            try
            {
                conection.executeStoredTransaction(procFuncs);
            }
            catch (System.Data.SqlClient.SqlException)
            {
                return(false);
            }

            return(true);
        }
コード例 #28
0
ファイル: Editar.cs プロジェクト: AxelFulop/TpGDD20192C
        private void eliminarFuncionalidad(string funcionalidad)
        {
            try
            {
                ConexionBD.Conexion conection = new ConexionBD.Conexion().getInstance();
                conection.executeProcedure(Properties.Settings.Default.Schema + ".eliminarFuncionalidadARol",
                                           new List <String>()
                {
                    "@nombreRol", "@descripcionFuncionalidad"
                },
                                           new String[2] {
                    this.rol, funcionalidad
                });

                MessageBox.Show("Funcionalidad " + funcionalidad + " eliminada correctamente para '" + this.rol + "'");
            }
            catch (Exception)
            {
                MessageBox.Show("Error al eliminar la funcionalidad " + funcionalidad);
            }
        }
コード例 #29
0
ファイル: Editar.cs プロジェクト: AxelFulop/TpGDD20192C
        private bool agregarFuncionalidad(string func)
        {
            try
            {
                ConexionBD.Conexion conection = new ConexionBD.Conexion().getInstance();
                conection.executeProcedure(Properties.Settings.Default.Schema + ".agregarFuncionalidadARol",
                                           new List <String>()
                {
                    "@nombreRol", "@descripcionFuncionalidad"
                },
                                           new String[2] {
                    this.rol, func
                });

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
コード例 #30
0
        private void button2_Click(object sender, EventArgs e)
        {
            vacioMsg.Visible = false;
            string fechaInicio, fechaFin;

            if (semestre.SelectedItem == "Primero")
            {
                fechaInicio = new DateTime(int.Parse(year.Value.ToString()), 1, 1).ToShortDateString();
                fechaFin    = new DateTime(int.Parse(year.Value.ToString()), 7, 1).ToShortDateString();
            }
            else if (semestre.SelectedItem == "Segundo")
            {
                fechaInicio = new DateTime(int.Parse(year.Value.ToString()), 7, 1).ToShortDateString();
                fechaFin    = new DateTime(int.Parse((year.Value + 1).ToString()), 1, 1).ToShortDateString();
            }
            else
            {
                MessageBox.Show("Semestre inválido");
                return;
            }

            string query = "SELECT top 5 p.proveedor_id,p.proveedor_cuit, p.proveedor_razon_social," +
                           "avg(100-o.oferta_precio*100/o.oferta_precio_lista) as Porcentaje_Descuento_Promedio," +
                           "count(o.oferta_codigo) as Cantidad_ofertas " +
                           "FROM " + Properties.Settings.Default.Schema + ".Proveedor p " +
                           "inner join " + Properties.Settings.Default.Schema + ".Oferta o on p.proveedor_id = o.proveedor_id " +
                           "where (o.oferta_fecha_publicacion between '" + fechaInicio + "' and '" +
                           fechaFin + "') " +
                           "group by p.proveedor_id,p.proveedor_cuit, p.proveedor_razon_social " +
                           "order by Porcentaje_Descuento_Promedio desc";

            ConexionBD.Conexion conection = new ConexionBD.Conexion().getInstance();
            proveedores     = conection.selectReturnMultiplyRowsByQuery(query);
            grid.DataSource = proveedores;

            if (proveedores.Rows.Count == 0)
            {
                vacioMsg.Visible = true;
            }
        }