private void buttonInsertDisc_Click(object sender, EventArgs e) { if (textBoxBandId.Text == "" || textBoxDateOfRelease.Text == "" || textBoxDiscTitle.Text == "" || textBoxHowMuchLeft.Text == "" || textBoxListOfSongs.Text == "" || textBoxRetailPrice.Text == "" || textBoxSaledInCurrentYear.Text == "" || textBoxSaledInLastYear.Text == "" || textBoxWholeSaleCompany.Text == "" || textBoxWholesalePrice.Text == "") { MessageBox.Show("Wrong input!"); return; } IDiscsRepository discsRep = new DiscsRepository(); DiscModel toPost = new DiscModel(); toPost.BandId = Convert.ToInt32(textBoxBandId.Text); toPost.DateOfRelease = textBoxDateOfRelease.Text; toPost.HowMuchLeft = Convert.ToInt32(textBoxHowMuchLeft.Text); toPost.ListOfSongs = textBoxListOfSongs.Text; toPost.RetailPrice = Convert.ToInt32(textBoxRetailPrice.Text); toPost.SaledInCurrentYear = Convert.ToInt32(textBoxSaledInCurrentYear.Text); toPost.SaledInLastYear = Convert.ToInt32(textBoxSaledInLastYear.Text); toPost.Title = textBoxDiscTitle.Text; toPost.WholesaleCompany = textBoxWholeSaleCompany.Text; toPost.WholesalePrice = Convert.ToInt32(textBoxWholesalePrice.Text); bool flag = discsRep.AddDisc(toPost); if (flag) { MessageBox.Show("Posted!"); } else { MessageBox.Show("Error!"); } textBoxBandId.Text = ""; textBoxDateOfRelease.Text = ""; textBoxHowMuchLeft.Text = ""; textBoxListOfSongs.Text = ""; textBoxRetailPrice.Text = ""; textBoxSaledInCurrentYear.Text = ""; textBoxSaledInLastYear.Text = ""; textBoxDiscTitle.Text = ""; textBoxWholeSaleCompany.Text = ""; textBoxWholesalePrice.Text = ""; }
private void buttonSerializeDiscs_Click(object sender, EventArgs e) { using (FileStream fs = new FileStream("discs.json", FileMode.OpenOrCreate)) { IDiscsRepository discsRep = new DiscsRepository(); List <DiscModel> discs = discsRep.GetAllDiscs().ToList(); var options = new JsonSerializerOptions { WriteIndented = true }; foreach (DiscModel disc in discs) { JsonSerializer.SerializeAsync(fs, disc, options); } } }
private void buttonSeeDiscs_Click(object sender, EventArgs e) { IDiscsRepository discsRep = new DiscsRepository(); List <DiscModel> discs = discsRep.GetAllDiscs().ToList(); listDiscs.Items.Clear(); foreach (DiscModel disc in discs) { string toList = "Disc title:" + disc.Title + ", disc serial number:" + disc.SerialNumber + ", date of release:" + disc.DateOfRelease + ", sold in current year:" + disc.SaledInCurrentYear + ", in last year:" + disc.SaledInLastYear + ", how much left:" + disc.HowMuchLeft + ", retail price:" + disc.RetailPrice + ", wholesale:" + disc.WholesalePrice + ", wholesale company:" + disc.WholesaleCompany + ", list of songs:" + disc.ListOfSongs; listDiscs.Items.Add(toList); } }
private void buttonUpdateDisc_Click(object sender, EventArgs e) { if (textBoxSerialNumber.Text == "" || textBoxHowMuchLeft.Text == "" || textBoxRetailPrice.Text == "" || textBoxWholesalePrice.Text == "" || textBoxSaledInCurrentYear.Text == "") { MessageBox.Show("Wrong input!"); return; } IDiscsRepository discsRep = new DiscsRepository(); bool flag = discsRep.UpdateDisc( Convert.ToInt32(textBoxSerialNumber.Text), Convert.ToInt32(textBoxWholesalePrice.Text), Convert.ToInt32(textBoxRetailPrice.Text), Convert.ToInt32(textBoxSaledInCurrentYear.Text), Convert.ToInt32(textBoxHowMuchLeft.Text) ); if (flag) { MessageBox.Show("Updated!"); } else { MessageBox.Show("Error!"); } textBoxBandId.Text = ""; textBoxDateOfRelease.Text = ""; textBoxHowMuchLeft.Text = ""; textBoxListOfSongs.Text = ""; textBoxRetailPrice.Text = ""; textBoxSaledInCurrentYear.Text = ""; textBoxSaledInLastYear.Text = ""; textBoxDiscTitle.Text = ""; textBoxWholeSaleCompany.Text = ""; textBoxWholesalePrice.Text = ""; }
private void buttonDeleteDisc_Click(object sender, EventArgs e) { if (textBoxDeleteSerialNumber.Text == "") { MessageBox.Show("Wrong input!"); return; } IDiscsRepository bandsRep = new DiscsRepository(); bool flag = bandsRep.DeleteMusician(Convert.ToInt32(textBoxDeleteSerialNumber.Text)); if (flag) { MessageBox.Show("Deleted!"); } else { MessageBox.Show("Error!"); } textBoxDeleteSerialNumber.Text = ""; }
public Part1() { discsRepository = new DiscsRepository(); capsule = new Capsule(); }