예제 #1
0
 private void AddClient_Click(object sender, RoutedEventArgs e)
 {
     using (LSEntities ls = new LSEntities())
     {
         ls.Client.Load();
         Client client = new Client();
         {
             // Занесение данных из формы в объект
             client.ID         = ls.Client.Count();
             client.FirstName  = fn.Text;
             client.LastName   = ln.Text;
             client.Patronimyc = pn.Text;
             if (m.IsChecked == true)
             {
                 client.Gender = "1";
             }
             else
             {
                 client.Gender = "2";
             }
             client.Phone            = ph.Text;
             client.Birtday          = bd.SelectedDate;
             client.Email            = ml.Text;
             client.RegistrationDate = (DateTime)rd.SelectedDate;
         }
         ls.Client.Add(client); // Занесение в БД
         ls.SaveChanges();      //Сохранение БД
         System.Windows.MessageBox.Show("Клиент успешно Добавлен!");
         this.Close();
     }
 }
예제 #2
0
 public ClientServise()
 {
     LSEntities ls = new LSEntities();
     {
         InitializeComponent();
         //Загрузка таблицы в ListBox
         ls.ClientService.Load();
         ClientServiceLB.ItemsSource = ls.ClientService.Local.ToBindingList();
     }
 }