コード例 #1
0
        private void btnEmployeeMenu_Click(object sender, EventArgs e)
        {
            tabControlManager.SelectTab(tpEmpl);

            //Load all employees in the listview
            uc.ExtractAllUsers();
            UpdateListView();
            if (lvEmployee.Items.Count == 0)
            {
                CustomMessageBoxController.ShowMessage("No employees found!", MessageBoxButtons.OK);
            }
            if (searchEmpl.text != "Search by name")
            {
                searchEmpl.text = "Search by name";
            }

            //Load departments in combobox
            LoadDepartmentsInComboBox();
            //cmxCategoryEmpl.Clear();
            //foreach (var item in stController.GetAllDepartments())
            //{
            //    cmxCategoryEmpl.AddItem(item);
            //}

            editPanelUser.Visible    = false;
            lvEmployee.Enabled       = true;
            lvEmployee.HideSelection = true;
        }
コード例 #2
0
        private void btnSavePr_Click(object sender, EventArgs e)
        {
            if (sc.EditStock(stockID, bunifuDropdownEditProductDepartment.selectedValue))
            {
                CustomMessageBoxController.ShowMessage($"Department of {sc.GetStock(stockID).Name} successfully updated!", MessageBoxButtons.OK);
                uc.ExtractAllUsers();
                UpdateListView();
            }
            else
            {
                CustomMessageBoxController.ShowMessage("Failed to update department!", MessageBoxButtons.OK);
            }
            editPanelUser.Visible    = false;
            panelEditProduct.Visible = false;

            //if (uc.EditUser(currentID, bunifuDropdownEditDepartment.selectedValue))
            //{
            //    CustomMessageBoxController.ShowMessage($"Department of employee {currentID} successfully updated!", MessageBoxButtons.OK);
            //    uc.ExtractAllUsers();
            //    UpdateListView();
            //}
            //else
            //{
            //    CustomMessageBoxController.ShowMessage("Failed to update department!", MessageBoxButtons.OK);
            //}
            //editPanelUser.Visible = false;
        }
コード例 #3
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (currentID != 0)
            {
                panelAddUser.Visible       = true;
                lblCurrPage.Text           = "Edit user";
                btnReset.Visible           = false;
                btnConfirmAdd.Visible      = false;
                btnUpdate.Visible          = true;
                btnClosePopUpPanel.Visible = true;
                //LoadDepartmentsInDropDown();
                RefillDropDownLists();
                EnableFieldInput();
                DisplayUserInfo();

                //Availability:
                if (userToEdit.Role == Role.EMPLOYEE)
                {
                    LoadAvailability();
                    EnableAvailabilitySwitchers();
                }
                else
                {
                    SwitchOffAvailability();
                    DisableAvailabilitySwitchers();
                }
            }
            else
            {
                CustomMessageBoxController.ShowMessage("Choose a user to edit first!", MessageBoxButtons.OK);
            }
        }
コード例 #4
0
        private void cmbDepartments_onItemSelected(object sender, EventArgs e)
        {
            //TODO add up to three values to compare


            try
            {
                if (chartEmplPerDept.Series["empPerDept"].Points.Count() < 3)
                {
                    chartEmplPerDept.Series["empPerDept"].Points.AddXY(cmbDepartments.selectedValue,
                                                                       stController.GetEmployeesInDepartment(cmbDepartments.selectedValue));
                    cmbDepartments.RemoveAt(cmbDepartments.selectedIndex);
                }
                else
                {
                    CustomMessageBoxController.ShowMessage("You can compare up to three items.", MessageBoxButtons.OK);
                    chartEmplPerDept.Series["empPerDept"].Points.Clear();
                    FillItemsEmployeeStatisctics();
                }
            }
            catch
            {
                CustomMessageBoxController.ShowMessage("No statistics are available for this department.", MessageBoxButtons.OK);
            }
        }
