using dccdc.Models; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; using Dapper; namespace dccdc.DAL { public class NativeInfoMaintainDal { public List GetAllList(string id) { using (IDbConnection conn = CommHelper.GetSqlConnection()) { string param = ""; if (id != "") { param += " and id=@id"; } return conn.Query("select * from native_info_maintain where 1=1"+param,new{id=id}).ToList(); } } public List GetAllList() { using (IDbConnection conn = CommHelper.GetSqlConnection()) { return conn.Query("select * from native_info_maintain where status='是'" ).ToList(); } } public bool Edit(NativeInfoMaintainModel model) { using (IDbConnection conn = CommHelper.GetSqlConnection()) { string sql = @"UPDATE [native_info_maintain] SET [natives] = @natives ,[status] = @status ,[creator] = @creator ,[create_time] = @create_time WHERE id=@id"; return (conn.Execute(sql, model) != 0 ? true : false); } } public bool Add(NativeInfoMaintainModel model) { using (IDbConnection conn = CommHelper.GetSqlConnection()) { string sql = @"INSERT INTO [native_info_maintain] ([natives] ,[status] ,[creator] ,[create_time]) VALUES (@natives , @status , @creator , @create_time)"; return (conn.Execute(sql, model) != 0 ? true : false); } } /// /// 根据id删除户籍 /// /// /// public object del(string id) { string sql = @"delete native_info_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 }; } } } } }