以编程方式更改当前分支 [英] Change Current Branch Programmatically

查看:81
本文介绍了以编程方式更改当前分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在运行时使用代码(AEF)更改分支?您如何在运行时执行此操作?假设我有一个自定义操作,当我单击该操作时,我想使用代码来更改公司吗?

Is it possible to change the branch at runtime using code (AEF)? How can you do this at runtime? Say I have a custom Action that when clicked I want to change the company using code, how can I do that?

推荐答案

下面

using PX.Common;
using PX.Data;
using PX.Objects.CS;
using System.Collections;
using System.Web;

namespace AccessInfoChange
{
    public class BranchMaintExtension : PXGraphExtension<BranchMaint>
    {
        public PXAction<BranchMaint.BranchBAccount> changeBranch;
        [PXUIField(DisplayName = "Change Branch")]
        [PXButton]
        public virtual IEnumerable ChangeBranch(PXAdapter adapter)
        {
                int branchObj = 5; //BranchID of Branch you would like to switch to
                PXContext.SetBranchID(branchObj);
                HttpCookie branchCooky = HttpContext.Current.Response.Cookies["UserBranch"];
                if (branchCooky == null)
                    HttpContext.Current.Response.Cookies.Add(new HttpCookie("UserBranch", "MAIN"));//BranchCD of Branch to switch
                else branchCooky.Value = branchObj.ToString();//String of IntegerID for BranchID to switch
            return adapter.Get();
        }
    }
}

这篇关于以编程方式更改当前分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