private void SignIN(PasswordBox passwordBox) { if (passwordBox.Password.ToString() != "" && log_input != "") { var user = en.User.Where(u => u.Login == log_input && u.Password == passwordBox.Password.ToString()).FirstOrDefault(); if (user != null) { IntPtr active = GetActiveWindow(); Window ActiveWindow = Application.Current.Windows.OfType <Window>().SingleOrDefault(window => new WindowInteropHelper(window).Handle == active); ActiveWindow.Hide(); switch (user.RoleId) { case 2: case 0: { AdminCatalog c = new AdminCatalog(user.Login); c.Show(); break; } default: { Catalog c = new Catalog(user.Login); c.Show(); break; } } MessageBox.Show("Welcome, " + user.Name + "!"); } else { MessageBox.Show("User not found."); } } else { MessageBox.Show("Fill the form."); } Log_input = ""; passwordBox.Password = null; }
private void BackClick(object sender, RoutedEventArgs e) { IntPtr active = GetActiveWindow(); Window ActiveWindow = Application.Current.Windows.OfType <Window>().SingleOrDefault(window => new WindowInteropHelper(window).Handle == active); ActiveWindow.Hide(); adminCatalog.Show(); }
private void DeleteClick(object sender, RoutedEventArgs e) { var gd = en.Goods.Where(u => u.Name == goods.Name).FirstOrDefault(); if (gd != null) { en.Goods.Remove(gd); } en.SaveChanges(); this.Hide(); IntPtr active = GetActiveWindow(); Window ActiveWindow = Application.Current.Windows.OfType <Window>().SingleOrDefault(window => new WindowInteropHelper(window).Handle == active); ActiveWindow.Hide(); AdminCatalog ac = new AdminCatalog(adminCatalog.login); ac.Show(); }
private void AddClick(object sender, RoutedEventArgs e) { try { var item = en.Goods.Where(u => u.Name == Name.Text).FirstOrDefault(); if (item == null) { int value = 2; if (int.Parse(Amount.Text) > 0) { value = 1; } if (int.Parse(Amount.Text) > 11) { value = 0; } en.Goods.Add(new Goods() { Name = Name.Text, Description = Description.Text, Price = Price.Text, Amount = int.Parse(Amount.Text), Preview = ImagePath.Text, StatusId = value }); en.SaveChanges(); MessageBox.Show(Name.Text + " added!"); IntPtr active = GetActiveWindow(); Window ActiveWindow = Application.Current.Windows.OfType <Window>().SingleOrDefault(window => new WindowInteropHelper(window).Handle == active); ActiveWindow.Hide(); AdminCatalog ac = new AdminCatalog(adminCatalog.login); ac.Show(); } else { MessageBox.Show("This item already exists."); } } catch { MessageBox.Show("error"); } }
private void SubmitClick(object sender, RoutedEventArgs e) { try { var gd = en.Goods.Where(u => u.Name == item.Name).FirstOrDefault(); if (gd != null) { gd.Name = Name.Text; gd.Description = Description.Text; gd.Price = Price.Text; gd.Amount = int.Parse(Amount.Text); gd.Preview = ImagePath.Text; int value = 2; if (int.Parse(Amount.Text) == 0) { value = 2; } else if (int.Parse(Amount.Text) > 0) { value = 1; } if (int.Parse(Amount.Text) > 11) { value = 0; } gd.StatusId = value; en.SaveChanges(); MessageBox.Show(gd.Name + " changed!"); IntPtr active = GetActiveWindow(); Window ActiveWindow = Application.Current.Windows.OfType <Window>().SingleOrDefault(window => new WindowInteropHelper(window).Handle == active); ActiveWindow.Hide(); AdminCatalog ac = new AdminCatalog(adminCatalog.login); ac.Show(); } } catch { MessageBox.Show("error"); } }