123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- 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<CheckBoxs> excuteSql(string sql, params SqlParameter[] param)
- {
- return ServiceBase<CheckBoxs>.excuteSql(new CheckBoxs(), "CheckBoxs", sql, CommandType.Text, param);
- }
- CheckBoxs excuteType(string sql, params SqlParameter[] param)
- {
- //查询结果放入对象集合
- List<CheckBoxs> hdList = excuteSql(sql, param);
- //判断集合是否为空
- if (hdList == null || hdList.Count == 0)
- //返回null
- return null;
- //返回单个对象
- return hdList[0];
- }
- /// <summary>
- /// 增Add
- /// </summary>
- /// <param name="Dov"></param>
- /// <returns></returns>
- 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;
- }
- /// <summary>
- /// 修改
- /// </summary>
- /// <param name="Dov"></param>
- /// <returns></returns>
- 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;
- }
- /// <summary>
- /// 删
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- 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;
- }
- /// <summary>
- /// 根据diid查询
- /// </summary>
- /// <param name="diid"></param>
- /// <returns></returns>
- public List<CheckBoxs> 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);
-
- }
- /// <summary>
- /// 根据 diid 和 checktype 查询
- /// </summary>
- /// <param name="diid">diid</param>
- /// <param name="cbType">
- /// top
- /// left
- /// right
- /// </param>
- /// <returns></returns>
- public List<CheckBoxs> 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);
- }
- }
- }
|