public override void Refresh() { this._detail = productCategoryManager.Select(); this.bindingSource1.DataSource = this._detail; if (this.action == "insert") { Model.ProductCategory pc = new Book.Model.ProductCategory(); pc.ProductCategoryId = Guid.NewGuid().ToString(); this._detail.Add(pc); this.bindingSource1.DataSource = this._detail; this.bindingSource1.Position = this.bindingSource1.IndexOf(pc); this.gridControl1.RefreshDataSource(); } switch (this.action) { case "insert": this.gridView1.OptionsBehavior.Editable = true; break; case "update": this.gridView1.OptionsBehavior.Editable = true; break; case "view": this.gridView1.OptionsBehavior.Editable = false; break; default: break; } base.Refresh(); }
private void gridView1_KeyDown(object sender, KeyEventArgs e) { if (this.action == "insert" || this.action == "update") { if (e.KeyData == Keys.Enter) { Model.ProductCategory pc = new Book.Model.ProductCategory(); pc.ProductCategoryId = Guid.NewGuid().ToString(); this._detail.Add(pc); this.bindingSource1.Position = this.bindingSource1.IndexOf(pc); } if (e.KeyData == Keys.Delete) { this._detail.Remove(this.bindingSource1.Current as Model.ProductCategory); } this.gridControl1.RefreshDataSource(); } }
public void Update(DataSet ds) { try { BL.V.BeginTransaction(); foreach (DataTable dt in ds.Tables) { ValidateDT(dt); foreach (DataRow dr in dt.Rows) { Model.ProductCategory pc = new Book.Model.ProductCategory(); pc.ProductCategoryId = dr["ProductCategoryId"].ToString(); pc.ProductCategoryParentId = dr["ProductCategoryParentId"].ToString() == "" ? null : dr["ProductCategoryParentId"].ToString(); pc.UpdateTime = DateTime.Now; pc.Id = dr["Id"].ToString(); pc.ProductCategoryName = dr["ProductCategoryName"].ToString(); pc.CategoryLevel = int.Parse(dr["CategoryLevel"].ToString()); if (accessor.ExistsPrimary(pc.ProductCategoryId)) { pc.InsertTime = DateTime.Parse(dr["InsertTime"].ToString()); accessor.Update(pc); } else { pc.InsertTime = DateTime.Now; this.Insert(pc); } } } BL.V.CommitTransaction(); } catch (Exception ex) { BL.V.RollbackTransaction(); throw ex; } }
protected override void Delete() { if (MessageBox.Show(Properties.Resources.ConfirmToDelete, this.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK) { return; } //this.productCategoryManager.Delete(this.bindingSource1.Current as Model.ProductCategory); GridView gv = this.gridControl1.FocusedView as GridView; if (gv != null) { DataRow dr = gv.GetDataRow(gv.FocusedRowHandle); if (dr != null) { Model.ProductCategory pc = new Book.Model.ProductCategory(); pc.ProductCategoryId = dr["ProductCategoryId"].ToString(); this.productCategoryManager.Delete(pc); return; } } throw new global::Helper.MessageValueException("请先选择要删除的行!"); }
public IList <Book.Model.Product> Select(Book.Model.ProductCategory Category) { string str = ""; if (Category.CategoryLevel == 1) { //str = " ProductCategoryId = '" + Category.ProductCategoryId + "' and (productCategoryid2='' or productCategoryid2 is null) and ( productCategoryid3='' or productCategoryid3 is null)"; //点击大类,显示该类别下所有商品 str = " ProductCategoryId = '" + Category.ProductCategoryId + "'"; } else if (Category.CategoryLevel == 2) { str = " productCategoryid2='" + Category.ProductCategoryId + "' and ( productCategoryid3='' or productCategoryid3 is null)"; } else { str = " productCategoryid3='" + Category.ProductCategoryId + "'"; } Hashtable ht = new Hashtable(); ht.Add("sql", str); return(sqlmapper.QueryForList <Model.Product>("Product.select_byCategory", ht)); }
public IList <Book.Model.Product> SelectProductByProductCategoryId(Book.Model.ProductCategory Category) { return(accessor.SelectProductByProductCategoryId(Category)); }
public IList <Book.Model.Product> SelectProductByProductCategoryId(Book.Model.ProductCategory Category) { return(sqlmapper.QueryForList <Model.Product>("Product.select_byCategoryTo", Category.ProductCategoryId)); }