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