using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; using dccdc.Models; using Dapper; namespace dccdc.DAL { public class ExamProjectResultMaintainDal { public int getCount(string id) { using (IDbConnection conn = CommHelper.GetSqlConnection()) { string sql = "select * from [exam_project_result_maintain] where project_id="+ id; return conn.Query(sql).ToList().Count; } } /// /// 根据体检项查询下面结果 /// /// /// public List GetAllList(int page, int pagesize,string id) { //throw new NotImplementedException(); string sql = "select *,row_number() over(order by id) as rownum from [exam_project_result_maintain] where 1=1"; if (!string.IsNullOrEmpty(id)) { sql += " and project_id like @project_id"; } sql = "select * from (" + sql + ") t where t.rownum>(" + page + "-1)*" + pagesize + " and rownum<=" + page + "*" + pagesize; using (IDbConnection conn = CommHelper.GetSqlConnection()) { return conn.Query(sql, new { project_id = "%" + id + "%" }).ToList(); } } /// /// 根据主键查询结果明细 /// /// /// public List GetAllListById(string id) { using (IDbConnection conn = CommHelper.GetSqlConnection()) { return conn.Query("select * from exam_project_result_maintain where id=@id", new { @id = id }).ToList(); } } public bool Update(ExamProjectResultMaintainModel model) { using (IDbConnection conn = CommHelper.GetSqlConnection()) { string sql = @"UPDATE [exam_project_result_maintain] SET [project_id] = @project_id ,[project_name] = @project_name ,[test_result] = @test_result ,[is_qualified] = @is_qualified ,[is_add_summary] = @is_add_summary ,[status] = @status WHERE id=@id"; return (conn.Execute(sql, model) != 0 ? true : false); } } public bool Add(ExamProjectResultMaintainModel model) { using (IDbConnection conn = CommHelper.GetSqlConnection()) { string sql = @"INSERT INTO [exam_project_result_maintain] ([project_id] ,[project_name] ,[test_result] ,[is_qualified] ,[is_add_summary] ,[status]) VALUES (@project_id ,@project_name ,@test_result ,@is_qualified ,@is_add_summary ,@status)"; return (conn.Execute(sql, model) != 0 ? true : false); } } public DataTable gettjlx4xm() { //throw new NotImplementedException(); string sql = @"select distinct c.exam_group_maintain_id, b.project_id,b.project_name from professionalExam_register a join professionalExam_project_result b on a.id=b.person_id join examination_process c on c.person_id=a.id and c.exam_group_maintain_id=b.exam_group_maintain_id where a.medical_scheme_maintain_id=4 order by c.exam_group_maintain_id "; using (var conn = CommHelper.GetSqlConnection()) { var dr = conn.ExecuteReader(sql); DataTable dt = new DataTable(); dt.Load(dr); if (!dr.IsClosed) dr.Close(); return dt; } } } }