using System; using System.Collections.Generic; using System.Linq; using System.Text; using Models; using System.Data.SqlClient; using System.Data; namespace DAL { public class ScoreService { /// /// 添加分数 /// /// public bool AddScore(Scores s) { string sql = "INSERT INTO Score(Nid,NName,Score,Weak,Uid,InputTime,STid,STName)VALUES(@Nid,@NName,@Score,@Weak,@Uid,@InputTime,@STid,@STName)"; SqlParameter[] parameter = new SqlParameter[] { new SqlParameter("@Nid",s.Nid), new SqlParameter("@NName",s.NName), new SqlParameter("@Score",s.Score), new SqlParameter("@Weak",s.Wake), new SqlParameter("@Uid",s.Uid), new SqlParameter("@InputTime",s.InputTime), new SqlParameter("@STid",s.STid), new SqlParameter("@STName",s.STName), }; if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0) return true; else return false; } /// /// 根据用户id获取该用户指定时间的评分信息 /// /// /// public List getScoreByUID(int id, string time) { List vss = new List(); string sql = "select * from setDataType where Name in ('办公桌面','安全防范能源消耗','请假次数','行为规范','礼貌礼节')"; SetDataTypeService sdtss = new SetDataTypeService(); SetDataService setDatasv = new SetDataService(); List sdts = sdtss.excuteSql(sql, null); if (sdts != null) { List sds = new List(); for (int i = 0; i < sdts.Count; i++) { ViewScore vs = new ViewScore(); Scores s = new Scores(); //根据每个考察类型和时间查询指定用户的分数信息 SqlParameter[] parameter = new SqlParameter[]{ new SqlParameter("@Uid",id), new SqlParameter("@time",time), new SqlParameter("@sTid",sdts[i].Id) }; List scores = excuteSql("select * from Score where Uid=@Uid and InputTime=@time and sTid=@sTid", CommandType.Text, parameter); if (scores != null&&scores.Count>0) s = scores[0]; vs.Sdt = sdts[i]; vs.Sc = s; vss.Add(vs); } } return vss; } /// /// 返回实体的集合 /// /// /// /// /// private List excuteSql(string sql, CommandType commandType, SqlParameter[] parameter) { return ServiceBase.excuteSql(new Scores(), "Scores", sql, CommandType.Text, parameter); } /// /// 根据考察类型和时间获取员工的评分信息 /// /// /// /// /// public List getScoreBySTID(string time, int uid, int stid) { SqlParameter[] parameter = new SqlParameter[]{ new SqlParameter("@Uid",uid), new SqlParameter("@time",time), new SqlParameter("@sTid",stid) }; return excuteSql("select * from Score where Uid=@Uid and InputTime=@time and sTid=@stid", CommandType.Text, parameter); } } }