📄 dataacess.cs
字号:
using System;
using System.Configuration;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using ASPNET.StarterKit.BusinessLogicLayer;
namespace ASPNET.StarterKit.DataAccessLayer {
public abstract class DataAccess {
/*** 属性 ***/
/// <summary>
/// 从配置文件中返回数据库连接信息
/// </summary>
protected string ConnectionString {
get {
if (ConfigurationManager.ConnectionStrings["aspnet_staterKits_TimeTracker"] == null)
throw (new NullReferenceException("需要在Web.Config文件中定义连接字符串!"));
string connectionString = ConfigurationManager.ConnectionStrings["aspnet_staterKits_TimeTracker"].ConnectionString;
if (String.IsNullOrEmpty(connectionString))
throw (new NullReferenceException("需要在Web.Config文件中定义连接字符串!"));
else
return (connectionString);
}
}
/*** 方法 ***/
//项目分类
public abstract int CreateNewCategory(Category newCategory);
public abstract bool DeleteCategory(int categoryId);
public abstract List<Category> GetAllCategories();
public abstract Category GetCategoryByCategoryId(int Id);
public abstract List<Category> GetCategoriesByProjectId(int projectId);
public abstract Category GetCategoryByCategoryNameandProjectId(string categoryName, int projectId);
public abstract bool UpdateCategory(Category newCategory);
//时间项
public abstract int CreateNewTimeEntry(TimeEntry newTimeEntry);
public abstract bool DeleteTimeEntry(int timeEntryId);
public abstract List<TimeEntry> GetAllTimeEntries();
public abstract List<TimeEntry> GetTimeEntries(int projectId, string userName);
public abstract TimeEntry GetTimeEntryById(int timeEntryId);
public abstract List<TimeEntry> GetTimeEntriesByUserNameAndDates(string userName,
DateTime startingDate, DateTime endDate);
public abstract bool UpdateTimeEntry(TimeEntry timeEntry);
// 项目
public abstract bool AddUserToProject(int projectId, string userName);
public abstract int CreateNewProject(Project newProject);
public abstract bool DeleteProject(int projectID);
public abstract List<Project> GetAllProjects();
public abstract Project GetProjectById(int projectId);
public abstract List<Project> GetProjectsByManagerUserName(string userName);
public abstract List<string> GetProjectMembers(int Id);
public abstract List<Project> GetProjectsByUserName(string userName);
public abstract bool RemoveUserFromProject(int projectId, string userName);
public abstract bool UpdateProject(Project projectToUpdate);
//用户报表
public abstract List<UserReport> GetUserReportsByProjectId(int projectId);
public abstract List<UserReport> GetUserReportsByCategoryId(int categoryId);
//资源使用报表
public abstract List<UserTotalDurationReport> GetUserReportsByUserName(string userName);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -