コード例 #1
0
ファイル: AddCourse.cs プロジェクト: ischoolinc/JHEvaluation
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtName.Text.Trim() == "")
            {
                return;
            }
            bool chkHasCourseName = false;
            int  SchoolYear, Semester;

            int.TryParse(cboSchoolYear.Text, out SchoolYear);
            int.TryParse(cboSemester.Text, out Semester);


            foreach (CourseRecord cr in Course.Instance.Items)
            {
                if (cr.SchoolYear == SchoolYear && cr.Semester == Semester && cr.Name == txtName.Text)
                {
                    chkHasCourseName = true;
                    MessageBox.Show("課程名稱重複");
                    break;
                }
            }
            if (chkHasCourseName == false)
            {
                CourseRecordEditor cre = Course.Instance.AddCourse();
                cre.SchoolYear = SchoolYear;
                cre.Semester   = Semester;
                cre.Name       = txtName.Text;
                //2021-10-25 Cynthia 預設不列入學期成績  https://3.basecamp.com/4399967/buckets/15765350/todos/3312348115
                cre.CalculationFlag = "2";
                cre.Save();
                Course.Instance.SyncDataBackground(cre.ID);
                if (chkInputData.Checked == true)
                {
                    foreach (CourseRecord cr in Course.Instance.Items)
                    {
                        if (cr.SchoolYear == SchoolYear && cr.Semester == Semester && cr.Name == txtName.Text)
                        {
                            Course.Instance.PopupDetailPane(cr.ID);
                            Course.Instance.SyncDataBackground(cr.ID);
                        }
                    }
                }
                this.Close();
            }
        }
コード例 #2
0
ファイル: AddCourse.cs プロジェクト: ischoolinc/PSEvaluation
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtName.Text.Trim() == "")
            {
                return;
            }
            bool chkHasCourseName = false;
            int  SchoolYear, Semester;

            int.TryParse(cboSchoolYear.Text, out SchoolYear);
            int.TryParse(cboSemester.Text, out Semester);


            foreach (CourseRecord cr in Course.Instance.Items)
            {
                if (cr.SchoolYear == SchoolYear && cr.Semester == Semester && cr.Name == txtName.Text)
                {
                    chkHasCourseName = true;
                    MessageBox.Show("課程名稱重複");
                    break;
                }
            }
            if (chkHasCourseName == false)
            {
                CourseRecordEditor cre = Course.Instance.AddCourse();
                cre.SchoolYear = SchoolYear;
                cre.Semester   = Semester;
                cre.Name       = txtName.Text;
                cre.Save();
                Course.Instance.SyncDataBackground(cre.ID);
                if (chkInputData.Checked == true)
                {
                    foreach (CourseRecord cr in Course.Instance.Items)
                    {
                        if (cr.SchoolYear == SchoolYear && cr.Semester == Semester && cr.Name == txtName.Text)
                        {
                            Course.Instance.PopupDetailPane(cr.ID);
                            Course.Instance.SyncDataBackground(cr.ID);
                        }
                    }
                }
                this.Close();
            }
        }