private void Form1_Load(object sender, EventArgs e) { //Guitar guitar = new Guitar() //{ // Brand = "Gibson", // GuitarType = "Les Paul Studio Gold Top", // Color = "Antique Zebra", // Value = 700 //}; //GuitarContext guitarContext = new GuitarContext(); //guitarContext.Guitars.Add(guitar); //guitarContext.SaveChanges(); try { List <Guitar> allGuitars = GuitarDb.GetGuitars(); PopulateGuitarList(allGuitars); } catch (SqlException) { MessageBox.Show("We are having database issues, try again later"); MessageBox.Show("Guitars are unable to be loaded. App will close"); Close(); } }
private void AddGuitarBtn_Click(object sender, EventArgs e) { // Create Guitar object to add Guitar guitar = new Guitar { Brand = BrandTxtBox.Text, GuitarType = GuitarTypeTxtBox.Text, Color = ColorTxtBox.Text, Value = double.Parse(ValueTxtBox.Text) }; DialogResult dialog = MessageBox.Show("Is everything correct?", "Guitar", MessageBoxButtons.YesNo, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button2); if (dialog == DialogResult.Yes) { GuitarDb.Add(guitar); MessageBox.Show("Guitar Added!"); } }