DelegationInfoOrFeeCostServcies.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Data.SqlClient;
  5. using System.Linq;
  6. using System.Text;
  7. using Models;
  8. namespace DAL
  9. {
  10. public class DelegationInfoOrFeeCostServcies
  11. {
  12. /// <summary>
  13. /// 查询所有
  14. /// </summary>
  15. /// <param name="sql">sql语句</param>
  16. /// <param name="param">可变参数数组</param>
  17. /// <returns>返回集合</returns>
  18. List<DelegationInfoOrFeeCost> excuteSql(string sql, params SqlParameter[] param)
  19. {
  20. return ServiceBase<DelegationInfoOrFeeCost>.excuteSql(new DelegationInfoOrFeeCost(), "DelegationInfoOrFeeCost", sql, CommandType.Text, param);
  21. }
  22. /// <summary>
  23. /// 获取单个对象
  24. /// </summary>
  25. /// <param name="sql">sql语句</param>
  26. /// <param name="param">可变参数数组</param>
  27. /// <returns>返回空或者单个对象</returns>
  28. DelegationInfoOrFeeCost excuteType(string sql, params SqlParameter[] param)
  29. {
  30. //查询结果放入对象集合
  31. List<DelegationInfoOrFeeCost> diList = excuteSql(sql, param);
  32. //判断集合是否为空
  33. if (diList == null || diList.Count == 0)
  34. //返回null
  35. return null;
  36. //返回单个对象
  37. return diList[0];
  38. }
  39. /// <summary>
  40. /// 根据编号查询多条对象对象信息
  41. /// </summary>
  42. /// <param name="id">对象编号</param>
  43. /// <returns>返回空或者多个对象信息</returns>
  44. public List<DelegationInfoOrFeeCost> GetDelegationInfoIdByIDAll(int diid)
  45. {
  46. //调用获取单个对象的方法
  47. return excuteSql("select * from DelegationInfoOrFeeCost where DIid=" + diid);
  48. }
  49. /// <summary>
  50. /// 根据编号查询对象信息
  51. /// </summary>
  52. /// <param name="id">对象编号</param>
  53. /// <returns>返回空或者单个对象信息</returns>
  54. public DelegationInfoOrFeeCost GetDelegationInfoIdByID(int diid)
  55. {
  56. //调用获取单个对象的方法
  57. return excuteType("select * from DelegationInfoOrFeeCost where DIid="+diid);
  58. }
  59. /// <summary>
  60. /// 根据签证表id查询链接表id
  61. /// </summary>
  62. /// <param name="id"></param>
  63. /// <returns></returns>
  64. public DelegationInfoOrFeeCost getAllByCountryId(int cid)
  65. {
  66. return excuteType("select * from DelegationInfoOrFeeCost where isdel=0 and CFCid=@id", new SqlParameter("@id", cid));
  67. }
  68. /// <summary>
  69. /// 添加团组表和签证费用标准表的连表
  70. /// </summary>
  71. /// <param name="Dov"></param>
  72. /// <returns></returns>
  73. public bool Add(DelegationInfoOrFeeCost cf)
  74. {
  75. string sql = "insert into DelegationInfoOrFeeCost values(@DIid,@CFCid,@Oper,@OpdTime,@isdel);SELECT @@IDENTITY";
  76. SqlParameter[] parameter = new SqlParameter[]{
  77. new SqlParameter("@DIid",cf.DIid),
  78. new SqlParameter("@CFCid",cf.CFCid),
  79. new SqlParameter("@Oper",cf.Oper),
  80. new SqlParameter("@OpdTime",cf.OpdTime),
  81. new SqlParameter("@isdel",cf.isdel)
  82. };
  83. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  84. return true;
  85. return false;
  86. }
  87. /// <summary>
  88. /// 修改这条签证的状态
  89. /// </summary>
  90. /// <param name="id">签证表 id</param>
  91. /// <param name="userid">操作人编号 </param>
  92. /// <param name="datetime">操作人操作时间</param>
  93. /// <returns></returns>
  94. public bool delDelegationInfoOrFeeCost(int id, int userid, string datetime)
  95. {
  96. SqlParameter[] parameter = new SqlParameter[]{
  97. new SqlParameter("@CId",id),
  98. new SqlParameter("@OPDate",datetime),
  99. new SqlParameter("@Oper",userid)
  100. };
  101. if (SqlHelper.ExecuteNonQuery("update DelegationInfoOrFeeCost set isdel=1,Oper=@Oper,OpdTime=@OPDate where DFCid=@CId", CommandType.Text, parameter) > 0)
  102. return true;
  103. return false;
  104. }
  105. }
  106. }