예제 #1
0
        public ClassImportWizard()
        {
            InitializeComponent();

            #region 設定Wizard會跟著Style跑
            (GlobalManager.Renderer as Office2007Renderer).ColorTableChanged += new EventHandler(ClassImportWizard_ColorTableChanged);
            //this.ImportWizard.FooterStyle.ApplyStyle(( GlobalManager.Renderer as Office2007Renderer ).ColorTable.GetClass(ElementStyleClassKeys.RibbonFileMenuBottomContainerKey));
            this.ImportWizard.HeaderStyle.ApplyStyle((GlobalManager.Renderer as Office2007Renderer).ColorTable.GetClass(ElementStyleClassKeys.RibbonFileMenuBottomContainerKey));
            this.ImportWizard.FooterStyle.BackColorGradientAngle = -90;
            this.ImportWizard.FooterStyle.BackColorGradientType  = eGradientType.Linear;
            this.ImportWizard.FooterStyle.BackColor  = (GlobalManager.Renderer as Office2007Renderer).ColorTable.RibbonBar.Default.TopBackground.Start;
            this.ImportWizard.FooterStyle.BackColor2 = (GlobalManager.Renderer as Office2007Renderer).ColorTable.RibbonBar.Default.TopBackground.End;
            this.ImportWizard.BackColor       = (GlobalManager.Renderer as Office2007Renderer).ColorTable.RibbonBar.Default.TopBackground.Start;
            this.ImportWizard.BackgroundImage = null;
            for (int i = 0; i < 5; i++)
            {
                (this.ImportWizard.Controls[1].Controls[i] as ButtonX).ColorTable = eButtonColor.OrangeWithBackground;
            }
            (this.ImportWizard.Controls[0].Controls[1] as System.Windows.Forms.Label).ForeColor = (GlobalManager.Renderer as Office2007Renderer).ColorTable.RibbonBar.MouseOver.TitleText;
            (this.ImportWizard.Controls[0].Controls[2] as System.Windows.Forms.Label).ForeColor = (GlobalManager.Renderer as Office2007Renderer).ColorTable.RibbonBar.Default.TitleText;
            #endregion

            //SmartSchool.Common.SkillSchool.SetConnection("smartschool@dev", "admin", "1234");
            _context            = new WizardContext();
            _data_source        = new ImportDataAccess();
            _context.DataSource = _data_source;
        }
예제 #2
0
        private void UpdateTeacherInformation(SheetHelper sheet)
        {
            Dictionary <string, string> selectedFields = new Dictionary <string, string>();

            foreach (string each in Context.SelectedFields)
            {
                selectedFields.Add(each, each);
            }

            if (!UpdateRequired(selectedFields))
            {
                return;
            }
            bool doAddRequired = false;

            ImportCondition condition   = GetIdentifyField();
            CourseLookup    lookup      = new CourseLookup(condition);
            TeacherLookup   tlookup     = Context.Extensions[TeacherLookup.Name] as TeacherLookup;
            SheetRowSource  sheetSource = new SheetRowSource(sheet, Context);

            XmlElement removeReq = DSXmlHelper.LoadXml("<Request/>");
            XmlElement addReq    = DSXmlHelper.LoadXml("<Request/>");

            int firstRow = sheet.FirstDataRowIndex, maxRow = sheet.MaxDataRowIndex;

            for (int rowIndex = firstRow; rowIndex <= maxRow; rowIndex++)
            {
                sheetSource.BindRow(rowIndex);

                string courseId = lookup.GetCourseID(sheetSource);

                if (string.IsNullOrEmpty(courseId))
                {
                    throw new Exception("資料更新過程中,資料可能被另一使用者更改,匯入資料失敗。");
                }

                if (selectedFields.ContainsKey("授課教師一"))
                {
                    XmlElement removeItem = CreateChild(removeReq, "Course");
                    CreateChild(removeItem, "CourseID").InnerText = courseId;
                    CreateChild(removeItem, "Sequence").InnerText = "1";
                }

                if (selectedFields.ContainsKey("授課教師二"))
                {
                    XmlElement removeItem = CreateChild(removeReq, "Course");
                    CreateChild(removeItem, "CourseID").InnerText = courseId;
                    CreateChild(removeItem, "Sequence").InnerText = "2";
                }

                if (selectedFields.ContainsKey("授課教師三"))
                {
                    XmlElement removeItem = CreateChild(removeReq, "Course");
                    CreateChild(removeItem, "CourseID").InnerText = courseId;
                    CreateChild(removeItem, "Sequence").InnerText = "3";
                }

                if (selectedFields.ContainsKey("授課教師一"))
                {
                    string teacherId = tlookup.GetTeacherID(sheetSource.GetFieldData("授課教師一"));
                    if (!string.IsNullOrEmpty(teacherId))
                    {
                        XmlElement addItem = CreateChild(addReq, "CourseTeacher");
                        CreateChild(addItem, "RefCourseID").InnerText  = courseId;
                        CreateChild(addItem, "RefTeacherID").InnerText = teacherId;
                        CreateChild(addItem, "Sequence").InnerText     = "1";
                        doAddRequired = true;
                    }
                }

                if (selectedFields.ContainsKey("授課教師二"))
                {
                    string teacherId = tlookup.GetTeacherID(sheetSource.GetFieldData("授課教師二"));
                    if (!string.IsNullOrEmpty(teacherId))
                    {
                        XmlElement addItem = CreateChild(addReq, "CourseTeacher");
                        CreateChild(addItem, "RefCourseID").InnerText  = courseId;
                        CreateChild(addItem, "RefTeacherID").InnerText = teacherId;
                        CreateChild(addItem, "Sequence").InnerText     = "2";
                        doAddRequired = true;
                    }
                }

                if (selectedFields.ContainsKey("授課教師三"))
                {
                    string teacherId = tlookup.GetTeacherID(sheetSource.GetFieldData("授課教師三"));
                    if (!string.IsNullOrEmpty(teacherId))
                    {
                        XmlElement addItem = CreateChild(addReq, "CourseTeacher");
                        CreateChild(addItem, "RefCourseID").InnerText  = courseId;
                        CreateChild(addItem, "RefTeacherID").InnerText = teacherId;
                        CreateChild(addItem, "Sequence").InnerText     = "3";
                        doAddRequired = true;
                    }
                }
            }

            ImportDataAccess da = Context.DataSource as ImportDataAccess;

            da.RemoveCourseTeachers(removeReq);

            if (doAddRequired)
            {
                da.AddCourseTeachers(addReq);
            }
        }