/// <summary> /// 绑定数据源 /// </summary> private void bind() { string courTableID = Request.QueryString["courTableID"]; CourseTableBLL ctBLL = new CourseTableBLL(); TeacherBLL teacherBLL = new TeacherBLL(); CourseBLL courBLL = new CourseBLL(); ClassBLL classBLL = new ClassBLL(); CourseTable ct = ctBLL.get(courTableID); Class clazz = classBLL.get(ct.ClassID); #region 页面数据绑定 className.Text = clazz.Name; courseName.Text = courBLL.get(ct.CourId).Name; teacherName.Text = teacherBLL.get(ct.TeachID).Name; week.Text = "第" + ct.Week + "周"; weekDay.Text = ct.WeekDay; classtTime.Text = ct.CourseTime; classAddress.Text = ct.Place; CommonBLL commBLL = new CommonBLL(); DataTable dt = commBLL.getAbsentStudent(courTableID, false); AspNetPager1.RecordCount = dt.Rows.Count; int from = (AspNetPager1.CurrentPageIndex - 1) * AspNetPager1.PageSize + 1; int to = from + AspNetPager1.PageSize - 1 > AspNetPager1.RecordCount ? AspNetPager1.RecordCount : from + AspNetPager1.PageSize - 1; GridView1.DataSource = PageUtil.getPaged(dt, from, to); GridView1.DataBind(); #endregion }
/// <summary> /// 绑定数据源 /// </summary> private void bind() { string id = Request.QueryString["ID"].ToString(); string week = Request.QueryString["week"].ToString(); CourseBLL courBLL = new CourseBLL(); TeacherBLL teacherBLL = new TeacherBLL(); ClassBLL classBLL = new ClassBLL(); CourseTableBLL ctBLL = new CourseTableBLL(); ct = ctBLL.get(id); #region 页面数据绑定 Label_course.Text = courBLL.get(ct.CourId).Name; Label_teacher.Text = teacherBLL.get(ct.TeachID).Name; Label_class.Text = classBLL.get(ct.ClassID).Name; PageUtil.bindDropDownList(DropDownList_semester_from, ct.Semester.Substring(0, 4)); PageUtil.bindDropDownList(DropDownList_semester_to, ct.Semester.Substring(5, 4)); PageUtil.bindDropDownList(DropDownList_semester_end, ct.Semester.Substring(9, 3)); PageUtil.bindDropDownList(DropDownList_week_from, week.Split('-')[0]); PageUtil.bindDropDownList(DropDownList_week_to, week.Split('-')[1]); PageUtil.bindDropDownList(DropDownList_weekDay, ct.WeekDay); TextBox_place.Text = ct.Place; PageUtil.bindDropDownList(DropDownList_courseTime, ct.CourseTime.Split('节')[0]); #endregion }
public static CourseTable CreateCourseTable(string dataAreaId, string courseId, global::System.DateTimeOffset registrationDeadline, global::System.DateTimeOffset startDateTime, int maxAttendees, global::System.DateTimeOffset endDateTime, int minimumNumberOfParticipants, long instructorId, global::Microsoft.Dynamics.DataEntities.CourseType courseType) { CourseTable courseTable = new CourseTable(); courseTable.dataAreaId = dataAreaId; courseTable.CourseId = courseId; courseTable.RegistrationDeadline = registrationDeadline; courseTable.StartDateTime = startDateTime; courseTable.MaxAttendees = maxAttendees; courseTable.EndDateTime = endDateTime; courseTable.MinimumNumberOfParticipants = minimumNumberOfParticipants; courseTable.InstructorId = instructorId; if ((courseType == null)) { throw new global::System.ArgumentNullException("courseType"); } courseTable.CourseType = courseType; return(courseTable); }
public async Task <IActionResult> Edit(int id, [Bind("courseId,coursename,coursetype")] CourseTable courseTable) { if (id != courseTable.courseId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(courseTable); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CourseTableExists(courseTable.courseId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(courseTable)); }
/// <summary> /// 绑定数据源 /// </summary> private void bind() { string id = Request.QueryString["id"].ToString(); AttendanceBLL attendBLL = new AttendanceBLL(); attend = attendBLL.get(id); CourseTableBLL ctBLL = new CourseTableBLL(); CourseTable ct = ctBLL.get(attend.CourTableID); ClassBLL classBLL = new ClassBLL(); TeacherBLL teacherBLL = new TeacherBLL(); CourseBLL courseBLL = new CourseBLL(); StudentBLL stuBLL = new StudentBLL(); #region 绑定页面数据 Label_class.Text = classBLL.get(ct.ClassID).Name; Label_course.Text = courseBLL.get(ct.CourId).Name; Label_teacher.Text = teacherBLL.get(ct.TeachID).Name; Label_student.Text = stuBLL.get(attend.StudID).Name; Label_oldStatus.Text = attend.Status; Label_week.Text = ct.Week; Label_weekDay.Text = ct.WeekDay; Label_courseTime.Text = ct.CourseTime; Label_place.Text = ct.Place; #endregion }
protected void ImageButton_submit_Click(object sender, ImageClickEventArgs e) { if (check()) { string semester = DropDownList_semester_from.SelectedValue + "-" + DropDownList_semester_to.SelectedValue + "学年" + DropDownList_semester_end.SelectedValue; int week_from = Convert.ToInt32(DropDownList_week_from.SelectedValue); int week_to = Convert.ToInt32(DropDownList_week_to.SelectedValue); string weekDay = DropDownList_weekDay.SelectedValue; string place = TextBox_place.Text; string courseTime = DropDownList_courseTime.SelectedValue + "节"; string teachId = DropDownList_teacher.SelectedValue; string classId = DropDownList_class.SelectedValue; string courId = DropDownList_course.SelectedValue; CourseTableBLL courTableBLL = new CourseTableBLL(); CourseTable courTable = new CourseTable(); courTable.Semester = semester; courTable.WeekDay = weekDay; courTable.Place = place; courTable.CourseTime = courseTime; courTable.TeachID = teachId; courTable.ClassID = classId; courTable.CourId = courId; for (int i = week_from; i <= week_to; i++) { courTable.Week = i.ToString(); courTableBLL.save(courTable); } Response.Write("<script>alert('添加成功!');location.href='addCourseTable.aspx';</script>"); } }
public object get(string id) { CourseTable courTable = null; string selectSql = "SELECT * FROM t_courseTable WHERE ID=@ID"; SqlParameter[] sqlParas = new SqlParameter[] { new SqlParameter("@ID", id) }; DataSet ds = SQLServerDBUtil.query(selectSql, sqlParas); if (ds.Tables[0].Rows.Count != 0) { courTable = new CourseTable(); courTable.Id = ds.Tables[0].Rows[0][0].ToString(); courTable.Semester = ds.Tables[0].Rows[0][1].ToString(); courTable.Week = ds.Tables[0].Rows[0][2].ToString(); courTable.WeekDay = ds.Tables[0].Rows[0][3].ToString(); courTable.Place = ds.Tables[0].Rows[0][4].ToString(); courTable.CourseTime = ds.Tables[0].Rows[0][5].ToString(); courTable.TeachID = ds.Tables[0].Rows[0][6].ToString(); courTable.ClassID = ds.Tables[0].Rows[0][7].ToString(); courTable.CourId = ds.Tables[0].Rows[0][8].ToString(); } return(courTable); }
protected void ImageButton_delete_Click(object sender, ImageClickEventArgs e) { ImageButton imageButton = sender as ImageButton; string id = imageButton.CommandArgument; AttendanceBLL attendBLL = new AttendanceBLL(); CourseTableBLL ctBLL = new CourseTableBLL(); CourseTable ct = ctBLL.get(id); string filter = "courId='" + ct.CourId + "' and teachID='" + ct.TeachID + "' and classID='" + ct.ClassID; filter += "' and semester='" + ct.Semester + "' and weekDay='" + ct.WeekDay + "' and courseTime='" + ct.CourseTime + "'"; DataTable dt = PageUtil.getProcessedDataTable(ctBLL.getAll().Tables[0], filter, null, false); foreach (DataRow dr in dt.Rows) { attendBLL.deleteByCourseTableId(dr["ID"].ToString()); CourseTable tempCt = new CourseTable(); tempCt.Id = dr["ID"].ToString(); ctBLL.delete(tempCt); } Response.Write("<script>alert('删除成功!');location.href='showCourseTable.aspx';</script>"); }
public ActionResult DeleteConfirmed(int id) { CourseTable courseTable = db.CourseTables.Find(id); db.CourseTables.Remove(courseTable); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult CourseEnrollment(FormCollection form) { CourseTable course = db.Courses.Find(int.Parse(form["CourseId"])); db.Students.Find(int.Parse(form["StudentId"])).Courses.Add(course); db.SaveChanges(); return(RedirectToAction("Courses", new { id = Int32.Parse(form["StudentId"]) })); }
public ActionResult Edit([Bind(Include = "courseID,courseName,courseShortName,courseCode")] CourseTable courseTable) { if (ModelState.IsValid) { db.Entry(courseTable).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(courseTable)); }
public void delete(object obj) { CourseTable courTable = (CourseTable)obj; string deleteSql = "DELETE FROM t_courseTable WHERE ID=@ID"; SqlParameter[] sqlParas = new SqlParameter[] { new SqlParameter("@ID", courTable.Id) }; SQLServerDBUtil.execute(deleteSql, sqlParas); }
public async Task <IActionResult> Create([Bind("courseId,coursename,coursetype")] CourseTable courseTable) { if (ModelState.IsValid) { _context.Add(courseTable); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(courseTable)); }
public ActionResult Create([Bind(Include = "courseID,courseName,courseShortName,courseCode")] CourseTable courseTable) { if (ModelState.IsValid) { db.CourseTables.Add(courseTable); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(courseTable)); }
public bool onPressingAddingCourseButton(string CourseName, string CourseCode, string CourseCredit) { if (CourseName == "" || CourseCredit == "" || CourseCode == "") { return(false); } else { IDatabaseTable databaseTable = new CourseTable(new Course(CourseName, CourseCode, CourseCredit)); return(databaseTable.SendData()); } }
protected void ImageButton_submit_Click(object sender, ImageClickEventArgs e) { if (check()) { AttendanceBLL attendBLL = new AttendanceBLL(); CourseTableBLL ctBLL = new CourseTableBLL(); string filter = "courId='" + ct.CourId + "' and teachID='" + ct.TeachID + "' and classID='" + ct.ClassID; filter += "' and semester='" + ct.Semester + "' and weekDay='" + ct.WeekDay + "' and courseTime='" + ct.CourseTime + "'"; #region 先删除旧数据 DataTable dt = PageUtil.getProcessedDataTable(ctBLL.getAll().Tables[0], filter, null, false); foreach (DataRow dr in dt.Rows) { attendBLL.deleteByCourseTableId(dr["ID"].ToString()); CourseTable tempCt = new CourseTable(); tempCt.Id = dr["ID"].ToString(); ctBLL.delete(tempCt); } #endregion #region 后添加新数据 string semester = DropDownList_semester_from.SelectedValue + "-" + DropDownList_semester_to.SelectedValue + "学年" + DropDownList_semester_end.SelectedValue; int week_from = Convert.ToInt32(DropDownList_week_from.SelectedValue); int week_to = Convert.ToInt32(DropDownList_week_to.SelectedValue); string weekDay = DropDownList_weekDay.SelectedValue; string place = TextBox_place.Text; string courseTime = DropDownList_courseTime.SelectedValue + "节"; string teachId = ct.TeachID; string classId = ct.ClassID; string courId = ct.CourId; CourseTable courTable = new CourseTable(); courTable.Semester = semester; courTable.WeekDay = weekDay; courTable.Place = place; courTable.CourseTime = courseTime; courTable.TeachID = teachId; courTable.ClassID = classId; courTable.CourId = courId; for (int i = week_from; i <= week_to; i++) { courTable.Week = i.ToString(); ctBLL.save(courTable); } #endregion Response.Write("<script>alert('修改成功!');location.href='showCourseTable.aspx';</script>"); } }
// POST: api/Course public CourseTable Post([FromBody] CourseTable value) { using (database_for_practiceEntities entities = new database_for_practiceEntities()) { value.Instructor = findInstructor(value.InstructorID); entities.CourseTables.Attach(value); entities.Entry(value).State = System.Data.Entity.EntityState.Unchanged; entities.SaveChanges(); var return_val = entities.CourseTables.Find(value.CourseID); return(value); } }
public bool updateCourse(int id, string CourseName, string CourseCode, string CourseCredit) { if (CourseName == " " || CourseCode == " " || CourseCredit == " ") { return(false); } else { CourseTable databaseTable = new CourseTable(new Course(id, CourseName, CourseCode, CourseCredit)); return(databaseTable.UpdateInfo()); } }
// GET: CourseTables/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CourseTable courseTable = db.CourseTables.Find(id); if (courseTable == null) { return(HttpNotFound()); } return(View(courseTable)); }
public ActionResult CreateCourse(CourseTable course) { try { // TODO: Add insert logic here db.Courses.Add(course); db.SaveChanges(); return(RedirectToAction("CourseIndex")); } catch { return(View()); } }
public ActionResult Edit(CourseTable course) { try { // TODO: Add update logic here db.Entry(course).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
public void bind() { courTableID = Request.QueryString["courTableID"]; User user = Session["User"] as User; TeacherBLL teachBLL = new TeacherBLL(); StudentBLL studBLL = new StudentBLL(); CourseTableBLL ctBLL = new CourseTableBLL(); CourseTable ct = ctBLL.get(courTableID); ClassBLL classBll = new ClassBLL(); Class cla = classBll.get(ct.ClassID); className.Text = cla.Name; dt = studBLL.getByClassId(ct.ClassID).Tables[0]; if (Session["attenList"] != null) { attenList = Session["attenList"] as List <Attendance>; } else { attenList = new List <Attendance>(); foreach (DataRow dr in dt.Rows) { Attendance attend = new Attendance(); attend.Status = "正常"; attend.Remark = ""; attend.Recorder = "教师"; attend.RecorderID = teachBLL.getByUserId(user.Id).Id; attend.StudID = dr["ID"].ToString(); attend.CourTableID = courTableID; attenList.Add(attend); } } AspNetPager1.RecordCount = dt.Rows.Count; int from = (AspNetPager1.CurrentPageIndex - 1) * AspNetPager1.PageSize + 1; int to = from + AspNetPager1.PageSize - 1 > AspNetPager1.RecordCount ? AspNetPager1.RecordCount : from + AspNetPager1.PageSize - 1; GridView1.DataSource = PageUtil.resort(PageUtil.getPaged(dt, from, to)); GridView1.DataBind(); initStatusAndRemark(); }
// DELETE: api/Course/5 public void Delete(int id) { using (database_for_practiceEntities entities = new database_for_practiceEntities()) { var toDelete = new CourseTable { CourseID = id }; entities.CourseTables.Attach(toDelete); if (toDelete != null) { entities.CourseTables.Remove(toDelete); entities.SaveChanges(); } } }
protected void ButtonStudent_Click(object sender, EventArgs e) { connect = new SqlConnection(connectionString); command = new SqlCommand("Select ID as 'Student ID', Name as 'First Name', Surname From Students", connect); connect.Open(); reader = command.ExecuteReader(); CourseTable.Columns.Clear(); CourseTable.DataSourceID = null; CourseTable.DataKeyNames = null; CourseTable.AutoGenerateColumns = true; CourseTable.DataSource = reader; CourseTable.DataBind(); reader.Close(); connect.Close(); }
protected void ButtonClass_Click(object sender, EventArgs e) { connect = new SqlConnection(connectionString); command = new SqlCommand("Select Class.Name as 'Class Name', Courses.Name as 'Given Course Name', COUNT(Courses.ID) as 'Number Of Students' From TakenCourses INNER JOIN Courses ON TakenCourses.CourseID = Courses.ID INNER JOIN Class ON Courses.ID = Class.CourseID Group By Class.Name, Courses.Name; ", connect); connect.Open(); reader = command.ExecuteReader(); CourseTable.Columns.Clear(); CourseTable.DataSourceID = null; CourseTable.DataKeyNames = null; CourseTable.AutoGenerateColumns = true; CourseTable.DataSource = reader; CourseTable.DataBind(); reader.Close(); connect.Close(); }
protected void ButtonTakenCourse_Click(object sender, EventArgs e) { connect = new SqlConnection(connectionString); command = new SqlCommand("Select Students.Name, Courses.Name From TakenCourses INNER JOIN Students ON TakenCourses.StudentID = Students.ID INNER JOIN Courses ON TakenCourses.CourseID = Courses.ID", connect); connect.Open(); reader = command.ExecuteReader(); CourseTable.Columns.Clear(); CourseTable.DataSourceID = null; CourseTable.DataKeyNames = null; CourseTable.AutoGenerateColumns = true; CourseTable.DataSource = reader; CourseTable.DataBind(); reader.Close(); connect.Close(); }
public void save(object obj) { CourseTable courTable = (CourseTable)obj; string insertSql = "INSERT INTO t_courseTable(semester,week,weekDay,place,courseTime,teachID,classID,courId) VALUES(@semester,@week,@weekDay,@place,@courseTime,@teachID,@classID,@courId)"; SqlParameter[] sqlParas = new SqlParameter[] { new SqlParameter("@semester", courTable.Semester), new SqlParameter("@week", courTable.Week), new SqlParameter("@weekDay", courTable.WeekDay), new SqlParameter("@place", courTable.Place), new SqlParameter("@courseTime", courTable.CourseTime), new SqlParameter("@teachID", courTable.TeachID), new SqlParameter("@classID", courTable.ClassID), new SqlParameter("@courId", courTable.CourId) }; SQLServerDBUtil.execute(insertSql, sqlParas); }
public void update(object obj) { CourseTable courTable = (CourseTable)obj; string updateSql = "UPDATE t_courseTable SET semester=@semester,week=@week,weekDay=@weekDay,place=@place,courseTime=@courseTime,teachID=@teachID,classID=@classID,courId=@courId WHERE ID=@ID"; SqlParameter[] sqlParas = new SqlParameter[] { new SqlParameter("@semester", courTable.Semester), new SqlParameter("@week", courTable.Week), new SqlParameter("@weekDay", courTable.WeekDay), new SqlParameter("@place", courTable.Place), new SqlParameter("@courseTime", courTable.CourseTime), new SqlParameter("@teachID", courTable.TeachID), new SqlParameter("@classID", courTable.ClassID), new SqlParameter("@courId", courTable.CourId), new SqlParameter("@ID", courTable.Id) }; SQLServerDBUtil.execute(updateSql, sqlParas); }
// PUT: api/Course/5 public CourseTable Put(int id, [FromBody] CourseTable value) { using (database_for_practiceEntities entities = new database_for_practiceEntities()) { var curEntity = entities.CourseTables.ToList().FirstOrDefault(e => e.CourseID == id); if (curEntity != null) { curEntity.CourseName = value.CourseName; curEntity.InstructorID = value.InstructorID; curEntity.Instructor = findInstructor(value.InstructorID); curEntity.StudentIdList = value.StudentIdList; curEntity.Schedule = value.Schedule; curEntity.LengthOfCourse = value.LengthOfCourse; entities.SaveChanges(); return(value); } return(null); } }
public void bind() { List <Attendance> attenList = Session["attenList"] as List <Attendance>; CourseTableBLL ctBLL = new CourseTableBLL(); TeacherBLL teachBll = new TeacherBLL(); CourseBLL courBLL = new CourseBLL(); ClassBLL classBLL = new ClassBLL(); CourseTable ct = ctBLL.get(attenList[0].CourTableID); Class clazz = classBLL.get(ct.ClassID); #region 页面数据绑定 className.Text = clazz.Name; courseName.Text = courBLL.get(ct.CourId).Name; teacherName.Text = teachBll.get(ct.TeachID).Name; week.Text = "第" + ct.Week + "周"; weekDay.Text = ct.WeekDay; classtTime.Text = ct.CourseTime; classAddress.Text = ct.Place; lateNumber.Text = attenList.Where(x => x.Status.Equals("迟到")).ToList().Count.ToString(); absences.Text = attenList.Where(x => !x.Status.Equals("正常")).ToList().Count.ToString(); allNumber.Text = clazz.StudCount; attRate.Text = FormatUtil.doubleToPercent(attenList.Where(x => x.Status.Equals("正常")).ToList().Count / Convert.ToDouble(clazz.StudCount)); DataTable dt = transferListToDataTable(attenList); AspNetPager1.RecordCount = dt.Rows.Count; int from = (AspNetPager1.CurrentPageIndex - 1) * AspNetPager1.PageSize + 1; int to = from + AspNetPager1.PageSize - 1 > AspNetPager1.RecordCount ? AspNetPager1.RecordCount : from + AspNetPager1.PageSize - 1; GridView1.DataSource = PageUtil.resort(PageUtil.getPaged(dt, from, to)); GridView1.DataBind(); #endregion }