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 OtherPriceOPService { /// /// 查询所有 /// /// sql语句 /// 可变参数数组 /// 返回集合 List excuteSql(string sql, params SqlParameter[] param) { return ServiceBase.excuteSql(new OtherPriceOP(), "OtherPriceOP", sql, CommandType.Text, param); } /// /// 获取单个对象 /// /// sql语句 /// 可变参数数组 /// 返回空或者单个对象 OtherPriceOP excuteType(string sql, params SqlParameter[] param) { //查询结果放入对象集合 List gdpList = excuteSql(sql, param); //判断集合是否为空 if (gdpList == null || gdpList.Count == 0) //返回null return null; //返回单个对象 return gdpList[0]; } /// /// 根据编号查询对象信息 /// /// 对象编号 /// 返回空或者单个对象信息 public OtherPriceOP GetOtherPriceOfOPByID(int id) { //调用获取单个对象的方法 return excuteType("select * from OtherPriceOP where Id = @id and isdel=0", new SqlParameter("@id", id)); } public float GetSKTH(int diid) { string sql = "select sum(Price) from OtherPriceOP where Diid=@diid and IsDel=0 and PriceType =1 and PayType='1' "; SqlParameter[] parameter = new SqlParameter[]{ new SqlParameter("@DIId",diid) }; object obj = SqlHelper.ExecuteScalar(sql, CommandType.Text, parameter); try { return float.Parse(obj == null ? "0" : obj.ToString()); } catch { return 0; } } /// /// 获取全部 - 分页 /// /// public List GetOtherPriceOfOP(int pageIndex, out int sumPage, out int totalRecord, string tourCode) { string sqlwhere = "IsDel = 0 and DIId = " + tourCode; return PageBase.excutePageSql(new OtherPriceOP(), "OtherPriceOP", "OtherPriceOP", "*", "OperatorDate desc", sqlwhere, 10, pageIndex, out sumPage, out totalRecord); } public List GetOtherPrice(int diid) { //调用获取单个对象的方法 return excuteSql("select * from OtherPriceOP where diid = " + diid + " and isdel = 0 and PriceType = 1 and PayType='" + "1' "); } /// 增加 /// /// public bool AddOtherPriceOfOP(OtherPriceOP gpd, out int id) { string sql = "insert into OtherPriceOP values(@DIID,@PriceName,@Price,@Currency,@Remark,@Operator,@OperatorDate,@IsDel,@PayType,@PriceType);SELECT @@IDENTITY"; SqlParameter[] parameter = new SqlParameter[]{ new SqlParameter("@DIId",gpd.DIID), new SqlParameter("@PriceName",gpd.PriceName), new SqlParameter("@Price",gpd.Price), new SqlParameter("@Currency",gpd.Currency), new SqlParameter("@Remark",gpd.Remark), new SqlParameter("@Operator",gpd.Operators), new SqlParameter("@OperatorDate",gpd.OperatorsDate), new SqlParameter("@IsDel",gpd.IsDel), new SqlParameter("@PayType",gpd.PayType), new SqlParameter("@PriceType",gpd.PriceType) }; int obj = Convert.ToInt32(SqlHelper.ExecuteScalar(sql, CommandType.Text, parameter)); if (obj > 0) { id = obj; return true; } id = 0; return false; } /// /// 编辑 /// /// public bool EditOtherPriceOfOP(OtherPriceOP gpd) { string sql = "update OtherPriceOP set DIID = @DIID,PriceName = @PriceName,Price = @Price,Currency = @Currency,Remark = @Remark ,Operator = @Operator,OperatorDate = @OperatorDate,PayType=@PayType,PriceType=@PriceType where Id = @Id"; SqlParameter[] parameter = new SqlParameter[]{ new SqlParameter("@DIId",gpd.DIID), new SqlParameter("@PriceName",gpd.PriceName), new SqlParameter("@Price",gpd.Price), new SqlParameter("@Currency",gpd.Currency), new SqlParameter("@Remark",gpd.Remark), new SqlParameter("@Operator",gpd.Operators), new SqlParameter("@OperatorDate",gpd.OperatorsDate), new SqlParameter("@Id",gpd.Id), new SqlParameter("@PayType",gpd.PayType), new SqlParameter("@PriceType",gpd.PriceType) }; if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0) return true; return false; } /// /// 删除 /// /// public bool DelOtherPriceOfOP(int id) { string sql = "update OtherPriceOP set IsDel = 1 where Id = @Id"; if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, new SqlParameter("@Id", id)) > 0) return true; return false; } /// /// 查询退多付款的其他款项 /// /// /// public DataTable GetOtherPriceOfOPByDiiD(int diid) { //调用获取单个对象的方法 return SqlHelper.TransferProcedure("exec_OtherPriceOP_QueryByPayType", CommandType.StoredProcedure, new SqlParameter("@diid", diid)); } } }