Exemple #1
0
        private void getIncidentUser()
        {
            //clear comboBox before filling it
            cmbUser.Items.Clear();
            ConIncident Incident = new ConIncident();
            //get the users
            List <String> users = Incident.getUsers();

            foreach (string item in users)
            {
                //fill the comboBox
                cmbUser.Items.Add(item);
            }
        }
Exemple #2
0
        //method for loading the dashboard
        private void Dashboard()
        {
            ConIncident conIncident = new ConIncident();

            //get the list from the controller layer with incidents
            List <ModIncident> incidents = conIncident.getIncidents();

            //clear comboBox before filling it
            DashDgInc.Rows.Clear();
            //give it a pretty font
            DashDgInc.Font = new Font("Lato Light", 12, FontStyle.Regular);
            DashDgInc.RowTemplate.Height = 30;

            //get the Id of the logged in user
            ObjectId userId = conSession.GetId();

            //foreach incident, check if the incident was reported by the currently logged in employee
            foreach (ModIncident item in incidents)
            {
                if (item.EmployeeID == userId)
                {
                    DashDgInc.Rows.Add(item.Id.ToString(), item.Subject, item.TypeOfIncident, item.Date.ToString("yyyy/MM/dd"), item.Deadline.ToString("yyyy/MM/dd"), item.Status + "%");
                }
            }

            //foreach row, look if the status is 100% --> make it Green
            //else if the incident has expired, make it red
            //else if the incident deadline is in 3 days, make it orange
            //else, leave it blank
            foreach (DataGridViewRow row in DashDgInc.Rows)
            {
                if (row.Cells[5].Value.ToString() == "100%")
                {
                    row.DefaultCellStyle.BackColor = ColorTranslator.FromHtml("#5eff7e");
                }
                else if (Convert.ToDateTime(row.Cells[4].Value) < DateTime.Now)
                {
                    row.DefaultCellStyle.BackColor = ColorTranslator.FromHtml("#e34040");
                }
                else if ((Convert.ToDateTime(row.Cells[4].Value) - DateTime.Now).Days < 3)
                {
                    row.DefaultCellStyle.BackColor = ColorTranslator.FromHtml("#eba834");
                }
                else
                {
                    row.DefaultCellStyle.BackColor = ColorTranslator.FromHtml("#ffffff");
                }
            }
        }
Exemple #3
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            ConIncident Incident = new ConIncident();
            //check if all the fields are filled
            bool check = Incident.checkFields(cmbDateTime.Text, txtSubject.Text, cmbType.Text, cmbUser.Text, cmbPriority.Text, cmbDeadline.Text, txtDescription.Text);

            if (check == false)
            {
                lblFalse.Text = "Please fill in al the information";
            }
            else
            {
                //insert incident into database
                Incident.insertIncident(cmbDateTime.Text, txtSubject.Text, cmbType.Text, cmbUser.Text, cmbPriority.Text, cmbDeadline.Text, txtDescription.Text);
                btnIncident.PerformClick();
            }
        }
Exemple #4
0
        private void btnUpgrade_Click(object sender, EventArgs e)
        {
            ConIncident Incident = new ConIncident();

            //check if the comment is filled
            if (string.IsNullOrWhiteSpace(txtUpComment.Text))
            {
                lblNoComment.Text = "Please enter a comment";
            }
            else
            {
                //upgrade the status
                Incident.UpgradeStatus(int.Parse(UpDownStatus.Value.ToString()), lblUpID.Text);
                //add comment into database
                Incident.SetComment("Comments", txtUpComment.Text, lblUpID.Text);
                pnlUpgrade.Hide();
                getAllIncidents(false);
            }
        }
Exemple #5
0
        private void getAllIncidents(bool onlyResolved)
        {
            //First clear the listview
            incidentsList.Clear();
            listIncidents.Items.Clear();
            listResolvedIncidents.Items.Clear();
            ConIncident incident = new ConIncident();
            //Get all the incidents
            List <ModIncident> incidents = incident.getIncidents();
            int id = 1;

            foreach (ModIncident item in incidents)
            {
                if (onlyResolved == false)
                {
                    ModIncident mod = new ModIncident {
                        ID = id, Subject = item.Subject, Name = item.Name, Date = item.Date, Deadline = item.Deadline, Status = item.Status, TypeOfIncident = item.TypeOfIncident, Description = item.Description
                    };
                    ListViewItem list = new ListViewItem(new[] { id.ToString(), item.Subject, item.Name, item.Date.Date.ToString("d"), item.Deadline.Date.ToString("d"), item.Status.ToString(), item.TypeOfIncident, item.Description, item.Id.ToString() });
                    //Fill the Masterlist
                    incidentsList.Add(mod);
                    //Fill the listview
                    listIncidents.Items.Add(list);
                    id++;
                }
                else if (onlyResolved == true)
                {
                    if (item.Status == 100)
                    {
                        ListViewItem list = new ListViewItem(new[] { id.ToString(), item.Subject, item.Name, item.Date.Date.ToString("d"), item.Deadline.Date.ToString("d"), item.Status.ToString(), item.TypeOfIncident });
                        //Fill the listview
                        listResolvedIncidents.Items.Add(list);
                        id++;
                    }
                }
            }
        }