opitineraryService.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. using Models;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data.SqlClient;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace DAL
  10. {
  11. public class opitineraryService
  12. {
  13. List<opitineraryfixed> excuteSqlFi(string sql, params SqlParameter[] param)
  14. {
  15. return ServiceBase<opitineraryfixed>.excuteSql(new opitineraryfixed(), "opitineraryfixed", sql, CommandType.Text, param);
  16. }
  17. opitineraryfixed excuteTypeFi(string sql, params SqlParameter[] param)
  18. {
  19. //查询结果放入对象集合
  20. List<opitineraryfixed> hdList = excuteSqlFi(sql, param);
  21. opitineraryfixed air = new opitineraryfixed();
  22. //判断集合是否为空
  23. if (hdList == null || hdList.Count == 0)
  24. {
  25. return air;
  26. }
  27. //返回单个对象
  28. return hdList[0];
  29. }
  30. public opitineraryfixed getFiFirstData()
  31. {
  32. return this.excuteTypeFi("select * from opitineraryfixed", new SqlParameter[] {});
  33. }
  34. public bool EditFi(opitineraryfixed hd)
  35. {
  36. string sql = @"update opitineraryfixed
  37. set itemPrepare = @itemPrepare, specialReminder = @specialReminder, CGPrecautions = @CGPrecautions, YGCG = @YGCG, Conduct = @Conduct, CommonEnglish = @CommonEnglish
  38. where tid = 1";
  39. SqlParameter[] parameter = new SqlParameter[]{
  40. new SqlParameter("@itemPrepare",hd.ItemPrepare),
  41. new SqlParameter("@specialReminder",hd.SpecialReminder),
  42. new SqlParameter("@CGPrecautions",hd.CGPrecautions),
  43. new SqlParameter("@YGCG",hd.YGCG),
  44. new SqlParameter("@Conduct",hd.Conduct),
  45. new SqlParameter("@CommonEnglish",hd.CommonEnglish),
  46. };
  47. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  48. return true;
  49. return false;
  50. }
  51. List<opitinerarydata> excuteSqlDa(string sql, params SqlParameter[] param)
  52. {
  53. return ServiceBase<opitinerarydata>.excuteSql(new opitinerarydata(), "opitinerarydata", sql, CommandType.Text, param);
  54. }
  55. opitinerarydata excuteTypeDa(string sql, params SqlParameter[] param)
  56. {
  57. //查询结果放入对象集合
  58. List<opitinerarydata> hdList = excuteSqlDa(sql, param);
  59. opitinerarydata air = new opitinerarydata();
  60. //判断集合是否为空
  61. if (hdList == null || hdList.Count == 0)
  62. {
  63. return air;
  64. }
  65. //返回单个对象
  66. return hdList[0];
  67. }
  68. public opitinerarydata getDaFirstData(string Name)
  69. {
  70. return this.excuteTypeDa("select * from opitinerarydata where name = @name",
  71. new SqlParameter[] { new SqlParameter("@name",Name) });
  72. }
  73. /// <summary>
  74. /// 增加手册data表
  75. /// </summary>
  76. /// <param name="opda">data对象</param>
  77. /// <param name="sel">true为增加城市false增加国家</param>
  78. /// <returns></returns>
  79. public bool Add(opitinerarydata opda,bool sel)
  80. {
  81. string sql = @"insert into opitinerarydata ";
  82. SqlParameter[] parameter = new SqlParameter[]{
  83. new SqlParameter("@name",opda.Name),
  84. new SqlParameter("@Introduction",opda.Introduction),
  85. };
  86. if (sel)
  87. {
  88. sql += "(name,Introduction,timeDifference,currExchangeRate,temperature)" +
  89. " values(@name,@Introduction ,@timeDifference ,@currExchangeRate,@temperature)";
  90. var parameterList = parameter.ToList();
  91. parameterList.Add(new SqlParameter { ParameterName = "@timeDifference", Value = opda.TimeDifference });
  92. parameterList.Add(new SqlParameter { ParameterName = "@currExchangeRate", Value = opda.CurrExchangeRate });
  93. parameterList.Add(new SqlParameter { ParameterName = "@temperature", Value = opda.Temperature });
  94. parameter = parameterList.ToArray();
  95. }
  96. else
  97. {
  98. sql += "(name,Introduction)" +
  99. " values(@name,@Introduction)";
  100. }
  101. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  102. return true;
  103. return false;
  104. }
  105. public bool EditDa(opitinerarydata hd)
  106. {
  107. string sql = @"update opitinerarydata
  108. set Introduction = @Introduction , timeDifference =@timeDifference , currExchangeRate =@currExchangeRate , temperature =@temperature
  109. where name =@name";
  110. SqlParameter[] parameter = new SqlParameter[]{
  111. new SqlParameter("@Introduction",hd.Introduction),
  112. new SqlParameter("@timeDifference",hd.TimeDifference),
  113. new SqlParameter("@currExchangeRate",hd.CurrExchangeRate),
  114. new SqlParameter("@temperature",hd.Temperature),
  115. new SqlParameter("@name",hd.Name),
  116. };
  117. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  118. return true;
  119. return false;
  120. }
  121. }
  122. }