123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- 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 ProceedsReceivedService
- {
- /// <summary>
- /// 查询所有
- /// </summary>
- /// <param name="sql">sql语句</param>
- /// <param name="param">可变参数数组</param>
- /// <returns>返回集合</returns>
- List<ProceedsReceived> excuteSql(string sql, params SqlParameter[] param)
- {
- return ServiceBase<ProceedsReceived>.excuteSql(new ProceedsReceived(), "ProceedsReceived", sql, CommandType.Text, param);
- }
- /// <summary>
- /// 获取单个对象
- /// </summary>
- /// <param name="sql">sql语句</param>
- /// <param name="param">可变参数数组</param>
- /// <returns>返回空或者单个对象</returns>
- ProceedsReceived excuteType(string sql, params SqlParameter[] param)
- {
- //查询结果放入对象集合
- List<ProceedsReceived> ioaList = excuteSql(sql, param);
- //判断集合是否为空
- if (ioaList == null || ioaList.Count == 0)
- //返回null
- return null;
- //返回单个对象
- return ioaList[0];
- }
- /// <summary>
- /// 根据编号查询对象信息
- /// </summary>
- /// <param name="id">对象编号</param>
- /// <returns>返回空或者单个对象信息</returns>
- public ProceedsReceived GetProceedsReceivedByDIId(int DIId)
- {
- //调用获取单个对象的方法
- return excuteType("select * from ProceedsReceived where DIId = @DIId", new SqlParameter("@DIId", DIId));
- }
- /// <summary>
- /// 根据编号查询对象信息
- /// </summary>
- /// <param name="id">对象编号</param>
- /// <returns>返回空或者单个对象信息</returns>
- public ProceedsReceived GetProceedsReceivedById(int id)
- {
- //调用获取单个对象的方法
- return excuteType("select * from ProceedsReceived where Id = @Id and isdel = 0", new SqlParameter("@Id", id));
- }
- /// <summary>
- /// 根据编号查询对象信息 - 集合
- /// </summary>
- /// <param name="id">对象编号</param>
- /// <returns>返回空或者对象集合信息</returns>
- public List<ProceedsReceived> GetAllByDIId(int DIId)
- {
- //调用获取单个对象的方法
- return excuteSql("select * from ProceedsReceived where DIId = @DIId and isdel = 0", new SqlParameter("@DIId", DIId));
- }
- /// <summary>
- /// 批量添加方法
- /// </summary>
- /// <param name="list"></param>
- /// <returns></returns>
- public bool AddUpCardAuditContent(List<ProceedsReceived> list)
- {
- SqlCommand cmd = SqlHelper.createCon().CreateCommand();
- cmd.Connection.Open();
- //SqlTransaction trans = cmd.Connection.BeginTransaction();
- try
- {
- foreach (ProceedsReceived pr in list)
- {
- cmd.CommandText = "insert into ProceedsReceived values(" + pr.DIID + ",'" + pr.SectionTime + "'," + pr.Price + "," + pr.Currency + ","
- + pr.ReceivablesType + ",'" + pr.Client + "','" + pr.Remark + "'," + pr.Operators + ",'"
- + pr.OperatorsDate + "'," + pr.IsDel + "," + pr.FID + ")";
- cmd.ExecuteNonQuery();
- }
- //trans.Commit();
- cmd.Connection.Close();
- return true;
- }
- catch
- {
- //trans.Rollback();
- cmd.Connection.Close();
- return false;
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- public bool DelProceedsReceived(int DIId)
- {
- if (SqlHelper.ExecuteNonQuery("delete ProceedsReceived where DIId = @DIId", CommandType.Text, new SqlParameter("@DIId", DIId)) > 0)
- return true;
- return false;
- }
- public object GetSumByDIId(int diid)
- {
- //调用获取单个对象的方法
- //return excuteSql("select * from ProceedsReceived where DIId = @DIId", new SqlParameter("@DIId", DIId));
- return SqlHelper.ExecuteScalar("select sum(Price) from ProceedsReceived where DIId = @DIId and isdel=0", CommandType.Text, new SqlParameter("@DIId", diid));
- }
- /// <summary>
- /// 根据收款账单id查询已收款项
- /// </summary>
- /// <param name="p"></param>
- /// <returns></returns>
- public ProceedsReceived GetProceedsReceivedByFId(int FID)
- {
- //调用获取单个对象的方法
- return excuteType("select * from ProceedsReceived where FID = @FID", new SqlParameter("@FID", FID));
- }
- public DataTable getAllProceedsReceivedByPro(int diid)
- {
- DataTable dt = SqlHelper.TransferProcedure("[dbo].[exec_ReceviedAccount_Recevied]", CommandType.StoredProcedure, new SqlParameter("@diid", diid));
- if (dt != null)
- return dt;
- return null;
- }
- }
- }
|