Beispiel #1
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (listViewReception.SelectedItems.Count == 1)
     {
         ReceptionSet reception = listViewReception.SelectedItems[0].Tag as ReceptionSet;
         reception.idCitizen  = Convert.ToInt32(comboBoxCitizen.SelectedItem.ToString().Split('.')[0]);
         reception.idStaff    = Convert.ToInt32(comboBoxStaff.SelectedItem.ToString().Split('.')[0]);
         reception.service    = textBoxService.Text;
         reception.date       = textBoxDate.Text;
         reception.idEmployer = Convert.ToInt32(comboBoxEmployer.SelectedItem.ToString().Split('.')[0]);
         Program.znt.SaveChanges();
         ShowReception();
     }
 }
Beispiel #2
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     if (comboBoxCitizen.SelectedItem != null && comboBoxStaff.SelectedItem != null && textBoxDate.Text != "" && textBoxService.Text != "")
     {
         ReceptionSet reception = new ReceptionSet();
         reception.idCitizen  = Convert.ToInt32(comboBoxCitizen.SelectedItem.ToString().Split('.')[0]);
         reception.idStaff    = Convert.ToInt32(comboBoxStaff.SelectedItem.ToString().Split('.')[0]);
         reception.service    = textBoxService.Text;
         reception.date       = textBoxDate.Text;
         reception.idEmployer = Convert.ToInt32(comboBoxEmployer.SelectedItem.ToString().Split('.')[0]);
         Program.znt.ReceptionSet.Add(reception);
         Program.znt.SaveChanges();
         ShowReception();
     }
     else
     {
         MessageBox.Show("Выберите данные", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Beispiel #3
0
 private void listViewReception_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewReception.SelectedItems.Count == 1)
     {
         ReceptionSet reception = listViewReception.SelectedItems[0].Tag as ReceptionSet;
         comboBoxCitizen.SelectedIndex = comboBoxCitizen.FindString(reception.idCitizen.ToString());
         comboBoxStaff.SelectedIndex   = comboBoxStaff.FindString(reception.idStaff.ToString());
         textBoxService.Text           = reception.service;
         textBoxDate.Text = reception.date;
         comboBoxEmployer.SelectedIndex = comboBoxEmployer.FindString(reception.idEmployer.ToString());
     }
     else
     {
         comboBoxCitizen.SelectedItem  = null;
         comboBoxStaff.SelectedItem    = null;
         textBoxService.Text           = "";
         textBoxDate.Text              = "";
         comboBoxEmployer.SelectedItem = null;
     }
 }
Beispiel #4
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewReception.SelectedItems.Count == 1)
         {
             ReceptionSet reception = listViewReception.SelectedItems[0].Tag as ReceptionSet;
             Program.znt.ReceptionSet.Remove(reception);
             Program.znt.SaveChanges();
             ShowReception();
         }
         comboBoxCitizen.SelectedItem  = null;
         comboBoxStaff.SelectedItem    = null;
         textBoxService.Text           = "";
         textBoxDate.Text              = "";
         comboBoxEmployer.SelectedItem = null;
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }