Пример #1
0
        public int insertarEspectaculo(Espectaculo espec, SqlTransaction trans)
        {
            string query = "[TheBigBangQuery].[InsertarEspectaculo]";

            try
            {
                SqlCommand command = new SqlCommand(query);

                command.CommandType = System.Data.CommandType.StoredProcedure;
                command.CommandText = query;
                command.Transaction = trans;

                SqlParameter outId = new SqlParameter("@newId", SqlDbType.Decimal)
                {
                    Direction = ParameterDirection.Output
                };

                command.Parameters.AddWithValue("@empresa", espec.empresa == null ?  "0" : espec.empresa.id.ToString());
                command.Parameters.AddWithValue("@rubro", espec.rubro.id);
                command.Parameters.AddWithValue("@descripcion", espec.descripcion);
                command.Parameters.AddWithValue("@direccion", espec.direccion);
                command.Parameters.Add(outId);


                DatabaseConection.executeNoParamFunction(command);

                var returnV = outId.Value;

                return(int.Parse(returnV.ToString()));
            }
            catch (Exception e) {
                return(-1);
            }
        }
Пример #2
0
        public void insertGradoDePublicacion(GradoPublicacion grado)
        {
            string query = "INSERT INTO [TheBigBangQuery].[GradoPublicaciones](grad_nivel,grad_comision) " +
                           "VALUES (@descripcion, @comision)";
            SqlCommand command = new SqlCommand(query);

            SqlParameter descParam = new SqlParameter("@descripcion", System.Data.SqlDbType.NVarChar);

            descParam.Value = grado.nivel;

            SqlParameter comsionParam = new SqlParameter("@comision", System.Data.SqlDbType.Decimal);

            comsionParam.Value = (decimal)grado.comision;

            command.Parameters.Add(descParam);
            command.Parameters.Add(comsionParam);

            try
            {
                DatabaseConection.executeNoParamFunction(command);
            }
            catch (Exception e) {
                Console.Write(e.Message);
            }
        }
Пример #3
0
        public void insertarFactura(SqlTransaction transaction, string tipoPago, Compra compra, Action <int> resNuevoId)
        {
            string procedure = "[TheBigBangQuery].[insertarNuevaFactura]";

            try {
                SqlCommand command = new SqlCommand(procedure);
                command.Transaction = transaction;
                command.CommandType = CommandType.StoredProcedure;
                command.CommandType = CommandType.StoredProcedure;

                command.Parameters.AddWithValue("@idCompra", compra.id);
                command.Parameters.AddWithValue("@tipoPago", tipoPago);
                command.Parameters.AddWithValue("@fecha", Generals.getFecha());
                command.Parameters.AddWithValue("@idEmpresa", compra.publicacion.espectaculo.empresa.id);
                SqlParameter param = new SqlParameter("@numeroFactura", SqlDbType.Decimal)
                {
                    Direction = ParameterDirection.Output
                };
                command.Parameters.Add(param);

                DatabaseConection.executeNoParamFunction(command);
                var newId = param.Value;
                int newIdInt;
                if (int.TryParse(newId.ToString(), out newIdInt))
                {
                    resNuevoId(newIdInt);
                }
            }
            catch (Exception ex) {
                throw new SqlInsertException("Error al realizar la rendicion de comisiones", 0);
            }
        }
Пример #4
0
        public int insertarUbicacion(Ubicacion ubic, SqlTransaction transaction)
        {
            string procedure = "[TheBigBangQuery].[InsertarUbicacion]";

            try
            {
                SqlCommand command = new SqlCommand();

                command.Transaction = transaction != null ? transaction : null;
                command.CommandText = procedure;
                command.CommandType = CommandType.StoredProcedure;

                command.Parameters.AddWithValue("@fila", ubic.fila);
                command.Parameters.AddWithValue("@asiento", ubic.asiento.ToString());
                command.Parameters.AddWithValue("@sinEnumerar", ubic.sinEnumerar.ToString());
                command.Parameters.AddWithValue("@tipoUbi", ubic.tipoUbicaciones.id.ToString());

                SqlParameter outId = new SqlParameter("@newId", SqlDbType.Decimal)
                {
                    Direction = ParameterDirection.Output
                };
                command.Parameters.Add(outId);

                DatabaseConection.executeNoParamFunction(command);


                return(int.Parse(outId.Value.ToString()));
            }
            catch (Exception ex) {
                throw new SqlInsertException("Error al insertar ubicaciones", SqlInsertException.CODIGO_UBICACION);
            }
        }
