Exemplo n.º 1
0
        private void InitSubjectFieldsList()
        {
            // SubjectField
            ListManager childListControl = (ListManager)Page.LoadControl(ServerPath + ListManager.ControlURL);

            childListControl.ID                   = ChildListType.SubjectFieldInfo.ToString();
            childListControl.InstanceType         = ChildListType.SubjectFieldInfo.ToString();
            childListControl.IsChildList          = true;
            childListControl.ListLabel            = "Subject Field List";
            childListControl.AllowEditAll         = true;
            childListControl.NeedListInstances   += new NeedListInstancesEventHandler(childListControl_NeedListInstances);
            childListControl.InstanceRowSaving   += new InstanceRowSavingEventHandler(childList_InstanceRowSaving);
            childListControl.InstanceRowDeleting += new InstanceRowDeletingEventHandler(childListControl_InstanceRowDeleting);

            GridViewEditCommandColumn editColumn = new GridViewEditCommandColumn();

            childListControl.Columns.Add(editColumn);

            GridViewDeleteButtonColumn deleteColumn = new GridViewDeleteButtonColumn();

            deleteColumn.ConfirmTextFormatString = "Are you sure to delete {0}";
            deleteColumn.ConfirmTextFields       = new string[] { SubjectFieldInfoDto.FLD_TableColumn };
            childListControl.Columns.Add(deleteColumn);

            GridViewDataTextColumn tcc = new GridViewDataTextColumn("Table Column", SubjectFieldInfoDto.FLD_TableColumn);

            tcc.IsReadOnly = true;
            childListControl.Columns.Add(tcc);
            GridViewDataColumn maxC = new GridViewDataColumn("Length In Table", SubjectFieldInfoDto.FLD_MaxLengthInTable);

            maxC.IsReadOnly = true;
            childListControl.Columns.Add(maxC);

            childListControl.Columns.Add(new GridViewDataColumn("Max Length", SubjectFieldInfoDto.FLD_MaxLength));

            childListControl.Columns.Add(new GridViewDataTextColumn("Field Label", SubjectFieldInfoDto.FLD_FieldLabel));
            childListControl.Columns.Add(new GridViewDataTextColumn("Help Text", SubjectFieldInfoDto.FLD_HelpText));
            childListControl.Columns.Add(new GridViewDropDownListColumn("Data Type", SubjectFieldInfoDto.FLD_FieldDataTypeId, DataTypeList));

            GridViewDropDownListColumn lookupCol = new GridViewDropDownListColumn("Lookup Subject", SubjectFieldInfoDto.FLD_LookupSubjectId, SubjectList);

            childListControl.Columns.Add(lookupCol);
            lookupCol.enableEmptyItem = true;

            GridViewDropDownListColumn pickupCol = new GridViewDropDownListColumn("Pickup Entity", SubjectFieldInfoDto.FLD_PickupEntityId, EntityList);

            childListControl.Columns.Add(pickupCol);
            pickupCol.enableEmptyItem = true;

            childListControl.Columns.Add(new GridViewDataColumn("Sort", SubjectFieldInfoDto.FLD_Sort));
            childListControl.Columns.Add(new GridViewDataColumn("Row Index", SubjectFieldInfoDto.FLD_RowIndex));
            childListControl.Columns.Add(new GridViewDataColumn("Col Index", SubjectFieldInfoDto.FLD_ColIndex));
            childListControl.Columns.Add(new GridViewDataCheckColumn("Required", SubjectFieldInfoDto.FLD_IsRequired));
            childListControl.Columns.Add(new GridViewDataCheckColumn("Readonly", SubjectFieldInfoDto.FLD_IsReadonly));
            childListControl.Columns.Add(new GridViewDataCheckColumn("ShowInGrid", SubjectFieldInfoDto.FLD_IsShowInGrid));
            childListControl.Columns.Add(new GridViewDataCheckColumn("LinkInGrid", SubjectFieldInfoDto.FLD_IsLinkInGrid));

            // Add empty row above the list control
            HtmlTable    table = new HtmlTable();
            HtmlTableRow row   = new HtmlTableRow();

            row.Height = "10";
            table.Rows.Add(row);
            PlaceHolder1.Controls.Add(table);
            // Add the child list control
            PlaceHolder1.Controls.Add(childListControl);
        }
