| @ -1,126 +0,0 @@ | |||
| using BWP.B3SheepButcherManage.BL; | |||
| using BWP.B3SheepButcherManage.BO; | |||
| using BWP.Web.CustomPageLayout; | |||
| using BWP.Web.Layout; | |||
| using BWP.Web.WebControls; | |||
| using Forks.EnterpriseServices.DataForm; | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Linq; | |||
| using System.Text; | |||
| using System.Web.UI; | |||
| using System.Web.UI.WebControls; | |||
| using TSingSoft.WebControls2; | |||
| using Forks.Utils.Collections; | |||
| using BWP.Web.Utils; | |||
| namespace BWP.Web.Pages.B3SheepButcherManage.Bills.ButcherOrder_ | |||
| { | |||
| class ButcherOrderEdit : DepartmentWorkFlowBillEditPage<ButcherOrder, IButcherOrderBL> | |||
| { | |||
| private DFEditGrid detailGrid; | |||
| protected override void BuildBasePropertiesEditor(TitlePanel titlePanel, PageLayoutSection section) | |||
| { | |||
| var layoutManager = new LayoutManager("main", mDFInfo, mDFContainer); | |||
| var config = new AutoLayoutConfig(); | |||
| config.Add("AccountingUnit_ID"); | |||
| config.Add("Department_ID"); | |||
| config.Add("Date"); | |||
| config.Add("Employee_ID"); | |||
| config.Add("Remark"); | |||
| layoutManager.Config = config; | |||
| section.ApplyLayout(layoutManager, config, mPageLayoutManager, mDFInfo); | |||
| titlePanel.Controls.Add(layoutManager.CreateLayout()); | |||
| } | |||
| protected override void BuildBody(Control form) | |||
| { | |||
| base.BuildBody(form); | |||
| CreateDetailPanel(form.EAdd(new TitlePanel("排宰明细"))); | |||
| } | |||
| private void CreateDetailPanel(TitlePanel titlePanel) | |||
| { | |||
| var vPanel = new VLayoutPanel(); | |||
| titlePanel.Controls.Add(vPanel); | |||
| if (CanSave) | |||
| { | |||
| var hPanel = vPanel.Add(new HLayoutPanel(), new VLayoutOption(HorizontalAlign.Left)); | |||
| var dialogButton = hPanel.Add(new DialogButton | |||
| { | |||
| Text = "选择过磅单", | |||
| Url = string.Format("SelectWeighBillDialog.aspx?ID={0}&", MinDmo.ID) | |||
| }); | |||
| dialogButton.BeforeClientClick = "var accID=__DFContainer.getValue('AccountingUnit_ID'); if (accID == '') { alert('先选择会计单位');return false;}"; | |||
| dialogButton.ClientDynamicParamGetter = "return 'AccountingUnit_ID=' + __DFContainer.getValue('AccountingUnit_ID')"; | |||
| dialogButton.Click += delegate | |||
| { | |||
| detailGrid.GetFromUI(); | |||
| var details = DialogUtil.GetCachedObj<ButcherOrder_Detail>(this); | |||
| var selectItems = detailGrid.GetSelectedItems(); | |||
| if (selectItems.Count > 0) | |||
| { | |||
| var selectDetail = (ButcherOrder_Detail)(selectItems[0]); | |||
| var idx = Dmo.Details.IndexOf(selectDetail) + 1; | |||
| foreach (var detail in details) | |||
| { | |||
| Dmo.Details.Insert(idx, detail); | |||
| idx++; | |||
| } | |||
| } | |||
| else | |||
| { | |||
| foreach (var detail in details) | |||
| Dmo.Details.Add(detail); | |||
| } | |||
| detailGrid.DataBind(); | |||
| }; | |||
| } | |||
| var detailEditor = new DFCollectionEditor<ButcherOrder_Detail>(() => Dmo.Details); | |||
| detailEditor.AllowDeletionFunc = () => CanSave; | |||
| detailEditor.CanDeleteFunc = (detail) => CanSave; | |||
| detailEditor.IsEditableFunc = (field, detail) => CanSave; | |||
| detailEditor.CanSelectFunc = (detail) => CanSave; | |||
| detailGrid = vPanel.Add(new DFEditGrid(detailEditor) { Width = Unit.Percentage(100), MultiSelectionEnabled = CanSave }); | |||
| detailGrid.Columns.EAdd(new DFEditGridColumn<DFTextBox>("Sequence")).InitEditControl += (sender, e) => | |||
| { | |||
| e.Control.Style["width"] = "160px"; | |||
| }; | |||
| detailGrid.Columns.EAdd(new DFEditGridColumn<DFTextBox>("WeightBill_ID")).InitEditControl += (sender, e) => | |||
| { | |||
| e.Control.Style["width"] = "160px"; | |||
| }; | |||
| detailGrid.Columns.Add(new DFEditGridColumn<DFValueLabel>("Supplier_Name")); | |||
| detailGrid.Columns.Add(new DFEditGridColumn<DFValueLabel>("BuyNum")); | |||
| detailGrid.Columns.EAdd(new DFEditGridColumn<DFTextBox>("Number")).InitEditControl += (sender, e) => | |||
| { | |||
| e.Control.Style["width"] = "160px"; | |||
| }; | |||
| detailGrid.PreferWidthGridSet = new Dictionary<string, Unit> { { "顺序号", Unit.Percentage(20) }, { "过磅单号", Unit.Percentage(20) }, { "排宰头数", Unit.Percentage(20) } }; | |||
| var section2 = mPageLayoutManager.AddSection("detailColumns1", "明细"); | |||
| section2.ApplyLayout(detailGrid, mPageLayoutManager, DFInfo.Get(typeof(ButcherOrder_Detail))); | |||
| titlePanel.SetPageLayoutSetting(mPageLayoutManager, section2.Name); | |||
| mDFContainer.AddNonDFControl(detailGrid, "$Details"); | |||
| } | |||
| protected override void OnLoad(EventArgs e) | |||
| { | |||
| base.OnLoad(e); | |||
| if (!IsPostBack) | |||
| DataBind(); | |||
| } | |||
| public override void GetFromUI() | |||
| { | |||
| base.GetFromUI(); | |||
| detailGrid.GetFromUI(); | |||
| } | |||
| protected override bool EnableReferToCreate | |||
| { | |||
| get { return false; } | |||
| } | |||
| } | |||
| } | |||
| @ -1,38 +0,0 @@ | |||
| using BWP.B3SheepButcherManage.BL; | |||
| using BWP.B3SheepButcherManage.BO; | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Linq; | |||
| using System.Text; | |||
| using TSingSoft.WebControls2; | |||
| namespace BWP.Web.Pages.B3SheepButcherManage.Bills.ButcherOrder_ | |||
| { | |||
| class ButcherOrderList : DomainBillListPage<ButcherOrder, IButcherOrderBL> | |||
| { | |||
| protected override void AddQueryControls(VLayoutPanel vPanel) | |||
| { | |||
| vPanel.Add(CreateDefaultBillQueryControls((panel, config) => | |||
| { | |||
| config.Add("Date"); | |||
| config.Add("AccountingUnit_ID"); | |||
| config.Add("Department_ID"); | |||
| config.Add("Employee_ID"); | |||
| })); | |||
| } | |||
| protected override void AddDFBrowseGridColumn(DFBrowseGrid grid, string field) | |||
| { | |||
| base.AddDFBrowseGridColumn(grid, field); | |||
| if (field == "BillState") | |||
| { | |||
| AddDFBrowseGridColumn(grid, "Date"); | |||
| AddDFBrowseGridColumn(grid, "AccountingUnit_Name"); | |||
| AddDFBrowseGridColumn(grid, "Department_Name"); | |||
| AddDFBrowseGridColumn(grid, "Employee_Name"); | |||
| AddDFBrowseGridColumn(grid, "CheckUser_Name"); | |||
| AddDFBrowseGridColumn(grid, "Remark"); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @ -1,19 +0,0 @@ | |||
| using BWP.B3SheepButcherManage.BL; | |||
| using BWP.B3SheepButcherManage.BO; | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Linq; | |||
| using System.Text; | |||
| namespace BWP.Web.Pages.B3SheepButcherManage.Bills.ButcherOrder_ | |||
| { | |||
| class ButcherOrderPrint : DomainTemplatePrintPage<ButcherOrder, IButcherOrderBL> | |||
| { | |||
| protected override void AddParameters(IDictionary<string, object> dic) | |||
| { | |||
| dic.Add("$ID", Dmo.ID); | |||
| dic.Add("$Details", Dmo.Details); | |||
| dic.Add("$DetailType", typeof(ButcherOrder_Detail)); | |||
| } | |||
| } | |||
| } | |||
| @ -1,100 +0,0 @@ | |||
| using BWP.B3SheepButcherManage.BO; | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Linq; | |||
| using System.Text; | |||
| using TSingSoft.WebControls2; | |||
| using Forks.Utils.Collections; | |||
| using BWP.Web.Layout; | |||
| using Forks.EnterpriseServices.DomainObjects2; | |||
| using Forks.EnterpriseServices.DomainObjects2.DQuery; | |||
| using Forks.EnterpriseServices.SqlDoms; | |||
| using BWP.B3Frameworks.BO.NamedValueTemplate; | |||
| using BWP.B3Frameworks; | |||
| using BWP.B3Frameworks.Utils; | |||
| using Forks.EnterpriseServices.DataForm; | |||
| namespace BWP.Web.Pages.B3SheepButcherManage.Bills.ButcherOrder_ | |||
| { | |||
| class SelectWeighBillDialog : DmoMultiSelectDialog<WeightBill, ButcherOrder_Detail> | |||
| { | |||
| protected override void CreateQueryGridColumns(DFBrowseGrid grid) | |||
| { | |||
| grid.Columns.Add(new DFBrowseGridColumn("ID")); | |||
| grid.Columns.Add(new DFBrowseGridColumn("Supplier_Name")); | |||
| grid.Columns.Add(new DFBrowseGridColumn("Number")); | |||
| grid.Columns.Add(new DFBrowseGridColumn("LiveColonyHouse_Name")); | |||
| grid.Columns.Add(new DFBrowseGridColumn("AlreadyNumber")); | |||
| grid.Columns.EAdd(new DFEditGridColumn("ThisNumber")).HeaderText = "本次计划头数"; | |||
| grid.Columns.Add(new DFBrowseGridColumn("Remark")); | |||
| } | |||
| protected override void CreateQuery(VLayoutPanel vPanel) | |||
| { | |||
| var layout = new LayoutManager("", mDFInfo, mQueryContainer); | |||
| var config = new AutoLayoutConfig(); | |||
| config.Add("WeighTime"); | |||
| layout.Config = config; | |||
| vPanel.Add(layout.CreateLayout()); | |||
| base.CreateQuery(vPanel); | |||
| } | |||
| protected override DQueryDom GetQueryDom() | |||
| { | |||
| var dom = base.GetQueryDom(); | |||
| var detail = JoinAlias.Create("detail"); | |||
| var temp = new JoinAlias(typeof(AlreadyTemp)); | |||
| AlreadyTemp.Register(dom); | |||
| dom.From.AddJoin(JoinType.Left, new DQDmoSource(temp), DQCondition.EQ(detail, "WeightBill_ID", temp, "WeightBill_ID")); | |||
| dom.Columns.Add(DQSelectColumn.Field("Supplier_Name")); | |||
| dom.Columns.Add(DQSelectColumn.Field("ID", "过磅单号")); | |||
| dom.Columns.Add(DQSelectColumn.Field("BuyNum")); | |||
| dom.Columns.Add(DQSelectColumn.Field("Number", detail, "收购头数")); | |||
| dom.Columns.Add(DQSelectColumn.Field("LiveColonyHouse_Name", detail)); | |||
| dom.Columns.Add(DQSelectColumn.Field("AlreadyNumber", temp, "已排头数")); | |||
| var lastNumber = DQExpression.Subtract(DQExpression.IfNull(DQExpression.Field(detail, "Number"), DQExpression.Value(0)), DQExpression.IfNull(DQExpression.Field(temp, "AlreadyNumber"), DQExpression.Value(0))); | |||
| dom.Columns.Add(DQSelectColumn.Create(lastNumber, "ThisNumber")); | |||
| dom.Columns.Add(DQSelectColumn.Field("Remark", detail)); | |||
| dom.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("AccountingUnit_ID", long.Parse(Request.QueryString["AccountingUnit_ID"])), DQCondition.InEQ("BillState", 单据状态.已作废), DQCondition.EQ("Domain_ID", DomainContext.Current.ID))); | |||
| dom.Where.Conditions.Add(DQCondition.GreaterThan(lastNumber, DQExpression.Value(0))); | |||
| OrganizationUtil.AddOrganizationLimit(dom, typeof(WeightBill)); | |||
| return dom; | |||
| } | |||
| protected override void SetResultFromDFDataRow(ButcherOrder_Detail dmo, DFDataRow row) | |||
| { | |||
| var number = (int?)row["Number"]; | |||
| var already = (int?)row["AlreadyNumber"]; | |||
| dmo.Supplier_Name = (string)row["Supplier_Name"]; | |||
| dmo.WeightBill_ID = (long)row["ID"]; | |||
| dmo.BuyNum = (int?)row["BuyNum"]; | |||
| var thiNumber = row["ThisNumber"]; | |||
| if (thiNumber == null) | |||
| throw new Exception("本次计划头数不能为空"); | |||
| dmo.Number = Convert.ToInt32(thiNumber); | |||
| var more = (already ?? 0) + (dmo.Number ?? 0) - (number ?? 0); | |||
| if (more > 0) | |||
| throw new Exception(string.Format("过磅单No.{0} 排宰头数超出收购头数{1}头", dmo.WeightBill_ID, more)); | |||
| } | |||
| class AlreadyTemp | |||
| { | |||
| public long WeightBill_ID { get; set; } | |||
| public int AlreadyNumber { get; set; } | |||
| public static void Register(DQueryDom root) | |||
| { | |||
| var main = new JoinAlias(typeof(ButcherOrder)); | |||
| var detail = new JoinAlias(typeof(ButcherOrder_Detail)); | |||
| var query = new DQueryDom(main); | |||
| query.From.AddJoin(JoinType.Inner, new DQDmoSource(detail), DQCondition.EQ(main, "ID", detail, "ButcherOrder_ID")); | |||
| query.Columns.Add(DQSelectColumn.Field("WeightBill_ID", detail)); | |||
| query.Columns.Add(DQSelectColumn.Sum(detail, "Number")); | |||
| query.GroupBy.Expressions.Add(DQExpression.Field(detail, "WeightBill_ID")); | |||
| query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ(main, "Domain_ID", DomainContext.Current.ID), (DQCondition.InEQ(main, "BillState", 单据状态.已作废)))); | |||
| root.RegisterQueryTable(typeof(AlreadyTemp), new string[] { "WeightBill_ID", "AlreadyNumber" }, query); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @ -1,30 +0,0 @@ | |||
| <?xml version="1.0" encoding="utf-8" ?> | |||
| <Select xmlns="urn:XDQuery"> | |||
| <Columns> | |||
| <Field name="ID"/> | |||
| </Columns> | |||
| <From> | |||
| <Join type="Inner"> | |||
| <DmoClass class="BWP.B3SheepButcherManage.BO.WeightBill, B3SheepButcherManage"/> | |||
| <DmoClass class="BWP.B3SheepButcherManage.BO.WeightBill_Record, B3SheepButcherManage" alias="detail"/> | |||
| <Condition> | |||
| <EQ> | |||
| <Field name="ID"/> | |||
| <Field name="WeightBill_ID" alias="detail"/> | |||
| </EQ> | |||
| </Condition> | |||
| </Join> | |||
| </From> | |||
| <Where> | |||
| <And> | |||
| <GreaterThanOrEqual> | |||
| <Field name="WeighTime"/> | |||
| <QBE paramName="MinWeighTime" /> | |||
| </GreaterThanOrEqual> | |||
| <LessThanOrEqual> | |||
| <Field name="WeighTime"/> | |||
| <QBE paramName="MaxWeighTime"/> | |||
| </LessThanOrEqual> | |||
| </And> | |||
| </Where> | |||
| </Select> | |||
| @ -0,0 +1,209 @@ | |||
| using BWP.B3Frameworks; | |||
| using BWP.B3Frameworks.BO; | |||
| using BWP.B3Frameworks.Utils; | |||
| using BWP.B3SheepButcherManage.BO; | |||
| using BWP.Web.Utils; | |||
| using Forks.EnterpriseServices.DataForm; | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Linq; | |||
| using System.Text; | |||
| using System.Web.UI; | |||
| using System.Web.UI.HtmlControls; | |||
| using System.Web.UI.WebControls; | |||
| using TSingSoft.WebControls2; | |||
| using TSingSoft.WebPluginFramework; | |||
| using Forks.Utils.Collections; | |||
| using BWP.B3SheepButcherManage.BL; | |||
| using Forks.EnterpriseServices.BusinessInterfaces; | |||
| using BWP.Web.Layout; | |||
| using BWP.B3ProduceUnitedInfos.NamedValueTemplate; | |||
| using Forks.EnterpriseServices.DomainObjects2.DQuery; | |||
| using Forks.EnterpriseServices.DomainObjects2; | |||
| using Forks.EnterpriseServices.SqlDoms; | |||
| using BWP.B3Frameworks.BO.NamedValueTemplate; | |||
| namespace BWP.Web.Pages.B3SheepButcherManage.Bills.Butcher_ | |||
| { | |||
| class CreateButcher : AppBasePage | |||
| { | |||
| IDFInfo mDFInfo = DFInfo.Get(typeof(WeightBill)); | |||
| protected QueryContainer mQueryContainer; | |||
| /// <summary> | |||
| /// 查询结果Grid | |||
| /// </summary> | |||
| protected DFBrowseGrid queryGrid; | |||
| protected override void InitForm(HtmlForm form) | |||
| { | |||
| form.Controls.Add(new LiteralControl("<h1>排宰</h1>")); | |||
| mQueryContainer = QueryContainer.FromResource(BasisType.FullName + ".xml", BasisType.Assembly); | |||
| var vPanel = new VLayoutPanel(); | |||
| form.Controls.Add(vPanel); | |||
| CreateQuery(vPanel); | |||
| CreateQueryGrid(vPanel); | |||
| } | |||
| private void CreateQueryGrid(VLayoutPanel vPanel) | |||
| { | |||
| queryGrid = new DFBrowseGrid(new DFDataTableEditor(), GetQueryDom()) | |||
| { | |||
| Width = Unit.Percentage(100), | |||
| MultiSelectionEnabled = true, | |||
| IgnoreItemsCount = true, | |||
| }; | |||
| CreateQueryGridColumns(queryGrid); | |||
| vPanel.Add(queryGrid); | |||
| var profile = DomainUserProfileUtil.Load<B3FrameworksDomainUserProfile>(); | |||
| var hPanel = vPanel.Add(new HLayoutPanel()); | |||
| hPanel.Add(new SimpleLabel("会计单位")); | |||
| var accInput = hPanel.Add(new ChoiceBox(B3FrameworksConsts.DataSources.授权会计单位全部)); | |||
| accInput.Width = 160; | |||
| accInput.EnableTopItem = true; | |||
| if (profile.DefaultAccountingUnit_ID.HasValue) | |||
| { | |||
| accInput.Value = profile.DefaultAccountingUnit_ID.ToString(); | |||
| accInput.DisplayValue = profile.DefaultAccountingUnit_Name; | |||
| } | |||
| hPanel.Add(new SimpleLabel("部门")); | |||
| var deptInput = hPanel.Add(new ChoiceBox(B3FrameworksConsts.DataSources.授权部门全部)); | |||
| deptInput.Width = 160; | |||
| deptInput.EnableTopItem = true; | |||
| deptInput.EnableInputArgument = true; | |||
| var employee = DomainUserUtil.GetCurrentBindingMinEmployee(); | |||
| if (employee != null && employee.Domain_ID == DomainContext.Current.ID) | |||
| { | |||
| var deptID = WebBLUtil.GetDmoPropertyByID<Employee, long?>("Department_ID", employee.ID); | |||
| if (deptID.HasValue) | |||
| { | |||
| deptInput.Value = deptID.ToString(); | |||
| deptInput.DisplayValue = WebBLUtil.GetDmoPropertyByID<string>(typeof(Department), "Name", deptID.Value); | |||
| } | |||
| } | |||
| hPanel.Add(new SimpleLabel("屠宰日期")); | |||
| var dateInput = hPanel.Add(new DFDateInput()); | |||
| dateInput.Value = BLContext.Today; | |||
| var button = new TSButton("排宰"); | |||
| vPanel.Add(button); | |||
| button.Click += delegate | |||
| { | |||
| queryGrid.GetFromUI(); | |||
| IList<WeightBill_Record> selectedList = new List<WeightBill_Record>(); | |||
| foreach (var row in queryGrid.GetSelectedItems()) | |||
| { | |||
| var selectDmo = new WeightBill_Record(); | |||
| selectDmo.ID = (long)row["DetailID"]; | |||
| selectDmo.WeightBill_ID = (long)row["ID"]; | |||
| selectDmo.RemainNumber = (int?)row["RemainNumber"]; | |||
| selectDmo.ButcherNumber = (int?)row["ButcherNumber"]; | |||
| selectDmo.Number = (int)row["Number"]; | |||
| selectDmo.LiveColonyHouse_Name = (string)row["LiveColonyHouse_Name"]; | |||
| selectDmo.LiveVarieties_ID = (long?)row["LiveVarieties_ID"]; | |||
| selectedList.Add(selectDmo); | |||
| } | |||
| var mBL = BIFactory.Create<IButcherBL>(); | |||
| long? accID = null, deptID = null; | |||
| if (!accInput.IsEmpty) | |||
| accID = long.Parse(accInput.Value); | |||
| if (!deptInput.IsEmpty) | |||
| deptID = long.Parse(deptInput.Value); | |||
| var id = mBL.InsertOrUpdate(accID, deptID, dateInput.Value, selectedList); | |||
| queryGrid.DataBind(); | |||
| AspUtil.Alert(this, string.Format("排宰成功!(屠宰单号No.{0})", id)); | |||
| }; | |||
| } | |||
| void CreateQueryGridColumns(DFBrowseGrid grid) | |||
| { | |||
| grid.Columns.Add(new DFBrowseGridColumn("WeighTime")); | |||
| grid.Columns.Add(new DFBrowseGridColumn("ID")); | |||
| grid.Columns.Add(new DFBrowseGridColumn("Supplier_Name")); | |||
| grid.Columns.Add(new DFBrowseGridColumn("LiveVarieties_Name")); | |||
| grid.Columns.Add(new DFBrowseGridColumn("LiveColonyHouse_Name")); | |||
| grid.Columns.Add(new DFBrowseGridColumn("Number")); | |||
| grid.Columns.Add(new DFBrowseGridColumn("Weight")); | |||
| grid.Columns.Add(new DFBrowseGridColumn("PlanNumber")); | |||
| grid.Columns.Add(new DFBrowseGridColumn("ButcherNumber")); | |||
| grid.Columns.EAdd(new DFEditGridColumn<DFTextBox>("RemainNumber")).HeaderText = "本次计划数"; | |||
| grid.ValueColumns.Add("LiveVarieties_ID"); | |||
| } | |||
| private ChoiceBox _houseInput; | |||
| private void CreateQuery(VLayoutPanel vPanel) | |||
| { | |||
| var panel = new LayoutManager("", mDFInfo, mQueryContainer); | |||
| panel.Add("WeighTime", QueryCreator.DateRange(mDFInfo.Fields["WeighTime"], mQueryContainer, "MinWeighTime", "MaxWeighTime", null, BLContext.Today.AddDays(1).AddMinutes(-1))); | |||
| panel.Add("活体圈舍", new SimpleLabel("活体圈舍"), _houseInput = new ChoiceBox(B3ProduceUnitedInfos.B3ProduceUnitedInfosDataSources.活体圈舍)); | |||
| panel["活体圈舍"].NotAutoAddToContainer = true; | |||
| _houseInput.Width = 160; | |||
| _houseInput.EnableTopItem = true; | |||
| _houseInput.EnableInputArgument = true; | |||
| _houseInput.CodeArgument=生物资产属性.羊.Value.ToString(); | |||
| var config = new AutoLayoutConfig(); | |||
| panel.Config = config; | |||
| config.Add("ID"); | |||
| config.Add("AccountingUnit_ID"); | |||
| config.Add("Supplier_ID"); | |||
| config.Add("WeighTime"); | |||
| config.Add("活体圈舍"); | |||
| vPanel.Add(panel.CreateLayout()); | |||
| var qButton = new TSButton("开始查询"); | |||
| qButton.Click += delegate | |||
| { | |||
| queryGrid.Reset(); | |||
| queryGrid.Query = GetQueryDom(); | |||
| queryGrid.DataBind(); | |||
| }; | |||
| vPanel.Add(new HLayoutPanel { qButton, new RedirectTSButton("清除条件") }); | |||
| } | |||
| DQueryDom GetQueryDom() | |||
| { | |||
| var dom = mQueryContainer.Build(); | |||
| var detail = new JoinAlias(typeof(WeightBill_Record)); | |||
| var bill = dom.From.RootSource.Alias; | |||
| dom.From.AddJoin(JoinType.Inner, new DQDmoSource(detail), DQCondition.EQ(bill, "ID", detail, "WeightBill_ID")); | |||
| dom.Columns.Add(DQSelectColumn.Field("LiveVarieties_Name", detail)); | |||
| dom.Columns.Add(DQSelectColumn.Field("LiveVarieties_ID", detail)); | |||
| dom.Columns.Add(DQSelectColumn.Field("Number", detail)); | |||
| dom.Columns.Add(DQSelectColumn.Field("Weight", detail)); | |||
| dom.Columns.Add(DQSelectColumn.Field("RemainNumber", detail)); | |||
| dom.Columns.Add(DQSelectColumn.Field("PlanNumber", detail)); | |||
| dom.Columns.Add(DQSelectColumn.Field("ButcherNumber", detail)); | |||
| dom.Columns.Add(DQSelectColumn.Field("LiveColonyHouse_Name", detail)); | |||
| dom.Columns.Add(DQSelectColumn.Create(DQExpression.Field(detail, "ID"), "DetailID")); | |||
| dom.Where.Conditions.Add(DQCondition.EQ("BillState", 单据状态.已审核)); | |||
| dom.Where.Conditions.Add(DQCondition.GreaterThan(detail, "RemainNumber", 0)); | |||
| OrganizationUtil.AddOrganizationLimit<AccountingUnit>(dom, "AccountingUnit_ID"); | |||
| OrganizationUtil.AddOrganizationLimit<Department>(dom, "Department_ID"); | |||
| if (!_houseInput.IsEmpty) | |||
| { | |||
| dom.Where.Conditions.Add(DQCondition.EQ(detail, "LiveColonyHouse_Name", _houseInput.Value)); | |||
| } | |||
| return dom; | |||
| } | |||
| protected override void OnLoad(EventArgs e) | |||
| { | |||
| base.OnLoad(e); | |||
| if (!IsPostBack) | |||
| { | |||
| queryGrid.DataBind(); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @ -1,133 +0,0 @@ | |||
| using BWP.B3Frameworks; | |||
| using BWP.B3Frameworks.BO.NamedValueTemplate; | |||
| using BWP.B3SheepButcherManage.BO; | |||
| using Forks.EnterpriseServices.DomainObjects2; | |||
| using Forks.EnterpriseServices.DomainObjects2.DQuery; | |||
| using Forks.EnterpriseServices.SqlDoms; | |||
| using Forks.Utils.Data; | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Linq; | |||
| using System.Text; | |||
| namespace BWP.B3SheepButcherManage.BL | |||
| { | |||
| partial class ButcherBL | |||
| { | |||
| public string CreateDetailFromWeightClient(Butcher dmo) | |||
| { | |||
| string connectionString = GetConnectionStr(dmo.AccountingUnit_ID ?? 0); | |||
| if (string.IsNullOrEmpty(connectionString)) | |||
| { | |||
| throw new ApplicationException("未设置 屠宰单 数据库连接字符串!"); | |||
| } | |||
| var orderData = TempContainer.GetDate(dmo.Date); | |||
| if (!orderData.Any()) | |||
| throw new Exception("没有排宰数据"); | |||
| dmo.Details.Clear(); | |||
| return GetDataByOrder(orderData, connectionString, dmo); | |||
| } | |||
| string GetDataByOrder(List<TempContainer> orderData, string connectionString, Butcher dmo) | |||
| { | |||
| var msg = new StringBuilder(); | |||
| var sql = "select [Index],[Livestock_ID],[Livestock_Name],[Weight],[Time] from [dbo].[B3ClientService_GradeAndWeight_Detail] where [Order]= {0} and [Date] ='" + dmo.Date + "' Order by [Index]"; | |||
| using (var sqlUtil = new SqlUtil(connectionString)) | |||
| { | |||
| foreach (var item in orderData) | |||
| { | |||
| var idx = 0; | |||
| var s = string.Format(sql, item.Order); | |||
| using (var reader = sqlUtil.ExecuteReader(s)) | |||
| { | |||
| while (reader.Read()) | |||
| { | |||
| var detail = new Butcher_Detail(); | |||
| idx++; | |||
| if (!(reader["Index"] is DBNull)) | |||
| { | |||
| detail.Sequence = Convert.ToInt32(reader["Index"]); // 顺序号 | |||
| } | |||
| detail.PrePhase = item.Order; | |||
| detail.WeightBill_ID = item.WeightBill_ID; | |||
| detail.LiveVarieties_ID = item.LiveVarieties_ID; | |||
| detail.LiveVarieties_Name = item.LiveVarieties_Name; | |||
| detail.PhaseCode = string.Format("{0}-{1}", detail.PrePhase, idx); | |||
| if (!(reader["Livestock_ID"] is DBNull)) | |||
| { | |||
| detail.Livestock_ID = Convert.ToInt64(reader["Livestock_ID"]); // 级别 | |||
| } | |||
| if (!(reader["Livestock_Name"] is DBNull)) | |||
| { | |||
| detail.Livestock_Name = reader["Livestock_Name"].ToString(); // 级别 | |||
| } | |||
| if (!(reader["Weight"] is DBNull)) | |||
| { | |||
| detail.Weight = Convert.ToDecimal(reader["Weight"]); // 重量 | |||
| } | |||
| if (!(reader["Time"] is DBNull)) | |||
| { | |||
| detail.Time = Convert.ToDateTime(reader["Time"]); // 时间 | |||
| } | |||
| dmo.Details.Add(detail); | |||
| } | |||
| if (item.Number != idx) | |||
| msg.Append(string.Format("顺序号{0}排宰{1}头 读入{2}头", item.Order, item.Number, idx)); | |||
| } | |||
| } | |||
| } | |||
| return msg.ToString(); | |||
| } | |||
| class TempContainer | |||
| { | |||
| public int Order { get; set; } | |||
| public int Number { get; set; } | |||
| public long WeightBill_ID { get; set; } | |||
| public long? LiveVarieties_ID { get; set; } | |||
| public string LiveVarieties_Name { get; set; } | |||
| public static List<TempContainer> GetDate(DateTime date) | |||
| { | |||
| var order = new JoinAlias(typeof(ButcherOrder)); | |||
| var orderDetail = new JoinAlias(typeof(ButcherOrder_Detail)); | |||
| var weightDetail = new JoinAlias(typeof(WeightBill_Record)); | |||
| var query = new DQueryDom(order); | |||
| query.From.AddJoin(JoinType.Left, new DQDmoSource(orderDetail), DQCondition.EQ(order, "ID", orderDetail, "ButcherOrder_ID")); | |||
| query.From.AddJoin(JoinType.Left, new DQDmoSource(weightDetail), DQCondition.EQ(orderDetail, "WeightBill_ID", weightDetail, "WeightBill_ID")); | |||
| query.Columns.Add(DQSelectColumn.Field("Sequence", orderDetail)); | |||
| query.Columns.Add(DQSelectColumn.Field("Number", orderDetail)); | |||
| query.Columns.Add(DQSelectColumn.Field("WeightBill_ID", orderDetail)); | |||
| query.Columns.Add(DQSelectColumn.Field("LiveVarieties_ID", weightDetail)); | |||
| query.Columns.Add(DQSelectColumn.Field("LiveVarieties_Name", weightDetail)); | |||
| query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ(order, "Date", date), DQCondition.InEQ("BillState", 单据状态.已作废), DQCondition.EQ("Domain_ID", DomainContext.Current.ID))); | |||
| query.OrderBy.Expressions.Add(DQOrderByExpression.Create(orderDetail, "Sequence")); | |||
| var list = new List<TempContainer>(); | |||
| using (var session = Dmo.NewSession()) | |||
| { | |||
| using (var reader = session.ExecuteReader(query)) | |||
| { | |||
| while (reader.Read()) | |||
| { | |||
| var entity = new TempContainer(); | |||
| entity.Order = (int)reader[0]; | |||
| entity.Number = (int?)reader[1] ?? 0; | |||
| entity.WeightBill_ID = (long)reader[2]; | |||
| entity.LiveVarieties_ID = (long?)reader[3]; | |||
| entity.LiveVarieties_Name = (string)reader[4]; | |||
| list.Add(entity); | |||
| } | |||
| } | |||
| } | |||
| return list; | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @ -1,30 +0,0 @@ | |||
| using BWP.B3Frameworks.BL; | |||
| using BWP.B3SheepButcherManage.BO; | |||
| using Forks.EnterpriseServices; | |||
| using Forks.EnterpriseServices.BusinessInterfaces; | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Linq; | |||
| using System.Text; | |||
| namespace BWP.B3SheepButcherManage.BL | |||
| { | |||
| [BusinessInterface(typeof(ButcherOrderBL))] | |||
| [LogicName("羊排宰单")] | |||
| public interface IButcherOrderBL : IDepartmentWorkFlowBillBL<ButcherOrder> | |||
| { } | |||
| public class ButcherOrderBL : DepartmentWorkFlowBillBL<ButcherOrder>, IButcherOrderBL | |||
| { | |||
| protected override void beforeSave(ButcherOrder dmo) | |||
| { | |||
| var idx = 1; | |||
| foreach (var detail in dmo.Details) | |||
| { | |||
| detail.Sequence = idx; | |||
| idx++; | |||
| } | |||
| base.beforeSave(dmo); | |||
| } | |||
| } | |||
| } | |||
| @ -1,35 +0,0 @@ | |||
| using BWP.B3Frameworks; | |||
| using BWP.B3Frameworks.Attributes; | |||
| using BWP.B3Frameworks.BO; | |||
| using Forks.EnterpriseServices; | |||
| using Forks.EnterpriseServices.DataForm; | |||
| using Forks.EnterpriseServices.DomainObjects2; | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Linq; | |||
| using System.Text; | |||
| using TSingSoft.WebControls2; | |||
| namespace BWP.B3SheepButcherManage.BO | |||
| { | |||
| [DFClass, Serializable] | |||
| [LogicName("羊排宰单")] | |||
| [DmoTypeID(B3FrameworksConsts.DmoTypeIDBases.B3SheepButcherManage, B3SheepButcherManageConsts.DmoTypeIDOffsets.ButcherOrder)] | |||
| [EditUrl("~/B3SheepButcherManage/Bills/ButcherOrder_/ButcherOrderEdit.aspx")] | |||
| public class ButcherOrder : DepartmentWorkFlowBill | |||
| { | |||
| private DateTime dt = DateTime.Today; | |||
| [LogicName("宰杀日期")] | |||
| [DFExtProperty("WebControlType", DFEditControl.DateInput)] | |||
| public DateTime Date { get { return dt; } set { dt = value; } } | |||
| private ButcherOrder_DetailCollection mDetail = new ButcherOrder_DetailCollection(); | |||
| [OneToMany(typeof(ButcherOrder_Detail), "Sequence", false)] | |||
| [Join("ID", "ButcherOrder_ID")] | |||
| public ButcherOrder_DetailCollection Details | |||
| { | |||
| get { return mDetail; } | |||
| set { mDetail = value; } | |||
| } | |||
| } | |||
| } | |||
| @ -1,44 +0,0 @@ | |||
| using BWP.B3Frameworks.BO; | |||
| using Forks.EnterpriseServices; | |||
| using Forks.EnterpriseServices.DataDictionary; | |||
| using Forks.EnterpriseServices.DataForm; | |||
| using Forks.EnterpriseServices.DomainObjects2; | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Linq; | |||
| using System.Text; | |||
| namespace BWP.B3SheepButcherManage.BO | |||
| { | |||
| [DFClass, Serializable] | |||
| [LogicName("羊排宰单_明细")] | |||
| public class ButcherOrder_Detail : Base | |||
| { | |||
| [DbColumn(Index = IndexType.Normal, AllowNull = false)] | |||
| public long ButcherOrder_ID { get; set; } | |||
| [LogicName("顺序号")] | |||
| [DFNotEmpty] | |||
| public int Sequence { get; set; } | |||
| [LogicName("过磅单号")] | |||
| public long? WeightBill_ID { get; set; } | |||
| [Join("WeightBill_ID", "ID")] | |||
| [LogicName("收购头数")] | |||
| [ReferenceTo(typeof(WeightBill), "BuyNum")] | |||
| public int? BuyNum { get; set; } | |||
| [LogicName("排宰头数")] | |||
| public int? Number { get; set; } | |||
| [Join("WeightBill_ID", "ID")] | |||
| [LogicName("供应商")] | |||
| [ReferenceTo(typeof(WeightBill), "Supplier_Name")] | |||
| public string Supplier_Name { get; set; } | |||
| } | |||
| [Serializable] | |||
| public class ButcherOrder_DetailCollection : DmoCollection<ButcherOrder_Detail> | |||
| { } | |||
| } | |||
| @ -1,28 +0,0 @@ | |||
| <?xml version="1.0" encoding="utf-8" ?> | |||
| <BillReports xmlns="urn:BillReports" version="1.0" displayName="羊排宰单" phyName="羊排宰单"> | |||
| <Report phyName="标准格式"> | |||
| <BillReport xmlns="urn:BillReport" version="1" displayName="标准格式" > | |||
| <Bands> | |||
| <TextBand fontName="黑体" fontSize="15" align="Center">羊排宰单№$Dmo.ID</TextBand> | |||
| <DFInfoBand object="$Dmo" cols="4"> | |||
| <Field name="AccountingUnit_Name" lblWidth="4"/> | |||
| <Field name="Department_Name" lblWidth="4"/> | |||
| <Field name="Date" lblWidth="4"/> | |||
| <Field name="Employee_Name" lblWidth="4"/> | |||
| <Field name="Remark" lblWidth="4"/> | |||
| </DFInfoBand> | |||
| <HtmlBand> | |||
| <![CDATA[<h2>排宰明细</h2>]]> | |||
| </HtmlBand> | |||
| <DFListBand collection="$Details" itemType="$DetailType" enablePaging="true" > | |||
| <Field name="Sequence"/> | |||
| <Field name="WeightBill_ID"/> | |||
| <Field name="Supplier_Name" /> | |||
| <Field name="BuyNum" /> | |||
| <Field name="Number"/> | |||
| </DFListBand> | |||
| </Bands> | |||
| </BillReport> | |||
| </Report> | |||
| </BillReports> | |||