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 DelegationEnDataService { List excuteSql(string sql, params SqlParameter[] param) { return ServiceBase.excuteSql(new DelegationEnData(), "DelegationEnData", sql, CommandType.Text, param); } DelegationEnData 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(DelegationEnData Dov) { string sql = "insert into DelegationEnData values(@Area,@Job,@JobEn,@DelegationSetting,@DelegationSettingEn,@Oper,@Opdate,@Isdel);SELECT @@IDENTITY"; SqlParameter[] parameter = new SqlParameter[]{ new SqlParameter("@Area",Dov.Area), new SqlParameter("@Job",Dov.Job), new SqlParameter("@JobEn",Dov.JobEn), new SqlParameter("@DelegationSetting",Dov.DelegationSetting), new SqlParameter("@DelegationSettingEn",Dov.DelegationSettingEn), 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(DelegationEnData Dov) { string sql = "update DelegationEnData set Area=@Area,Job=@Job,JobEn=@JobEn,DelegationSetting=@DelegationSetting," + "DelegationSettingEn=@DelegationSettingEn,Oper=@Oper,Opdate=@Opdate,Isdel=@Isdel where Id = @Id"; SqlParameter[] parameter = new SqlParameter[]{ new SqlParameter("@Area",Dov.Area), new SqlParameter("@Job",Dov.Job), new SqlParameter("@JobEn",Dov.JobEn), new SqlParameter("@DelegationSetting",Dov.DelegationSetting), new SqlParameter("@DelegationSettingEn",Dov.DelegationSettingEn), 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 DelegationEnData set Isdel=1 where Id=@Id", CommandType.Text, new SqlParameter("@Id", id)) > 0) return true; return false; } /// /// 查找所有数据 - 分页 /// /// public List GetAllAskData(int pageIndex, out int sumPage, out int totalRecord, string Area, string Job) { string sqlwhere = "IsDel = 0 and Area like '%" + Area + "%' and Job like '%" + Job + "%'"; return PageBase.excutePageSql(new DelegationEnData(), "DelegationEnData", "DelegationEnData", "*", "id asc", sqlwhere, 10, pageIndex, out sumPage, out totalRecord); } public DelegationEnData getById(int id) { return excuteType("select * from DelegationEnData where Isdel=0 and Id=@id", new SqlParameter("@id", id)); } } }