Exemplo n.º 2
0
        private void DefineColumns()
        {
            foreach (SubjectFieldDto field in CurrentSubject.SubjectFields)
            {
                if (field.IsShowInGrid)
                {
                    if (field.FieldKey.Equals(ControlledFieldName, StringComparison.OrdinalIgnoreCase))
                    {
                        continue;
                    }
                    // Todo: implement multi-language
                    string headerText = field.GetFieldLabelByLanguage(CurrentUserContext.CurrentLanguage.Id);
                    if (field.IsLinkInGrid && field.DucType != DucTypes.Lookup && field.DucType != DucTypes.Pickup)
                    {
                        GridViewLinkButtonColumn hc = new GridViewLinkButtonColumn(headerText, field.FieldKey);
                        ucListManager.Columns.Add(hc);
                        hc.EditColumnIndex             = field.ColIndex;
                        hc.DataNavigateUrlFormatString = ServerPath + field.LookupSubjectManageUrlFormatString;
                        if (field.DucType == DucTypes.Lookup && field.LookupSubjectId != null)
                        {
                            // Link to another subject by LookupSubjectId
                            hc.DataNavigateUrlField = field.FieldKey;
                        }
                        else
                        {
                            // Link to current subject
                            if (MasterInstance != null)
                            {
                                // Add MasterInstance
                                hc.DataNavigateUrlFormatString += string.Format("&{0}={1}", QryMasterInstanceId, MasterInstance.Id);
                            }
                            hc.DataNavigateUrlField = BaseDto.FLD_StringId;
                        }
                    }
                    else
                    {
                        switch (field.DucType)
                        {
                        case DucTypes.Lookup:
                        case DucTypes.Pickup:
                            GridViewDropDownListColumn ddlCol = new GridViewDropDownListColumn(headerText, field.FieldKey, field.ListDataSource);
                            ucListManager.Columns.Add(ddlCol);
                            ddlCol.IsReadOnly      = field.IsReadonly;
                            ddlCol.enableEmptyItem = !field.IsRequired;
                            ddlCol.EditColumnIndex = field.ColIndex;
                            ddlCol.DropDownHeight  = WebContext.Current.ApplicationOption.DropDownHeight;
                            break;

                        case DucTypes.Text:
                        case DucTypes.TextArea:
                        case DucTypes.Currency:
                        case DucTypes.Email:
                        case DucTypes.Formula:
                        case DucTypes.Integer:
                        case DucTypes.Number:
                        case DucTypes.Percentage:
                            GridViewDataTextColumn textCol = new GridViewDataTextColumn(headerText, field.FieldKey);
                            ucListManager.Columns.Add(textCol);
                            textCol.IsReadOnly      = field.IsReadonly;
                            textCol.EditColumnIndex = field.ColIndex;
                            if (field.MaxLength.HasValue)
                            {
                                textCol.MaxLength = field.MaxLength.Value;
                            }
                            break;

                        case DucTypes.Date:
                            GridViewDataDateColumn dateCol = new GridViewDataDateColumn(headerText, field.FieldKey);
                            ucListManager.Columns.Add(dateCol);
                            dateCol.IsReadOnly      = field.IsReadonly;
                            dateCol.EditColumnIndex = field.ColIndex;
                            break;

                        case DucTypes.Datetime:
                            GridViewDataDateTimeColumn dateTimeCol = new GridViewDataDateTimeColumn(headerText, field.FieldKey);
                            ucListManager.Columns.Add(dateTimeCol);
                            dateTimeCol.IsReadOnly      = field.IsReadonly;
                            dateTimeCol.EditColumnIndex = field.ColIndex;
                            break;

                        case DucTypes.Time:
                            GridViewDataTimeColumn timeCol = new GridViewDataTimeColumn(headerText, field.FieldKey);
                            ucListManager.Columns.Add(timeCol);
                            timeCol.IsReadOnly      = field.IsReadonly;
                            timeCol.EditColumnIndex = field.ColIndex;
                            break;

                        case DucTypes.Image:
                            GridViewBinaryImageColumn ic = new GridViewBinaryImageColumn(headerText, field.FieldKey);
                            ucListManager.Columns.Add(ic);
                            ic.IsReadOnly      = field.IsReadonly;
                            ic.EditColumnIndex = field.ColIndex;
                            ic.ImageWidth      = 60;
                            ic.ImageHeight     = 80;
                            break;

                        case DucTypes.Attachment:
                            GridViewAttachmentColumn ac = new GridViewAttachmentColumn(headerText, field.FieldKey);
                            ucListManager.Columns.Add(ac);
                            ac.IsReadOnly              = field.IsReadonly;
                            ac.EditColumnIndex         = field.ColIndex;
                            ac.NavigateUrlFormatString = ServerPath + field.NavigateUrlFormatString;
                            ac.NavigateUrlField        = BaseDto.FLD_StringId;
                            ac.LinkTextField           = BA.Core.UIConst.FLD_LinkText;
                            break;

                        default:
                            GridViewDataColumn c = new GridViewDataColumn(headerText, field.FieldKey);
                            ucListManager.Columns.Add(c);
                            c.IsReadOnly      = field.IsReadonly;
                            c.EditColumnIndex = field.ColIndex;
                            if (field.MaxLength.HasValue)
                            {
                                c.MaxLength = field.MaxLength.Value;
                            }
                            break;
                        }
                    }
                }
            }

            if (AllowEdit)
            {
                GridViewEditCommandColumn editColumn = new GridViewEditCommandColumn();
                ucListManager.Columns.Add(editColumn);
                editColumn.UniqueName    = "edt0001";
                editColumn.NonExportable = true;
            }
            if (AllowDelete)
            {
                GridViewDeleteButtonColumn deleteColumn = new GridViewDeleteButtonColumn();
                ucListManager.Columns.Add(deleteColumn);
                deleteColumn.UniqueName              = "del0001";
                deleteColumn.NonExportable           = true;
                deleteColumn.ConfirmTextFormatString = "Are you sure to delete {0}";
                deleteColumn.ConfirmTextFields       = new string[] { BaseDto.FLD_Display };
            }
        }