コード例 #5
0
 private void lvEmployee_MouseDoubleClick(object sender, MouseEventArgs e)
 {
     if (currentID != 0)
     {
         lblCurrPage.Text = $"View user information";
         RefillDropDownLists();
         DisplayUserInfo();
         DisableFieldInput();
         btnReset.Visible      = false;
         btnConfirmAdd.Visible = false;
         btnUpdate.Visible     = false;
         panelAddUser.Visible  = true;
         //Availability:
         if (uc.GetUser(currentID).Role == Role.EMPLOYEE)
         {
             try
             {
                 LoadAvailability();
             }
             catch (Exception ex)
             {
                 CustomMessageBoxController.ShowMessage(ex.Message, MessageBoxButtons.OK);
             }
         }
         else
         {
             SwitchOffAvailability();
         }
         DisableAvailabilitySwitchers();
     }
     else
     {
         CustomMessageBoxController.ShowMessage("Choose a user to edit first!", MessageBoxButtons.OK);
     }
 }
コード例 #6
0
 private void btnLogIn_Click(object sender, EventArgs e)
 {
     //Login
     if (uc.Login(tbUsername.text, tbPassword.text))
     {
         uc.ExtractAllUsers();
         int id = uc.GetCurrentUserId();
         if (uc.GetUser(id).Role == Role.ADMINISTRATOR)
         {
             Form formAdmin = new FormAdmin(this.FindForm(), id);
             RememberMe();
             this.Hide();
             formAdmin.ShowDialog();
             this.Show();
         }
         else if (uc.GetUser(id).Role == Role.MANAGER)
         {
             Form formManager = new FormManager(id);
             RememberMe();
             this.Hide();
             formManager.ShowDialog();
             this.Show();
         }
         else
         {
             CustomMessageBoxController.ShowMessage("Employees should log in via the website.", MessageBoxButtons.OK);
         }
     }
     else
     {
         CustomMessageBoxController.ShowMessage("Invalid credentials. Please try again.", MessageBoxButtons.OK);
     }
 }
コード例 #7
0
        private void btnSaveShift_Click(object sender, EventArgs e)
        {
            pnlAddShift.Visible = false;
            string[] text     = cmxAvailableEmpl.selectedValue.Split(':');
            int      id       = int.Parse(text[0]);
            Shift    newShift = new Shift(0, (Time)cmxShift.selectedIndex, datepicker.selectedIndex);

            newShift.Users.Add(uc.GetUser(id));
            scController.SaveShift(newShift, uc.GetUser(id));
            CustomMessageBoxController.ShowMessage("Shift Added!", MessageBoxButtons.OK);
        }
コード例 #8
0
 private void btnRequestStock_Click(object sender, EventArgs e)
 {
     if (stockID == 0)
     {
         CustomMessageBoxController.ShowMessage("Choose a stock to edit first!", MessageBoxButtons.OK);
     }
     else
     {
         sc.RequestStock(stockID);
         CustomMessageBoxController.ShowMessage("Stock successfully requested!", MessageBoxButtons.OK);
     }
 }
コード例 #9
0
 private void btnDeleteStock_Click(object sender, EventArgs e)
 {
     try
     {
         sc.DeleteStock(stockID);
         CustomMessageBoxController.ShowMessage("Stock is deleted!", MessageBoxButtons.OK);
     }
     catch (Exception)
     {
         CustomMessageBoxController.ShowMessage("Failed to delete stock!", MessageBoxButtons.OK);
     }
     UpdateListView();
 }
コード例 #10
0
 private void brnSaveUser_Click(object sender, EventArgs e)
 {
     if (uc.EditUser(currentID, bunifuDropdownEditDepartment.selectedValue))
     {
         CustomMessageBoxController.ShowMessage($"Department of employee {currentID} successfully updated!", MessageBoxButtons.OK);
         uc.ExtractAllUsers();
         UpdateListView();
     }
     else
     {
         CustomMessageBoxController.ShowMessage("Failed to update department!", MessageBoxButtons.OK);
     }
     editPanelUser.Visible = false;
 }
