Example #1
0
        //添加课程
        private void button5_Click(object sender, EventArgs e)
        {
            LessonModel lessonModel = new LessonModel(moduleModel.type, moduleModel.lessonList.Count);
            //lessonModel.type = moduleModel.type;
            // lessonModel.orderNum = moduleModel.lessonList.Count;

            LessonDetailForm frm = new LessonDetailForm(lessonModel, moduleModel, LessonDetailType.LessonDetailTypeAdd);

            if (frm.ShowDialog() == DialogResult.OK)//对话框返回值为ok时运行
            {
                moduleModel.lessonList.Add(lessonModel);
                refreshLessonListView();

                String jsonString = JSONHandle.getJsonString(moduleModel.lessonList);
                //MessageBox.Show("jsonString:" + jsonString);
                String filePath = moduleModel.jsonFileLocalPath;
                FileHandle.saveJsonFile(filePath, jsonString);
            }
        }
Example #2
0
        private void lessonListView_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            ListView.SelectedIndexCollection c = lessonListView.SelectedIndices;
            if (c.Count > 0)
            {
                //MessageBox.Show("index:"+c[0]);

                int         index       = c[0];
                LessonModel lessonModel = (LessonModel)moduleModel.lessonList[index];

                LessonDetailForm frm = new LessonDetailForm(lessonModel, moduleModel, LessonDetailType.LessonDetailTypeEdit);
                if (frm.ShowDialog() == DialogResult.OK)//对话框返回值为ok时运行
                {
                    moduleModel.lessonList.Add(lessonModel);
                    refreshLessonListView();

                    String jsonString = JSONHandle.Obj2Json(moduleModel.lessonList);
                    //MessageBox.Show("jsonString:"+jsonString);
                    String filePath = moduleModel.jsonFileLocalPath;
                    FileHandle.saveJsonFile(filePath, jsonString);
                }
            }
        }