Exemplo n.º 1
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     if (comboBoxClient.SelectedItem != null && comboBoxSotr.SelectedItem != null)
     {
         ConsultSet cons = new ConsultSet();
         cons.IdClient    = Convert.ToInt32(comboBoxClient.SelectedItem.ToString().Split('.')[0]);
         cons.IdSotrudnik = Convert.ToInt32(comboBoxSotr.SelectedItem.ToString().Split('.')[0]);
         if (comboBoxTypeOfCons.SelectedIndex == 0)
         {
             cons.TypeConsult   = 0;
             cons.MobileConsult = Convert.ToString(textBoxPredMobile.Text);
         }
         else if (comboBoxTypeOfCons.SelectedIndex == 1)
         {
             cons.TypeConsult   = 1;
             cons.AcsessConsult = Convert.ToString(textBoxPredAcsess.Text);
         }
         else
         {
             cons.TypeConsult = 2;
             cons.OperConsult = Convert.ToString(textBoxPredOper);
         }
         Program.SpDb.ConsultSet.Add(cons);
         Program.SpDb.SaveChanges();
         ShowConsultSet();
     }
     else
     {
         MessageBox.Show("Данные не выбраны", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemplo n.º 2
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (comboBoxTypeOfCons.SelectedIndex == 0)
         {
             if (listViewMobileCons.SelectedItems.Count == 1)
             {
                 ConsultSet cons = listViewMobileCons.SelectedItems[0].Tag as ConsultSet;
                 Program.SpDb.ConsultSet.Remove(cons);
                 Program.SpDb.SaveChanges();
                 ShowConsultSet();
             }
             comboBoxSotr.SelectedItem   = null;
             comboBoxClient.SelectedItem = null;
             textBoxPredMobile.Text      = "";
         }
         else if (comboBoxTypeOfCons.SelectedIndex == 1)
         {
             if (listViewAcsessCons.SelectedItems.Count == 1)
             {
                 ConsultSet cons = listViewAcsessCons.SelectedItems[0].Tag as ConsultSet;
                 Program.SpDb.ConsultSet.Remove(cons);
                 Program.SpDb.SaveChanges();
                 ShowConsultSet();
             }
             comboBoxSotr.SelectedItem   = null;
             comboBoxClient.SelectedItem = null;
             textBoxPredAcsess.Text      = "";
         }
         else
         {
             if (listViewOperCons.SelectedItems.Count == 1)
             {
                 ConsultSet cons = listViewOperCons.SelectedItems[0].Tag as ConsultSet;
                 Program.SpDb.ConsultSet.Remove(cons);
                 Program.SpDb.SaveChanges();
                 ShowConsultSet();
             }
             comboBoxSotr.SelectedItem   = null;
             comboBoxClient.SelectedItem = null;
             textBoxPredOper.Text        = "";
         }
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 3
0
 private void listViewOperCons_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewOperCons.SelectedItems.Count == 1)
     {
         ConsultSet cons = listViewOperCons.SelectedItems[0].Tag as ConsultSet;
         comboBoxClient.SelectedIndex = comboBoxClient.FindString(cons.IdClient.ToString());
         comboBoxSotr.SelectedIndex   = comboBoxClient.FindString(cons.IdSotrudnik.ToString());
         textBoxPredOper.Text         = cons.OperConsult.ToString();
     }
     else
     {
         comboBoxSotr.SelectedItem   = null;
         comboBoxClient.SelectedItem = null;
         textBoxPredOper.Text        = "";
     }
 }
Exemplo n.º 4
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (comboBoxTypeOfCons.SelectedIndex == 0)
     {
         if (listViewMobileCons.SelectedItems.Count == 1)
         {
             ConsultSet cons = listViewMobileCons.SelectedItems[0].Tag as ConsultSet;
             cons.IdSotrudnik   = Convert.ToInt32(comboBoxSotr.SelectedItem.ToString().Split('.')[0]);
             cons.IdClient      = Convert.ToInt32(comboBoxClient.SelectedItem.ToString().Split('.')[0]);
             cons.MobileConsult = Convert.ToString(textBoxPredMobile.Text);
             Program.SpDb.SaveChanges();
             ShowConsultSet();
         }
     }
     if (comboBoxTypeOfCons.SelectedIndex == 1)
     {
         if (listViewAcsessCons.SelectedItems.Count == 1)
         {
             ConsultSet cons = listViewAcsessCons.SelectedItems[0].Tag as ConsultSet;
             cons.IdSotrudnik   = Convert.ToInt32(comboBoxSotr.SelectedItem.ToString().Split('.')[0]);
             cons.IdClient      = Convert.ToInt32(comboBoxClient.SelectedItem.ToString().Split('.')[0]);
             cons.AcsessConsult = Convert.ToString(textBoxPredAcsess.Text);
             Program.SpDb.SaveChanges();
             ShowConsultSet();
         }
     }
     else
     {
         if (listViewOperCons.SelectedItems.Count == 1)
         {
             ConsultSet cons = listViewOperCons.SelectedItems[0].Tag as ConsultSet;
             cons.IdSotrudnik = Convert.ToInt32(comboBoxSotr.SelectedItem.ToString().Split('.')[0]);
             cons.IdClient    = Convert.ToInt32(comboBoxClient.SelectedItem.ToString().Split('.')[0]);
             cons.OperConsult = Convert.ToString(textBoxPredOper.Text);
             Program.SpDb.SaveChanges();
             ShowConsultSet();
         }
     }
 }