Пример #1
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            CustomerView customerView = new CustomerView();

            customerView.Owner = this;
            customerView.Show();
        }
        /// <summary>
        /// This method validates login information and opens new windows depending on the results
        /// </summary>
        /// <param name="username">Username parameter</param>
        /// <param name="password">Password parameter</param>
        /// <param name="main">Window that needs to be closed if validation is successfull</param>
        public void Login(string username, string password, MainWindow main)
        {
            List <FoodOrder> orderList = fom.GetAllFoodOrders();

            //Admin login
            if (username == "Employee" && password == "Employee")
            {
                AdminView av = new AdminView();
                main.Close();
                av.Show();
            }
            //Guest login
            else if (orderList.Contains((from o in orderList where o.CustomerJMBG == username select o).FirstOrDefault()) && password == "Guest")
            {
                FoodOrder fo;
                using (FoodOrderAppBaseEntities context = new FoodOrderAppBaseEntities())
                {
                    fo = (from o in context.FoodOrders where o.CustomerJMBG == username select o).FirstOrDefault();
                }
                //Guest loging with FoodOrder on Ready status
                if (fo.StatusOfOrder == "READY")
                {
                    AutoClosingMessageBox.Show("You order is ready!\nEnjoy your meal.", "Bon Appétit", 2000);
                    CustomerView cv = new CustomerView(username);
                    main.Close();
                    cv.Show();
                }
                //Guest loging with FoodOrder on Processing status
                else if (fo.StatusOfOrder == "PROCESSING")
                {
                    MessageBox.Show("You order is still processing.\nThank you for your patience.", "Almost there...", MessageBoxButton.OK, MessageBoxImage.Asterisk);
                }
                //Guest loging with FoodOrder on Rejected status
                else if (fo.StatusOfOrder == "REJECTED")
                {
                    AutoClosingMessageBox.Show("You order is rejected.\nPlease try again.", "Rejected", 2000);
                    CustomerView cv = new CustomerView(username);
                    main.Close();
                    cv.Show();
                }
                //Guest loging with no existing FoodOrder
                else if (fo == null)
                {
                    CustomerView cv = new CustomerView(username);
                    main.Close();
                    cv.Show();
                }
            }
            else if (!orderList.Contains((from o in orderList where o.CustomerJMBG == username select o).FirstOrDefault()) && password == "Guest")
            {
                CustomerView cv = new CustomerView(username);
                main.Close();
                cv.Show();
            }
            //Wrong credentials
            else
            {
                MessageBox.Show("Username or Password was incorrect ", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Пример #3
0
        private void ShowNewForm(object sender, EventArgs e)
        {
            CustomerView customerView = new CustomerView();

            customerView.MdiParent = this;
            customerView.Show();
        }
Пример #4
0
        private void customerToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CustomerView customerView = new CustomerView();

            customerView.MdiParent = this;
            customerView.Show();
        }
Пример #5
0
        private void WithoutAccountMethod(object param)
        {
            CustomerView customerView = new CustomerView();

            App.Current.MainWindow.Close();
            App.Current.MainWindow = customerView;
            customerView.Show();
        }
Пример #6
0
        public void Login(string username, string password, MainWindow main)
        {
            List <FoodCustomer> customersList = fcm.GetAllFoodCustomers();

            if (username == "Employee" && password == "Employee")
            {
                AdminView av = new AdminView();
                main.Close();
                av.Show();
            }
            else if (customersList.Contains((from c in customersList where c.JMBG == username select c).FirstOrDefault()) && password == "Guest")
            {
                FoodCustomer fc;
                FoodOrder    fo;
                using (FoodOrderAppBaseEntities context = new FoodOrderAppBaseEntities())
                {
                    fc = (from c in context.FoodCustomers where c.JMBG == username select c).FirstOrDefault();
                    fo = (from o in context.FoodOrders where o.FoodCustomer.JMBG == fc.JMBG select o).FirstOrDefault();
                }
                if (fo == null)
                {
                    CustomerView cv = new CustomerView(fc);
                    main.Close();
                    cv.Show();
                }
                else if (fo.StatusOfOrder == "READY")
                {
                    AutoClosingMessageBox.Show("You order is ready!\nEnjoy your meal.", "Bon Appétit", 2000);
                    CustomerView cv = new CustomerView(fc);
                    main.Close();
                    cv.Show();
                }
                else if (fo.StatusOfOrder == "PROCESSING")
                {
                    MessageBox.Show("You order is still processing.\nThank you for your patience.", "Almost there...", MessageBoxButton.OK, MessageBoxImage.Asterisk);
                }
                else if (fo.StatusOfOrder == "REJECTED")
                {
                    AutoClosingMessageBox.Show("You order is rejected.\nPlease try again.", "Rejected", 2000);
                    CustomerView cv = new CustomerView(fc);
                    main.Close();
                    cv.Show();
                }
            }
            else if (!customersList.Contains((from c in customersList where c.JMBG == username select c).FirstOrDefault()) && password == "Guest")
            {
                FoodCustomer fc = new FoodCustomer();
                fc.JMBG = username;
                fcm.AddFoodCustomer(fc);
                CustomerView cv = new CustomerView(fc);
                main.Close();
                cv.Show();
            }
            else
            {
                MessageBox.Show("Username or Password was incorrect ", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Пример #7
0
 public void ToCustomer(object parameter)
 {
     if (parameter == null)
     {
         var win = new CustomerView();
         win.Show();
     }
     else if (parameter.ToString() == "Customer")
     {
         selectedViewModel = new CustomerViewModel();
     }
 }
Пример #8
0
        private void loginBtn_Click(object sender, RoutedEventArgs e)
        {
            string name     = nameTxt.Text.Trim();
            string password = passwordTxt.Password.Trim();

            if (name == "")
            {
                errorLbl.Text = "Please fill name!";
            }
            else if (password == "")
            {
                errorLbl.Text = "Please fill password!";
            }
            else
            {
                EmployeeMediator mediator = new EmployeeMediator();
                Employee         employee = mediator.getEmployee(name, password);

                if (name == "customer" && password == "customer123")
                {
                    this.Visibility = Visibility.Hidden;
                    CustomerView cview          = new CustomerView();
                    Session.getSession().window = cview;
                    cview.Show();
                }
                else if (employee == null)
                {
                    errorLbl.Text = "Name/Password is incorrect";
                }
                else
                {
                    Session.getSession().employee = employee;

                    Window[] views = new Window[] { new AttractionDView(), new MaintenanceDView(), new RaACreativeDView(), new ConstructionDView(), new DiningRDView(),
                                                    new KitchenDView(), new PurchasingDView(), new AccountingFDView(), new FrontOfficeDView(), new HouseKeepingDView(),
                                                    new SalesMDView(), new HRDView(), new ManagerView() };

                    this.Visibility = Visibility.Hidden;
                    int departmentID            = (int)employee.departmentID - 1;
                    Session.getSession().window = views[departmentID];
                    views[departmentID].Show();
                }
            }
        }
 private void OpenCust()
 {
     CurrentCustomer = new CustomerModel();
     CV = new CustomerView();
     CV.Show();
 }
Пример #10
0
        static void Main(string[] args)
        {
            IView customerList = new CustomerListView();
            IView customerView = null;

            while (customerView == null)
            {
                customerList.Show();
                Console.WriteLine("\nAre you a new customer?\nPress 1 if yes, otherwise press 2.");
                int response = Console.ReadLine().ToInt(-1);
                Console.Clear();

                if (response == 1)
                {
                    Customer customer = new Customer();

                    customer.Id = GenerateID.GetGeneratedID();
                    Console.WriteLine("Enter your first name:");
                    customer.FirstName = Console.ReadLine();
                    Console.WriteLine("Enter your Middle name:");
                    customer.MiddleName = Console.ReadLine();
                    Console.WriteLine("Enter your Last name:");
                    customer.LastName = Console.ReadLine();
                    Console.WriteLine("Enter your gender 'M' - Male, 'F' - Female:");
                    customer.Gender = Console.ReadLine();
                    Console.WriteLine("Enter your contact no.");
                    customer.ContactNo = Console.ReadLine();
                    Console.WriteLine("Enter your email address:");
                    customer.Email = Console.ReadLine();
                    Console.WriteLine("Enter your current address");
                    customer.Address = Console.ReadLine();

                    customerView = new CustomerView(customer);

                    if (((CustomerView)customerView).CustomerManager.Add(customer))
                    {
                        Console.WriteLine("Member succesfully added! See details below.");
                        customerView.Show();
                    }
                    else
                    {
                        Console.WriteLine("Member can't be added.");
                        customerView = null;
                    }
                }
                else if (response == 2)
                {
                    Console.WriteLine("Enter your Id.");
                    Customer customer = ((CustomerListView)customerList).Manager.GetById(Console.ReadLine().ToInt(-1), "Id");
                    if (customer == null)
                    {
                        Console.WriteLine($"Entered Id can't be found!");
                    }
                    else
                    {
                        customerView = new CustomerView(customer);
                    }
                }
                else
                {
                    Console.WriteLine("Response not recognize. Please try again.");
                }
            }

            while (true)
            {
                Console.WriteLine($"\nHello {((CustomerView)customerView).Customer.Info.FirstName}! What would you like to do?");
                Console.WriteLine("Press 1 to show your order history. Press 2 to shop! Press 3 to exit.\n");
                int response = Console.ReadLine().ToInt(-1);

                Console.Clear();

                if (response == 1)
                {
                    customerView.Show();
                }
                else if (response == 2)
                {
                    IView           cartView        = null;
                    bool            doneShopping    = false;
                    PurchaseHistory purchaseHistory = ((CustomerView)customerView).Customer.PurchaseHistory.Find(x => x.Purchase.Status == "Pending");
                    Purchase        purchase;

                    if (purchaseHistory == null)
                    {
                        purchase = new Purchase(GenerateID.GetGeneratedID(), ((CustomerView)customerView).Customer.Info.Id,
                                                "Pending", DateTime.Now.ToString(), 0);

                        if (((CustomerView)customerView).PurchaseManager.Add(purchase))
                        {
                            Console.WriteLine("New purchase. Add items to your cart.");
                            ((CustomerView)customerView).Customer.PurchaseHistory.Add(new PurchaseHistory(purchase));
                            cartView = new CartView(new List <PurchaseDetails>(), purchase.Id);
                        }
                        else
                        {
                            Console.WriteLine("Can't create new purchase. Please try again.");
                            doneShopping = true;
                        }
                    }
                    else
                    {
                        purchase = purchaseHistory.Purchase;
                        Console.WriteLine("You have a pending purchase. Restoring.");
                        cartView = new CartView(purchaseHistory.PurchaseDetails, purchaseHistory.Purchase.Id);
                    }

                    IView groceriesView = new GroceriesView();

                    while (!doneShopping)
                    {
                        Console.WriteLine("Press 1 to add an item, 2 to change the quantity of an item, " +
                                          "3 to show your cart, and 4 to check out, 5 to exit.\n");
                        groceriesView.Show();
                        Console.WriteLine();

                        int input;

                        input = Console.ReadLine().ToInt(0);
                        Actions action = (Actions)input;

                        Console.Clear();

                        switch (action)
                        {
                        case Actions.ADD_ITEM:
                        {
                            Console.WriteLine("Enter the barcode of an item");
                            Item item = ((GroceriesView)groceriesView).Manager.GetById(Console.ReadLine().ToInt(-1), "Id");

                            if (item == null)
                            {
                                Console.WriteLine("Item can't be found.");
                            }
                            else
                            {
                                ((CartView)cartView).AddItem(item);
                            }

                            break;
                        }

                        case Actions.CHANGE_QUANTITY:
                        {
                            Console.WriteLine("Enter the barcode of an item to change quantity.");
                            int id = Console.ReadLine().ToInt(-1);

                            Item item = null;

                            try
                            {
                                item = ((CartView)cartView).Purchases.Find(x => x.PurchaseItem.ItemId == id).Item;
                            }
                            catch (Exception ex)
                            {
                                Logging.log.Error(ex);
                            }

                            if (item != null)
                            {
                                Console.WriteLine("Enter the new quantity of the item");
                                int quantity = Console.ReadLine().ToInt(-1);

                                if (quantity == -1)
                                {
                                    Console.WriteLine("Can't change quantity for that value");
                                }
                                else
                                {
                                    ((CartView)cartView).ChangeQuantity(item, quantity);
                                }
                            }
                            else
                            {
                                Console.WriteLine("Entered item can't be found!");
                            }

                            break;
                        }

                        case Actions.SHOW_CART:
                        {
                            cartView.Show();
                            break;
                        }

                        case Actions.CHECK_OUT:
                        {
                            using (TransactionScope scope = new TransactionScope())
                            {
                                float total = ((CartView)cartView).ComputeTotalPrice();
                                purchase.Status = "Purchased";
                                purchase.Date   = DateTime.Now.ToString();
                                purchase.Total  = total;

                                if (((CustomerView)customerView).PurchaseManager.Update(purchase))
                                {
                                    Console.WriteLine("Thank you. Please come again.");
                                    doneShopping = true;
                                }
                                else
                                {
                                    Console.WriteLine("Can't proceed to check out. Please try again.");
                                    break;
                                }

                                scope.Complete();
                            }

                            break;
                        }

                        case Actions.EXIT:
                        {
                            doneShopping = true;
                            break;
                        }

                        default:
                        {
                            Console.WriteLine("Action not recognize. Try again.");
                            break;
                        }
                        }
                    }
                }
                else if (response == 3)
                {
                    break;
                }
                else
                {
                    Console.WriteLine("Response not recognize. Please try again.");
                }
            }
        }
Пример #11
0
 private void MergeSelectedCustomer()
 {
     CustomerView cv = new CustomerView();
     cv.DataContext = new CustomerViewModel(SelectedCustomer.CustomerId, CustomerTemp);
     cv.Show();
     using (dbContext db = new dbContext())
     {
         var temp = db.CustomerTemp.SingleOrDefault(item => item.CustomerTempId == CustomerTemp.CustomerTempId);
         db.CustomerTemp.Remove(temp);
         db.SaveChanges();
     }
     Messenger.Default.Send(new NotificationMessage("CloseSimilarCustomerListViewWindow"));
 }
Пример #12
0
        private void GwynButton_Click(object sender, RoutedEventArgs e)
        {
            CustomerView form = new CustomerView();

            form.Show();
        }
Пример #13
0
        public void ShowCustomerViewWindow()
        {
            CustomerView cv = new CustomerView();

            cv.Show();
        }