public static Deposit GetLastDerpositByHolder(SqlConnectionStringBuilder stringBuilder, AClient holder) { int isEntity = 0; if (holder is Entity) { isEntity = 1; } else if (holder is Client) { isEntity = 0; } var sqlQuery = $@"SELECT TOP 1 * FROM Deposits WHERE HolderId = {holder.Id} and isEntity = {isEntity} ORDER BY ID DESC"; Deposit lastDeposit = null; using (var connector = new SqlConnector(stringBuilder)) { var reader = connector.GetData(sqlQuery); while (reader.Read()) { lastDeposit = ConvertSqlData.ToDeposit(reader, holder); } } return(lastDeposit); }
private void DbFillEmployees(SqlConnector connector, ADepartament departament, int index) { var sqlQuery = $@"SELECT * FROM Employees WHERE DepartamentId = {index}"; using (var reader = connector.GetData(sqlQuery)) { while (reader.Read()) { var currentEmployee = ConvertSqlData.ToEmployee(reader, departament); if (currentEmployee != null) { departament.AddEmployee(currentEmployee); } } } }
public static Entity GetEntityById(SqlConnectionStringBuilder stringBuilder, int id, Bank bank) { var sqlQuery = $@"SELECT * FROM Entitys WHERE Id = {id}"; Entity currentEntity = null; using (var connector = new SqlConnector(stringBuilder)) { var reader = connector.GetData(sqlQuery); while (reader.Read()) { currentEntity = ConvertSqlData.ToEntity(reader, bank); } } return(currentEntity); }
public static Client GetClientById(SqlConnectionStringBuilder stringBuilder, int id, Bank bank) { var sqlQuery = $@"SELECT * FROM Clients WHERE Id = {id}"; Client currentClient = null; using (var connector = new SqlConnector(stringBuilder)) { var reader = connector.GetData(sqlQuery); while (reader.Read()) { currentClient = ConvertSqlData.ToClient(reader, bank); } } return(currentClient); }
public static Client GetLastClient(SqlConnectionStringBuilder stringBuilder, Bank bank) { var sqlQuery = @"SELECT TOP 1 * FROM Clients ORDER BY ID DESC"; Client lastClient = null; using (var connector = new SqlConnector(stringBuilder)) { var reader = connector.GetData(sqlQuery); while (reader.Read()) { lastClient = ConvertSqlData.ToClient(reader, bank); } } return(lastClient); }
public static Employee GetEmployeeById(SqlConnectionStringBuilder stringBuilder, int id, ADepartament departament) { var sqlQuery = $@"SELECT * FROM Employees WHERE Id = {id}"; Employee lastEmployee = null; using (var connector = new SqlConnector(stringBuilder)) { var reader = connector.GetData(sqlQuery); while (reader.Read()) { lastEmployee = ConvertSqlData.ToEmployee(reader, departament); } } return(lastEmployee); }
public static Employee GetLastEmployee(SqlConnectionStringBuilder stringBuilder, ADepartament departament) { var sqlQuery = @"SELECT TOP 1 * FROM Employees ORDER BY ID DESC"; Employee lastEmployee = null; using (var connector = new SqlConnector(stringBuilder)) { var reader = connector.GetData(sqlQuery); while (reader.Read()) { lastEmployee = ConvertSqlData.ToEmployee(reader, departament); } } return(lastEmployee); }
public static Entity GetLastEntity(SqlConnectionStringBuilder stringBuilder, Bank bank) { var sqlQuery = @"SELECT TOP 1 * FROM Entitys ORDER BY ID DESC"; Entity lastEntity = null; using (var connector = new SqlConnector(stringBuilder)) { var reader = connector.GetData(sqlQuery); while (reader.Read()) { lastEntity = ConvertSqlData.ToEntity(reader, bank); } } return(lastEntity); }
public static IEnumerable <Deposit> GetDepositsByHolder(SqlConnectionStringBuilder stringBuilder, AClient holder) { var sqlQuery = $@"SELECT * FROM Deposits WHERE HolderId = {holder.Id}"; List <Deposit> deposits = new List <Deposit>(); using (var connector = new SqlConnector(stringBuilder)) { var reader = connector.GetData(sqlQuery); while (reader.Read()) { var deposit = ConvertSqlData.ToDeposit(reader, holder); deposits.Add(deposit); } } return(deposits); }
private void DbFillEntitys(SqlConnectionStringBuilder connectionStringBuilder) { var sqlGetClients = @"SELECT * FROM Entitys"; using (var connector = new SqlConnector(connectionStringBuilder)) { using (var reader = connector.GetData(sqlGetClients)) { while (reader.Read()) { var currentClient = ConvertSqlData.ToEntity(reader, this); GetCredits((int)reader[0], connectionStringBuilder, currentClient, 1); GetDeposits((int)reader[0], connectionStringBuilder, currentClient, 1); Clients.Add(currentClient); } } } }
private void GetDeposits(int index, SqlConnectionStringBuilder connectionStringBuilder, AClient holder, int entity = 0) { var sqlDepositQuery = $@"SELECT * FROM Deposits WHERE HolderId = {index} AND isEntity = {entity}"; using (var connector = new SqlConnector(connectionStringBuilder)) { using (var depositReader = connector.GetData(sqlDepositQuery)) { while (depositReader.Read()) { var deposit = ConvertSqlData.ToDeposit(depositReader, holder); if (deposit != null) { holder.Deposits.Add(deposit); Deposits.Add(deposit); } } } } }