Exemple #1
0
 /// <summary>
 /// Кнопка сохранить изменения
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btn_save_edit_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         using RegistrantCoreContext ef = new RegistrantCoreContext();
         var contragent = ef.Contragents.FirstOrDefault(x => x.IdContragent == Convert.ToInt32(tb_idcontragent.Text));
         if (contragent != null)
         {
             contragent.Name        = tb_edit_name.Text;
             contragent.ServiceInfo =
                 $"{contragent.ServiceInfo}\n {DateTime.Now} {App.ActiveUser} изменил название контрагента";
         }
         ef.SaveChanges();
         btn_refresh_Click(sender, e);
         ContentEdit.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_add_add_Click(object sender, RoutedEventArgs e)
 {
     ContentAddUser.Hide();
     if (tb_login.Text != "")
     {
         try
         {
             using RegistrantCoreContext ef = new RegistrantCoreContext();
             User user = new User
             {
                 Name     = tb_name.Text,
                 Login    = tb_login.Text,
                 Password = tb_pass.Text
             };
             user.LevelAccess = cb_access.SelectedIndex switch
             {
                 0 => "kpp",
                 1 => "reader",
                 2 => "warehouse",
                 3 => "shipment",
                 4 => "admin",
                 _ => user.LevelAccess
             };
             ef.Add(user);
             ef.SaveChanges();
             LoadUser();
         }
         catch (Exception ex)
         {
             ((MainWindow)Application.Current.MainWindow).ContentErrorText.ShowAsync();
             ((MainWindow)Application.Current.MainWindow).text_debuger.Text = ex.ToString();
         }
         ContentSave.ShowAsync();
     }
 }
Exemple #3
0
 /// <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_delete_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                using RegistrantCoreContext ef = new RegistrantCoreContext();
                var driver = ef.Drivers.FirstOrDefault(x => x.IdDriver == Convert.ToInt32(tb_id.Text));
                if (driver != null)
                {
                    driver.Active      = "0";
                    driver.ServiceInfo = driver.ServiceInfo + "\n" + DateTime.Now + " " + App.ActiveUser + " удалил водителя";
                }

                ef.SaveChanges();
                ContentAddEdit.Hide();
                btn_refresh_Click(sender, e);
            }
            catch (Exception ex)
            {
                MainWindow mainWindow = (MainWindow)Application.Current.MainWindow;
                if (mainWindow != null)
                {
                    mainWindow.ContentErrorText.ShowAsync();
                    mainWindow.text_debuger.Text = ex.ToString();
                }
            }
        }
Exemple #5
0
        private void btn_load_Click(object sender, RoutedEventArgs e)
        {
            var bt      = e.OriginalSource as Button;
            var current = bt?.DataContext as Shipments;

            if (current != null)
            {
                MessageBoxResult?result = MessageBox.Show("Сменить статус водителя " + current.Fio + " на Загрузка начата?", "Внимание", MessageBoxButton.YesNo, MessageBoxImage.Information);
                if (result == MessageBoxResult.Yes)
                {
                    try
                    {
                        using RegistrantCoreContext ef = new RegistrantCoreContext();
                        var shipment = ef.Shipments.FirstOrDefault(x => x.IdShipment == current.IdShipment);
                        if (shipment != null)
                        {
                            shipment.IdTimeNavigation.DateTimeLoad = DateTime.Now;
                        }
                        ef.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                        MainWindow mainWindow = (MainWindow)Application.Current.MainWindow;
                        if (mainWindow != null)
                        {
                            mainWindow.ContentErrorText.ShowAsync();
                            mainWindow.text_debuger.Text = ex.ToString();
                        }
                        ;
                    }
                }
            }

            btn_refresh_Click(sender, e);
        }
        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);
            }
        }
