Exemplo n.º 1
0
        private void GetTeacherShedule()
        {
            listSheduleMonday.Clear();
            listSheduleTuesday.Clear();
            listSheduleWednesday.Clear();
            listSheduleThursday.Clear();
            listSheduleFriday.Clear();
            listSheduleSaturday.Clear();
            sheduleGridMonday.ItemsSource    = new Collection <string>();
            sheduleGridTuesday.ItemsSource   = new Collection <string>();
            sheduleGridWednesday.ItemsSource = new Collection <string>();
            sheduleGridThursday.ItemsSource  = new Collection <string>();
            sheduleGridFriday.ItemsSource    = new Collection <string>();
            sheduleGridSaturday.ItemsSource  = new Collection <string>();

            foreach (KeyValuePair <string, int> keyValue in TeacherId)
            {
                if (keyValue.Key == Manager.Teacher)
                {
                    Manager.TeacherUid = keyValue.Value;
                }
            }
            string responseTeachShedule = Request.TeacherShedule(Manager.TeacherUid, Manager.WeekSetting);
            JArray jAnswer = JArray.Parse(responseTeachShedule);

            try
            {
                for (int i = 0; i < jAnswer.Count; i++)
                {
                    JObject j123 = JObject.Parse(jAnswer[i].ToString());
                    if (j123["day_of_week"].ToString() == "1")
                    {
                        JArray jPairs = JArray.Parse(j123["pairs"].ToString());
                        for (int j = 0; j < jPairs.Count; j++)
                        {
                            Days    monday = new Days();
                            JObject jobj   = JObject.Parse(jPairs[j].ToString());

                            if (jobj["isnull"].ToString() != "1")
                            {
                                monday.pairNum     = jobj["p_num"].ToString();
                                monday.pairSubject = jobj["p_subj"].ToString();
                                monday.pairAud     = jobj["p_aud"].ToString();
                                monday.pairTeacher = jobj["p_group"].ToString();
                            }
                            else
                            {
                                monday.pairNum     = jobj["p_num"].ToString();
                                monday.pairSubject = ("Нет");
                                monday.pairAud     = ("-/-");
                                monday.pairTeacher = ("Нет");
                            }
                            listSheduleMonday.Add(monday);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
            try
            {
                for (int i = 0; i < jAnswer.Count; i++)
                {
                    JObject j123 = JObject.Parse(jAnswer[i].ToString());
                    if (j123["day_of_week"].ToString() == "2")
                    {
                        JArray jPairs = JArray.Parse(j123["pairs"].ToString());
                        for (int j = 0; j < jPairs.Count; j++)
                        {
                            Days    tuesday = new Days();
                            JObject jobj    = JObject.Parse(jPairs[j].ToString());
                            if (jobj["isnull"].ToString() != "1")
                            {
                                tuesday.pairNum     = jobj["p_num"].ToString();
                                tuesday.pairSubject = jobj["p_subj"].ToString();
                                tuesday.pairAud     = jobj["p_aud"].ToString();
                                tuesday.pairTeacher = jobj["p_group"].ToString();
                            }
                            else
                            {
                                tuesday.pairNum     = jobj["p_num"].ToString();
                                tuesday.pairSubject = ("Нет");
                                tuesday.pairAud     = ("-/-");
                                tuesday.pairTeacher = ("Нет");
                            }
                            listSheduleTuesday.Add(tuesday);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
            try
            {
                for (int i = 0; i < jAnswer.Count; i++)
                {
                    JObject j123 = JObject.Parse(jAnswer[i].ToString());
                    if (j123["day_of_week"].ToString() == "3")
                    {
                        JArray jPairs = JArray.Parse(j123["pairs"].ToString());
                        for (int j = 0; j < jPairs.Count; j++)
                        {
                            Days    wednesday = new Days();
                            JObject jobj      = JObject.Parse(jPairs[j].ToString());
                            if (jobj["isnull"].ToString() != "1")
                            {
                                wednesday.pairNum     = jobj["p_num"].ToString();
                                wednesday.pairSubject = jobj["p_subj"].ToString();
                                wednesday.pairAud     = jobj["p_aud"].ToString();
                                wednesday.pairTeacher = jobj["p_group"].ToString();
                            }
                            else
                            {
                                wednesday.pairNum     = jobj["p_num"].ToString();
                                wednesday.pairSubject = ("Нет");
                                wednesday.pairAud     = ("-/-");
                                wednesday.pairTeacher = ("Нет");
                            }
                            listSheduleWednesday.Add(wednesday);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
            try
            {
                for (int i = 0; i < jAnswer.Count; i++)
                {
                    JObject j123 = JObject.Parse(jAnswer[i].ToString());
                    if (j123["day_of_week"].ToString() == "4")
                    {
                        JArray jPairs = JArray.Parse(j123["pairs"].ToString());
                        for (int j = 0; j < jPairs.Count; j++)
                        {
                            Days    thursday = new Days();
                            JObject jobj     = JObject.Parse(jPairs[j].ToString());
                            if (jobj["isnull"].ToString() != "1")
                            {
                                thursday.pairNum     = jobj["p_num"].ToString();
                                thursday.pairSubject = jobj["p_subj"].ToString();
                                thursday.pairAud     = jobj["p_aud"].ToString();
                                thursday.pairTeacher = jobj["p_group"].ToString();
                            }
                            else
                            {
                                thursday.pairNum     = jobj["p_num"].ToString();
                                thursday.pairSubject = ("Нет");
                                thursday.pairAud     = ("-/-");
                                thursday.pairTeacher = ("Нет");
                            }
                            listSheduleThursday.Add(thursday);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
            try
            {
                for (int i = 0; i < jAnswer.Count; i++)
                {
                    JObject j123 = JObject.Parse(jAnswer[i].ToString());
                    if (j123["day_of_week"].ToString() == "5")
                    {
                        JArray jPairs = JArray.Parse(j123["pairs"].ToString());
                        for (int j = 0; j < jPairs.Count; j++)
                        {
                            Days    friday = new Days();
                            JObject jobj   = JObject.Parse(jPairs[j].ToString());
                            if (jobj["isnull"].ToString() != "1")
                            {
                                friday.pairNum     = jobj["p_num"].ToString();
                                friday.pairSubject = jobj["p_subj"].ToString();
                                friday.pairAud     = jobj["p_aud"].ToString();
                                friday.pairTeacher = jobj["p_group"].ToString();
                            }
                            else
                            {
                                friday.pairNum     = jobj["p_num"].ToString();
                                friday.pairSubject = ("Нет");
                                friday.pairAud     = ("-/-");
                                friday.pairTeacher = ("Нет");
                            }
                            listSheduleFriday.Add(friday);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
            try
            {
                for (int i = 0; i < jAnswer.Count; i++)
                {
                    JObject j123 = JObject.Parse(jAnswer[i].ToString());
                    if (j123["day_of_week"].ToString() == "6")
                    {
                        JArray jPairs = JArray.Parse(j123["pairs"].ToString());
                        for (int j = 0; j < jPairs.Count; j++)
                        {
                            Days    saturday = new Days();
                            JObject jobj     = JObject.Parse(jPairs[j].ToString());
                            if (jobj["isnull"].ToString() != "1")
                            {
                                saturday.pairNum     = jobj["p_num"].ToString();
                                saturday.pairSubject = jobj["p_subj"].ToString();
                                saturday.pairAud     = jobj["p_aud"].ToString();
                                saturday.pairTeacher = jobj["p_group"].ToString();
                            }
                            else
                            {
                                saturday.pairNum     = jobj["p_num"].ToString();
                                saturday.pairSubject = ("Нет");
                                saturday.pairAud     = ("-/-");
                                saturday.pairTeacher = ("Нет");
                            }
                            listSheduleSaturday.Add(saturday);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }

            sheduleGridMonday.ItemsSource    = listSheduleMonday;
            sheduleGridTuesday.ItemsSource   = listSheduleTuesday;
            sheduleGridWednesday.ItemsSource = listSheduleWednesday;
            sheduleGridThursday.ItemsSource  = listSheduleThursday;
            sheduleGridFriday.ItemsSource    = listSheduleFriday;
            sheduleGridSaturday.ItemsSource  = listSheduleSaturday;
        }
Exemplo n.º 2
0
        private void GetGroupShedule()
        {
            listSheduleMonday.Clear();
            listSheduleTuesday.Clear();
            listSheduleWednesday.Clear();
            listSheduleThursday.Clear();
            listSheduleFriday.Clear();
            listSheduleSaturday.Clear();
            sheduleGridMonday.ItemsSource    = new Collection <string>();
            sheduleGridTuesday.ItemsSource   = new Collection <string>();
            sheduleGridWednesday.ItemsSource = new Collection <string>();
            sheduleGridThursday.ItemsSource  = new Collection <string>();
            sheduleGridFriday.ItemsSource    = new Collection <string>();
            sheduleGridSaturday.ItemsSource  = new Collection <string>();

            string responseGroupShedule = Request.GroupShedule();
            JArray jAnswer = JArray.Parse(responseGroupShedule);

            #region GroupShedule
            try
            {
                for (int i = 0; i < jAnswer.Count; i++)
                {
                    JObject j123 = JObject.Parse(jAnswer[i].ToString());
                    if (j123["day_of_week"].ToString() == "1")
                    {
                        JArray jPairs = JArray.Parse(j123["pairs"].ToString());
                        for (int j = 0; j < jPairs.Count; j++)
                        {
                            Days    monday = new Days();
                            JObject jobj   = JObject.Parse(jPairs[j].ToString());

                            if (jobj["isnull"].ToString() != "1")
                            {
                                monday.pairNum     = jobj["p_num"].ToString();
                                monday.pairSubject = jobj["p_subj"].ToString();
                                monday.pairAud     = jobj["p_aud"].ToString();
                                monday.pairTeacher = jobj["p_prep"].ToString();
                            }
                            else
                            {
                                monday.pairNum     = jobj["p_num"].ToString();
                                monday.pairSubject = ("Нет");
                                monday.pairAud     = ("-/-");
                                monday.pairTeacher = ("Нет");
                            }
                            listSheduleMonday.Add(monday);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
            try
            {
                for (int i = 0; i < jAnswer.Count; i++)
                {
                    JObject j123 = JObject.Parse(jAnswer[i].ToString());
                    if (j123["day_of_week"].ToString() == "2")
                    {
                        JArray jPairs = JArray.Parse(j123["pairs"].ToString());
                        for (int j = 0; j < jPairs.Count; j++)
                        {
                            Days    tuesday = new Days();
                            JObject jobj    = JObject.Parse(jPairs[j].ToString());
                            if (jobj["isnull"].ToString() != "1")
                            {
                                tuesday.pairNum     = jobj["p_num"].ToString();
                                tuesday.pairNum     = jobj["p_num"].ToString();
                                tuesday.pairSubject = jobj["p_subj"].ToString();
                                tuesday.pairSubject = jobj["p_subj"].ToString();
                                tuesday.pairAud     = jobj["p_aud"].ToString();
                                tuesday.pairTeacher = jobj["p_prep"].ToString();
                                tuesday.ischange    = jobj["ischange"].ToString();
                            }
                            else
                            {
                                tuesday.pairNum     = jobj["p_num"].ToString();
                                tuesday.pairSubject = ("Нет");
                                tuesday.pairAud     = ("-/-");
                                tuesday.pairTeacher = ("Нет");
                            }
                            listSheduleTuesday.Add(tuesday);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
            try
            {
                for (int i = 0; i < jAnswer.Count; i++)
                {
                    JObject j123 = JObject.Parse(jAnswer[i].ToString());
                    if (j123["day_of_week"].ToString() == "3")
                    {
                        JArray jPairs = JArray.Parse(j123["pairs"].ToString());
                        for (int j = 0; j < jPairs.Count; j++)
                        {
                            Days    wednesday = new Days();
                            JObject jobj      = JObject.Parse(jPairs[j].ToString());
                            if (jobj["isnull"].ToString() != "1")
                            {
                                wednesday.pairNum     = jobj["p_num"].ToString();
                                wednesday.pairSubject = jobj["p_subj"].ToString();
                                wednesday.pairAud     = jobj["p_aud"].ToString();
                                wednesday.pairTeacher = jobj["p_prep"].ToString();
                            }
                            else
                            {
                                wednesday.pairNum     = jobj["p_num"].ToString();
                                wednesday.pairSubject = ("Нет");
                                wednesday.pairAud     = ("-/-");
                                wednesday.pairTeacher = ("Нет");
                            }
                            listSheduleWednesday.Add(wednesday);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
            try
            {
                for (int i = 0; i < jAnswer.Count; i++)
                {
                    JObject j123 = JObject.Parse(jAnswer[i].ToString());
                    if (j123["day_of_week"].ToString() == "4")
                    {
                        JArray jPairs = JArray.Parse(j123["pairs"].ToString());
                        for (int j = 0; j < jPairs.Count; j++)
                        {
                            Days    thursday = new Days();
                            JObject jobj     = JObject.Parse(jPairs[j].ToString());
                            if (jobj["isnull"].ToString() != "1")
                            {
                                thursday.pairNum     = jobj["p_num"].ToString();
                                thursday.pairSubject = jobj["p_subj"].ToString();
                                thursday.pairAud     = jobj["p_aud"].ToString();
                                thursday.pairTeacher = jobj["p_prep"].ToString();
                            }
                            else
                            {
                                thursday.pairNum     = jobj["p_num"].ToString();
                                thursday.pairSubject = ("Нет");
                                thursday.pairAud     = ("-/-");
                                thursday.pairTeacher = ("Нет");
                            }
                            listSheduleThursday.Add(thursday);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
            try
            {
                for (int i = 0; i < jAnswer.Count; i++)
                {
                    JObject j123 = JObject.Parse(jAnswer[i].ToString());
                    if (j123["day_of_week"].ToString() == "5")
                    {
                        JArray jPairs = JArray.Parse(j123["pairs"].ToString());
                        for (int j = 0; j < jPairs.Count; j++)
                        {
                            Days    friday = new Days();
                            JObject jobj   = JObject.Parse(jPairs[j].ToString());
                            if (jobj["isnull"].ToString() != "1")
                            {
                                friday.pairNum     = jobj["p_num"].ToString();
                                friday.pairSubject = jobj["p_subj"].ToString();
                                friday.pairAud     = jobj["p_aud"].ToString();
                                friday.pairTeacher = jobj["p_prep"].ToString();
                            }
                            else
                            {
                                friday.pairNum     = jobj["p_num"].ToString();
                                friday.pairSubject = ("Нет");
                                friday.pairAud     = ("-/-");
                                friday.pairTeacher = ("Нет");
                            }
                            listSheduleFriday.Add(friday);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
            try
            {
                for (int i = 0; i < jAnswer.Count; i++)
                {
                    JObject j123 = JObject.Parse(jAnswer[i].ToString());
                    if (j123["day_of_week"].ToString() == "6")
                    {
                        JArray jPairs = JArray.Parse(j123["pairs"].ToString());
                        for (int j = 0; j < jPairs.Count; j++)
                        {
                            Days    saturday = new Days();
                            JObject jobj     = JObject.Parse(jPairs[j].ToString());
                            if (jobj["isnull"].ToString() != "1")
                            {
                                saturday.pairNum     = jobj["p_num"].ToString();
                                saturday.pairSubject = jobj["p_subj"].ToString();
                                saturday.pairAud     = jobj["p_aud"].ToString();
                                saturday.pairTeacher = jobj["p_prep"].ToString();
                            }
                            else
                            {
                                saturday.pairNum     = jobj["p_num"].ToString();
                                saturday.pairSubject = ("Нет");
                                saturday.pairAud     = ("-/-");
                                saturday.pairTeacher = ("Нет");
                            }
                            listSheduleSaturday.Add(saturday);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
            #endregion

            sheduleGridMonday.ItemsSource    = listSheduleMonday;
            sheduleGridTuesday.ItemsSource   = listSheduleTuesday;
            sheduleGridWednesday.ItemsSource = listSheduleWednesday;
            sheduleGridThursday.ItemsSource  = listSheduleThursday;
            sheduleGridFriday.ItemsSource    = listSheduleFriday;
            sheduleGridSaturday.ItemsSource  = listSheduleSaturday;
        }