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 YgsqDal { public List findId(int ygid) { using (IDbConnection conn = CommHelper.GetSqlConnection()) { string param = ""; param = " and ygid=@ygid"; return conn.Query("select * from MJ_YGSQ where 1=1 " + param, new { @ygid = ygid }).ToList(); } } public bool save(YgsqModel model) { string sql = @"INSERT INTO [MJ_YGSQ] ([sbid] ,[ygid]) VALUES (@sbid, @ygid)"; using (IDbConnection conn = CommHelper.GetSqlConnection()) { var s = conn.Execute(sql, model) != 0 ? true : false; return s; } } public object Delete(int ygid) { string sql = "delete from MJ_YGSQ where ygid=@ygid"; using (IDbConnection conn = CommHelper.GetSqlConnection()) { try { int result = conn.Execute(sql, new { ygid = ygid }); if (result > 0) return new { State = 1, Message = "操作成功!" }; else return new { State = 0, Message = "操作失败!" }; } catch (Exception ex) { return new { State = 0, Message = ex.Message }; } } } } }