コード例 #11
0
 private void LoadAvailability()
 {
     try
     {
         switchMonday.Value    = uc.isAvailable(currentID, 0);
         switchTuesday.Value   = uc.isAvailable(currentID, 1);
         switchWednesday.Value = uc.isAvailable(currentID, 2);
         switchThursday.Value  = uc.isAvailable(currentID, 3);
         switchFriday.Value    = uc.isAvailable(currentID, 4);
         switchSaturday.Value  = uc.isAvailable(currentID, 5);
     }
     catch (Exception ex)
     {
         CustomMessageBoxController.ShowMessage(ex.Message, MessageBoxButtons.OK);
     }
 }
コード例 #12
0
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     if (BlankFieldsExist())
     {
         CustomMessageBoxController.ShowMessage("All fields are obligatory!", MessageBoxButtons.OK);
     }
     else
     {
         if (UsernameExists())
         {
             CustomMessageBoxController.ShowMessage("This username already exists!", MessageBoxButtons.OK);
         }
         else
         {
             PrepareValues();
             Role defaultRole = uc.GetUser(currentID).Role;
             if (uc.EditUser(currentID, tbAddFirstName.Text, tbAddLastName.Text, dOb, tbAddAddress.Text, gender, tbAddPhone.Text, dOs, tbAddUsername.Text, tbAddPassword.Text,
                             tbAddEmail.Text, Convert.ToDouble(tbAddSalary.Text), role, 1, departmentName))
             {
                 try
                 {
                     if (defaultRole == selectedRole && selectedRole == Role.EMPLOYEE)
                     {
                         uc.EditUserAvailability(currentID, switchMonday.Value, switchTuesday.Value, switchWednesday.Value, switchThursday.Value, switchFriday.Value,
                                                 switchSaturday.Value);
                     }
                     else if (defaultRole != selectedRole && defaultRole == Role.EMPLOYEE)
                     {
                         uc.DeleteUserAvailability(currentID);
                     }
                     else if (defaultRole != selectedRole && selectedRole == Role.EMPLOYEE)
                     {
                         uc.AddUserAvailability(currentID, switchMonday.Value, switchTuesday.Value, switchWednesday.Value, switchThursday.Value, switchFriday.Value,
                                                switchSaturday.Value);
                     }
                     CustomMessageBoxController.ShowMessage($"User with ID: { currentID} is successfully updated!", MessageBoxButtons.OK);
                 }
                 catch (Exception ex)
                 { CustomMessageBoxController.ShowMessage(ex.Message, MessageBoxButtons.OK); }
             }
             else
             {
                 CustomMessageBoxController.ShowMessage("Failed to update user!", MessageBoxButtons.OK);
             }
         }
     }
 }
コード例 #13
0
        private void LoadRequests()
        {
            List <ShiftRequest> top5 = new List <ShiftRequest>();

            if (counterViewMore > 0)
            {
                top5 = rc.LoadShiftRequests().Skip(counterViewMore * 5).Take(5).ToList();
                if (top5.Count == 0)
                {
                    counterViewMore--;
                    CustomMessageBoxController.ShowMessage("No more requests!", MessageBoxButtons.OK);
                    return;
                }
            }
            else if (counterViewMore < 0)
            {
                counterViewMore++;
                CustomMessageBoxController.ShowMessage("No previous pages!", MessageBoxButtons.OK);
                return;
            }
            else
            {
                top5 = rc.LoadShiftRequests().Take(5).ToList();
            }

            if (top5.Count > 0)
            {
                linkLabel1.Visible = true;
                linkLabel2.Visible = true;
                GetAllLabels();
                ClearShiftRequestsLabels();
                displayedRequestsIDs.Clear();
                for (int i = 0; i < top5.Count; i++)
                {
                    displayedRequestsIDs.Add(top5[i].RequestID);
                    GetNameLabel(i + 1).Text    = top5[i].ShowIdName();
                    GetRequestLabel(i + 1).Text = top5[i].ToString();
                }
            }
            else
            {
                lblEmpIdNameReq1.Text = "No requests";
                linkLabel1.Visible    = false;
                linkLabel2.Visible    = false;
            }
        }
