TouristGuideGroundDataService.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Models;
  6. using System.Data.SqlClient;
  7. using System.Data;
  8. namespace DAL
  9. {
  10. /// <summary>
  11. /// 车/导游地接资料数据访问类
  12. /// </summary>
  13. public class TouristGuideGroundDataService
  14. {
  15. /// <summary>
  16. /// 查询所有
  17. /// </summary>
  18. /// <param name="sql">sql语句</param>
  19. /// <param name="param">可变参数数组</param>
  20. /// <returns>返回集合</returns>
  21. List<TouristGuideGroundData> excuteSql(string sql, params SqlParameter[] param)
  22. {
  23. return ServiceBase<TouristGuideGroundData>.excuteSql(new TouristGuideGroundData(), "TouristGuideGroundData", sql, CommandType.Text, param);
  24. }
  25. /// <summary>
  26. /// 获取单个对象
  27. /// </summary>
  28. /// <param name="sql">sql语句</param>
  29. /// <param name="param">可变参数数组</param>
  30. /// <returns>返回空或者单个对象</returns>
  31. TouristGuideGroundData excuteType(string sql, params SqlParameter[] param)
  32. {
  33. //查询结果放入对象集合
  34. List<TouristGuideGroundData> ctggdList = excuteSql(sql, param);
  35. //判断集合是否为空
  36. if (ctggdList == null || ctggdList.Count == 0)
  37. //返回null
  38. return null;
  39. //返回单个对象
  40. return ctggdList[0];
  41. }
  42. /// <summary>
  43. /// 根据编号查询对象信息
  44. /// </summary>
  45. /// <param name="id">对象编号</param>
  46. /// <returns>返回空或者单个对象信息</returns>
  47. public TouristGuideGroundData GetTouristGuideGroundDataByID(int id)
  48. {
  49. //调用获取单个对象的方法
  50. return excuteType("select * from TouristGuideGroundData where Id = @id and IsDel = 0", new SqlParameter("@id", id));
  51. }
  52. /// <summary>
  53. /// 获取全部
  54. /// </summary>
  55. /// <returns></returns>
  56. public List<TouristGuideGroundData> GetAll()
  57. {
  58. return excuteSql("select * from TouristGuideGroundData where IsDel = 0 order by id");
  59. }
  60. /// <summary>
  61. /// 查询信息
  62. /// </summary>
  63. /// <returns>返回空或者单个对象信息</returns>
  64. public List<TouristGuideGroundData> GetTouristGuideGroundDataUnitArea(string unitArea)
  65. {
  66. //调用获取单个对象的方法
  67. return excuteSql("select * from TouristGuideGroundData where UnitArea like '%" + unitArea + "%'");
  68. }
  69. /// <summary>
  70. /// 查询对象信息
  71. /// </summary>
  72. /// <param name="city">所在城市</param>
  73. /// <param name="name">酒店名称</param>
  74. /// <returns>返回空或者单个对象信息</returns>
  75. public TouristGuideGroundData GetTouristGuideGroundData(string Contact, string Tel)
  76. {
  77. //调用获取单个对象的方法
  78. return excuteType("select * from TouristGuideGroundData where Contact = @Contact and Tel = @Tel and IsDel = 0", new SqlParameter("@Contact", Contact), new SqlParameter("@Tel", Tel));
  79. }
  80. /// <summary>
  81. /// 查询对象信息
  82. /// </summary>
  83. /// <param name="city">所在城市</param>
  84. /// <param name="name">酒店名称</param>
  85. /// <returns>返回空或者单个对象信息</returns>
  86. public TouristGuideGroundData GetTouristGuideGroundDataByUnitNameAndTel(string unitName, string tel)
  87. {
  88. //调用获取单个对象的方法
  89. return excuteType("select * from TouristGuideGroundData where UnitName = @UnitName and Tel = @Tel and IsDel = 0", new SqlParameter("@UnitName", unitName), new SqlParameter("@Tel", tel));
  90. }
  91. /// <summary>
  92. /// 获取全部 - 分页
  93. /// </summary>
  94. /// <returns></returns>
  95. public List<TouristGuideGroundData> GetTouristGuideGroundData(int pageIndex, out int sumPage, out int totalRecord, string unitArea, string unitName, string contact, string tel)
  96. {
  97. string sqlwhere = "IsDel = 0 and UnitArea like '%" + unitArea + "%' and UnitName like '%" + unitName + "%' and Contact like '%" + contact + "%' and Tel like '%" + tel + "%'";
  98. return PageBase<TouristGuideGroundData>.excutePageSql(new TouristGuideGroundData(), "TouristGuideGroundData", "TouristGuideGroundData", "*", "id desc", sqlwhere, 20, pageIndex, out sumPage, out totalRecord);
  99. }
  100. /// <summary>
  101. /// 增加
  102. /// </summary>
  103. /// <param name="cd"></param>
  104. /// <returns></returns>
  105. public bool AddTouristGuideGroundData(TouristGuideGroundData ctggd)
  106. {
  107. string sql = "insert into TouristGuideGroundData values(@StaffType,@UnitArea,@UnitName,@Address,@Contact,@Tel,@Email,@Fax,@OtherInformation,@CompanyOrGuide,@Score,"
  108. + "@SuitScore,@ServeScore,@TalkProScore,@TimeScore,@FitScore,@StrainScore,@LocalAndChineseScore,@Operator,@OperatorDate,@IsDel)";
  109. SqlParameter[] parameter = new SqlParameter[]{
  110. new SqlParameter("@StaffType",ctggd.StaffType),
  111. new SqlParameter("@UnitArea",ctggd.UnitArea),
  112. new SqlParameter("@UnitName",ctggd.UnitName),
  113. new SqlParameter("@Address",ctggd.Address),
  114. new SqlParameter("@Contact",ctggd.Contact),
  115. new SqlParameter("@Tel",ctggd.Tel),
  116. new SqlParameter("@Email",ctggd.Email),
  117. new SqlParameter("@Fax",ctggd.Fax),
  118. new SqlParameter("@OtherInformation",ctggd.OtherInformation),
  119. new SqlParameter("@CompanyOrGuide",ctggd.CompanyOrGuide),
  120. new SqlParameter("@Score",ctggd.Score),
  121. new SqlParameter("@SuitScore",ctggd.SuitScore),
  122. new SqlParameter("@ServeScore",ctggd.ServeScore),
  123. new SqlParameter("@TalkProScore",ctggd.TalkProScore),
  124. new SqlParameter("@TimeScore",ctggd.TimeScore),
  125. new SqlParameter("@FitScore",ctggd.FitScore),
  126. new SqlParameter("@StrainScore",ctggd.StrainScore),
  127. new SqlParameter("@LocalAndChineseScore",ctggd.LocalAndChineseScore),
  128. new SqlParameter("@Operator",ctggd.Operators),
  129. new SqlParameter("@OperatorDate",ctggd.OperatorsDate),
  130. new SqlParameter("@IsDel",ctggd.IsDel)
  131. };
  132. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  133. return true;
  134. return false;
  135. }
  136. /// <summary>
  137. /// 增加 返回id
  138. /// </summary>
  139. /// <param name="cd"></param>
  140. /// <returns></returns>
  141. public bool AddTouristGuideGroundDataReturnId(TouristGuideGroundData ctggd, out int id)
  142. {
  143. string sql = "insert into TouristGuideGroundData values(@StaffType,@UnitArea,@UnitName,@Address,@Contact,@Tel,@Email,@Fax,@OtherInformation,@CompanyOrGuide,@Score,"
  144. + "@SuitScore,@ServeScore,@TalkProScore,@TimeScore,@FitScore,@StrainScore,@LocalAndChineseScore,@Operator,@OperatorDate,@IsDel);SELECT @@IDENTITY";
  145. SqlParameter[] parameter = new SqlParameter[]{
  146. new SqlParameter("@StaffType",ctggd.StaffType),
  147. new SqlParameter("@UnitArea",ctggd.UnitArea),
  148. new SqlParameter("@UnitName",ctggd.UnitName),
  149. new SqlParameter("@Address",ctggd.Address),
  150. new SqlParameter("@Contact",ctggd.Contact),
  151. new SqlParameter("@Tel",ctggd.Tel),
  152. new SqlParameter("@Email",ctggd.Email),
  153. new SqlParameter("@Fax",ctggd.Fax),
  154. new SqlParameter("@OtherInformation",ctggd.OtherInformation),
  155. new SqlParameter("@CompanyOrGuide",ctggd.CompanyOrGuide),
  156. new SqlParameter("@Score",ctggd.Score),
  157. new SqlParameter("@SuitScore",ctggd.SuitScore),
  158. new SqlParameter("@ServeScore",ctggd.ServeScore),
  159. new SqlParameter("@TalkProScore",ctggd.TalkProScore),
  160. new SqlParameter("@TimeScore",ctggd.TimeScore),
  161. new SqlParameter("@FitScore",ctggd.FitScore),
  162. new SqlParameter("@StrainScore",ctggd.StrainScore),
  163. new SqlParameter("@LocalAndChineseScore",ctggd.LocalAndChineseScore),
  164. new SqlParameter("@Operator",ctggd.Operators),
  165. new SqlParameter("@OperatorDate",ctggd.OperatorsDate),
  166. new SqlParameter("@IsDel",ctggd.IsDel)
  167. };
  168. int obj = Convert.ToInt32(SqlHelper.ExecuteScalar(sql, CommandType.Text, parameter));
  169. if (obj > 0)
  170. {
  171. id = obj;
  172. return true;
  173. }
  174. else
  175. {
  176. id = 0;
  177. return false;
  178. }
  179. //if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  180. // return true;
  181. //return false;
  182. }
  183. /// <summary>
  184. /// 编辑
  185. /// </summary>
  186. /// <param name="sdt"></param>
  187. /// <returns></returns>
  188. public bool EditTouristGuideGroundData(TouristGuideGroundData ctggd)
  189. {
  190. string sql = "update TouristGuideGroundData set StaffType=@StaffType,UnitArea = @UnitArea,UnitName = @UnitName,Address = @Address,Contact = @Contact,Tel = @Tel,Email = @Email,Fax = @Fax,"
  191. + "OtherInformation = @OtherInformation,CompanyOrGuide = @CompanyOrGuide,Score = @Score,"
  192. + "SuitScore=@SuitScore,ServeScore=@ServeScore,TalkProScore=@TalkProScore,TimeScore=@TimeScore,FitScore=@FitScore,StrainScore=@StrainScore,LocalAndChineseScore=@LocalAndChineseScore,"
  193. + "Operator = @Operator,OperatorDate = @OperatorDate where Id = @Id";
  194. SqlParameter[] parameter = new SqlParameter[]{
  195. new SqlParameter("@StaffType",ctggd.StaffType),
  196. new SqlParameter("@UnitArea",ctggd.UnitArea),
  197. new SqlParameter("@UnitName",ctggd.UnitName),
  198. new SqlParameter("@Address",ctggd.Address),
  199. new SqlParameter("@Contact",ctggd.Contact),
  200. new SqlParameter("@Tel",ctggd.Tel),
  201. new SqlParameter("@Email",ctggd.Email),
  202. new SqlParameter("@Fax",ctggd.Fax),
  203. new SqlParameter("@OtherInformation",ctggd.OtherInformation),
  204. new SqlParameter("@CompanyOrGuide",ctggd.CompanyOrGuide),
  205. new SqlParameter("@Score",ctggd.Score),
  206. new SqlParameter("@SuitScore",ctggd.SuitScore),
  207. new SqlParameter("@ServeScore",ctggd.ServeScore),
  208. new SqlParameter("@TalkProScore",ctggd.TalkProScore),
  209. new SqlParameter("@TimeScore",ctggd.TimeScore),
  210. new SqlParameter("@FitScore",ctggd.FitScore),
  211. new SqlParameter("@StrainScore",ctggd.StrainScore),
  212. new SqlParameter("@LocalAndChineseScore",ctggd.LocalAndChineseScore),
  213. new SqlParameter("@Operator",ctggd.Operators),
  214. new SqlParameter("@OperatorDate",ctggd.OperatorsDate),
  215. new SqlParameter("@Id",ctggd.Id)
  216. };
  217. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  218. return true;
  219. return false;
  220. }
  221. /// <summary>
  222. /// 删除
  223. /// </summary>
  224. /// <param name="id"></param>
  225. /// <returns></returns>
  226. public bool DelTouristGuideGroundData(int id)
  227. {
  228. if (SqlHelper.ExecuteNonQuery("update TouristGuideGroundData set IsDel = 1 where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
  229. return true;
  230. return false;
  231. }
  232. }
  233. }