123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Models;
- using System.Data.SqlClient;
- using System.Data;
- namespace DAL
- {
- /// <summary>
- /// 车/导游地接资料数据访问类
- /// </summary>
- public class TouristGuideGroundDataService
- {
- /// <summary>
- /// 查询所有
- /// </summary>
- /// <param name="sql">sql语句</param>
- /// <param name="param">可变参数数组</param>
- /// <returns>返回集合</returns>
- List<TouristGuideGroundData> excuteSql(string sql, params SqlParameter[] param)
- {
- return ServiceBase<TouristGuideGroundData>.excuteSql(new TouristGuideGroundData(), "TouristGuideGroundData", sql, CommandType.Text, param);
- }
- /// <summary>
- /// 获取单个对象
- /// </summary>
- /// <param name="sql">sql语句</param>
- /// <param name="param">可变参数数组</param>
- /// <returns>返回空或者单个对象</returns>
- TouristGuideGroundData excuteType(string sql, params SqlParameter[] param)
- {
- //查询结果放入对象集合
- List<TouristGuideGroundData> ctggdList = excuteSql(sql, param);
- //判断集合是否为空
- if (ctggdList == null || ctggdList.Count == 0)
- //返回null
- return null;
- //返回单个对象
- return ctggdList[0];
- }
- /// <summary>
- /// 根据编号查询对象信息
- /// </summary>
- /// <param name="id">对象编号</param>
- /// <returns>返回空或者单个对象信息</returns>
- public TouristGuideGroundData GetTouristGuideGroundDataByID(int id)
- {
- //调用获取单个对象的方法
- return excuteType("select * from TouristGuideGroundData where Id = @id and IsDel = 0", new SqlParameter("@id", id));
- }
- /// <summary>
- /// 获取全部
- /// </summary>
- /// <returns></returns>
- public List<TouristGuideGroundData> GetAll()
- {
- return excuteSql("select * from TouristGuideGroundData where IsDel = 0 order by id");
- }
- /// <summary>
- /// 查询信息
- /// </summary>
- /// <returns>返回空或者单个对象信息</returns>
- public List<TouristGuideGroundData> GetTouristGuideGroundDataUnitArea(string unitArea)
- {
- //调用获取单个对象的方法
- return excuteSql("select * from TouristGuideGroundData where UnitArea like '%" + unitArea + "%'");
- }
- /// <summary>
- /// 查询对象信息
- /// </summary>
- /// <param name="city">所在城市</param>
- /// <param name="name">酒店名称</param>
- /// <returns>返回空或者单个对象信息</returns>
- public TouristGuideGroundData GetTouristGuideGroundData(string Contact, string Tel)
- {
- //调用获取单个对象的方法
- return excuteType("select * from TouristGuideGroundData where Contact = @Contact and Tel = @Tel and IsDel = 0", new SqlParameter("@Contact", Contact), new SqlParameter("@Tel", Tel));
- }
- /// <summary>
- /// 查询对象信息
- /// </summary>
- /// <param name="city">所在城市</param>
- /// <param name="name">酒店名称</param>
- /// <returns>返回空或者单个对象信息</returns>
- public TouristGuideGroundData GetTouristGuideGroundDataByUnitNameAndTel(string unitName, string tel)
- {
- //调用获取单个对象的方法
- return excuteType("select * from TouristGuideGroundData where UnitName = @UnitName and Tel = @Tel and IsDel = 0", new SqlParameter("@UnitName", unitName), new SqlParameter("@Tel", tel));
- }
- /// <summary>
- /// 获取全部 - 分页
- /// </summary>
- /// <returns></returns>
- public List<TouristGuideGroundData> GetTouristGuideGroundData(int pageIndex, out int sumPage, out int totalRecord, string unitArea, string unitName, string contact, string tel)
- {
- string sqlwhere = "IsDel = 0 and UnitArea like '%" + unitArea + "%' and UnitName like '%" + unitName + "%' and Contact like '%" + contact + "%' and Tel like '%" + tel + "%'";
- return PageBase<TouristGuideGroundData>.excutePageSql(new TouristGuideGroundData(), "TouristGuideGroundData", "TouristGuideGroundData", "*", "id desc", sqlwhere, 20, pageIndex, out sumPage, out totalRecord);
- }
- /// <summary>
- /// 增加
- /// </summary>
- /// <param name="cd"></param>
- /// <returns></returns>
- public bool AddTouristGuideGroundData(TouristGuideGroundData ctggd)
- {
- string sql = "insert into TouristGuideGroundData values(@StaffType,@UnitArea,@UnitName,@Address,@Contact,@Tel,@Email,@Fax,@OtherInformation,@CompanyOrGuide,@Score,"
- + "@SuitScore,@ServeScore,@TalkProScore,@TimeScore,@FitScore,@StrainScore,@LocalAndChineseScore,@Operator,@OperatorDate,@IsDel)";
- SqlParameter[] parameter = new SqlParameter[]{
- new SqlParameter("@StaffType",ctggd.StaffType),
- new SqlParameter("@UnitArea",ctggd.UnitArea),
- new SqlParameter("@UnitName",ctggd.UnitName),
- new SqlParameter("@Address",ctggd.Address),
- new SqlParameter("@Contact",ctggd.Contact),
- new SqlParameter("@Tel",ctggd.Tel),
- new SqlParameter("@Email",ctggd.Email),
- new SqlParameter("@Fax",ctggd.Fax),
- new SqlParameter("@OtherInformation",ctggd.OtherInformation),
- new SqlParameter("@CompanyOrGuide",ctggd.CompanyOrGuide),
- new SqlParameter("@Score",ctggd.Score),
- new SqlParameter("@SuitScore",ctggd.SuitScore),
- new SqlParameter("@ServeScore",ctggd.ServeScore),
- new SqlParameter("@TalkProScore",ctggd.TalkProScore),
- new SqlParameter("@TimeScore",ctggd.TimeScore),
- new SqlParameter("@FitScore",ctggd.FitScore),
- new SqlParameter("@StrainScore",ctggd.StrainScore),
- new SqlParameter("@LocalAndChineseScore",ctggd.LocalAndChineseScore),
- new SqlParameter("@Operator",ctggd.Operators),
- new SqlParameter("@OperatorDate",ctggd.OperatorsDate),
- new SqlParameter("@IsDel",ctggd.IsDel)
- };
- if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
- return true;
- return false;
- }
- /// <summary>
- /// 增加 返回id
- /// </summary>
- /// <param name="cd"></param>
- /// <returns></returns>
- public bool AddTouristGuideGroundDataReturnId(TouristGuideGroundData ctggd, out int id)
- {
- string sql = "insert into TouristGuideGroundData values(@StaffType,@UnitArea,@UnitName,@Address,@Contact,@Tel,@Email,@Fax,@OtherInformation,@CompanyOrGuide,@Score,"
- + "@SuitScore,@ServeScore,@TalkProScore,@TimeScore,@FitScore,@StrainScore,@LocalAndChineseScore,@Operator,@OperatorDate,@IsDel);SELECT @@IDENTITY";
- SqlParameter[] parameter = new SqlParameter[]{
- new SqlParameter("@StaffType",ctggd.StaffType),
- new SqlParameter("@UnitArea",ctggd.UnitArea),
- new SqlParameter("@UnitName",ctggd.UnitName),
- new SqlParameter("@Address",ctggd.Address),
- new SqlParameter("@Contact",ctggd.Contact),
- new SqlParameter("@Tel",ctggd.Tel),
- new SqlParameter("@Email",ctggd.Email),
- new SqlParameter("@Fax",ctggd.Fax),
- new SqlParameter("@OtherInformation",ctggd.OtherInformation),
- new SqlParameter("@CompanyOrGuide",ctggd.CompanyOrGuide),
- new SqlParameter("@Score",ctggd.Score),
- new SqlParameter("@SuitScore",ctggd.SuitScore),
- new SqlParameter("@ServeScore",ctggd.ServeScore),
- new SqlParameter("@TalkProScore",ctggd.TalkProScore),
- new SqlParameter("@TimeScore",ctggd.TimeScore),
- new SqlParameter("@FitScore",ctggd.FitScore),
- new SqlParameter("@StrainScore",ctggd.StrainScore),
- new SqlParameter("@LocalAndChineseScore",ctggd.LocalAndChineseScore),
- new SqlParameter("@Operator",ctggd.Operators),
- new SqlParameter("@OperatorDate",ctggd.OperatorsDate),
- new SqlParameter("@IsDel",ctggd.IsDel)
- };
- int obj = Convert.ToInt32(SqlHelper.ExecuteScalar(sql, CommandType.Text, parameter));
- if (obj > 0)
- {
- id = obj;
- return true;
- }
- else
- {
- id = 0;
- return false;
- }
- //if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
- // return true;
- //return false;
- }
- /// <summary>
- /// 编辑
- /// </summary>
- /// <param name="sdt"></param>
- /// <returns></returns>
- public bool EditTouristGuideGroundData(TouristGuideGroundData ctggd)
- {
- string sql = "update TouristGuideGroundData set StaffType=@StaffType,UnitArea = @UnitArea,UnitName = @UnitName,Address = @Address,Contact = @Contact,Tel = @Tel,Email = @Email,Fax = @Fax,"
- + "OtherInformation = @OtherInformation,CompanyOrGuide = @CompanyOrGuide,Score = @Score,"
- + "SuitScore=@SuitScore,ServeScore=@ServeScore,TalkProScore=@TalkProScore,TimeScore=@TimeScore,FitScore=@FitScore,StrainScore=@StrainScore,LocalAndChineseScore=@LocalAndChineseScore,"
- + "Operator = @Operator,OperatorDate = @OperatorDate where Id = @Id";
- SqlParameter[] parameter = new SqlParameter[]{
- new SqlParameter("@StaffType",ctggd.StaffType),
- new SqlParameter("@UnitArea",ctggd.UnitArea),
- new SqlParameter("@UnitName",ctggd.UnitName),
- new SqlParameter("@Address",ctggd.Address),
- new SqlParameter("@Contact",ctggd.Contact),
- new SqlParameter("@Tel",ctggd.Tel),
- new SqlParameter("@Email",ctggd.Email),
- new SqlParameter("@Fax",ctggd.Fax),
- new SqlParameter("@OtherInformation",ctggd.OtherInformation),
- new SqlParameter("@CompanyOrGuide",ctggd.CompanyOrGuide),
- new SqlParameter("@Score",ctggd.Score),
- new SqlParameter("@SuitScore",ctggd.SuitScore),
- new SqlParameter("@ServeScore",ctggd.ServeScore),
- new SqlParameter("@TalkProScore",ctggd.TalkProScore),
- new SqlParameter("@TimeScore",ctggd.TimeScore),
- new SqlParameter("@FitScore",ctggd.FitScore),
- new SqlParameter("@StrainScore",ctggd.StrainScore),
- new SqlParameter("@LocalAndChineseScore",ctggd.LocalAndChineseScore),
- new SqlParameter("@Operator",ctggd.Operators),
- new SqlParameter("@OperatorDate",ctggd.OperatorsDate),
- new SqlParameter("@Id",ctggd.Id)
- };
- if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
- return true;
- return false;
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- public bool DelTouristGuideGroundData(int id)
- {
- if (SqlHelper.ExecuteNonQuery("update TouristGuideGroundData set IsDel = 1 where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
- return true;
- return false;
- }
- }
- }
|