Exemple #1
0
 private void listViewConnects_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewConnects.SelectedItems.Count == 1)
     {
         ConnectedClients connected = listViewConnects.SelectedItems[0].Tag as ConnectedClients;
         comboBoxClient.SelectedIndex = comboBoxClient.FindString(connected.IdClients.ToString());
         comboBoxRates.SelectedIndex  = comboBoxRates.FindString(connected.IdRates.ToString());
     }
 }
Exemple #2
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     if (comboBoxClient.SelectedItem != null && comboBoxRates.SelectedItem != null)
     {
         ConnectedClients connected = new ConnectedClients();
         connected.IdWorkers = Convert.ToInt32(labelWorkerShow.Text.Split(':')[0]);
         connected.IdClients = Convert.ToInt32(comboBoxClient.SelectedItem.ToString().Split(':')[0]);
         connected.IdRates   = Convert.ToInt32(comboBoxRates.SelectedItem.ToString().Split(':')[0]);
         Program.stlBD.ConnectedClients.Add(connected);
         Program.stlBD.SaveChanges();
         ShowConnects();
     }
     else
     {
         MessageBox.Show("Не все поля заполнены", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #3
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewConnects.SelectedItems.Count == 1)
         {
             ConnectedClients connected = listViewConnects.SelectedItems[0].Tag as ConnectedClients;
             Program.stlBD.ConnectedClients.Remove(connected);
             Program.stlBD.SaveChanges();
             ShowConnects();
         }
     }
     catch
     {
         MessageBox.Show("Поле используется", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }