コード例 #1
0
    private void RenderForm()
    {
        var grantToWrite       = this.ApplicationUser.HasGrantToWrite(ApplicationGrant.Objetivo);
        var defaultComboOption = FormSelectOption.DefaultOption(this.Dictionary);

        this.TxtRecursos = new FormTextArea
        {
            Value        = this.Objetivo.Resources,
            Label        = this.Dictionary["Item_Objetivo_FieldLabel_Resources"],
            Name         = "TxtResources",
            Rows         = 3,
            GrantToWrite = grantToWrite
        };

        this.TxtMetodologia = new FormTextArea
        {
            Value        = this.Objetivo.Methodology,
            Label        = this.Dictionary["Item_Objetivo_FieldLabel_Methodology"],
            Name         = "TxtMethodology",
            Rows         = 3,
            GrantToWrite = grantToWrite
        };

        this.TxtNotes = new FormTextArea
        {
            Value        = this.Objetivo.Notes,
            Label        = this.Dictionary["Item_Objetivo_FieldLabel_Notes"],
            Name         = "TxtNotes",
            Rows         = 3,
            GrantToWrite = grantToWrite
        };

        this.CmbResponsible = new FormSelect
        {
            ColumnsSpanLabel = 1,
            Label            = this.Dictionary["Item_Objetivo_FieldLabel_Responsible"],
            ColumnsSpan      = 3,
            Name             = "CmbResponsible",
            GrantToWrite     = grantToWrite,
            Required         = true,
            RequiredMessage  = this.Dictionary["Common_Required"],
            DefaultOption    = defaultComboOption
        };

        this.CmbResponsibleClose = new FormSelect
        {
            ColumnsSpanLabel = 3,
            Label            = this.Dictionary["Item_Objetivo_FieldLabel_CloseResponsible"],
            ColumnsSpan      = 9,
            Name             = "CmbEndResponsible",
            GrantToWrite     = grantToWrite,
            DefaultOption    = defaultComboOption,
            RequiredMessage  = this.Dictionary["Common_Required"],
            Required         = true
        };

        this.CmbResponsibleRecord = new FormSelect
        {
            ColumnsSpanLabel = 3,
            Label            = this.Dictionary["Item_IndicatorRecord_FieldLabel_Responsible"],
            ColumnsSpan      = 9,
            Name             = "CmbResponsibleRecord",
            GrantToWrite     = grantToWrite,
            DefaultOption    = defaultComboOption,
            Required         = true,
            RequiredMessage  = this.Dictionary["Common_Required"]
        };

        this.CmbIndicador = new FormSelect
        {
            ColumnsSpanLabel = 1,
            Label            = this.Dictionary["Item_Objetivo_FieldLabel_Indicator"],
            ColumnsSpan      = 3,
            Name             = "CmbIndicador",
            GrantToWrite     = grantToWrite,
            Required         = true,
            RequiredMessage  = this.Dictionary["Common_Required"],
            DefaultOption    = defaultComboOption
        };

        foreach (var indicador in Indicador.ByCompany(this.Company.Id))
        {
            if (indicador.Active || indicador.Id == this.Objetivo.IndicatorId)
            {
                this.CmbIndicador.AddOption(new FormSelectOption
                {
                    Value    = indicador.Id.ToString(),
                    Text     = indicador.Description,
                    Selected = indicador.Id == this.Objetivo.IndicatorId
                });
            }
        }

        foreach (var e in this.Company.Employees)
        {
            if (e.Active && e.DisabledDate == null)
            {
                this.CmbResponsible.AddOption(new FormSelectOption
                {
                    Value    = e.Id.ToString(),
                    Text     = e.FullName,
                    Selected = e.Id == this.Objetivo.Responsible.Id
                });

                this.CmbResponsibleClose.AddOption(new FormSelectOption
                {
                    Value    = e.Id.ToString(),
                    Text     = e.FullName,
                    Selected = e.Id == this.Objetivo.EndResponsible.Id
                });

                this.CmbResponsibleRecord.AddOption(new FormSelectOption
                {
                    Value    = e.Id.ToString(),
                    Text     = e.FullName,
                    Selected = false
                });
            }
        }

        this.TxtFechaCierrePrevista = new FormDatePicker
        {
            Id               = "TxtFechaCierrePrevista",
            Value            = this.Objetivo.PreviewEndDate,
            ColumnsSpan      = Constant.ColumnSpan4,
            ColumnsSpanLabel = Constant.ColumnSpan2,
            Label            = this.Dictionary["Item_Objetivo_FieldLabel_ClosePreviewDate"]
        };

        this.TxtFechaCierreReal = new FormDatePicker
        {
            Id               = "TxtFechaCierreReal",
            Value            = this.Objetivo.EndDate,
            ColumnsSpan      = Constant.ColumnSpan4,
            ColumnsSpanLabel = Constant.ColumnSpan2,
            Label            = this.Dictionary["Item_Objetivo_FieldLabel_CloseRealDate"]
        };
    }