using System; using System.Collections.Generic; using System.Linq; using System.Text; using Models; using System.Data.SqlClient; using System.Data; namespace DAL { /// /// 销售报价汇总数据访问类 /// public class SalesQuotationService { /// /// 查询所有 /// /// sql语句 /// 可变参数数组 /// 返回集合 List excuteSql(string sql, params SqlParameter[] param) { return ServiceBase.excuteSql(new SalesQuotation(), "SalesQuotation", sql, CommandType.Text, param); } /// /// 获取单个对象 /// /// sql语句 /// 可变参数数组 /// 返回空或者单个对象 SalesQuotation excuteType(string sql, params SqlParameter[] param) { //查询结果放入对象集合 List sqList = excuteSql(sql, param); //判断集合是否为空 if (sqList == null || sqList.Count == 0) //返回null return null; //返回单个对象 return sqList[0]; } /// /// 根据编号查询对象信息 /// /// /// 返回空或者单个对象信息 public SalesQuotation GetSalesQuotationByDIID(int DIID) { //调用获取单个对象的方法 return excuteType("select * from SalesQuotation where DIID = @DIID and IsDel = 0", new SqlParameter("@DIID", DIID)); } /// /// 增加 /// /// /// public bool AddSalesQuotation(SalesQuotation sq) { string sql = "insert into SalesQuotation values(@DIID,@PriceDescription,@Contains,@NoContains,@ExchangeRate,@Remark,@Operator,@OperatorDate,@IsDel)"; SqlParameter[] parameter = new SqlParameter[]{ new SqlParameter("@DIID",sq.DIID), new SqlParameter("@PriceDescription",sq.PriceDescription), new SqlParameter("@Contains",sq.Contains), new SqlParameter("@NoContains",sq.NoContains), new SqlParameter("@ExchangeRate",sq.ExchangeRate), new SqlParameter("@Remark",sq.Remark), new SqlParameter("@Operator",sq.Operators), new SqlParameter("@OperatorDate",sq.OperatorsDate), new SqlParameter("@IsDel",sq.IsDel) }; if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0) return true; return false; } /// /// 编辑 /// /// /// public bool EditSalesQuotation(SalesQuotation sq) { string sql = "update SalesQuotation set DIID = @DIID,PriceDescription = @PriceDescription,[Contains] = @Contains,NoContains = @NoContains,ExchangeRate = @ExchangeRate,Remark = @Remark,Operator = @Operator,OperatorDate = @OperatorDate where Id = @Id"; SqlParameter[] parameter = new SqlParameter[] { new SqlParameter("@DIID",sq.DIID), new SqlParameter("@PriceDescription",sq.PriceDescription), new SqlParameter("@Contains",sq.Contains), new SqlParameter("@NoContains",sq.NoContains), new SqlParameter("@ExchangeRate",sq.ExchangeRate), new SqlParameter("@Remark",sq.Remark), new SqlParameter("@Operator",sq.Operators), new SqlParameter("@OperatorDate",sq.OperatorsDate), new SqlParameter("@Id",sq.Id) }; if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0) return true; return false; } /// /// 删除 /// /// /// public bool DelSalesQuotation(int id) { if (SqlHelper.ExecuteNonQuery("update SalesQuotation set IsDel = 1 where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0) return true; return false; } } }