コード例 #1
0
        protected void btn_TeacherSalary_Click(object sender, EventArgs e)
        {
            DalOperationAboutTeacherSalary teacherSalaryDal = new DalOperationAboutTeacherSalary();
            if (this.btn_TeacherSalary.Text == "添加")
            {
                string teacherNo = this.teacherNo.Value;
                string termTag = this.TeacherSalary_TermTag.SelectedValue;
                int teacherType = int.Parse(this.teacherType.Value.Trim());

                List<TeacherSalary> teacherSalaries = teacherSalaryDal.GetTeacherSalarys(teacherNo, teacherType, termTag, 0);
                if (teacherSalaries != null && teacherSalaries.Count != 0)
                {
                    Javascript.Alert("本学期已为该教师添加过薪酬预算,请核对信息后再次录入!", Page);
                }
                else {
                    TeachersList teacherList = new TeachersList
                    {
                        teacherNo = this.teacherNo.Value
                    };

                    TeacherSalary salary = new TeacherSalary();
                    salary.teacher = teacherList;
                    if (Course_TR.Visible)
                    {
                        string atCourseType = this.atCourseType.Value;
                        Courses course = new Courses
                        {
                            courseNo = this.CourseId_hf.Value
                        };
                        salary.course = course;
                        salary.atCourseType = int.Parse(atCourseType);
                        salary.teachPeriod = int.Parse(this.teachPeriod.Text.Trim());
                        if (this.experPeriod.Text == null || this.experPeriod.Text.Trim().Length == 0)
                        {
                            salary.experPeriod = 0;
                        }
                        else
                        {
                            salary.experPeriod = int.Parse(this.experPeriod.Text.Trim());
                        }
                    }

                    if (BuildInSalaryItemValueList(salary)) {
                        salary.teacherType = int.Parse(this.teacherType.Value.Trim());
                        salary.termTag = TeacherSalary_TermTag.SelectedValue;
                        salary.memo = teacherSalary_Memo.Text.Trim();
                        using (TransactionScope scope = new TransactionScope())
                        {
                            try
                            {
                                teacherSalaryDal.AddTeacherSalary(salary);
                                AddSalaryEntryDefault(salary);
                                scope.Complete();
                                Javascript.RefreshParentWindow("/Administrator/SalaryManage.aspx?fragment=3", Page);
                            }
                            catch (Exception ex)
                            {
                                MongoDBLog.LogRecord(ex);
                                Javascript.GoHistory(-1, "添加薪酬预算和月发放薪酬记录失败!", Page);
                            }
                        }
                    }
                }
            }
        }