コード例 #14
0
        private void btnConfirmAddProduct_Click_1(object sender, EventArgs e)
        {
            panelAddProduct.Visible = false;

            try
            {
                if (btnConfirmAddProduct.ButtonText == "Add")
                {
                    if (sc.AddStock(tbName.Text, tbDescription.Text, Convert.ToDouble(tbTotalPrice.Text), Convert.ToDouble(tbSupplyCost.Text), datePicker.Value.Date,
                                    Convert.ToInt32(tbQuantity.Text), Convert.ToInt32(tbTotalSales.Text), Convert.ToInt32(tbRestockQuantity.Text), swRequested.Value,
                                    dc.GetDepartmentId(ddDepartment.selectedIndex + 1)))
                    {
                        CustomMessageBoxController.ShowMessage("New product successfully added!", MessageBoxButtons.OK);
                    }
                    else
                    {
                        CustomMessageBoxController.ShowMessage("Failed to add product!", MessageBoxButtons.OK);
                    }
                }
                else
                {
                    if (sc.EditStock(stockID, tbName.Text, tbDescription.Text, Convert.ToDouble(tbTotalPrice.Text), Convert.ToDouble(tbSupplyCost.Text), datePicker.Value.Date,
                                     Convert.ToInt32(tbQuantity.Text), Convert.ToInt32(tbTotalSales.Text), Convert.ToInt32(tbRestockQuantity.Text), swRequested.Value,
                                     dc.GetDepartmentId(ddDepartment.selectedIndex + 1)))
                    {
                        CustomMessageBoxController.ShowMessage("Product successfully edited!", MessageBoxButtons.OK);
                    }
                    else
                    {
                        CustomMessageBoxController.ShowMessage("Failed to edit product!", MessageBoxButtons.OK);
                    }
                }
            }
            catch (Exception)
            {
                CustomMessageBoxController.ShowMessage("Something went wrong.", MessageBoxButtons.OK);
            }
            finally
            {
                UpdateListView();
                ResetAddProductInput();
                HideAddProduct();
            }
        }
コード例 #15
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (currentID != 0)
     {
         if (currentID != loggedUserId)
         {
             CustomMessageBoxController.ShowMessage($"Deleted user: {uc.DeleteUser(currentID)}", MessageBoxButtons.OK);
             UpdateListView();
         }
         else
         {
             CustomMessageBoxController.ShowMessage("You cannot delete yourself, please log in from different account to proceed.", MessageBoxButtons.OK);
         }
     }
     else
     {
         CustomMessageBoxController.ShowMessage("Choose a user to delete first!", MessageBoxButtons.OK);
     }
 }
コード例 #16
0
 private void btnEditStock_Click(object sender, EventArgs e)
 {
     bunifuDropdownEditProductDepartment.Clear();
     if (stockID == 0)
     {
         CustomMessageBoxController.ShowMessage("Choose a stock to edit first!", MessageBoxButtons.OK);
     }
     else
     {
         tbEditProductName.Text = sc.GetStock(stockID).Name;
         foreach (var item in stController.GetAllDepartments())
         {
             bunifuDropdownEditProductDepartment.AddItem(item);
         }
         //bunifuDropdownEditProductDepartment.selectedIndex = Convert.ToInt32(sc.GetStock(stockID).Department.Id) - 1;
         bunifuDropdownEditProductDepartment.selectedIndex = sc.GetStock(stockID).Department.Id - 1;
         panelEditProduct.Visible = true;
     }
 }
コード例 #17
0
 private void btnDeleteDept_Click(object sender, EventArgs e)
 {
     if (cmxDeleteDepartment.selectedIndex != -1)
     {
         if (dc.DeleteDepartment(cmxDeleteDepartment.selectedValue))
         {
             CustomMessageBoxController.ShowMessage("The department was deleted successfully!", MessageBoxButtons.OK);
             pnlDeleteDept.Visible = false;
             lbxAllDepartments.Items.Remove(cmxDeleteDepartment.selectedValue);
         }
         else
         {
             CustomMessageBoxController.ShowMessage("The delete was unsuccessful.", MessageBoxButtons.OK);
         }
     }
     else
     {
         CustomMessageBoxController.ShowMessage("Please select a department to delete.", MessageBoxButtons.OK);
     }
 }
