private void btnFinishOrder_Click(object sender, EventArgs e)
        {
            if (_orderdetails.Count != 0)
            {
                Order order = new Order()
                {
                    Date       = DateTime.Now,
                    Status     = false,
                    EmployeeId = currentEmployee.Id
                };
                _context.Orders.Add(order);
                _context.SaveChanges();


                foreach (var item in _orderdetails)
                {
                    item.OrderId = order.Id;
                    _context.OrderDetails.Add(item);
                }
                _context.SaveChanges();
                flpCashier.Controls.Clear();
            }
            else
            {
                MessageBox.Show("Please add products to the order");
            }
        }
        private void btnDeleteCategory_Click(object sender, EventArgs e)
        {
            if (cmbCategoriesforDeletion.SelectedItem == null)
            {
                ShowMessage("Category can not be empty");
                return;
            }

            deletedcategory.Active = false;
            _context.SaveChanges();
            FillComboCategories();
            Close();
        }
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (selectedProduct != null)
     {
         selectedProduct.IsActive = false;
         _context.SaveChanges();
         FillProducts();
         MessageBox.Show("Product Deleted", "Delete", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         ShowMessage("Please select product for deletion");
     }
 }
 private void btnDeleteEmployee_Click(object sender, EventArgs e)
 {
     if (selectedEmployee != null)
     {
         selectedEmployee.ActiveEmp = false;
         _context.SaveChanges();
         FillEmployeees();
         MessageBox.Show("Employee Deleted", "Delete", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         ShowMessage("Please select employee for deletion");
     }
 }
Beispiel #5
0
 private void btnReady_Click(object sender, EventArgs e)
 {
     if (selectedOrder != null)
     {
         selectedOrder.Status = true;
         _context.SaveChanges();
         FillBarristaList();
         MessageBox.Show("Product is Ready", "Delete", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         MessageBox.Show("Please select Order from Pending Orders List");
     }
 }
        private void btnUpdateCategory_Click(object sender, EventArgs e)
        {
            string name = txtUpdateCategory.Text.Trim();

            if (name == "" || updatedCategory == null)
            {
                ShowMessage("Please fill all inputs");
                return;
            }
            updatedCategory.Name = name;
            _context.SaveChanges();
            FillComboCate();

            Close();
        }
Beispiel #7
0
        private void BtnAdd_Click(object sender, EventArgs e)
        {
            string fname    = txtFirstname.Text.Trim();
            string lname    = txtLastname.Text.Trim();
            string username = txtUsername.Text.Trim();
            string password = txtPassword.Text.Trim();
            Role   role     = cmbRoles.SelectedItem as Role;

            if (fname == "" || username == "" || password == "")
            {
                ShowMessage("Firstname or username or password is empty");
                return;
            }

            if (_context.Employees.Any(emp => emp.Username == username))
            {
                ShowMessage("Username exists");
                return;
            }

            if (role == null)
            {
                ShowMessage("Role should be selected");
                return;
            }

            //username doesnt't exist and role selected, so create new employee
            Employee employee = new Employee
            {
                Firstname   = fname,
                Lastname    = lname,
                Username    = username,
                Password    = HashPassword(password),
                RoleId      = role.Id,
                IsFirstTime = true,
                ActiveEmp   = true
            };

            _context.Employees.Add(employee);
            _context.SaveChanges();

            ShowMessage("User successfully selected", error: false);

            Close();
        }
        private void btnLogin_Click(object sender, EventArgs e)
        {
            string username = txtUsername.Text.Trim();
            string newPassword = txtNewPassword.Text.Trim();
            string confirmPassword = txtConfirmPassword.Text.Trim();

            if (username == "" || newPassword == "" || confirmPassword == "")
            {
                ShowMessage("Password or Username cannot be empty");
                return;
            }

            var employee = _context.Employees.FirstOrDefault(em => em.Username == username);

            if (employee == null)
            {
                ShowMessage("Wrong Information");
                return;
            }

            if (confirmPassword != newPassword)
            {
                ShowMessage("Passwords dont match");
                return;
            }

            employee.Password = HashPassword(newPassword);
            employee.IsFirstTime = false;
            MessageBox.Show("Your password is successfully changed");
            _context.SaveChanges();
            if (employee.Role.Name == "Barista")
            {
                MessageBox.Show("Hello Barista");
                (new Barista()).ShowDialog();
            }
            else if (employee.Role.Name == "Cashier")
            {
                MessageBox.Show("Hello Cashier");
                (new Cashier(employee)).ShowDialog();
                
            }
        }
Beispiel #9
0
        private void btnUpdateProduct_Click(object sender, EventArgs e)
        {
            if (nupPrice.Value > 0 && txtName.Text != "" && cmbCategory.SelectedItem != null)
            {
                selectedProduct.Name  = txtName.Text.Trim();
                selectedProduct.Price = nupPrice.Value;

                string   productName = cmbCategory.SelectedItem.ToString();
                Category categoryofp = _context.Categories.FirstOrDefault(c => c.Name == productName);

                selectedProduct.CategoryId = categoryofp.Id;
                _context.SaveChanges();
                FillProducts();
            }
            else
            {
                ShowMessage("Please fill all inputs");
                return;
            }
        }