コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Id   = Convert.ToInt32(Request["id"]);
            Type = Request["type"];

            if (!IsPostBack)
            {
                ResetForm();

                // new
                if (Type == "0")
                {
                    //
                }
                // modify
                else
                {
                    var gradeSchema = new CGradeSchema();
                    var grade       = gradeSchema.Get(Id);
                    if (grade != null)
                    {
                        RadTextBoxName.Text = grade.Name;
                        if (grade.IsGlobal)
                        {
                            RadComboBoxIsGlobal.SelectedIndex = 0;
                        }
                        else
                        {
                            RadComboBoxIsGlobal.SelectedIndex = 1;
                        }

                        if (grade.ProgramId != null)
                        {
                            var program = new CProgram().Get(Convert.ToInt32(grade.ProgramId));
                            if (program != null)
                            {
                                var programGroup = new CProgramGroup().Get(Convert.ToInt32(program.ProgramGroupId));
                                if (programGroup != null)
                                {
                                    RadComboBoxFaculty.SelectedValue = programGroup.FacultyId.ToString();
                                    LoadProgramGroup(RadComboBoxFaculty.SelectedValue);
                                }
                                RadComboBoxProgramGroup.SelectedValue = program.ProgramGroupId.ToString();
                                LoadProgram(RadComboBoxProgramGroup.SelectedValue);
                            }
                            RadComboBoxProgram.SelectedValue = program.ProgramId.ToString();
                            LoadProgramCourse(RadComboBoxProgram.SelectedValue);

                            if (grade.ProgramCourseId != null)
                            {
                                var programCourse = new CProgramCourse().Get(Convert.ToInt32(grade.ProgramCourseId));
                                if (programCourse != null)
                                {
                                    RadComboBoxProgramCourse.SelectedValue = programCourse.ProgramCourseId.ToString();
                                    LoadProgramCourseLevel(RadComboBoxProgramCourse.SelectedValue);

                                    if (grade.ProgramCourseLevelId != null)
                                    {
                                        var programCourseLevel = new CProgramCourseLevel().Get(Convert.ToInt32(grade.ProgramCourseLevelId));
                                        if (programCourseLevel != null)
                                        {
                                            RadComboBoxProgramCourseLevel.SelectedValue = programCourseLevel.ProgramCourseLevelId.ToString();
                                            LoadProgramClass(RadComboBoxProgram.SelectedValue, RadComboBoxProgramCourse.SelectedValue, RadComboBoxProgramCourseLevel.SelectedValue);

                                            if (grade.ProgramClassId != null)
                                            {
                                                var programclass = new CProgramClass().Get(Convert.ToInt32(grade.ProgramClassId));
                                                if (programclass != null)
                                                {
                                                    RadComboBoxProgramClass.SelectedValue = programclass.ProgramClassId.ToString();
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            RadComboBoxFaculty.OpenDropDownOnLoad            = false;
            RadComboBoxProgramGroup.OpenDropDownOnLoad       = false;
            RadComboBoxProgram.OpenDropDownOnLoad            = false;
            RadComboBoxProgramCourse.OpenDropDownOnLoad      = false;
            RadComboBoxProgramCourseLevel.OpenDropDownOnLoad = false;
            RadComboBoxProgramClass.OpenDropDownOnLoad       = false;
        }
コード例 #2
0
        protected void RadToolBar1_OnButtonClick(object sender, RadToolBarEventArgs e)
        {
            if (e.Item.Text == "Save")
            {
                var cGradeSchema = new CGradeSchema();
                var gradeSchema  = new Erp2016.Lib.GradeSchema();

                // new
                if (Type == "0")
                {
                    gradeSchema                = new Erp2016.Lib.GradeSchema();
                    gradeSchema.CreatedId      = CurrentUserId;
                    gradeSchema.CreatedDate    = DateTime.Now;
                    gradeSchema.SiteLocationId = CurrentSiteLocationId;

                    if (RadComboBoxIsGlobal.SelectedValue == "1")
                    {
                        var result = cGradeSchema.GetGlobal(CurrentSiteLocationId);
                        if (result != null)
                        {
                            Type        = "1";
                            gradeSchema = result;
                        }
                    }
                }
                // modify
                else
                {
                    gradeSchema = cGradeSchema.Get(Id);
                }

                gradeSchema.Name     = RadTextBoxName.Text;
                gradeSchema.IsGlobal = RadComboBoxIsGlobal.SelectedValue == "1" ? true : false;

                if (!string.IsNullOrEmpty(RadComboBoxProgram.SelectedValue))
                {
                    gradeSchema.ProgramId = Convert.ToInt32(RadComboBoxProgram.SelectedValue);
                }

                if (!string.IsNullOrEmpty(RadComboBoxProgramCourse.SelectedValue))
                {
                    gradeSchema.ProgramCourseId = Convert.ToInt32(RadComboBoxProgramCourse.SelectedValue);
                }

                if (!string.IsNullOrEmpty(RadComboBoxProgramCourseLevel.SelectedValue))
                {
                    gradeSchema.ProgramCourseLevelId = Convert.ToInt32(RadComboBoxProgramCourseLevel.SelectedValue);
                }

                if (!string.IsNullOrEmpty(RadComboBoxProgramClass.SelectedValue))
                {
                    gradeSchema.ProgramClassId = Convert.ToInt32(RadComboBoxProgramClass.SelectedValue);
                }

                if (gradeSchema.IsGlobal)
                {
                    gradeSchema.ProgramId            = null;
                    gradeSchema.ProgramCourseId      = null;
                    gradeSchema.ProgramCourseLevelId = null;
                    gradeSchema.ProgramClassId       = null;
                }

                // new
                if (Type == "0")
                {
                    cGradeSchema.Add(gradeSchema);
                }
                // modify
                else
                {
                    gradeSchema.UpdatedId   = CurrentUserId;
                    gradeSchema.UpdatedDate = DateTime.Now;
                    cGradeSchema.Update(gradeSchema);
                }

                RunClientScript("Close();");
            }
        }