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;
        }
示例#2
0
        public Frm新建任务(Frm任务S form)
        {
            InitializeComponent();

            this.form     = form;
            this.owner_id = form.owner_id;

            RefrashGridcontrol();
            this.chineseLocale();
            //  选择任务模板的事件
            this.repositoryItemComboBox1.SelectedIndexChanged += TaskTemplateSelectedIndexChanged;

            //显示的数据
            this.comboBoxEmp.DisplayMember = "Name"; //name为类A的字段名
            //隐藏的数据(对于多个数据,可以用逗号隔开。例:id,name)
            this.comboBoxEmp.ValueMember = "Id";     //id为类A的字段名(对于隐藏对个数据,把数据放到一个字段用逗号隔开)
            List <String> emps = new List <string>();

            emps.Add(this.owner_id);
            this.comboBoxEmp.DataSource = EmpService.findByIds(emps);

            //  当没有选择模板
            this.nextTaskTemplates = TaskTemplateService.getByFrontTaskTemplateId(this.parentTaskTemplateId);

            this.barTaskTemp.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;
            }

            //  初始化任务model
            this.appointmentModel = new AppointmentModel();
            this.appointmentModel.build难度(1);

            /// 参与者
            this.searchLookUpEdit1.EditValue = ""; //  name
            this.searchLookUpEdit1.ToolTip   = ""; //  id
        }