Exemple #1
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (listViewAvailableService.SelectedItems.Count == 1)
     {
         AvailableServicesSet availableServiceSet = listViewAvailableService.SelectedItems[0].Tag as AvailableServicesSet;
         availableServiceSet.NameService     = textBoxNameService.Text;
         availableServiceSet.CategoryService = comboBoxCategoryService.Text;
         availableServiceSet.TypeService     = comboBoxTypeService.Text;
         availableServiceSet.Price           = Convert.ToInt32(textBoxPrice.Text);
         Program.wftDb.SaveChanges();
         ShowAvailableService();
     }
 }
Exemple #2
0
 private void listViewAvailableService_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewAvailableService.SelectedItems.Count == 1)
     {
         AvailableServicesSet availableServiceSet = listViewAvailableService.SelectedItems[0].Tag as AvailableServicesSet;
         textBoxNameService.Text      = availableServiceSet.NameService.ToString();
         comboBoxCategoryService.Text = availableServiceSet.CategoryService.ToString();
         comboBoxTypeService.Text     = availableServiceSet.TypeService.ToString();
         textBoxPrice.Text            = availableServiceSet.Price.ToString();
     }
     else
     {
         textBoxNameService.Text      = "";
         comboBoxCategoryService.Text = null;
         comboBoxTypeService.Text     = null;
         textBoxPrice.Text            = "";
     }
 }
Exemple #3
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     if (textBoxNameService.Text != "" && comboBoxCategoryService.Text != null && comboBoxTypeService.Text != null && textBoxPrice.Text != "")
     {
         AvailableServicesSet availableServiceSet = new AvailableServicesSet();
         availableServiceSet.NameService     = textBoxNameService.Text;
         availableServiceSet.CategoryService = comboBoxCategoryService.Text;
         availableServiceSet.TypeService     = comboBoxTypeService.Text;
         availableServiceSet.Price           = Convert.ToInt32(textBoxPrice.Text);
         Program.wftDb.AvailableServicesSet.Add(availableServiceSet);
         Program.wftDb.SaveChanges();
         ShowAvailableService();
     }
     else
     {
         MessageBox.Show("Данные не выбраны", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #4
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewAvailableService.SelectedItems.Count == 1)
         {
             AvailableServicesSet availableServiceSet = listViewAvailableService.SelectedItems[0].Tag as AvailableServicesSet;
             Program.wftDb.AvailableServicesSet.Remove(availableServiceSet);
             Program.wftDb.SaveChanges();
             ShowAvailableService();
         }
         textBoxNameService.Text      = "";
         comboBoxCategoryService.Text = null;
         comboBoxTypeService.Text     = null;
         textBoxPrice.Text            = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }