| @ -0,0 +1,252 @@ | |||
| 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); | |||
| } | |||
| } | |||
| @ -0,0 +1,134 @@ | |||
| using BWP.B3ExportBase; | |||
| using BWP.B3ExportBase.Utils; | |||
| using BWP.B3Frameworks; | |||
| using BWP.B3Frameworks.Utils; | |||
| using BWP.B3QingDaoWanFu.BL; | |||
| using BWP.B3UnitedInfos; | |||
| using BWP.B3UnitedInfos.BO; | |||
| using BWP.Web.Layout; | |||
| using BWP.Web.Pages.B3ExportBase; | |||
| using BWP.Web.Utils; | |||
| using Forks.EnterpriseServices.BusinessInterfaces; | |||
| using Forks.EnterpriseServices.DomainObjects2.DQuery; | |||
| using Forks.EnterpriseServices.SqlDoms; | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Linq; | |||
| using System.Text; | |||
| using System.Web.UI; | |||
| using TSingSoft.WebControls2; | |||
| using TSingSoft.WebPluginFramework; | |||
| namespace BWP.Web.Pages.B3QingDaoWanFu.ExportUI | |||
| { | |||
| // [LogicName("存货导MES")] | |||
| class GoodsExportToMES : ExportBaseInfoList<Goods, IGoodsExportBL> | |||
| { | |||
| private ChoiceBox _dfcUrl; | |||
| protected override void AddExportControl(HLayoutPanel hbox) | |||
| { | |||
| hbox.Add(new SimpleLabel("外部系统")); | |||
| _dfcUrl = hbox.Add(new ChoiceBox()); | |||
| _dfcUrl.DataKind = B3ExportBaseConsts.DataSources.外部系统; | |||
| _dfcUrl.EnableInputArgument = true; | |||
| _dfcUrl.SmartOrderEnabled = false; | |||
| _dfcUrl.EnableTopItem = true; | |||
| _dfcUrl.Width = 130; | |||
| base.AddExportControl(hbox); | |||
| } | |||
| protected override string DoExport(List<long> idList) | |||
| { | |||
| if (idList.Count == 0) | |||
| { | |||
| throw new ApplicationException("请选择档案!"); | |||
| } | |||
| if (_dfcUrl.IsEmpty) | |||
| { | |||
| throw new ApplicationException("请选择外部系统!"); | |||
| } | |||
| BL.Export(idList, long.Parse(_dfcUrl.Value)); | |||
| return BIFactory.GetLastMessage(); | |||
| } | |||
| public override string Url | |||
| { | |||
| get { return "~/B3QingDaoWanFu/ExportUI/GoodsExportToMES.aspx"; } | |||
| } | |||
| protected override string Caption | |||
| { | |||
| get { return "存货导MES存货"; } | |||
| } | |||
| protected override string EditUrl | |||
| { | |||
| get | |||
| { | |||
| return "B3UnitedInfos/BaseInfos/Goods_/GoodsEdit.aspx"; | |||
| } | |||
| } | |||
| protected override DQueryDom GetQueryDom() | |||
| { | |||
| var query = base.GetQueryDom(); | |||
| var goodsProperty = query.EJoin<GoodsProperty>(); | |||
| var catalog = query.EJoin<GoodsPropertyCatalog>("GoodsPropertyCatalog_ID", JoinType.Left, goodsProperty); | |||
| query.Columns.Add(DQSelectColumn.Create(DQExpression.Field(goodsProperty, "Name"), "存货属性")); | |||
| query.Columns.Add(DQSelectColumn.Create(DQExpression.Field(catalog, "Name"), "存货属性分类")); | |||
| TreeUtil.AddTreeCondition<GoodsPropertyCatalog>(query, mQueryContainer, "存货属性分类", catalog); | |||
| DomainUtil.AddDomainPermissionLimit(query, typeof(GoodsProperty), goodsProperty); | |||
| return query; | |||
| } | |||
| protected override void AddQueryControls(VLayoutPanel vPanel) | |||
| { | |||
| vPanel.Add(CreateDefaultBaseInfoQueryControls((layoutManager, config) => | |||
| { | |||
| layoutManager.Add("存货属性分类", new SimpleLabel("属性分类"), QueryCreator.DFChoiceBox(mDFInfo.Fields["ID"], B3UnitedInfosConsts.DataSources.存货属性分类)); | |||
| config.AddAfter("GoodsProperty_ID", "ID"); | |||
| config.AddBefore("存货属性分类", "GoodsProperty_ID"); | |||
| config.Add("ProductLine_ID"); | |||
| config.Add("Brand"); | |||
| config.Add("Origin"); | |||
| })); | |||
| } | |||
| protected override void AddDFBrowseGridColumn(DFBrowseGrid grid, string field) | |||
| { | |||
| base.AddDFBrowseGridColumn(grid, field); | |||
| if (field == "Name") | |||
| { | |||
| AddDFBrowseGridColumn(grid, "Brand"); | |||
| AddDFBrowseGridColumn(grid, "Origin"); | |||
| AddDFBrowseGridColumn(grid, "存货属性"); | |||
| AddDFBrowseGridColumn(grid, "存货属性分类"); | |||
| AddDFBrowseGridColumn(grid, "ProductLine_Name"); | |||
| AddDFBrowseGridColumn(grid, "MainUnit"); | |||
| AddDFBrowseGridColumn(grid, "SecondUnit"); | |||
| AddDFBrowseGridColumn(grid, "Spec"); | |||
| } | |||
| } | |||
| protected override void OnLoad(EventArgs e) | |||
| { | |||
| base.OnLoad(e); | |||
| if (!IsPostBack) | |||
| { | |||
| var tuple = ExportConfigUtil.LoadDefaultExtSystems(MethodID); | |||
| if (tuple != null) | |||
| { | |||
| _dfcUrl.Value = tuple.Item1.ToString(); | |||
| _dfcUrl.DisplayValue = tuple.Item2; | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @ -0,0 +1,59 @@ | |||
| <?xml version="1.0" encoding="utf-8" ?> | |||
| <Select xmlns="urn:XDQuery"> | |||
| <Columns> | |||
| <Field name="ID"/> | |||
| </Columns> | |||
| <From> | |||
| <DmoClass class="BWP.B3UnitedInfos.BO.Goods, B3UnitedInfos"/> | |||
| </From> | |||
| <Where> | |||
| <And> | |||
| <EQ> | |||
| <Field name="ID"/> | |||
| <QBE paramName="ID"/> | |||
| </EQ> | |||
| <EQ> | |||
| <Field name="GoodsProperty_ID"/> | |||
| <QBE paramName="GoodsProperty_ID"/> | |||
| </EQ> | |||
| <EQ> | |||
| <Field name="ProductLine_ID"/> | |||
| <QBE paramName="ProductLine_ID"/> | |||
| </EQ> | |||
| <Or> | |||
| <Contains> | |||
| <Field name="Name"/> | |||
| <QBE paramName="Name"/> | |||
| </Contains> | |||
| <Contains> | |||
| <Field name="Spell"/> | |||
| <QBE paramName="Name"/> | |||
| </Contains> | |||
| </Or> | |||
| <Contains> | |||
| <Field name="Code"/> | |||
| <QBE paramName="Code"/> | |||
| </Contains> | |||
| <EQ> | |||
| <Field name="Stopped"/> | |||
| <QBE paramName="Stopped"/> | |||
| </EQ> | |||
| <EQ> | |||
| <Field name="IsLocked"/> | |||
| <QBE paramName="IsLocked"/> | |||
| </EQ> | |||
| <Contains> | |||
| <Field name="Brand"/> | |||
| <QBE paramName="Brand"/> | |||
| </Contains> | |||
| <Contains> | |||
| <Field name="Origin"/> | |||
| <QBE paramName="Origin"/> | |||
| </Contains> | |||
| <Contains> | |||
| <Field name="Remark"/> | |||
| <QBE paramName="Remark"/> | |||
| </Contains> | |||
| </And> | |||
| </Where> | |||
| </Select> | |||
| @ -0,0 +1,79 @@ | |||
| using BWP.B3ExportBase; | |||
| using BWP.B3ExportBase.BL; | |||
| using BWP.B3Frameworks; | |||
| using BWP.B3UnitedInfos.BO; | |||
| using Forks.EnterpriseServices; | |||
| using Forks.EnterpriseServices.BusinessInterfaces; | |||
| using Forks.EnterpriseServices.DomainObjects2.DQuery; | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Linq; | |||
| using System.Text; | |||
| using TSingSoft.WebPluginFramework.BIPlugins.BLEvents; | |||
| using TSingSoft.WebPluginFramework; | |||
| namespace BWP.B3QingDaoWanFu.BL | |||
| { | |||
| [BusinessInterface(typeof(GoodsExportBL))] | |||
| public interface IGoodsExportBL : IExportBaseBL | |||
| { | |||
| void Export(List<long> dmoIDs, long extSystemID); | |||
| void UpdateOrInsert(Goods goods); | |||
| void Stop(string code); | |||
| void Delete(string code); | |||
| } | |||
| [LogicName("存货导MES存货")] | |||
| [ExportID(B3FrameworksConsts.DmoTypeIDBases.B3QingDaoWanFu, B3QingDaoWanFuConsts.DmoTypeIDOffsets.GoodsExport)] | |||
| public class GoodsExportBL : ExportBaseBL<Goods>, IGoodsExportBL | |||
| { | |||
| protected override void BeforeExport(List<long> dmoIDs) | |||
| { | |||
| Dmos = new List<Goods>(); | |||
| var scriptHelper = new PythonScriptHelper(string.Empty, Config.Script, this); | |||
| MinDmoProperties = new List<string>(); | |||
| MinDetailProperties = new List<string>(); | |||
| LoadFullDom = true; | |||
| //在脚本里设置是否载入整张单据 或者部分字段 | |||
| scriptHelper.Before(); | |||
| if (LoadFullDom) | |||
| { | |||
| var list = new List<long>(); | |||
| var query = new DmoQuery(typeof(Goods)); | |||
| query.Where.Conditions.EFieldInList("ID", dmoIDs); | |||
| foreach (Goods bill in Session.ExecuteList(query)) | |||
| { | |||
| if (list.IndexOf(bill.ID) == -1) | |||
| { | |||
| list.Add(bill.ID); | |||
| Dmos.Add(bill); | |||
| } | |||
| } | |||
| return; | |||
| } | |||
| LoadMinDmo(Dmos, dmoIDs); | |||
| scriptHelper.After(); | |||
| } | |||
| public void Export(List<long> dmoIDs, long extSystemID) | |||
| { | |||
| BeforeExport(dmoIDs); | |||
| } | |||
| public void UpdateOrInsert(Goods goods) | |||
| { } | |||
| public void Stop(string code) | |||
| { } | |||
| public void Delete(string code) | |||
| { } | |||
| } | |||
| } | |||
| @ -0,0 +1,15 @@ | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Linq; | |||
| using System.Text; | |||
| namespace BWP.B3QingDaoWanFu | |||
| { | |||
| public class B3QingDaoWanFuConsts | |||
| { | |||
| internal static class DmoTypeIDOffsets | |||
| { | |||
| public const byte GoodsExport = 1; | |||
| } | |||
| } | |||
| } | |||