static void LoadDetail(ProductInStore dmo) { if (dmo.ProductInStoreTemplate_ID == null) { throw new ArgumentException("请先选择成品入库模板"); } dmo.Details.Clear(); var query = new DQueryDom(new JoinAlias(typeof(ProductInStoreTemplate_GoodsDetail))); query.Columns.Add(DQSelectColumn.Field("Goods_ID")); query.Columns.Add(DQSelectColumn.Field("Goods_Name")); query.Columns.Add(DQSelectColumn.Field("Goods_Code")); query.Columns.Add(DQSelectColumn.Field("Goods_MainUnitRatio")); query.Columns.Add(DQSelectColumn.Field("Goods_SecondUnitRatio")); query.Where.Conditions.Add(DQCondition.EQ("ProductInStoreTemplate_ID", dmo.ProductInStoreTemplate_ID)); query.EExecuteList <long, string, string>().Select(x => new ProductInStore_Detail { ProductInStore_ID = dmo.ID, Goods_ID = x.Item1, Goods_Name = x.Item2, Goods_Code = x.Item3 }).EAddToCollection(dmo.Details); dmo.Details.Clear(); using (var context = new TransactionContext()) { using (var reader = context.Session.ExecuteReader(query)) { while (reader.Read()) { var detail = new ProductInStore_Detail { Goods_ID = (long)reader[0], Goods_Name = (string)reader[1], Goods_Code = (string)reader[2], Goods_MainUnitRatio = (Money <decimal>?)reader[3], Goods_SecondUnitRatio = (Money <decimal>?)reader[4] }; dmo.Details.Add(detail); } } } }
private void AddToolsBar(HLayoutPanel hPanel) { if (!CanSave) { return; } hPanel.Add(new SimpleLabel("选择存货")); var selectGoods = hPanel.Add(new ChoiceBox(B3ButcheryDataSource.存货带编号) { Width = Unit.Pixel(130), EnableMultiSelection = true, EnableInputArgument = true, AutoPostBack = true }); mDFContainer.AddNonDFControl(selectGoods, "$SelectGoods"); selectGoods.SelectedValueChanged += delegate { detailGrid.GetFromUI(); if (!selectGoods.IsEmpty) { var config = new B3ButcheryConfig(); DateTime?productionDate = null; //判断当前配置 否为当天时间,是 为入库时间 默认是 否 if (config.ProductInStoreChooseDate.Value) { productionDate = Dmo.InStoreDate; } else { productionDate = DateTime.Today; } foreach (var item in selectGoods.GetValues()) { var d = new ProductInStore_Detail() { Goods_ID = long.Parse(item), ProductionDate = productionDate, Price = 0 }; DmoUtil.RefreshDependency(d, "Goods_ID"); var last = Dmo.Details.LastOrDefault(); if (last != null) { d.BrandItem_ID = last.BrandItem_ID; d.BrandItem_Name = last.BrandItem_Name; } Dmo.Details.Add(d); } } selectGoods.Clear(); detailGrid.DataBind(); var script = B3ButcheryWebUtil.SetCursorPositionScript(butcheryConfig.ProductInStoreCursorField, "$DetailGrid", Dmo.Details.Count, detailGrid.PageSize); if (!string.IsNullOrEmpty(script)) { Page.ClientScript.RegisterStartupScript(GetType(), "Startup", script, true); } }; var addGoodsbt = hPanel.Add(new DialogButton { Text = "选择存货", }); addGoodsbt.Url = "/B3Butchery/Dialogs/SelectGoodsDialog.aspx"; addGoodsbt.Click += delegate { detailGrid.GetFromUI(); var details = DialogUtil.GetCachedObj <TemGoodsDetail>(this); foreach (var temGoodsDetail in details) { var detail = new ProductInStore_Detail(); detail.Goods_ID = temGoodsDetail.Goods_ID; DmoUtil.RefreshDependency(detail, "Goods_ID"); detail.TaxRate = detail.Goods_TaxRate; detail.Number = temGoodsDetail.Number; detail.SecondNumber = temGoodsDetail.SecondNumber; Dmo.Details.Add(detail); } detailGrid.DataBind(); }; hPanel.Add(new SimpleLabel("生产日期")); var selectDate = new DateInput(); hPanel.Add(selectDate); var summary = new TSButton() { Text = "统一生产日期" }; summary.Click += (sender, e) => { if (!selectDate.IsEmpty) { detailGrid.GetFromUI(); var date = selectDate.Value; foreach (var r in Dmo.Details) { r.ProductionDate = date; } detailGrid.DataBind(); } }; hPanel.Add(summary); var quickSelctButton = new DialogButton() { Url = "~/B3UnitedInfos/Dialogs/QucicklySelectGoodsDetailsDialog.aspx", Text = "快速选择" }; quickSelctButton.Click += delegate { ReceiveSelectedGoodsDetailDialog(); }; hPanel.Add(quickSelctButton); hPanel.Add(new TSButton("更新生产计划号", delegate { GetFromUI(); foreach (var item in Dmo.Details) { item.ProductPlan_ID = Dmo.ProductPlan_ID; item.ProductPlan_Name = Dmo.ProductPlan_Name; } detailGrid.DataBind(); })); ProduceFinishBtn(hPanel, this);//耘垦选择生产完工单button var loadProductInStoreTemp = hPanel.Add(new DialogButton { Text = "选择模板", }); loadProductInStoreTemp.Url = "/B3Butchery/Dialogs/ProductInStoreTempDialog.aspx"; loadProductInStoreTemp.Click += delegate { detailGrid.GetFromUI(); var temp = DialogUtil.GetCachedObj <ProductInStore_Temp>(this).FirstOrDefault(); Dmo.AccountingUnit_ID = temp.AccountingUnit_ID; Dmo.AccountingUnit_Name = temp.AccountingUnit_Name; Dmo.Department_ID = temp.Department_ID; Dmo.Department_Name = temp.Department_Name; Dmo.Employee_ID = temp.Employee_ID; Dmo.Employee_Name = temp.Employee_Name; Dmo.InStoreType_ID = temp.InStoreType_ID; Dmo.InStoreType_Name = temp.InStoreType_Name; Dmo.Store_ID = temp.Store_ID; Dmo.Store_Name = temp.Store_Name; Dmo.CheckEmployee_ID = temp.CheckEmployee_ID; Dmo.CheckEmployee_Name = temp.CheckEmployee_Name; Dmo.CheckDate = temp.CheckDate; if (Dmo.InStoreDate != null) { Dmo.InStoreDate = temp.InStoreDate; } foreach (var de in temp.Details) { var detail = new ProductInStore_Detail(); detail.BrandItem_ID = de.BrandItem_ID; detail.BrandItem_Name = de.BrandItem_Name; detail.Goods_ID = de.Goods_ID; detail.Goods_Name = de.Goods_Name; detail.Goods_Spec = de.Goods_Spec; detail.Goods_Code = de.Goods_Code; DmoUtil.RefreshDependency(detail, "Goods_ID"); Dmo.Details.Add(detail); } AppToUI(); detailGrid.DataBind(); }; }