Пример #1
0
        public virtual void LoadFormData(Appointment appointment)
        {
            Boolean fromParent = false; //  从上级模板加载模板

            try {
                if (!String.IsNullOrEmpty(appointment.CustomFields["TaskTemplateId"].ToString()))
                {
                    this.barTaskTemplate.Enabled = false;
                    this.taskTemplates.Add(
                        new TaskTemplate(
                            appointment.CustomFields["TaskTemplateId"].ToString()
                            , TaskTemplateService.getTaskTemplateNameById(appointment.CustomFields["TaskTemplateId"].ToString())
                            )
                        );;
                    this.repositoryItemComboBox1.Items.Add(appointment.CustomFields["TaskTemplateName"].ToString());
                    this.barTaskTemplate.EditValue = appointment.CustomFields["TaskTemplateName"].ToString();
                }
                else
                {
                    fromParent = true;
                }
            }
            catch (Exception) {
                fromParent = true;
            }
            if (fromParent)
            {
                //  当没有选择模板
                this.nextTaskTemplates = TaskTemplateService.getByFrontTaskTemplateId(this.parentTaskTemplateId);

                this.barTaskTemplate.Enabled = true;
                if (this.nextTaskTemplates.Count > 0)
                {
                    foreach (NextTaskTemplate nextTaskTemplate in this.nextTaskTemplates)
                    {
                        this.repositoryItemComboBox1.Items.Add(nextTaskTemplate.TaskTemplateName);
                    }
                    //this.barTaskTemplate.EditValue = this.nextTaskTemplates[0].TaskTemplateName;
                }
            }

            this.chineseLocale();   //  本地化

            //  选择任务模板的事件
            this.repositoryItemComboBox1.SelectedIndexChanged += TaskTemplateSelectedIndexChanged;
        }