private void btnDelete_Click(object sender, System.EventArgs e) { if (brandGridView.SelectedRows.Count > 0) { DataGridViewRow dataRow = brandGridView.SelectedRows[0]; int.TryParse(dataRow.Cells["id"].Value.ToString(), out int id); if (id < 0) { MessageBox.Show("Invalid brand id"); return; } else { int success = BrandDataAccess.DeleteBrand(id); if (success > 0) { MessageBox.Show("successfully deleted"); frmBrands_Load(sender, e); } } } else { MessageBox.Show("Please select a brand to delete"); return; } }
public BrandPublishHandler(string Url) { config = (BrandConfigurationSection)ConfigurationManager.GetSection("publish/brandPublish"); Logger = LogManager.GetLogger(config.Logger); dal = new BrandDataAccess(config); PageParameter = GetParameter(Url); PageFileName = GetPageFileName(); }
public BrandPageCreator(BrandPageParameter parameter, BrandConfigurationSection config) { Parameter = parameter; Config = config; Logger = LogManager.GetLogger(config.Logger); dal = new BrandDataAccess(config); }
private void ViewEditData() { brand = BrandDataAccess.GetBrandById(brandId); if (brand != null) { txtBrand.Text = brand.BrandName; chkActive.Checked = brand.IsActive; } }
public void frmBrands_Load(object sender, System.EventArgs e) { DataTable dt = BrandDataAccess.GetBrands(); if (dt != null) { this.brandGridView.DataSource = dt; FormatGrid(ref this.brandGridView); } }
private void LoadComboBoxData() { products = ProductDataAccess.GetProductsForPurchaseItem(); if (products != null && cmbProduct.Items.Count < 1) { foreach (var item in products) { cmbProduct.Items.Add(item.Value); productsIds.Add(item.Key); } } brands = BrandDataAccess.GetBrandsForPurchaseItem(); if (brands != null && cmbBrand.Items.Count < 1) { foreach (var item in brands) { cmbBrand.Items.Add(item.Value); brandsIds.Add(item.Key); } } }
private int AddUpdateBrand() { if (brand != null && brand.Id > 0) { brand.Id = brandId; brand.BrandName = txtBrand.Text; brand.IsActive = chkActive.Checked; brand.UpdatedBy = userId; return(BrandDataAccess.UpdateBrand(brand)); } else { var brand = new BrandDTO() { BrandName = txtBrand.Text, IsActive = chkActive.Checked, CreatedBy = userId }; return(BrandDataAccess.AddBrand(brand)); } }
public BrandController() { DataAccess = new BrandDataAccess(); }