You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

233 lines
7.2 KiB

using BWP.B3Frameworks;
using BWP.B3Frameworks.BO;
using BWP.B3Frameworks.BO.MoneyTemplate;
using BWP.B3Frameworks.BO.NamedValueTemplate;
using BWP.B3Frameworks.Utils;
using BWP.B3QingDaoWanFu.BO;
using BWP.B3Sale.BO;
using BWP.B3Sale.Utils;
using BWP.B3UnitedInfos;
using BWP.B3UnitedInfos.BO;
using BWP.Web.Layout;
using BWP.Web.Pages.B3Sale.Reports;
using BWP.Web.Utils;
using BWP.Web.WebControls;
using Forks.EnterpriseServices.DataForm;
using Forks.EnterpriseServices.DomainObjects2;
using Forks.EnterpriseServices.DomainObjects2.DQuery;
using Forks.EnterpriseServices.SqlDoms;
using Forks.Utils;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using TSingSoft.WebControls2;
using TSingSoft.WebControls2.DFGrids;
using TSingSoft.WebControls2.QBELinks;
using TSingSoft.WebPluginFramework;
using TSingSoft.WebPluginFramework.Controls;
using TSingSoft.WebPluginFramework.Exports;
namespace BWP.Web.Pages.B3QingDaoWanFu.SaleOutStore_
{
public class SaleOutStoreSimpleAnayse:DFBrowseGridReportPage
{
protected override string Caption
{
get { return "万福销售出库分析"; }
}
protected override bool EnableExcelExport
{
get
{
return true;
}
}
//已经查询
private object SearchFlag
{
set
{
ViewState["SearchFlag"] = value;
}
get
{
return ViewState["SearchFlag"];
}
}
private QueryResult GetQueryResult(LoadArguments arg)
{
var data = new DFDataTableEditor().Load(arg);
return new QueryResult(data.TotalCount, data.Data.Rows, data.Data.Columns, arg.SumColumns.Any() ? data.Data.SumRow : null);
}
protected override string AccessRoleName
{
get { return "B3QingDaoWanFu.报表.销售出库分析"; }
}
protected override bool EnableQueryPanel
{
get
{
return false;
}
}
readonly DFInfo _mainInfo = DFInfo.Get(typeof(SaleOutStore));
readonly DFInfo _detailInfo = DFInfo.Get(typeof(SaleOutStore_Detail));
private CustomPriviewAction previewAction;
private CustomPrintAction printAction;
private DFChoiceBox deliverLineInput;
private DFNamedValueInput<> billStateInput;
protected override void InitForm(HtmlForm form)
{
var group = new ButtonGroup();
previewAction = new CustomPriviewAction();
printAction = new CustomPrintAction();
if (SearchFlag != null)
{
printAction.Url = "SaleOutStoreSimpleAnaysePrint.aspx";
previewAction.Url = "SaleOutStoreSimpleAnaysePrint.aspx";
}
var billReportSelect = new BillReportSelectAction(PrintUtil.GetTemplateFile(PluginName, "SaleOutStoreSimpleAnaysePrint.xml"));
group.Actions.Add(previewAction);
group.Actions.Add(printAction);
group.Actions.Add(billReportSelect);
var hPanel = new HLayoutPanel();
hPanel.Add(group);
form.Controls.Add(hPanel);
base.InitForm(form);
}
protected override void AddQueryControls(VLayoutPanel vPanel)
{
var layout = new LayoutManager("Main", _mainInfo);
layout.Add("DeliverGoodsLine_ID", mQueryContainer.AddLink(new ChoiceBoxMultiSelectLink(deliverLineInput = QueryCreator.DFChoiceBoxEnableMultiSelection(_mainInfo.Fields["DeliverGoodsLine_ID"], B3SaleDataSources.线), s => long.Parse(s)), "DeliverGoodsLine_ID"));
layout["DeliverGoodsLine_ID"].NotAutoAddToContainer = true;
layout.Add("LoadTime", QueryCreator.TimeRange(_mainInfo.Fields["LoadTime"], mQueryContainer, "MinLoadTime", "MaxLoadTime"));
var state = mQueryContainer.Add(billStateInput = QueryCreator.(_mainInfo.Fields["BillState"], true, false, true, true), "BillState");
((ChoiceBox)state).Value = ..Value.ToString() + "|";
state.DisplayValue = "已审核;";
state.EnableInputArgument = true;
layout.Add("BillState", state);
layout.Add("OrderDate", QueryCreator.TimeRange(_mainInfo.Fields["OrderDate"], mQueryContainer, "MinOrderDate", "MaxOrderDate"));
var config = layout.CreateDefaultConfig(4);
config.Expand = false;
var section = mPageLayoutManager.AddSection("查询条件", "查询条件");
section.ApplyLayout(layout, config, mPageLayoutManager, _mainInfo);
section.SetDisplayName("DeliverGoodsLine_ID", "送货线路");
section.SetDisplayName("LoadTime", "发货时间");
section.SetDisplayName("BillState", "单据状态");
section.SetDisplayName("OrderDate", "订货时间");
vPanel.Add(layout.CreateLayout(), new VLayoutOption(HorizontalAlign.Left));
}
private Dictionary<string, string> fieldInfo = new Dictionary<string, string>() { {"Customer_Name", "购货客户" }, { "Goods_Name", "存货名称" },{ "Goods_Spec", "存货规格" }, { "Order_Detail_UnitNum", "订单数量" } };
protected override void PrepareData()
{
base.PrepareData();
var maxLoad = mQueryContainer.GetControl<DFDateTimeInput>("MaxLoadTime");
var minLoad = mQueryContainer.GetControl<DFDateTimeInput>("MinLoadTime");
var maxOrder = mQueryContainer.GetControl<DFDateTimeInput>("MaxOrderDate");
var minOrder = mQueryContainer.GetControl<DFDateTimeInput>("MinOrderDate");
var info = new SaleOutStorePrintInfo();
if (!maxLoad.IsEmpty)
{
info.MaxLoadTime = maxLoad.Date;
}
if (!maxOrder.IsEmpty)
{
info.MaxOrderDate = maxOrder.Date;
}
if (!minLoad.IsEmpty)
{
info.MinLoadTime = minLoad.Date;
}
if (!minOrder.IsEmpty)
{
info.MinOrderDate = minOrder.Date;
}
info.BillStates = string.Join("|", billStateInput.GetValues().Select(x => x.Value));
info.DeliverGoodsLines = deliverLineInput.Value;
info.Save();
printAction.Url = "SaleOutStoreSimpleAnaysePrint.aspx";
previewAction.Url = "SaleOutStoreSimpleAnaysePrint.aspx";
SearchFlag = "1";
}
protected override DQueryDom GetQueryDom()
{
var dom = base.GetQueryDom();
var root = dom.From.RootSource.Alias;
var detail = JoinAlias.Create("detail");
dom.Where.Conditions.Add(DQCondition.EQ(root, "Domain_ID", DomainContext.Current.ID));
OrganizationUtil.AddOrganizationLimit(dom, typeof(SaleOutStore));
foreach (var item in fieldInfo)
{
switch (item.Key)
{
case "Customer_Name":
dom.Columns.Add(DQSelectColumn.Create(DQExpression.Field(root, item.Key), item.Value));
dom.GroupBy.Expressions.Add(DQExpression.Field(root, item.Key));
break;
case "Goods_Name":
case "Goods_Spec":
dom.Columns.Add(DQSelectColumn.Create(DQExpression.Field(detail, item.Key), item.Value));
dom.GroupBy.Expressions.Add(DQExpression.Field(detail, item.Key));
break;
case "Order_Detail_UnitNum":
dom.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(DQExpression.Field(detail, item.Key)), item.Value));
SumColumnIndexs.Add(dom.Columns.Count - 1);
break;
default:
break;
}
}
return dom;
}
}
}