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 JobsStateMaintainDal { /// /// 根据id、岗位类型查询岗位类型列表 /// /// /// /// public List GetAllList(string id, string status) { using (IDbConnection conn = CommHelper.GetSqlConnection()) { string param = ""; if (id != "") { param = " and id=@id"; } if (status != "") { param += " and status=@status"; } return conn.Query("select * from jobs_state_maintain where 1=1 " + param + " order by id", new { @id = id, @status = status }).ToList(); } } public bool Add(JobsStateMaintainModel model) { using (IDbConnection conn = CommHelper.GetSqlConnection()) { string sql = @"INSERT INTO [jobs_state_maintain] ([code] ,[jobs_state] ,[status] ,[creator] ,[create_time]) VALUES (@code ,@jobs_state ,@status ,@creator ,@create_time)"; return (conn.Execute(sql, model) != 0 ? true : false); } } public bool Update(JobsStateMaintainModel model) { string sql = @"UPDATE [jobs_state_maintain] SET [jobs_state] = @jobs_state ,[status] = @status WHERE id=@id "; using (IDbConnection conn = CommHelper.GetSqlConnection()) { return (conn.Execute(sql, model) != 0 ? true : false); } } /// /// 根据id删除岗位类型 /// /// /// public object del(string id) { string sql = @"delete jobs_state_maintain where id=@id"; using (IDbConnection conn = CommHelper.GetSqlConnection()) { try { int c = conn.Execute(sql, new { id = id }); if (c > 0) { return new { State = 1, Message = "操作成功!" }; } else { return new { State = 0, Message = "操作失败,请联系管理员!" }; } } catch (Exception ex) { return new { State = 0, Message = ex.Message }; } } } } }