Пример #5
0
        public void actualizarCliente(Cliente cliente)
        {
            string query = "EXEC [TheBigBangQuery].[ActualizarCliente] " +
                           "@id = '" + cliente.id.ToString().Trim() + "', " +
                           "@nombre = '" + cliente.nombre.Trim() + "', " +
                           "@apellido = '" + cliente.apellido.Trim() + "'," +
                           "@tipoDocumento = '" + cliente.TipoDocumento.Trim() + "', " +
                           "@numeroDocumento = '" + cliente.documento.Trim() + "', " +
                           "@cuil = '" + cliente.cuil.Trim() + "', " +
                           "@mail = '" + cliente.mail.Trim() + "', " +
                           "@telefono = '" + cliente.telefono.Trim() + "'," +
                           "@calle = '" + cliente.direccion.calle.Trim() + "', " +
                           "@altura = '" + cliente.direccion.numero.Trim() + "'," +
                           "@piso = '" + cliente.direccion.piso.Trim() + "'," +
                           "@depto = '" + cliente.direccion.depto.Trim() + "'," +
                           "@localidad = '" + cliente.direccion.localidad.Trim() + "'," +
                           "@codigoPostal = '" + cliente.direccion.codigoPostal.Trim() + "'," +
                           "@fechaDeNacimiento = '" + ((DateTime)cliente.fechaNacimiento).ToString("yyyy-dd-MM").Trim() + "'," +
                           "@fechaCreacion = '" + ((DateTime)cliente.fechaCreacion).ToString("yyyy-dd-MM").Trim() + "'";

            try
            {
                DatabaseConection.executeNoParamFunction(query);
            }
            catch (SqlException ex)
            {
                MessageBoxButtons alert = MessageBoxButtons.OK;
                MessageBox.Show(ex.Message, "ERROR", alert);
            }
        }
        public int insertarUbicacionPorPublicacion(Ubicacion ubi, Publicacion pub, SqlTransaction transaction)
        {
            // REVISAR PORQ NO INSERTA LAS UBICACIONES DE LA PUBLICACION QUE LE ESTOY PASANDO
            string procedure = "[TheBigBangQuery].[InsertarUbicacionPorPublicacion]";

            try
            {
                SqlCommand command = new SqlCommand();

                command.CommandText = procedure;
                command.CommandType = CommandType.StoredProcedure;
                command.Transaction = transaction;

                command.Parameters.AddWithValue("@ubicacion", ubi.id.ToString());
                command.Parameters.AddWithValue("@publicacion", pub.id.ToString());
                command.Parameters.AddWithValue("@precio", ubi.precio.ToString());
                // POR DEFAULT TODAS LAS UBICACIONES ESTAN DISPONIBLES
                command.Parameters.AddWithValue("@disponible", "0");

                DatabaseConection.executeNoParamFunction(command);
            }
            catch (Exception ex) {
                return(-1);
            }

            return(1);
        }
Пример #7
0
        public void insertarEmpresaConUsuario(Empresa empresa, String usuario, String contraseña)
        {
            string query = "EXEC [TheBigBangQuery].[InsertarEmpresaConUsuario]" +
                           "@usuario = '" + usuario + "'," +
                           "@contraseña = '" + contraseña + "'," +
                           "@razonSocial = '" + empresa.razonSocial + "'," +
                           "@cuit = '" + empresa.cuit + "'," +
                           "@mail = '" + empresa.mailEmpresa + "'," +
                           "@telefono = '" + empresa.telefonoEmpresa + "'," +
                           "@calle = '" + empresa.direccion.calle + "'," +
                           "@altura = '" + empresa.direccion.numero + "'," +
                           "@piso = '" + empresa.direccion.piso + "'," +
                           "@depto = '" + empresa.direccion.depto + "'," +
                           "@localidad = '" + empresa.direccion.localidad + "'," +
                           "@codigoPostal = '" + empresa.direccion.codigoPostal + "'," +
                           "@ciudad = '" + empresa.direccion.ciudad + "'," +
                           "@fechaCreacion = '" + Generals.getFecha() + "'";

            try
            {
                DatabaseConection.executeNoParamFunction(query);
            }
            catch (SqlException e) {
                throw e;
            }
        }
