123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- using Models;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Data.SqlClient;
- using System.Linq;
- using System.Text;
- namespace DAL
- {
- public class AskDataService
- {
- List<AskData> excuteSql(string sql, params SqlParameter[] param)
- {
- return ServiceBase<AskData>.excuteSql(new AskData(), "AskData", sql, CommandType.Text, param);
- }
- AskData excuteType(string sql, params SqlParameter[] param)
- {
- //查询结果放入对象集合
- List<AskData> hdList = excuteSql(sql, param);
- //判断集合是否为空
- if (hdList == null || hdList.Count == 0)
- //返回null
- return null;
- //返回单个对象
- return hdList[0];
- }
- //增Add
- public bool Add(AskData Dov)
- {
- string sql = "insert into AskData values(@Diid,@DeleName,@Country,@Area,@UnitName,@Field,@TalkCase,@Oper,@OpDate,@Isdel);SELECT @@IDENTITY";
- SqlParameter[] parameter = new SqlParameter[]{
- new SqlParameter("@Diid",Dov.Diid),
- new SqlParameter("@DeleName",Dov.DeleName),
- new SqlParameter("@Country",Dov.Country),
- new SqlParameter("@Area",Dov.Area),
- new SqlParameter("@UnitName",Dov.UnitName),
- new SqlParameter("@Field",Dov.Field),
- new SqlParameter("@TalkCase",Dov.TalkCase),
- new SqlParameter("@Oper",Dov.Oper),
- new SqlParameter("@OpDate",Dov.OpDate),
- new SqlParameter("@Isdel",Dov.Isdel)
- };
- if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
- return true;
- return false;
- }
- //改Update
- public bool Edit(AskData Dov)
- {
- string sql = "update AskData set Diid=@Diid,DeleName=@DeleName,Country=@Country,Area=@Area,UnitName=@UnitName,Field=@Field,TalkCase=@TalkCase,Oper=@Oper,OpDate=@OpDate,Isdel=@Isdel where Id = @Id";
- SqlParameter[] parameter = new SqlParameter[]{
- new SqlParameter("@Diid",Dov.Diid),
- new SqlParameter("@DeleName",Dov.DeleName),
- new SqlParameter("@Country",Dov.Country),
- new SqlParameter("@Area",Dov.Area),
- new SqlParameter("@UnitName",Dov.UnitName),
- new SqlParameter("@Field",Dov.Field),
- new SqlParameter("@TalkCase",Dov.TalkCase),
- new SqlParameter("@Oper",Dov.Oper),
- new SqlParameter("@OpDate",Dov.OpDate),
- new SqlParameter("@Isdel",Dov.Isdel),
- new SqlParameter("@Id",Dov.Id)
- };
- if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
- return true;
- return false;
- }
- //删
- public bool delOA(int id)
- {
- if (SqlHelper.ExecuteNonQuery("update AskData set Isdel=1 where Id=@Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
- return true;
- return false;
- }
- /// <summary>
- /// 查找所有数据 - 分页
- /// </summary>
- /// <returns></returns>
- public List<AskData> GetAllAskData(int pageIndex, out int sumPage, out int totalRecord, string Country, string Area, string Field)
- {
- string sqlwhere = "IsDel = 0 and Country like '%" + Country + "%' and Area like '%" + Area + "%' and Field like '%" + Field + "%'";
- return PageBase<AskData>.excutePageSql(new AskData(), "AskData", "AskData", "*", "id asc", sqlwhere, 15, pageIndex, out sumPage, out totalRecord);
- }
- public AskData getById(int id)
- {
- return excuteType("select * from AskData where Isdel=0 and Id=@id", new SqlParameter("@id", id));
- }
- /// <summary>
- /// 根据ID集合查询数据
- /// 20210831 贾文滔
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- public List<AskData> getByIdlist(string id)
- {
- return excuteSql("select * from AskData where Isdel=0 and Id in (" + id + ") order by Country", new SqlParameter("@id", id));
- }
- }
- }
|