Пример #1
0
        //get the incident by ID
        public ModIncident GetIncidentById(ObjectId objectId)
        {
            //ask DAL for every incident and make objects out of them
            BsonDocument incident    = conn.LoadRecordById <BsonDocument>("Incidents", objectId);
            ModIncident  modIncident = new ModIncident()
            {
                Subject        = incident.GetElement("Subject").Value.ToString(),
                Status         = incident.GetElement("Status").Value.AsInt32,
                Resolved       = incident.GetElement("Resolved").Value.AsBoolean,
                Date           = incident.GetElement("Date").Value.AsDateTime,
                Deadline       = incident.GetElement("Deadline").Value.AsDateTime,
                TypeOfIncident = incident.GetElement("TypeOfIncident").Value.ToString(),
                Id             = incident.GetElement("_id").Value.AsObjectId
            };

            return(modIncident);
        }
Пример #2
0
        //if one of the buttons is pressed open a popup menu
        private void DashDgInc_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            //check which button is pressed
            if (e.ColumnIndex == DashDgInc.Columns["ID"].Index && e.RowIndex >= 0)
            {
                pnlDashPopup.Visible = true;

                //get the information from the pressed button and get that incident
                string      information = DashDgInc.Rows[e.RowIndex].Cells[0].Value + "";
                ModIncident incident    = conEmployeeDashboard.GetIncidentById(ObjectId.Parse(information));

                //fill in the cells with the information
                LblDashPopUpInformation.Text = "Informatie over: " + incident.Subject;
                lblDashPopupSubject.Text     = "Subject: " + incident.Subject;
                lblDashPopupStatus.Text      = "Status: " + incident.Status;

                FillCells(incident.Id);
            }
        }
Пример #3
0
        public List <ModIncident> getIncidents()
        {
            //get the incidents from the database
            var incidentList = db.LoadRecords <BsonDocument>("Incidents");

            List <ModIncident> incidents = new List <ModIncident>();

            //List<BsonDocument> resultList = new List<BsonDocument>();
            foreach (var item in incidentList)
            {
                ObjectId id   = item.GetElement("EmployeeID").Value.AsObjectId;
                var      user = db.LoadRecordById <BsonDocument>("Users", id);

                string name;
                try
                {
                    name = user.GetElement("FirstName").Value.ToString();
                }
                catch
                {
                    name = "Unknown";
                }

                ModIncident incident = new ModIncident()
                {
                    Name           = name,
                    Subject        = item.GetElement("Subject").Value.ToString(),
                    Status         = item.GetElement("Status").Value.AsInt32,
                    Resolved       = item.GetElement("Resolved").Value.AsBoolean,
                    Date           = item.GetElement("Date").Value.AsDateTime,
                    Deadline       = item.GetElement("Deadline").Value.AsDateTime,
                    EmployeeID     = item.GetElement("EmployeeID").Value.AsObjectId,
                    TypeOfIncident = item.GetElement("TypeOfIncident").Value.ToString(),
                    Description    = item.GetElement("Description").Value.ToString(),
                    Id             = item.GetElement("_id").Value.AsObjectId
                };
                incidents.Add(incident);
            }
            return(incidents);
        }
Пример #4
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++;
                    }
                }
            }
        }