123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- 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 UpCardAuditService
- {
- /// <summary>
- /// 查询所有
- /// </summary>
- /// <param name="sql">sql语句</param>
- /// <param name="param">可变参数数组</param>
- /// <returns>返回集合</returns>
- List<UpCardAudit> excuteSql(string sql, params SqlParameter[] param)
- {
- return ServiceBase<UpCardAudit>.excuteSql(new UpCardAudit(), "UpCardAudit", sql, CommandType.Text, param);
- }
- /// <summary>
- /// 获取单个对象
- /// </summary>
- /// <param name="sql">sql语句</param>
- /// <param name="param">可变参数数组</param>
- /// <returns>返回空或者单个对象</returns>
- UpCardAudit excuteType(string sql, params SqlParameter[] param)
- {
- //查询结果放入对象集合
- List<UpCardAudit> ucaList = excuteSql(sql, param);
- //判断集合是否为空
- if (ucaList == null || ucaList.Count == 0)
- //返回null
- return null;
- //返回单个对象
- return ucaList[0];
- }
- /// <summary>
- /// 根据编号查询对象信息
- /// </summary>
- /// <param name="id">对象编号</param>
- /// <returns>返回空或者单个对象信息</returns>
- public List<UpCardAudit> GetUpCardAuditByYearMonth(int uid, string YearMonth)
- {
- //调用获取单个对象的方法
- return excuteSql("select * from UpCardAudit where uid = @uid and YearMonth = @YearMonth and IsDel = 0 order by Id", new SqlParameter("@uid", uid), new SqlParameter("@YearMonth", YearMonth));
- }
- /// <summary>
- /// 根据编号查询对象信息
- /// </summary>
- /// <param name="id">对象编号</param>
- /// <returns>返回空或者单个对象信息</returns>
- public List<UpCardAudit> GetYearMonth()
- {
- //调用获取单个对象的方法
- return excuteSql("select * from UpCardAudit where IsDel = 0 order by Id desc");
- }
- /// <summary>
- /// 根据编号查询对象信息
- /// </summary>
- /// <param name="id">对象编号</param>
- /// <returns>返回空或者单个对象信息</returns>
- public UpCardAudit GetUpCardAuditByID(int id)
- {
- //调用获取单个对象的方法
- return excuteType("select * from UpCardAudit where Id = @id and IsDel = 0", new SqlParameter("@id", id));
- }
- /// <summary>
- /// 根据条件获取数据集合
- /// </summary>
- /// <param name="yearMonth"></param>
- /// <param name="isAudit"></param>
- /// <param name="userid"></param>
- /// <returns></returns>
- public List<UpCardAudit> GetUpCardAudit(int pageIndex, out int sumPage, out int totalRecord, string yearMonth, string isAudit, string userid)
- {
- string sqlwhere = "YearMonth = '" + yearMonth + "' and IsDel = 0 and uid = " + userid + "";
- if (isAudit == "0")
- sqlwhere += " and (IsAudit = " + isAudit + " or IsAudit = 2)";
- else
- sqlwhere += " and IsAudit = 1";
- return PageBase<UpCardAudit>.excutePageSql(new UpCardAudit(), "UpCardAudit", "UpCardAudit", "*", "id desc", sqlwhere, 15, pageIndex, out sumPage, out totalRecord);
- }
- /// <summary>
- /// 新增
- /// </summary>
- /// <param name="sdt">对象</param>
- public bool AddUpCardAudit(UpCardAudit u, out int id)
- {
- string sql = "insert into UpCardAudit([Uid],[YearMonth],[ApplicationPeriod],[Attachment],[Subject],[IsAudit],[IsDel]) values(" + u.Uid + ",'" + u.YearMonth + "','" + u.ApplicationPeriod + "','" + u.Attachment + "','" + u.Subject + "'," + u.IsAudit + "," + u.IsDel + ");SELECT @@IDENTITY";
- int obj = Convert.ToInt32(SqlHelper.ExecuteScalar(sql, CommandType.Text));
- if (obj > 0)
- {
- id = obj;
- return true;
- }
- id = 0;
- return false;
- }
- /// <summary>
- /// 编辑
- /// </summary>
- /// <param name="uca"></param>
- /// <returns></returns>
- public bool UpdateUpCardAudit(UpCardAudit uca)
- {
- string Attachment = "";
- if (!string.IsNullOrEmpty(uca.Attachment))
- Attachment = ", Attachment = '" + uca.Attachment + "'";
- string sql = "update UpCardAudit set ApplicationPeriod = @ApplicationPeriod " + Attachment + " , Subject = @Subject where id = @Id";
- if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, new SqlParameter("@ApplicationPeriod", uca.ApplicationPeriod), new SqlParameter("@Subject", uca.Subject), new SqlParameter("@Id", uca.Id)) > 0)
- return true;
- return false;
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- public bool DelUpCardAudit(int id)
- {
- if (SqlHelper.ExecuteNonQuery("update UpCardAudit set IsDel = 1 where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
- return true;
- return false;
- }
- /// <summary>
- /// 更改审核状态
- /// </summary>
- /// <param name="isAudit"></param>
- /// <param name="auditRemark"></param>
- /// <param name="Operate"></param>
- /// <param name="OperateTime"></param>
- /// <param name="id"></param>
- /// <returns></returns>
- public bool UpdeteIsAudit(int isAudit, string auditRemark, int operate, string operateTime, int id)
- {
- string sql = "update UpCardAudit set IsAudit = @IsAudit,AuditRemark=@AuditRemark,Operate=@Operate,OperateTime=@OperateTime where Id = @Id";
- SqlParameter[] parameter = new SqlParameter[]{
- new SqlParameter("@IsAudit",isAudit),
- new SqlParameter("@AuditRemark",auditRemark),
- new SqlParameter("@Operate",operate),
- new SqlParameter("@OperateTime",operateTime),
- new SqlParameter("@Id",id)
- };
- if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
- return true;
- return false;
- }
- public List<UpCardAudit> GetError(int userId, string yearMonth)
- {
- string sql = "select * from UpCardAudit where uid = " + userId + " and YearMonth = '" + yearMonth + "' and Isdel=0 "
- + "AND Id NOT IN (select UCAid from UpCardAuditContent where Isdel=0 "
- + "AND UCAid IN (select Id from UpCardAudit where uid = " + userId + " and YearMonth = '" + yearMonth + "' and IsDel = 0))";
- return excuteSql(sql);
- }
- }
- }
|