protected override void OnClick(EventArgs e)
        {
            base.OnClick(e);

            FastTrackPage page = this.Page as FastTrackPage;

            if (page != null)
            {
                PropertyInfo property = page.GetPropertyInfo(page.SelectedPropertyName);
                if (property != null)
                {
                    if (page.IsListProperty(property.Name))
                    {
                        IList list = (IList)page.GetPropertyValue(property.Name);
                        list.Add(obj);
                    }
                    else
                    {
                        page.SetPropertyValue(property.Name, obj);
                    }

                    page.SaveObject(page.SelectedObject);

                    page.Response.Redirect(page.GetEditUrl(page.SelectedObject, ""));
                }
            }
        }
Ejemplo n.º 2
0
        public static Control GetPropertyValueEditor(FastTrackPage page, Type type, PropertyInfo property)
        {
            Control editor = null;

            if (page.IsListProperty(type, property.Name))
            {
                editor = new ListEditor(property.Name);
            }
            else
            {
                Type propertyType = property.PropertyType;

                if (propertyType.IsEnum)
                    editor = new EnumerationEditor(property.Name);

                else if (propertyType.IsPrimitive)
                {
                    if (propertyType == typeof(bool))
                        editor = new BooleanEditor(property.Name);

                    else if (propertyType == typeof(Int16)
                       || propertyType == typeof(Int32)
                       || propertyType == typeof(Int64)
                       || propertyType == typeof(Byte))
                        editor = new NumberEditor(property.Name);
                }
                else if (propertyType.IsValueType)
                {
                    if (propertyType == typeof(DateTime))
                        editor = new DateTimeEditor(property.Name);

                    else if (propertyType == typeof(Decimal))
                        editor = new NumberEditor(property.Name);
                }
                else if (propertyType.IsClass)
                {
                    if (propertyType == typeof(string))
                        editor = new StringEditor(property.Name);

                    else if (propertyType == typeof(byte[]))
                        ; //editor = new DateTimeEditor(property.Name);

                    else
                    {
                        editor = new ReferenceEditor(property.Name);
                    }
                }
            }

            return editor;
        }
        protected override void OnClick(EventArgs e)
        {
            base.OnClick(e);

            FastTrackPage page = this.Page as FastTrackPage;

            if (page != null)
            {
                PropertyInfo property = page.GetPropertyInfo(propertyName);
                if (property != null)
                {
                    Type type = property.PropertyType;
                    if (page.IsListProperty(property.Name))
                    {
                        type = page.GetListPropertyItemType(property.Name);
                    }
                    page.Response.Redirect(page.GetListUrl(type, this.listUrl, page.SelectedObject, propertyName));
                }
            }
        }
Ejemplo n.º 4
0
        private void CreateRow(FastTrackPage page, object value, TableRow row, ArrayList properties)
        {
            if (page.SelectedPropertyName != null && page.SelectedPropertyName != "")
            {
                if (page.SelectedObject != null)
                {
                    TableCell cell = new TableCell();
                    SelectListItemLinkButton link = new SelectListItemLinkButton(value);
                    link.Text = "Select";
                    row.Cells.Add(cell);
                    cell.Controls.Add(link);
                    cell.BackColor = this.ForeColor;
                }
            }

            if (propertyName != null && propertyName != "")
            {
                TableCell cell = new TableCell();
                RemoveListItemLinkButton link = new RemoveListItemLinkButton(value, propertyName);
                link.Text = "Remove";
                row.Cells.Add(cell);
                cell.Controls.Add(link);
                cell.BackColor = this.ForeColor;
            }

            TableCell viewCell = new TableCell();
            ViewListItemLinkButton viewLink = new ViewListItemLinkButton(value);

            viewLink.Text = "View";
            row.Cells.Add(viewCell);
            viewCell.Controls.Add(viewLink);
            viewCell.BackColor = this.ForeColor;

            TableCell editCell = new TableCell();
            EditListItemLinkButton editLink = new EditListItemLinkButton(value);

            editLink.Text = "Edit";
            row.Cells.Add(editCell);
            editCell.Controls.Add(editLink);
            editCell.BackColor = this.ForeColor;

            TableCell deleteCell = new TableCell();
            DeleteListItemLinkButton deleteLink = new DeleteListItemLinkButton();

            deleteLink.Text = "Delete";
            row.Cells.Add(deleteCell);
            deleteCell.Controls.Add(deleteLink);
            deleteCell.BackColor = this.ForeColor;

            foreach (PropertyInfo property in properties)
            {
                TableCell cell  = new TableCell();
                Label     label = new Label();
                label.ForeColor = Color.Black;

                object propertyValue = page.GetPropertyValue(value, property.Name);

                if (page.IsListProperty(value, property.Name))
                {
                    int count = 0;
                    if (propertyValue != null)
                    {
                        count = ((IList)propertyValue).Count;
                    }
                    label.Text = count.ToString() + " items";
                }
                else
                {
                    if (propertyValue != null)
                    {
                        label.Text = propertyValue.ToString();
                    }
                }

                row.Cells.Add(cell);
                cell.Controls.Add(label);
                cell.BackColor = this.ForeColor;
            }
        }
