示例#1
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            int           i      = 0;
            StringBuilder errors = new StringBuilder();

            if (repProd.IdProducts == null || repProd.IdRecipes == null)
            {
                errors.AppendLine("Укажите id продукта или товара правильно");
            }
            if (errors.Length > 0)
            {
                MessageBox.Show(errors.ToString());
                return;
            }
            if (repProd.Id == 0)
            {
                SweetshopEntities1.GetContext().RecipeProducts.Add(repProd);
            }
            try
            {
                SweetshopEntities1.GetContext().SaveChanges();
                MessageBox.Show("Информация сохранена");
                PageMove.BWFrame.GoBack();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            using (SweetshopEntities1 db = new SweetshopEntities1())
            {
                bool authorize = false;
                try
                {
                    foreach (var user in SweetshopEntities1.GetContext().Admins)
                    {
                        if (LoginBox.Text == user.Email && PassBox.Password == user.Password && user.Type == 2)
                        {
                            authorize = true;
                            DateTime    dt      = DateTime.Now;
                            JoinHistory history = new JoinHistory();
                            history.Email    = LoginBox.Text;
                            history.Password = PassBox.Password;
                            history.Time     = dt;
                            db.JoinHistories.Add(history);
                            db.SaveChanges();
                            MessageBox.Show("Вы вошли как администратор", "Добро пожаловать", MessageBoxButton.OK, MessageBoxImage.Information);
                            PageMove.BWFrame.Navigate(new PageAdmin());
                        }
                    }
                    foreach (var user in SweetshopEntities1.GetContext().SysAdmins)
                    {
                        if (LoginBox.Text == user.Email && PassBox.Password == user.Password && user.Type == 1)
                        {
                            authorize = true;
                            DateTime    dt      = DateTime.Now;
                            JoinHistory history = new JoinHistory();
                            history.Email    = LoginBox.Text;
                            history.Password = PassBox.Password;
                            history.Time     = dt;
                            db.JoinHistories.Add(history);
                            db.SaveChanges();

                            MessageBox.Show("Вы вошли как сис-админ", "Добро пожаловать", MessageBoxButton.OK, MessageBoxImage.Information);
                            PageMove.BWFrame.Navigate(new PageSysAdmin());
                        }
                    }
                    if (authorize == false)
                    {
                        DateTime    dt      = DateTime.Now;
                        JoinHistory history = new JoinHistory();
                        history.Email    = LoginBox.Text;
                        history.Password = PassBox.Password;
                        history.Time     = dt;
                        db.JoinHistories.Add(history);
                        db.SaveChanges();

                        MessageBox.Show("Неправильно введен логин или пароль", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
                catch
                {
                    /*CheckConnection();*/
                }
            }
        }
 private void Page_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     if (Visibility == Visibility.Visible)
     {
         SweetshopEntities1.GetContext().ChangeTracker.Entries().ToList().ForEach(p => p.Reload());
         DGRecipe.ItemsSource = SweetshopEntities1.GetContext().Recipes.ToList();
     }
 }
示例#4
0
        public PageAddRecipe(Recipe selectedRep)
        {
            if (selectedRep != null)
            {
                repRole = selectedRep;
            }
            InitializeComponent();

            DataContext           = repRole;
            ComboType.ItemsSource = SweetshopEntities1.GetContext().ProductTypes.ToList();
        }
示例#5
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            StringBuilder errors = new StringBuilder();

            if (string.IsNullOrWhiteSpace(repRole.Name))
            {
                errors.AppendLine("Укажите название правильно");
            }
            if (string.IsNullOrWhiteSpace(repRole.Author))
            {
                errors.AppendLine("Укажите имя автора правильно");
            }
            if (repRole.ProductType == null)
            {
                errors.AppendLine("Укажите тип продукта правильно");
            }
            if (repRole.DataCreate == null)
            {
                errors.AppendLine("Укажите дату создания правильно");
            }
            if (repRole.Price <= 0 || repRole.Price > 1000)
            {
                errors.AppendLine("Укажите цену правильно");
            }
            if (errors.Length > 0)
            {
                MessageBox.Show(errors.ToString());
                return;
            }
            if (repRole.Id == 0)
            {
                SweetshopEntities1.GetContext().Recipes.Add(repRole);
            }
            try
            {
                SweetshopEntities1.GetContext().SaveChanges();
                MessageBox.Show("Информация сохранена");
                PageMove.BWFrame.GoBack();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
        private void Button_deleteClick(object sender, RoutedEventArgs e)
        {
            var recipeRemove = DGRecipe.SelectedItems.Cast <Recipe>().ToList();

            if (MessageBox.Show($"Вы точно хотите удалить следующие {recipeRemove.Count()} элементов?", "Внимание", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
            {
                try
                {
                    SweetshopEntities1.GetContext().Recipes.RemoveRange(recipeRemove);
                    SweetshopEntities1.GetContext().SaveChanges();
                    MessageBox.Show("Данные удалены");
                    DGRecipe.ItemsSource = SweetshopEntities1.GetContext().Recipes.ToList();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString());
                }
            }
        }
示例#7
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            StringBuilder errors = new StringBuilder();

            if (string.IsNullOrWhiteSpace(prod.ProductName))
            {
                errors.AppendLine("Укажите название правильно");
            }
            if (prod.Counts <= 0 || prod.Counts > 10000)
            {
                errors.AppendLine("Укажите количество правильно");
            }
            if (prod.DeliveryDate == null)
            {
                errors.AppendLine("Укажите дату правильно");
            }
            if (string.IsNullOrWhiteSpace(prod.Manafacturer))
            {
                errors.AppendLine("Укажите производителя правильно");
            }
            if (errors.Length > 0)
            {
                MessageBox.Show(errors.ToString());
                return;
            }
            if (prod.Id == 0)
            {
                SweetshopEntities1.GetContext().Products.Add(prod);
            }
            try
            {
                SweetshopEntities1.GetContext().SaveChanges();
                MessageBox.Show("Информация сохранена");
                PageMove.BWFrame.GoBack();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            StringBuilder errors = new StringBuilder();

            if (string.IsNullOrWhiteSpace(mandgRole.Name))
            {
                errors.AppendLine("Укажите имя правильно");
            }
            if (string.IsNullOrWhiteSpace(mandgRole.Email))
            {
                errors.AppendLine("Укажите логин правильно");
            }
            if (string.IsNullOrWhiteSpace(mandgRole.Password))
            {
                errors.AppendLine("Укажите пароль правильно");
            }
            if (errors.Length > 0)
            {
                MessageBox.Show(errors.ToString());
                return;
            }
            if (mandgRole.Id == 0)
            {
                SweetshopEntities1.GetContext().Manadgers.Add(mandgRole);
                mandgRole.Type = 3;
            }
            try
            {
                SweetshopEntities1.GetContext().SaveChanges();
                MessageBox.Show("Информация сохранена");
                PageMove.BWFrame.GoBack();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
示例#9
0
 public PagePrint()
 {
     InitializeComponent();
     DGRecipe.ItemsSource = SweetshopEntities1.GetContext().Recipes.ToArray();
 }
 private void TBoxFind_Change(object sender, TextChangedEventArgs e)
 {
     DGRecipe.ItemsSource = SweetshopEntities1.GetContext().Recipes.ToList().Where(p => p.Name.ToLower().Contains(tBoxFind.Text.ToLower()) || p.ProductType.Name.ToLower().Contains(tBoxFind.Text.ToLower()) || p.Author.ToLower().Contains(tBoxFind.Text.ToLower())).ToList();
 }
 public PageAdminTableRecipe()
 {
     InitializeComponent();
     DGRecipe.ItemsSource = SweetshopEntities1.GetContext().Recipes.ToList();
 }
 public PageSysAdminTableJoinHistory()
 {
     InitializeComponent();
     DGHistory.ItemsSource = SweetshopEntities1.GetContext().JoinHistories.ToList();
 }