private void RefreshItems(object sender, EventArgs e) { var biz = new ProductTypeBiz(); dataGridView.DataSource = biz.LoadItems(); dataGridView.Refresh(); }
private void LoadProductType() { var biz = new ProductTypeBiz(); var items = biz.LoadItems(); items.Insert(0, new ProductType()); drlProductType.Items.Clear(); drlProductType.DataSource = items; drlProductType.DisplayMember = "Name"; drlProductType.ValueMember = "Id"; }
public ProductTypeView(User user) { InitializeComponent(); dataGridView.AutoGenerateColumns = false; var biz = new ProductTypeBiz(); dataGridView.DataSource = biz.LoadItems(); dataGridView.Refresh(); currentUser = user; buttonSelectItems.Text = "Chọn"; }
private void DeleteItem(object sender, EventArgs e) { var items = new List<ProductType>(); foreach (DataGridViewRow row in dataGridView.Rows) { if (row.Cells[0].Value != null && row.Cells[0].Value == "1") { items.Add(row.DataBoundItem as ProductType); } } var biz = new ProductTypeBiz(); biz.RemoveItem(items); RefreshItems(sender, e); }
private void InitForm(User user) { buttonSave.DialogResult = System.Windows.Forms.DialogResult.OK; button2.DialogResult = System.Windows.Forms.DialogResult.Cancel; currentUser = user.Id; var biz = new ProductTypeBiz(); var types = biz.LoadItems(); types.Insert(0, new ProductType()); drlType.Items.Clear(); drlType.DataSource = types; drlType.DisplayMember = "Name"; drlType.ValueMember = "Id"; }
private void DeleteItem(object sender, EventArgs e) { var items = new List <ProductType>(); foreach (DataGridViewRow row in dataGridView.Rows) { if (row.Cells[0].Value != null && row.Cells[0].Value == "1") { items.Add(row.DataBoundItem as ProductType); } } var biz = new ProductTypeBiz(); biz.RemoveItem(items); RefreshItems(sender, e); }
public ProductTypeForm(int id, User user) { InitializeComponent(); textName.Focus(); itemId = id; var biz = new ProductTypeBiz(); var item = biz.LoadItem(id); textName.Text = item.Name; created = item.Created; createdBy = item.CreatedByUserId; modified = item.Modified; modifiedBy = item.ModifiedByUserId; InitForm(user); this.Text = "Sửa loại sản phẩm"; }
private void SaveItem(object sender, EventArgs e) { if (CustomValidation()) { var item = new ProductType(); item.Name = textName.Text; if (itemId > 0) { item.Id = itemId; item.Created = created; item.CreatedByUserId = createdBy; item.Modified = DateTime.Now; item.ModifiedByUserId = currentUser; var biz = new ProductTypeBiz(); biz.UpdateItem(item); } else { item.Created = DateTime.Now; item.CreatedByUserId = currentUser; item.Modified = DateTime.Now; item.ModifiedByUserId = currentUser; var biz = new ProductTypeBiz(); biz.SaveItem(item); } this.Close(); } else { this.DialogResult = System.Windows.Forms.DialogResult.None; } }