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 ProceedsReceivedService { /// /// 查询所有 /// /// sql语句 /// 可变参数数组 /// 返回集合 List excuteSql(string sql, params SqlParameter[] param) { return ServiceBase.excuteSql(new ProceedsReceived(), "ProceedsReceived", sql, CommandType.Text, param); } /// /// 获取单个对象 /// /// sql语句 /// 可变参数数组 /// 返回空或者单个对象 ProceedsReceived excuteType(string sql, params SqlParameter[] param) { //查询结果放入对象集合 List ioaList = excuteSql(sql, param); //判断集合是否为空 if (ioaList == null || ioaList.Count == 0) //返回null return null; //返回单个对象 return ioaList[0]; } /// /// 根据编号查询对象信息 /// /// 对象编号 /// 返回空或者单个对象信息 public ProceedsReceived GetProceedsReceivedByDIId(int DIId) { //调用获取单个对象的方法 return excuteType("select * from ProceedsReceived where DIId = @DIId", new SqlParameter("@DIId", DIId)); } /// /// 根据编号查询对象信息 /// /// 对象编号 /// 返回空或者单个对象信息 public ProceedsReceived GetProceedsReceivedById(int id) { //调用获取单个对象的方法 return excuteType("select * from ProceedsReceived where Id = @Id and isdel = 0", new SqlParameter("@Id", id)); } /// /// 根据编号查询对象信息 - 集合 /// /// 对象编号 /// 返回空或者对象集合信息 public List GetAllByDIId(int DIId) { //调用获取单个对象的方法 return excuteSql("select * from ProceedsReceived where DIId = @DIId and isdel = 0", new SqlParameter("@DIId", DIId)); } /// /// 批量添加方法 /// /// /// public bool AddUpCardAuditContent(List 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; } } /// /// 删除 /// /// /// 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)); } /// /// 根据收款账单id查询已收款项 /// /// /// 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; } } }