Пример #8
0
        public void incrementarContadorDeIntentos(string usuario)
        {
            string     query   = "EXEC [TheBigBangQuery].IncrementarIntento @usuario = @usuarioC";
            SqlCommand command = new SqlCommand(query);

            command.Parameters.AddWithValue("@usuarioC", usuario);
            DatabaseConection.executeNoParamFunction(command);
        }
Пример #9
0
        public void resetearIntentos(Usuario usuario)
        {
            string query = "UPDATE [TheBigBangQuery].[Usuario] " +
                           "SET usua_n_intentos = 0 " +
                           "WHERE usua_id = @idUsuario";
            SqlCommand command = new SqlCommand(query);

            command.Parameters.AddWithValue("@idUsuario", usuario.id);
            DatabaseConection.executeNoParamFunction(command);
        }
Пример #10
0
        public void habilitarODesabilitarCliente(Cliente cliente)
        {
            string query = "UPDATE [TheBigBangQuery].[Cliente] " +
                           "SET clie_dado_baja = " + (cliente.bajaLogica != null ? "NULL" : "GETDATE()") +
                           " WHERE clie_id = '" + cliente.id + "'";

            SqlCommand command = new SqlCommand(query);

            DatabaseConection.executeNoParamFunction(command);
        }
Пример #11
0
        public void actualizarGradoDePublicacion(GradoPublicacion grado)
        {
            string query = "UPDATE [TheBigBangQuery].[GradoPublicaciones] " +
                           "SET [grad_nivel] = '" + grado.nivel +
                           "', [grad_comision] = " + grado.comision.ToString() +
                           " WHERE [grad_id] = " + grado.id;
            SqlCommand command = new SqlCommand(query);

            try
            {
                DatabaseConection.executeNoParamFunction(command);
            }
            catch (Exception e) { }
        }
Пример #12
0
        public void habilitarODesahabilitarEmpresa(Empresa empresa)
        {
            string query = "UPDATE TheBigBangQuery.Empresa " +
                           "SET empr_dado_baja = " +
                           (empresa.bajaLogica != null ? "'" + Generals.getFecha().ToString("yyyy-dd-MM") + "'" : "NULL") +
                           " WHERE empr_id = 1";

            try
            {
                DatabaseConection.executeNoParamFunction(query);
            }
            catch (SqlException ex) {
                throw ex;
            }
        }
Пример #13
0
        public void insertarCliente(Cliente cliente, string contraseña)
        {
            string        query  = "[TheBigBangQuery].[InsertarNuevoClienteConUsuario]";
            SqlDataReader reader = null;

            try
            {
                SqlCommand command = new SqlCommand(query);
                command.CommandText = query;
                command.CommandType = CommandType.StoredProcedure;

                command.Parameters.AddWithValue("@usuario", cliente.usuario.Trim());
                command.Parameters.AddWithValue("@contraseña", contraseña.Trim());
                command.Parameters.AddWithValue("@nombre", cliente.nombre.Trim());
                command.Parameters.AddWithValue("@apellido", cliente.apellido);
                command.Parameters.AddWithValue("@tipoDoc", cliente.TipoDocumento.Trim());
                command.Parameters.AddWithValue("@documento", cliente.documento.Trim());
                command.Parameters.AddWithValue("@cuil", cliente.cuil.Trim());
                command.Parameters.AddWithValue("@mail", cliente.mail.Trim());
                command.Parameters.AddWithValue("@telefono", cliente.telefono.Trim());
                command.Parameters.AddWithValue("@calle", cliente.direccion.calle.Trim());
                command.Parameters.AddWithValue("@altura", cliente.direccion.numero.Trim());
                command.Parameters.AddWithValue("@piso", cliente.direccion.piso.Trim());
                command.Parameters.AddWithValue("@depto", cliente.direccion.depto.Trim());
                command.Parameters.AddWithValue("@localidad", cliente.direccion.localidad.Trim());
                command.Parameters.AddWithValue("@codigoPostal", cliente.direccion.codigoPostal.Trim());
                command.Parameters.AddWithValue("@fechaNacimiento", ((DateTime)cliente.fechaNacimiento));
                command.Parameters.AddWithValue("@fechaCreacion", ((DateTime)cliente.fechaCreacion));

                DatabaseConection.executeNoParamFunction(command);
            }
            catch (SqlException e) {
                if (e.Message.Contains("dni"))
                {
                    throw new SqlInsertException("Ya existe un usuario con el dni ingresado", 0);
                }
                else
                {
                    throw new SqlInsertException("Ya existe un usuario con el cuir ingresado", 0);
                }
            }
            catch (Exception e)
            {
                throw new SqlInsertException("No se ha podido procesar el alta del cliente", 0);
            }
        }
