123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- 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 AirCompanyServcies
- {
- List<AirCompany> excuteSql(string sql, params SqlParameter[] param)
- {
- return ServiceBase<AirCompany>.excuteSql(new AirCompany(), "AirCompany", sql, CommandType.Text, param);
- }
- AirCompany excuteType(string sql, params SqlParameter[] param)
- {
- //查询结果放入对象集合
- List<AirCompany> hdList = excuteSql(sql, param);
- AirCompany air = new AirCompany();
- //判断集合是否为空
- if (hdList == null || hdList.Count == 0)
- {
- //返回null
- air.CnName = "该航司尚未收录";
- return air;
- }
- //返回单个对象
- return hdList[0];
- }
- public AirCompany getByShortCode(string ShortCode)
- {
- return this.excuteType("select * from AirCompany where Isdel=0 and ShortCode=@ShortCode", new SqlParameter("@ShortCode", ShortCode.ToUpper()));
- }
- public AirCompany getById(string Id)
- {
- return this.excuteType("select * from AirCompany where Isdel=0 and Id=" + Id);
- }
- /// <summary>
- /// 查找所有数据 - 分页
- /// </summary>
- /// <returns></returns>
- public List<AirCompany> GetAll(int pageIndex, out int sumPage, out int totalRecord, string ShortCode)
- {
- string sqlwhere = "IsDel = 0 and ShortCode like '%" + ShortCode + "%'";
- return PageBase<AirCompany>.excutePageSql(new AirCompany(), "AirCompany", "AirCompany", "*", "id asc", sqlwhere, 10, pageIndex, out sumPage, out totalRecord);
- }
- /// <summary>
- /// 增加
- /// </summary>
- /// <param name="cd"></param>
- /// <returns></returns>
- public bool Add(AirCompany hd)
- {
- string sql = "insert into AirCompany values(@ShortCode,@CnName,@EnName,@OPer,@OPDate,@Isdel)";
- SqlParameter[] parameter = new SqlParameter[]{
- new SqlParameter("@ShortCode",hd.ShortCode),
- new SqlParameter("@CnName",hd.CnName),
- new SqlParameter("@EnName",hd.EnName),
- new SqlParameter("@OPer",hd.OPer),
- new SqlParameter("@OPDate",hd.OPDate),
- new SqlParameter("@Isdel",hd.Isdel)
- };
- if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
- return true;
- return false;
- }
- /// <summary>
- /// 编辑
- /// </summary>
- /// <param name="sdt"></param>
- /// <returns></returns>
- public bool Edit(AirCompany hd)
- {
- string sql = "update AirCompany set ShortCode=@ShortCode,CnName=@CnName,EnName=@EnName,"
- + "OPer=@OPer,OPDate=@OPDate,Isdel=@Isdel where Id = @Id";
- SqlParameter[] parameter = new SqlParameter[]{
- new SqlParameter("@ShortCode",hd.ShortCode),
- new SqlParameter("@CnName",hd.CnName),
- new SqlParameter("@EnName",hd.EnName),
- new SqlParameter("@OPer",hd.OPer),
- new SqlParameter("@OPDate",hd.OPDate),
- new SqlParameter("@Isdel",hd.Isdel),
- new SqlParameter("@Id",hd.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 AirCompany set IsDel = 1 where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
- return true;
- return false;
- }
- }
- }
|