public void ButtonEnterClick(object sender, RoutedEventArgs e) { //CompEntities db = new CompEntities(); string login = EnterLogin.Text.Trim(); string password = EnterPassword.Password.Trim(); using (CompEntities5 db = new CompEntities5()) { var AuthUser = db.Users.Where(u => u.Email == login && u.Password == password).FirstOrDefault(); var userNum = db.Clients.Where(u => u.Email == login).FirstOrDefault(); var empNum = db.Employees.Where(emp => emp.Email == login).FirstOrDefault(); if (String.IsNullOrEmpty(login) || String.IsNullOrEmpty(password)) { MessageBox.Show("Все поля должны быть заполнены!"); } else if (AuthUser != null && AuthUser.Rights == "3") { NavigationService.Navigate(new Cabinet(login, userNum.ClientNum)); // если логин и пароль правильные переход в личный кабинет клиента } else if (AuthUser != null && AuthUser.Rights == "2") { NavigationService.Navigate(new empCabinet(login, empNum.EmployeeNum)); // если логин и пароль правильные переход в личный кабинет сотрудника } else { MessageBox.Show("Неправильный логин или пароль"); } } }
private void Button_ClickBasket(object sender, RoutedEventArgs e) { CompEntities5 db = new CompEntities5(); var CNum = db.Clients.Where(n => n.Email == email).FirstOrDefault(); var PNUm = Convert.ToInt32((sender as Button).Uid); var checkBas = db.Basketts.Where(b => b.ProdNum == PNUm && b.ClientNum == CNum.ClientNum).FirstOrDefault(); if (checkBas == null) { Basketts newPoint = new Basketts { ClientNum = CNum.ClientNum, ProdNum = PNUm, Quantity = 1 }; db.Basketts.Add(newPoint); } else { checkBas.Quantity += 1; } db.SaveChanges(); MessageBox.Show("Товар добавлен в корзину"); }
public viewSearch(string Pname, string loginemail, int CNum) { InitializeComponent(); CompEntities5 db = new CompEntities5(); var p = db.Products.Where(n => n.Name.Contains(Pname)).ToList(); if (String.IsNullOrWhiteSpace(Pname)) { l1.Visibility = Visibility.Visible; l1.Content = "Поле не заполнено"; BBack.Visibility = Visibility.Hidden; p = null; } else if (p.Count == 0) { BBack.Visibility = Visibility.Hidden; l1.Visibility = Visibility.Visible; p = null; } else if (p.Count > 0) { db.Products.Where(n => n.Name.Contains(Pname)).ToList(); GviewSearch.ItemsSource = db.Products.Local.ToBindingList(); l1.Visibility = Visibility.Hidden; p = null; } email = loginemail; num = CNum; }
private void ButtonCatClic(object sender, RoutedEventArgs e) { string checkButton = (sender as Button).Content.ToString(); CompEntities5 db = new CompEntities5(); var check = db.Categories.Where(num => num.CatName == checkButton).FirstOrDefault(); NavigationService.Navigate(new viewProducts(check.CatNum, email)); }
public viewOrderDetails(int orderNumm, string email) { InitializeComponent(); CompEntities5 db = new CompEntities5(); var searchName = db.OrderDetails.Join(db.Products, o => o.ProductNum, p => p.ProductNum, (o, p) => new { PName = p.Name, Cost = o.Cost, Quantity = o.Quantity, OrderNum = o.OrderNum, Sum = o.Sum, ProductNum = p.ProductNum }).Where(o => o.OrderNum == orderNumm); viewOrdersDetails.ItemsSource = searchName.ToList(); email1 = email; }
public Catalog(string loginemail) { InitializeComponent(); using (CompEntities5 db = new CompEntities5()) { db.Categories.ToList(); categories.ItemsSource = db.Categories.Local.ToBindingList(); email = loginemail; } }