Beispiel #1
0
 private void Window_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     if (Visibility == Visibility.Visible)
     {
         OrderfurnituredbEntities.GetContext().ChangeTracker.Entries().ToList().ForEach(p => p.Reload());
         DGridMaterial.ItemsSource = OrderfurnituredbEntities.GetContext().Material.ToList();
     }
 }
Beispiel #2
0
        private void UpdateEquipment()
        {
            var currentMaterial = OrderfurnituredbEntities.GetContext().Material.ToList();

            currentMaterial = currentMaterial.Where(p => p.Name.ToLower().Contains(TBoxSearch.Text.ToLower())).ToList();


            DGridMaterial.ItemsSource = currentMaterial.OrderBy(p => p.Article).ToList();
        }
Beispiel #3
0
        private void UpdateEquipment()
        {
            var currentEquipment = OrderfurnituredbEntities.GetContext().Equipments.ToList();

            currentEquipment = currentEquipment.Where(p => p.Name.ToLower().Contains(TBoxSearch.Text.ToLower())).ToList();


            DGridEquipments.ItemsSource = currentEquipment.OrderBy(p => p.Name).ToList();
        }
 public AddFurniture(Furniture selectedFurniture)
 {
     InitializeComponent();
     if (selectedFurniture != null)
     {
         _currentFurniture = selectedFurniture;
     }
     DataContext = _currentFurniture;
     CBoxTypeNameSupplier.ItemsSource = OrderfurnituredbEntities.GetContext().Supplier.ToList();
 }
Beispiel #5
0
 public AddEcuipments(Equipments selectedEquipment)
 {
     InitializeComponent();
     if (selectedEquipment != null)
     {
         _currentEquipment = selectedEquipment;
     }
     DataContext = _currentEquipment;
     CBoxTypeEquipment.ItemsSource = OrderfurnituredbEntities.GetContext().TypeEquipment.ToList();
 }
Beispiel #6
0
 public AddMaterial(Material selectedMaterial)
 {
     InitializeComponent();
     if (selectedMaterial != null)
     {
         _currentMaterial = selectedMaterial;
     }
     DataContext = _currentMaterial;
     CBoxTypeNameSupplier.ItemsSource = OrderfurnituredbEntities.GetContext().Supplier.ToList();
     suppliers = OrderfurnituredbEntities.GetContext().Supplier.ToList();
 }
