Skip to content

Commit

Permalink
#232 change DBConnection to DbConnection
Browse files Browse the repository at this point in the history
  • Loading branch information
AnhAnNek committed May 16, 2023
1 parent 9034fe0 commit 1396e7f
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion CompanyManagement/CompanyManagement.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
<Compile Include="Converters\EnumDescConverter.cs" />
<Compile Include="Database\AccountsDao.cs" />
<Compile Include="Database\Base\BaseDao.cs" />
<Compile Include="Database\Base\DBConnection.cs" />
<Compile Include="Database\Base\DbConnection.cs" />
<Compile Include="Database\MilestonesDao.cs" />
<Compile Include="Database\MileTasksDao.cs" />
<Compile Include="Database\ProjectBonusesDao.cs" />
Expand Down
2 changes: 1 addition & 1 deletion CompanyManagement/Database/Base/BaseDao.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,6 @@ public abstract class BaseDao
public const string mileTskID = "MileID";
public const string mileTskTskID = "TaskID";

protected DBConnection dbConnection = new DBConnection();
protected DbConnection dbConnection = new DbConnection();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

namespace CompanyManagement.Database.Base
{
public class DBConnection
public class DbConnection
{
private SqlConnection conn;

public DBConnection()
public DbConnection()
{
conn = new SqlConnection(Properties.Settings.Default.connStr);
}
Expand All @@ -24,12 +24,12 @@ public bool ExecuteNonQuery(string command)
if (cmd.ExecuteNonQuery() > 0)
{
success = true;
Log.Ins.Information(nameof(DBConnection), "Completed");
Log.Ins.Information(nameof(DbConnection), "Completed");
}
}
catch (Exception ex)
{
Log.Ins.Error(nameof(DBConnection), ex.Message);
Log.Ins.Error(nameof(DbConnection), ex.Message);
}
finally
{
Expand Down Expand Up @@ -59,7 +59,7 @@ public List<T> GetList<T>(string sqlStr, Func<SqlDataReader, T> converter)
}
catch (Exception ex)
{
Log.Ins.Error(nameof(DBConnection), ex.Message);
Log.Ins.Error(nameof(DbConnection), ex.Message);
}
finally
{
Expand All @@ -80,7 +80,7 @@ public decimal GetDecimal(string sqlStr)
}
catch (Exception ex)
{
Log.Ins.Error(nameof(DBConnection), ex.Message);
Log.Ins.Error(nameof(DbConnection), ex.Message);
}
finally
{
Expand Down
2 changes: 1 addition & 1 deletion CompanyManagementMSTest/Database/AccountsDaoTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void SearchByUsername_Found()

public Account Search(Account account)
{
DBConnection dbConnection = new DBConnection();
DbConnection dbConnection = new DbConnection();
string sqlStr = $"SELECT * FROM Accounts WHERE Username = '{account.Username}' ";
return (Account)dbConnection.GetSingleObject(sqlStr, reader => new Account(reader));
}
Expand Down
2 changes: 1 addition & 1 deletion CompanyManagementMSTest/Database/MileTasksDaoTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void MileTasks_Dao_Search_By_MileID_Test()

private MileTask Search(MileTask mileTsk)
{
DBConnection dbConnection = new DBConnection();
DbConnection dbConnection = new DbConnection();
string sql = $"SELECT * FROM MileTasks WHERE MileID='{mileTsk.MileID}' AND TaskID='{mileTsk.TskID}'";
return (MileTask)dbConnection.GetSingleObject(sql, reader => new MileTask(reader));
}
Expand Down
2 changes: 1 addition & 1 deletion CompanyManagementMSTest/Database/MilestonesDaoTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void Milestones_Dao_Search_By_ProjectID()

private Milestone Search(string id)
{
DBConnection dbConnection = new DBConnection();
DbConnection dbConnection = new DbConnection();
string sql = $"SELECT * FROM Milestones WHERE ID='{id}'";
return (Milestone)dbConnection.GetSingleObject(sql, reader => new Milestone(reader));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void SearchProjectByCreatorID_Found()

private ProjectAssignment Search(ProjectAssignment assign)
{
DBConnection dbConnection = new DBConnection();
DbConnection dbConnection = new DbConnection();
string sql = $"SELECT * FROM ProjectAssignments WHERE ProjectID='{assign.ProjID}' AND DepartmentID='{assign.DeptID}'";
return (ProjectAssignment)dbConnection.GetSingleObject(sql, reader => new ProjectAssignment(reader));
}
Expand Down
6 changes: 3 additions & 3 deletions CompanyManagementMSTest/Database/ProjectBonusesDaoTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,20 @@ public void SearchByEmplojID_Found()

public ProjectBonus Search(ProjectBonus projectBonus)
{
DBConnection dbConnection = new DBConnection();
DbConnection dbConnection = new DbConnection();
string sqlStr = $"Select * From ProjectBonuses Where ID = '{projectBonus.ID}'";
return (ProjectBonus)dbConnection.GetSingleObject(sqlStr, reader => new ProjectBonus(reader));
}

public List<ProjectBonus> SearchByProjectID(string prjectID)
{
DBConnection dbConnection = new DBConnection();
DbConnection dbConnection = new DbConnection();
string sqlStr = $"Select * From ProjectBonuses Where ProjectID = '{prjectID}'";
return dbConnection.GetList(sqlStr, reader => new ProjectBonus(reader));
}
public List<ProjectBonus> SearchByEmployeeID(string employeeID)
{
DBConnection dbConnection = new DBConnection();
DbConnection dbConnection = new DbConnection();
string sqlStr = $"Select * From ProjectBonuses Where EmployeeID = '{employeeID}'";
return dbConnection.GetList(sqlStr, reader => new ProjectBonus(reader));
}
Expand Down
4 changes: 2 additions & 2 deletions CompanyManagementMSTest/Database/SalaryRecordsDaoTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ public void GetByEmployeeID_Fount()

public SalaryRecord Search(SalaryRecord salaryRecord)
{
DBConnection dbConnection = new DBConnection();
DbConnection dbConnection = new DbConnection();
string sqlStr = $"Select * From SalaryRecords where ID = '{salaryRecord.ID}'";
return (SalaryRecord)dbConnection.GetSingleObject(sqlStr, reader => new SalaryRecord(reader));
}
public List<SalaryRecord> SearchByMonthYear(int month, int year)
{
DBConnection dbConnection = new DBConnection();
DbConnection dbConnection = new DbConnection();
string sqlStr = $"Select * From SalaryRecords where Month(MonthYear) = '{month}' AND Year(MonthYear) = '{year}'";
return dbConnection.GetList(sqlStr, reader => new SalaryRecord(reader));
}
Expand Down
4 changes: 2 additions & 2 deletions CompanyManagementMSTest/Database/TaskCheckOutsDaoTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ public void SearchByProjectID_Found()

private TaskCheckOut Search(string timeShtID, string tskID)
{
DBConnection dbConnection = new DBConnection();
DbConnection dbConnection = new DbConnection();
string sql = $"SELECT * FROM TaskCheckOuts WHERE TimeSheetID='{timeShtID}' AND TaskID='{tskID}'";
return (TaskCheckOut)dbConnection.GetSingleObject(sql, reader => new TaskCheckOut(reader));
}

private void Delete(string timeShtID, string tskID)
{
DBConnection dbConnection = new DBConnection();
DbConnection dbConnection = new DbConnection();
string sql = $"DELETE FROM TaskCheckOuts WHERE TimeSheetID='{timeShtID}' AND TaskID='{tskID}'";
dbConnection.ExecuteNonQuery(sql);
}
Expand Down
2 changes: 1 addition & 1 deletion CompanyManagementMSTest/Database/TasksDaoTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void SearchCurrentTasksByEmployeeID_Found()

private List<TaskInProject> SearchByPrjID(string PrjID)
{
DBConnection dbConnection = new DBConnection();
DbConnection dbConnection = new DbConnection();
string sql = $"SELECT * FROM Tasks WHERE ProjectID = '{PrjID}'";
return dbConnection.GetList<TaskInProject>(sql, reader => new TaskInProject(reader));
}
Expand Down
2 changes: 1 addition & 1 deletion CompanyManagementMSTest/Database/TimeSheetsCIODaoTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void TotalWorksDayByEmployeeID()

public TimeSheet Search(TimeSheet timeSheet)
{
DBConnection dbConnection = new DBConnection();
DbConnection dbConnection = new DbConnection();
string sqlStr = $"Select * From TimeSheets Where ID = '{timeSheet.ID}'";
return (TimeSheet)dbConnection.GetSingleObject(sqlStr, reader => new TimeSheet(reader));
}
Expand Down

0 comments on commit 1396e7f

Please sign in to comment.