Пример #14
0
        public void canjearPuntos(int clieId, int puntosARestar)
        {
            string query = "[TheBigBangQuery].[canjearPuntos]";

            try
            {
                SqlCommand command = new SqlCommand(query);
                command.CommandText = query;
                command.CommandType = CommandType.StoredProcedure;

                command.Parameters.AddWithValue("@puntosCanjeados", puntosARestar);
                command.Parameters.AddWithValue("@idCliente", clieId);

                DatabaseConection.executeNoParamFunction(command);
            }
            catch (Exception e) {
                throw new SqlInsertException("Error al actualizar los puntos del usuario", 0);
            }
        }
Пример #15
0
        public void insertarTarjetaDeCliente(Tarjeta tarj, int clieID)
        {
            string query = "INSERT INTO [TheBigBangQuery].[Tarjetas] (tarj_cliente, tarj_titular, tarj_numero, tarj_caducidad, tarj_cvv) " +
                           "VALUES (@cli, @titular, @numero, @vencimiento, @cvv)";

            try {
                SqlCommand command = new SqlCommand(query);
                command.Parameters.AddWithValue("@cli", clieID);
                command.Parameters.AddWithValue("@titular", tarj.titular);
                command.Parameters.AddWithValue("@numero", tarj.numero);
                command.Parameters.AddWithValue("@vencimiento", tarj.vencimiento);
                command.Parameters.AddWithValue("@cvv", tarj.vcc);

                DatabaseConection.executeNoParamFunction(command);
            }
            catch (Exception e) {
                throw new SqlInsertException("Error al insertar tarjeta de credito", 0);
            }
        }
Пример #16
0
        public void habilitarDeshabilitarUsuario(int userId, bool isHabilitado)
        {
            string query = "UPDATE [TheBigBangQuery].[Usuario] " +
                           "SET usua_habilitado = @habilitado, usua_n_intentos = 0" +
                           "WHERE usua_id = @userId";

            try
            {
                SqlCommand command = new SqlCommand(query);
                command.CommandText = query;

                command.Parameters.AddWithValue("@habilitado", isHabilitado ? 0 : 1);
                command.Parameters.AddWithValue("@userId", userId);

                DatabaseConection.executeNoParamFunction(command);
            }
            catch (Exception e) {
                throw new SqlInsertException("Error al modificar estado del usuario", 0);
            }
        }
Пример #17
0
        public void insertarNuevoPremio(Premio premio)
        {
            string procedure = "[TheBigBangQuery].[insertarNuevoPremio] @puntos, @nombre, @vencimiento";

            try
            {
                SqlCommand command = new SqlCommand(procedure);
                command.CommandText = procedure;
                command.CommandType = CommandType.StoredProcedure;

                command.Parameters.AddWithValue("@puntos", premio.puntosNecesarios);
                command.Parameters.AddWithValue("@nombre", premio.nombre);
                command.Parameters.AddWithValue("@vencimiento", premio.fechaVencimiento);

                DatabaseConection.executeNoParamFunction(command);
            }
            catch (Exception ex) {
                throw new SqlInsertException("Error al insertar el premio", 0);
            }
        }