Beispiel #7
0
        private void BtnSave(object sender, RoutedEventArgs e)
        {
            StringBuilder errors = new StringBuilder();

            if (string.IsNullOrWhiteSpace(_currentEquipment.label))
            {
                errors.AppendLine("Укажите маркировку оборудования");
            }
            if (string.IsNullOrWhiteSpace(_currentEquipment.Name))
            {
                errors.AppendLine("Укажите наименование оборудования");
            }
            if (_currentEquipment.TypeEquipment == null)
            {
                errors.AppendLine("Выберите тип оборудования");
            }

            if (TBcharac.Text.Length > 150)
            {
                MessageBox.Show("Количество символов не должно превышать 150 символов ");
                return;
            }
            //if(TBcharac.Text.Length>45)
            //{
            // Сделать проверку если количество символов больше 45 делать перенос строки.
            //}
            if (errors.Length > 0)
            {
                MessageBox.Show(errors.ToString());
                return;
            }

            if (_currentEquipment.Id == 0)
            {
                OrderfurnituredbEntities.GetContext().Equipments.Add(_currentEquipment);
            }

            try
            {
                OrderfurnituredbEntities.GetContext().SaveChanges();
                MessageBox.Show("Запись успешно сохранена!");
                WorkEquipments.WorkWithEquipments equipmentAccountingWindow = new WorkEquipments.WorkWithEquipments();
                equipmentAccountingWindow.Visibility = Visibility.Visible;
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
Beispiel #8
0
        private void BtnRemove(object sender, RoutedEventArgs e)
        {
            var materialForRemoving = DGridMaterial.SelectedItems.Cast <Material>().ToList();

            if (MessageBox.Show($"Вы точно хотите удалить следующие {materialForRemoving.Count()} элементов?", "Внимание", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
            {
                try
                {
                    OrderfurnituredbEntities.GetContext().Material.RemoveRange(materialForRemoving);
                    OrderfurnituredbEntities.GetContext().SaveChanges();
                    MessageBox.Show("Данны успешно удалены!");

                    DGridMaterial.ItemsSource = OrderfurnituredbEntities.GetContext().Material.ToList();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString());
                }
            }
        }
        private void BtnSave(object sender, RoutedEventArgs e)
        {
            var p = OrderfurnituredbEntities.GetContext().Furniture.Any(l => l.Article == ChekMark.Text);

            if (p == true)
            {
                MessageBox.Show("Артикул уже существует, придумайте другой. ");
                return;
            }
            StringBuilder errors = new StringBuilder();

            if (string.IsNullOrWhiteSpace(_currentFurniture.Article))
            {
                errors.AppendLine("Укажите артикул фурнитуры");
            }
            if (string.IsNullOrWhiteSpace(_currentFurniture.Name))
            {
                errors.AppendLine("Укажите наименование фурнитуры");
            }



            if (errors.Length > 0)
            {
                MessageBox.Show(errors.ToString());
                return;
            }
            else
            {
                OrderfurnituredbEntities.GetContext().Furniture.Add(_currentFurniture);
            }


            OrderfurnituredbEntities.GetContext().SaveChanges();
            MessageBox.Show("Запись успешно сохранена!");
            WorkFurniture.WorkWithFurniture fur = new WorkFurniture.WorkWithFurniture();
            fur.Visibility = Visibility.Visible;
            this.Close();
        }
Beispiel #10
0
        private void SignIN(object sender, RoutedEventArgs e)
        {
            using (var db = new OrderfurnituredbEntities())
            {
                var lg = LoginText.Text.Trim();
                var pw = PasswordText.Password.Trim();
                var cp = CaptchaText.Text.Trim();
                if (string.IsNullOrEmpty(lg) && string.IsNullOrEmpty(cp) && string.IsNullOrEmpty(pw))
                {
                    Captcha();
                    MessageBox.Show("Логин, пароль, капча не введены, повторите попытку!");
                    return;
                }
                if (string.IsNullOrEmpty(lg) && !string.IsNullOrEmpty(cp) && !string.IsNullOrEmpty(pw))
                {
                    Captcha();
                    MessageBox.Show("Логин не введен, повторите попытку!");
                    return;
                }
                if (string.IsNullOrEmpty(lg) && !string.IsNullOrEmpty(cp) && string.IsNullOrEmpty(pw))
                {
                    Captcha();
                    MessageBox.Show("Логин и пароль не введены, повторите попытку!");
                    return;
                }
                if (!string.IsNullOrEmpty(lg) && string.IsNullOrEmpty(cp) && string.IsNullOrEmpty(pw))
                {
                    Captcha();
                    MessageBox.Show("Логин и капча не введены, повторите попытку!");
                    return;
                }
                if (!string.IsNullOrEmpty(lg) && string.IsNullOrEmpty(cp) && !string.IsNullOrEmpty(pw))
                {
                    Captcha();
                    MessageBox.Show("Капча не введена, повторите попытку!");
                    return;
                }
                if (!string.IsNullOrEmpty(lg) && !string.IsNullOrEmpty(cp) && string.IsNullOrEmpty(pw))
                {
                    Captcha();
                    MessageBox.Show("Пароль не введен, повторите попытку!");
                    return;
                }

                var res = from Users in db.Users where Users.Login == LoginText.Text && Users.Password == PasswordText.Password select Users;
                if (res.Count() == 1 && CaptchaText.Text == CaptchaLabel.Content.ToString())
                {
                    switch (res.First().Role)
                    {
                    case "Директор":
                        GlobalBack.role = Role.Director;
                        Roles.Director dir = new Roles.Director();
                        dir.Visibility = Visibility.Visible;
                        this.Close();
                        break;

                    case "Заказчик":
                        GlobalBack.role = Role.Customer;
                        Roles.Customer cust = new Roles.Customer();
                        cust.Visibility = Visibility.Visible;
                        this.Close();
                        break;

                    case "Заместитель директора":
                        GlobalBack.role = Role.ZamDirectora;
                        Roles.ZamDirectora zam = new Roles.ZamDirectora();
                        zam.Visibility = Visibility.Visible;
                        this.Close();
                        break;

                    case "Менеджер":
                        GlobalBack.role = Role.Manager;
                        Roles.Manager man = new Roles.Manager();
                        man.Visibility = Visibility.Visible;
                        this.Close();
                        break;

                    case "Мастер":
                        GlobalBack.role = Role.Master;
                        Roles.Master mas = new Roles.Master();
                        mas.Visibility = Visibility.Visible;
                        this.Close();
                        break;
                    }
                }
                else if (res.Count() == 1 && CaptchaText.Text != CaptchaLabel.Content.ToString())
                {
                    Captcha();
                    MessageBox.Show("Капча введена не правильно\nПовторите попытку!");
                    return;
                }
                else
                {
                    Captcha();
                    MessageBox.Show("Логин или пароль введены не правильно!\nПовторите попытку!");
                    return;
                }
            }
        }
Beispiel #11
0
        private void Signup(object sender, RoutedEventArgs e)
        {
            var lg = Login.Text;
            var pw = Password.Password;



            using (var db = new OrderfurnituredbEntities())
            {
                StringBuilder errors = new StringBuilder();
                var           p      = db.Users.Any(l => l.Login == Login.Text);

                if (pw.Length < 6 || pw.Length > 20)
                {
                    errors.AppendLine("Длина пароля должна состоять от 6 до 20 символов");
                }
                if (!pw.Any(char.IsUpper))
                {
                    errors.AppendLine("Пароль должен содержать хотя бы одну заглавную букву");
                }
                if (!pw.Any(char.IsDigit))
                {
                    errors.AppendLine("Пароль должен содержать хотя бы одну цифру");
                }
                if (pw.Intersect("!@#$%^").Count() == 0)
                {
                    errors.AppendLine("Пароль должен содержать хотя бы один символ из набора  '!@#$%^'");
                }
                if (String.IsNullOrEmpty(lg))
                {
                    errors.AppendLine("Логин не введен, повторите попытку");
                }
                if (String.IsNullOrEmpty(pw))
                {
                    errors.AppendLine("Пароль не введен, повторите попытку");
                }
                if (Password.Password != RepeatPassword.Password)
                {
                    errors.AppendLine("Пароли не совпадают, повторите попытку!");
                }
                if (p == true)
                {
                    errors.AppendLine("Пользователь с таким логином уже существует, придумайте другой.");
                }
                var imageBuffer = BitmapSourceToByteArray((BitmapSource)Picture.Source);
                if (errors.Length > 0)
                {
                    MessageBox.Show(errors.ToString());
                    return;
                }
                else
                {
                    Users user = new Users
                    {
                        Login     = Login.Text,
                        Password  = Password.Password,
                        FirstName = FirstName.Text,
                        LastName  = LastName.Text,
                        MidName   = MiddleName.Text,
                        Role      = "Заказчик",
                        Picture   = imageBuffer
                    };
                    db.Users.Add(user);
                    db.SaveChanges();
                    MessageBox.Show("Аккаунт успешно создан!");
                }
            }
        }