123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- 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 IncreasePaymentsService
- {
- /// <summary>
- /// 查询所有
- /// </summary>
- /// <param name="sql">sql语句</param>
- /// <param name="param">可变参数数组</param>
- /// <returns>返回集合</returns>
- List<IncreasePayments> excuteSql(string sql, params SqlParameter[] param)
- {
- return ServiceBase<IncreasePayments>.excuteSql(new IncreasePayments(), "IncreasePayments", sql, CommandType.Text, param);
- }
- /// <summary>
- /// 获取单个对象
- /// </summary>
- /// <param name="sql">sql语句</param>
- /// <param name="param">可变参数数组</param>
- /// <returns>返回空或者单个对象</returns>
- IncreasePayments excuteType(string sql, params SqlParameter[] param)
- {
- //查询结果放入对象集合
- List<IncreasePayments> IncreasePaymentsList = excuteSql(sql, param);
- //判断集合是否为空
- if (IncreasePaymentsList == null || IncreasePaymentsList.Count == 0)
- //返回null
- return null;
- //返回单个对象
- return IncreasePaymentsList[0];
- }
- /// <summary>
- /// 根据编号查询对象信息
- /// </summary>
- /// <param name="id">对象编号</param>
- /// <returns>返回空或者单个对象信息</returns>
- public IncreasePayments GetIncreasePaymentsByID(int id)
- {
- //调用获取单个对象的方法
- return excuteType("select * from IncreasePayments where Id = @id", new SqlParameter("@id", id));
- }
- /// <summary>
- /// 获取全部有效数据
- /// </summary>
- /// <returns></returns>
- public List<IncreasePayments> GetAll()
- {
- return excuteSql("select * from IncreasePayments Where IsDel = 0");
- }
- /// <summary>
- /// 获取信息
- /// </summary>
- /// <returns></returns>
- public double GetSumMoney(int uid, string yearMonth)
- {
- object obj = SqlHelper.ExecuteScalar("select sum([money]) from IncreasePayments where isDel = 0 and userId = " + uid + " and yearMonth = '" + yearMonth + "'", CommandType.Text);
- double sumMoney = 0;
- if(obj!=null && !string.IsNullOrEmpty(obj.ToString()))
- sumMoney = Convert.ToDouble(obj);
- //调用获取单个对象的方法
- return sumMoney;
-
- }
- /// <summary>
- /// 根据条件查询条件获取 - 分页
- /// </summary>
- /// <param name="pageIndex"></param>
- /// <param name="sumPage"></param>
- /// <param name="totalRecord"></param>
- /// <param name="dataType"></param>
- /// <param name="name"></param>
- /// <returns></returns>
- public List<IncreasePayments> GetAll(int pageIndex, out int sumPage, out int totalRecord, string yearMonth, string increaseType,string userId)
- {
- string sqlwhere;
- if (userId != "0")
- {
- sqlwhere = "YearMonth = '" + yearMonth + "' and Sid = " + increaseType + " and UserId = " + userId + " and IsDel = 0";
- }else
- {
- sqlwhere = "YearMonth = '" + yearMonth + "' and Sid = " + increaseType + " and IsDel = 0";
- }
- return PageBase<IncreasePayments>.excutePageSql(new IncreasePayments(), "IncreasePayments", "IncreasePayments", "*", "id desc", sqlwhere, 10, pageIndex, out sumPage, out totalRecord);
- }
- /// <summary>
- /// 新增
- /// </summary>
- /// <param name="sdt">对象</param>
- public bool AddIncreasePayments(IncreasePayments ip)
- {
- string sql = "insert into IncreasePayments values(@YearMonth,@UserId,@Sid,@OccurrenceDate,@Money,@Remark,@Operator,@OperatorDate,@IsDel)";
- SqlParameter[] parameter = new SqlParameter[]{
- new SqlParameter("@YearMonth",ip.YearMonths),
- new SqlParameter("@UserId",ip.UserId),
- new SqlParameter("@Sid",ip.Sid),
- new SqlParameter("@OccurrenceDate",ip.OccurrenceDate),
- new SqlParameter("@Money", ip.Money),
- new SqlParameter("@Remark",ip.Remark),
- new SqlParameter("@Operator",ip.Operators),
- new SqlParameter("@OperatorDate",ip.OperatorsDate),
- new SqlParameter("@IsDel",ip.IsDel)
- };
- if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
- return true;
- return false;
- }
- /// <summary>
- /// 编辑
- /// </summary>
- /// <param name="sdt"></param>
- /// <returns></returns>
- public bool EditIncreasePayments(IncreasePayments ip)
- {
- string sql = "update IncreasePayments set YearMonth = @YearMonth,UserId = @UserId,Sid = @Sid,OccurrenceDate = @OccurrenceDate,Money = @Money,Remark = @Remark,Operator = @Operator,OperatorDate = @OperatorDate where Id = @Id";
- SqlParameter[] parameter = new SqlParameter[]{
- new SqlParameter("@YearMonth",ip.YearMonths),
- new SqlParameter("@UserId",ip.UserId),
- new SqlParameter("@Sid",ip.Sid),
- new SqlParameter("@OccurrenceDate",ip.OccurrenceDate),
- new SqlParameter("@Money", ip.Money),
- new SqlParameter("@Remark",ip.Remark),
- new SqlParameter("@Operator",ip.Operators),
- new SqlParameter("@OperatorDate",ip.OperatorsDate),
- new SqlParameter("@Id",ip.Id)
- };
- if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
- return true;
- return false;
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- public bool DelIncreasePayments(int id)
- {
- if (SqlHelper.ExecuteNonQuery("update IncreasePayments set IsDel = 1 where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
- return true;
- return false;
- }
- }
- }
|