/// <summary> /// 根据Int型数据选择列表 /// </summary> /// <param name="UserID"></param> /// <returns></returns> public static System.Data.DataTable QueryOne <T>(T value, String TableName, String ValueName) { string sql = String.Format("SELECT * From {0} WHERE {1}=@{2}", TableName, ValueName, ValueName); SqlParameter[] parameters = { new SqlParameter("@" + ValueName, value) }; Utility.SQLHelper db = new Utility.SQLHelper(); return(db.ExecuteQuery(sql, parameters, CommandType.Text)); }
public static DataTable SelectByEnableAndCollege(int pageSize, int currentPage, String orderField, String orderValue, String College, Boolean Enable) { Utility.SQLHelper db = new Utility.SQLHelper(); String sql = String.Format("select top {0} * from(select row_number() over (order by {1} {2}) as RID,Tb_StudentInfoModel.* from Tb_User,Tb_StudentInfoModel where (Tb_User.ID=Tb_StudentInfoModel.UserId and Tb_User.Enable=@Enable and Tb_StudentInfoModel.College=@College)) A where RID>{3}", pageSize, orderField, orderValue, pageSize * (currentPage - 1)); SqlParameter[] parameters = { new SqlParameter("@Enable", Enable), new SqlParameter("@College", College) }; return(db.ExecuteQuery(sql, parameters, CommandType.Text)); }
public static DataTable CountByEnableAndCollege(Boolean enable, String College) { Utility.SQLHelper db = new Utility.SQLHelper(); String sql = "select count(*) from Tb_User,Tb_StudentInfoModel where Tb_User.ID=Tb_StudentInfoModel.UserId and Tb_User.Enable=@Enable and Tb_StudentInfoModel.College=@College"; SqlParameter[] parameters = { new SqlParameter("@Enable", enable), new SqlParameter("@College", College) }; return(db.ExecuteQuery(sql, parameters, CommandType.Text)); }
public static DataTable FindProjectScore(int ProjectID, int MatchModelID) { Utility.SQLHelper db = new Utility.SQLHelper(); String sql = String.Format("Select * From Tb_ProjectScore Where ProjectID=@ProjectID And MatchModelID=@MatchModelID"); SqlParameter[] parameters = { new SqlParameter("@ProjectID", ProjectID), new SqlParameter("@MatchModelID", MatchModelID) }; return(db.ExecuteQuery(sql, parameters, CommandType.Text)); }
public static DataTable FindJudgeMatch(int JudgeID, DateTime Now) { Utility.SQLHelper db = new Utility.SQLHelper(); String sql = String.Format("Select * From (Tb_JudgeInfoModel INNER JOIN Tb_MatchJuryRelation ON Tb_JudgeInfoModel.Id=Tb_MatchJuryRelation.JudgeID INNER JOIN Tb_Match ON Tb_MatchJuryRelation.MatchID=Tb_Match.ID) where (Tb_JudgeInfoModel.Id=@JudgeID And datediff(d,Tb_Match.DeadLine,@DateTime)<0)"); SqlParameter[] parameters = { new SqlParameter("@JudgeID", JudgeID), new SqlParameter("@DateTime", Now) }; return(db.ExecuteQuery(sql, parameters, CommandType.Text)); }
public static DataTable QueryOne(String UserName) { string sql = "select * from Tb_User where Name=@Name"; SqlParameter[] parameters = { new SqlParameter("@Name", UserName) }; Utility.SQLHelper db = new Utility.SQLHelper(); return(db.ExecuteQuery(sql, parameters, CommandType.Text)); }
public static int ProjectScoreHasRecord(int ProjectID, int MatchModelID) { Utility.SQLHelper db = new Utility.SQLHelper(); String sql = String.Format("select count(*) from Tb_ProjectScore where ProjectID=@ProjectID And MatchModelID=@MatchModelID "); SqlParameter[] parameters = { new SqlParameter("@ProjectID", ProjectID), new SqlParameter("@MatchModelID", MatchModelID) }; DataTable dt = db.ExecuteQuery(sql, parameters, CommandType.Text); if (dt.Rows.Count > 0) { return(Convert.ToInt32(dt.Rows[0][0])); } return(0); }