コード例 #1
0
        public void GetSisFacultyEvaluationPerSchedule(int PeriodID, int ScheduleID)
        {
            try
            {
                using (var db = new LetranIntegratedSystemEntities())
                {
                    SQList   = new List <SisQuestionList>();
                    SEPSList = new List <SisEvaluationPerSchedList>();

                    var result = db.GetHRiSsisPerSchedule(PeriodID, ScheduleID).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)
                        {
                            SisEvaluationPerSchedList sis = new SisEvaluationPerSchedList();
                            sis.FacultyName        = result.FirstOrDefault().FacultyName;
                            sis.SubjectDescription = result.FirstOrDefault().SubjectDescription;
                            sis.SectionName        = result.FirstOrDefault().SectionName;
                            sis.Days        = result.FirstOrDefault().Days;
                            sis.StartTime   = result.FirstOrDefault().StartTime.Value;
                            sis.EndTime     = result.FirstOrDefault().EndTime.Value;
                            sis.RoomName    = result.FirstOrDefault().RoomName;
                            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;
                            }



                            SEPSList.Add(sis);
                        }

                        lblInstructor.Content  = SEPSList.FirstOrDefault().FacultyName.ToUpper();
                        lblSubject.Content     = SEPSList.FirstOrDefault().SubjectDescription;
                        lblSection.Content     = SEPSList.FirstOrDefault().SectionName;
                        lblRespondents.Content = SEPSList.FirstOrDefault().Respondents.ToString();

                        lblDay.Content  = SEPSList.FirstOrDefault().Days;
                        lblTime.Content = SEPSList.FirstOrDefault().StartTime.ToString("t") + " - " + SEPSList.FirstOrDefault().EndTime.ToString("t");
                        lblRoom.Content = SEPSList.FirstOrDefault().RoomName;

                        double cat1 = Math.Round((SEPSList.Where(m => m.SisCategoryID == 1 && m.Result != 0).Average(m => m.Result) * .50), 2);
                        double cat2 = Math.Round((SEPSList.Where(m => m.SisCategoryID == 2 && m.Result != 0).Average(m => m.Result) * .25), 2);
                        double cat3 = Math.Round((SEPSList.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  = SEPSList.Where(m => m.SisCategoryID == 1).ToList();
                        lblMeanSkill.Content = "MEAN: " + Math.Round(SEPSList.Where(m => m.SisCategoryID == 1 && m.Result != 0).Average(m => m.Result), 2).ToString();

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

                        dgClassroom.ItemsSource  = SEPSList.Where(m => m.SisCategoryID == 3).ToList();
                        lblMeanClassroom.Content = "MEAN: " + Math.Round(SEPSList.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);
            }
        }