Beispiel #1
0
        private void Managment_Load(object sender, EventArgs e)
        {
            panel1.Visible          = false;
            panelRestock.Visible    = false;
            panelAddProduct.Visible = false;
            Department transfer;

            //UpdateDataGridView();
            managment.LoadAllFormerEmployees();
            managment.LoadAllEmployees();


            ProductManagment.ProductsSales.AddRange(managment.LoadSalesProds());
            ProductManagment.ProductsDEPOT.AddRange(managment.LoadDepotProds());
            ProductManagment.RequestedProducts.AddRange(managment.LoadRequestedProducts());
            for (int y = 0; y < ProductManagment.RequestedProducts.Count; y++)
            {
                listBox3.Items.Add(ProductManagment.RequestedProducts[y].GetRequestInfo());
            }


            foreach (Employee em in managment.GetAllEmployees().ToList())
            {
                DateTime date1  = em.ContractEnd;
                DateTime date2  = DateTime.Now;
                DateTime date3  = DateTime.Now.AddDays(7);
                int      result = DateTime.Compare(date1, date2);
                if (em.Email == current_email)
                {
                    label1.Text += $", {em.FName} { em.LName}";
                    department   = em.Department;
                    if (em.Positions == "EMPLOYEE")
                    {
                        panelLeftSide.Visible = false;
                        label1.Left           = 20;
                        label1.Text           = "Application is not available for employees,\n but you can see your schedule in our site\n\n www.employeesite.com";
                    }
                    if (em.Department != Department.HUMANRESOURCES)
                    {
                        lblDepartment.Visible = false;
                        cbxDepartment.Visible = false;
                    }
                }
                if (result < 0)
                {
                    managment.AddToFormerEmployees(em.Email, "Contract end");
                    MessageBox.Show($"The contract of {em.FName} {em.LName} ended. He is now added to Former Employees");
                }
                int resultReminder = DateTime.Compare(date1, date3);
                if (resultReminder >= -7 && resultReminder <= 0)
                {
                    MessageBox.Show($"The contract of {em.FName} {em.LName} is about to expire.");
                }
            }
            switch (department)
            {
            case Department.SALES:
                transfer = Department.SALES;
                break;

            case Department.PR:
                transfer = Department.PR;
                break;

            case Department.DEPOT:
                transfer = Department.DEPOT;
                break;

            default:
                transfer = Department.HUMANRESOURCES;
                break;
            }

            schedule = new Schedule(managment.GetAllEmployees(), managment.GetAllNewEmployees(), managment.GetAllFormerEmployees(), transfer);
            UpdateDataGridView();

            if (department != Department.DEPOT)
            {
                btnSearch.Visible  = false;
                btnRestock.Visible = false;
            }

            if (department == Department.HUMANRESOURCES || department == Department.PR)
            {
                btnProducts.Visible = false;
            }


            //dataGridView1.DataSource = managment.GetAllEmployees();
        }