12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Shapes;
- namespace Learn
- {
- /// <summary>
- /// Логика взаимодействия для AddRegistration.xaml
- /// </summary>
- public partial class AddRegistration : Window
- {
- Entities DB = new Entities();
- ClientService cs = new ClientService();
- int ServId = 0;
- public AddRegistration()
- {
- InitializeComponent();
- }
- public AddRegistration(int id)
- {
- InitializeComponent();
- ServId = id;
- ServName.Text = DB.Service.Where(x => x.ID == id).Select(x => x.Title).First();
- Duration.Text = (DB.Service.Where(x => x.ID == id).Select(x => x.DurationInSeconds).First() / 60).ToString();
- List<string> clients = new List<string>();
- foreach (Client c in DB.Client)
- {
- clients.Add($"{c.LastName} {c.FirstName} {c.Patronymic}");
- }
- Client.ItemsSource = clients;
- }
- private void MakeReg(object sender, RoutedEventArgs e)
- {
- cs.ClientID = Client.SelectedIndex + 1;
- cs.ServiceID = ServId;
- DateTime tm = Convert.ToDateTime(TimeServ.Text);
- DateTime DateReg = new DateTime(DateServ.SelectedDate.Value.Year, DateServ.SelectedDate.Value.Month, DateServ.SelectedDate.Value.Day, tm.Hour, tm.Minute, tm.Second);
- cs.StartTime = DateReg;
- DB.ClientService.Add(cs);
- DB.SaveChanges();
- MessageBox.Show("Запись сделана");
- this.Close();
- }
- }
- }
|