コード例 #18
0
 private void ApproveRequest(ShiftRequest approvedRequest)
 {
     if (approvedRequest != null)
     {
         bool isApproved = rc.Approve(approvedRequest);
         if (isApproved)
         {
             LoadRequests();
             CustomMessageBoxController.ShowMessage("Request is approved!", MessageBoxButtons.OK);
         }
         else
         {
             CustomMessageBoxController.ShowMessage("Could not approve request!", MessageBoxButtons.OK);
         }
     }
     else
     {
         CustomMessageBoxController.ShowMessage("There is no request to approve!", MessageBoxButtons.OK);
     }
 }
コード例 #19
0
 private void btnEdit_Click(object sender, EventArgs e)
 {
     if (currentID == 0)
     {
         CustomMessageBoxController.ShowMessage("Choose an employee to edit first!", MessageBoxButtons.OK);
     }
     else
     {
         //Load departments in combobox
         bunifuDropdownEditDepartment.Clear();
         foreach (string depName in stController.GetAllDepartments())
         {
             bunifuDropdownEditDepartment.AddItem(depName);
         }
         editPanelUser.Visible = true;
         tbEditName.Text       = uc.GetUser(currentID).FirstName + " " + uc.GetUser(currentID).LastName;
         //bunifuDropdownEditDepartment.selectedIndex = Convert.ToInt32(uc.GetUser(currentID).Department);
         bunifuDropdownEditDepartment.selectedIndex = stController.GetAllDepartments().IndexOf(uc.GetUser(currentID).Dep.DptName);
         tbEditName.Enabled = false;
     }
 }
コード例 #20
0
        private void btnEmployeeMenu_Click(object sender, EventArgs e)
        {
            tabControlAdmin.SelectTab(tpEmployees);
            currentID = 0;

            uc.ExtractAllUsers();
            UpdateListView();
            if (lvEmployee.Items.Count == 0)
            {
                CustomMessageBoxController.ShowMessage("No employees found!", MessageBoxButtons.OK);
            }
            if (searchBar.text != "Search by name")
            {
                searchBar.text = "Search by name";
            }

            searchBar.Enabled        = true;
            panelAddUser.Visible     = false;
            lvEmployee.Enabled       = true;
            lvEmployee.HideSelection = true;
        }
コード例 #21
0
 private void btnSaveEditDepartment_Click(object sender, EventArgs e)
 {
     if (!String.IsNullOrWhiteSpace(tbEditNameDept.Text) && cmxDepartmentsEdit.selectedIndex != -1)
     {
         if (dc.EditDepartment(cmxDepartmentsEdit.selectedValue, tbEditNameDept.Text))
         {
             CustomMessageBoxController.ShowMessage("The department is updated successfully!", MessageBoxButtons.OK);
             pnlEditDept.Visible = false;
             lbxAllDepartments.Items.Clear();
             lbxAllDepartments.Items.AddRange(dc.GetAllDepartments().ToArray());
         }
         else
         {
             CustomMessageBoxController.ShowMessage("The update was unsuccessful.", MessageBoxButtons.OK);
         }
     }
     else
     {
         CustomMessageBoxController.ShowMessage("Please fill out all fields.", MessageBoxButtons.OK);
     }
 }
コード例 #22
0
 private void btnSaveNewDepartment_Click(object sender, EventArgs e)
 {
     if (!String.IsNullOrWhiteSpace(tbAddDepartment.Text))
     {
         if (dc.AddDepartment(tbAddDepartment.Text))
         {
             CustomMessageBoxController.ShowMessage("New department is added successfully!", MessageBoxButtons.OK);
             pnlAddDepartment.Visible = false;
             lbxAllDepartments.Items.Add(tbAddDepartment.Text);
         }
         else
         {
             CustomMessageBoxController.ShowMessage("A department with this name already exists.", MessageBoxButtons.OK);
             tbAddDepartment.Text = "";
         }
     }
     else
     {
         CustomMessageBoxController.ShowMessage("Please fill out the new name of the department", MessageBoxButtons.OK);
     }
 }