Пример #18
0
        public void actualizarContraseñaDelUsuario(string passAnterior, string nuevaPsw, int userId)
        {
            string query = "[TheBigBangQuery].[actualizarContraseñaUsuario]";

            try
            {
                SqlCommand command = new SqlCommand(query);
                command.CommandType = CommandType.StoredProcedure;

                command.Parameters.AddWithValue("@pswAnterior", passAnterior);
                command.Parameters.AddWithValue("@nuevaPsw", nuevaPsw);
                command.Parameters.AddWithValue("@userId", userId);

                DatabaseConection.executeNoParamFunction(command);
            }
            catch (SqlException e) {
                throw new DataNotFoundException(e.Message);
            }
            catch (Exception e) {}
        }
Пример #19
0
        public void actualizarPuntosPorCompra(Compra compra, SqlTransaction trans)
        {
            string procedure = "[TheBigBangQuery].[ActualizarPuntosDelCliente]";

            try
            {
                SqlCommand command = new SqlCommand(procedure);
                command.CommandText = procedure;
                command.Transaction = trans;
                command.CommandType = CommandType.StoredProcedure;

                command.Parameters.AddWithValue("@idCliente", compra.cli.id);
                command.Parameters.AddWithValue("@montoCompra", compra.total);
                command.Parameters.AddWithValue("@fechaCompra", compra.fechaCompra);

                DatabaseConection.executeNoParamFunction(command);
            }
            catch (Exception e) {
                throw new SqlInsertException("No se han podido actualizar los puntos del cliente", 0);
            }
        }
Пример #20
0
        public void insertarCompra(Compra compra, Publicacion publi, SqlTransaction transaction)
        {
            string procedure = "[TheBigBangQuery].[InsertarCompra]";

            DataTable table = new DataTable();

            table.Columns.Add("ubli_ubicacion", typeof(decimal));
            compra.ubicaciones.ForEach(elem => {
                table.Rows.Add(elem.id);
            });



            try
            {
                SqlCommand com = new SqlCommand(procedure);
                com.CommandText = procedure;
                com.CommandType = CommandType.StoredProcedure;
                com.Transaction = transaction;

                com.Parameters.AddWithValue("@publicacion", publi.id);
                com.Parameters.AddWithValue("@cliente", compra.cli.id);
                com.Parameters.AddWithValue("@fechaCompra", compra.fechaCompra);
                com.Parameters.AddWithValue("@medioPago", compra.medioPago.ToString());
                com.Parameters.AddWithValue("@cantidad", compra.cantidad.ToString());
                com.Parameters.AddWithValue("@total", compra.total);

                SqlParameter param = new SqlParameter("@ubicaciones", SqlDbType.Structured);
                param.TypeName = "[TheBigBangQuery].[UbicacionesList]";
                param.Value    = table;

                com.Parameters.Add(param);

                DatabaseConection.executeNoParamFunction(com);
            }
            catch (Exception e) {
                throw new SqlInsertException("Error al insertar la compra", 0);
            }
        }
Пример #21
0
        public void habilitarODeshabilitarGrado(GradoPublicacion grado)
        {
            string fecha = grado.bajaLogica == null ? "NULL" : "'" + ((DateTime)grado.bajaLogica).Date.ToString("yyyy-dd-MM") + "'";
            string query = "UPDATE [TheBigBangQuery].[GradoPublicaciones] " +
                           "SET [grad_baja] = " + fecha + " " +
                           "WHERE [grad_id] = @id";
            SqlCommand command = new SqlCommand(query);

            SqlParameter param = new SqlParameter("@id", System.Data.SqlDbType.Decimal);

            param.Value = grado.id;
            command.Parameters.Add(param);

            try
            {
                DatabaseConection.executeNoParamFunction(command);
            }
            catch (Exception e)
            {
                Console.Write(e.Message);
            }
        }
