private void BlackListForm_Load(object sender, EventArgs e) { #region Init SchoolYear Semester List <UDT.OpeningTime> listOpenTime = access.Select <UDT.OpeningTime>(); if (listOpenTime.Count == 0) { listOpenTime.Add(new UDT.OpeningTime() { SchoolYear = int.Parse(K12.Data.School.DefaultSchoolYear), Semester = int.Parse(K12.Data.School.DefaultSemester) }); listOpenTime.SaveAll(); } cbxSchoolYear.Items.Add(listOpenTime[0].SchoolYear + 1); cbxSchoolYear.Items.Add(listOpenTime[0].SchoolYear); cbxSchoolYear.Items.Add(listOpenTime[0].SchoolYear - 1); cbxSchoolYear.SelectedIndex = 1; cbxSemester.Items.Add(1); cbxSemester.Items.Add(2); cbxSemester.SelectedIndex = listOpenTime[0].Semester - 1; #endregion initFinsh = true; ReloadDataGridView(); }
public ClassSelectCourse_Management() { InitializeComponent(); pictureBox1.BackColor = Color.White; #region Init ComboBox AccessHelper access = new AccessHelper(); List <UDT.OpeningTime> openTimeList = access.Select <UDT.OpeningTime>(); if (openTimeList.Count == 0) { openTimeList.Add(new UDT.OpeningTime() { SchoolYear = int.Parse(K12.Data.School.DefaultSchoolYear), Semester = int.Parse(K12.Data.School.DefaultSemester) }); openTimeList.SaveAll(); } // SchoolYear schoolYearCbx.Items.Add(openTimeList[0].SchoolYear - 1); schoolYearCbx.Items.Add(openTimeList[0].SchoolYear); schoolYearCbx.Items.Add(openTimeList[0].SchoolYear + 1); schoolYearCbx.SelectedIndex = 1; // Semester semesterCbx.Items.Add(1); semesterCbx.Items.Add(2); semesterCbx.SelectedIndex = int.Parse("" + openTimeList[0].Semester) - 1; #endregion }
protected override void ProtectedConvert(IProcess process) { base.ProtectedConvert(process); var globalCollection = new List <Manga.IManga>(); var cache = Serializer <ObservableCollection <Manga.Mangas> > .Load(CacheFile); if (cache != null) { globalCollection.AddRange(cache.Where(gm => !globalCollection.Exists(m => m.Uri == gm.Uri))); } var fileUrls = globalCollection.Select(m => m.Uri).ToList(); var settings = Repository.GetStateless <MangaSetting>(); using (var context = Repository.GetEntityContext()) { var dbMangas = context.Get <IManga>().ToList(); var fromFileInDb = dbMangas.Where(m => fileUrls.Contains(m.Uri)).ToList(); if (fromFileInDb.Count == 0) { fromFileInDb = globalCollection.ToList(); } var onlyInDb = dbMangas.Where(m => !fileUrls.Contains(m.Uri)).ToList(); globalCollection = fromFileInDb.Concat(onlyInDb).ToList(); foreach (var manga in globalCollection.Where(m => m.Setting == null).OfType <Manga.Mangas>()) { manga.Setting = settings.Single(s => s.Manga == ConfigStorage.GetPlugin(manga.GetType()).MangaGuid); } globalCollection.SaveAll(); } Backup.MoveToBackup(CacheFile); }
private void Save() { try { List <UDT.Players> addplayers = new List <UDT.Players>(); foreach (DataGridViewRow drv in dgSearch.SelectedRows) { int sid = int.Parse(drv.Tag.ToString()); UDT.Players p = new UDT.Players(); p.RefStudentId = sid; p.ClassName = drv.Cells[colClassName.Index].Value.ToString(); p.SeatNo = int.Parse(drv.Cells[colSeatNo.Index].Value.ToString()); p.Name = drv.Cells[colName.Index].Value.ToString(); p.CreatedBy = drv.Cells[colAccount.Index].Value.ToString(); p.RefTeamId = _team_id; p.RefEventId = _refEventID; // 如果沒有隊,自己是隊長 if (_team_id.HasValue == false) { p.IsTeamLeader = true; } addplayers.Add(p); } addplayers.SaveAll(); } catch (Exception ex) { _sbError.Append("參賽人員儲存錯誤," + ex.Message); } }
public BuildCourseClass() { InitializeComponent(); this.ImeMode = ImeMode.OnHalf; #region 學年、學期 AccessHelper access = new AccessHelper(); List <UDT.OpeningTime> opTimeList = access.Select <UDT.OpeningTime>(); if (opTimeList.Count == 0) { opTimeList.Add(new UDT.OpeningTime() { SchoolYear = int.Parse(K12.Data.School.DefaultSchoolYear), Semester = int.Parse(K12.Data.School.DefaultSemester) }); opTimeList.SaveAll(); } schoolYearCbx.Items.Add(opTimeList[0].SchoolYear + 1); schoolYearCbx.Items.Add(opTimeList[0].SchoolYear); schoolYearCbx.Items.Add(opTimeList[0].SchoolYear - 1); schoolYearCbx.SelectedIndex = 1; semesterCbx.Items.Add(1); semesterCbx.Items.Add(2); semesterCbx.SelectedIndex = opTimeList[0].Semester - 1; #endregion }
private void frmSubject_Management_Load(object sender, EventArgs e) { errorProvider1 = new ErrorProvider(); this.Access = new AccessHelper(); List <UDT.OpeningTime> opTimeList = Access.Select <UDT.OpeningTime>(); if (opTimeList.Count == 0) { opTimeList.Add(new UDT.OpeningTime() { SchoolYear = int.Parse(K12.Data.School.DefaultSchoolYear), Semester = int.Parse(K12.Data.School.DefaultSemester) }); opTimeList.SaveAll(); } #region InitSchoolYear cboSchoolYear.Items.Add(opTimeList[0].SchoolYear + 2); //Cyn新增 cboSchoolYear.Items.Add(opTimeList[0].SchoolYear + 1); cboSchoolYear.Items.Add(opTimeList[0].SchoolYear); cboSchoolYear.Items.Add(opTimeList[0].SchoolYear - 1); cboSchoolYear.Items.Add(opTimeList[0].SchoolYear - 2); //Cyn新增 cboSchoolYear.SelectedIndex = 2; //Cyn 由1改2 #endregion #region InitSemester cboSemester.Items.Add(1); cboSemester.Items.Add(2); cboSemester.SelectedIndex = opTimeList[0].Semester - 1; #endregion this.InitSubject(); }
private void SettingExamineReport_Load(object sender, EventArgs e) { #region Init SchoolYear Semester AccessHelper access = new AccessHelper(); List <UDT.OpeningTime> listOpenTime = access.Select <UDT.OpeningTime>(); if (listOpenTime.Count == 0) { listOpenTime.Add(new UDT.OpeningTime() { SchoolYear = int.Parse(K12.Data.School.DefaultSchoolYear), Semester = int.Parse(K12.Data.School.DefaultSemester) }); listOpenTime.SaveAll(); } cbxSchoolYear.Items.Add(listOpenTime[0].SchoolYear + 1); cbxSchoolYear.Items.Add(listOpenTime[0].SchoolYear); cbxSchoolYear.Items.Add(listOpenTime[0].SchoolYear - 1); cbxSchoolYear.SelectedIndex = 1; cbxSemester.Items.Add(1); cbxSemester.Items.Add(2); cbxSemester.SelectedIndex = listOpenTime[0].Semester - 1; #endregion initFinish = true; ReloadCbxType(); }
private void ManualDisClass_Load(object sender, EventArgs e) { #region Init SchoolYear Semester { List <UDT.OpeningTime> opTimeList = access.Select <UDT.OpeningTime>(); if (opTimeList.Count == 0) { opTimeList.Add(new UDT.OpeningTime() { SchoolYear = int.Parse(School.DefaultSchoolYear), Semester = int.Parse(School.DefaultSemester) }); opTimeList.SaveAll(); } cbxSchoolYear.Items.Add(opTimeList[0].SchoolYear + 1); cbxSchoolYear.Items.Add(opTimeList[0].SchoolYear); cbxSchoolYear.Items.Add(opTimeList[0].SchoolYear - 1); cbxSchoolYear.SelectedIndex = 1; cbxSemester.Items.Add(1); cbxSemester.Items.Add(2); cbxSemester.SelectedIndex = opTimeList[0].Semester - 1; } #endregion ReloadCourseTypeCbx(); _initFinsih = true; }
public RibbonButtons() { Program.MainPanel.RibbonBarItems["管理"]["新增"].Image = Properties.Resources.atom_add_128; Program.MainPanel.RibbonBarItems["管理"]["新增"].Size = RibbonBarButton.MenuButtonSize.Large; Program.MainPanel.RibbonBarItems["管理"]["新增"].Click += delegate { DialogResult dr = new AddNewForm().ShowDialog(); if (dr == DialogResult.OK) { Program.RefreshFilteredSource(); } }; Program.MainPanel.RibbonBarItems["管理"]["刪除"].Image = Properties.Resources.atom_close_128; Program.MainPanel.RibbonBarItems["管理"]["刪除"].Size = RibbonBarButton.MenuButtonSize.Large; Program.MainPanel.RibbonBarItems["管理"]["刪除"].Click += delegate { DialogResult dr = MessageBox.Show("刪除選擇的學校?", "Campus", MessageBoxButtons.YesNo); if (dr == DialogResult.Yes) { AccessHelper ah = new AccessHelper(); List <School> schools = ah.Select <School>(Program.MainPanel.SelectedSource); schools.ForEach((x) => x.Deleted = true); schools.SaveAll(); Program.RefreshFilteredSource(); } }; //Program.MainPanel.RibbonBarItems["進階"]["搜尋"].Image = Properties.Resources.lamp_search_128; //Program.MainPanel.RibbonBarItems["進階"]["搜尋"].Size = RibbonBarButton.MenuButtonSize.Medium; //Program.MainPanel.RibbonBarItems["進階"]["搜尋"].Click += delegate //{ // new SearchForm().ShowDialog(); //}; //Program.MainPanel.RibbonBarItems["進階"]["批次"].Size = RibbonBarButton.MenuButtonSize.Medium; //Program.MainPanel.RibbonBarItems["進階"]["批次"]["Desktop 管理"].Click += delegate //{ // new DesktopModuleManagerForm().ShowDialog(); //}; //Program.MainPanel.RibbonBarItems["進階"]["批次"]["UDM 管理"].Click += delegate //{ // new UDMManagerForm().ShowDialog(); //}; //Program.MainPanel.SelectedSourceChanged += delegate //{ // Program.MainPanel.RibbonBarItems["總務"]["單筆查詢"].Enable = Program.MainPanel.SelectedSource.Count > 0; //}; //Program.MainPanel.RibbonBarItems["總務"]["單筆查詢"].Size = RibbonBarButton.MenuButtonSize.Medium; //Program.MainPanel.RibbonBarItems["總務"]["單筆查詢"].Click += delegate //{ // new VirtualAccountFound.VAFinder().ShowDialog(); //}; }
private void Delete_Click(object sender, EventArgs e) { if (this.lblMessage.Tag == null) { return; } try { // 身分代碼 int identity_id = int.Parse(this.lblMessage.Tag.ToString()); List <UDT.Identity> Identity_Records = Access.Select <UDT.Identity>(string.Format("uid={0}", identity_id.ToString())); // 刪除身分不影響選課記錄,故不必串接刪除選課記錄 // DataTable dataTable = queryHelper.Select(string.Format(@"select student.id as student_id, dept.id as dept_id from student join dept on dept.id=student.ref_dept_id where student.ref_dept_id is not null and student.ref_dept_id={0} //union //select student.id as student_id, dept.id as dept_id from student join class on student.ref_class_id=class.id join dept on dept.id=class.ref_dept_id where student.ref_dept_id is null and class.ref_dept_id={0}", identities[0].DeptID.ToString())); // Dictionary<string, List<string>> dicDeptIDMappingStudentIDs = new Dictionary<string, List<string>>(); // foreach (DataRow row in dataTable.Rows) // { // if (!dicDeptIDMappingStudentIDs.ContainsKey(row["dept_id"] + "")) // dicDeptIDMappingStudentIDs.Add(row["dept_id"] + "", new List<string>()); // dicDeptIDMappingStudentIDs[row["dept_id"] + ""].Add(row["student_id"] + ""); // } // 可選修課目 List <UDT.SIRelation> SIRelation_Records = Access.Select <UDT.SIRelation>(string.Format("ref_identity_id = {0}", identity_id)); DialogResult result = MessageBox.Show("確定刪除「選課身分」及其所包含之所有學年度學期「可選修科目」?若僅刪除特定學年度學期「可選修科目」,請多選「可選修科目」並按「Del」鍵,再按「儲存」。", "警告", MessageBoxButtons.OKCancel); if (result == System.Windows.Forms.DialogResult.Cancel) { return; } if (SIRelation_Records.Count > 0) { SIRelation_Records.ForEach(x => x.Deleted = true); SIRelation_Records.SaveAll(); } if (Identity_Records.Count > 0) { Identity_Records.ForEach(x => x.Deleted = true); Identity_Records.SaveAll(); } InitIdentity(); this.lblMessage.Text = string.Empty; this.lblMessage.Tag = null; this.dgvData.Rows.Clear(); } catch (Exception ex) { MsgBox.Show(ex.Message, "錯誤"); } }
public void BGW_DoWork(object sender, DoWorkEventArgs e) { try { int progress = 10; AccessHelper access = new AccessHelper(); List <UDT.SubjectClassSelection> scsNewList = access.Select <UDT.SubjectClassSelection>(); // 讀取要修改的科目資料 CheckState != Indeterminate List <string> subjectIDList = new List <string>(); foreach (DataGridViewRow dr in dataGridViewX1.Rows) { if ("" + dr.Cells[0].Value != "Indeterminate") { subjectIDList.Add("" + dr.Tag); } } BGW.ReportProgress(progress); // 刪除舊資料(班級選課管理):刪除CheckState != Indeterminate 的資料 string subjectIDs = string.Join(",", subjectIDList); foreach (var _class in classDic) { progress += 40 / classDic.Count; BGW.ReportProgress(progress); List <UDT.SubjectClassSelection> scsOLDList = access.Select <UDT.SubjectClassSelection>("ref_class_id = " + _class.Key + " AND ref_subject_id IN(" + subjectIDs + ")"); access.DeletedValues(scsOLDList); } // 新增資料(班級選課管理):新增CheckState == Checked 的資料 foreach (DataGridViewRow dr in dataGridViewX1.Rows) { progress += 60 / dataGridViewX1.Rows.Count; BGW.ReportProgress(progress); // 勾選的科目 if ("" + dr.Cells[0].Value == "Checked") { // 班級 foreach (var _class in classDic) { UDT.SubjectClassSelection scs = new UDT.SubjectClassSelection(); scs.RefSubjectID = int.Parse("" + dr.Tag); scs.RefClassID = int.Parse(_class.Key); scsNewList.Add(scs); } } } // 儲存新資料 scsNewList.SaveAll(); } catch (Exception ex) { e.Result = ex; } }
private void buttonX1_Click(object xxcxcz, EventArgs zcxzczxce) { string selectValue = comboBoxEx1.Text; if (DevComponents.DotNetBar.MessageBoxEx.Show(selectValue == "" ? "進行分發作業?" : ("進行第" + selectValue + "梯次分發作業?"), "", MessageBoxButtons.OKCancel) == DialogResult.OK) { this.Close(); BackgroundWorker bkw = new BackgroundWorker(); bkw.DoWork += delegate(object sender, DoWorkEventArgs e) { Dictionary <校系資料, int> 配額 = new Dictionary <校系資料, int>(); List <推甄學生資料> 分發對像 = new List <推甄學生資料>(); foreach (var item in 校系資料庫.Items.Values) { 配額.Add(item, item.額); } foreach (var item in _分發學生) { if (item.確定分發結果 && item.分發結果 != null) { 配額[item.分發結果]--; } if (!item.確定分發結果 && ("" + item.梯次) == selectValue) { 分發對像.Add(item); } } Dictionary <校系資料, 推甄學生資料[]> 蘿蔔坑 = new Dictionary <校系資料, 推甄學生資料[]>(); foreach (var item in 配額) { 蘿蔔坑.Add(item.Key, new 推甄學生資料[item.Value]); } 分發對像.取得志願組(); 分發對像.Sort(delegate(推甄學生資料 o1, 推甄學生資料 o2) { return(o1.排名.CompareTo(o2.排名)); }); foreach (var item in 分發對像) { 分發學生(item, 蘿蔔坑); } 分發對像.SaveAll(); e.Result = 分發對像; }; bkw.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e) { MotherForm.SetStatusBarMessage(selectValue == "" ? "分發完成。" : ("第" + selectValue + "梯次分發完成。")); new 統計分發結果(selectValue == "" ? "分發內容" : ("第" + selectValue + "梯次分發內容。"), (List <推甄學生資料>)e.Result).Show(); }; bkw.RunWorkerAsync(); MotherForm.SetStatusBarMessage(selectValue == "" ? "分發中..." : ("第" + selectValue + "梯次分發中...")); } }
private void _bgwSaveData_DoWork(object sender, DoWorkEventArgs e) { try { _TargetEventsList.SaveAll(); } catch (Exception ex) { e.Cancel = true; } }
private void Save_Click(object sender, EventArgs e) { if (this.lblMessage.Tag == null) { return; } if (this.dgvData.Rows.Count > 0 && !Is_Validated()) { return; } try { int identity_id = int.Parse(this.lblMessage.Tag.ToString()); List <UDT.SIRelation> records = Access.Select <UDT.SIRelation>(string.Format("ref_identity_id = {0}", identity_id)); if (records != null && records.Count > 0) { List <UDT.Subject> subjects = Access.Select <UDT.Subject>(string.Format("uid in ({0}) and school_year={1} and semester={2}", string.Join(",", records.Select(x => x.SubjectID)), this.cboSchoolYear.Text, this.cboSemester.Text)); records.ForEach((x) => { if (subjects.Where(y => y.UID == x.SubjectID.ToString()).Count() > 0) { x.Deleted = true; } }); records.SaveAll(); } List <UDT.SIRelation> new_records = new List <UDT.SIRelation>(); foreach (DataGridViewRow row in this.dgvData.Rows) { if (row.IsNewRow) { continue; } UDT.SIRelation record = new UDT.SIRelation(); record.CountLimit = int.Parse(row.Cells["CountLimit"].Value + ""); record.Group = row.Cells["Group"].Value + ""; record.IdentityID = identity_id; record.SubjectID = int.Parse(row.Tag.ToString()); new_records.Add(record); } new_records.SaveAll(); MsgBox.Show("儲存成功。"); } catch (Exception ex) { MsgBox.Show(ex.Message); } }
void iWizard_ImportComplete(object sender, EventArgs e) { if (_ReplaceAll) { foreach (var item in _DeletedItems) { item.Deleted = true; } _DeletedItems.SaveAll(); } 校系資料庫.Sync(); }
private void SaveUDT(UDT.Approach approach) { List <UDT.Approach> records = Access.Select <UDT.Approach>(string.Format("ref_student_id={0}", this._RunningKey)); if (records.Count > 0) { records.ForEach(x => x.Deleted = true); } records.Add(approach); records.SaveAll(); }
/// <summary> /// 透過班級ID調整所屬班級學生ID /// </summary> /// <param name="ClassID"></param> /// <param name="OldClassComment"></param> /// <param name="ClassComment"></param> public static void UpdateUDTClassSepcByClassID(int ClassID, string ClassName, string OldClassComment, string ClassComment) { try { List <string> StudentIDList = new List <string>(); // 取得班級學生ID,學生狀態:一般、休學、中輟 QueryHelper qh = new QueryHelper(); string query = "select id from student where student.status in(1,4,8) and ref_class_id=" + ClassID; DataTable dt = qh.Select(query); foreach (DataRow dr in dt.Rows) { StudentIDList.Add(dr[0].ToString()); } // 取得特殊班學生資料 Dictionary <string, UDT_ClassSpecial> StudSpecDict = GetClassSpecStudentByIDList(StudentIDList); List <UDT_ClassSpecial> StudSpecDataList = new List <UDT_ClassSpecial>(); foreach (string StudID in StudentIDList) { if (StudSpecDict.ContainsKey(StudID)) { StudSpecDict[StudID].OldClassID = StudSpecDict[StudID].ClassID; StudSpecDict[StudID].OldClassComment = StudSpecDict[StudID].ClassComment; StudSpecDict[StudID].OldClassName = StudSpecDict[StudID].ClassName; StudSpecDict[StudID].ClassID = ClassID; StudSpecDict[StudID].ClassName = ClassName; StudSpecDict[StudID].ClassComment = ClassComment; StudSpecDataList.Add(StudSpecDict[StudID]); } else { UDT_ClassSpecial cs = new UDT_ClassSpecial(); cs.StudentID = int.Parse(StudID); cs.ClassID = ClassID; cs.ClassName = ClassName; cs.ClassComment = ClassComment; StudSpecDataList.Add(cs); } } if (StudSpecDataList.Count > 0) { StudSpecDataList.SaveAll(); } }catch (Exception ex) { FISCA.Presentation.Controls.MsgBox.Show("鎖定班級寫入資料發生錯誤," + ex.Message); } }
void iWizard_ImportPackage(object sender, 人申請入學志願選填.ImportLibrary.ImportPackageEventArgs e) { List <校系資料> importItems = new List <校系資料>(); foreach (var row in e.Items) { 校系資料 importData = (row.ID != "") ? 校系資料庫.Items[row["代碼"]] : new 校系資料() { 代碼 = row["代碼"] }; if (_DeletedItems.Contains(importData)) { _DeletedItems.Remove(importData); } foreach (var field in e.ImportFields) { string value = row[field]; switch (field) { default: break; case "校名": importData.校名 = value; break; case "系名": importData.系名 = value; break; case "組別": importData.組別 = value; break; case "名額": importData.額 = int.Parse(value); break; case "網路資訊": importData.網路資訊 = value; break; } } importItems.Add(importData); } importItems.SaveAll(); }
private void btnDelete_Click(object sender, EventArgs e) { List<UDT.StatisticsGroup> StatisticsGroups = new List<UDT.StatisticsGroup>(); if (MessageBox.Show("確定刪除?", "警告", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.Cancel) return; foreach (DataGridViewRow DataGridViewRow in this.dgvData.SelectedRows) { UDT.StatisticsGroup StatisticsGroup = DataGridViewRow.Tag as UDT.StatisticsGroup; StatisticsGroup.Deleted = true; StatisticsGroups.Add(StatisticsGroup); } StatisticsGroups.SaveAll(); this.InitStatisticsGroup(); }
private void buttonX1_Click(object sender, EventArgs e) { string selectValue = comboBoxEx1.Text; bool 結果 = this.checkBoxX1.Checked; this.Close(); foreach (var item in _分發學生) { if (selectValue == "" + item.梯次) { item.確定分發結果 = 結果; } } _分發學生.SaveAll(); }
private void btnSaveAll_Click(object sender, EventArgs e) { List <校系資料> list = new List <校系資料>(); foreach (DataGridViewRow row in dataGridViewX1.Rows) { if (row.IsNewRow) { continue; } list.Add((校系資料)row.Tag); } list.SaveAll(); btnReflash_Click(null, null); }
public void Save(List<string> students) { List<SCAttendExt> scattendRecords = new List<SCAttendExt>(); foreach (string student in students) { SCAttendExt scattendRecord = new SCAttendExt(); scattendRecord.StudentID = int.Parse(student); scattendRecord.CourseID = int.Parse(PrimaryKey); scattendRecord.IsCancel = false; scattendRecords.Add(scattendRecord); } try { List<string> insertedRecordUIDs = scattendRecords.SaveAll(); List<K12.Data.StudentRecord> studentRecords = new List<StudentRecord>(); if (insertedRecordUIDs != null && insertedRecordUIDs.Count > 0) { // 寫入「新增」的 Log List<UDT.SCAttendExt> insertedRecords = Access.Select<UDT.SCAttendExt>(insertedRecordUIDs); Dictionary<string, UDT.SCAttendExt> dicInsertedRecords = new Dictionary<string, SCAttendExt>(); if (insertedRecords.Count > 0) dicInsertedRecords = insertedRecords.ToDictionary(x => x.UID); CourseRecord courseRecord = Course.SelectByID(PrimaryKey); studentRecords = K12.Data.Student.SelectByIDs(insertedRecords.Select(x => x.StudentID.ToString())); Dictionary<string, StudentRecord> dicStudentRecords = new Dictionary<string, StudentRecord>(); if (studentRecords.Count > 0) dicStudentRecords = studentRecords.ToDictionary(x => x.ID); LogSaver logBatch = ApplicationLog.CreateLogSaverInstance(); foreach (string iRecords in dicInsertedRecords.Keys) { UDT.SCAttendExt insertedRecord = dicInsertedRecords[iRecords]; StudentRecord student = dicStudentRecords[insertedRecord.StudentID.ToString()]; StringBuilder sb = new StringBuilder(); sb.Append("學生「" + student.Name + "」,學號「" + student.StudentNumber + "」"); sb.AppendLine("被新增一筆「修課記錄」。"); sb.AppendLine("詳細資料:"); sb.Append("開課「" + courseRecord.Name + "」\n"); logBatch.AddBatch("管理學生修課.新增", "新增", "course", PrimaryKey, sb.ToString()); } logBatch.LogBatch(true); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// 全部班級解鎖(會過濾不自動解鎖) /// </summary> public static void UnlockAllClass() { AccessHelper _AccessHelper = new AccessHelper(); List <UDT_ClassLock> dataList = _AccessHelper.Select <UDT_ClassLock>(); foreach (UDT_ClassLock data in dataList) { // 當不自動解鎖跳過 if (data.UnAutoUnlock) { continue; } data.isLock = false; } dataList.SaveAll(); }
private void frmWishEditor_Load(object sender, EventArgs e) { #region Init SchoolYear、Semester { List <UDT.OpeningTime> listOpenTime = this._access.Select <UDT.OpeningTime>(); if (listOpenTime.Count == 0) { listOpenTime.Add(new UDT.OpeningTime() { SchoolYear = int.Parse(K12.Data.School.DefaultSchoolYear), Semester = int.Parse(K12.Data.School.DefaultSemester) }); listOpenTime.SaveAll(); } cbxSchoolYear.Items.Add(listOpenTime[0].SchoolYear + 1); cbxSchoolYear.Items.Add(listOpenTime[0].SchoolYear); cbxSchoolYear.Items.Add(listOpenTime[0].SchoolYear - 1); cbxSchoolYear.SelectedIndex = 1; cbxSemester.Items.Add(1); cbxSemester.Items.Add(2); cbxSemester.SelectedIndex = listOpenTime[0].Semester - 1; } #endregion #region Init CoursePeriod { ReloadCoursePeriod(cbxSchoolYear.SelectedItem.ToString(), cbxSemester.SelectedItem.ToString()); } #endregion #region Init DataGridView { if (cbxCoursePeriod.Items.Count > 0) { ReloadDataGridView(cbxSchoolYear.SelectedItem.ToString(), cbxSemester.SelectedItem.ToString(), cbxCoursePeriod.SelectedItem.ToString()); } } #endregion this._loading = false; }
private void buttonX1_Click(object sender, EventArgs e) { _AccessHelper.DeletedValues(_MapRecords); _MapRecords.Clear(); AbsenceMapRecord amr; foreach (DataGridViewRow row in dataGridViewX1.Rows) { amr = new AbsenceMapRecord(); amr.absence = "" + row.Cells[0].Value; amr.allow1 = (bool)row.Cells[1].Value == true ? "1" : "0"; amr.allow2 = (bool)row.Cells[2].Value == true ? "1" : "0"; _MapRecords.Add(amr); } _MapRecords.SaveAll(); this.DialogResult = DialogResult.OK; this.Close(); }
public static void Main() { K12.Presentation.NLDPanels.Student.RibbonBarItems["DearDiary"]["addTestData"].Click += delegate { //取得選取學生 var stuList = K12.Data.Student.SelectByIDs(K12.Presentation.NLDPanels.Student.SelectedSource); //多次儲存 foreach (var stuRec in stuList) { var newRec = new DiaryRecord() { RefStudentID = int.Parse(stuRec.ID), Content = "TEST" }; newRec.Save(); } return; //批次儲存 List <DiaryRecord> list = new List <DiaryRecord>(); foreach (var stuRec in stuList) { list.Add(new DiaryRecord() { RefStudentID = int.Parse(stuRec.ID), Content = "TEST" }); } list.SaveAll(); }; K12.Presentation.NLDPanels.Student.RibbonBarItems["DearDiary"]["showDiaryCount"].Click += delegate { var stuList = K12.Data.Student.SelectByIDs(K12.Presentation.NLDPanels.Student.SelectedSource); var message = ""; foreach (var stuRec in stuList) { FISCA.UDT.AccessHelper accessHelper = new FISCA.UDT.AccessHelper(); message += string.Format("{0}:{1}\n", stuRec.Name, accessHelper.Select <DiaryRecord>("ref_student_id=" + stuRec.ID).Count); } System.Windows.Forms.MessageBox.Show(message.TrimEnd()); }; }
private void btnSet_Click(object sender, EventArgs e) { //1. 重設密碼登入,待實作。 //2. 更新資料 try { // update status if (this.targetScoreLock == null) { this.targetScoreLock = new UDT.SubjectScoreLock(); this.targetScoreLock.SchoolYear = (int)this.nudSchoolYear.Value; this.targetScoreLock.Semester = int.Parse(((SemesterItem)this.cboSemester.SelectedItem).Value); } this.targetScoreLock.IsLocked = this.chkIsLocked.Checked; List<ActiveRecord> recs = new List<ActiveRecord>(); recs.Add(this.targetScoreLock); recs.SaveAll(); string msg = string.Format("已 {0} {1} {2} 成績輸入設定。", (this.chkIsLocked.Checked ? "鎖定" : "開放"), this.nudSchoolYear.Value, ((SemesterItem)this.cboSemester.SelectedItem).Name); //log FISCA.LogAgent.ApplicationLog.Log("成績輸入設定", "修改", "", "", msg); Util.ShowMsg(msg, "開放/鎖定成績輸入!"); } catch (Exception ex) { string msg = string.Format("{0} {1} {2} 成績輸入設定時發生錯誤!", (this.chkIsLocked.Checked ? "鎖定" : "開放"), this.nudSchoolYear.Value, ((SemesterItem)this.cboSemester.SelectedItem).Name); Util.ShowMsg("", "開放/鎖定成績輸入!"); } //reload data ... this.GetLockedStatus(); }
private void btnDelete_Click(object sender, EventArgs e) { if (this.dgvData.SelectedRows.Count == 0) { MessageBox.Show("請選取項目(可複選)。"); return; } if (MessageBox.Show("確定刪除?", "警告", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.Cancel) return; List<UDT.CSFaq> CSFaqs = new List<UDT.CSFaq>(); foreach (DataGridViewRow row in this.dgvData.SelectedRows) { UDT.CSFaq CSFaq = row.Tag as UDT.CSFaq; CSFaq.Deleted = true; CSFaqs.Add(CSFaq); } CSFaqs.SaveAll(); this.DGV_DataBinding(); }
private void btnSave_Click(object sender, EventArgs e) { string msg = _cir.CreateBy != FISCA.Authentication.DSAServices.UserAccount ? "注意:您並非此項目的開設者" : ""; if (MessageBox.Show("你是否要進行此操作?\n" + msg, "確認", MessageBoxButtons.OKCancel) == DialogResult.OK) { List <string> log = new List <string>(); int i = 1; foreach (DataGridViewRow row in dataGridViewX1.Rows) { ((CreationItemsParticipateRecord)row.Tag).CanParticipate = row.Cells[5].Value.ToString() == "True" ? true : false; log.Add("" + i + ":年級:" + row.Cells[0].Value + ",班級:" + row.Cells[1].Value + ",座號:" + row.Cells[2].Value + ",姓名:" + row.Cells[3].Value + ",學號:" + row.Cells[4].Value + ",核可:" + (row.Cells[5].Value.ToString() == "True" ? "是" : "否")); i++; } lcipr.SaveAll(); ApplicationLog.Log("服務學習線上開設", "核可作業", "已核可" + dataGridViewX1.Rows.Count + "筆資料\n" + string.Join("\n", log)); this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); } }
private void btnSave_Click(object sender, EventArgs e) { try { btnSave.Enabled = false; List <UDT.HistoricalRecords> ssData = new List <UDT.HistoricalRecords>(); foreach (DataGridViewRow drv in dgData.Rows) { UDT.HistoricalRecords hr = drv.Tag as UDT.HistoricalRecords; if (hr != null) { hr.Rank = null; if (drv.Cells[colRank.Index].Value != null) { int rank; int.TryParse(drv.Cells[colRank.Index].Value.ToString(), out rank); hr.Rank = rank; hr.CreatedBy = _userAccount; } ssData.Add(hr); } } if (ssData.Count > 0) { ssData.SaveAll(); } FISCA.Presentation.Controls.MsgBox.Show("儲存完成"); LoadData(); } catch (Exception ex) { FISCA.Presentation.Controls.MsgBox.Show("儲存失敗," + ex.Message); btnSave.Enabled = true; return; } finally { } }
private void RemoveSSAttend_Click(object sender, EventArgs e) { ComboItem item = (ComboItem)this.cboSelectableSubject.SelectedItem; if (item.Tag == null) { return; } int subject_id = int.Parse(item.Tag.ToString()); List <UDT.SSAttend> records = Access.Select <UDT.SSAttend>(string.Format("ref_subject_id = {0}", subject_id)); if (records == null || records.Count == 0) { return; } List <UDT.SSAttend> dRecords = new List <UDT.SSAttend>(); foreach (DataGridViewRow row in this.dgvSelectedStudent.SelectedRows) { int student_id = int.Parse(row.Tag.ToString()); List <UDT.SSAttend> filterRecords = records.Where(x => x.StudentID == student_id).ToList(); filterRecords.ForEach((x) => { x.Deleted = true; dRecords.Add(x); }); if (this.dicSSAttends.ContainsKey(student_id + "-" + subject_id)) { this.dicSSAttends.Remove(student_id + "-" + subject_id); } } dRecords.SaveAll(); InitSSAttend(subject_id); InitNonSSAttend(subject_id); }
private void buttonX1_Click(object sender, EventArgs e) { _AccessHelper.DeletedValues(_MapRecords); _MapRecords.Clear(); MapRecord mr; foreach (DataGridViewRow row in dataGridView1.Rows) { if (string.IsNullOrWhiteSpace("" + row.Cells["student_tag"].Value)) { continue; } mr = new MapRecord(); mr.student_tag = "" + row.Cells["student_tag"].Value; mr.code1 = "" + row.Cells["code1"].Value; mr.code2 = "" + row.Cells["code2"].Value; mr.note = "" + row.Cells["note"].Value; _MapRecords.Add(mr); } _MapRecords.SaveAll(); this.Close(); }
private void TurnIntoCourseStudent_Load(object sender, EventArgs e) { #region Init SchoolYearLb、SemesterLb { List <UDT.OpeningTime> timeList = access.Select <UDT.OpeningTime>(); if (timeList.Count == 0) { timeList.Add(new UDT.OpeningTime() { SchoolYear = int.Parse(K12.Data.School.DefaultSchoolYear), Semester = int.Parse(K12.Data.School.DefaultSemester) }); timeList.SaveAll(); } schoolYearCbx.Items.Add(timeList[0].SchoolYear + 1); schoolYearCbx.Items.Add(timeList[0].SchoolYear); schoolYearCbx.Items.Add(timeList[0].SchoolYear - 1); schoolYearCbx.SelectedIndex = 1; semesterCbx.Items.Add(1); semesterCbx.Items.Add(2); if ("" + timeList[0].Semester == "1") { semesterCbx.SelectedIndex = 0; } if ("" + timeList[0].Semester == "2") { semesterCbx.SelectedIndex = 1; } } #endregion initFinish = true; ReloadCourseTypeCbx(); }
private void 選填志願毛毛蟲_SaveButtonClick(object sender, EventArgs e) { foreach (Node node in advTree1.Nodes) { node.EndEdit(false); } int wishOrder = 1; foreach (var item in list) { item.Deleted = true; } foreach (Node node in advTree1.Nodes) { if (node == InsertNode) { continue; //空結點當沒看到,就算你給我搬到最上面還是沒看到,反正就是沒看到,拉拉拉拉拉..... } foreach (var item in 校系資料庫.Items.Values) { if (item.ToString() == node.Cells[0].Text) { list.Add( new 志願() { StudentRecord = K12.Data.Student.SelectByID(PrimaryKey), 志願排序 = wishOrder++, 校系資料 = item, 忽略 = node.Cells[1].Checked, 忽略原因 = node.Cells[2].Text }); } } } list.SaveAll(); this.選填志願毛毛蟲_PrimaryKeyChanged(null, null); }
private void Save_Click(object sender, EventArgs e) { if (MessageBox.Show("確定發佈?若您選擇「確定」,「選課結果」將加入至「學生修課」。若不確定,請按「取消」。", "警告", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.Cancel) return; this.circularProgress.IsRunning = true; this.circularProgress.Visible = true; int item = 2; try { Task task = Task.Factory.StartNew(() => { List<UDT.CSAttendSnapshot> CSAttendSnapshots = Access.Select<UDT.CSAttendSnapshot>(string.Format("school_year = {0} and semester = {1} and item = {2}", this.SchoolYear, this.Semester, item)); if (CSAttendSnapshots.Count == 0) throw new Exception("無資料可發佈。"); List<UDT.SCAttendExt> SCAttendExts = new List<UDT.SCAttendExt>(); DataTable dataTable = Query.Select(string.Format("select se.uid, se.ref_student_id, se.ref_course_id, se.report_group, se.is_cancel, se.seat_x, se.seat_y from $ischool.emba.scattend_ext as se join course on course.id=se.ref_course_id where course.school_year={0} and course.semester={1}", this.SchoolYear, this.Semester)); List<string> oSCAttendExts = new List<string>(); foreach (DataRow row in dataTable.Rows) { string key = row["ref_student_id"] + "-" + row["ref_course_id"]; oSCAttendExts.Add(key); } Dictionary<string, UDT.CSAttendSnapshot> dicCSAttendSnapshots = new Dictionary<string, UDT.CSAttendSnapshot>(); foreach(UDT.CSAttendSnapshot CSAttendSnapshot in CSAttendSnapshots) { string key = CSAttendSnapshot.StudentID + "-" + CSAttendSnapshot.CourseID; if (!oSCAttendExts.Contains(key)) { UDT.SCAttendExt SCAttendExt = new UDT.SCAttendExt(); SCAttendExt.CourseID = CSAttendSnapshot.CourseID; SCAttendExt.StudentID = CSAttendSnapshot.StudentID; SCAttendExts.Add(SCAttendExt); } } SCAttendExts.SaveAll(); }); task.ContinueWith((x) => { this.circularProgress.IsRunning = false; this.circularProgress.Visible = false; if (x.Exception != null) MessageBox.Show(x.Exception.InnerException.Message); else MessageBox.Show("發佈完成。"); }, System.Threading.CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext()); } catch (Exception ex) { this.circularProgress.IsRunning = false; this.circularProgress.Visible = false; MessageBox.Show(ex.Message); return; } }
private void btnSet_Click(object sender, EventArgs e) { if (!this.Is_Validated()) { MessageBox.Show("請修正錯誤再儲存。"); return; } this.btnSet.Enabled = false; List<UDT.AssignedSurvey> AssignedSurveys = new List<UDT.AssignedSurvey>(); foreach (DataGridViewRow row in this.dgvData.Rows) { if (row.IsNewRow) continue; //if (row.Cells[5].Tag == null) // continue; string SurveyID = row.Cells[5].Value + ""; int course_id = int.Parse(row.Cells[0].Tag + ""); int teacher_id = int.Parse(row.Cells[1].Tag + ""); UDT.AssignedSurvey AssignedSurvey = row.Tag as UDT.AssignedSurvey; if (AssignedSurvey == null) AssignedSurvey = new UDT.AssignedSurvey(); if (string.IsNullOrEmpty(SurveyID)) AssignedSurvey.Deleted = true; else { AssignedSurvey.CourseID = course_id; AssignedSurvey.TeacherID = teacher_id; AssignedSurvey.SurveyID = int.Parse(SurveyID); AssignedSurvey.OpeningTime = DateTime.Parse((row.Cells[3].Value + "").Trim()); AssignedSurvey.EndTime = DateTime.Parse((row.Cells[4].Value + "").Trim()); AssignedSurvey.Description = (row.Cells[6].Value + "").Trim(); } AssignedSurveys.Add(AssignedSurvey); } AssignedSurveys.SaveAll(); // 問卷組態 AssignedSurveys = Access.Select<UDT.AssignedSurvey>(); this.dicAssignedSurveys.Clear(); foreach (UDT.AssignedSurvey AssegnedSurvey in AssignedSurveys) { if (!this.dicAssignedSurveys.ContainsKey(AssegnedSurvey.CourseID + "-" + AssegnedSurvey.TeacherID)) this.dicAssignedSurveys.Add(AssegnedSurvey.CourseID + "-" + AssegnedSurvey.TeacherID, AssegnedSurvey); } this.btnSet.Enabled = true; MsgBox.Show("儲存成功。"); if (this.cboCourse.SelectedIndex == -1) return; ComboItem item = this.cboCourse.Items[this.cboCourse.SelectedIndex] as ComboItem; this.DGV_DataBinding(item); }
private void WriteChongTongCourse(decimal school_year, string semester, List<CourseSection> CourseSections) { if (CourseSections.Count == 0) return; string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" }; List<UDT.ConflictCourse> conflict_courses = new List<UDT.ConflictCourse>(); Dictionary<int, Dictionary<string, List<CourseSection>>> dicCourseSections = new Dictionary<int, Dictionary<string, List<CourseSection>>>(); Dictionary<int, CourseSection> dicCourseIDs = new Dictionary<int, CourseSection>(); CourseSections.ForEach((x) => { if (!dicCourseIDs.ContainsKey(x.CourseID)) dicCourseIDs.Add(x.CourseID, x); }); CourseSections.ForEach((x) => { if (!dicCourseSections.ContainsKey(x.CourseID)) dicCourseSections.Add(x.CourseID, new Dictionary<string,List<CourseSection>>()); if (!dicCourseSections[x.CourseID].ContainsKey(x.BeginTime.ToShortDateString())) dicCourseSections[x.CourseID].Add(x.BeginTime.ToShortDateString(), new List<CourseSection>()); dicCourseSections[x.CourseID][x.BeginTime.ToShortDateString()].Add(x); }); foreach (int CourseID in dicCourseSections.Keys) { foreach (string date in dicCourseSections[CourseID].Keys) { CourseSection A = dicCourseIDs[CourseID]; Dictionary<int, List<CourseSection>> dicBs = new Dictionary<int, List<CourseSection>>(); foreach (CourseSection x in dicCourseSections[CourseID][date]) { List<CourseSection> ChongTongCourseSections = CourseSections.Where(y => (y.SubjectID != x.SubjectID && y.CourseID != x.CourseID && x.BeginTime.ToShortDateString() == y.BeginTime.ToShortDateString())).Where(y => ((x.BeginTime <= y.BeginTime && x.EndTime >= y.EndTime) || (x.BeginTime >= y.BeginTime && x.BeginTime <= y.EndTime) || (x.EndTime >= y.BeginTime && x.EndTime <= y.EndTime))).ToList(); foreach (CourseSection cs in ChongTongCourseSections) { if (!dicBs.ContainsKey(cs.CourseID)) dicBs.Add(cs.CourseID, new List<CourseSection>()); dicBs[cs.CourseID].Add(cs); } } foreach (int course_id in dicBs.Keys) { UDT.ConflictCourse conflict_course = new UDT.ConflictCourse(); CourseSection B = dicBs[course_id].ElementAt(0); DateTime begin_time = DateTime.MaxValue; DateTime end_time = DateTime.MinValue; if (dicBs[course_id].Min(y => y.BeginTime) < begin_time) begin_time = dicBs[course_id].Min(y => y.BeginTime); if (dicBs[course_id].Max(y => y.EndTime) > end_time) end_time = dicBs[course_id].Max(y => y.EndTime); //if (A.CourseID != 649) // continue; conflict_course.SchoolYear = A.SchoolYear; conflict_course.Semester = A.Semester; conflict_course.CourseID_A = A.CourseID; conflict_course.CourseName_A = A.CourseName; conflict_course.CourseID_B = B.CourseID; conflict_course.CourseName_B = B.CourseName; conflict_course.ConflictDate = date; conflict_course.ConflictWeek = Day[Convert.ToInt16(DateTime.Parse(date).DayOfWeek)]; conflict_course.IsSameSubject = false; conflict_course.ConflictTime = begin_time.ToString("HH:mm") + "~" + end_time.ToString("HH:mm"); conflict_courses.Add(conflict_course); } } } conflict_courses.SaveAll(); }
private void btnSet_Click(object sender, EventArgs e) { this.circularProgress.IsRunning = true; this.circularProgress.Visible = true; this.btnSet.Enabled = false; int school_year = int.Parse(this.nudSchoolYear.Value + ""); int semester = int.Parse((this.cboSemester.SelectedItem as DataItems.SemesterItem).Value); List<dynamic> backup_lists = new List<dynamic>(); foreach (DataGridViewRow row in this.dgvData.Rows) { if (!row.Selected) continue; dynamic o = new ExpandoObject(); dynamic oo = row.Tag as dynamic; o.CourseName = row.Cells[0].Value + ""; o.CourseID = row.Cells[0].Tag + ""; o.TeacherID = row.Cells[3].Tag + ""; o.TeacherName = row.Cells[3].Value + ""; o.SubjectCode = row.Cells[1].Value + ""; o.NewSubjectCode = row.Cells[2].Value + ""; o.TotalNo = row.Cells[6].Value + ""; o.FillNo = row.Cells[7].Value + ""; o.SubjectName = oo.SubjectName; o.ClassName = oo.ClassName; o.Status = row.Cells[8].Value + ""; o.SubjectID = row.Cells[1].Tag + ""; DateTime survey_date_begin = DateTime.Today; DateTime survey_date_end = DateTime.Today; List<string> survey_dates = new List<string>(); if (DateTime.TryParse(row.Cells[4].Value + "", out survey_date_begin)) survey_dates.Add(survey_date_begin.ToShortDateString()); if (DateTime.TryParse(row.Cells[5].Value + "", out survey_date_end)) survey_dates.Add(survey_date_end.ToShortDateString()); survey_dates = survey_dates.Distinct().ToList(); o.SurveyDate = string.Join("~", survey_dates); backup_lists.Add(o); } Task task = Task.Factory.StartNew(()=> { List<UDT.Reply> Replys = Access.Select<UDT.Reply>("status = 1"); List<UDT.TeacherStatistics> TeacherStatistics = Access.Select<UDT.TeacherStatistics>(); Dictionary<string, UDT.TeacherStatistics> dicTeacherStatistics = new Dictionary<string, UDT.TeacherStatistics>(); if (TeacherStatistics.Count > 0) dicTeacherStatistics = TeacherStatistics.ToDictionary(x => x.CourseID + "-" + x.TeacherID + "-" + x.SchoolYear + "-" + x.Semester); List<UDT.TeacherStatistics> nTeacherStatistics = new List<UDT.TeacherStatistics>(); foreach (dynamic o in backup_lists) { //if (o.Status == "無效") // continue; BusinessLogic.TeacherStatistics cTeacherStatistics = new BusinessLogic.TeacherStatistics(o.CourseID, o.TeacherID); bool can_save = false; if (cTeacherStatistics.Survey == null) continue; cTeacherStatistics.SchoolYear = school_year.ToString(); cTeacherStatistics.Semester = semester.ToString(); cTeacherStatistics.CourseName = o.CourseName; cTeacherStatistics.SubjectName = o.SubjectName; cTeacherStatistics.ClassName = o.ClassName; cTeacherStatistics.TeacherName = o.TeacherName; cTeacherStatistics.SubjectCode = o.SubjectCode; cTeacherStatistics.NewSubjectCode = o.NewSubjectCode; cTeacherStatistics.FeedBackCount = o.FillNo; cTeacherStatistics.CSAttendCount = o.TotalNo; cTeacherStatistics.CourseID = o.CourseID; cTeacherStatistics.SubjectID = o.SubjectID; cTeacherStatistics.TeacherID = o.TeacherID; cTeacherStatistics.SurveyDate = o.SurveyDate; foreach (UDT.Reply Reply in Replys) { if (Reply.SurveyID.ToString() != cTeacherStatistics.Survey.uSurvey.UID || Reply.CourseID.ToString() != o.CourseID || Reply.TeacherID.ToString() != o.TeacherID) continue; cTeacherStatistics.SetAnswer(Reply.Answer); can_save = true; } string Statistics_List = cTeacherStatistics.ToString(); string key = o.CourseID + "-" + o.TeacherID; UDT.TeacherStatistics oTeacherStatistic = new UDT.TeacherStatistics(); if (dicTeacherStatistics.ContainsKey(key + "-" + school_year + "-" + semester)) oTeacherStatistic = dicTeacherStatistics[key + "-" + school_year + "-" + semester]; oTeacherStatistic.CourseID = int.Parse(o.CourseID); oTeacherStatistic.TeacherID = int.Parse(o.TeacherID); oTeacherStatistic.SchoolYear = school_year; oTeacherStatistic.Semester = semester; oTeacherStatistic.StatisticsList = Statistics_List; oTeacherStatistic.TimeStamp = DateTime.Now; if (can_save) nTeacherStatistics.Add(oTeacherStatistic); } nTeacherStatistics.SaveAll(); }); task.ContinueWith((y) => { if (y.Exception != null) { MessageBox.Show(y.Exception.InnerException.Message); goto TheEnd; } this.DGV_DataBinding(); MessageBox.Show("計算完畢。"); TheEnd: this.circularProgress.IsRunning = false; this.circularProgress.Visible = false; this.btnSet.Enabled = true; }, System.Threading.CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext()); }
public override string ProcessRequest(int Year, Dictionary<string, Dictionary<string, string>> Data) { if (Year != 102 && this.successor != null) { return this.successor.ProcessRequest(Year, Data); } else { StringBuilder strLog = new StringBuilder(); List<UDT.Approach> ExistingRecords = new List<UDT.Approach>(); AccessHelper Access = new AccessHelper(); strLog.AppendLine("詳細資料:"); ExistingRecords = Access.Select<UDT.Approach>(); // 要新增的 Record List<UDT.Approach> insertRecords = new List<UDT.Approach>(); // 要更新的 Record List<UDT.Approach> updateRecords = new List<UDT.Approach>(); foreach (string key in Data.Keys) { //string id_number = Data[key]["身分證號"].Trim(); string q1_string = Data[key]["升學與就業情形"].Trim(); string q2_string = Data[key]["升學:就讀學校情形"].Trim(); string q3_string = Data[key]["升學:學制別"].Trim(); string q4_string = Data[key]["升學:入學方式"].Trim(); string q5_string = Data[key]["未升學未就業:動向"].Trim(); string q6_string = Data[key]["是否需要教育部協助"].Trim().Replace("1", "是").Replace("2", "否"); string memo = Data[key]["備註"].Trim(); strLog.AppendLine("填報學年度「" + Year + "」升學與就業情形「" + q1_string + "」升學:就讀學校情形「" + q2_string + "」升學:學制別「" + q3_string + "」升學:入學方式「" + q4_string + "」未升學未就業:動向「" + q5_string + "」是否需要教育部協助「" + q6_string + "」備註「" + memo + "」"); int q2_int; int q3_int; int q4_int; int q5_int; int student_id = int.Parse(key); UDT.Approach record = new UDT.Approach(); IEnumerable<UDT.Approach> filterRecords = new List<UDT.Approach>(); filterRecords = ExistingRecords.Where(x => x.StudentID == student_id); if (filterRecords.Count() > 0) { record = filterRecords.OrderByDescending(x => x.LastUpdateTime).ElementAt(0); updateRecords.Add(record); } else { insertRecords.Add(record); } int q1 = int.Parse(q1_string); record.StudentID = student_id; record.SurveyYear = Year; record.Q1 = q1; if (int.TryParse(q2_string, out q2_int)) record.Q2 = q2_int; else record.Q2 = null; if (int.TryParse(q3_string, out q3_int)) record.Q3 = q3_int; else record.Q3 = null; if (int.TryParse(q4_string, out q4_int)) record.Q4 = q4_int; else record.Q4 = null; if (int.TryParse(q5_string, out q5_int)) record.Q5 = q5_int; else record.Q5 = null; record.Q6 = q6_string; record.Memo = memo; record.LastUpdateTime = DateTime.Now; } // 新增 List<string> insertedIDs = new List<string>(); try { insertedIDs = insertRecords.SaveAll(); } catch (System.Exception e) { System.Windows.Forms.MessageBox.Show(e.Message); return e.Message; } // 更新 List<string> updatedIDs = new List<string>(); try { updatedIDs = updateRecords.SaveAll(); } catch (System.Exception e) { System.Windows.Forms.MessageBox.Show(e.Message); return e.Message; } // RaiseEvent if (insertedIDs.Count > 0 || updatedIDs.Count > 0) { //IEnumerable<string> uids = insertedIDs.Union(updatedIDs); UDT.Approach.RaiseAfterUpdateEvent(); } ApplicationLog.Log("高雄市國中畢業學生進路調查", "登錄畢業學生進路", "student", "", strLog.ToString()); return "儲存成功。"; } }
private void btnFilter_Click(object sender, EventArgs e) { uint capacity = 0; if (uint.TryParse(txtCapacity.Text.Trim(), out capacity)) { if (capacity == 0) { MessageBox.Show("人數上限為 0,無法自動篩汰學生。"); return; } else { uint locked_no = 0; uint total_no = 0; foreach (DataGridViewRow row in this.dgvData.Rows) { if (row.DefaultCellStyle.BackColor != System.Drawing.Color.Pink) { total_no += 1; bool manual = false; bool period1 = false; if ((bool.TryParse(row.Cells["colManual"].Value + "", out manual) && manual) || (bool.TryParse(row.Cells["colPeriod1"].Value + "", out period1) && period1)) locked_no += 1; } } if (capacity >= total_no) { MessageBox.Show("選課人數未超過人數上限,不需篩汰學生。"); return; } else { if (locked_no > capacity) { MessageBox.Show("「手動優先人數」+「第一階段選上人數」大於人數上限,無法自動篩汰學生。"); return; } else { this.DisableButtons(); uint delete_no = total_no - capacity; List<DataGridViewRow> locked_rows_evaluation = new List<DataGridViewRow>(); List<DataGridViewRow> locked_rows_condition = new List<DataGridViewRow>(); List<DataGridViewRow> locked_rows_condition_evaluation = new List<DataGridViewRow>(); List<DataGridViewRow> deleted_rows = new List<DataGridViewRow>(); List<DataGridViewRow> locked_rows = new List<DataGridViewRow>(); List<DataGridViewRow> no_locked_rows = new List<DataGridViewRow>(); foreach (DataGridViewRow row in this.dgvData.Rows) { if (row.DefaultCellStyle.BackColor == System.Drawing.Color.Pink) { deleted_rows.Add(row); continue; } bool locked_evaluation = false; bool locked_condition = false; bool manual = false; bool period1 = false; bool.TryParse(row.Cells["colManual"].Value + "", out manual); bool.TryParse(row.Cells["colPeriod1"].Value + "", out period1); bool.TryParse(row.Cells["chkEvaluation"].Value + "", out locked_evaluation); bool.TryParse(row.Cells["chkLock"].Value + "", out locked_condition); if (manual || period1) continue; if (!locked_evaluation && !locked_condition) no_locked_rows.Add(row); if (!locked_condition && locked_evaluation) locked_rows_evaluation.Add(row); if (locked_condition && !locked_evaluation) locked_rows_condition.Add(row); if (locked_condition && locked_evaluation) locked_rows_condition_evaluation.Add(row); } // 重排「no_locked_rows」索引號 List<int> OrderedArray_no_locked = RandomOrder(Enumerable.Range(0, no_locked_rows.Count).ToList()); // 重排「locked_rows_evaluation」索引號 List<int> OrderedArray_evaluation = RandomOrder(Enumerable.Range(0, locked_rows_evaluation.Count).ToList()); // 重排「locked_rows_condition」索引號 List<int> OrderedArray_condition = RandomOrder(Enumerable.Range(0, locked_rows_condition.Count).ToList()); // 重排「locked_rows_condition_evaluation」索引號 List<int> OrderedArray_condition_evaluation = RandomOrder(Enumerable.Range(0, locked_rows_condition_evaluation.Count).ToList()); // 待移除資料 List<DataGridViewRow> will_delete_rows = new List<DataGridViewRow>(); // 先移除沒有任何勾選 for (int i = 0; i < OrderedArray_no_locked.Count; i++) { will_delete_rows.Add(no_locked_rows.ElementAt(OrderedArray_no_locked.ElementAt(i))); } // 再移除選課優先 for (int i = 0; i < OrderedArray_evaluation.Count; i++) { will_delete_rows.Add(locked_rows_evaluation.ElementAt(OrderedArray_evaluation.ElementAt(i))); } // 再移除條件優先 for (int i = 0; i < OrderedArray_condition.Count; i++) { will_delete_rows.Add(locked_rows_condition.ElementAt(OrderedArray_condition.ElementAt(i))); } // 最後移除選課優先+條件優先 for (int i = 0; i < OrderedArray_condition_evaluation.Count; i++) { will_delete_rows.Add(locked_rows_condition_evaluation.ElementAt(OrderedArray_condition_evaluation.ElementAt(i))); } // 寫入自動篩汰資料 string CourseID = this.groupPanel1.Tag + ""; decimal school_year = this.nudSchoolYear.Value; string semester = (this.cboSemester.SelectedItem as DataItems.SemesterItem).Value; List<UDT.CSAttend> CSAttends = Access.Select<UDT.CSAttend>(string.Format("ref_course_id={0}", CourseID)); Dictionary<int, UDT.CSAttend> dicCSAttends = new Dictionary<int, UDT.CSAttend>(); if (CSAttends.Count > 0) { CSAttends.ForEach((x) => { if (!dicCSAttends.ContainsKey(x.StudentID)) dicCSAttends.Add(x.StudentID, x); }); } List<UDT.CSAttend> CSAttend_Deleteds = new List<UDT.CSAttend>(); List<UDT.CSAttendLog> CSAttendLogs = new List<UDT.CSAttendLog>(); // 開始移除「will_delete_rows」的元素 for (int i = 0; i<delete_no; i++) { DataGridViewRow row = will_delete_rows.ElementAt(i); int StudentID = int.Parse(row.Cells["lblStudentID"].Value + ""); if (dicCSAttends.ContainsKey(StudentID)) { UDT.CSAttend CSAttend = dicCSAttends[StudentID]; UDT.CSAttendLog CSAttendLog = new UDT.CSAttendLog(); CSAttend.Deleted = true; CSAttendLog.StudentID = StudentID; CSAttendLog.CourseID = int.Parse(CourseID); CSAttendLog.SchoolYear = int.Parse(school_year.ToString()); CSAttendLog.Semester = int.Parse(semester); CSAttendLog.Item = this.item; CSAttendLog.Action = "delete"; CSAttendLog.ActionBy = "staff"; CSAttendLogs.Add(CSAttendLog); CSAttend_Deleteds.Add(CSAttend); } } CSAttend_Deleteds.SaveAll(); CSAttendLogs.SaveAll(); this.InitCSAttend(CourseID); if (this.chkShowLog.Checked) this.AppendCSAttendLog(CourseID); this.EnableButtons(); } } } } else { MessageBox.Show("人數上限必須為正整數。"); return; } }
private void pay_btn_Click(object sender, EventArgs e) { MotherForm.SetStatusBarMessage("校車對帳資料產生中...."); #region 對帳 Payment.Balance(); #endregion AccessHelper udtHelper = new AccessHelper(); List<NewStudentRecord> students = udtHelper.Select<NewStudentRecord>("學年度='" + this.cboYear.Text + "'"); List<string> newStudentIDList = new List<string>(); //List<string> newStudentNumberList = new List<string>(); int nowSet = 0; foreach (NewStudentRecord var in students) { MotherForm.SetStatusBarMessage("正在讀取校車資料庫", nowSet++ * 10 / students.Count); if (!newStudentIDList.Contains(var.UID)) { newStudentIDList.Add(var.UID); //newStudentNumberList.Add(var.Number); } } List<PaymentDetail> Studentdetails = PaymentDetail.GetByTarget("NewStudent", newStudentIDList); //List<PaymentDetail> Studentdetails = PaymentDetail.GetAll(); List<StudentByBus> _Source = new List<StudentByBus>(); List<StudentByBus> StudentByBuses = StudentByBusDAO.SelectByBusYearAndTimeNameAndStudntList(int.Parse(this.cboYear.Text), this.cboRange.Text, newStudentIDList); Dictionary<string, StudentByBus> EveryStudentByBuses = new Dictionary<string,StudentByBus>(); nowSet = 0; foreach (StudentByBus var in StudentByBuses) { MotherForm.SetStatusBarMessage("正在讀取校車資料庫", 10 + nowSet++ * 40 / StudentByBuses.Count); if (!EveryStudentByBuses.ContainsKey(var.StudentID)) EveryStudentByBuses.Add(var.StudentID, var); } DateTime day; nowSet = 0; foreach (PaymentDetail pd in Studentdetails) { MotherForm.SetStatusBarMessage("正在更新校車資料庫", 50 + nowSet++ * 50 / Studentdetails.Count); //List<StudentByBus> StudentByBuses = StudentByBusDAO.SelectByStudntID(pd.Extensions["MergeField::學號"]); if (!EveryStudentByBuses.ContainsKey(pd.RefTargetID)) continue; StudentByBus sbb = EveryStudentByBuses[pd.RefTargetID]; //if (pd.Extensions["MergeField::學號"] == "39002" || pd.Extensions["MergeField::學號"] == "39001") // nowSet = nowSet; if (sbb.PayStatus == true) continue; pd.FillHistories(); IList<PaymentHistory> historyss = pd.Histories; foreach (PaymentHistory history in historyss) { if (history.Receipt.Cancelled) { if (DateTime.TryParse(history.PayDate.ToString(), out day)) { //foreach (StudentByBus sbb in StudentByBuses) //{ if (sbb.SchoolYear == int.Parse(pd.Extensions["校車收費年度"]) && sbb.BusRangeName == pd.Extensions["校車收費名稱"]) { if (sbb.comment != "改單:原為" + history.Receipt.Extensions["MergeField::代碼"] + " " + history.Receipt.Extensions["MergeField::站名"] + ",金額為" + history.Receipt.Amount) { sbb.PayStatus = true; sbb.PayDate = DateTime.Parse(history.PayDate.ToString()); sbb.comment += "改單:原為" + history.Receipt.Extensions["MergeField::代碼"] + " " + history.Receipt.Extensions["MergeField::站名"] + ",金額為" + history.Receipt.Amount; _Source.Add(sbb); } break; } //} } else continue; } else { if (DateTime.TryParse(history.PayDate.ToString(), out day)) { //foreach (StudentByBus sbb in StudentByBuses) //{ if (sbb.SchoolYear == int.Parse(pd.Extensions["校車收費年度"]) && sbb.BusRangeName == pd.Extensions["校車收費名稱"]) { if (sbb.PayStatus == false || sbb.PayDate != DateTime.Parse(history.PayDate.ToString())) { sbb.PayStatus = true; sbb.PayDate = DateTime.Parse(history.PayDate.ToString()); if (history.Receipt.PaidAmount != sbb.BusMoney) sbb.comment = "繳費金額為" + history.Receipt.PaidAmount.ToString(); _Source.Add(sbb); } break; } //} } else continue; } } } if (_Source.Count > 0) _Source.SaveAll(); MotherForm.SetStatusBarMessage("校車對帳資料完成", 100); MessageBox.Show("已新增 " + _Source.Count + " 筆記錄,校車對帳資料完成!"); }
static void iWizardBusStop_ImportPackage(object sender, ImportLibrary.ImportPackageEventArgs e) { List<Data.BusStop> importItems = new List<Data.BusStop>(); foreach (var row in e.Items) { Data.BusStop importData = (row.ID != "") ? 檢查校車站名資料庫[row.ID] : new Data.BusStop(); if (_DeletedBusStops.Contains(importData)) _DeletedBusStops.Remove(importData); foreach (var field in e.ImportFields) { string value = row[field]; switch (field) { default: break; case "校車時段": importData.BusTimeName = value; break; case "代碼": importData.BusStopID = value; break; case "站名": importData.BusStopName = value; break; case "月費": if (value.Length > 0) importData.BusMoney = int.Parse(value); else importData.BusMoney = 0; break; case "車號": importData.BusNumber = value; break; case "站序": importData.BusStopNo = value; break; case "停車地址": importData.BusStopAddr = value; break; case "到站時間": importData.ComeTime = value; break; case "放學上車地點": importData.BusUpAddr = value; break; } } importItems.Add(importData); } importItems.SaveAll(); }
public override string Import(List<EMBA.DocumentValidator.IRowStream> Rows) { IEnumerable<SubjectSemesterScore> allSubjectSemesterScoreRecords = Access.Select<SubjectSemesterScore>(); // 要新增的 SubjectSemesterScoreRecord List<SubjectSemesterScore> insertRecords = new List<SubjectSemesterScore>(); // 要更新的 SubjectSemesterScoreRecord List<SubjectSemesterScore> updateRecords = new List<SubjectSemesterScore>(); foreach (IRowStream row in Rows) { SubjectSemesterScore record = new SubjectSemesterScore(); string subject_code = row.GetValue("課程識別碼").Trim(); string new_subject_code = row.GetValue("課號").Trim(); string subject_name = row.GetValue("課程名稱").Trim(); string school_year = row.GetValue("學年度").Trim(); string semester = row.GetValue("學期").Trim(); string student_number = row.GetValue("學號").Trim(); string class_name = string.Empty; string course_id = string.Empty; string studentID = dicStudent_Numbers[student_number.ToUpper()]; IEnumerable<SubjectSemesterScore> filterRecords = new List<SubjectSemesterScore>(); if (keyField == "課程識別碼") { // 鍵值為:學年度+學期+學號+課程識別碼 filterRecords = allSubjectSemesterScoreRecords.Where(x => (x.SchoolYear.HasValue ? x.SchoolYear.Value.ToString() : "").Trim() == (string.IsNullOrEmpty(school_year) ? "" : int.Parse(school_year).ToString())).Where(x => (x.Semester.HasValue ? x.Semester.ToString() : "").Trim() == (string.IsNullOrEmpty(semester) ? "" : int.Parse(semester).ToString())).Where(x => x.SubjectCode.Trim().ToUpper() == subject_code.ToUpper()).Where(x => x.StudentID.ToString() == dicStudent_Numbers[student_number.ToUpper()]); } else { // 鍵值為:學年度+學期+學號+課號 filterRecords = allSubjectSemesterScoreRecords.Where(x => (x.SchoolYear.HasValue ? x.SchoolYear.Value.ToString() : "").Trim() == (string.IsNullOrEmpty(school_year) ? "" : int.Parse(school_year).ToString())).Where(x => (x.Semester.HasValue ? x.Semester.ToString() : "").Trim() == (string.IsNullOrEmpty(semester) ? "" : int.Parse(semester).ToString())).Where(x => x.NewSubjectCode.Trim().ToUpper() == new_subject_code.ToUpper()).Where(x => x.StudentID.ToString() == dicStudent_Numbers[student_number.ToUpper()]); } if (filterRecords.Count() > 0) record = filterRecords.ElementAt(0); if (mOption.SelectedFields.Contains("等第成績") && !string.IsNullOrWhiteSpace(row.GetValue("等第成績"))) record.Score = row.GetValue("等第成績").Trim(); int intSchoolyear = 0; int.TryParse(school_year, out intSchoolyear); if (!string.IsNullOrEmpty(school_year)) record.SchoolYear = intSchoolyear; int intSemester = 0; int.TryParse(semester, out intSemester); if (!string.IsNullOrEmpty(semester)) record.Semester = intSemester; // 「開課」系統編號暫不寫入 //record.CourseID = int.Parse(filterDataRows.ElementAt(0)["course_id"] + ""); if (mOption.SelectedFields.Contains("學分數") && !string.IsNullOrWhiteSpace(row.GetValue("學分數"))) record.Credit = int.Parse(row.GetValue("學分數").Trim()); if (mOption.SelectedFields.Contains("取得學分") && !string.IsNullOrWhiteSpace(row.GetValue("取得學分"))) record.IsPass = (row.GetValue("取得學分").Trim() == "是" ? true : false); if (mOption.SelectedFields.Contains("必選修") && !string.IsNullOrWhiteSpace(row.GetValue("必選修"))) record.IsRequired = (row.GetValue("必選修") == "必修" ? true : false); if (keyField == "課號") { record.NewSubjectCode = new_subject_code; if (mOption.SelectedFields.Contains("課程識別碼") && !string.IsNullOrEmpty(subject_code)) record.SubjectCode = subject_code; } else { record.SubjectCode = subject_code; if (mOption.SelectedFields.Contains("課號") && !string.IsNullOrEmpty(new_subject_code)) record.NewSubjectCode = new_subject_code; } if (mOption.SelectedFields.Contains("備註") && !string.IsNullOrWhiteSpace(row.GetValue("備註"))) record.Remark = row.GetValue("備註").Trim(); if (mOption.SelectedFields.Contains("抵免課程") && !string.IsNullOrWhiteSpace(row.GetValue("抵免課程"))) record.OffsetCourse = row.GetValue("抵免課程").Trim(); if (!string.IsNullOrEmpty(course_id)) record.CourseID = int.Parse(course_id); record.StudentID = int.Parse(studentID); record.SubjectID = int.Parse(dicSubjectIDs[(keyField == "課程識別碼" ? subject_code : new_subject_code)]); if (mOption.SelectedFields.Contains("課程名稱") && !string.IsNullOrEmpty(subject_name)) record.SubjectName = subject_name; if (dicClass_Names.ContainsKey(studentID + "_" + (keyField == "課程識別碼" ? subject_code : new_subject_code))) record.CourseID = int.Parse(dicClass_Names[studentID + "_" + (keyField == "課程識別碼" ? subject_code : new_subject_code)]); if (record.RecordStatus == RecordStatus.Insert) insertRecords.Add(record); if (record.RecordStatus == RecordStatus.Update) updateRecords.Add(record); } List<string> insertedRecordIDs = new List<string>(); try { insertedRecordIDs = insertRecords.SaveAll(); } catch (System.Exception e) { System.Windows.Forms.MessageBox.Show(e.Message); return e.Message; } List<string> updatedRecordIDs = new List<string>(); try { updatedRecordIDs = updateRecords.SaveAll(); } catch (System.Exception e) { System.Windows.Forms.MessageBox.Show(e.Message); return e.Message; } // RaiseEvent if (insertedRecordIDs.Count > 0 || updateRecords.Count > 0) { IEnumerable<string> uids = insertedRecordIDs.Union(updatedRecordIDs); UDT.SubjectSemesterScore.RaiseAfterUpdateEvent(this, new ParameterEventArgs(uids)); } return string.Empty; }
protected override void OnSaveButtonClick(EventArgs e) { // 1、先 Clone 原始資料,便於記錄 Log TeacherExtVO originalTeacherExtVO; int teacherID = int.Parse(PrimaryKey); if (_dicUTDs.ContainsKey(teacherID)) { originalTeacherExtVO = _dicUTDs[teacherID]; _dicUTDs[teacherID] = originalTeacherExtVO.Clone(); } else originalTeacherExtVO = new TeacherExtVO(); // 2、回填修改資料 originalTeacherExtVO.WebSiteUrl = this.txtWebSiteUrl.Text; ErrorProvider1.Clear(); DateTime birthday = DateTime.Now; if (!string.IsNullOrWhiteSpace(this.txtBirthday.Text)) { if (!DateTime.TryParse(this.txtBirthday.Text.Trim(), out birthday)) { ErrorProvider1.SetError(this.txtBirthday, "格式錯誤,範例:1970/8/24"); return; } else ErrorProvider1.SetError(this.txtBirthday, ""); } originalTeacherExtVO.Birthday = string.IsNullOrWhiteSpace(this.txtBirthday.Text) ? string.Empty : birthday.ToShortDateString(); originalTeacherExtVO.Address = this.txtAddress.Text; originalTeacherExtVO.Mobil = this.txtMobil.Text; originalTeacherExtVO.OtherPhone = this.txtOtherPhone.Text; originalTeacherExtVO.Phone = this.txtPhone.Text; originalTeacherExtVO.MajorWorkPlace = this.txtMajorWorkPlace.Text; originalTeacherExtVO.Memo = this.txtMemo.Text; originalTeacherExtVO.EmployeeNo = this.txtEmployeeNo.Text; originalTeacherExtVO.NtuSystemNo = this.txtNtuSystemNo.Text; originalTeacherExtVO.EnglishName = this.txtEnglishName.Text; originalTeacherExtVO.Research = this.txtResearch.Text; originalTeacherExtVO.TeacherID = int.Parse(PrimaryKey); // 3、存檔 List<TeacherExtVO> updateRecords = new List<TeacherExtVO>(); updateRecords.Add(originalTeacherExtVO); List<string> updatedRecordIDs = updateRecords.SaveAll(); // 4、記錄 Log List<TeacherExtVO> updatedRecords = Access.Select<TeacherExtVO>(string.Format("ref_teacher_id={0}", PrimaryKey)); if (updatedRecords != null && updatedRecords.Count > 0) { if (_dicUTDs.ContainsKey(teacherID)) WriteUpdateLog(_dicUTDs[teacherID], originalTeacherExtVO); else WriteAddLog(originalTeacherExtVO); } DataBindToForm(updatedRecords); SaveButtonVisible = false; CancelButtonVisible = false; }
private void btnSave_Click(object sender, EventArgs e) { btnSave.Enabled = false; // 讀取畫面是否允許設定 Dictionary<string, bool?> appDict = new Dictionary<string, bool?>(); try { foreach (DataGridViewRow drv in dgData.Rows) { string uid = drv.Tag.ToString(); if (!string.IsNullOrEmpty(uid)) { bool? bb; string strB = ""; bb = null; if (drv.Cells[colApprove.Index].Value !=null) strB=drv.Cells[colApprove.Index].Value.ToString(); if (strB == "是") bb = true; if (strB == "否") bb = false; if (!appDict.ContainsKey(uid)) appDict.Add(uid, bb); } } List<udtNoticeApprove> updateNoticeApproveList = new List<udtNoticeApprove>(); // 修改是否引許相關資料 foreach (string key in appDict.Keys) { bool? newB = appDict[key]; if (_NoticeApproveDict.ContainsKey(key)) { foreach (udtNoticeApprove nData in _NoticeApproveDict[key]) { // 相同 if (nData.Approve != newB) { nData.Approve = newB; updateNoticeApproveList.Add(nData); } } } } // 更新資料 if (updateNoticeApproveList.Count > 0) updateNoticeApproveList.SaveAll(); MsgBox.Show("儲存完成."); this.Close(); }catch( Exception ex) { MsgBox.Show("儲存失敗," + ex.Message); } }
private void Save_Click(object sender, EventArgs e) { this.DialogResult = System.Windows.Forms.DialogResult.OK; try { string Err_Msg = string.Empty; string SurveyName = this.txtName.Text.Trim(); if (string.IsNullOrEmpty(SurveyName)) Err_Msg += "請輸入評鑑樣版名稱。\n"; if (!string.IsNullOrEmpty(Err_Msg)) throw new Exception(Err_Msg); // 所有的「評鑑樣版」 List<UDT.Survey> Surveys = Access.Select<UDT.Survey>(string.Format(@"name='{0}'", SurveyName)); // 若新增的「評鑑樣版」名稱已存在,則發出警告並跳出程式 if ((this._Survey == null) && Surveys.Count() > 0) { MessageBox.Show("同名之評鑑樣版已存在。"); this.DialogResult = System.Windows.Forms.DialogResult.None; return; } // 若修改的「評鑑樣版」名稱已存在,且該「評鑑樣版」的「uid」非待修改「評鑑樣版」所擁有,則發出警告並跳出程式 if ((this._Survey != null) && Surveys.Where(x => x.UID != this._Survey.UID).Count() > 0) { MessageBox.Show("同名之評鑑樣版已存在。"); this.DialogResult = System.Windows.Forms.DialogResult.None; return; } // 修改「問卷」 if (this._Survey != null) { this._Survey.Name = this.txtName.Text.Trim(); this._Survey.Category = this.txtCategory.Text.Trim(); this._Survey.Description = this.txtDescription.Text.Trim(); this._Survey.Save(); this.Close(); return; } // 待新增的「問卷」 UDT.Survey nSurvey = new UDT.Survey(); nSurvey.Name = SurveyName; nSurvey.Category = this.txtCategory.Text.Trim(); nSurvey.Description = this.txtDescription.Text.Trim(); nSurvey.Save(); // 檢查是否複製「題目」 ComboItem item = (ComboItem)this.cboSurvey.SelectedItem; if (item == null || item.Tag == null) { // 不複製 this.Close(); return; } else { // 複製「題目」、「答案選項」、及「題目標題」 string SurveyID = ((UDT.Survey)item.Tag).UID; List<UDT.Question> oQuestions = Access.Select<UDT.Question>(string.Format(@"ref_survey_id = {0}", SurveyID)); List<UDT.Question> nQuestions = new List<UDT.Question>(); foreach (UDT.Question oQuestion in oQuestions) { UDT.Question nQuestion = new UDT.Question(); nQuestion.SurveyID = int.Parse(nSurvey.UID); nQuestion.Title = oQuestion.Title; nQuestion.Type = oQuestion.Type; nQuestion.IsRequired = oQuestion.IsRequired; nQuestion.IsCase = oQuestion.IsCase; nQuestion.IsSelfAssessment = oQuestion.IsSelfAssessment; nQuestion.DisplayOrder = oQuestion.DisplayOrder; nQuestions.Add(nQuestion); } nQuestions.SaveAll(); nQuestions = Access.Select<UDT.Question>(string.Format(@"ref_survey_id = {0}", nSurvey.UID)); List<UDT.QuestionOption> oQuestionOptions = new List<UDT.QuestionOption>(); List<UDT.QuestionOption> nQuestionOptions = new List<UDT.QuestionOption>(); if (oQuestions.Count > 0) oQuestionOptions = Access.Select<UDT.QuestionOption>(string.Format(@"ref_question_id in ({0})", string.Join(",", oQuestions.Select(x => x.UID)))); foreach (UDT.QuestionOption oQuestionOption in oQuestionOptions) { UDT.Question oQuestion = oQuestions.Where(x => x.UID == oQuestionOption.QuestionID.ToString()).ElementAt(0); UDT.Question nQuestion = nQuestions.Where(x => x.Title == oQuestion.Title).ElementAt(0); UDT.QuestionOption nQuestionOption = new UDT.QuestionOption(); nQuestionOption.QuestionID = int.Parse(nQuestion.UID); nQuestionOption.Title = oQuestionOption.Title; nQuestionOption.DisplayOrder = oQuestionOption.DisplayOrder; nQuestionOptions.Add(nQuestionOption); } nQuestionOptions.SaveAll(); List<UDT.QHRelation> oQHRelations = new List<UDT.QHRelation>(); List<UDT.QHRelation> nQHRelations = new List<UDT.QHRelation>(); Dictionary<string, string> dicQHRelations = new Dictionary<string, string>(); if (oQuestions.Count > 0) oQHRelations = Access.Select<UDT.QHRelation>(string.Format(@"ref_question_id in ({0})", string.Join(",", oQuestions.Select(x => x.UID)))); if (oQHRelations.Count > 0) { foreach(UDT.QHRelation QHRelation in oQHRelations) { if (!dicQHRelations.ContainsKey(QHRelation.QuestionID.ToString())) dicQHRelations.Add(QHRelation.QuestionID.ToString(), QHRelation.HierarchyTitle); } } foreach (UDT.QHRelation oQHRelation in oQHRelations) { UDT.Question oQuestion = oQuestions.Where(x => x.UID == oQHRelation.QuestionID.ToString()).ElementAt(0); UDT.Question nQuestion = nQuestions.Where(x => x.Title == oQuestion.Title).ElementAt(0); if (dicQHRelations.ContainsKey(oQuestion.UID)) { UDT.QHRelation nQHRelation = new UDT.QHRelation(); nQHRelation.QuestionID = int.Parse(nQuestion.UID); nQHRelation.HierarchyTitle = dicQHRelations[oQuestion.UID]; nQHRelations.Add(nQHRelation); } } nQHRelations.SaveAll(); this.Close(); return; } } catch (Exception ex) { MessageBox.Show(ex.Message); this.DialogResult = System.Windows.Forms.DialogResult.None; } finally { //this.Close(); } }
static void iWizardBusStudentPayment_ImportPackage(object sender, ImportLibrary.ImportPackageEventArgs e) { List<Data.StudentByBus> importItems = new List<Data.StudentByBus>(); foreach (var row in e.Items) { Data.StudentByBus importData = new Data.StudentByBus(); if (row.ID != "") importData = 搭車紀錄資料庫[row.ID]; //Data.StudentByBus importData = (row.ID != "") ? 學生搭車紀錄資料庫[學生資料庫[row["學號"]].ID][row["搭車年度"] + row["期間名稱"]] : new Data.StudentByBus(); //if (_DeletedBusStudents.Contains(importData)) // _DeletedBusStudents.Remove(importData); string bustime = ""; string busid = ""; int daycount = 0; foreach (var field in e.ImportFields) { string value = row[field]; switch (field) { default: break; case "搭車天數": if (value.Length > 0) importData.DateCount = int.Parse(value); break; case "車費": if (value.Length > 0) importData.BusMoney = int.Parse(value); else importData.BusMoney = 0; break; case "是否繳費": if (value.Length > 0) { if (value == "是" || value == "Yes" || value == "True") importData.PayStatus = true; else importData.PayStatus = false; } else importData.PayStatus = false; break; case "繳費日期": if (value.Length > 0) importData.PayDate = DateTime.Parse(value); break; case "備註": importData.comment = value; break; } } importItems.Add(importData); } importItems.SaveAll(); }
private void btnRecover_Click(object sender, EventArgs e) { if (this.lstCourse.SelectedIndex == -1) return; this.DisableButtons(); string CourseID = this.groupPanel1.Tag + ""; decimal school_year = this.nudSchoolYear.Value; string semester = (this.cboSemester.SelectedItem as DataItems.SemesterItem).Value; List<UDT.CSAttend> CSAttends = new List<UDT.CSAttend>(); List<UDT.CSAttendLog> CSAttendLogs = new List<UDT.CSAttendLog>(); if (this.dgvData.SelectedRows.Count == 0) return; this.dgvData.SelectedRows.Cast<DataGridViewRow>().ToList().ForEach((x) => { if (x.DefaultCellStyle.BackColor == System.Drawing.Color.Pink) { UDT.CSAttend CSAttend = new UDT.CSAttend(); UDT.CSAttendLog CSAttendLog = new UDT.CSAttendLog(); CSAttend.StudentID = int.Parse(x.Cells["lblStudentID"].Value + ""); CSAttend.CourseID = int.Parse(CourseID); CSAttend.SchoolYear = int.Parse(school_year.ToString()); CSAttend.Semester = int.Parse(semester); CSAttend.Item = this.item; CSAttends.Add(CSAttend); CSAttendLog.StudentID = int.Parse(x.Cells["lblStudentID"].Value + ""); CSAttendLog.CourseID = int.Parse(CourseID); CSAttendLog.SchoolYear = int.Parse(school_year.ToString()); CSAttendLog.Semester = int.Parse(semester); CSAttendLog.Item = this.item; CSAttendLog.Action = "insert"; CSAttendLog.ActionBy = "staff"; CSAttendLogs.Add(CSAttendLog); x.DefaultCellStyle.BackColor = System.Drawing.SystemColors.Window; } }); CSAttends.SaveAll(); CSAttendLogs.SaveAll(); this.InitCSAttend(CourseID); if (this.chkShowLog.Checked) this.AppendCSAttendLog(CourseID); this.EnableButtons(); }
private void Save_Click(object sender, EventArgs e) { string graduationRequirementName = this.txtName.Text.Trim(); Access = new AccessHelper(); // 所有的「畢業條件」 List<GraduationRequirement> graduationRequirements = Access.Select<GraduationRequirement>(); // 若新增的「畢業條件」名稱已存在,則發出警告並跳出程式 if (graduationRequirements.Where(x => (x.Name == graduationRequirementName && x.DepartmentGroupID == _DepartmentGroupID)).Count() > 0) { MessageBox.Show("同名之畢業條件已存在!"); return; } // 待新增的「畢業條件」 GraduationRequirement graduationRequirement = new GraduationRequirement(); // 檢查是否複製 ComboItem item = (ComboItem)this.cboGraduationRequirementRule.SelectedItem; if (item == null || item.Tag == null) { // 不複製 graduationRequirement.Name = graduationRequirementName; graduationRequirement.DepartmentGroupID = _DepartmentGroupID; graduationRequirement.RequiredCredit = 0; graduationRequirement.DepartmentCredit = 0; graduationRequirement.ElectiveCredit = 0; graduationRequirement.Save(); } else { // 1、複製「畢業條件」 GraduationRequirement oGraduationRequirement = (GraduationRequirement)item.Tag; graduationRequirement.Name = graduationRequirementName; graduationRequirement.DepartmentGroupID = _DepartmentGroupID; graduationRequirement.RequiredCredit = oGraduationRequirement.RequiredCredit; graduationRequirement.DepartmentCredit = oGraduationRequirement.DepartmentCredit; graduationRequirement.ElectiveCredit = oGraduationRequirement.ElectiveCredit; graduationRequirements = new List<GraduationRequirement>(); graduationRequirements.Add(graduationRequirement); List<string> graduationRequirementIDs = graduationRequirements.SaveAll(); // 2、複製「畢業應修科目清單」 List<GraduationSubjectList> graduationSubjects = Access.Select<GraduationSubjectList>(string.Format("ref_graduation_requirement_id = {0}", oGraduationRequirement.UID)); List<GraduationSubjectList> newGraduationSubjects = new List<GraduationSubjectList>(); foreach(GraduationSubjectList graduationSubject in graduationSubjects) { GraduationSubjectList newGraduationSubjectList = new GraduationSubjectList(); newGraduationSubjectList.GraduationRequirementID = int.Parse(graduationRequirementIDs[0]); newGraduationSubjectList.SubjectID = graduationSubject.SubjectID; newGraduationSubjectList.Prerequisites = graduationSubject.Prerequisites; newGraduationSubjects.Add(newGraduationSubjectList); } newGraduationSubjects.SaveAll(); // 3、複製「畢業應修科目群組應修科目數及應修學分數」--待討論,建議不做 // 4、重繪「指定畢業條件」選單 //EMBACore.Initialization.StudentInit.RedrawGraduationRequirementMenuButton(); } this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); }
static void CourseInit_PopupOpen(object sender, PopupOpenEventArgs e) { //MenuButton mb = e.VirtualButtons["不指定"]; e.VirtualButtons["不指定"].Click += delegate { List<string> selectedIDs = K12.Presentation.NLDPanels.Course.SelectedSource; if (selectedIDs.Count == 0) { MessageBox.Show("請先選擇課程!"); return; } Task task = Task.Factory.StartNew(() => { List<UDT.SubjectSemesterScoreInputRule> SubjectSemesterScoreInputRules = (new AccessHelper()).Select<UDT.SubjectSemesterScoreInputRule>(string.Format("ref_course_id in ({0})", string.Join(",", selectedIDs))); if (SubjectSemesterScoreInputRules.Count > 0) { SubjectSemesterScoreInputRules.ForEach(x => x.Deleted = true); SubjectSemesterScoreInputRules.SaveAll(); } }); task.ContinueWith((x) => { ListPaneFields.Course_SubjectSemesterScoreInputRule.Instance.ReloadMe(); }, TaskScheduler.FromCurrentSynchronizationContext()); }; e.VirtualButtons["P/N 制"].Tag = 1; e.VirtualButtons["P/N 制"].BeginGroup = true; e.VirtualButtons["P/N 制"].Click += (s1, e1) => { List<string> selectedIDs = K12.Presentation.NLDPanels.Course.SelectedSource; if (selectedIDs.Count == 0) { MessageBox.Show("請先選擇課程!"); return; } Task task = Task.Factory.StartNew(() => { List<UDT.SubjectSemesterScoreInputRule> SubjectSemesterScoreInputRules = (new AccessHelper()).Select<UDT.SubjectSemesterScoreInputRule>(string.Format("ref_course_id in ({0})", string.Join(",", selectedIDs))); Dictionary<string, UDT.SubjectSemesterScoreInputRule> dicSubjectSemesterScoreInputRules = new Dictionary<string, SubjectSemesterScoreInputRule>(); if (SubjectSemesterScoreInputRules.Count > 0) dicSubjectSemesterScoreInputRules = SubjectSemesterScoreInputRules.ToDictionary(x => x.CourseID.ToString()); List<UDT.SubjectSemesterScoreInputRule> Insert_SubjectSemesterScoreInputRules = new List<SubjectSemesterScoreInputRule>(); foreach (string CourseID in selectedIDs) { if (!dicSubjectSemesterScoreInputRules.ContainsKey(CourseID)) { UDT.SubjectSemesterScoreInputRule SubjectSemesterScoreInputRule = new UDT.SubjectSemesterScoreInputRule(); SubjectSemesterScoreInputRule.CourseID = int.Parse(CourseID); SubjectSemesterScoreInputRule.InputRule = 1; Insert_SubjectSemesterScoreInputRules.Add(SubjectSemesterScoreInputRule); } } Insert_SubjectSemesterScoreInputRules.SaveAll(); }); task.ContinueWith((x) => { ListPaneFields.Course_SubjectSemesterScoreInputRule.Instance.ReloadMe(); }, TaskScheduler.FromCurrentSynchronizationContext()); }; }
private void savebtn_Click(object sender, EventArgs e) { List<Data.StudentByBus> _Source = new List<Data.StudentByBus>(); Data.StudentByBus sbr = new Data.StudentByBus(); BusSetup bussetup = BusSetupDAO.SelectByBusYearAndRange(int.Parse(this.cboYear.Text), this.cboRange.Text); _Source.Clear(); for (int i = studentdataGridView.Rows.Count - 1; i >= 0; i--) { sbr = (Data.StudentByBus)studentdataGridView.Rows[i].Tag; if (sbr == null && (studentdataGridView[2, i].Value == null || studentdataGridView[2, i].Value.ToString() == "")) continue; if (sbr == null) sbr = new Data.StudentByBus(); sbr.StudentID = (string)studentdataGridView[9, i].Value; sbr.ClassName = (string)studentdataGridView[0, i].Value; sbr.ClassID = (string)studentdataGridView[11, i].Value; sbr.BusStopID = studentdataGridView[2, i].Value.ToString().Substring(0, 4); BusStop buses = BusStopDAO.SelectByBusTimeNameAndByStopID(bussetup.BusTimeName, sbr.BusStopID); sbr.PayStatus = (bool)studentdataGridView[5, i].Value; DateTime PayDate; if (studentdataGridView[6, i].Value.ToString() != "" && DateTime.TryParse(studentdataGridView[6, i].Value.ToString(), out PayDate)) sbr.PayDate = DateTime.Parse(studentdataGridView[6, i].Value.ToString()); sbr.DateCount = int.Parse(studentdataGridView[7, i].Value.ToString()); int total = buses.BusMoney * sbr.DateCount; int div_value = total / 10; sbr.comment = (string)studentdataGridView[8, i].Value; sbr.BusRangeName = bussetup.BusRangeName; sbr.BusTimeName = bussetup.BusTimeName; if ((total - div_value * 10) < 5) sbr.BusMoney = div_value * 10; else sbr.BusMoney = div_value * 10 + 10; sbr.SchoolYear = int.Parse(this.cboYear.Text); _Source.Add(sbr); } _Source.SaveAll(); RefreshDataGrid(); MessageBox.Show("儲存成功!"); }
private void savebtn_Click(object sender, EventArgs e) { if (this.cboYear.Text == "" || this.cboRange.Text == "") { MessageBox.Show("搭車年度與期間名稱不可為空!"); return; } AccessHelper udtHelper = new AccessHelper(); Dictionary<string, List<NewStudentRecord>> NewStudnets = new Dictionary<string, List<NewStudentRecord>>(); List<NewStudentRecord> students = udtHelper.Select<NewStudentRecord>("學年度='" + this.cboYear.Text + "'"); Dictionary<string, NewStudentRecord> NewStudents = new Dictionary<string, NewStudentRecord>(); foreach (NewStudentRecord var in students) { if (!NewStudents.ContainsKey(var.UID)) NewStudents.Add(var.UID, var); } List<ClassRecord> cls = K12.Data.Class.SelectAll(); List<string> clsid = new List<string>(); foreach (ClassRecord var in cls) { if (var.GradeYear.ToString() == null) continue; if (var.Name.Substring(0, 2) == "夜輔" || var.Name.Substring(0, 2) == "轉學") continue; if (!clsid.Contains(var.ID)) clsid.Add(var.ID); } List<StudentRecord> studentclass = K12.Data.Student.SelectByClassIDs(clsid); Dictionary<string, StudentRecord> studentids = new Dictionary<string, StudentRecord>(); foreach (StudentRecord var in studentclass) { if (var.Status.ToString() != "一般") continue; if (!studentids.ContainsKey(var.IDNumber)) studentids.Add(var.IDNumber, var); } BusSetup bussetup = BusSetupDAO.SelectByBusYearAndRange(int.Parse(this.cboYear.Text), this.cboRange.Text); //List<BusStop> buses = BusStopDAO.SelectByBusTimeNameOrderByStopID(bussetup.BusTimeName); List<StudentByBus> _Source = StudentByBusDAO.SelectByBusYearAndTimeName(int.Parse(this.cboYear.Text), this.cboRange.Text); //轉換後之資料 List<StudentByBus> StudentBuses = new List<StudentByBus>(); foreach (var item in _Source) { if (NewStudents.ContainsKey(item.StudentID)) { if (studentids.ContainsKey(NewStudents[item.StudentID].IDNumber)) { item.StudentID = studentids[NewStudents[item.StudentID].IDNumber].ID; item.ClassName = studentids[NewStudents[item.StudentID].IDNumber].Class.Name; StudentBuses.Add(item); } } } if (StudentBuses.Count > 0) { StudentBuses.SaveAll(); MessageBox.Show("新生共" + StudentBuses.Count + "筆儲存成功!"); } else MessageBox.Show("無任何符合條件新生!"); }
/// <summary> /// 取消調代記錄 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void toolStripMenuItem1_Click(object sender, EventArgs e) { if (MessageBox.Show("是否確認取消共" + grdResult.SelectedRows.Count + "筆調代記錄?", "取消確認", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { List<string> UnCancelUIDs = new List<string>(); List<string> DeleteUIDs = new List<string>(); List<CancelCourseCalendar> CancelRecords = new List<CancelCourseCalendar>(); foreach(DataGridViewRow Row in grdResult.SelectedRows) { CalendarRecord record = Row.Tag as CalendarRecord; CancelCourseCalendar CancelCalendar = new CancelCourseCalendar(record); CancelRecords.Add(CancelCalendar); //代課記錄 if (record.ExchangeCalendar == null) { UnCancelUIDs.Add(record.ReplaceID); DeleteUIDs.Add(record.UID); } //調課記錄 else { UnCancelUIDs.Add(record.ExchangeID); UnCancelUIDs.Add(record.ExchangeCalendar.ExchangeID); DeleteUIDs.Add(record.UID); DeleteUIDs.Add(record.ExchangeCalendar.UID); } } //儲存取消的行事曆記錄 CancelRecords.SaveAll(); //先將行事曆啟用 Calendar.Instance.Cancel(UnCancelUIDs, false); //將行事曆刪除 Calendar.Instance.Delete(DeleteUIDs); //重新執行查詢 Query(); } }
private void Save_Click(object sender, EventArgs e) { List<UDT.ExperienceDataSource> uRecords = new List<UDT.ExperienceDataSource>(); List<UDT.ExperienceDataSource> nRecords = new List<UDT.ExperienceDataSource>(); //List<UDT.ExperienceDataSource> dRecords = new List<UDT.ExperienceDataSource>(); foreach (DataGridViewRow dataGridViewRow in this.dgvData.Rows) { if (dataGridViewRow.IsNewRow) continue; if (dataGridViewRow.Tag == null) { UDT.ExperienceDataSource experienceDataSource = new UDT.ExperienceDataSource(); experienceDataSource.ItemCategory = (string.IsNullOrEmpty(this._ItemCategory) ? dataGridViewRow.Cells[0].Value + "" : this._ItemCategory); experienceDataSource.Item = dataGridViewRow.Cells[1].Value + ""; experienceDataSource.NotDisplay = (dataGridViewRow.Cells[2].Value == null ? false : bool.Parse(dataGridViewRow.Cells[2].Value + "")); nRecords.Add(experienceDataSource); } else { UDT.ExperienceDataSource experienceDataSource = dataGridViewRow.Tag as UDT.ExperienceDataSource; experienceDataSource.ItemCategory = (string.IsNullOrEmpty(this._ItemCategory) ? dataGridViewRow.Cells[0].Value + "" : this._ItemCategory); experienceDataSource.Item = dataGridViewRow.Cells[1].Value + ""; experienceDataSource.NotDisplay = (dataGridViewRow.Cells[2].Value == null ? false : bool.Parse(dataGridViewRow.Cells[2].Value + "")); uRecords.Add(experienceDataSource); } } nRecords.SaveAll(); uRecords.SaveAll(); if (!string.IsNullOrEmpty(this._ItemCategory)) { UDT.ExperienceDataSource.RaiseAfterUpdateEvent(); this.Close(); } else this.InitExperienceDataSouce(this._ItemCategory); //oExperienceDataSources.ForEach((x) => //{ // if (uRecords.Where(y => y.UID == x.UID).Count() == 0) // dRecords.Add(x); //}); }
private void btnManualFilter_Click(object sender, EventArgs e) { this.DisableButtons(); List<UDT.CSAttend> CSAttend_Deleteds = new List<UDT.CSAttend>(); List<UDT.CSAttendLog> CSAttendLogs = new List<UDT.CSAttendLog>(); string CourseID = this.groupPanel1.Tag + ""; List<UDT.CSAttend> CSAttends = Access.Select<UDT.CSAttend>(string.Format("ref_course_id={0}", CourseID)); Dictionary<int, UDT.CSAttend> dicCSAttends = new Dictionary<int, UDT.CSAttend>(); if (CSAttends.Count > 0) { CSAttends.ForEach((x) => { if (!dicCSAttends.ContainsKey(x.StudentID)) dicCSAttends.Add(x.StudentID, x); }); } decimal school_year = this.nudSchoolYear.Value; string semester = (this.cboSemester.SelectedItem as DataItems.SemesterItem).Value; string error_message = string.Empty; List<DataGridViewRow> cantdeletes = new List<DataGridViewRow>(); foreach(DataGridViewRow row in this.dgvData.SelectedRows) { int StudentID = int.Parse(row.Cells["lblStudentID"].Value + ""); bool locked_evaluation = false; bool locked_condition = false; bool manual = false; bool period1 = false; if (bool.TryParse(row.Cells["colManual"].Value + "", out manual) && manual) cantdeletes.Add(row); if (bool.TryParse(row.Cells["colPeriod1"].Value + "", out period1) && period1) cantdeletes.Add(row); if (bool.TryParse(row.Cells["chkEvaluation"].Value + "", out locked_evaluation) && locked_evaluation) cantdeletes.Add(row); if (bool.TryParse(row.Cells["chkLock"].Value + "", out locked_condition) && locked_condition) cantdeletes.Add(row); cantdeletes = cantdeletes.Distinct().ToList(); if (dicCSAttends.ContainsKey(StudentID)) { UDT.CSAttend CSAttend = dicCSAttends[StudentID]; UDT.CSAttendLog CSAttendLog = new UDT.CSAttendLog(); CSAttend.Deleted = true; CSAttendLog.StudentID = StudentID; CSAttendLog.CourseID = int.Parse(CourseID); CSAttendLog.SchoolYear = int.Parse(school_year.ToString()); CSAttendLog.Semester = int.Parse(semester); CSAttendLog.Item = this.item; CSAttendLog.Action = "delete"; CSAttendLog.ActionBy = "staff"; CSAttendLogs.Add(CSAttendLog); CSAttend_Deleteds.Add(CSAttend); } } if (cantdeletes.Count > 0) { error_message = "下列學生已勾選「優先」,確定手動篩汰學生?\n\n"; foreach (DataGridViewRow row in cantdeletes) { error_message += string.Format("學號「{0}」,姓名「{1}」。\n", row.Cells[3].Value + "", row.Cells[4].Value + ""); } if (MessageBox.Show(error_message, "提示", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.Cancel) { this.EnableButtons(); return; } } else { if (MessageBox.Show("確定手動篩汰學生?", "提示", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.Cancel) { this.EnableButtons(); return; } } CSAttend_Deleteds.SaveAll(); CSAttendLogs.SaveAll(); this.InitCSAttend(CourseID); if (this.chkShowLog.Checked) this.AppendCSAttendLog(CourseID); this.EnableButtons(); }
private void SaveUDT() { // 待刪除資料 Dictionary<string, PaymentHistory> deleteRecords = new Dictionary<string, PaymentHistory>(); // 待更新資料 Dictionary<string, PaymentHistory> updateRecords = new Dictionary<string, PaymentHistory>(); // 待新增資料 List<PaymentHistory> insertRecords = new List<PaymentHistory>(); // 學生資料 K12.Data.StudentRecord studentRecord = K12.Data.Student.SelectByID(PrimaryKey); foreach (DataGridViewRow dataGridRow in this.dgvData.Rows) { if (dataGridRow.IsNewRow) continue; PaymentHistory paymentHistoryRecord = (PaymentHistory)dataGridRow.Tag; if (paymentHistoryRecord == null) paymentHistoryRecord = new PaymentHistory(); // 學年度 paymentHistoryRecord.SchoolYear = int.Parse(dataGridRow.Cells["SchoolYear"].Value.ToString()); // 學期 paymentHistoryRecord.Semester = int.Parse(SemesterItem.GetSemesterByName(dataGridRow.Cells["Semester"].Value.ToString()).Value); // 是否繳費 bool isPaied = false; bool.TryParse(dataGridRow.Cells["IsPaied"].Value == null ? "" : dataGridRow.Cells["IsPaied"].Value.ToString(), out isPaied); paymentHistoryRecord.IsPaied = (isPaied ? 1 : 0); // 學生系統編號 paymentHistoryRecord.StudentID = int.Parse(PrimaryKey); if (paymentHistoryRecord.RecordStatus == FISCA.UDT.RecordStatus.Insert) insertRecords.Add(paymentHistoryRecord); else if (paymentHistoryRecord.RecordStatus == FISCA.UDT.RecordStatus.Update) updateRecords.Add(paymentHistoryRecord.UID, paymentHistoryRecord); } IEnumerable<DataGridViewRow> dataGridViewRows = this.dgvData.Rows.Cast<DataGridViewRow>(); foreach (string key in _dicUTDs.Keys) { if (dataGridViewRows.Where(x => x.Cells["UID"].Value != null).Where(x => (x.Cells["UID"].Value.ToString() == key)).Count() == 0) { PaymentHistory paymentHistoryRecord = _dicUTDs[key]; paymentHistoryRecord.Deleted = true; deleteRecords.Add(key, paymentHistoryRecord); } } // 更新日期 if (insertRecords.Count>0) insertRecords.ForEach(x=>x.LastModifiedDate = System.DateTime.Now); List<string> insertedRecordUIDs = insertRecords.SaveAll(); // 匯入「新增」資料 List<PaymentHistory> insertedRecords = new List<PaymentHistory>(); if (insertedRecordUIDs != null && insertedRecordUIDs.Count>0) insertedRecords = this.Access.Select<PaymentHistory>(insertedRecordUIDs); if (insertedRecords != null && insertedRecords.Count > 0) { // 寫入「新增」的 Log Dictionary<string, PaymentHistory> dicInsertedRecords = insertedRecords.ToDictionary(x => x.UID); foreach (string iRecords in dicInsertedRecords.Keys) { PaymentHistory record = dicInsertedRecords[iRecords]; StringBuilder sb = new StringBuilder(); sb.Append("學生「" + studentRecord.Name + "」,學號「" + studentRecord.StudentNumber + "」"); sb.AppendLine("被新增一筆「繳費紀錄」。"); sb.AppendLine("詳細資料:"); sb.Append("學年度「" + record.SchoolYear + "」\n"); sb.Append("學期「" + record.Semester + "」\n"); sb.Append("繳費「" + IsPaidToString(record.IsPaied) + "」\n"); FISCA.LogAgent.ApplicationLog.Log("繳費記錄.學生", "新增", Log.LogTargetCategory.Student.ToString().ToLower(), record.StudentID.ToString(), sb.ToString()); } } // 更新日期 if (updateRecords.Count > 0) updateRecords.Values.ToList().ForEach(x => x.LastModifiedDate = System.DateTime.Now); List<string> updatedRecords = updateRecords.Values.SaveAll(); // 匯入「更新」資料 List<PaymentHistory> updatedRecordss = new List<PaymentHistory>(); if (updatedRecords != null && updatedRecords.Count>0) updatedRecordss = Access.Select<PaymentHistory>(updatedRecords); if (updatedRecordss != null && updatedRecordss.Count > 0) { // 批次寫入「修改」的 Log foreach (PaymentHistory uRecords in updatedRecordss) { PaymentHistory record = uRecords; PaymentHistory oldRecord = _dicUTDs[uRecords.UID]; StringBuilder sb = new StringBuilder(); sb.Append("學生「" + studentRecord.Name + "」,學號「" + studentRecord.StudentNumber + "」"); sb.AppendLine("被修改一筆「繳費記錄」。"); sb.AppendLine("詳細資料:"); if (!oldRecord.SchoolYear.Equals(record.SchoolYear)) sb.Append("學年度由「" + oldRecord.SchoolYear + "」改為「" + record.SchoolYear + "」\n"); if (!oldRecord.Semester.Equals(record.Semester)) sb.Append("學期由「" + oldRecord.Semester + "」改為「" + record.Semester + "」\n"); if (!oldRecord.IsPaied.Equals(record.IsPaied)) sb.Append("繳費由「" + IsPaidToString(oldRecord.IsPaied) + "」改為「" + IsPaidToString(record.IsPaied) + "」\n"); FISCA.LogAgent.ApplicationLog.Log("繳費記錄.學生", "修改", Log.LogTargetCategory.Student.ToString().ToLower(), record.StudentID.ToString(), sb.ToString()); } } // 刪除資料 List<string> deletedRecords = deleteRecords.Values.SaveAll(); if (deleteRecords != null && deleteRecords.Count > 0) { // 寫入「刪除」的 Log foreach (string dRecords in deletedRecords) { PaymentHistory newRecord = deleteRecords[dRecords]; StringBuilder sb = new StringBuilder(); sb.Append("學生「" + studentRecord.Name + "」,學號「" + studentRecord.StudentNumber + "」"); sb.AppendLine("被刪除一筆「繳費記錄」。"); sb.AppendLine("詳細資料:"); sb.Append("學年度「" + newRecord.SchoolYear + "」\n"); sb.Append("學期「" + newRecord.Semester + "」\n"); sb.Append("繳費「" + IsPaidToString(newRecord.IsPaied) + "」\n"); FISCA.LogAgent.ApplicationLog.Log("繳費記錄.學生", "刪除", Log.LogTargetCategory.Student.ToString().ToLower(), newRecord.StudentID.ToString(), sb.ToString()); } } }
private void Delete_Click(object sender, EventArgs e) { if (this.lstSurvey.SelectedItem == null) { MessageBox.Show("請先選取問卷樣版。"); return; } // 檢查待刪項目是否已有人做答 IEnumerable<UDT.Reply> Replys = Access.Select<UDT.Reply>(string.Format("ref_survey_id = {0}", ((dynamic)this.lstSurvey.SelectedItem).UID)); List<UDT.Question> Questions = Access.Select<UDT.Question>(string.Format("ref_survey_id in ({0})", ((dynamic)this.lstSurvey.SelectedItem).UID)); // 若有則發出警告 if (Replys.Count() > 0) { string Error_Message = "此問卷已有學生做答,不得刪除。\n"; //List<K12.Data.ClassRecord> Clazz = K12.Data.Class.SelectByIDs(Replys.Select(x => x.ClassID.ToString()).Distinct()); //Error_Message += "做答班級:" + string.Join(",", Clazz.Select(x => x.Name)) + "\n"; MessageBox.Show(Error_Message); return; } else { if (MessageBox.Show("確定刪除?", "警告", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.Cancel) return; // 刪問題選項 List<UDT.QuestionOption> QuestionOptions = new List<UDT.QuestionOption>(); if (Questions.Count > 0) QuestionOptions = Access.Select<UDT.QuestionOption>(string.Format("ref_question_id in ({0})", string.Join(",", Questions.Select(x => x.UID)))); QuestionOptions.ForEach(x => x.Deleted = true); QuestionOptions.SaveAll(); // 刪問題 Questions.ForEach(x => x.Deleted = true); Questions.SaveAll(); // 刪問卷 List<UDT.Survey> Surveys = Access.Select<UDT.Survey>(new List<string> { ((dynamic)this.lstSurvey.SelectedItem).UID }); Surveys.ForEach(x => x.Deleted = true); Surveys.SaveAll(); } this.Init(); this.detailPane1.Clear(); }
protected override void OnSaveData() { //SCAttend.SCAttendID = row["sc_attend_id"].ToString(); //SCAttend.StudentID = row["ref_student_id"].ToString(); //SCAttend.Group = row["report_group"].ToString(); //SCAttend.CourseID = PrimaryKey; //SCAttend.IsCancel = isCancel; // 1、先取得 SCAttendExt 物件 List<dynamic> SCAttendExts = new List<dynamic>(); foreach (DataGridViewRow row in this.dgvData.Rows) { if (row.IsNewRow) continue; dynamic SCAttend = (row.Tag as dynamic); SCAttendExts.Add(SCAttend); } if (SCAttendExts.Count == 0) return; List<string> studentIDs = new List<string>(); foreach (dynamic SCAttend in SCAttendExts) studentIDs.Add(SCAttend.StudentID); List<SCAttendExt> scattendExts = Access.Select<SCAttendExt>(string.Format("ref_student_id in ({0}) And ref_course_id='{1}'", string.Join(",", studentIDs), PrimaryKey)); List<SCAttendExt> originalExts = new List<SCAttendExt>(); if (scattendExts != null && scattendExts.Count>0) scattendExts.ForEach(x => originalExts.Add(x.Clone())); // 2、更新 SCAttendExt 物件內容 List<SCAttendExt> updateRecords = new List<SCAttendExt>(); foreach (DataGridViewRow row in this.dgvData.Rows) { if (row.IsNewRow) continue; dynamic SCAttend = (row.Tag as dynamic); IEnumerable<SCAttendExt> SCAttendExtRecords = scattendExts.Where(x => (x.UID == SCAttend.SCAttendID)); SCAttendExt scattendExtRecord = SCAttendExtRecords.ElementAt(0); scattendExtRecord.Group = (row.Cells["ReportGroup"].Value == null ? "" : row.Cells["ReportGroup"].Value.ToString()); bool isCancel = false; bool.TryParse((row.Cells["IsCancel"].Value == null ? "" : row.Cells["IsCancel"].Value.ToString()), out isCancel); scattendExtRecord.IsCancel = isCancel; if (scattendExtRecord.RecordStatus == FISCA.UDT.RecordStatus.Update) updateRecords.Add(scattendExtRecord); } List<string> updatedRecordUIDs = updateRecords.SaveAll(); BatchLogAgent batchLogAgent = new BatchLogAgent(); if (updatedRecordUIDs != null && updatedRecordUIDs.Count > 0) { List<SCAttendExt> updatedRecords = Access.Select<SCAttendExt>(updatedRecordUIDs); Dictionary<string, UDT.SCAttendExt> dicUpdatedRecords = new Dictionary<string, SCAttendExt>(); if (updatedRecords.Count > 0) dicUpdatedRecords = updatedRecords.ToDictionary(x => x.UID); CourseRecord courseRecord = Course.SelectByID(PrimaryKey); List<StudentRecord> studentRecords = K12.Data.Student.SelectByIDs(updatedRecords.Select(x => x.StudentID.ToString())); Dictionary<string, StudentRecord> dicStudentRecords = new Dictionary<string, StudentRecord>(); if (studentRecords.Count > 0) dicStudentRecords = studentRecords.ToDictionary(x => x.ID); foreach (string iRecords in dicUpdatedRecords.Keys) { UDT.SCAttendExt updatedRecord = dicUpdatedRecords[iRecords]; StudentRecord student = dicStudentRecords[updatedRecord.StudentID.ToString()]; IEnumerable<UDT.SCAttendExt> originalRecords = originalExts.Where(x => (x.StudentID.ToString() == student.ID && x.CourseID == updatedRecord.CourseID)); LogAgent log = new LogAgent(); this.AddLog(log, originalRecords.ElementAt(0)); this.AddLog(log, updatedRecord); batchLogAgent.AddLogAgent(log); //StringBuilder sb = new StringBuilder(); //sb.Append("學生「" + student.Name + "」,學號「" + student.StudentNumber + "」"); //sb.AppendLine("被修改一筆「修課記錄」。"); //sb.AppendLine("詳細資料:"); //sb.Append("開課「" + courseRecord.Name + "」\n"); //if (!updatedRecord.Group.Equals(originalRecords.ElementAt(0).Group)) // sb.Append("報告小組由「" + originalRecords.ElementAt(0).Group + "」改為「" + updatedRecord.Group + "」\n"); //if (!updatedRecord.IsCancel.Equals(originalRecords.ElementAt(0).IsCancel)) // sb.Append("停修由「" + originalRecords.ElementAt(0).IsCancel + "」改為「" + updatedRecord.IsCancel + "」\n"); } } if (batchLogAgent.Count > 0) batchLogAgent.Save(); LoadData(); SaveButtonVisible = false; CancelButtonVisible = false; }
static void iWizardBusNewStudent_ImportPackage(object sender, ImportLibrary.ImportPackageEventArgs e) { List<Data.StudentByBus> importItems = new List<Data.StudentByBus>(); foreach (var row in e.Items) { Data.StudentByBus importData = (row.ID != "") ? 新生搭車紀錄資料庫[新生資料庫[row["編號"]].UID] : new Data.StudentByBus(); //if (_DeletedBusStudents.Contains(importData)) // _DeletedBusStudents.Remove(importData); string bustime = ""; string busid = ""; int daycount = 0; foreach (var field in e.ImportFields) { string value = row[field]; if (field == "校車時段") bustime = value; if (field == "代碼") busid = value; if (field == "天數") daycount = int.Parse(value); switch (field) { default: break; case "校車時段": importData.BusTimeName = value; break; case "代碼": importData.BusStopID = value; break; case "期間名稱": importData.BusRangeName = value; break; case "科別": importData.ClassName = value; break; case "編號": importData.StudentID = 新生資料庫[value].UID; break; case "搭車年度": if (value.Length > 0) importData.SchoolYear = int.Parse(value); break; case "天數": if (value.Length > 0) importData.DateCount = int.Parse(value); break; case "車費": if (value.Length > 0) importData.BusMoney = int.Parse(value); else importData.BusMoney = 0; break; case "是否繳費": if (value.Length > 0) { if (value == "是" || value == "Yes" || value == "True") importData.PayStatus = true; else importData.PayStatus = false; } else importData.PayStatus = false; break; case "繳費日期": if (value.Length > 0) importData.PayDate = DateTime.Parse(value); break; case "備註": importData.comment = value; break; } } int total = 校車站名資料庫[bustime][busid].BusMoney * daycount; int div_value = total / 10; if ((total - div_value * 10) < 5) importData.BusMoney = div_value * 10; else importData.BusMoney = div_value * 10 + 10; //importData.BusMoney = 校車站名資料庫[bustime][busid].BusMoney * daycount; importItems.Add(importData); } importItems.SaveAll(); }
private void WriteDuplicateCourse(decimal school_year, string semester, List<CourseSection> CourseSections) { List<KeyValuePair<CourseSection, CourseSection>> ChongTongCourseSections = new List<KeyValuePair<CourseSection, CourseSection>>(); List<int> CourseIDs = new List<int>(); CourseSections.ForEach((x) => { if (!CourseIDs.Contains(x.CourseID)) { List<CourseSection> SameSubjectSections = CourseSections.Where(y => (y.SubjectID == x.SubjectID && y.CourseID != x.CourseID)).GroupBy(y => y.CourseID).Select(y => y.First()).ToList(); SameSubjectSections.ForEach((y) => { ChongTongCourseSections.Add(new KeyValuePair<CourseSection, CourseSection>(x, y)); }); CourseIDs.Add(x.CourseID); } }); List<UDT.ConflictCourse> conflict_courses = new List<UDT.ConflictCourse>(); ChongTongCourseSections.ForEach((x) => { UDT.ConflictCourse conflict_course = new UDT.ConflictCourse(); conflict_course.SchoolYear = x.Key.SchoolYear; conflict_course.Semester = x.Key.Semester; conflict_course.CourseID_A = x.Key.CourseID; conflict_course.CourseID_B = x.Value.CourseID; conflict_course.CourseName_A = x.Key.CourseName; conflict_course.CourseName_B = x.Value.CourseName; conflict_course.ConflictDate = string.Empty; conflict_course.ConflictWeek = string.Empty; conflict_course.ConflictTime = string.Empty; conflict_course.IsSameSubject = true; conflict_courses.Add(conflict_course); }); conflict_courses.SaveAll(); }