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); } }
protected override void DataPortal_Update() { //crear la conexion a la base if (Db == null) { Db = DatabaseFactory.CreateDatabase(); } Comando = Db.CreateSPCommand(ActualizarSp); AddCommonParameters(); AddUpdateParameters(); Db.ExecuteNonQuery(Comando); int resultado; int.TryParse(Db.GetOutputParameterValue(Comando, "sn_reg_modificados").ToString(), out resultado); if (resultado == 0) { throw new JusException("No se modifico ningun dato"); } PostUpdate(); FieldManager.UpdateChildren(); }
public List <Tarjeta> getTardejtasDelCliente(int clieId) { string query = "SELECT * FROM [TheBigBangQuery].[Tarjetas] WHERE tarj_cliente = @id"; SqlDataReader reader = null; List <Tarjeta> tarjetas = new List <Tarjeta>(); try { SqlCommand command = new SqlCommand(query); command.CommandText = query; command.Parameters.AddWithValue("@id", clieId); reader = DatabaseConection.executeQuery(command); if (reader.HasRows) { while (reader.Read()) { tarjetas.Add(parsearTarjetaDeReader(reader)); } } return(tarjetas); } catch (Exception e) { throw new DataNotFoundException("No se han encontrado tarjetas"); } finally { if (reader != null && !reader.IsClosed) { reader.Close(); } } }
public List <Compra> getPaginaComprasCliente(int clieId, int pagina) { string function = "SELECT * FROM [TheBigBangQuery].[getComprasPorPagina](@pagina, @clieId)"; SqlDataReader reader = null; List <Compra> compras = new List <Compra>(); try { SqlCommand command = new SqlCommand(function); command.Parameters.AddWithValue("@pagina", pagina); command.Parameters.AddWithValue("@clieId", clieId); reader = DatabaseConection.executeQuery(command); if (reader.HasRows) { while (reader.Read()) { compras.Add(parsearCompraDelReader(reader)); } } return(compras); } catch (Exception e) { throw new DataNotFoundException("Error al buscar la pagina " + pagina + "de compras"); } finally { if (reader != null && !reader.IsClosed) { reader.Close(); } } }
public List <string> getFormasDePago() { string query = "SELECT form_nombre FROM TheBigBangQuery.FormaDePago"; SqlDataReader reader = null; List <string> response = new List <string>(); try { reader = DatabaseConection.executeQuery(query); if (reader.HasRows) { while (reader.Read()) { response.Add(reader.GetSqlString(0).ToString()); } } return(response); } catch (Exception ex) { throw new DataNotFoundException("No se han encontrado metodos de pago"); } finally { if (reader != null & !reader.IsClosed) { reader.Close(); } } }
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; } }
public void getClientesHabilitados(Action <List <Cliente> > lambda) { string query = getClientsQuery + " WHERE clie_dado_baja IS NULL"; SqlDataReader reader = null; List <Cliente> clientesHabilitados = new List <Cliente>(); try { reader = DatabaseConection.executeQuery(query); if (reader.HasRows) { while (reader.Read()) { clientesHabilitados.Add(getClienteFromReder(reader)); } } lambda(clientesHabilitados); } catch (Exception e) { throw new DataNotFoundException("Error al buscar clientes habilitados"); } finally{ if (reader != null & !reader.IsClosed) { reader.Close(); } } }
public void getUsuarios(Action <List <Usuario> > result) { string query = "SELECT usua_id, usua_usuario, usua_n_intentos, usua_habilitado " + "FROM TheBigBangQuery.Usuario"; SqlDataReader reader = null; List <Usuario> usuariosList = new List <Usuario>(); try { reader = DatabaseConection.executeQuery(query); if (reader.HasRows) { while (reader.Read()) { usuariosList.Add(getUsuarioDeRader(reader)); } } // SI EL USUARIO NO ES VALIDO RETORNO NULL result(usuariosList); } catch (Exception ex) { throw new DataNotFoundException("No se han encontrado usuarios registrados"); } finally { if (reader != null && !reader.IsClosed) { reader.Close(); } } }
public List <GradoPublicacion> getGradosDePublicacion() { List <GradoPublicacion> gradosPublicacion = new List <GradoPublicacion>(); string query = "SELECT * " + "FROM TheBigBangQuery.GradoPublicaciones " + "ORDER BY 3 DESC"; SqlDataReader reader = null; try { reader = DatabaseConection.executeQuery(query); if (reader.HasRows) { while (reader.Read()) { gradosPublicacion.Add(getGradoFromReader(reader)); } } } catch (SqlException e) { throw e; } catch (ObjectParseException ex) { throw ex; } finally { if (reader != null & !reader.IsClosed) { reader.Close(); } } return(gradosPublicacion); }
public List <TipoUbicacion> getTipoUbicaciones() { List <TipoUbicacion> tiposUbicaciones = new List <TipoUbicacion>(); string query = "SELECT * FROM [TheBigBangQuery].[TipoUbicacion]"; SqlDataReader reader = null; try { reader = DatabaseConection.executeQuery(query); if (reader.HasRows) { while (reader.Read()) { tiposUbicaciones.Add(getTipoUbicacionFromReader(reader)); } } } catch (ObjectDisposedException ex) { } finally { if (reader != null & !reader.IsClosed) { reader.Close(); } } return(tiposUbicaciones); }
public int getUltimaPaginaRubros(List <Rubro> rubros) { string query = "SELECT [TheBigBangQuery].[getUltimaLineaFiltroRubro](@table, @fechaActual)"; try { SqlCommand com = new SqlCommand(query); DataTable table = new DataTable(); table.Columns.Add("rub_id", typeof(decimal)); foreach (Rubro r in rubros) { table.Rows.Add(r.id); } SqlParameter param = new SqlParameter("@table", SqlDbType.Structured); param.TypeName = "[TheBigBangQuery].[RubrosList]"; param.Value = table; com.Parameters.Add(param); com.Parameters.AddWithValue("@fechaActual", Generals.getFecha()); return(DatabaseConection.executeParamFunction <int>(com)); } catch (Exception e) { throw e; } }
public Empresa getEmpresaPorUserId(int userId) { string query = mainEmpresaQuery + " WHERE empr_usuario = @id"; SqlCommand command = new SqlCommand(query); SqlParameter param = new SqlParameter("@id", System.Data.SqlDbType.Int); param.Value = userId; command.Parameters.Add(param); Empresa empre = null; SqlDataReader reader = null; try { reader = DatabaseConection.executeQuery(command); if (reader.HasRows) { reader.Read(); empre = getEmpresaFromReader(reader); } } catch (Exception e) { throw e; } finally { if (reader != null & !reader.IsClosed) { reader.Close(); } } return(empre); }
public void getComprasPorEmpresa(int empId, int canitdad, Action <List <Compra> > lambdaEmpresas) { string query = "SELECT * FROM [TheBigBangQuery].[getComprasDeEmpresaPorCantidad] (@empeId, @cantidad)"; SqlDataReader reader = null; try { List <Compra> comprasList = new List <Compra>(); SqlCommand command = new SqlCommand(query); command.CommandText = query; command.Parameters.AddWithValue("@empeId", empId); command.Parameters.AddWithValue("@cantidad", canitdad); reader = DatabaseConection.executeQuery(command); if (reader.HasRows) { while (reader.Read()) { comprasList.Add(parsearCompraDelReader(reader)); } } lambdaEmpresas(comprasList); } catch (Exception e) { throw new DataNotFoundException("No se encontraron compras para el cliente selecionado"); } finally { if (reader != null && !reader.IsClosed) { reader.Close(); } } }
public List <Empresa> getEmpresasMayoresAId(int id) { List <Empresa> empresas = new List <Empresa>(); string query = mainEmpresaQuery + "WHERE empr_id > @id" + ordenarPorIdAsc; SqlCommand command = new SqlCommand(query); SqlParameter param = new SqlParameter("@id", System.Data.SqlDbType.Decimal); param.Value = id; command.Parameters.Add(param); SqlDataReader reader = DatabaseConection.executeQuery(command); if (reader.HasRows) { while (reader.Read()) { empresas.Add(getEmpresaFromReader(reader)); } } else { reader.Close(); throw new DataNotFoundException("No se han encontrado empresas mayores al id " + id); } reader.Close(); return(empresas); }
public Empresa getEmpresaPorId(int id, SqlTransaction trans = null) { Empresa empresa = new Empresa(); string query = mainEmpresaQuery + "WHERE empr_id = @id"; SqlCommand command = new SqlCommand(query); if (trans != null) { command.Transaction = trans; } SqlParameter param = new SqlParameter("@id", System.Data.SqlDbType.Decimal); param.Value = id; command.Parameters.Add(param); SqlDataReader reader = DatabaseConection.executeQuery(command); if (reader.HasRows) { reader.Read(); empresa = getEmpresaFromReader(reader); } else { reader.Close(); throw new DataNotFoundException("No se ha podido encontrar una empresa con dicho id"); } reader.Close(); return(empresa); }
private void button1_Click(object sender, EventArgs e) { Compra compra = new Compra(); List <Ubicacion> ubicaciones = new List <Ubicacion>(); foreach (var u in UbicacionesListView.CheckedItems) { Ubicacion ubi = (Ubicacion)((ListViewItem)u).Tag; compra.total += ubi.precio; ubicaciones.Add(ubi); } ComprasDao comprasDao = new ComprasDao(); SqlTransaction trans = DatabaseConection.getInstance().BeginTransaction(); compra.ubicaciones = ubicaciones; compra.fechaCompra = Generals.getFecha(); compra.cantidad = ubicaciones.Count; Cliente clie = new Cliente(); compra.cli = clie; ubicacionesSeleccionadas = ubicaciones; try { comprasDao.insertarCompra(compra, publicacionActual, trans); trans.Commit(); MessageBox.Show("Compra realizada con exito"); } catch (Exception ex) { trans.Rollback(); MessageBox.Show("Ha ocurrido un error al procesar la compra"); } }
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); }
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); } }
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); } }
public List <Publicacion> getPublicaciones() { List <Publicacion> publicaciones = new List <Publicacion>(); SqlDataReader reader = null; try { reader = DatabaseConection.executeQuery(baseQuery + "ORDER BY publ_id DESC"); if (reader.HasRows) { while (reader.Read()) { publicaciones.Add(ParserPublicaciones.parsearPublicacionDelReader(reader)); } } return(publicaciones); } catch (Exception ex) { throw ex; } finally { if (reader != null & !reader.IsClosed) { reader.Close(); } } }
public List <Premio> getPremiosPorPuntos() { string function = "SELECT * FROM [TheBigBangQuery].[getPremiosDelPuntaje]()"; SqlDataReader reader = null; List <Premio> premiosList = new List <Premio>(); try { SqlCommand command = new SqlCommand(function); reader = DatabaseConection.executeQuery(command); if (reader.HasRows) { while (reader.Read()) { premiosList.Add(parsearPremioDelReader(reader)); } } return(premiosList); } catch (Exception e) { throw new DataNotFoundException("No se han podido encontrar premios para los puntos actuales"); } finally { if (reader != null & !reader.IsClosed) { reader.Close(); } } }
public Cliente getClientePorUserId(int id) { string query = getClientsQuery + " WHERE clie_usuario = @id"; SqlCommand command = new SqlCommand(query); SqlParameter param = new SqlParameter("@id", System.Data.SqlDbType.Int); param.Value = id; command.Parameters.Add(param); SqlDataReader reader = null; Cliente cliente = null; try { reader = DatabaseConection.executeQuery(command); if (reader.HasRows) { reader.Read(); cliente = getClienteFromReder(reader); } } catch (Exception e) { throw e; } finally{ if (reader != null & !reader.IsClosed) { reader.Close(); } } return(cliente); }
public List <Cliente> getClientes() { SqlDataReader reader = null; try { List <Cliente> clientes = new List <Cliente>(); reader = DatabaseConection.executeQuery(getClientsQuery + " ORDER BY clie_id ASC"); if (reader.HasRows) { while (reader.Read()) { clientes.Add(getClienteFromReder(reader)); } } return(clientes); } catch (Exception e) { throw e; } finally { if (reader != null && !reader.IsClosed) { reader.Close(); } } }
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 getPuntosDelCliente(int clieId) { string query = "SELECT clie_puntos FROM TheBigBangQuery.Cliente WHERE clie_id = @clieId"; SqlDataReader reader = null; try { SqlCommand command = new SqlCommand(query); command.Parameters.AddWithValue("@clieId", clieId); reader = DatabaseConection.executeQuery(command); int ret = 0; if (reader.HasRows) { reader.Read(); ret = (int)reader.GetSqlDecimal(0); } return(ret); } catch (Exception ex) { throw new DataNotFoundException("No se han encontrado puntos registrados para el cliente"); } finally { if (reader != null && !reader.IsClosed) { reader.Close(); } } }
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); } }
public List <Ubicacion> getUbicaciones() { List <Ubicacion> ubicaciones = new List <Ubicacion>(); SqlDataReader reader = null; string query = baseQuery + ", ubpu_precio" + baseFrom + " JOIN TheBigBangQuery.TipoUbicacion ON (tipu_id = ubi_tipo_codigo)"; try { reader = DatabaseConection.executeQuery(query); if (reader.HasRows) { while (reader.Read()) { ubicaciones.Add(new Ubicacion(reader)); } } } catch (Exception e) { throw new DataNotFoundException("Ha ocurrido un error al traer los datos de la base de datos"); } finally { if (reader != null & !reader.IsClosed) { reader.Close(); } } return(ubicaciones); }
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); }
static void Main() { DatabaseConection.initDatabase(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.ApplicationExit += new EventHandler(OnExit); Application.Run(new Form1()); }
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); }