Пример #22
0
        public int insertarPublicacion(Publicacion publi, SqlTransaction transaction)
        {
            string query = "[TheBigBangQuery].[InsertarPublicacion]";

            try
            {
                SqlCommand command = new SqlCommand(query);

                command.CommandType = System.Data.CommandType.StoredProcedure;
                command.CommandText = query;
                command.Transaction = transaction;

                SqlParameter outId = new SqlParameter("@newId", SqlDbType.Decimal)
                {
                    Direction = ParameterDirection.Output
                };
                SqlParameter fechaPubParam = new SqlParameter("@fechaPublicacion", SqlDbType.DateTime)
                {
                    Value = publi.fechaPublicacion
                };
                SqlParameter fechaEveParam = new SqlParameter("@fechaEvento", SqlDbType.DateTime)
                {
                    Value = publi.fechaEvento
                };

                command.Parameters.AddWithValue("@idEspec", publi.espectaculo.id.ToString());
                command.Parameters.AddWithValue("@gradoPublicacion", publi.gradoPublicacion.id.ToString());
                command.Parameters.Add(fechaPubParam);
                command.Parameters.Add(fechaEveParam);
                command.Parameters.AddWithValue("@estado", publi.estado);
                command.Parameters.Add(outId);

                DatabaseConection.executeNoParamFunction(command);
                return(int.Parse(outId.Value.ToString()));
            }
            catch (Exception ex) {
                throw ex;
            }
        }
Пример #23
0
        public void actualizarRol(Rol rol)
        {
            string query = "UPDATE TheBigBangQuery.Rol " +
                           "SET rol_nombre= '" + rol.nombre + "', rol_dado_baja = " +
                           "CONVERT(datetime, '" + rol.bajaLogica.ToString("yyyy-MM-dd HH:mm:ss") + "',20) " +
                           "WHERE rol_cod = " + rol.id;

            if (rol.bajaLogica == Generals.getFechaMinima())
            {
                query = "UPDATE TheBigBangQuery.Rol " +
                        "SET rol_nombre= '" + rol.nombre + "', rol_dado_baja = NULL " +
                        "WHERE rol_cod = " + rol.id;
            }
            else
            {
                string     query2  = "DELETE FROM [TheBigBangQuery].[Roles_usuario] WHERE rolu_rol = @rolId";
                SqlCommand command = new SqlCommand(query2);

                command.Parameters.AddWithValue("@rolId", rol.id);
                DatabaseConection.executeNoParamFunction(command);
            }
            DatabaseConection.executeQuery(query).Close();
        }
Пример #24
0
        public void actualizarPublicacion(bool fechaActualizda, Publicacion publicacion, SqlTransaction transaction)
        {
            string procedure = "[TheBigBangQuery].[ActualizarPublicacion]";

            try
            {
                SqlCommand command = new SqlCommand(procedure);
                command.CommandText = procedure;
                command.Transaction = transaction;
                command.CommandType = CommandType.StoredProcedure;

                command.Parameters.AddWithValue("@publId", publicacion.id.ToString());
                command.Parameters.AddWithValue("@espeId", publicacion.espectaculo.id.ToString());
                command.Parameters.AddWithValue("@rubroEspe", publicacion.espectaculo.rubro.id.ToString());
                command.Parameters.AddWithValue("@descipcion", publicacion.espectaculo.descripcion.ToString());
                command.Parameters.AddWithValue("@direccion", publicacion.espectaculo.direccion.ToString());
                command.Parameters.AddWithValue("@idGradoPublicacion", publicacion.gradoPublicacion.id.ToString());
                command.Parameters.AddWithValue("@fechaPublicacion", publicacion.fechaPublicacion);
                command.Parameters.AddWithValue("@fechaEvento", publicacion.fechaEvento);

                command.Parameters.AddWithValue("@estado", publicacion.estado);
                command.Parameters.AddWithValue("@fechaActualizada", fechaActualizda ? 1 : 0);

                DatabaseConection.executeNoParamFunction(command);
            }
            catch (Exception e) {
                if (e.Message.Contains("Ya existe"))
                {
                    throw new SqlInsertException("No se puede actualizar la publicacion porque ya existe una del mismo espectaculo para la fecha seleccionada"
                                                 , SqlInsertException.CODIGO_PUBLICACION);
                }
                else
                {
                    throw new SqlInsertException("No se ha podido actualizar la publicacion.", SqlInsertException.CODIGO_PUBLICACION);
                }
            }
        }
