Пример #1
0
 private void ButtonEdit_Click(object sender, EventArgs e)
 {
     if (listViewTakensSet.SelectedItems.Count == 1)
     {
         TakenSet deal = listViewTakensSet.SelectedItems[0].Tag as TakenSet;
         deal.IdBook       = Convert.ToInt32(comboBoxBook.SelectedItem.ToString().Split('.')[0]);
         deal.IdReader     = Convert.ToInt32(comboBoxReader.SelectedItem.ToString().Split('.')[0]);
         deal.DateDelivery = textBoxDelivery.Text;
         deal.DateIssue    = textBoxDateIssue.Text;
         Program.pcDb.SaveChanges();
         ShowTaken();
     }
 }
Пример #2
0
 private void ButtonAdd_Click(object sender, EventArgs e)
 {
     if (comboBoxBook.SelectedItem != null && comboBoxReader.SelectedItem != null)
     {
         TakenSet deal = new TakenSet();
         deal.IdBook       = Convert.ToInt32(comboBoxBook.SelectedItem.ToString().Split('.')[0]);
         deal.IdReader     = Convert.ToInt32(comboBoxReader.SelectedItem.ToString().Split('.')[0]);
         deal.DateDelivery = textBoxDelivery.Text;
         deal.DateIssue    = textBoxDateIssue.Text;
         Program.pcDb.TakenSet.Add(deal);
         Program.pcDb.SaveChanges();
         ShowTaken();
     }
     else
     {
         MessageBox.Show("Невозможно добавить данные", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Пример #3
0
 private void ListViewTakensSet_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewTakensSet.SelectedItems.Count == 1)
     {
         TakenSet taken = listViewTakensSet.SelectedItems[0].Tag as TakenSet;
         comboBoxBook.SelectedIndex   = comboBoxBook.FindString(taken.IdBook.ToString());
         comboBoxReader.SelectedIndex = comboBoxBook.FindString(taken.IdReader.ToString());
         taken.DateDelivery           = textBoxDelivery.Text;
         taken.DateIssue = textBoxDateIssue.Text;
     }
     else
     {
         comboBoxBook.SelectedItem   = null;
         comboBoxReader.SelectedItem = null;
         textBoxDelivery.Text        = "";
         textBoxDateIssue.Text       = "";
     }
 }
Пример #4
0
 private void ButtonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewTakensSet.SelectedItems.Count == 1)
         {
             TakenSet deal = listViewTakensSet.SelectedItems[0].Tag as TakenSet;
             Program.pcDb.TakenSet.Remove(deal);
             Program.pcDb.SaveChanges();
             ShowTaken();
         }
         comboBoxBook.SelectedItem   = null;
         comboBoxReader.SelectedItem = null;
         textBoxDelivery.Text        = "";
         textBoxDateIssue.Text       = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }