AirTicketAgentService.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. public class AirTicketAgentService
  11. {
  12. List<AirTicketAgent> excuteSql(string sql, params SqlParameter[] param)
  13. {
  14. return ServiceBase<AirTicketAgent>.excuteSql(new AirTicketAgent(), "AirTicketAgent", sql, CommandType.Text, param);
  15. }
  16. AirTicketAgent excuteType(string sql, params SqlParameter[] param)
  17. {
  18. //查询结果放入对象集合
  19. List<AirTicketAgent> hdList = excuteSql(sql, param);
  20. //判断集合是否为空
  21. if (hdList == null || hdList.Count == 0)
  22. //返回null
  23. return null;
  24. //返回单个对象
  25. return hdList[0];
  26. }
  27. /// <summary>
  28. /// 查询所有
  29. /// </summary>
  30. /// <returns></returns>
  31. public AirTicketAgent GetById(int id)
  32. {
  33. return excuteType("select * from AirTicketAgent where Isdel=0 and Id="+id);
  34. }
  35. /// <summary>
  36. /// 查找所有数据 - 分页
  37. /// </summary>
  38. /// <returns></returns>
  39. public List<AirTicketAgent> GetAll(int pageIndex, out int sumPage, out int totalRecord, string Name)
  40. {
  41. string sqlwhere = "IsDel = 0 and Name like '%" + Name + "%'";
  42. return PageBase<AirTicketAgent>.excutePageSql(new AirTicketAgent(), "AirTicketAgent", "AirTicketAgent", "*", "id asc", sqlwhere, 10, pageIndex, out sumPage, out totalRecord);
  43. }
  44. //增Add
  45. public bool Add(AirTicketAgent Dov)
  46. {
  47. string sql = "insert into AirTicketAgent values(@DeleName,@Account,@Bank,@OPer,@OPdate,@Isdel);SELECT @@IDENTITY";
  48. SqlParameter[] parameter = new SqlParameter[]{
  49. new SqlParameter("@DeleName",Dov.Name),
  50. new SqlParameter("@Account",Dov.Account),
  51. new SqlParameter("@Bank",Dov.Bank),
  52. new SqlParameter("@OPer",Dov.OPer),
  53. new SqlParameter("@OPdate",Dov.OPdate),
  54. new SqlParameter("@Isdel",Dov.Isdel)
  55. };
  56. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  57. return true;
  58. return false;
  59. }
  60. //改Update
  61. public bool Edit(AirTicketAgent Dov)
  62. {
  63. string sql = "update AirTicketAgent set DeleName=@DeleName,Account=@Account,Bank=@Bank,OPer=@OPer,OPdate=@OPdate, Isdel=@Isdel where Id = @Id";
  64. SqlParameter[] parameter = new SqlParameter[]{
  65. new SqlParameter("@DeleName",Dov.Name),
  66. new SqlParameter("@Account",Dov.Account),
  67. new SqlParameter("@Bank",Dov.Bank),
  68. new SqlParameter("@OPer",Dov.OPer),
  69. new SqlParameter("@OPdate",Dov.OPdate),
  70. new SqlParameter("@Isdel",Dov.Isdel),
  71. new SqlParameter("@Id",Dov.Id)
  72. };
  73. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  74. return true;
  75. return false;
  76. }
  77. //删
  78. public bool delOA(int id)
  79. {
  80. if (SqlHelper.ExecuteNonQuery("update AirTicketAgent set Isdel=1 where Id=@Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
  81. return true;
  82. return false;
  83. }
  84. public List<AirTicketAgent> GetByNameAndAccount(string name, string account)
  85. {
  86. return excuteSql("select * from AirTicketAgent where Isdel=0 and Name=" + name + " and Account=" + account);
  87. }
  88. public List<AirTicketAgent> GetAll()
  89. {
  90. return excuteSql("select * from AirTicketAgent where isdel = 0 and OPer != '' ");
  91. }
  92. }
  93. }