123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Models;
- using System.Data;
- using System.Data.SqlClient;
- namespace DAL
- {
- /// <summary>
- /// 等级信息数据访问层
- /// </summary>
- public class LevelService
- {
- /// <summary>
- /// 查询所有等级信息数据
- /// </summary>
- /// <param name="pageIndex"></param>
- /// <param name="sumPage"></param>
- /// <param name="totalRecord"></param>
- /// <returns></returns>
- public object GetAll(int pageIndex, out int sumPage, out int totalRecord,string Did,string Cid)
- {
- string sqlwhere = " Did="+Did+" and IsDel = 0 and Cid="+Cid;
- return PageBase<Level>.excutePageSql(new Level(), "Level", "Level", "*", "id asc", sqlwhere, 10, pageIndex, out sumPage, out totalRecord);
- }
- /// <summary>
- /// 新增等级信息
- /// </summary>
- /// <param name="level">等级信息实体</param>
- /// <returns></returns>
- public bool AddLevel(Level level)
- {
- string sql = "insert into Level values(@Lid,@LName,@Profit,@Rebate,@Tax,@Did,@IsDel,@Cid)";
- SqlParameter[] parameter = new SqlParameter[]{
- new SqlParameter("@Lid",level.Lid),
- new SqlParameter("@LName",level.LName),
- new SqlParameter("@Profit",level.Profit),
- new SqlParameter("@Rebate",level.Rebate),
- new SqlParameter("@Tax",level.Tax),
- new SqlParameter("@Did",level.Did),
- new SqlParameter("@IsDel",level.IsDel),
- new SqlParameter("@Cid",level.Cid)
- };
- if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
- return true;
- return false;
- }
- /// <summary>
- /// 根据编号查询实体
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- public Level GetSetDataByID(int id)
- {
- //调用获取单个对象的方法
- return excuteType("select * from Level where Id = @id and IsDel = 0", new SqlParameter("@id", id));
- }
- /// <summary>
- /// 获取单个对象
- /// </summary>
- /// <param name="sql">sql语句</param>
- /// <param name="param">可变参数数组</param>
- /// <returns>返回空或者单个对象</returns>
- private Level excuteType(string sql, SqlParameter param)
- {
- //查询结果放入对象集合
- List<Level> LevelList = excuteSql(sql, param);
- //判断集合是否为空
- if (LevelList == null || LevelList.Count == 0)
- //返回null
- return null;
- //返回单个对象
- return LevelList[0];
- }
- /// <summary>
- /// 查询所有
- /// </summary>
- /// <param name="sql">sql语句</param>
- /// <param name="param">可变参数数组</param>
- /// <returns>返回集合</returns>
- List<Level> excuteSql(string sql, params SqlParameter[] param)
- {
- return ServiceBase<Level>.excuteSql(new Level(), "Level", sql, CommandType.Text, param);
- }
- /// <summary>
- /// 根据id修改level表数据
- /// </summary>
- /// <param name="level"></param>
- /// <returns></returns>
- public bool EditLevel(Level level)
- {
- string sql = "update Level set Lid = @Lid ,LName = @LName ,Profit = @Profit,Rebate = @Rebate,Tax = @Tax,Did = @Did,Cid=@Cid where Id = @Id";
- SqlParameter[] parameter = new SqlParameter[]{
- new SqlParameter("@Lid",level.Lid),
- new SqlParameter("@LName",level.LName),
- new SqlParameter("@Profit",level.Profit),
- new SqlParameter("@Rebate",level.Rebate),
- new SqlParameter("@Tax",level.Tax),
- new SqlParameter("@Did",level.Did),
- new SqlParameter("@IsDel",level.IsDel),
- new SqlParameter("@Id",level.Id),
- new SqlParameter("@Cid",level.Cid)
- };
- if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
- return true;
- return false;
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- public bool DelSetData(int id)
- {
- if (SqlHelper.ExecuteNonQuery("update Level set IsDel = 1 where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
- return true;
- return false;
- }
- /// <summary>
- /// 根据航空公司id和等级id查询等级信息
- /// </summary>
- /// <param name="p"></param>
- /// <returns></returns>
- public Level GetOfferByLid(int Lid,int Cid)
- {
- //调用获取单个对象的方法
- return excuteType("select * from Level where Lid = @Lid and Cid="+Cid+" and IsDel = 0", new SqlParameter("@Lid", Lid));
- }
- }
- }
|