Exemple #7
0
        //Кнопка удалить
        private void btn_delete_Click(object sender, RoutedEventArgs e)
        {
            if (tb_idcontragent != null)
            {
                try
                {
                    using RegistrantCoreContext ef = new RegistrantCoreContext();
                    var temp = ef.Contragents.FirstOrDefault(x => x.IdContragent == Convert.ToInt32(tb_idcontragent.Text));
                    if (temp != null)
                    {
                        temp.Active = "0";
                    }
                    ef.SaveChanges();
                    ContentEdit.Hide();
                }
                catch (Exception ex)
                {
                    MainWindow mainWindow = (MainWindow)Application.Current.MainWindow;
                    if (mainWindow != null)
                    {
                        mainWindow.ContentErrorText.ShowAsync();
                        mainWindow.text_debuger.Text = ex.ToString();
                    }
                }
            }
            //Кнопа перенесена в другоме место,

            /*var bt = e.OriginalSource as Button;
             * var current = bt.DataContext as DB.Contragent;
             *
             * try
             * {
             *  using RegistrantCoreContext ef = new RegistrantCoreContext();
             *  var contragent = ef.Contragents.FirstOrDefault(x => x.IdContragent == current.IdContragent);
             *  if (contragent != null)
             *  {
             *      contragent.Active = "0";
             *      contragent.ServiceInfo = $"{contragent.ServiceInfo}\n{DateTime.Now} {App.ActiveUser} изменил удалил";
             *  }
             *  ef.SaveChanges();
             *  btn_refresh_Click(sender, e);
             * }
             * catch (Exception ex)
             * {
             *  MainWindow mainWindow = (MainWindow) Application.Current.MainWindow;
             *  if (mainWindow != null)
             *  {
             *      mainWindow.ContentErrorText.ShowAsync();
             *      mainWindow.text_debuger.Text = ex.ToString();
             *  }
             * }
             * }*/
        }
        /// Непосредственное редактирование
        private void btn_edit_Click1(object sender, RoutedEventArgs e)
        {
            try
            {
                using RegistrantCoreContext ef = new RegistrantCoreContext();
                var driver = ef.Drivers.FirstOrDefault(x => x.IdDriver == Convert.ToInt32(tb_id.Text));
                if (driver != null)
                {
                    driver.Family     = tb_Family.Text;
                    driver.Name       = tb_name.Text;
                    driver.Patronymic = tb_patronomyc.Text;
                    driver.Phone      = tb_phone.Text;

                    driver.Attorney    = tb_attorney.Text;
                    driver.Auto        = tb_auto.Text;
                    driver.AutoNumber  = tb_autonum.Text;
                    driver.Passport    = tb_passport.Text;
                    driver.Info        = tb_info.Text;
                    driver.ServiceInfo = driver.ServiceInfo + "\n" + DateTime.Now + " " + App.ActiveUser + " внес изменения";
                    ef.SaveChanges();
                    btn_close_Click(sender, e);
                    ContentAddEdit.Hide();
                }

                ef.SaveChanges();
                btn_close_Click(sender, e);
                ContentAddEdit.Hide();
                btn_refresh_Click(sender, e);
            }
            catch (Exception ex)
            {
                MainWindow mainWindow = (MainWindow)Application.Current.MainWindow;
                if (mainWindow != null)
                {
                    mainWindow.ContentErrorText.ShowAsync();
                    mainWindow.text_debuger.Text = ex.ToString();
                }
            }
        }
        /// Кнопка добавления водителя
        private void btn_add_Click(object sender, RoutedEventArgs e)
        {
            if (tb_Family.Text == "")
            {
                MessageBox.Show("Введите хотя бы фамилию водителя!", "Внимание!", MessageBoxButton.OK,
                                MessageBoxImage.Error);
                return;
            }

            try
            {
                using RegistrantCoreContext ef = new RegistrantCoreContext();
                Driver driver = new Driver
                {
                    Family      = tb_Family.Text,
                    Name        = tb_name.Text,
                    Patronymic  = tb_patronomyc.Text,
                    Phone       = tb_phone.Text,
                    Attorney    = tb_attorney.Text,
                    Auto        = tb_auto.Text,
                    AutoNumber  = tb_autonum.Text,
                    Passport    = tb_passport.Text,
                    Info        = tb_info.Text,
                    Active      = "1",
                    ServiceInfo = DateTime.Now + " " + App.ActiveUser + " добавил водителя"
                };

                ef.Add(driver);
                ef.SaveChanges();
                btn_close_Click(sender, e);
            }
            catch (Exception ex)
            {
                MainWindow mainWindow = (MainWindow)Application.Current.MainWindow;
                if (mainWindow != null)
                {
                    mainWindow.ContentErrorText.ShowAsync();
                    mainWindow.text_debuger.Text = ex.ToString();
                }
            }
        }
        private void btn_deluser_Click(object sender, RoutedEventArgs e)
        {
            var bt      = e.OriginalSource as Button;
            var current = bt?.DataContext as User;

            if (current != null)
            {
                try
                {
                    using RegistrantCoreContext ef = new RegistrantCoreContext();
                    ef.Remove(current);
                    ef.SaveChanges();
                    LoadUser();
                    ContentSave.ShowAsync();
                }
                catch (Exception ex)
                {
                    ((MainWindow)Application.Current.MainWindow).ContentErrorText.ShowAsync();
                    ((MainWindow)Application.Current.MainWindow).text_debuger.Text = ex.ToString();
                }
            }
        }
        private void btn_del_yes_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                using RegistrantCoreContext ef = new RegistrantCoreContext();
                var shipment = ef.Shipments.FirstOrDefault(x => x.IdShipment == Convert.ToInt32(idcont.Text));
                if (shipment != null)
                {
                    shipment.Active      = "0";
                    shipment.Description = shipment.Description + " " + tb_reasofordel.Text;
                    shipment.ServiceInfo = shipment.ServiceInfo + "\n" + DateTime.Now + " " + App.ActiveUser +
                                           " удалил отгрузку";
                }

                ef.SaveChanges();
                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        private void btn_save_Click(object sender, RoutedEventArgs e)
        {
            if (tb_login.Text != "")
            {
                using RegistrantCoreContext ef = new RegistrantCoreContext();
                var user = ef.Users.FirstOrDefault(x => x.IdUser == Convert.ToInt32(tb_id.Text));

                if (tb_pass.Text == user?.Password)
                {
                    user.Login    = tb_login.Text;
                    user.Password = tb_passnew.Text;
                    ef.SaveChanges();
                    ContentSave.ShowAsync();

                    tb_pass.Text    = "";
                    tb_passnew.Text = "";
                }
                else
                {
                    MainWindow mainWindow = (MainWindow)Application.Current.MainWindow;
                    if (mainWindow != null)
                    {
                        mainWindow.ContentErrorText.ShowAsync();
                        mainWindow.text_debuger.Text = "Пароль не совпадает со старым";
                    }
                }
            }
            else
            {
                MainWindow mainWindow = (MainWindow)Application.Current.MainWindow;
                if (mainWindow != null)
                {
                    mainWindow.ContentErrorText.ShowAsync();
                    mainWindow.text_debuger.Text = "Новый логин не должен быть пустым";
                }
            }
        }
        private void EditByAdminRole()
        {
            if (cb_drivers.Text == "")
            {
                MessageBox.Show("Водитель не выбран", "Внимание!", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            if (cb_contragent.Text == "")
            {
                MessageBox.Show("Контрагент не выбран", "Внимание!", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            try
            {
                using RegistrantCoreContext ef = new RegistrantCoreContext();
                var shipment =
                    ef.Shipments.FirstOrDefault(x => x.IdShipment == Convert.ToInt64(idcont.Text));

                if (shipment != null)
                {
                    if (cb_drivers.SelectedItem != null)
                    {
                        var current = cb_drivers.SelectedItem as Drivers;
                        shipment.IdDriver = current?.IdDriver;

                        shipment.IdDriverNavigation.Phone      = tb_phone.Text;
                        shipment.IdDriverNavigation.Attorney   = tb_attorney.Text;
                        shipment.IdDriverNavigation.Auto       = tb_auto.Text;
                        shipment.IdDriverNavigation.AutoNumber = tb_autonum.Text;
                    }
                    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,
                            Auto        = tb_auto.Text,
                            Active      = "1",
                            ServiceInfo = DateTime.Now + " " + App.ActiveUser + " добавил водителя"
                        };
                        shipment.IdDriverNavigation = driver;
                    }

                    if (cb_contragent.SelectedItem != null)
                    {
                        var current = cb_contragent.SelectedItem as Contragent;
                        shipment.IdContragent = current?.IdContragent;
                    }
                    else
                    {
                        Contragent contragent = new Contragent
                        {
                            Name        = cb_contragent.Text,
                            Active      = "1",
                            ServiceInfo = DateTime.Now + " " + App.ActiveUser + " добавил контрагента"
                        };
                        shipment.IdContragentNavigation = contragent;
                    }

                    if (dt_plan.Value.HasValue)
                    {
                        shipment.IdTimeNavigation.DateTimePlanRegist = dt_plan.Value;
                    }

                    if (dt_fact.Value.HasValue)
                    {
                        shipment.IdTimeNavigation.DateTimeFactRegist = dt_fact.Value;
                    }

                    if (dt_arrive.Value.HasValue)
                    {
                        shipment.IdTimeNavigation.DateTimeArrive = dt_arrive.Value;
                    }

                    if (dt_load.Value.HasValue)
                    {
                        shipment.IdTimeNavigation.DateTimeLoad = dt_load.Value;
                    }

                    if (dt_endload.Value.HasValue)
                    {
                        shipment.IdTimeNavigation.DateTimeEndLoad = dt_endload.Value;
                    }

                    if (dt_left.Value.HasValue)
                    {
                        shipment.IdTimeNavigation.DateTimeLeft = dt_left.Value;
                    }

                    if (string.IsNullOrWhiteSpace(tb_numrealese.Text))
                    {
                        shipment.NumRealese = tb_numrealese.Text;
                    }

                    if (string.IsNullOrWhiteSpace(tb_packetdoc.Text))
                    {
                        shipment.PacketDocuments = tb_packetdoc.Text;
                    }

                    if (string.IsNullOrWhiteSpace(tb_tochkaload.Text))
                    {
                        shipment.TochkaLoad = tb_tochkaload.Text;
                    }

                    if (string.IsNullOrWhiteSpace(tb_CountPodons.Text))
                    {
                        shipment.CountPodons = tb_CountPodons.Text;
                    }

                    if (string.IsNullOrWhiteSpace(tb_nomencluture.Text))
                    {
                        shipment.Nomenclature = tb_nomencluture.Text;
                    }

                    if (string.IsNullOrWhiteSpace(tb_size.Text))
                    {
                        shipment.Size = tb_size.Text;
                    }

                    if (string.IsNullOrWhiteSpace(tb_Destination.Text))
                    {
                        shipment.Destination = tb_Destination.Text;
                    }

                    if (string.IsNullOrWhiteSpace(tb_typeload.Text))
                    {
                        shipment.TypeLoad = tb_typeload.Text;
                    }

                    if (string.IsNullOrWhiteSpace(tb_descript.Text))
                    {
                        shipment.Description = tb_descript.Text;
                    }

                    if (string.IsNullOrWhiteSpace(tb_storekeeper.Text))
                    {
                        shipment.StoreKeeper = tb_storekeeper.Text;
                    }

                    shipment.Active      = "1";
                    shipment.ServiceInfo = shipment.ServiceInfo + "\n" + DateTime.Now + " " + App.ActiveUser +
                                           " внес изменения в отгрузку";
                }
                ef.SaveChanges();
                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Программное исключене", MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }
        }
        private void EditByWarehouseRole()
        {
            try
            {
                using RegistrantCoreContext ef = new RegistrantCoreContext();
                var shipment = ef.Shipments.FirstOrDefault(x => x.IdShipment == Convert.ToInt32(idcont.Text));

                if (shipment != null)
                {
                    if (dt_load.Value.HasValue)
                    {
                        shipment.IdTimeNavigation.DateTimeLoad = dt_load.Value;
                    }

                    if (dt_endload.Value.HasValue)
                    {
                        shipment.IdTimeNavigation.DateTimeEndLoad = dt_endload.Value;
                    }

                    if (string.IsNullOrWhiteSpace(tb_CountPodons.Text))
                    {
                        shipment.CountPodons = tb_CountPodons.Text;
                    }

                    if (string.IsNullOrWhiteSpace(tb_nomencluture.Text))
                    {
                        shipment.Nomenclature = tb_nomencluture.Text;
                    }

                    if (string.IsNullOrWhiteSpace(tb_size.Text))
                    {
                        shipment.Size = tb_size.Text;
                    }

                    if (string.IsNullOrWhiteSpace(tb_Destination.Text))
                    {
                        shipment.Destination = tb_Destination.Text;
                    }

                    if (string.IsNullOrWhiteSpace(tb_typeload.Text))
                    {
                        shipment.TypeLoad = tb_typeload.Text;
                    }

                    if (string.IsNullOrWhiteSpace(tb_descript.Text))
                    {
                        shipment.Description = tb_descript.Text;
                    }

                    if (string.IsNullOrWhiteSpace(tb_storekeeper.Text))
                    {
                        shipment.StoreKeeper = tb_storekeeper.Text;
                    }
                    else
                    {
                        shipment.StoreKeeper = App.ActiveUser;
                    }

                    shipment.ServiceInfo = shipment.ServiceInfo + "\n" + DateTime.Now + " " + App.ActiveUser +
                                           " внес изменения в отгрузку";
                    ef.SaveChanges();
                    Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Программное исключене", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        /// Добавить соответственно
        private void btn_add_Click(object sender, RoutedEventArgs e)
        {
            if (cb_drivers.Text == "")
            {
                MessageBox.Show("Водитель не выбран", "Внимание!", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (cb_contragent.Text == "")
            {
                MessageBox.Show("Контрагент не выбран", "Внимание!", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (dt_plan.Value == null)
            {
                MessageBox.Show("Дата плановой загрузки не заполнена!", "Внимание!", MessageBoxButton.OK,
                                MessageBoxImage.Error);
                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,
                        Auto        = tb_auto.Text,
                        Active      = "1",
                        ServiceInfo = DateTime.Now + " " + App.ActiveUser + " добавил водителя"
                    };

                    shipment.IdDriverNavigation = driver;
                }

                if (cb_contragent.SelectedItem != null)
                {
                    var current = cb_contragent.SelectedItem as Contragent;
                    shipment.IdContragent = current?.IdContragent;
                }
                else
                {
                    Contragent contragent = new Contragent
                    {
                        Name        = cb_contragent.Text,
                        Active      = "1",
                        ServiceInfo = DateTime.Now + " " + App.ActiveUser + " добавил контрагента"
                    };
                    shipment.IdContragentNavigation = contragent;
                }

                Time time = new Time
                {
                    //При добавлении можно сохранять прям DateTime? не боясь за null-ы
                    DateTimePlanRegist = dt_plan.Value,
                    DateTimeFactRegist = dt_fact.Value,
                    DateTimeArrive     = dt_arrive.Value,
                    DateTimeLoad       = dt_load.Value,
                    DateTimeEndLoad    = dt_endload.Value,
                    DateTimeLeft       = dt_left.Value
                };

                shipment.IdTimeNavigation = time;

                if (string.IsNullOrWhiteSpace(tb_numrealese.Text))
                {
                    shipment.NumRealese = tb_numrealese.Text;
                }

                if (string.IsNullOrWhiteSpace(tb_packetdoc.Text))
                {
                    shipment.PacketDocuments = tb_packetdoc.Text;
                }

                if (string.IsNullOrWhiteSpace(tb_tochkaload.Text))
                {
                    shipment.TochkaLoad = tb_tochkaload.Text;
                }

                if (string.IsNullOrWhiteSpace(tb_CountPodons.Text))
                {
                    shipment.CountPodons = tb_CountPodons.Text;
                }

                if (string.IsNullOrWhiteSpace(tb_nomencluture.Text))
                {
                    shipment.Nomenclature = tb_nomencluture.Text;
                }

                if (string.IsNullOrWhiteSpace(tb_size.Text))
                {
                    shipment.Size = tb_size.Text;
                }

                if (string.IsNullOrWhiteSpace(tb_Destination.Text))
                {
                    shipment.Destination = tb_Destination.Text;
                }

                if (string.IsNullOrWhiteSpace(tb_typeload.Text))
                {
                    shipment.TypeLoad = tb_typeload.Text;
                }

                if (string.IsNullOrWhiteSpace(tb_descript.Text))
                {
                    shipment.Description = tb_descript.Text;
                }

                if (string.IsNullOrWhiteSpace(tb_storekeeper.Text))
                {
                    shipment.StoreKeeper = tb_storekeeper.Text;
                }

                shipment.Active      = "1";
                shipment.ServiceInfo = DateTime.Now + " " + App.ActiveUser + " добавил отгрузку";

                ef.Add(shipment);
                ef.SaveChanges();
                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Программное исключене", MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }
        }