Пример #25
0
        public void insertarItem(ItemFactura item, SqlTransaction trans)
        {
            string procedure = "[TheBigBangQuery].[InsertarItemFactura]";

            try
            {
                SqlCommand command = new SqlCommand(procedure);
                command.CommandText = procedure;
                command.CommandType = CommandType.StoredProcedure;
                command.Transaction = trans;

                command.Parameters.AddWithValue("@numFact", item.numFactura);
                command.Parameters.AddWithValue("@idUbi", item.ubicacion.id);
                command.Parameters.AddWithValue("@idPubli", item.publicacion.id);
                command.Parameters.AddWithValue("@monto", item.monto);
                command.Parameters.AddWithValue("@cantidad", item.cantidad);
                command.Parameters.AddWithValue("@desc", item.descripcion);

                DatabaseConection.executeNoParamFunction(command);
            }
            catch (Exception e) {
                throw new SqlInsertException("Error al insertar el item de factura", 0);
            }
        }
Пример #26
0
        public void removerRolesDelUsuario(List <Rol> roles, int userId)
        {
            string         query = "DELETE FROM [TheBigBangQuery].[Roles_usuario] WHERE rolu_rol = @rolId AND rolu_usuario = @userId";
            SqlTransaction trans = DatabaseConection.getInstance().BeginTransaction();

            try
            {
                roles.ForEach(elem =>
                {
                    SqlCommand command  = new SqlCommand(query);
                    command.CommandText = query;
                    command.Transaction = trans;
                    command.Parameters.AddWithValue("@userId", userId);
                    command.Parameters.AddWithValue("@rolId", elem.id);
                    DatabaseConection.executeNoParamFunction(command);
                });

                trans.Commit();
            }
            catch (Exception e) {
                trans.Rollback();
                throw new SqlInsertException("Error al insertar los roles", 0);
            }
        }
Пример #27
0
        public void insertarRolesPorUsuario(List <Rol> roles, int userId)
        {
            string         query = "INSERT INTO [TheBigBangQuery].[Roles_usuario](rolu_usuario, rolu_rol) VALUES (@userId, @rolId)";
            SqlTransaction trans = DatabaseConection.getInstance().BeginTransaction();

            try
            {
                roles.ForEach(elem =>
                {
                    SqlCommand command  = new SqlCommand(query);
                    command.CommandText = query;
                    command.Transaction = trans;
                    command.Parameters.AddWithValue("@userId", userId);
                    command.Parameters.AddWithValue("@rolId", elem.id);
                    DatabaseConection.executeNoParamFunction(command);
                });

                trans.Commit();
            }
            catch (Exception ex) {
                trans.Rollback();
                throw new SqlInsertException("Error al insertar los roles", 0);
            }
        }
Пример #28
0
        public void actualizarEmpresa(Empresa empresa)
        {
            string query = "EXEC [TheBigBangQuery].[ActualizarEmpresa] " +
                           "@id = '" + empresa.id + "'," +
                           "@cuit = '" + empresa.cuit + "'," +
                           "@razonSocial = '" + empresa.razonSocial + "'," +
                           "@mail = '" + empresa.mailEmpresa + "'," +
                           "@telefono = '" + empresa.telefonoEmpresa + "'," +
                           "@direccion = '" + empresa.direccion.calle + "'," +
                           "@altura = '" + empresa.direccion.numero + "'," +
                           "@piso = '" + empresa.direccion.piso + "'," +
                           "@depto = '" + empresa.direccion.depto + "'," +
                           "@localidad = '" + empresa.direccion.localidad + "'," +
                           "@codigoPostal = '" + empresa.direccion.codigoPostal + "'," +
                           "@ciudad = '" + empresa.direccion.ciudad + "'";

            try
            {
                DatabaseConection.executeNoParamFunction(query);
            }
            catch (SqlException e) {
                throw e;
            }
        }