• 分享过滤条件中增加一个自定义过滤变量插件代码


    // 以下代码示例演示过滤条件中增加一个自定义过滤变量,例如预算部门
    // 另外还需要在t_mdl_filtercondition,t_mdl_filtercondition_l中增加相应记录,例如
    /*--插入配置过滤条件<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
    DELETE FROM T_MDL_FILTERCONDITION WHERE FID=1000001;
    INSERT INTO T_MDL_FILTERCONDITION(FID,FCONDITIONTYPEID,FSEQ,FOPERATE,FINPUTCTLTYPE,FDATASOURCETYPE,FDATAFIELDINDEX,FVALUE,FINPUT,FCLASSNAME) VALUES (1000001, 1000001,1,'=',0,0,0,'ISNULL',0,'XXApp.Core.BuggetDeptFilter.CurrBuggetDeptFilter,XXApp.Core') ;
    
    --插入配置过滤条件多语言
    DELETE FROM T_MDL_FILTERCONDITION_L WHERE FID=1000001;
    INSERT INTO T_MDL_FILTERCONDITION_L(FPKID,FID,FLOCALEID,FNAME,FDATASOURCE,FTOOLTIP) VALUES (1000001,1000001,2052,N'当前预算部门',null,null) ;
    
    */
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Kingdee.BOS.Core.CommonFilter.ConditionVariableAnalysis;
    using Kingdee.BOS.Core.CommonFilter;
    using System.ComponentModel;
    using Kingdee.BOS.App.Data;
    
    namespace XXApp.Core.BuggetDeptFilter
    {
    /// <summary>
    /// 当前用户根据预算部门进行过滤
    /// </summary>
    [Description("当前用户根据预算部门进行过滤")]
    public class CurrBuggetDeptFilter : AbstractVariableAnalysisPlugin 
    {
    public override string GetVariableFilter(ConditionVariableContext ctx)
    {
    StringBuilder sb = new StringBuilder();
    
    // 获取当前登录用户所在的部门
    sb.AppendFormat("select staff.FDEPTID ");
    sb.AppendFormat(" from t_bd_staff staff ");
    sb.AppendFormat(" inner join t_sec_user suser on staff.fpersonid=suser.FLINKOBJECT ");
    sb.AppendFormat(" inner join V_BD_CONTACTOBJECT vcon on vcon.fid=suser.FLINKOBJECT and vcon.ftype=1 ");
    sb.AppendFormat(" where suser.fuserid={0} ", ctx.Context.UserId);
    
    // 获取部门对应的预算部门内码
    string strSelect = string.Format(@"select fdeptid
    from t_bd_department where fdeptid IN ({0}) and FISBUDGET=1
    union all
    select FBudgetDept
    from t_bd_department where fdeptid IN ({0}) and FISBUDGET=0", sb.ToString());
    
    
    long currDeptId = DBUtils.ExecuteScalar<long>(ctx.Context, strSelect, 0, null);
    
    // 当前用户没有关联职员
    if (currDeptId <= 0)
    {
    return "1=1";
    }
    
    // 取出当前预算部门的名称
    string strSql = string.Format(@"SELECT FNAME FROM T_BD_DEPARTMENT_L 
    WHERE FDEPTID={0} AND FLOCALEID={1}", currDeptId, ctx.Context.UserLocale.LCID);
    
    string strName = DBUtils.ExecuteScalar<string>(ctx.Context, strSql, string.Empty, null);
    
    return string.Format("{0} {1} '{2}'", ctx.FieldName , ctx.Operater, strName);
    }
    }
    }

  • 相关阅读:
    Innodb存储引擎
    Innodb学习之MySQL体系结构
    C# sql查询数据库返回单个值方法
    Welcome To SWPUNC-ACM
    P2184 贪婪大陆 题解
    线上Java调优-Arthas入门
    JVM调优学习笔记
    RabbitMQ博文收藏
    System.Net.WebException: 远程服务器返回错误: (405) 不允许的方法。
    随机过程-Brown运动
  • 原文地址:https://www.cnblogs.com/fyq891014/p/4188790.html
Copyright © 2020-2023  润新知