SalesQuotationService.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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 SalesQuotationService
  14. {
  15. /// <summary>
  16. /// 查询所有
  17. /// </summary>
  18. /// <param name="sql">sql语句</param>
  19. /// <param name="param">可变参数数组</param>
  20. /// <returns>返回集合</returns>
  21. List<SalesQuotation> excuteSql(string sql, params SqlParameter[] param)
  22. {
  23. return ServiceBase<SalesQuotation>.excuteSql(new SalesQuotation(), "SalesQuotation", 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. SalesQuotation excuteType(string sql, params SqlParameter[] param)
  32. {
  33. //查询结果放入对象集合
  34. List<SalesQuotation> sqList = excuteSql(sql, param);
  35. //判断集合是否为空
  36. if (sqList == null || sqList.Count == 0)
  37. //返回null
  38. return null;
  39. //返回单个对象
  40. return sqList[0];
  41. }
  42. /// <summary>
  43. /// 根据编号查询对象信息
  44. /// </summary>
  45. /// <param name="DIID"></param>
  46. /// <returns>返回空或者单个对象信息</returns>
  47. public SalesQuotation GetSalesQuotationByDIID(int DIID)
  48. {
  49. //调用获取单个对象的方法
  50. return excuteType("select * from SalesQuotation where DIID = @DIID and IsDel = 0", new SqlParameter("@DIID", DIID));
  51. }
  52. /// <summary>
  53. /// 增加
  54. /// </summary>
  55. /// <param name="cd"></param>
  56. /// <returns></returns>
  57. public bool AddSalesQuotation(SalesQuotation sq)
  58. {
  59. string sql = "insert into SalesQuotation values(@DIID,@PriceDescription,@Contains,@NoContains,@ExchangeRate,@Remark,@Operator,@OperatorDate,@IsDel)";
  60. SqlParameter[] parameter = new SqlParameter[]{
  61. new SqlParameter("@DIID",sq.DIID),
  62. new SqlParameter("@PriceDescription",sq.PriceDescription),
  63. new SqlParameter("@Contains",sq.Contains),
  64. new SqlParameter("@NoContains",sq.NoContains),
  65. new SqlParameter("@ExchangeRate",sq.ExchangeRate),
  66. new SqlParameter("@Remark",sq.Remark),
  67. new SqlParameter("@Operator",sq.Operators),
  68. new SqlParameter("@OperatorDate",sq.OperatorsDate),
  69. new SqlParameter("@IsDel",sq.IsDel)
  70. };
  71. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  72. return true;
  73. return false;
  74. }
  75. /// <summary>
  76. /// 编辑
  77. /// </summary>
  78. /// <param name="sdt"></param>
  79. /// <returns></returns>
  80. public bool EditSalesQuotation(SalesQuotation sq)
  81. {
  82. string sql = "update SalesQuotation set DIID = @DIID,PriceDescription = @PriceDescription,[Contains] = @Contains,NoContains = @NoContains,ExchangeRate = @ExchangeRate,Remark = @Remark,Operator = @Operator,OperatorDate = @OperatorDate where Id = @Id";
  83. SqlParameter[] parameter = new SqlParameter[] {
  84. new SqlParameter("@DIID",sq.DIID),
  85. new SqlParameter("@PriceDescription",sq.PriceDescription),
  86. new SqlParameter("@Contains",sq.Contains),
  87. new SqlParameter("@NoContains",sq.NoContains),
  88. new SqlParameter("@ExchangeRate",sq.ExchangeRate),
  89. new SqlParameter("@Remark",sq.Remark),
  90. new SqlParameter("@Operator",sq.Operators),
  91. new SqlParameter("@OperatorDate",sq.OperatorsDate),
  92. new SqlParameter("@Id",sq.Id)
  93. };
  94. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  95. return true;
  96. return false;
  97. }
  98. /// <summary>
  99. /// 删除
  100. /// </summary>
  101. /// <param name="id"></param>
  102. /// <returns></returns>
  103. public bool DelSalesQuotation(int id)
  104. {
  105. if (SqlHelper.ExecuteNonQuery("update SalesQuotation set IsDel = 1 where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
  106. return true;
  107. return false;
  108. }
  109. }
  110. }