private void bttnSearchworker_Click(object sender, EventArgs e)
        {
            lvWokerView.Items.Clear();

            if (rbEmployee.Checked)
            {
                Populateemployees(Worker.GetAllEmployees());
            }
            else if (rbManager.Checked)
            {
                PopulateManagers(Worker.GetAllManagers());
            }
            else if (rbAll.Checked)
            {
                PopulateManagers(Worker.GetAllManagers());
                Populateemployees(Worker.GetAllEmployees());
            }
            tbLname.Clear();
            tbFname.Clear();
            rbMorningshift.Checked   = false;
            rbAfternoonShift.Checked = false;
            rbEveningShift.Checked   = false;
            rbMonday.Checked         = false;
            rbTuesday.Checked        = false;
            rbWednesday.Checked      = false;
            rbThrusday.Checked       = false;
            rbFriday.Checked         = false;
            rbSaturday.Checked       = false;
            rbSunday.Checked         = false;
        }
Exemple #2
0
        private void deleteBtn_Click(object sender, EventArgs e)
        {
            if (lbRuleList.SelectedIndex == -1)
            {
                MessageBox.Show("Select a rule");
            }
            else
            {
                if (MessageBox.Show("Do you really want to delete this rule?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    string ruleText = lbRuleList.SelectedItem.ToString();
                    string ruleId   = ruleText.Substring(0, ruleText.IndexOf("-"));
                    Rules.RemoveRule(Convert.ToInt32(ruleId));
                    try
                    {
                        foreach (Worker w in Worker.GetAllEmployees())
                        {
                            MailMessage mail       = new MailMessage();
                            SmtpClient  SmtpServer = new SmtpClient("smtp.gmail.com");

                            mail.From = new MailAddress("*****@*****.**");
                            mail.To.Add(w.Email);
                            mail.Subject = "Rule Changed!";
                            mail.Body    = "Hey a rule was deleted from the list! Go and check it out: <link here>.";

                            SmtpServer.Port        = SmtpServerPort;
                            SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "MediaBazaar!Test123");
                            SmtpServer.EnableSsl   = true;

                            SmtpServer.Send(mail);
                        }
                        MessageBox.Show("Rules updated and mail sent!");
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                    UpdateForm();
                }
            }
        }
Exemple #3
0
        private void AddRulebtn_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(tbDescription.Text))
            {
                MessageBox.Show("Description is empty");
            }
            else
            {
                Rules newRule = new Rules(tbDescription.Text, createdBy);

                try
                {
                    foreach (Worker w in Worker.GetAllEmployees())
                    {
                        MailMessage mail       = new MailMessage();
                        SmtpClient  SmtpServer = new SmtpClient("smtp.gmail.com");

                        mail.From = new MailAddress("*****@*****.**");
                        mail.To.Add(w.Email);
                        mail.Subject = "Rule Changed!";
                        mail.Body    = "Hey there is a new rule added to the list! Go and check it out: <link here>.";

                        SmtpServer.Port        = SmtpServerPort;
                        SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "MediaBazaar!Test123");
                        SmtpServer.EnableSsl   = true;

                        SmtpServer.Send(mail);
                    }
                    MessageBox.Show("Rules updated and mail sent!");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }

                UpdateForm();
            }
        }
        private void bttnSearchworker_Click(object sender, EventArgs e)
        {
            lvWokerView.Items.Clear();

            if (rbEmployee.Checked)
            {
                Populateemployees(Worker.GetAllEmployees());
            }
            else if (rbManager.Checked)
            {
                PopulateManagers(Worker.GetAllManagers());
            }
            else if (rbAll.Checked)
            {
                PopulateManagers(Worker.GetAllManagers());
                Populateemployees(Worker.GetAllEmployees());
            }
            if (lvWokerView.Items.Count == 0)
            {
                MessageBox.Show("no worker found");
            }
            cbDepartment.Text          = "Department";
            cbDepartment.SelectedIndex = -1;
            tbLname.Clear();
            tbFname.Clear();
            rbMorningshift.Checked   = false;
            rbAfternoonShift.Checked = false;
            rbEveningShift.Checked   = false;
            rbMonday.Checked         = false;
            rbTuesday.Checked        = false;
            rbWednesday.Checked      = false;
            rbThrusday.Checked       = false;
            rbFriday.Checked         = false;
            rbSaturday.Checked       = false;
            rbSunday.Checked         = false;
        }
        private void LoadPeople()
        {
            List <Worker> people = Worker.GetAllEmployees();

            PopulatePeople(people);
        }