123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Models;
- using System.Data.SqlClient;
- using System.Data;
- namespace DAL
- {
- /// <summary>
- /// 其他款项访问类
- /// </summary>
- public class OtherPriceOPService
- {
- /// <summary>
- /// 查询所有
- /// </summary>
- /// <param name="sql">sql语句</param>
- /// <param name="param">可变参数数组</param>
- /// <returns>返回集合</returns>
- List<OtherPriceOP> excuteSql(string sql, params SqlParameter[] param)
- {
- return ServiceBase<OtherPriceOP>.excuteSql(new OtherPriceOP(), "OtherPriceOP", sql, CommandType.Text, param);
- }
- /// <summary>
- /// 获取单个对象
- /// </summary>
- /// <param name="sql">sql语句</param>
- /// <param name="param">可变参数数组</param>
- /// <returns>返回空或者单个对象</returns>
- OtherPriceOP excuteType(string sql, params SqlParameter[] param)
- {
- //查询结果放入对象集合
- List<OtherPriceOP> gdpList = excuteSql(sql, param);
- //判断集合是否为空
- if (gdpList == null || gdpList.Count == 0)
- //返回null
- return null;
- //返回单个对象
- return gdpList[0];
- }
- /// <summary>
- /// 根据编号查询对象信息
- /// </summary>
- /// <param name="id">对象编号</param>
- /// <returns>返回空或者单个对象信息</returns>
- 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;
- }
- }
- /// <summary>
- /// 获取全部 - 分页
- /// </summary>
- /// <returns></returns>
- public List<OtherPriceOP> GetOtherPriceOfOP(int pageIndex, out int sumPage, out int totalRecord, string tourCode)
- {
- string sqlwhere = "IsDel = 0 and DIId = " + tourCode;
- return PageBase<OtherPriceOP>.excutePageSql(new OtherPriceOP(), "OtherPriceOP", "OtherPriceOP", "*", "OperatorDate desc", sqlwhere, 10, pageIndex, out sumPage, out totalRecord);
- }
- public List<OtherPriceOP> GetOtherPrice(int diid)
- {
- //调用获取单个对象的方法
- return excuteSql("select * from OtherPriceOP where diid = " + diid + " and isdel = 0 and PriceType = 1 and PayType='" + "1' ");
- }
- /// 增加
- /// </summary>
- /// <returns></returns>
- 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;
- }
- /// <summary>
- /// 编辑
- /// </summary>
- /// <returns></returns>
- 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;
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <returns></returns>
- 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;
- }
- /// <summary>
- /// 查询退多付款的其他款项
- /// </summary>
- /// <param name="diid"></param>
- /// <returns></returns>
- public DataTable GetOtherPriceOfOPByDiiD(int diid)
- {
- //调用获取单个对象的方法
- return SqlHelper.TransferProcedure("exec_OtherPriceOP_QueryByPayType", CommandType.StoredProcedure, new SqlParameter("@diid", diid));
- }
- }
- }
|