private void submitButton_Click(object sender, EventArgs e) { if (listNumber == 1) { string detail = detailTextBox.Text; DateTime date = DateTime.Parse(dateTime.Text); EventDb db = new EventDb(); EventDetails eventDetails = new EventDetails(); eventDetails.eventName = detail; eventDetails.createTime = date; eventDetails.courseName = className; db.AddEvent(eventDetails); mainFrm.eventDetails = mainFrm.db.GetEventDetails(); mainFrm.listView3.Items.Clear(); mainFrm.SetListView3(mainFrm.eventDetails); this.Dispose(); } else if (listNumber == 3) { if (detailTextBox.Text == "") { MessageBox.Show("请设置事件!"); return; } else { DateTime dt = DateTime.Parse(this.dateTime.Text); int year = dt.Year; int month = dt.Month; int day = dt.Day; int count = Calculated.Calculate(year, month, day); if (count < 0) { MessageBox.Show("抱歉,日期选择出错!"); } else { EventDetails ev = new EventDetails(); ev.eventName = detailTextBox.Text; ev.createTime = dt; ev.courseName = ""; mainFrm.db.AddEvent(ev); mainFrm.eventDetails = mainFrm.db.GetEventDetails(); mainFrm.listView3.Items.Clear(); mainFrm.SetListView3(mainFrm.eventDetails); this.Dispose(); return; } } } }
private void submitEditButton_Click(object sender, EventArgs e) { DateTime dt = DateTime.Parse(dateTime.Text); int year = dt.Year; int month = dt.Month; int day = dt.Day; int count = Calculated.Calculate(year, month, day); if (count <= 0) { MessageBox.Show("抱歉,日期选择出错!"); } else { ed.eventName = detailTextBox.Text; ed.createTime = dt; mainFrm.db.edit(ed); MessageBox.Show("修改成功!"); mainFrm.eventDetails = mainFrm.db.GetEventDetails(); mainFrm.listView3.Items.Clear(); mainFrm.SetListView3(mainFrm.eventDetails); } this.Close(); }
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(); }