Exemplo n.º 1
0
        /// <summary>
        /// 得到数据库中courses
        /// </summary>
        /// <returns>Courses</returns>
        public List <List <Course> > GetCourses()
        {
            List <List <Course> > courses1 = new List <List <Course> >();
            ClassDb classDb = new ClassDb();

            for (int i = 0; i < 7; i++)
            {
                List <Course> courses2 = new List <Course>();
                courses2 = classDb.GetCourses(i);
                courses1.Add(courses2);
            }
            return(courses1);
        }
Exemplo n.º 2
0
        private void submitButton_Click(object sender, EventArgs e)
        {
            List <List <Course> > courses = new List <List <Course> >();
            string      userName          = userNameTextBox.Text;
            string      password          = passwordTextBox.Text;
            string      rstStr            = "id=" + userName + "&" + "password="******"http://47.100.30.233/courses", rstStr);
            Response    response          = JsonConvert.DeserializeObject <Response>(jsonStr);

            if (response.success == "false")
            {
                MessageBox.Show(response.message, "错误");
                return;
            }
            courses = response.data;
            ClassDb classDb = new ClassDb();

            classDb.ClearCoursesTable();
            foreach (var courses1 in courses)
            {
                foreach (Course course in courses1)
                {
                    classDb.AddRowInDataSet(course);
                }
            }
            mainFrm.courses = mainFrm.GetCourses();
            int slctWeek = mainFrm.weekComboBox.SelectedIndex + 1;
            int slctDay  = mainFrm.dayComboBox.SelectedIndex;

            mainFrm.db.deleteClassDetail();
            mainFrm.listView1.Items.Clear();
            mainFrm.listView3.Items.Clear();
            mainFrm.eventDetails = mainFrm.db.GetEventDetails();
            mainFrm.SetListView3(mainFrm.eventDetails);
            mainFrm.SetListView1(slctWeek, slctDay);
            this.Dispose();
        }