Esempio n. 1
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     if (comboBoxEmployee.SelectedItem != null || comboBoxClient.SelectedItem != null || comboBoxService.SelectedItem != null ||
         comboBoxStatus.SelectedItem != null || textBoxDate.Text != "")
     {
         DateTime temp;
         bool     date = DateTime.TryParse(textBoxDate.Text, out temp);
         if (!date)
         {
             MessageBox.Show("Введите дату в формате: ДД.ММ.ГГГГ", "Неверный формат даты", MessageBoxButtons.OK);
         }
         else
         {
             OrdersSet ordersSet = new OrdersSet();
             ordersSet.Date        = Convert.ToDateTime(textBoxDate.Text);
             ordersSet.Id_Employee = Convert.ToInt32(comboBoxEmployee.SelectedItem.ToString().Split('.')[0]);
             ordersSet.Id_Client   = Convert.ToInt32(comboBoxClient.SelectedItem.ToString().Split('.')[0]);
             ordersSet.Id_Service  = Convert.ToInt32(comboBoxService.SelectedItem.ToString().Split('.')[0]);
             ordersSet.Status      = comboBoxStatus.SelectedItem.ToString();
             Program.vp.OrdersSet.Add(ordersSet);
             Program.vp.SaveChanges();
             ShowOrders();
         }
     }
     else
     {
         MessageBox.Show("Заполните все поля", "Невозможно внести данные!", MessageBoxButtons.OK);
     }
 }
Esempio n. 2
0
 private void listViewOrders_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewOrders.SelectedItems.Count == 1)
     {
         OrdersSet ordersSet = listViewOrders.SelectedItems[0].Tag as OrdersSet;
         textBoxDate.Text = ordersSet.Date.ToString().Substring(0, ordersSet.Date.ToString().Length - 8);
         comboBoxEmployee.SelectedIndex = comboBoxEmployee.FindString(ordersSet.Id_Employee.ToString());
         comboBoxClient.SelectedIndex   = comboBoxClient.FindString(ordersSet.Id_Client.ToString());
         comboBoxService.SelectedIndex  = comboBoxService.FindString(ordersSet.Id_Service.ToString());
         comboBoxStatus.SelectedIndex   = comboBoxStatus.FindString(ordersSet.Status);
     }
     else
     {
         textBoxDate.Text = "";
         comboBoxEmployee.SelectedItem = null;
         comboBoxClient.SelectedItem   = null;
         comboBoxService.SelectedItem  = null;
         comboBoxStatus.SelectedItem   = null;
     }
 }
Esempio n. 3
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewOrders.SelectedItems.Count == 1)
         {
             OrdersSet ordersSet = listViewOrders.SelectedItems[0].Tag as OrdersSet;
             Program.vp.OrdersSet.Remove(ordersSet);
             Program.vp.SaveChanges();
             ShowOrders();
         }
         textBoxDate.Text = "";
         comboBoxEmployee.SelectedItem = null;
         comboBoxClient.SelectedItem   = null;
         comboBoxService.SelectedItem  = null;
         comboBoxStatus.SelectedItem   = null;
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }