protected override void OnPrimaryKeyChangedAsync() { //Get the Course Record Record = SHCourse.SelectByID(PrimaryKey); //Get the Course_Ext Record AccessHelper ah = new AccessHelper(); List<UDT.CourseExt> moreInfo = ah.Select<UDT.CourseExt>("ref_course_id='" + this.PrimaryKey + "'"); this.Course2 = (moreInfo.Count > 0) ? moreInfo[0] : null; }
private void frmSeatTable_Load(object sender, EventArgs e) { this.MaximizeBox = true; if (K12.Presentation.NLDPanels.Course.SelectedSource.Count < 1) { MessageBox.Show("請選擇課程"); return; } //1. 取得目前選取的課程 AccessHelper ah = new AccessHelper(); this.currentCourseID = K12.Presentation.NLDPanels.Course.SelectedSource[0]; K12.Data.CourseRecord rec = K12.Data.Course.SelectByID(this.currentCourseID); this.expandablePanel1.TitleText = rec.Name; List<UDT.CourseExt> course_exts = ah.Select<UDT.CourseExt>("ref_course_id=" + this.currentCourseID); if (course_exts.Count == 0) this.currentCourseExt = null; else { this.currentCourseExt = course_exts[0]; this.expandablePanel1.TitleText = rec.Name + " ( " + this.currentCourseExt.SubjectCode + " )"; } //2. 取得所有的座位表樣版 this.allLayouts = new List<ClassRoomLayout>(); List<UDT_ClassRoomLayout> udtLayouts =(new AccessHelper()).Select<UDT_ClassRoomLayout>(); foreach(UDT_ClassRoomLayout udtL in udtLayouts) { ClassRoomLayout lt = new ClassRoomLayout(udtL); this.allLayouts.Add(lt); this.cboLayouts.Items.Add(lt); //this.cboLayouts.SelectedIndex = 0; } //3. 取得此課程的座位表樣版 this.layout = this.allLayouts[0]; //預設 layout List<UDT.CourseExt> course_ext = ah.Select<UDT.CourseExt>("ref_course_id=" + this.currentCourseID ); if ((course_ext.Count ==0) || (course_ext[0].ClassroomLayoutID == null)) { //採預設 layout,所以不作任何事。 } else { foreach(ClassRoomLayout crl in this.allLayouts) { if (this.currentCourseExt.ClassroomLayoutID.ToString() == crl.UID ) { this.layout = crl ; break ; } } } this.currentCourseExt.ClassroomLayoutID = int.Parse(this.layout.UID); //4. 取得修課學生 this.GetSCAttendExt(); //5. 指定課程的座位樣版 this.cboLayouts.SelectedItem = this.layout ; //會觸發 selectedindex_change 事件 }
private void btnSave_Click(object sender, EventArgs e) { List<ActiveRecord> records = new List<ActiveRecord>(); //1. Course Ext if (this.currentCourseExt == null) { this.currentCourseExt = new UDT.CourseExt(); this.currentCourseExt.CourseID = int.Parse(this.currentCourseID); } //更新 CourseExt 的 ClassroomTemplateID this.currentCourseExt.ClassroomLayoutID = int.Parse(this.layout.UID); records.Add(this.currentCourseExt); //2. 更新座位的學生 if (this.updatedStudentIDs.Count > 0) { List<string> uids = new List<string>(); foreach (string studID in this.updatedStudentIDs) { SeatTableStudent stud = this.students[studID]; uids.Add(stud.CourseExt_UID); // } AccessHelper ah = new AccessHelper(); List<UDT.SCAttendExt> exts = ah.Select<UDT.SCAttendExt>(uids); foreach (UDT.SCAttendExt ext in exts) { SeatTableStudent stud = this.students[ext.StudentID.ToString()]; if (string.IsNullOrWhiteSpace(stud.SeatX)) ext.SeatX = null; else ext.SeatX = int.Parse(stud.SeatX); if (string.IsNullOrWhiteSpace(stud.SeatY)) ext.SeatY = null; else ext.SeatY = int.Parse(stud.SeatY); records.Add(ext); } } (new AccessHelper()).SaveAll(records); Util.ShowMsg("儲存完成",""); }
protected override void OnSaveData() { //Save To UDT UDT.CourseExt c = this.Course2; if (this.Course2 == null) c = new UDT.CourseExt() ; c.CourseID = int.Parse(this.PrimaryKey); string subjCode = this.cboSubject.Text ; UDT.Subject subj = this.dicSubjectsBySubjectIdentifier[subjCode]; c.SubjectID = int.Parse(subj.UID); c.SubjectCode = subjCode; //c.NewSubjectCode = this.txtNewSubjectCode.Text; c.NewSubjectCode = this.cboNewSubjectCode.Text; c.CourseType = this.cboCategory.SelectedItem.ToString(); c.IsRequired = this.swb.Value; int capacity = 0; int.TryParse(this.nudCountLimit.Text, out capacity); int serial = 0; int.TryParse(this.nudSerialNo.Text, out serial); c.Capacity = capacity; c.SerialNo = serial; c.ClassName = this.cboClass.SelectedValue.ToString(); c.Classroom = this.txtClassroom.Text.Trim(); c.CourseTimeInfo = this.txtCourseTimeInfo.Text.Trim(); c.Syllabus = this.txtOutline.Text.Trim(); c.Memo = this.txtMemo.Text.Trim(); List<ActiveRecord> recs = new List<ActiveRecord>(); recs.Add(c); AccessHelper ah = new AccessHelper(); ah.SaveAll(recs); //Save to DB this.Record.Name = this.txtCourseName.Text; this.Record.SchoolYear = (int)this.nudSchoolYear.Value; this.Record.Semester = int.Parse(this.cboSemester.SelectedValue.ToString()); //this.Record.RefClassID = this.cboClass.SelectedValue.ToString(); this.Record.Subject = this.cboSubject.Text; decimal credit = 0; decimal.TryParse(this.nudCredit.Text, out credit); this.Record.Credit = credit; //this.Record.Required = this.swb.Value; SHCourse.Update(this.Record); /* Log */ this.AddLog(this.Record, c); this.logAgent.ActionType = Log.LogActionType.Update; this.logAgent.Save("課程.資料項目.基本資料", "", "", Log.LogTargetCategory.Course, this.Record.ID); /* */ //K12.Presentation.NLDPanels.Course.RefillListPane(); ResetDirtyStatus(); }
private void buttonX1_Click(object sender, EventArgs e) { this.textBoxX2.Text = ""; this.addMsg(" ==== 開始匯入課程 ==="); if (string.IsNullOrWhiteSpace(this.textBoxX1.Text)) return; //1. 讀取所有科目 (供比對出科目代碼) this.GetAllSubjects(); //2. 讀取某學年度學期的所有課程 (決定要新增或修改) this.GetAllCourses(); //3. 開始讀取Excel 上的課程資料, Workbook wb = new Aspose.Cells.Workbook(); wb.Open(this.textBoxX1.Text); Worksheet ws = wb.Worksheets[1]; //課程 int rowIndex = 1; while (ws.Cells[rowIndex, 0].Value != null) { string courseCode = GetCellValue(ws.Cells[rowIndex, 1].Value); string classCode = GetCellValue(ws.Cells[rowIndex, 2].Value); if (classCode.Length > 2) classCode = classCode.Substring(1, 2); string credit = GetCellValue(ws.Cells[rowIndex, 3].Value); string courseName = GetCellValue(ws.Cells[rowIndex, 4].Value); string semester = GetCellValue(ws.Cells[rowIndex, 5].Value); string schoolyear = GetCellValue(ws.Cells[rowIndex, 6].Value); string subjID = "0"; if (!this.dicSubjects.ContainsKey(courseCode)) this.addMsg( string.Format("匯入課程時找不到 subject ID, code : {0}, class name :{1} , course name : {2}, schoolyear: {3}, semester :{4} ", courseCode, classCode, courseName, schoolyear, semester)); else { subjID = this.dicSubjects[courseCode].UID; string key = string.Format("{0}_{1}", courseCode, classCode); //檢查資料庫中是否已有存在?如果存再就修改,否則新增。 bool isCourseExisted = false; if (this.dicCourseExts.ContainsKey(key)) { UDT.CourseExt cExt = this.dicCourseExts[key]; if (this.dicCourses.ContainsKey(cExt.CourseID.ToString())) isCourseExisted = true; } if (isCourseExisted) { UDT.CourseExt cExt = this.dicCourseExts[key]; cExt.ClassName = classCode; cExt.SubjectCode = courseCode; cExt.SubjectID = int.Parse(subjID); List<ActiveRecord> recs = new List<ActiveRecord>(); recs.Add(cExt); (new AccessHelper()).UpdateValues(recs); SHCourseRecord course = this.dicCourses[cExt.CourseID.ToString()]; course.Credit = decimal.Parse(credit); course.Name = string.Format("{0} {1}", courseName, classCode); course.SchoolYear = int.Parse(schoolyear); course.Semester = int.Parse(semester); SHCourse.Update(course); } else { SHCourseRecord course = new SHCourseRecord(); course.Credit = decimal.Parse(credit); course.Name = string.Format("{0} {1}", courseName, classCode); course.SchoolYear = int.Parse(schoolyear); course.Semester = int.Parse(semester); string newID = SHCourse.Insert(course); UDT.CourseExt cExt = new UDT.CourseExt(); cExt.CourseID = int.Parse(newID); cExt.ClassName = classCode; cExt.SubjectCode = courseCode; cExt.SubjectID = int.Parse(subjID); List<ActiveRecord> recs = new List<ActiveRecord>(); recs.Add(cExt); (new AccessHelper()).InsertValues(recs); } } //if find subject id rowIndex += 1; this.lblStatus.Text = rowIndex.ToString() ; Application.DoEvents(); } // while loop //匯入修課學生 this.ImportSCAttendRecords(); }