123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- 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 ThreeCodeServices
- {
- List<ThreeCode> excuteSql(string sql, params SqlParameter[] param)
- {
- return ServiceBase<ThreeCode>.excuteSql(new ThreeCode(), "ThreeCode", sql, CommandType.Text, param);
- }
- ThreeCode excuteType(string sql, params SqlParameter[] param)
- {
- //查询结果放入对象集合
- List<ThreeCode> hdList = excuteSql(sql, param);
- //判断集合是否为空
- if (hdList == null || hdList.Count == 0)
- //返回null
- return null;
- //返回单个对象
- return hdList[0];
- }
- public ThreeCode getByThree(string three)
- {
- return this.excuteType("select * from ThreeCode where Isdel=0 and Three=@Three", new SqlParameter("@Three", three.ToUpper()));
- }
- //public ThreeCode getByCountry(string country)
- //{
- // return this.excuteType("select * from ThreeCode where Isdel=0 and country='"+country+"'");
- //}
- public List<ThreeCode> getByCountry(string country)
- {
- return this.excuteSql("select * from ThreeCode where Isdel=0 and country='" + country + "'");
- }
- public List<ThreeCode> getByCity(string city)
- {
- return this.excuteSql("select * from ThreeCode where Isdel=0 and City='" + city + "'");
- }
- public ThreeCode getById(string Id)
- {
- return this.excuteType("select * from ThreeCode where Isdel=0 and Id=" + Id);
- }
- /// <summary>
- /// 查找所有数据 - 分页
- /// </summary>
- /// <returns></returns>
- public List<ThreeCode> GetAll(int pageIndex, out int sumPage, out int totalRecord, string Three,string City)
- {
- string sqlwhere = "IsDel = 0 and Three like '%" + Three + "%'"+ "and City like '%" + City + "%'";
- return PageBase<ThreeCode>.excutePageSql(new ThreeCode(), "ThreeCode", "ThreeCode", "*", "id asc", sqlwhere, 10, pageIndex, out sumPage, out totalRecord);
- }
- /// <summary>
- /// 查找所有数据 - 国家
- /// </summary>
- /// <returns></returns>
- public List<ThreeCode> GetAllCountry()
- {
- return excuteSql("select * from ThreeCode where IsDel = 0");
- }
- /// <summary>
- /// 增加
- /// </summary>
- /// <param name="cd"></param>
- /// <returns></returns>
- public bool Add(ThreeCode hd)
- {
- string sql = "insert into ThreeCode values(@Three,@Four,@Country,@City,@AirPort,@AirPort_En,@OPer,@OPDate,@Isdel)";
- SqlParameter[] parameter = new SqlParameter[]{
- new SqlParameter("@Three",hd.Three),
- new SqlParameter("@Four",hd.Four),
- new SqlParameter("@Country",hd.Country),
- new SqlParameter("@City",hd.City),
- new SqlParameter("@AirPort",hd.AirPort),
- new SqlParameter("@AirPort_En",hd.AirPort_En),
- 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(ThreeCode hd)
- {
- string sql = "update ThreeCode set Three=@Three,Four=@Four,Country=@Country,City=@City,AirPort=@AirPort,"
- + "AirPort_En=@AirPort_En,OPer=@OPer,OPDate=@OPDate,Isdel=@Isdel where Id = @Id";
- SqlParameter[] parameter = new SqlParameter[]{
- new SqlParameter("@Three",hd.Three),
- new SqlParameter("@Four",hd.Four),
- new SqlParameter("@Country",hd.Country),
- new SqlParameter("@City",hd.City),
- new SqlParameter("@AirPort",hd.AirPort),
- new SqlParameter("@AirPort_En",hd.AirPort_En),
- 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 ThreeCode set IsDel = 1 where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
- return true;
- return false;
- }
- }
- }
|