Пример #1
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (listViewConsultation.SelectedItems.Count == 1)
     {
         ConsultationsSet consultationSet = listViewConsultation.SelectedItems[0].Tag as ConsultationsSet;
         consultationSet.IdClient       = Convert.ToInt32(comboBoxIdClient.SelectedItem.ToString().Split('.')[0]);
         consultationSet.IdEmployee     = Convert.ToInt32(comboBoxIdEmployee.SelectedItem.ToString().Split('.')[0]);
         consultationSet.DateAcceptance = textBoxDateAcceptance.Text;
         Program.wftDb.SaveChanges();
         ShowConsultation();
     }
 }
Пример #2
0
 private void listViewConsultation_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewConsultation.SelectedItems.Count == 1)
     {
         ConsultationsSet consultationSet = listViewConsultation.SelectedItems[0].Tag as ConsultationsSet;
         comboBoxIdClient.SelectedIndex   = comboBoxIdClient.FindString(consultationSet.IdClient.ToString());
         comboBoxIdEmployee.SelectedIndex = comboBoxIdEmployee.FindString(consultationSet.IdEmployee.ToString());
         textBoxDateAcceptance.Text       = consultationSet.DateAcceptance.ToString();
     }
     else
     {
         comboBoxIdClient.SelectedItem   = null;
         comboBoxIdEmployee.SelectedItem = null;
         textBoxDateAcceptance.Text      = "";
     }
 }
Пример #3
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     if (comboBoxIdClient.SelectedItem != null && comboBoxIdEmployee.SelectedItem != null && textBoxDateAcceptance.Text != "")
     {
         ConsultationsSet consultationSet = new ConsultationsSet();
         consultationSet.IdClient       = Convert.ToInt32(comboBoxIdClient.SelectedItem.ToString().Split('.')[0]);
         consultationSet.IdEmployee     = Convert.ToInt32(comboBoxIdEmployee.SelectedItem.ToString().Split('.')[0]);
         consultationSet.DateAcceptance = textBoxDateAcceptance.Text;
         Program.wftDb.ConsultationsSet.Add(consultationSet);
         Program.wftDb.SaveChanges();
         ShowConsultation();
     }
     else
     {
         MessageBox.Show("Данные не выбраны", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Пример #4
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewConsultation.SelectedItems.Count == 1)
         {
             ConsultationsSet consultationSet = listViewConsultation.SelectedItems[0].Tag as ConsultationsSet;
             Program.wftDb.ConsultationsSet.Remove(consultationSet);
             Program.wftDb.SaveChanges();
             ShowConsultation();
         }
         comboBoxIdClient.SelectedItem   = null;
         comboBoxIdEmployee.SelectedItem = null;
         textBoxDateAcceptance.Text      = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }