using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; using System.Text; using Models; namespace DAL { public class CheckBoxServcies { List excuteSql(string sql, params SqlParameter[] param) { return ServiceBase.excuteSql(new CheckBoxs(), "CheckBoxs", sql, CommandType.Text, param); } CheckBoxs excuteType(string sql, params SqlParameter[] param) { //查询结果放入对象集合 List hdList = excuteSql(sql, param); //判断集合是否为空 if (hdList == null || hdList.Count == 0) //返回null return null; //返回单个对象 return hdList[0]; } /// /// 增Add /// /// /// public bool Add(CheckBoxs cb) { string sql = "insert into CheckBoxs values(@Diid,@cbType,@cbValues,@Oper,@OPDate,@Isdel);SELECT @@IDENTITY"; SqlParameter[] parameter = new SqlParameter[]{ new SqlParameter("@Diid",cb.Diid), new SqlParameter("@cbType",cb.cbType), new SqlParameter("@cbValues",cb.cbValues), new SqlParameter("@Oper",cb.Oper), new SqlParameter("@OPDate",cb.OPDate), new SqlParameter("@Isdel",cb.Isdel) }; if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0) return true; return false; } /// /// 修改 /// /// /// public bool Edit(CheckBoxs cb) { string sql = "update CheckBoxs set Diid=@Diid,cbType=@cbType,cbValues=@cbValues ,Oper=@Oper,OPDate =@OPDate," + "Isdel=@Isdel where Id = @Id"; SqlParameter[] parameter = new SqlParameter[]{ new SqlParameter("@Diid",cb.Diid), new SqlParameter("@cbType",cb.cbType), new SqlParameter("@cbValues",cb.cbValues), new SqlParameter("@Oper",cb.Oper), new SqlParameter("@OPDate",cb.OPDate), new SqlParameter("@Isdel",cb.Isdel), new SqlParameter("@Id",cb.Id) }; if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0) return true; return false; } /// /// 删 /// /// /// public bool del(int id) { if (SqlHelper.ExecuteNonQuery("update CheckBoxs set Isdel=1 where Id=@Id", CommandType.Text, new SqlParameter("@Id", id)) > 0) return true; return false; } /// /// 根据diid查询 /// /// /// public List GetByDiid( string diid) { string sql = "select * from CheckBoxs where Diid=@diid and Isdel = 0"; SqlParameter[] parameter = new SqlParameter[] { new SqlParameter("@diid", diid) }; return excuteSql(sql, parameter); } /// /// 根据 diid 和 checktype 查询 /// /// diid /// /// top /// left /// right /// /// public List GetByDiidAndCheckType(string diid,string cbType) { string sql = "select * from CheckBoxs where Diid=@diid and cbType=@cbType and Isdel = 0"; SqlParameter[] parameter = new SqlParameter[] { new SqlParameter("@diid", diid), new SqlParameter("@cbType", cbType) }; return excuteSql(sql, parameter); } } }