using System.Data; using System.Data.SqlClient; using Business.FileFlow.Entity; using Common; namespace Business.FileFlow.Vo { public class ActionVo { /// /// 参数赋值 /// /// 实体类ActionEty /// 参数数组 private SqlParameter[] SetPara(ActionEty action) { return new[] { new SqlParameter("@id", action.Id), new SqlParameter("@name", action.Name), new SqlParameter("@remark", action.Remark), new SqlParameter("@delflag", action.DelFlag), new SqlParameter("@addUserID", action.AddUserId), new SqlParameter("@addtime", action.AddTime), new SqlParameter("@updateUserID", action.UpdateUserId), new SqlParameter("@lastTime", action.LastTime), new SqlParameter( "@approveId",action.ApproveId) }; } /// /// 新增action记录 /// /// 实体类ActionEty /// 成功返回空字符串,失败返回错误信息 public string InsertAction(ActionEty action) { var sql = "insert into action(id,name,remark,delflag,addUserID,addtime,updateUserID,lastTime,approveId) values(@id,@name,@remark,@delflag,@addUserID,@addtime,@updateUserID,@lastTime,@approveId)"; return SqlHelper.ExecSql(sql, SetPara(action)); } /// /// 获取全部流程操作信息 /// /// 查询字段 /// 数据表 public DataTable AllAction(string searchText) { var sql = "select p.id,p.name,p.remark,sss.depid,p.approveId as pid,sss.username as approvename,p.lastTime,s.username as addusername ,ss.username as updateusername from action p left join SysUser s on s.userid=p.addUserID left join SysUser ss on ss.userid=p.updateUserID left join SysUser sss on sss.userid=p.approveId where p.delflag ='false' "; if (!string.IsNullOrEmpty(searchText)) { //根据查询字段 进行查询 sql += string.Format( "and( p.name like '%{0}%' or p.remark like '%{0}%' or s.username like '%{0}%' or ss.username like '%{0}%' or sss.username like '%{0}%' )", searchText); } sql += " order by p.lastTime DESC"; return SqlHelper.ExecSqlDateTable(sql); } /// /// 更新流程操作信息 /// /// 实体类ActionEty /// 成功返回空字符串,失败返回错误信息 public string UpdateAction(ActionEty action) { var sq1 = "update action set name=@name,remark=@remark,lastTime=@lastTime,updateUserID=@updateUserID,approveId=@approveId where id=@id"; return SqlHelper.ExecSql(sq1, SetPara(action)); } /// /// 根据id删除流程操作信息 /// /// 流程操作id /// 成功返回空字符串,失败返回错误信息 public string DelAction(string id) { var sql = "update action set delflag='true' where id in (" + id + ")"; return SqlHelper.ExecSql(sql); } /// /// 根据userid 获取该用户可审批的操作 用','分割 /// /// 用户ID /// 操作ID集合 用','分割 public string MyActions(string userid) { string myactions = string.Empty; string sql = "select id from action where approveId=@approveId"; foreach (DataRow row in SqlHelper.ExecSqlDateTable(sql, new SqlParameter("@approveId", userid)).Rows) { myactions += row["id"]+","; } return myactions.Equals(string.Empty) ? myactions : myactions.TrimEnd(','); } } }