コード例 #23
0
 private void btnConfirmAdd_Click(object sender, EventArgs e)
 {
     if (BlankFieldsExist())
     {
         CustomMessageBoxController.ShowMessage("All fields are obligatory!", MessageBoxButtons.OK);
     }
     else
     {
         if (UsernameExists())
         {
             CustomMessageBoxController.ShowMessage("This username already exists! Update fail!", MessageBoxButtons.OK);
         }
         else
         {
             PrepareValues();
             if (uc.AddNewUser(tbAddFirstName.Text, tbAddLastName.Text, dOb, tbAddAddress.Text, gender, tbAddPhone.Text, dOs, tbAddUsername.Text, tbAddPassword.Text, tbAddEmail.Text, Convert.ToDouble(tbAddSalary.Text), role, 1, departmentName))
             {
                 int id = uc.lastInsertedUserId;
                 UpdateListView();
                 try
                 {
                     if (selectedRole == Role.EMPLOYEE)
                     {
                         uc.AddUserAvailability(id, switchMonday.Value, switchTuesday.Value, switchWednesday.Value, switchThursday.Value, switchFriday.Value, switchSaturday.Value);
                     }
                 }
                 catch (Exception ex)
                 { CustomMessageBoxController.ShowMessage(ex.Message, MessageBoxButtons.OK); }
                 //uc.AddUserPreferences(id, switchMonday.Value, switchTuesday.Value, switchWednesday.Value, switchThursday.Value, switchFriday.Value, switchSaturday.Value);
                 CustomMessageBoxController.ShowMessage("New user successfully added!", MessageBoxButtons.OK);
                 panelAddUser.Visible = false;
             }
             else
             {
                 CustomMessageBoxController.ShowMessage("Sorry, could not add user!", MessageBoxButtons.OK);
             }
         }
         dropdownAddDepartment.Enabled = true;
     }
 }
コード例 #24
0
 private void dropDepartment_onItemSelected(object sender, EventArgs e)
 {
     try
     {
         if (chartMostSold.Series["mostSold"].Points.Count() < 3)
         {
             chartMostSold.Series["mostSold"].Points.AddXY(dropDepartment.selectedValue.Trim(),
                                                           stController.GetMostSoldProduct(dropDepartment.selectedValue));
             dropDepartment.RemoveAt(dropDepartment.selectedIndex);
         }
         else
         {
             CustomMessageBoxController.ShowMessage("You can compare up to three items.", MessageBoxButtons.OK);
             chartMostSold.Series["mostSold"].Points.Clear();
             FillDropDepartmentStatisctics();
         }
     }
     catch
     {
         CustomMessageBoxController.ShowMessage("No statistics are available for this department.", MessageBoxButtons.OK);
     }
 }
コード例 #25
0
 private void RejectRequest(ShiftRequest rejectedRequest)
 {
     if (rejectedRequest != null)
     {
         //DialogResult dialogResult = CustomMessageBoxController.ShowMessage("Are you sure you want to reject this request?", MessageBoxButtons.YesNo);
         if ((CustomMessageBoxController.ShowMessage("Are you sure you want to reject this request?", MessageBoxButtons.YesNo)) == DialogResult.Yes)
         {
             bool isRejected = rc.Reject(rejectedRequest);
             if (isRejected)
             {
                 LoadRequests();
                 CustomMessageBoxController.ShowMessage("Request is rejected!", MessageBoxButtons.OK);
             }
             else
             {
                 CustomMessageBoxController.ShowMessage("Could not reject request!", MessageBoxButtons.OK);
             }
         }
     }
     else
     {
         CustomMessageBoxController.ShowMessage("There is no request to reject!", MessageBoxButtons.OK);
     }
 }