private void dgvShoes_SelectionChanged(object sender, EventArgs e) { try { string brand = dgvShoes.CurrentRow.Cells[0].Value.ToString(); string model = dgvShoes.CurrentRow.Cells[1].Value.ToString(); string colorway = dgvShoes.CurrentRow.Cells[2].Value.ToString(); double size = (double)dgvShoes.CurrentRow.Cells[3].Value; Shoe tempShoe = ShoeDB.GetShoe(brand, model, colorway, size); if (tempShoe != null) { tbCurrentShoe.Text = tempShoe.ToString(); } else { MessageBox.Show("That shoe is not valid now"); } } catch { MessageBox.Show("Please select a valid shoe"); } }
private void btnRemove_Click(object sender, EventArgs e) { try { string brand = dgvShoes.CurrentRow.Cells[0].Value.ToString(); string model = dgvShoes.CurrentRow.Cells[1].Value.ToString(); string colorway = dgvShoes.CurrentRow.Cells[2].Value.ToString(); double size = (double)dgvShoes.CurrentRow.Cells[3].Value; Shoe tempShoe = ShoeDB.GetShoe(brand, model, colorway, size); DialogResult dialog = MessageBox.Show("Are you sure you want to delete " + tempShoe.ToString() + "?", "Verify", MessageBoxButtons.YesNo); if (dialog == DialogResult.Yes) { ShoeDB.DeleteShoe(tempShoe); MessageBox.Show("The shoe was removed successfully!"); this.DialogResult = DialogResult.OK; showList(); } } catch { MessageBox.Show("There is no shoe to remove there"); } }
private void btnEdit_Click(object sender, EventArgs e) { try { string brand = dgvShoes.CurrentRow.Cells[0].Value.ToString(); string model = dgvShoes.CurrentRow.Cells[1].Value.ToString(); string colorway = dgvShoes.CurrentRow.Cells[2].Value.ToString(); double size = (double)dgvShoes.CurrentRow.Cells[3].Value; Shoe editShoe = ShoeDB.GetShoe(brand, model, colorway, size); formEditShoe form = new formEditShoe(editShoe); DialogResult r = form.ShowDialog(); if (r == DialogResult.OK) { showList(); } } catch { MessageBox.Show("Please add some shoes"); } }