Ejemplo n.º 5
0
        private void CreateRow(FastTrackPage page, object value, TableRow row, ArrayList properties)
        {
            if (page.SelectedPropertyName != null && page.SelectedPropertyName != "")
            {
                if (page.SelectedObject != null)
                {
                    TableCell cell = new TableCell();
                    SelectListItemLinkButton link = new SelectListItemLinkButton(value);
                    link.Text = "Select";
                    row.Cells.Add(cell);
                    cell.Controls.Add(link);
                    cell.BackColor = this.ForeColor ;
                }
            }

            if (propertyName != null && propertyName != "")
            {
                TableCell cell = new TableCell();
                RemoveListItemLinkButton link = new RemoveListItemLinkButton(value, propertyName);
                link.Text = "Remove";
                row.Cells.Add(cell);
                cell.Controls.Add(link);
                cell.BackColor = this.ForeColor;
            }

            TableCell viewCell = new TableCell();
            ViewListItemLinkButton viewLink = new ViewListItemLinkButton(value);
            viewLink.Text = "View";
            row.Cells.Add(viewCell);
            viewCell.Controls.Add(viewLink);
            viewCell.BackColor = this.ForeColor;

            TableCell editCell = new TableCell();
            EditListItemLinkButton editLink = new EditListItemLinkButton(value);
            editLink.Text = "Edit";
            row.Cells.Add(editCell);
            editCell.Controls.Add(editLink);
            editCell.BackColor = this.ForeColor;

            TableCell deleteCell = new TableCell();
            DeleteListItemLinkButton deleteLink = new DeleteListItemLinkButton();
            deleteLink.Text = "Delete";
            row.Cells.Add(deleteCell);
            deleteCell.Controls.Add(deleteLink);
            deleteCell.BackColor = this.ForeColor;

            foreach (PropertyInfo property in properties)
            {
                TableCell cell = new TableCell();
                Label label = new Label();
                label.ForeColor = Color.Black;

                object propertyValue = page.GetPropertyValue(value, property.Name);

                if (page.IsListProperty(value, property.Name))
                {
                    int count = 0;
                    if (propertyValue != null)
                        count = ((IList)propertyValue).Count;
                    label.Text = count.ToString() + " items";
                }
                else
                {
                    if (propertyValue != null)
                        label.Text = propertyValue.ToString();
                }

                row.Cells.Add(cell);
                cell.Controls.Add(label);
                cell.BackColor = this.ForeColor;
            }
        }
Ejemplo n.º 6
0
        public static Control GetPropertyValueEditor(FastTrackPage page, Type type, PropertyInfo property)
        {
            Control editor = null;

            if (page.IsListProperty(type, property.Name))
            {
                editor = new ListEditor(property.Name);
            }
            else
            {
                Type propertyType = property.PropertyType;

                if (propertyType.IsEnum)
                {
                    editor = new EnumerationEditor(property.Name);
                }

                else if (propertyType.IsPrimitive)
                {
                    if (propertyType == typeof(bool))
                    {
                        editor = new BooleanEditor(property.Name);
                    }


                    else if (propertyType == typeof(Int16) ||
                             propertyType == typeof(Int32) ||
                             propertyType == typeof(Int64) ||
                             propertyType == typeof(Byte))
                    {
                        editor = new NumberEditor(property.Name);
                    }
                }
                else if (propertyType.IsValueType)
                {
                    if (propertyType == typeof(DateTime))
                    {
                        editor = new DateTimeEditor(property.Name);
                    }

                    else if (propertyType == typeof(Decimal))
                    {
                        editor = new NumberEditor(property.Name);
                    }
                }
                else if (propertyType.IsClass)
                {
                    if (propertyType == typeof(string))
                    {
                        editor = new StringEditor(property.Name);
                    }


                    else if (propertyType == typeof(byte[]))
                    {
                        ; //editor = new DateTimeEditor(property.Name);
                    }
                    else
                    {
                        editor = new ReferenceEditor(property.Name);
                    }
                }
            }

            return(editor);
        }