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 buttonWeeklyRotation_Click(object sender, EventArgs e) { try { List <Shoe> rotation = ShoeDB.GetWeeklyRotation(); string sunday = rotation[0].ToString(); string monday = rotation[1].ToString(); string tuesday = rotation[2].ToString(); string wednesday = rotation[3].ToString(); string thursday = rotation[4].ToString(); string friday = rotation[5].ToString(); string saturday = rotation[6].ToString(); MessageBox.Show("Sunday:\t\t" + sunday + "\nMonday:\t\t" + monday + "\nTuesday:\t\t" + tuesday + "\nWednesday:\t" + wednesday + "\nThursday:\t" + thursday + "\nFriday:\t\t" + friday + "\nSaturday:\t" + saturday); } catch { MessageBox.Show("Please add some shoes"); } }
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 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"); } }
private void btnAddShoe_Click(object sender, EventArgs e) { try { string brand = cbBrand.SelectedItem.ToString(); double size = double.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("Please fill all the fields properly"); } }
private void btnFinish_Click(object sender, EventArgs e) { try { Shoe changedShoe = new Shoe() { Brand = cbBrand.SelectedItem.ToString(), Model = tbModel.Text, Colorway = tbColorway.Text, Size = double.Parse(cbSize.SelectedItem.ToString()), }; try { ShoeDB.EditShoe(shoeToEdit, changedShoe); MessageBox.Show("The shoe was edited successfully"); } catch { MessageBox.Show("Error editing shoe"); } } catch { MessageBox.Show("Please fill out all the fields properly"); } }
private void btnShoeOfDay_Click(object sender, EventArgs e) { try { string shoePicked = ShoeDB.GetRandomShoe().ToString(); MessageBox.Show("Shoe of the Day:\t" + shoePicked); } catch { MessageBox.Show("Please add some shoes"); } }
private void showList() { List <Shoe> shoeCount = ShoeDB.GetAllShoes(); tbShoeCount.Text = shoeCount.Count.ToString(); string brand = cbFilter.GetItemText(cbFilter.SelectedItem); if (brand == "All" || brand == "") { List <Shoe> shoeList = ShoeDB.GetAllShoes(); dgvShoes.DataSource = shoeList; } else if (brand != "All") { List <Shoe> shoeList = ShoeDB.GetShoeByType(brand); dgvShoes.DataSource = shoeList; } }