Ejemplo n.º 1
0
 private void btnUpdateBrand_Click(object sender, EventArgs e)
 {
     if (dgvBrands.SelectedRows.Count > 0)
     {
         int idSelectedBrand = Convert.ToInt32(dgvBrands.SelectedRows[0].Cells[0].Value);
         IRepositoryGeneric <Brand> repositoryBrand = new RepositoryBrand();
         Brand    brandToBeChanged = repositoryBrand.SelectById(idSelectedBrand);
         FrmBrand frmBrand         = new FrmBrand(brandToBeChanged);
         frmBrand.ShowDialog();
         FillDataGridViewBrandsAsync();
         FillDataGridViewProducsAsync();
     }
     else
     {
         MessageBox.Show("Please select one brand first.", "Error", MessageBoxButtons.OK,
                         MessageBoxIcon.Warning);
     }
 }
Ejemplo n.º 2
0
        private void btnRemoveBrand_Click(object sender, EventArgs e)
        {
            DialogResult myResult;

            myResult = MessageBox.Show("Are you sure that you want exclude this brand ?", "Warning", MessageBoxButtons.OKCancel,
                                       MessageBoxIcon.Warning);
            if (myResult == DialogResult.OK)
            {
                if (dgvBrands.SelectedRows.Count > 0)
                {
                    int idSelectedBrand = Convert.ToInt32(dgvBrands.SelectedRows[0].Cells[0].Value);
                    IRepositoryGeneric <Brand> repositoryBrand = new RepositoryBrand();
                    Brand brandToBeExcluded = repositoryBrand.SelectById(idSelectedBrand);
                    repositoryBrand.Remove(brandToBeExcluded);
                    FillDataGridViewBrandsAsync();
                }
                else
                {
                    MessageBox.Show("Please select one brand to be exclued", "Error", MessageBoxButtons.OK,
                                    MessageBoxIcon.Warning);
                }
            }
        }