using Dapper; using dccdc.Models; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; namespace dccdc.DAL { public class summaryreport_suggest_maintainDal { public List GetAllList(string id, string status) { using (IDbConnection conn = CommHelper.GetSqlConnection()) { string sql = "select * from summaryreport_suggest_maintain where 1=1"; if (!string.IsNullOrEmpty(id)) { sql += " and id=@id"; } if (!string.IsNullOrEmpty(status)) { sql += " and status=@status"; } return conn.Query(sql, new { @id = id, @status = status }).ToList(); } } public object save(summaryreport_suggest_maintainModel model) { string sql = ""; if (model.id == 0) { sql = @"INSERT INTO [dbo].[summaryreport_suggest_maintain] ([opinion_and_suggest] ,[status] ,[pinyin_code] ,[creator] ,[create_time]) VALUES (opinion_and_suggest ,status ,pinyin_code ,creator ,create_time)"; } else { sql = @"UUPDATE [dbo].[summaryreport_suggest_maintain] SET [opinion_and_suggest] = opinion_and_suggest ,[status] = status ,[pinyin_code] = pinyin_code ,[creator] = creator ,[create_time] = create_time WHERE id=@id"; } using (IDbConnection conn = CommHelper.GetSqlConnection()) { try { int result = conn.Execute(sql, model); if (result > 0) return new { State = 1, Message = "保存成功!" }; else return new { State = 0, Message = "保存失败!" }; } catch (Exception ex) { return new { State = 0, Message = ex.Message }; } } } public object delete(string id) { string sql = "delete from summaryreport_suggest_maintain where id=@id"; using (IDbConnection conn = CommHelper.GetSqlConnection()) { try { int result = conn.Execute(sql, new { id = id }); if (result > 0) return new { State = 1, Message = "操作成功!" }; else return new { State = 0, Message = "操作失败!" }; } catch (Exception ex) { return new { State = 0, Message = ex.Message }; } } } } }