private void StockEditorSettingForm_Load(object sender, EventArgs e) { IList <Model.DepotPosition> list = depotPositionManager.Select(this._depotId); if (list.Count == 0) { return; } foreach (Model.DepotPosition item in list) { Model.StockEditorDetal temp = this._stockEditorDetailManager.SelectByProductIdAndPositionIdAndStockHId(this._stockEditorDetail.ProductId, item.DepotPositionId, this._stockEditorDetail.StockEditorId); if (temp == null) { temp = new Book.Model.StockEditorDetal(); temp.StockEditorDetalId = Guid.NewGuid().ToString(); temp.StockEditorId = this._stockEditorDetail.StockEditorId; temp.DepotPositionId = item.DepotPositionId; temp.ProductId = this._stockEditorDetail.ProductId; temp.Product = this._stockEditorDetail.Product; temp.DepotPosition = item; temp.StockQuantity = this._stockManager.GetStockByProductIdAndDepotPositionId(this._stockEditorDetail.ProductId, item.DepotPositionId) == null ? 0 : this._stockManager.GetStockByProductIdAndDepotPositionId(this._stockEditorDetail.ProductId, item.DepotPositionId).StockQuantity1; temp.Directions = this._stockEditorDetail.Directions; temp.ProductUnitName = this._stockEditorDetail.ProductUnitName; temp.StockEditorQuantity = null; } if (StockEditorForm.dic.ContainsKey(this._stockEditorDetail.ProductId + item.DepotPositionId)) { temp.StockEditorQuantity = StockEditorForm.dic[this._stockEditorDetail.ProductId + item.DepotPositionId].StockEditorQuantity; } this.stockList.Add(temp); } this.bindingSourceStockEditorDetail.DataSource = this.stockList; this.gridControl1.RefreshDataSource(); }
public override void Refresh() { if (_stockEditor == null) { _stockEditor = new Model.StockEditor(); _stockEditor.StockEditorId = this._stockEditorManager.GetId(DateTime.Now); _stockEditor.StockEditorDate = DateTime.Now; _stockEditor.Employee0 = BL.V.ActiveOperator.Employee; //if (this.cateList.Count != 0) // category = cateList[0]; _stockEditor.Details = new List <Model.StockEditorDetal>(); _stockEditor.ProductPositionNums.Clear(); this.action = "insert"; } else { _stockEditor.Details.Clear(); if (this.action == "insert") { foreach (Model.Product product in productlist) { Model.StockEditorDetal detail = new Book.Model.StockEditorDetal(); detail.StockEditorDetalId = Guid.NewGuid().ToString(); detail.StockEditorId = _stockEditor.StockEditorId; detail.ProductName = product.ProductName; detail.ProductId = product.ProductId; detail.Id = product.Id; detail.CustomerProductName = product.CustomerProductName; detail.ProductId = product.ProductId; detail.DepotPosition = product.DepotPosition; detail.DepotPositionId = product.DepotPositionId; detail.ProductDesc = product.ProductDescription; detail.ProductVersion = product.ProductVersion; //object nums = this._stockEditorDetailManager.SelectByProductIdAndStockHId(detail.ProductId, detail.StockEditorId); //if (nums != null) // detail.StockEditorQuantity = Convert.ToDouble(nums); //else detail.StockEditorQuantity = null; detail.DepotPositionId = product.DepotPositionId; detail.ProductUnitName = this.productUnitManager.Get(product.DepotUnitId) == null ? null : this.productUnitManager.Get(product.DepotUnitId).CnName; _stockEditor.Details.Add(detail); // this.bindingSourceDetail.Position = this.bindingSourceDetail.IndexOf(detail); } } else { foreach (Model.Product product in productlist) { Model.StockEditorDetal detail = new Book.Model.StockEditorDetal(); detail.StockEditorDetalId = Guid.NewGuid().ToString(); detail.StockEditorId = _stockEditor.StockEditorId; detail.ProductName = product.ProductName; detail.ProductId = product.ProductId; detail.Id = product.Id; detail.CustomerProductName = product.CustomerProductName; detail.ProductId = product.ProductId; detail.DepotPosition = product.DepotPosition; detail.DepotPositionId = product.DepotPositionId; detail.ProductDesc = product.ProductDescription; detail.ProductVersion = product.ProductVersion; object nums = this._stockEditorDetailManager.SelectByProductIdAndStockHId(detail.ProductId, detail.StockEditorId); if (nums != null) { detail.StockEditorQuantity = Convert.ToDouble(nums); } else { detail.StockEditorQuantity = null; } detail.DepotPositionId = product.DepotPositionId; detail.ProductUnitName = this.productUnitManager.Get(product.DepotUnitId) == null ? null : this.productUnitManager.Get(product.DepotUnitId).CnName; _stockEditor.Details.Add(detail); } } } this.memoEditDirections.Text = _stockEditor.Directions; this.textEditStockEditorId.Text = _stockEditor.StockEditorId; this.dateEditStockEditorDate.DateTime = _stockEditor.StockEditorDate.Value; this.newChooseContorlEmployee0Id.EditValue = _stockEditor.Employee0; this.newChooseContorlEmployeeId.EditValue = _stockEditor.Employee; //if (_stockEditor.Supplier != null) // this.newChooseContorlSupplier.EditValue = _stockEditor.Supplier; //else // this.newChooseContorlSupplier.EditValue = null; this.lookUpEditDepotId.EditValue = this._depotManager.Get(_stockEditor.DepotId); if (_stockEditor.ProductCategoryId != null) { this.buttonEditProductCategoryId.EditValue = this._productCategoryManager.Get(_stockEditor.ProductCategoryId); } else { this.buttonEditProductCategoryId.EditValue = category; } this.bindingSourceDetail.DataSource = _stockEditor.Details; this.gridControl1.RefreshDataSource(); base.Refresh(); switch (this.action) { case "insert": case "update": this.gridView1.OptionsBehavior.Editable = true; this.textEditStockEditorId.Properties.ReadOnly = true; break; case "view": this.gridView1.OptionsBehavior.Editable = false; this.textEditStockEditorId.Properties.ReadOnly = true; break; } this.buttonEditProductCategoryId.Properties.ReadOnly = true; this.barButtonItem1.Caption = "共" + this.bindingSourceDetail.Count + "項"; }