private void AddGlass_Click(object sender, EventArgs e) { int quantity = int.Parse(quantityUpDown.Text); double cost = 0.0; cost = Math.Round(Convert.ToDouble(costEntry.Text), 2); Crud clash = new Crud(); clash.handleClash("glasses", "glassId", "glasses", glassIdEntry); Glasses addGlass = new Glasses(glassIdEntry.Text, brandEntry.Text, cost, quantity, glassImageEntryBox.Text); addGlass.addGlasses(); if (glassImageEntryBox.Text == "" || glassImageEntryBox.Text == "glasses.jpg") { glassImageEntryBox.Text = "glasses.jpg"; } else { try { File.Copy(Crud.fileName, Crud.destination); } catch (Exception ex) { MessageBox.Show("An error occured while uploading image"); } } refreshInputs(); glassImageEntryBox.Text = "glasses.jpg"; Random rnd = new Random(); int glassesId = rnd.Next(1, 9999); glassIdEntry.Text = "glasses" + glassesId.ToString(); }
private void button6_Click(object sender, EventArgs e) { int quantity = int.Parse(quantityUpdate.Text); double cost = 0.0; cost = Math.Round(Convert.ToDouble(costUpdate.Text), 2); Glasses updateGlass = new Glasses(searchUpdateKey.Text, brandUpdate.Text, cost, quantity, imageAddress.Text); updateGlass.updateGlasses(searchUpdateKey.Text); try { if (imageAddress.Text != "" && imageAddress.Text != "glasses.jpg") { File.Copy(Crud.fileName, Crud.destination); } } catch (Exception ex) { } }