예제 #1
0
 public RemoveItem(Goods g, AdminCatalog adminCatalog)
 {
     goods             = g;
     this.adminCatalog = adminCatalog;
     InitializeComponent();
     alertImage.Source = new BitmapImage((new Uri("C:/Users/emiagin/source/repos/WpfApp1/WpfApp1/red.png", UriKind.RelativeOrAbsolute)));
 }
예제 #2
0
파일: ViewModel.cs 프로젝트: pepe-Di/bd
        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;
        }
예제 #3
0
 public AdminItem(Goods g, AdminCatalog adminCatalog)
 {
     this.adminCatalog = adminCatalog;
     InitializeComponent();
     DataContext      = new ViewModel();
     item             = g;
     Name.Text        = item.Name;
     Description.Text = item.Description;
     Price.Text       = item.Price.ToString();
     Amount.Text      = item.Amount.ToString();
     ImagePath.Text   = item.Preview;
     Preview.Source   = new BitmapImage(new Uri(path + item.Preview, UriKind.RelativeOrAbsolute));
 }
예제 #4
0
        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();
        }
예제 #5
0
 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");
     }
 }
예제 #6
0
 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");
     }
 }
예제 #7
0
 public AddItem(AdminCatalog adminCatalog)
 {
     this.adminCatalog = adminCatalog;
     InitializeComponent();
     DataContext = new ViewModel();
 }