Beispiel #1
0
        public void GetSisFaculty(int FacultyID, int PeriodID)
        {
            try
            {
                using (var db = new LetranIntegratedSystemEntities())
                {
                    SQList   = new List <SisQuestionList>();
                    SEPFList = new List <SisEvaluationPerFacultyList>();

                    var result = db.GetHRiSsisPerFaculty(PeriodID, FacultyID).ToList();
                    if (result.Count > 0)
                    {
                        var sisQuestion = db.sisItems.Where(m => (m.sisCatID == 1 || m.sisCatID == 2 || m.sisCatID == 3) && m.sisItemweight == null).OrderBy(m => m.sisCatID).ToList();

                        int id = 1;
                        foreach (var q in sisQuestion)
                        {
                            SisQuestionList ques = new SisQuestionList();
                            ques.SisQuestionID = id;
                            ques.SisQuestion   = q.sisItem1;
                            ques.SisCategoryID = q.sisCatID.Value;
                            id++;
                            SQList.Add(ques);
                        }

                        foreach (var i in SQList)
                        {
                            SisEvaluationPerFacultyList sis = new SisEvaluationPerFacultyList();
                            sis.FacultyName = result.FirstOrDefault().FacultyName;

                            sis.Department  = db.Employees.Find(db.Faculties.Find(FacultyID).Employee.EmployeeID).AcademicDepartment.AcaDepartmentName;
                            sis.Designation = db.Employees.Find(db.Faculties.Find(FacultyID).Employee.EmployeeID).EmployeeDesignation1.EmployeeDesignationName;
                            sis.Position    = db.Employees.Find(db.Faculties.Find(FacultyID).Employee.EmployeeID).EmployeePosition.EmployeePositionName;
                            sis.Respondents = result.FirstOrDefault().Respondents.Value;

                            if (result.Where(m => m.QuestionNo == i.SisQuestionID.ToString()).Count() > 0)
                            {
                                sis.SisCategoryID       = SQList.Single(m => m.SisQuestionID == i.SisQuestionID).SisCategoryID;
                                sis.QuestionID          = SQList.Single(m => m.SisQuestionID == i.SisQuestionID).SisQuestionID;
                                sis.QuestionDescription = SQList.Single(m => m.SisQuestionID == i.SisQuestionID).SisQuestion;
                                sis.Result = result.Single(m => m.QuestionNo == i.SisQuestionID.ToString()).Result.Value;
                            }

                            SEPFList.Add(sis);
                        }

                        lblInstructor.Content  = SEPFList.FirstOrDefault().FacultyName.ToUpper();
                        lblDepartment.Content  = SEPFList.FirstOrDefault().Department;
                        lblDesignation.Content = SEPFList.FirstOrDefault().Designation;
                        lblPosition.Content    = SEPFList.FirstOrDefault().Position;
                        lblRespondents.Content = SEPFList.FirstOrDefault().Respondents.ToString();


                        double cat1 = Math.Round((SEPFList.Where(m => m.SisCategoryID == 1 && m.Result != 0).Average(m => m.Result) * .50), 2);
                        double cat2 = Math.Round((SEPFList.Where(m => m.SisCategoryID == 2 && m.Result != 0).Average(m => m.Result) * .25), 2);
                        double cat3 = Math.Round((SEPFList.Where(m => m.SisCategoryID == 3 && m.Result != 0).Average(m => m.Result) * .25), 2);

                        lblOverallMean.Content = Math.Round(cat1 + cat2 + cat3, 2).ToString();

                        dgSkill.ItemsSource  = SEPFList.Where(m => m.SisCategoryID == 1).ToList();
                        lblMeanSkill.Content = "MEAN: " + Math.Round(SEPFList.Where(m => m.SisCategoryID == 1 && m.Result != 0).Average(m => m.Result), 2).ToString();

                        dgWork.ItemsSource  = SEPFList.Where(m => m.SisCategoryID == 2).ToList();
                        lblMeanWork.Content = "MEAN: " + Math.Round(SEPFList.Where(m => m.SisCategoryID == 2 && m.Result != 0).Average(m => m.Result), 2).ToString();

                        dgClassroom.ItemsSource  = SEPFList.Where(m => m.SisCategoryID == 3).ToList();
                        lblMeanClassroom.Content = "MEAN: " + Math.Round(SEPFList.Where(m => m.SisCategoryID == 3 && m.Result != 0).Average(m => m.Result), 2).ToString();
                    }
                    else
                    {
                        MessageBox.Show("No respondent is this schedule.", "System Warning!", MessageBoxButton.OK, MessageBoxImage.Warning);
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }