Exemplo n.º 1
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (listViewAdvertisement.SelectedItems.Count == 1)
     {
         AdsSet adsSet = listViewAdvertisement.SelectedItems[0].Tag as AdsSet;
         adsSet.Number = (textBoxNewspaperNumber.Text);
         adsSet.Size   = (textBoxAdvertisementSize.Text);
         Program.bdad.SaveChanges();
         ShowAdvertisement();
     }
 }
Exemplo n.º 2
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     if (comboBoxNewspaper.SelectedItem != null && comboBoxOrganisation != null && textBoxNewspaperNumber.Text != "")
     {
         AdsSet adsSet = new AdsSet();
         adsSet.Id_Newspaper    = Convert.ToInt32(comboBoxNewspaper.SelectedItem.ToString().Split('.')[0]);
         adsSet.Id_Organisation = Convert.ToInt32(comboBoxOrganisation.SelectedItem.ToString().Split('.')[0]);
         adsSet.Number          = (textBoxNewspaperNumber.Text);
         adsSet.Size            = (textBoxAdvertisementSize.Text);
         Program.bdad.AdsSet.Add(adsSet);
         Program.bdad.SaveChanges();
         ShowAdvertisement();
     }
     else
     {
         MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 3
0
 private void listViewNewsPaper_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewAdvertisement.SelectedItems.Count == 1)
     {
         AdsSet adsSet = listViewAdvertisement.SelectedItems[0].Tag as AdsSet;
         comboBoxNewspaper.SelectedIndex    = comboBoxNewspaper.FindString(adsSet.Id_Newspaper.ToString());
         comboBoxOrganisation.SelectedIndex = comboBoxOrganisation.FindString(adsSet.Id_Organisation.ToString());
         textBoxNewspaperNumber.Text        = adsSet.Number.ToString();
         textBoxAdvertisementSize.Text      = adsSet.Size.ToString();
     }
     else
     {
         comboBoxNewspaper.SelectedItem    = null;
         comboBoxOrganisation.SelectedItem = null;
         textBoxNewspaperNumber.Text       = "";
         textBoxAdvertisementSize.Text     = "";
     }
 }
Exemplo n.º 4
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewAdvertisement.SelectedItems.Count == 1)
         {
             AdsSet adsSet = listViewAdvertisement.SelectedItems[0].Tag as AdsSet;
             Program.bdad.AdsSet.Remove(adsSet);
             Program.bdad.SaveChanges();
             ShowAdvertisement();
         }
         comboBoxNewspaper.SelectedItem    = null;
         comboBoxOrganisation.SelectedItem = null;
         textBoxNewspaperNumber.Text       = "";
         textBoxAdvertisementSize.Text     = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }