using System; using System.Collections.Generic; using System.Linq; using System.Text; using Models; using System.Data.SqlClient; using System.Data; namespace DAL { /// /// 车/导游地接资料数据访问类 /// public class TouristGuideGroundDataService { /// /// 查询所有 /// /// sql语句 /// 可变参数数组 /// 返回集合 List excuteSql(string sql, params SqlParameter[] param) { return ServiceBase.excuteSql(new TouristGuideGroundData(), "TouristGuideGroundData", sql, CommandType.Text, param); } /// /// 获取单个对象 /// /// sql语句 /// 可变参数数组 /// 返回空或者单个对象 TouristGuideGroundData excuteType(string sql, params SqlParameter[] param) { //查询结果放入对象集合 List ctggdList = excuteSql(sql, param); //判断集合是否为空 if (ctggdList == null || ctggdList.Count == 0) //返回null return null; //返回单个对象 return ctggdList[0]; } /// /// 根据编号查询对象信息 /// /// 对象编号 /// 返回空或者单个对象信息 public TouristGuideGroundData GetTouristGuideGroundDataByID(int id) { //调用获取单个对象的方法 return excuteType("select * from TouristGuideGroundData where Id = @id and IsDel = 0", new SqlParameter("@id", id)); } /// /// 获取全部 /// /// public List GetAll() { return excuteSql("select * from TouristGuideGroundData where IsDel = 0 order by id"); } /// /// 查询信息 /// /// 返回空或者单个对象信息 public List GetTouristGuideGroundDataUnitArea(string unitArea) { //调用获取单个对象的方法 return excuteSql("select * from TouristGuideGroundData where UnitArea like '%" + unitArea + "%'"); } /// /// 查询对象信息 /// /// 所在城市 /// 酒店名称 /// 返回空或者单个对象信息 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)); } /// /// 查询对象信息 /// /// 所在城市 /// 酒店名称 /// 返回空或者单个对象信息 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)); } /// /// 获取全部 - 分页 /// /// public List 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.excutePageSql(new TouristGuideGroundData(), "TouristGuideGroundData", "TouristGuideGroundData", "*", "id desc", sqlwhere, 20, pageIndex, out sumPage, out totalRecord); } /// /// 增加 /// /// /// 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; } /// /// 增加 返回id /// /// /// 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; } /// /// 编辑 /// /// /// 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; } /// /// 删除 /// /// /// 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; } } }