//查询选择商品 private void btn_CheckProduct2_Click(object sender, EventArgs e) { UI.Invoices.ChooseProductForm f = new Book.UI.Invoices.ChooseProductForm(); if (f.ShowDialog(this) == DialogResult.OK) { Model.Product product = f.SelectedItem as Model.Product; if (product != null) { this.btn_CheckProduct2.EditValue = product; this.bindingSource4.DataSource = this._manage.SelectByProductId(product.ProductId); if (this.bindingSource4.Count > 0) { this._CustomerProductPrice = this.bindingSource4.Current as Model.CustomerProductPrice; if (this._CustomerProductPrice.CustomerProductPriceRage != null) { AnalyzePriceRange(this._CustomerProductPrice.CustomerProductPriceRage); this.gridControl5.RefreshDataSource(); } else { this._priceRangeList.Clear(); this.gridControl5.RefreshDataSource(); } } else { this._priceRangeList.Clear(); this.gridControl5.RefreshDataSource(); } } } }
public CustomerProductPrice() { InitializeComponent(); string errorMessage = "價格區間填寫有誤,請查證后重新保存.\r請檢查以下項目\r1.價格區間是否連續.\r2.價格不能為零.\r3.<數量上限>不得小於<數量下限>.\r4.第一段價格區間,<數量下限>必須為1"; this.invalidValueExceptions.Add("PriceRange.Error", new AA(errorMessage, this.gridControl3)); //this.requireValueExceptions.Add(Model.CustomerProductPrice.PRO_ProductId, new AA("商品不能為空!", this.btn_CheckProduct)); this.bindingSourceCustomer.DataSource = (new BL.CustomerManager()).Select(); if (this.bindingSourceCustomer.DataSource != null && this.bindingSourceCustomer.Count > 0) { this._CustomerProductPriceList = this._manage.SelectByCustomerId((this.bindingSourceCustomer.Current as Model.Customer).CustomerId); this.customer = this.bindingSourceCustomer[0] as Model.Customer; } if (this._CustomerProductPriceList != null && this._CustomerProductPriceList.Count > 0) { this._CustomerProductPrice = this._CustomerProductPriceList[0]; } this.bindingSourceCustomerProduct.DataSource = this._CustomerProductPriceList; this.bindingSourcePriceRang.DataSource = this._priceRangeList; this.nccBuildEmployee.Choose = new Employees.ChooseEmployee(); this.nccChangeEmployee.Choose = new Employees.ChooseEmployee(); this.action = "view"; }
public CustomerProductPrice() { InitializeComponent(); string errorMessage = "The price range is incorrect, please check to save.\r1.The price range whether continuous.\r2.Price can not be zero.\r3.<Quantity upper limit>shall not be less than<Quantity lower limit>.\r4.The first section of the price range,<Quantity lower limit>must be 1"; this.invalidValueExceptions.Add("PriceRange.Error", new AA(errorMessage, this.gridControl3)); //this.requireValueExceptions.Add(Model.CustomerProductPrice.PRO_ProductId, new AA("商品不能為空!", this.btn_CheckProduct)); this.bindingSourceCustomer.DataSource = (new BL.CustomerManager()).Select(); if (this.bindingSourceCustomer.DataSource != null && this.bindingSourceCustomer.Count > 0) { this._CustomerProductPriceList = this._manage.SelectByCustomerId((this.bindingSourceCustomer.Current as Model.Customer).CustomerId); this.customer = this.bindingSourceCustomer[0] as Model.Customer; } if (this._CustomerProductPriceList != null && this._CustomerProductPriceList.Count > 0) { this._CustomerProductPrice = this._CustomerProductPriceList[0]; } this.bindingSourceCustomerProduct.DataSource = this._CustomerProductPriceList; this.bindingSourcePriceRang.DataSource = this._priceRangeList; this.nccBuildEmployee.Choose = new Employees.ChooseEmployee(); this.nccChangeEmployee.Choose = new Employees.ChooseEmployee(); this.action = "view"; }
/// <summary> /// Update a CustomerProductPrice. /// </summary> public void Update(Model.CustomerProductPrice customerProductPrice) { // // todo: add other logic here. // Validate(customerProductPrice); customerProductPrice.UpdateTime = DateTime.Now; accessor.Update(customerProductPrice); }
private void gridView2_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e) { if (this.action != "insert") { this.action = "view"; this._CustomerProductPrice = this.bindingSourceCustomerProduct.Current as Model.CustomerProductPrice; if (this._CustomerProductPrice != null) { Refresh(); } } }
protected override void AddNew() { this._CustomerProductPrice = new Book.Model.CustomerProductPrice(); this._CustomerProductPrice.CustomerProductPriceId = Guid.NewGuid().ToString(); this._CustomerProductPrice.Customer = this.bindingSourceCustomer.Current as Model.Customer; if (this._CustomerProductPrice.Customer != null) { this._CustomerProductPrice.CustomerId = this._CustomerProductPrice.Customer.CustomerId; } this._CustomerProductPrice.CustomerProductPriceRage = "1/999999999999/0"; this.action = "insert"; }
//增删改.选择商品 private void btn_CheckProduct_Click(object sender, EventArgs e) { if (this.action == "insert") { UI.Invoices.ChooseProductForm f = new Book.UI.Invoices.ChooseProductForm(); if (f.ShowDialog(this) == DialogResult.OK) { this._CustomerProductPrice.Product = f.SelectedItem as Model.Product; if (this._CustomerProductPrice.Product != null) { this._CustomerProductPrice.ProductId = this._CustomerProductPrice.Product.ProductId; this._CustomerProductPrice.ProductIDNo = this._CustomerProductPrice.Product.Id; this._CustomerProductPrice.ProductName = this._CustomerProductPrice.Product.ProductName; this._CustomerProductPrice.ProductDesc = this._CustomerProductPrice.Product.ProductDescription; this._CustomerProductPrice.ProductVersion = this._CustomerProductPrice.Product.ProductVersion; this._CustomerProductPrice.CustomerProductId = this._CustomerProductPrice.Product.CustomerProductName; this._CustomerProductPrice.CustomerProductsId = (new BL.CustomerProductsManager()).SelectPrimaryIdByProceName(this._CustomerProductPrice.ProductId); } this._CustomerProductPrice.Customer = this.bindingSourceCustomer.Current as Model.Customer; if (this._CustomerProductPrice.Customer != null) { this._CustomerProductPrice.CustomerId = this._CustomerProductPrice.Customer.CustomerId; } if (this._CustomerProductPriceList.Where(c => c.CustomerId == this._CustomerProductPrice.CustomerId && c.ProductId == this._CustomerProductPrice.ProductId).ToList <Model.CustomerProductPrice>().Count > 0) { //MessageBox.Show("有重複商品輸入", "提示"); //return; Model.CustomerProductPrice model = this._CustomerProductPriceList.Where(c => c.CustomerId == this._CustomerProductPrice.CustomerId && c.ProductId == this._CustomerProductPrice.ProductId).First(); model = this._CustomerProductPrice; this.bindingSourceCustomerProduct.Position = this._CustomerProductPriceList.IndexOf(this._CustomerProductPriceList.First(c => c.CustomerId == this._CustomerProductPrice.CustomerId && c.ProductId == this._CustomerProductPrice.ProductId)); } else if (this.action == "insert") { this._CustomerProductPriceList.Add(this._CustomerProductPrice); this.bindingSourceCustomerProduct.Position = this.bindingSourceCustomerProduct.IndexOf(this._CustomerProductPrice); } this.gridControl2.RefreshDataSource(); AnalyzePriceRange(this._CustomerProductPrice.CustomerProductPriceRage); this.gridControl3.RefreshDataSource(); this.btn_CheckProduct.EditValue = f.SelectedItem as Model.Product; } } }
//查询客户对应商品 private void gridView1_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e) { customer = this.bindingSourceCustomer.Current as Model.Customer; this.bindingSourceCustomerProduct.DataSource = this._CustomerProductPriceList = this._manage.SelectByCustomerId(customer.CustomerId); if (this.bindingSourceCustomerProduct.Count > 0) { this._CustomerProductPrice = this.bindingSourceCustomerProduct.Current as Model.CustomerProductPrice; this.action = "view"; } else { this.AddNew(); } this.gridControl2.RefreshDataSource(); this.Refresh(); }
public CustomerProductPrice() { InitializeComponent(); string errorMessage = "價格區間填寫有誤,請查證后重新保存.\r請檢查以下項目\r1.價格區間是否連續.\r2.價格不能為零.\r3.<數量上限>不得小於<數量下限>.\r4.第一段價格區間,<數量下限>必須為1"; this.invalidValueExceptions.Add("PriceRange.Error", new AA(errorMessage, this.gridControl3)); //this.requireValueExceptions.Add(Model.CustomerProductPrice.PRO_ProductId, new AA("商品不能為空!", this.btn_CheckProduct)); this.bindingSourceCustomer.DataSource = (new BL.CustomerManager()).Select(); if (this.bindingSourceCustomer.DataSource != null && this.bindingSourceCustomer.Count > 0) { this._CustomerProductPriceList = this._manage.SelectByCustomerId((this.bindingSourceCustomer.Current as Model.Customer).CustomerId); this.customer = this.bindingSourceCustomer[0] as Model.Customer; } if (this._CustomerProductPriceList != null && this._CustomerProductPriceList.Count > 0) { this._CustomerProductPrice = this._CustomerProductPriceList[0]; } this.bindingSourceCustomerProduct.DataSource = this._CustomerProductPriceList; this.bindingSourcePriceRang.DataSource = this._priceRangeList; this.nccBuildEmployee.Choose = new Employees.ChooseEmployee(); this.nccChangeEmployee.Choose = new Employees.ChooseEmployee(); this.action = "view"; this.slue_ProductId.Properties.DisplayMember = "Id"; this.slue_ProductId.Properties.ValueMember = "ProductId"; this.slue_ProductId.Properties.View.Columns.Add(new GridColumn() { FieldName = "Id", Caption = "商品編號", Width = 150, Visible = true, VisibleIndex = 0 }); this.slue_ProductId.Properties.View.Columns.Add(new GridColumn() { FieldName = "ProductName", Caption = "商品名稱", Width = 150, Visible = true, VisibleIndex = 1 }); this.slue_ProductId.Properties.View.Columns.Add(new GridColumn() { FieldName = "CustomerProductName", Caption = "客戶貨品名稱", Width = 150, Visible = true, VisibleIndex = 2 }); this.slue_ProductId.Properties.View.Columns.Add(new GridColumn() { FieldName = "ProductVersion", Caption = "版本", Width = 50, Visible = true, VisibleIndex = 3 }); this.slue_ProductId.Properties.DataSource = productManager.SelectProductForXO(); }
public override void Refresh() { if (this._CustomerProductPrice == null) { this.AddNew(); } else { if (this.action == "view") { this._CustomerProductPrice = this._manage.Get(this._CustomerProductPrice.CustomerProductPriceId); } if (this._CustomerProductPrice == null) { this.bindingSourceCustomerProduct.DataSource = this._manage.SelectByCustomerId(customer.CustomerId); if (this.bindingSourceCustomerProduct.Count == 0) { this.AddNew(); } else { this._CustomerProductPrice = this.bindingSourceCustomerProduct[0] as Model.CustomerProductPrice; this.bindingSourceCustomerProduct.Position = 0; } } } this.slue_ProductId.EditValue = this._CustomerProductPrice.Product == null ? null : this._CustomerProductPrice.Product.ProductId; this.btn_CheckProduct.EditValue = this._CustomerProductPrice.Product; this.memoEditNote.Text = this._CustomerProductPrice.Note; this.nccBuildEmployee.EditValue = this._CustomerProductPrice.BuildEmployee; this.nccChangeEmployee.EditValue = this._CustomerProductPrice.ChangeEmployee; AnalyzePriceRange(this._CustomerProductPrice.CustomerProductPriceRage); this.gridControl3.RefreshDataSource(); base.Refresh(); this.btn_CheckProduct2.Enabled = true; if (this.action == "view") { this.gridView3.OptionsBehavior.Editable = false; } else { this.gridView3.OptionsBehavior.Editable = true; } }
//新增改為直接填寫商品編號 private void slue_ProductId_EditValueChanged(object sender, EventArgs e) { if (this.action == "insert" && this.slue_ProductId.EditValue != null) { this._CustomerProductPrice.Product = productManager.Get(this.slue_ProductId.EditValue.ToString()); if (this._CustomerProductPrice.Product != null) { this.btn_CheckProduct.EditValue = this._CustomerProductPrice.Product; this._CustomerProductPrice.ProductId = this._CustomerProductPrice.Product.ProductId; this._CustomerProductPrice.ProductIDNo = this._CustomerProductPrice.Product.Id; this._CustomerProductPrice.ProductName = this._CustomerProductPrice.Product.ProductName; this._CustomerProductPrice.ProductDesc = this._CustomerProductPrice.Product.ProductDescription; this._CustomerProductPrice.ProductVersion = this._CustomerProductPrice.Product.ProductVersion; this._CustomerProductPrice.CustomerProductId = this._CustomerProductPrice.Product.CustomerProductName; this._CustomerProductPrice.CustomerProductsId = (new BL.CustomerProductsManager()).SelectPrimaryIdByProceName(this._CustomerProductPrice.ProductId); } this._CustomerProductPrice.Customer = this.bindingSourceCustomer.Current as Model.Customer; if (this._CustomerProductPrice.Customer != null) { this._CustomerProductPrice.CustomerId = this._CustomerProductPrice.Customer.CustomerId; } if (this._CustomerProductPriceList.Where(c => c.CustomerId == this._CustomerProductPrice.CustomerId && c.ProductId == this._CustomerProductPrice.ProductId).ToList <Model.CustomerProductPrice>().Count > 0) { //MessageBox.Show("有重複商品輸入", "提示"); //return; Model.CustomerProductPrice model = this._CustomerProductPriceList.Where(c => c.CustomerId == this._CustomerProductPrice.CustomerId && c.ProductId == this._CustomerProductPrice.ProductId).First(); model = this._CustomerProductPrice; this.bindingSourceCustomerProduct.Position = this._CustomerProductPriceList.IndexOf(this._CustomerProductPriceList.First(c => c.CustomerId == this._CustomerProductPrice.CustomerId && c.ProductId == this._CustomerProductPrice.ProductId)); } else { this._CustomerProductPriceList.Add(this._CustomerProductPrice); this.bindingSourceCustomerProduct.Position = this.bindingSourceCustomerProduct.IndexOf(this._CustomerProductPrice); } this.gridControl2.RefreshDataSource(); AnalyzePriceRange(this._CustomerProductPrice.CustomerProductPriceRage); this.gridControl3.RefreshDataSource(); } }
private void gridView2_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e) { this._CustomerProductPrice = this.bindingSourceCustomerProduct.Current as Model.CustomerProductPrice; if (this._CustomerProductPrice != null) { this.btn_CheckProduct.EditValue = this._CustomerProductPrice.Product; } if (this._CustomerProductPrice.CustomerProductPriceRage != null) { AnalyzePriceRange(this._CustomerProductPrice.CustomerProductPriceRage); this.gridControl3.RefreshDataSource(); } else { this._priceRangeList.Clear(); this._priceRangeList.Add(new PriceRange { startRange = 1, endRange = 999999999999, RangePrice = 0 }); this.gridControl3.RefreshDataSource(); } }
private void gridView4_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e) { if (this.bindingSource4.Current != null) { Model.CustomerProductPrice cpp = this.bindingSource4.Current as Model.CustomerProductPrice; if (this._CustomerProductPrice.CustomerProductPriceRage != null) { AnalyzePriceRange(this._CustomerProductPrice.CustomerProductPriceRage); this.gridControl5.RefreshDataSource(); } else { this._priceRangeList.Clear(); this.gridControl5.RefreshDataSource(); } } else { this._priceRangeList.Clear(); this.gridControl5.RefreshDataSource(); } }
protected override void RefreshData() { //this.bindingSource1.DataSource = ((BL.ProductManager)this.manager).Query(" SELECT product.Id,ProductSpecification,ProductName,ProductCategoryName,SupplierFullName ,CustomerProductName,ProductDescription FROM Product left join ProductCategory ca on ca.ProductCategoryId=Product.ProductCategoryId left join Supplier s on s.SupplierId=Product.SupplierId order by ProductName", 240, "pro").Tables[0]; //为了查询速度,暂将ProductSpecification,ProductDescription去掉 this.bindingSource1.DataSource = this.dt = ((BL.ProductManager) this.manager).Query("SELECT p.ProductId,p.Id,p.ProductName,SupplierFullName ,CustomerProductName,ca.ProductCategoryName,isnull(StocksQuantity,0) StocksQuantity,ProductVersion,'' as Price FROM Product p left join ProductCategory ca on ca.ProductCategoryId=p.ProductCategoryId left join Supplier s on s.SupplierId=p.SupplierId order by ProductName", 300, "pro").Tables[0]; IList <Model.CustomerProductPrice> cppList = cpp.SelectAll(); IList <Model.SupplierProduct> sppList = spp.SelectAll(); foreach (DataRow item in this.dt.Rows) { string productId = item["ProductId"].ToString(); string PriceRange = string.Empty; Model.CustomerProductPrice cPrice = cppList.FirstOrDefault(C => C.ProductId == productId); if (cPrice != null) { PriceRange = cPrice.CustomerProductPriceRage; cppList.Remove(cPrice); } else { Model.SupplierProduct sPrice = sppList.FirstOrDefault(S => S.ProductId == productId); if (sPrice != null) { PriceRange = sPrice.SupplierProductPriceRange; sppList.Remove(sPrice); } } string[] PriAndRange = string.IsNullOrEmpty(PriceRange) ? null : PriceRange.Split(','); if (PriAndRange != null) { item["Price"] = (string.IsNullOrEmpty(PriAndRange[0].Split('/')[2]) ? null : PriAndRange[0].Split('/')[2]); } } }
public void UpdateByCustomerProductsId(Model.CustomerProductPrice model) { accessor.UpdateByCustomerProductsId(model); }
public void Insert(Model.CustomerProductPrice e) { this.Insert <Model.CustomerProductPrice>(e); }
public Model.CustomerProductPrice GetNext(Model.CustomerProductPrice e) { return(accessor.GetNext(e)); }
public void Update(Model.CustomerProductPrice e) { this.Update <Model.CustomerProductPrice>(e); }
public bool HasRowsAfter(Model.CustomerProductPrice e) { return(accessor.HasRowsAfter(e)); }
public bool HasRowsBefore(Model.CustomerProductPrice e) { return(accessor.HasRowsBefore(e)); }
public bool HasRowsBefore(Model.CustomerProductPrice e) { return(sqlmapper.QueryForObject <bool>("CustomerProductPrice.has_rows_before", e)); }
public bool HasRowsAfter(Model.CustomerProductPrice e) { return(sqlmapper.QueryForObject <bool>("CustomerProductPrice.has_rows_after", e)); }
public Model.CustomerProductPrice GetPrev(Model.CustomerProductPrice e) { return(sqlmapper.QueryForObject <Model.CustomerProductPrice>("CustomerProductPrice.get_prev", e)); }
public void UpdateByCustomerProductsId(Model.CustomerProductPrice model) { sqlmapper.Update("CustomerProductPrice.UpdateByCustomerProductsId", model); }
protected override void RefreshData() { //为了查询速度,暂将ProductSpecification,ProductDescription去掉 this.bindingSource1.DataSource = this.dt = ((BL.ProductManager) this.manager).Query("SELECT product.ProductId,product.Id,ProductName,ProductCategoryName,c.CustomerFullName ,CustomerProductName,isnull(StocksQuantity,0) StocksQuantity,ProductVersion,'' as Price FROM Product left join ProductCategory ca on ca.ProductCategoryId=Product.ProductCategoryId left join Customer c on c.CustomerId=Product.CustomerId order by ProductName", 300, "pro").Tables[0]; IList <Model.CustomerProductPrice> cppList = cpp.SelectAll(); IList <Model.SupplierProduct> sppList = spp.SelectAll(); #region 方案一 foreach (DataRow item in this.dt.Rows) { string productId = item["ProductId"].ToString(); string PriceRange = string.Empty; Model.CustomerProductPrice cPrice = cppList.FirstOrDefault(C => C.ProductId == productId); if (cPrice != null) { PriceRange = cPrice.CustomerProductPriceRage; cppList.Remove(cPrice); } else { Model.SupplierProduct sPrice = sppList.FirstOrDefault(S => S.ProductId == productId); if (sPrice != null) { PriceRange = sPrice.SupplierProductPriceRange; sppList.Remove(sPrice); } } string[] PriAndRange = string.IsNullOrEmpty(PriceRange) ? null : PriceRange.Split(','); if (PriAndRange != null) { item["Price"] = (string.IsNullOrEmpty(PriAndRange[0].Split('/')[2]) ? null : PriAndRange[0].Split('/')[2]); } } #endregion #region 方案二 更慢 //EnumerableRowCollection<DataRow> dtListAll = dt.AsEnumerable(); //EnumerableRowCollection<DataRow> dtListCustomer = dtListAll.Where(D => cppList.Any(C => C.ProductId == D.Field<string>("ProductId"))); //EnumerableRowCollection<DataRow> dtListSuppiler = dtListAll.Where(D => sppList.Any(C => C.ProductId == D.Field<string>("ProductId"))); //foreach (DataRow item in dtListCustomer) //{ // string productId = item["ProductId"].ToString(); // string PriceRange = string.Empty; // Model.CustomerProductPrice cPrice = cppList.First(C => C.ProductId == productId); // PriceRange = cPrice.CustomerProductPriceRage; // cppList.Remove(cPrice); // string[] PriAndRange = string.IsNullOrEmpty(PriceRange) ? null : PriceRange.Split(','); // if (PriAndRange != null) // { // item["Price"] = (string.IsNullOrEmpty(PriAndRange[0].Split('/')[2]) ? null : PriAndRange[0].Split('/')[2]); // } //} //foreach (DataRow item in dtListSuppiler) //{ // string productId = item["ProductId"].ToString(); // string PriceRange = string.Empty; // Model.SupplierProduct sPrice = sppList.First(S => S.ProductId == productId); // PriceRange = sPrice.SupplierProductPriceRange; // sppList.Remove(sPrice); // string[] PriAndRange = string.IsNullOrEmpty(PriceRange) ? null : PriceRange.Split(','); // if (PriAndRange != null) // { // item["Price"] = (string.IsNullOrEmpty(PriAndRange[0].Split('/')[2]) ? null : PriAndRange[0].Split('/')[2]); // } //} #endregion }