/// <summary> /// Кнопка добавление, реального добавления /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_add_add_Click(object sender, RoutedEventArgs e) { try { using RegistrantCoreContext ef = new RegistrantCoreContext(); Contragent contragent = new Contragent { Name = tb_namecontragent.Text, ServiceInfo = $"{DateTime.Now} {App.ActiveUser} добавил контрагента", Active = "1" }; ef.Add(contragent); ef.SaveChanges(); ContentAdd.Hide(); } catch (Exception ex) { MainWindow mainWindow = (MainWindow)Application.Current.MainWindow; if (mainWindow != null) { mainWindow.ContentErrorText.ShowAsync(); mainWindow.text_debuger.Text = ex.ToString(); } } }
private void btn_adddriver_Click(object sender, RoutedEventArgs e) { LoadDrvAndContragents(); ClearTextboxes(); cb_drivers.Text = ""; ContentAdd.ShowAsync(); }
private void btn_add_add_Click(object sender, RoutedEventArgs e) { if (cb_drivers.Text == "") { return; } try { using RegistrantCoreContext ef = new RegistrantCoreContext(); Shipment shipment = new Shipment(); if (cb_drivers.SelectedItem != null) { var current = cb_drivers.SelectedItem as Drivers; shipment.IdDriver = current?.IdDriver; } else { //Если водителя нет в списках var splitNames = SplitNames(cb_drivers.Text + " "); Driver driver = new Driver { Name = splitNames.name.Replace(" ", ""), Family = splitNames.family.Replace(" ", ""), Patronymic = splitNames.patronomyc.Replace(" ", ""), AutoNumber = tb_autonum.Text, Attorney = tb_attorney.Text, Phone = tb_phone.Text, Passport = tb_passport.Text, Active = "1", ServiceInfo = DateTime.Now + " " + App.ActiveUser + " добавил водителя" }; shipment.IdDriverNavigation = driver; } Time time = new Time { DateTimeFactRegist = DateTime.Now }; shipment.IdTimeNavigation = time; shipment.Description = tb_info.Text; shipment.Active = "1"; shipment.ServiceInfo = DateTime.Now + " " + App.ActiveUser + " добавил отгрузку"; ef.Add(shipment); ef.SaveChanges(); ContentAdd.Hide(); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Программное исключене", MessageBoxButton.OK, MessageBoxImage.Error); } }
/// <summary> /// Кнопка добавление, реального добавления /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_add_add_Click(object sender, RoutedEventArgs e) { try { using (DB.RegistrantCoreContext ef = new DB.RegistrantCoreContext()) { DB.Contragent contragent = new DB.Contragent(); contragent.Name = tb_namecontragent.Text; contragent.ServiceInfo = DateTime.Now + " " + App.ActiveUser + " добавил контрагента"; contragent.Active = "1"; ef.Add(contragent); ef.SaveChanges(); //btn_refresh_Click(sender, e); ContentAdd.Hide(); } } catch (Exception ex) { ((MainWindow)System.Windows.Application.Current.MainWindow).ContentErrorText.ShowAsync(); ((MainWindow)System.Windows.Application.Current.MainWindow).text_debuger.Text = ex.ToString(); } }
/// <summary> /// Кнопка закрыть из диалг окна добавления /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_add_close_Click(object sender, RoutedEventArgs e) { ContentAdd.Hide(); }
//Добавить контрагента, диалог окно private void btn_addcontragent_Click(object sender, RoutedEventArgs e) { ContentAdd.ShowAsync(); tb_namecontragent.Text = null; }
private void btn_add_add_Click(object sender, RoutedEventArgs e) { if (cb_drivers.Text == "") { return; } try { using (DB.RegistrantCoreContext ef = new DB.RegistrantCoreContext()) { DB.Shipment shipment = new DB.Shipment(); if (cb_drivers.SelectedItem != null) { var test = cb_drivers as ComboBox; var current = test.SelectedItem as Models.Drivers; shipment.IdDriver = current.IdDriver; } else { //Если водителя нет в списках DB.Driver driver = new DB.Driver(); shipment.IdDriverNavigation = driver; var temp = SplitNames(cb_drivers.Text + " "); driver.Name = temp.name.Replace(" ", ""); driver.Family = temp.family.Replace(" ", ""); driver.Patronymic = temp.patronomyc.Replace(" ", ""); driver.AutoNumber = tb_autonum.Text; driver.Attorney = tb_attorney.Text; driver.Phone = tb_phone.Text; driver.AutoNumber = tb_autonum.Text; driver.Passport = tb_passport.Text; driver.Active = "1"; driver.ServiceInfo = DateTime.Now + " " + App.ActiveUser + " добавил водителя"; } DB.Time time = new DB.Time(); time.DateTimeFactRegist = DateTime.Now; shipment.IdTimeNavigation = time; shipment.Description = tb_info.Text; shipment.Active = "1"; shipment.ServiceInfo = DateTime.Now + " " + App.ActiveUser + " добавил отгрузку"; ef.Add(shipment); ef.SaveChanges(); ContentAdd.Hide(); } } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Программное исключене", MessageBoxButton.OK, MessageBoxImage.Error); } /* * if (tb_family.Text != "") * { * try * { * using (DB.RegistrantCoreContext ef = new DB.RegistrantCoreContext()) * { * DB.Shipment shipment = new DB.Shipment(); * shipment.IdDriverNavigation = new DB.Driver(); * shipment.IdTimeNavigation = new DB.Time(); * shipment.IdDriverNavigation.Family = tb_family.Text; * shipment.IdDriverNavigation.Name = tb_name.Text; * shipment.IdDriverNavigation.Patronymic = tb_patronymic.Text; * shipment.IdDriverNavigation.Phone = tb_phone.Text; * shipment.IdDriverNavigation.AutoNumber = tb_autonum.Text; * shipment.IdDriverNavigation.Passport = tb_passport.Text; * shipment.IdDriverNavigation.Info = tb_info.Text; * shipment.IdDriverNavigation.ServiceInfo = DateTime.Now + " " + App.ActiveUser + " добавил карточку водителя"; * * shipment.IdTimeNavigation.DateTimeFactRegist = DateTime.Now; * * shipment.ServiceInfo = DateTime.Now + " " + App.ActiveUser + " каскадное добавление с карточкой водителя"; * * ef.Add(shipment); * ef.SaveChanges(); * ContentAdd.Hide(); * btn_refresh_Click(sender, e); * } * } * catch (Exception ex) * { * ((MainWindow)System.Windows.Application.Current.MainWindow).ContentErrorText.ShowAsync(); * ((MainWindow)System.Windows.Application.Current.MainWindow).text_debuger.Text = ex.ToString(); * } * } * else * { * MessageBox.Show("Введите хотябы фамилию водителя!", "Внимание!", MessageBoxButton.OK, MessageBoxImage.Error); * }*/ }