using BWP.B3ExportBase;
|
|
using BWP.B3ExportBase.BL;
|
|
using BWP.B3Frameworks;
|
|
using BWP.B3Frameworks.Utils;
|
|
using BWP.Web.Layout;
|
|
using BWP.Web.Utils;
|
|
using Forks.EnterpriseServices.BusinessInterfaces;
|
|
using Forks.EnterpriseServices.DataForm;
|
|
using Forks.EnterpriseServices.DomainObjects2;
|
|
using Forks.EnterpriseServices.DomainObjects2.DQuery;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Security;
|
|
using System.Text;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using TSingSoft.WebControls2;
|
|
using TSingSoft.WebPluginFramework;
|
|
using Forks.Utils.Collections;
|
|
|
|
namespace BWP.Web
|
|
{
|
|
public abstract class ExportBaseInfoList<TDmo, TBL> : ListPageBase, IExportUIBase
|
|
where TBL : IExportBaseBL
|
|
{
|
|
protected override bool EnableExcelExport
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
protected readonly static DFInfo mDFInfo = DFInfo.Get(typeof(TDmo));
|
|
|
|
public virtual Control CreateUI()
|
|
{
|
|
return null;
|
|
}
|
|
|
|
protected TBL BL = BIFactory.Create<TBL>();
|
|
private ChoiceBox _chb;
|
|
|
|
|
|
private short? _billTypeID;
|
|
protected short BillTypeID
|
|
{
|
|
get
|
|
{
|
|
if (_billTypeID == null)
|
|
{
|
|
_billTypeID = DmoTypeIDAttribute.GetID(typeof(TDmo));
|
|
}
|
|
return _billTypeID.Value;
|
|
}
|
|
}
|
|
|
|
private short? _methodID;
|
|
|
|
public short MethodID
|
|
{
|
|
get
|
|
{
|
|
if (_methodID == null)
|
|
_methodID = BL.GetMethodID();
|
|
return _methodID.Value;
|
|
}
|
|
}
|
|
|
|
public abstract string Url { get; }
|
|
|
|
protected virtual string AccessRoleName
|
|
{
|
|
get { return ""; }
|
|
}
|
|
|
|
protected override void InitForm(System.Web.UI.HtmlControls.HtmlForm form)
|
|
{
|
|
|
|
var hPanel = new HLayoutPanel();
|
|
hPanel.Add(new SimpleLabel("导出方法"));
|
|
form.Controls.Add(hPanel);
|
|
_chb = hPanel.Add(new ChoiceBox(B3ExportBaseConsts.DataSources.导出方法));
|
|
_chb.Width = 150;
|
|
_chb.AutoPostBack = true;
|
|
_chb.EnableInputArgument = true;
|
|
_chb.SelectedValueChanged += delegate
|
|
{
|
|
var ui = B3ExportBaseUtil.GetExportUI(short.Parse(_chb.Value));
|
|
if (ui == null)
|
|
return;
|
|
if (!string.IsNullOrEmpty(ui.Url))
|
|
{
|
|
AspUtil.Redirect(ui.Url);
|
|
}
|
|
else
|
|
{
|
|
AspUtil.Redirect("~/B3ExportBase/ExportPage.aspx?methodID=" + _chb.Value);
|
|
}
|
|
};
|
|
if (BLContext.User.IsInRole("B3ExportBase.接口管理.配置"))
|
|
{
|
|
var button = new TSButton("配置") { UseSubmitBehavior = false };
|
|
button.OnClientClick = string.Format("preventEventDefault(event);OpenUrlInTopTab('B3ExportBase/ExportConfigEdit.aspx?methodID={0}','{1}配置');", MethodID, Caption);
|
|
hPanel.Add(button);
|
|
}
|
|
base.InitForm(form);
|
|
}
|
|
|
|
static readonly bool IsWithCode = TypeUtil.IsWithCodeBaseInfo(typeof(TDmo));
|
|
protected Control CreateDefaultBaseInfoQueryControls(Action<LayoutManager, AutoLayoutConfig> beforeCreateLayout = null)
|
|
{
|
|
var layoutManager = new LayoutManager("", mDFInfo, mQueryContainer);
|
|
var config = new AutoLayoutConfig() { Cols = 8, DefaultLabelWidth = 4 };
|
|
config.Add("ID");
|
|
config.Add("Name");
|
|
if (IsWithCode)
|
|
{
|
|
config.Add("Code");
|
|
}
|
|
config.Add("Stopped");
|
|
config.Add("IsLocked");
|
|
config.Add("Remark");
|
|
layoutManager.Config = config;
|
|
if (beforeCreateLayout != null)
|
|
{
|
|
beforeCreateLayout(layoutManager, config);
|
|
}
|
|
|
|
var section = mPageLayoutManager.AddSection(B3FrameworksConsts.PageLayouts.QueryConditions, B3FrameworksConsts.PageLayouts.QueryConditions_DisplayName);
|
|
section.ApplyLayout(layoutManager, config, mPageLayoutManager, mDFInfo);
|
|
return layoutManager.CreateLayout();
|
|
}
|
|
|
|
protected override void AddGrid(Control parent)
|
|
{
|
|
var hbox = new HLayoutPanel();
|
|
hbox.CssClass += " LeftPaddingWrapper";
|
|
parent.Controls.Add(hbox);
|
|
AddExportControl(hbox);
|
|
base.AddGrid(parent);
|
|
}
|
|
|
|
protected virtual void AddExportControl(HLayoutPanel hbox)
|
|
{
|
|
var btnExport = hbox.Add(new TSButton("导出"));
|
|
btnExport.Click += (sender, obj) => Export();
|
|
hbox.Add(new LiteralControl(" "));
|
|
}
|
|
|
|
protected virtual void BeforeUnExport(List<long> ids)
|
|
{
|
|
}
|
|
|
|
private void Export()
|
|
{
|
|
var idList = mBrowseGrid.GetSelectedItems().Select(item => (long)item["ID"]).ToList();
|
|
var message = DoExport(idList);
|
|
AspUtil.Alert(this, message);
|
|
mBrowseGrid.DataBind();
|
|
}
|
|
|
|
protected abstract string DoExport(List<long> idList);
|
|
|
|
protected override void InitBrowseGrid(DFBrowseGrid grid)
|
|
{
|
|
base.InitBrowseGrid(grid);
|
|
var section = mPageLayoutManager.AddSection(B3FrameworksConsts.PageLayouts.QueryResult, B3FrameworksConsts.PageLayouts.QueryResult_DisplayName);
|
|
section.ApplyLayout(grid, mPageLayoutManager, mDFInfo);
|
|
grid.MultiSelectionEnabled = true;
|
|
}
|
|
|
|
protected override DQueryDom GetQueryDom()
|
|
{
|
|
var query = base.GetQueryDom();
|
|
OrganizationUtil.AddOrganizationLimit(query, typeof(TDmo));
|
|
if (query.OrderBy.Expressions.Count == 0)
|
|
{
|
|
query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID", true));
|
|
}
|
|
return query;
|
|
}
|
|
|
|
|
|
protected override void OnLoad(EventArgs e)
|
|
{
|
|
if (!IsPostBack && MethodID > 0)
|
|
{
|
|
_chb.Value = MethodID.ToString();
|
|
_chb.DisplayValue = Caption;
|
|
}
|
|
base.OnLoad(e);
|
|
}
|
|
|
|
protected override bool NotWaitingUserInput()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
protected override void OnInit(EventArgs e)
|
|
{
|
|
if (!string.IsNullOrEmpty(AccessRoleName) && !User.IsInRole(AccessRoleName))
|
|
{
|
|
throw new SecurityException("您无权访问此页面");
|
|
}
|
|
|
|
base.OnInit(e);
|
|
}
|
|
|
|
protected override void CreateDFBrowseGridColumns(DFBrowseGrid grid)
|
|
{
|
|
if (string.IsNullOrEmpty(EditUrl))
|
|
{
|
|
AddDFBrowseGridColumn(grid, "ID");
|
|
}
|
|
else
|
|
{
|
|
grid.Columns.EAdd(new DFBrowseGridCustomExtColumn((row, cell, dataSourceIndex) =>
|
|
{
|
|
var id = row["ID"];
|
|
var linkButton = new LinkButton();
|
|
linkButton.OnClientClick = string.Format("OpenUrlInTopTab('{0}?ID={1}');return false;", EditUrl, id);
|
|
linkButton.Text = string.Format("No.{0}", id);
|
|
cell.Controls.Add(linkButton);
|
|
cell.Align = "center";
|
|
})).HeaderText = "单号";
|
|
}
|
|
|
|
if (IsWithCode)
|
|
AddDFBrowseGridColumn(grid, "Code");
|
|
AddDFBrowseGridColumn(grid, "Name");
|
|
AddDFBrowseGridColumn(grid, "Stopped");
|
|
AddDFBrowseGridColumn(grid, "IsLocked");
|
|
AddDFBrowseGridColumn(grid, "Remark");
|
|
}
|
|
|
|
protected virtual string EditUrl
|
|
{
|
|
get
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
|
|
protected virtual string LogicName
|
|
{
|
|
get { return mDFInfo.LogicName; }
|
|
}
|
|
//conString = InnerBLUtil.GetDmoPropertyByID<string>(context.Session, typeof(ExtSystem), "Address", extSystemID);
|
|
}
|
|
}
|