123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- 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>
- /// 日常费用付款申请详细数据访问类
- /// </summary>
- /// </summary>
- public class DailyFeePaymentContentService
- {
- /// <summary>
- /// 查询所有
- /// </summary>
- /// <param name="sql">sql语句</param>
- /// <param name="param">可变参数数组</param>
- /// <returns>返回集合</returns>
- List<DailyFeePaymentContent> excuteSql(string sql, params SqlParameter[] param)
- {
- return ServiceBase<DailyFeePaymentContent>.excuteSql(new DailyFeePaymentContent(), "DailyFeePaymentContent", sql, CommandType.Text, param);
- }
- /// <summary>
- /// 获取单个对象
- /// </summary>
- /// <param name="sql">sql语句</param>
- /// <param name="param">可变参数数组</param>
- /// <returns>返回空或者单个对象</returns>
- DailyFeePaymentContent excuteType(string sql, params SqlParameter[] param)
- {
- //查询结果放入对象集合
- List<DailyFeePaymentContent> cdList = excuteSql(sql, param);
- //判断集合是否为空
- if (cdList == null || cdList.Count == 0)
- //返回null
- return null;
- //返回单个对象
- return cdList[0];
- }
- /// <summary>
- /// 根据编号查询对象信息
- /// </summary>
- /// <param name="id">对象编号</param>
- /// <returns>返回空或者单个对象信息</returns>
- public DailyFeePaymentContent GetDailyFeePaymentContentByID(int id)
- {
- //调用获取单个对象的方法
- return excuteType("select * from DailyFeePaymentContent where Id = @id", new SqlParameter("@id", id));
- }
- /// <summary>
- /// 根据编号查询对象信息
- /// </summary>
- /// <param name="id">对象编号</param>
- /// <returns>返回空或者单个对象信息</returns>
- public List<DailyFeePaymentContent> GetDailyFeePaymentContentByDFPID(int DFPID)
- {
- //调用获取单个对象的方法
- return excuteSql("select * from DailyFeePaymentContent where DFPID = @DFPID ORDER BY ID", new SqlParameter("@DFPID", DFPID));
- }
- /// <summary>
- /// 增加
- /// </summary>
- /// <param name="dfpc"></param>
- /// <returns></returns>
- public bool AddDailyFeePaymentContent(List<DailyFeePaymentContent> list)
- {
- SqlCommand cmd = SqlHelper.createCon().CreateCommand();
- cmd.Connection.Open();
- SqlTransaction trans = cmd.Connection.BeginTransaction();
- try
- {
- foreach (DailyFeePaymentContent dfpc in list)
- {
- cmd.CommandText = "insert into DailyFeePaymentContent values(" + dfpc.DFPID + ",'" + dfpc.PriceName + "'," + dfpc.Count + "," + dfpc.Price + "," + dfpc.ItemSumPrice + ",'" + dfpc.Remark + "')";
- cmd.ExecuteNonQuery();
- }
- trans.Commit();
- cmd.Connection.Close();
- return true;
- }
- catch
- {
- trans.Rollback();
- cmd.Connection.Close();
- return false;
- }
- }
- /// <summary>
- /// 编辑
- /// </summary>
- /// <param name="sdt"></param>
- /// <returns></returns>
- public bool EditDailyFeePaymentContent(DailyFeePaymentContent dfpc)
- {
- string sql = "update DailyFeePaymentContent set PriceName = @PriceName,Count = @Count,Price = @Price,ItemSumPrice = @ItemSumPrice,Remark = @Remark where Id = @Id";
- SqlParameter[] parameter = new SqlParameter[] {
- new SqlParameter("@PriceName",dfpc.PriceName),
- new SqlParameter("@Count",dfpc.Count),
- new SqlParameter("@Price",dfpc.Price),
- new SqlParameter("@ItemSumPrice",dfpc.ItemSumPrice),
- new SqlParameter("@Remark",dfpc.Remark),
- new SqlParameter("@Id",dfpc.Id)
- };
- if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
- return true;
- return false;
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- public bool DelDailyFeePaymentContent(int id)
- {
- if (SqlHelper.ExecuteNonQuery("delete DailyFeePaymentContent where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
- return true;
- return false;
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- public bool DelDailyFeePaymentContentByDFPID(int DFPID)
- {
- if (SqlHelper.ExecuteNonQuery("delete DailyFeePaymentContent where DFPID = @DFPID", CommandType.Text, new SqlParameter("@DFPID", DFPID)) > 0)
- return true;
- return false;
- }
- /// <summary>
- /// LiuChengYi 2014/4/25
- /// 日常支付金额
- /// </summary>
- /// <param name="startTime"></param>
- /// <param name="endTime"></param>
- /// <returns></returns>
- public Double DelDailyFeePaymentContentByDateTime(string startTime, string endTime)
- {
- double DailyExpensesMoney;
- SqlParameter[] pars =
- {
- new SqlParameter("@startTime",startTime),
- new SqlParameter("@endTime",endTime)
- };
- DataTable dt = SqlHelper.TransferProcedure("dailyFeePaymentContent_Report", CommandType.StoredProcedure, pars);
- if (dt.Rows.Count > 0)
- {
- if (dt.Rows[0][0].ToString() != null && dt.Rows[0][0].ToString() != "")
- {
- DailyExpensesMoney = Convert.ToDouble(dt.Rows[0][0].ToString());
- }
- else
- {
- DailyExpensesMoney = 0;
- }
- }
- else
- {
- DailyExpensesMoney = 0;
- }
- return DailyExpensesMoney;
- }
- }
- }
|