UI插件:列表工具栏上加按钮

        private UFIDA.U9.FI.AR.ARMaintenanceBListUIModel.ARMainBListUIFormWebPart _strongPart;
        IUFButton CustBatchAccountDoc = null;     //生成对账单

        public override void AfterInit(IPart part, EventArgs args)
        {
            base.AfterInit(part, args);
            if (part == null)
                return;
            _strongPart = part as UFIDA.U9.FI.AR.ARMaintenanceBListUIModel.ARMainBListUIFormWebPart;
            if (_strongPart == null)
                return;

            CustBatchAccountDoc = new UFWebButtonAdapter();
            CustBatchAccountDoc.ID = "CustBatchAccountDoc";
            CustBatchAccountDoc.AutoPostBack = true;


            IUFToolbar _Toolbar = (IUFToolbar)_strongPart.FindControl("Toolbar1");

            CustBatchAccountDoc = UIControlBuilder.BuilderToolbarButton(_Toolbar, "True", "CustBatchAccountDoc", "True", "True", 35, 28, "6", "", true, false, "36BA88E0-FC28-402e-B9BA-3745A6771687", "36BA88E0-FC28-402e-B9BA-3745A6771687", "9307E981-85AA-4f19-ADB7-340D159F4A01");
            UIControlBuilder.SetButtonAccessKey(CustBatchAccountDoc);
            CustBatchAccountDoc.UIModel = _strongPart.Model.ElementID;
            CustBatchAccountDoc.Action = "CustBatchAccountDoc";
            CustBatchAccountDoc.Text = "生成对账单";

            ((UFWebToolbarAdapter)_Toolbar).Items.Add(CustBatchAccountDoc as System.Web.UI.WebControls.WebControl);
            CustBatchAccountDoc.Click += new EventHandler(CustBatchAccountDoc_Click);
        }
        public void CustBatchAccountDoc_Click(object sender, EventArgs e)
        {
            _strongPart.Model.ClearErrorMessage();
            _strongPart.DataCollect();
            IUIModel model = _strongPart.Model;
            IList<IUIRecord> list = _strongPart.Model.ARBillHead.Cache.GetSelectRecord();
            if (list.Count == 0)
            {
                _strongPart.Model.ErrorMessage.SetErrorMessage(ref model, "请先选择需要操作的行");
            }
            try
            {
                DiXinBP.Proxy.CreateAccountDocProxy proxy = new DiXinBP.Proxy.CreateAccountDocProxy();
                proxy.ARBillLineIDs = new List<long>();
                foreach (IUIRecord uIRecord in list)
                {
                    proxy.ARBillLineIDs.Add(long.Parse(uIRecord["ID"].ToString()));
                }
                string res = proxy.Do();
                if (!string.IsNullOrEmpty(res))
                {
                    if (res.Contains("异常"))
                    {
                        _strongPart.Model.ErrorMessage.SetErrorMessage(ref model, res);
                    }
                    else
                    {
                        NameValueCollection nameValues = new NameValueCollection();
                        nameValues.Add("ID", res);
                        _strongPart.ShowModalDialog("a47b6459-62df-450c-8771-f6c2512de587", "", "992", "504", string.Empty, nameValues);

                        // ShowAlertMessage(_strongPart, "生成对账单成功,单号为:" + res);
                    }
                }
            }
            catch (Exception ex)
            {
                _strongPart.Model.ErrorMessage.SetErrorMessage(ref model, ex.Message);
            }
        }

 

posted @ 2025-09-05 09:12  江境纣州  阅读(4)  评论(0)    收藏  举报