private void buttonAddShoe_Click(object sender, EventArgs e) { try { string brand = cbBrand.SelectedValue.ToString(); decimal size = decimal.Parse(cbSize.SelectedItem.ToString()); Shoe tempShoe = new Shoe { Brand = brand, Model = tbModel.Text.ToString(), Colorway = tbColorway.Text.ToString(), Size = size, }; try { ShoeDB.AddShoe(tempShoe); MessageBox.Show("The shoe was added successfully"); } catch { MessageBox.Show("Error adding shoe"); } } catch { MessageBox.Show("Fill all the fields properly"); } }
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(); decimal size = (decimal)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 buttonRemove_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(); decimal size = (decimal)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; List <Shoe> shoeList = ShoeDB.GetAllShoes(); dgvShoes.DataSource = shoeList; tbShoeCount.Text = shoeList.Count.ToString(); } } catch { MessageBox.Show("There is no shoe to remove there"); } }
private void MainMenuForm_Load(object sender, EventArgs e) { List <Shoe> shoeList = ShoeDB.GetAllShoes(); dgvShoes.DataSource = shoeList; tbShoeCount.Text = shoeList.Count.ToString(); }
private void buttonAdd_Click(object sender, EventArgs e) { formAddShoe form = new formAddShoe(); DialogResult r = form.ShowDialog(); if (r == DialogResult.OK) { List <Shoe> shoeList = ShoeDB.GetAllShoes(); dgvShoes.DataSource = shoeList; tbShoeCount.Text = shoeList.Count.ToString(); } }