Esempio n. 1
0
 private void AddDeleteCommandFieldInGrid()
 {
     CommandField field = new CommandField();
     field.ButtonType = ButtonType.Image;
     field.DeleteImageUrl = GetTemplateImageUrl("imgdelete.png", true);
     field.ShowDeleteButton = true;
     field.ShowHeader = false;
     gdvRoles.Columns.Add(field);
     gdvRoles.DataBind();
 }
Esempio n. 2
0
        /// <summary>
        /// Binds the grid.
        /// </summary>
        /// <param name="orderBy">The order by.</param>
        protected void BindGrid(string orderBy)
        {
            if(TableSchema != null && TableSchema.PrimaryKey != null)
            {
                SqlQuery query = new Select(TableSchema.Provider).From(TableSchema);

                if(!String.IsNullOrEmpty(_whereExpression))
                    query.WhereExpression(_whereExpression);

                if(_whereCollection != null)
                    SqlQueryBridge.AddLegacyWhereCollection(query, _whereCollection);

                string sortColumn = null;
                if(!String.IsNullOrEmpty(orderBy))
                    sortColumn = orderBy;
                else if(ViewState[ORDER_BY] != null)
                    sortColumn = (string)ViewState[ORDER_BY];

                int colIndex = -1;

                if(!String.IsNullOrEmpty(sortColumn))
                {
                    ViewState.Add(ORDER_BY, sortColumn);
                    TableSchema.TableColumn col = TableSchema.GetColumn(sortColumn);
                    if(col == null)
                    {
                        for(int i = 0; i < TableSchema.Columns.Count; i++)
                        {
                            TableSchema.TableColumn fkCol = TableSchema.Columns[i];
                            if(fkCol.IsForeignKey && !String.IsNullOrEmpty(fkCol.ForeignKeyTableName))
                            {
                                TableSchema.Table fkTbl = DataService.GetSchema(fkCol.ForeignKeyTableName, ProviderName, TableType.Table);
                                if(fkTbl != null)
                                {
                                    col = Utility.GetDisplayTableColumn(fkTbl);
                                    colIndex = i;
                                    break;
                                }
                            }
                        }
                    }
                    if(col != null && col.MaxLength < 2048)
                    {
                        string sortAlias = colIndex > -1 ? SqlFragment.JOIN_PREFIX + colIndex : col.ColumnName;
                        if(ViewState[SORT_DIRECTION] == null || ((string)ViewState[SORT_DIRECTION]) == SqlFragment.ASC)
                        {
                            query.OrderAsc(sortAlias);
                            //query.OrderBy = colIndex > -1 ? OrderBy.Asc(col, SqlFragment.JOIN_PREFIX + colIndex) : OrderBy.Asc(col);
                            ViewState[SORT_DIRECTION] = SqlFragment.ASC;
                        }
                        else
                        {
                            query.OrderDesc(sortAlias);
                            //query.OrderBy = colIndex > -1 ? OrderBy.Desc(col, SqlFragment.JOIN_PREFIX + colIndex) : OrderBy.Desc(col);
                            ViewState[SORT_DIRECTION] = SqlFragment.DESC;
                        }
                    }
                }

                DataTable dt = query.ExecuteJoinedDataSet().Tables[0];
                grid.DataSource = dt;
                grid.AutoGenerateColumns = false;
                grid.Columns.Clear();

                int columnOffset = 0;
                string dataKey = TableSchema.PrimaryKey.ColumnName;
                if(Utility.IsMappingTable(TableSchema) && dt.Columns.Count > TableSchema.Columns.Count)
                {
                    columnOffset = 1;
                    dataKey = dt.Columns[0].ColumnName;
                }

                grid.DataKeyNames = new[] {dataKey};

                CommandField link = new CommandField
                                        {
                                            ShowEditButton = true,
                                            EditText = "Edit"
                                        };

                grid.Columns.Insert(0, link);

                for(int i = 0; i < TableSchema.Columns.Count; i++)
                {
                    int dtColIndex = i + columnOffset;

                    BoundField field = new BoundField
                                           {
                                               DataField = dt.Columns[dtColIndex].ColumnName,
                                               SortExpression = dt.Columns[dtColIndex].ColumnName, HtmlEncode = false
                                           };
                    //field.SortExpression = Utility.QualifyColumnName(schema.Name, dt.Columns[i].ColumnName, schema.Provider);
                    TableSchema.TableColumn col = TableSchema.Columns[i];
                    if(col.IsForeignKey)
                    {
                        TableSchema.Table fkSchema = col.ForeignKeyTableName == null
                                                         ? DataService.GetForeignKeyTable(col, TableSchema)
                                                         : DataService.GetSchema(col.ForeignKeyTableName, ProviderName, TableType.Table);

                        if(fkSchema != null)
                            field.HeaderText = fkSchema.DisplayName;
                    }
                    else
                        field.HeaderText = col.DisplayName;

                    if(!Utility.IsAuditField(dt.Columns[dtColIndex].ColumnName) && !listHiddenGridColumns.Contains(dt.Columns[dtColIndex].ColumnName.ToLower()))
                        grid.Columns.Add(field);
                }

                grid.DataBind();
            }
        }
            public override DataControlFieldsEditor.FieldItem CreateField()
            {
                CommandField runtimeField = new CommandField();
                switch (this.commandType)
                {
                    case 0:
                        runtimeField.ShowEditButton = true;
                        break;

                    case 1:
                        runtimeField.ShowInsertButton = true;
                        break;

                    case 2:
                        runtimeField.ShowSelectButton = true;
                        break;

                    case 3:
                        runtimeField.ShowDeleteButton = true;
                        break;
                }
                DataControlFieldsEditor.FieldItem item = new DataControlFieldsEditor.CommandFieldItem(this._fieldsEditor, runtimeField);
                item.LoadFieldInfo();
                return item;
            }
Esempio n. 4
0
        protected override void OnSchemaRefreshed()
        {
            WebDetailsView wDetailsView = (WebDetailsView)this.Component;
            if (!wDetailsView.AutoGenerateEditButton && !wDetailsView.AutoGenerateDeleteButton && !wDetailsView.AutoGenerateInsertButton)
            {
                CommandField commandField = null;
                DataControlFieldCollection fields = wDetailsView.Fields;
                if (fields != null && fields.Count != 0)
                {
                    foreach (object f in fields)
                    {
                        if (f is CommandField)
                            commandField = (CommandField)f;
                    }
                }
                base.OnSchemaRefreshed();
                if (commandField == null)
                {
                    commandField = new CommandField();
                    commandField.ButtonType = ButtonType.Image;
                    commandField.EditImageUrl = "~/Image/UIPics/Edit.gif";
                    commandField.DeleteImageUrl = "~/Image/UIPics/Delete.gif";
                    commandField.NewImageUrl = "~/Image/UIPics/Add.gif";
                    commandField.UpdateImageUrl = "~/Image/UIPics/OK.gif";
                    commandField.CancelImageUrl = "~/Image/UIPics/Cancel.gif";
                    commandField.InsertImageUrl = "~/Image/UIPics/OK.gif";
                    commandField.ShowEditButton = true;
                    commandField.ShowDeleteButton = true;
                    commandField.ShowInsertButton = true;
                }
                if (!fields.Contains(commandField))
                {
                    fields.Add(commandField);
                    fields.SetDirty();
                }
            }
            else
            {
                base.OnSchemaRefreshed();
            }

            if (wDetailsView.Site != null)
            {
                object obj = wDetailsView.GetObjByID(wDetailsView.DataSourceID);
                if (obj is WebDataSource)
                {
                    DataSet Dset = DBUtils.GetDataDictionary(obj as WebDataSource, true);

                    if (Dset != null && Dset.Tables.Count > 0)
                    {
                        foreach (DataControlField field in wDetailsView.Fields)
                        {
                            if (field is BoundField)
                            {
                                int i = Dset.Tables[0].Rows.Count;
                                for (int j = 0; j < i; j++)
                                {
                                    if (string.Compare(Dset.Tables[0].Rows[j]["FIELD_NAME"].ToString(), ((BoundField)field).DataField, true) == 0)//IgnoreCase
                                    {
                                        string strCaption = Dset.Tables[0].Rows[j]["CAPTION"].ToString();
                                        if (((BoundField)field).HeaderText == ((BoundField)field).DataField && strCaption != "")
                                        {
                                            ((BoundField)field).HeaderText = strCaption;
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 5
0
		protected virtual ICollection CreateColumns (PagedDataSource dataSource, bool useDataSource)
		{
			bool autoGenerate = AutoGenerateColumns;

			if (autoGenerate) {
				IAutoFieldGenerator fieldGenerator = ColumnsGenerator;
				if (fieldGenerator != null)
					return fieldGenerator.GenerateFields (this);
			}
			
			ArrayList fields = new ArrayList ();
			
			if (AutoGenerateEditButton || AutoGenerateDeleteButton || AutoGenerateSelectButton) {
				CommandField field = new CommandField ();
				field.ShowEditButton = AutoGenerateEditButton;
				field.ShowDeleteButton = AutoGenerateDeleteButton;
				field.ShowSelectButton = AutoGenerateSelectButton;
				fields.Add (field);
			}

			fields.AddRange (Columns);
			
			if (autoGenerate) {
				if (useDataSource)
					autoFieldProperties = CreateAutoFieldProperties (dataSource);
	
				if (autoFieldProperties != null) {
					foreach (AutoGeneratedFieldProperties props in autoFieldProperties)
						fields.Add (CreateAutoGeneratedColumn (props));
				}
			}
			
			return fields;
		}
Esempio n. 6
0
        /// <summary>
        /// 
        /// </summary>
        //public void AddDeleteColumn(GridViewDeleteEventHandler handle)
        public void AddDeleteColumn()
        {
            CommandField delete = new CommandField();
            delete.ShowDeleteButton = true;
            //delete.HeaderText = "[Delete]";

            // TODO:
            //
            delete.DeleteText = "<div onclick=\"JavaScript:return confirm('确定删除吗?')\">删除</div>";

            //CommandField edit = new CommandField();
            //edit.ShowEditButton = true;

            _gd.Columns.Add(delete);
            //_gd.RowDeleting += handle;
            //gridview.Columns.Add(edit);
        }
Esempio n. 7
0
		public static void RenderingCommandField (Page p)
		{
			LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
			LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
			GridView grid = new GridView ();
			grid.AutoGenerateColumns = false;
			grid.ShowFooter = true;
			p.Form.Controls.Add (lcb);
			p.Form.Controls.Add (grid);
			p.Form.Controls.Add (lce);
			CommandField commandfield = new CommandField ();
			commandfield.HeaderText = "HeaderText";
			commandfield.FooterText = "FooterText";
			commandfield.ShowCancelButton = true;
			commandfield.ShowDeleteButton = true;
			commandfield.ShowEditButton = true;
			commandfield.ShowInsertButton = true;
			commandfield.ShowSelectButton = true;
			grid.DataSource = GridViewTest.CreateDataSource ();
			grid.Columns.Add (commandfield);
			grid.DataBind ();
		}
        private void SaveManipulationSetting(ManipulationMode mode, bool newState)
        {
            DataControlFieldCollection columns = ((GridView) base.Component).Columns;
            bool flag = false;
            ArrayList list = new ArrayList();
            foreach (DataControlField field in columns)
            {
                CommandField field2 = field as CommandField;
                if (field2 != null)
                {
                    switch (mode)
                    {
                        case ManipulationMode.Edit:
                            field2.ShowEditButton = newState;
                            break;

                        case ManipulationMode.Delete:
                            field2.ShowDeleteButton = newState;
                            break;

                        case ManipulationMode.Select:
                            field2.ShowSelectButton = newState;
                            break;
                    }
                    if (((!newState && !field2.ShowEditButton) && (!field2.ShowDeleteButton && !field2.ShowInsertButton)) && !field2.ShowSelectButton)
                    {
                        list.Add(field2);
                    }
                    flag = true;
                }
            }
            foreach (object obj2 in list)
            {
                columns.Remove((DataControlField) obj2);
            }
            if (!flag && newState)
            {
                CommandField field3 = new CommandField();
                switch (mode)
                {
                    case ManipulationMode.Edit:
                        field3.ShowEditButton = newState;
                        break;

                    case ManipulationMode.Delete:
                        field3.ShowDeleteButton = newState;
                        break;

                    case ManipulationMode.Select:
                        field3.ShowSelectButton = newState;
                        break;
                }
                columns.Insert(0, field3);
            }
            if (!newState)
            {
                PropertyDescriptor descriptor;
                GridView component = (GridView) base.Component;
                switch (mode)
                {
                    case ManipulationMode.Edit:
                        descriptor = TypeDescriptor.GetProperties(typeof(GridView))["AutoGenerateEditButton"];
                        descriptor.SetValue(base.Component, newState);
                        return;

                    case ManipulationMode.Delete:
                        descriptor = TypeDescriptor.GetProperties(typeof(GridView))["AutoGenerateDeleteButton"];
                        descriptor.SetValue(base.Component, newState);
                        return;

                    case ManipulationMode.Select:
                        TypeDescriptor.GetProperties(typeof(GridView))["AutoGenerateSelectButton"].SetValue(base.Component, newState);
                        break;

                    default:
                        return;
                }
            }
        }
        private void LoadGridViewListaRegistros()
        {
            RegistroFinanceiroNegocio registroNegocio = new RegistroFinanceiroNegocio();
            List<RegistroFinanceiro> listRegistros = registroNegocio.ObterTodosRegistros();

            List<AlunoProjeto> listAlunoProjeto = new List<AlunoProjeto>();

            GridViewListaRegistros.Columns.Clear();

            foreach (RegistroFinanceiro reg in listRegistros)
                listAlunoProjeto.Add(reg.AlunoProjeto);

            GridViewListaRegistros.DataSource = listAlunoProjeto;
            GridViewListaRegistros.AutoGenerateColumns = false;

            BoundField bfNomeAluno = new BoundField();
            bfNomeAluno.DataField = "NomeAluno";
            bfNomeAluno.HeaderText = "Aluno";
            GridViewListaRegistros.Columns.Add(bfNomeAluno);

            BoundField bfProjeto = new BoundField();
            bfProjeto.DataField = "NomeProjeto";
            bfProjeto.HeaderText = "Projeto";
            GridViewListaRegistros.Columns.Add(bfProjeto);

            //BoundField bfStatus = new BoundField();
            //bfStatus.DataField = "Status";
            //bfStatus.HeaderText = "Status";
            //GridViewListaRegistros.Columns.Add(bfStatus);

            CommandField cmdField = new CommandField();
            cmdField.ButtonType = ButtonType.Image;
            cmdField.DeleteImageUrl = "Icons/cross.png";
            cmdField.EditImageUrl = "Icons/page_edit.png";
            cmdField.SelectImageUrl = "Icons/money_add.png";
            cmdField.ShowDeleteButton = true;
            cmdField.ShowEditButton = true;
            cmdField.ShowSelectButton = true;
            cmdField.EditText = "Editar Registro";
            cmdField.DeleteText = "Remover Regisro";
            cmdField.SelectText = "Registrar Pagamentos";

            GridViewListaRegistros.Columns.Add(cmdField);

            GridViewListaRegistros.DataBind();
        }
        public void gvBind()
        {
            if (DDLProyectos.SelectedValue == null)
            {
                return;
            }

            DataTable dt = dc.BindGrid(" exec spBuscarDetalleProyecto " + DDLProyectos.SelectedValue);
            DataTable dtConceptos = dc.BindGrid("EXEC spBuscarConceptos 1");

             GridData.Columns.Clear();

            CommandField cfe = new CommandField();
            cfe.EditText = "Actualizar";
            cfe.CancelText = "Cancelar";
            cfe.UpdateText = "Grabar";
            cfe.ShowEditButton = true;
            GridData.Columns.Add(cfe);

            int j = 0;

            foreach (DataColumn col in dt.Columns)
            {
                if (col.ColumnName == "IDEmpleado" || col.ColumnName == "Nombre")
                {
                    //Declare the bound field and allocate memory for the bound field.
                    BoundField bfield = new BoundField();

                    //Initalize the DataField value.
                    bfield.DataField = col.ColumnName;

                    bfield.ReadOnly = true;

                    //Initialize the HeaderText field value.
                    bfield.HeaderText = col.ColumnName;

                    //Add the newly created bound field to the GridView.
                    GridData.Columns.Add(bfield);
                }
                else
                {
                    //Declare the bound field and allocate memory for the bound field.
                    BoundField bfield = new BoundField();

                    // bfield.HeaderStyle.Wrap = false;

                    //Initalize the DataField value.
                    bfield.DataField = col.ColumnName;

                    //Initialize the HeaderText field value.
                    // bfield.HeaderText = col.ColumnName + " - " + dtConceptos.Rows[j]["CONCEPTO"];
                    bfield.HeaderText = col.ColumnName;

                    //Add the newly created bound field to the GridView.
                    GridData.Columns.Add(bfield);

                    j++;
                }

            }

            GridData.DataSource = dt;
            GridData.DataBind();
        }
Esempio n. 11
0
        protected override void OnSchemaRefreshed()
        {
            WebGridView wGridView = (WebGridView)this.Component;
            if (wGridView.WizardDesignMode)
                return;
            if (!wGridView.AutoGenerateEditButton && !wGridView.AutoGenerateDeleteButton && !wGridView.AutoGenerateSelectButton)
            {
                CommandField commandField = null;
                DataControlFieldCollection fields = wGridView.Columns;
                if (fields != null && fields.Count != 0)
                {
                    foreach (object f in fields)
                    {
                        if (f is CommandField)
                            commandField = (CommandField)f;
                    }
                }
                base.OnSchemaRefreshed();
                if (commandField == null)
                {
                    commandField = new CommandField();
                    commandField.ButtonType = ButtonType.Image;
                    commandField.EditImageUrl = "~/Image/UIPics/Edit.gif";
                    commandField.DeleteImageUrl = "~/Image/UIPics/Delete.gif";
                    commandField.SelectImageUrl = "~/Image/UIPics/Select.gif";
                    commandField.UpdateImageUrl = "~/Image/UIPics/OK.gif";
                    commandField.CancelImageUrl = "~/Image/UIPics/Cancel.gif";
                    commandField.ShowEditButton = true;
                    commandField.ShowDeleteButton = true;
                    commandField.ShowSelectButton = true;
                }
                if (!fields.Contains(commandField))
                {
                    fields.Insert(0, commandField);
                    fields.SetDirty();            // 这里在vs2008里有问题
                }
            }
            else
            {
                base.OnSchemaRefreshed();
            }
            if (wGridView.Site != null)
            {
                object obj = wGridView.GetObjByID(wGridView.DataSourceID);
                if (obj is WebDataSource)
                {
                    WebDataSource wds = (WebDataSource)obj;

                    DataSet Dset = DBUtils.GetDataDictionary(wds, true);
                    if (Dset != null && Dset.Tables.Count > 0)
                    {
                        foreach (DataControlField field in wGridView.Columns)
                        {
                            if (field is BoundField)
                            {
                                int i = Dset.Tables[0].Rows.Count;
                                for (int j = 0; j < i; j++)
                                {
                                    if (Dset.Tables[0].Rows[j]["FIELD_NAME"].ToString().ToLower() == ((BoundField)field).DataField.ToLower())
                                    {
                                        string strCaption = Dset.Tables[0].Rows[j]["CAPTION"].ToString();
                                        if (((BoundField)field).HeaderText == ((BoundField)field).DataField && strCaption != "")
                                        {
                                            ((BoundField)field).HeaderText = strCaption;
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
            #if VS90
                    else if (!string.IsNullOrEmpty(wds.LinqDataSetID))
                    {
                        // 先不处理DD
                    }
            #endif
                }
            }
        }
        private void LoadGridViewListaProjetos()
        {
            ProjetoNegocio projeto = new ProjetoNegocio();
            List<Projeto> listProjetos = projeto.ObterTodosProjetos();

            GridViewListaProjetos.Columns.Clear();

            GridViewListaProjetos.DataSource = listProjetos;
            GridViewListaProjetos.AutoGenerateColumns = false;

            BoundField bfCodigo = new BoundField();
            bfCodigo.DataField = "Codigo";
            bfCodigo.HeaderText = "Codigo";
            GridViewListaProjetos.Columns.Add(bfCodigo);

            BoundField bfNomeProjeto = new BoundField();
            bfNomeProjeto.DataField = "Nome";
            bfNomeProjeto.HeaderText = "Nome";
            GridViewListaProjetos.Columns.Add(bfNomeProjeto);

            BoundField bfValorProjeto = new BoundField();
            bfValorProjeto.DataField = "Valor";
            bfValorProjeto.HeaderText = "Valor";
            GridViewListaProjetos.Columns.Add(bfValorProjeto);

            CommandField cmdField = new CommandField();
            cmdField.ButtonType = ButtonType.Image;
            cmdField.DeleteImageUrl = "Icons/cross.png";
            cmdField.EditImageUrl = "Icons/page_edit.png";
            cmdField.ShowDeleteButton = true;
            cmdField.ShowEditButton = true;
            cmdField.EditText = "Editar Projeto";
            cmdField.DeleteText = "Remover Projeto";

            GridViewListaProjetos.Columns.Add(cmdField);

            GridViewListaProjetos.DataBind();
        }
        private void LoadGridViewListaUsuarios()
        {
            UsuarioNegocio usuarioNegocio = new UsuarioNegocio();
            List<Usuario> listUsuarios = usuarioNegocio.ObterTodosUsuarios();

            GridViewListaUsuarios.Columns.Clear();

            GridViewListaUsuarios.DataSource = listUsuarios;
            GridViewListaUsuarios.AutoGenerateColumns = false;

            BoundField bfNomeUsuario = new BoundField();
            bfNomeUsuario.DataField = "Nome";
            bfNomeUsuario.HeaderText = "Nome";
            GridViewListaUsuarios.Columns.Add(bfNomeUsuario);

            BoundField bfLogin = new BoundField();
            bfLogin.DataField = "Login";
            bfLogin.HeaderText = "Login";
            GridViewListaUsuarios.Columns.Add(bfLogin);

            CommandField cmdField = new CommandField();
            cmdField.ButtonType = ButtonType.Image;
            cmdField.DeleteImageUrl = "Icons/cross.png";
            cmdField.EditImageUrl = "Icons/page_edit.png";
            //cmdField.SelectImageUrl = "Icons/money_add.png";
            cmdField.ShowDeleteButton = true;
            cmdField.ShowEditButton = true;
            //cmdField.ShowSelectButton = true;
            cmdField.EditText = "Editar Usuario";
            cmdField.DeleteText = "Remover Usuario";

            GridViewListaUsuarios.Columns.Add(cmdField);
            GridViewListaUsuarios.DataBind();
        }
Esempio n. 14
0
        private void GenerateStructure()
        {
            if (MainGrid.Columns.Count > 0)
                MainGrid.Columns.Clear();

            BoundField field = new BoundField();
            field.DataField = principalColumn;
            field.HeaderText = GetGlobalResourceObject("IbnFramework.GlobalMetaInfo", "Principal").ToString();
            field.HeaderStyle.HorizontalAlign = HorizontalAlign.Left;
            field.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
            field.HeaderStyle.CssClass = "ibn-vh";
            field.HtmlEncode = false;
            MainGrid.Columns.Add(field);

            int rightsCounter = 0;

            foreach (SecurityRight right in Mediachase.Ibn.Data.Services.Security.GetMetaClassRights(mc.Name))
            {
                rightsCounter++;
                field = new BoundField();
                field.DataField = right.RightName;
                field.HeaderText = CHelper.GetResFileString(right.FriendlyName);
                field.HeaderStyle.CssClass = "thCenter";
                field.HtmlEncode = false;
                MainGrid.Columns.Add(field);
            }

            for (int i = 1; i <= rightsCounter; i++)
            {
                MainGrid.Columns[i].HeaderStyle.Width = Unit.Percentage(percentsForRights / rightsCounter);
            }

            // Edit
            field = new BoundField();
            field.DataField = editColumn;
            field.HeaderText = String.Empty;
            field.HtmlEncode = false;
            field.HeaderStyle.Width = Unit.Pixel(25);
            field.ItemStyle.Width = Unit.Pixel(25);
            MainGrid.Columns.Add(field);

            // Delete
            CommandField del = new CommandField();
            del.ButtonType = ButtonType.Link;
            del.DeleteText = String.Format(CultureInfo.InvariantCulture,
                "<img src='{0}' width='16' height='16' border='0' title='{1}' />", ResolveUrl("~/Images/IbnFramework/delete.gif"), GetGlobalResourceObject("IbnFramework.GlobalMetaInfo", "Delete").ToString());
            del.HeaderStyle.Width = Unit.Pixel(25);
            del.ItemStyle.Width = Unit.Pixel(25);
            del.ShowDeleteButton = true;
            MainGrid.Columns.Add(del);

            string[] dataKeyNames = {idColumn};
            MainGrid.DataKeyNames = dataKeyNames;
        }
 protected override DataControlField SaveValues(string headerText)
 {
     CommandField field = new CommandField();
     if ((headerText != null) && (headerText.Length > 0))
     {
         field.HeaderText = headerText;
         field.ShowHeader = true;
     }
     if (this._buttonTypeList.SelectedIndex == 0)
     {
         field.ButtonType = ButtonType.Link;
     }
     else
     {
         field.ButtonType = ButtonType.Button;
     }
     field.ShowDeleteButton = this._deleteBox.Checked;
     field.ShowSelectButton = this._selectBox.Checked;
     if (this._cancelBox.Enabled)
     {
         field.ShowCancelButton = this._cancelBox.Checked;
     }
     field.ShowEditButton = this._updateBox.Checked;
     field.ShowInsertButton = this._insertBox.Checked;
     return field;
 }
Esempio n. 16
0
        /// <devdoc>
        /// Creates the set of fields to be used to build up the control
        /// hierarchy.
        /// When AutoGenerateRows is true, the fields are created to match the
        /// datasource and are appended to the set of fields defined in the Fields
        /// collection.
        /// </devdoc>
        protected virtual ICollection CreateFieldSet(object dataItem, bool useDataSource) {
            ArrayList fieldsArray = new ArrayList();

            if (AutoGenerateRows == true) {
                if (RowsGeneratorInternal is DetailsViewRowsGenerator) {
                    ((DetailsViewRowsGenerator)RowsGeneratorInternal).DataItem = dataItem;
                    ((DetailsViewRowsGenerator)RowsGeneratorInternal).InDataBinding = useDataSource;
                }
                fieldsArray.AddRange(RowsGeneratorInternal.GenerateFields(this));
            }

            foreach (DataControlField f in Fields) {
                fieldsArray.Add(f);
            }

            if (AutoGenerateInsertButton || AutoGenerateDeleteButton || AutoGenerateEditButton) {
                CommandField commandField = new CommandField();
                commandField.ButtonType = ButtonType.Link;

                if (AutoGenerateInsertButton) {
                    commandField.ShowInsertButton = true;
                }

                if (AutoGenerateDeleteButton) {
                    commandField.ShowDeleteButton = true;
                }

                if (AutoGenerateEditButton) {
                    commandField.ShowEditButton = true;
                }
                fieldsArray.Add(commandField);
            }

            return fieldsArray;
        }
Esempio n. 17
0
		protected virtual ICollection CreateFieldSet (object dataItem, bool useDataSource)
		{
			ArrayList fields = new ArrayList ();
			
			if (AutoGenerateRows) {
				if (useDataSource) {
					if (dataItem != null)
						fields.AddRange (CreateAutoGeneratedRows (dataItem));
				} else {
					if (autoFieldProperties != null) {
						foreach (AutoGeneratedFieldProperties props in autoFieldProperties)
							fields.Add (CreateAutoGeneratedRow (props));
					}
				}
			}
			
			fields.AddRange (Fields);
			
			if (AutoGenerateEditButton || AutoGenerateDeleteButton || AutoGenerateInsertButton) {
				CommandField field = new CommandField ();
				field.ShowEditButton = AutoGenerateEditButton;
				field.ShowDeleteButton = AutoGenerateDeleteButton;
				field.ShowInsertButton = AutoGenerateInsertButton;
				fields.Add (field);
				commandField = field;
			}
			
			return fields;
		}
Esempio n. 18
0
		public void CommandField_CopyProperty ()
		{
			PokerCommandField field = new PokerCommandField ();
			CommandField copy = new CommandField ();
			field.CancelImageUrl = "test";
			field.CancelText = "test";
			field.CausesValidation = false;
			field.DeleteImageUrl = "test";
			field.DeleteText = "test";
			field.EditImageUrl = "test";
			field.EditText = "test";
			field.InsertImageUrl = "test";
			field.InsertText = "test";
			field.NewImageUrl = "test";
			field.NewText = "test";
			field.SelectImageUrl = "test";
			field.SelectText = "test";
			field.ShowCancelButton = false;
			field.ShowDeleteButton = true;
			field.ShowEditButton = true;
			field.ShowInsertButton = true;
			field.ShowSelectButton = true;
			field.UpdateImageUrl = "test";
			field.UpdateText = "test";

			field.DoCopyProperties (copy);
			Assert.AreEqual (false, copy.CausesValidation, "CausesValidation");
			Assert.AreEqual ("test", copy.DeleteImageUrl, "DeleteImageUrl");
			Assert.AreEqual ("test", copy.DeleteText, "DeleteText");
			Assert.AreEqual ("test", copy.EditImageUrl, "EditImageUrl");
			Assert.AreEqual ("test", copy.EditText, "EditText");
			Assert.AreEqual ("test", copy.InsertImageUrl, "InsertImageUrl");
			Assert.AreEqual ("test", copy.InsertText, "InsertText");
			Assert.AreEqual ("test", copy.NewImageUrl, "NewImageUrl");
			Assert.AreEqual ("test", copy.NewText, "NewText");
			Assert.AreEqual ("test", copy.SelectImageUrl, "SelectImageUrl");
			Assert.AreEqual ("test", copy.SelectText, "SelectText");
			Assert.AreEqual (false, copy.ShowCancelButton, "ShowCancelButton ");
			Assert.AreEqual (true, copy.ShowDeleteButton, "ShowDeleteButton");
			Assert.AreEqual (true, copy.ShowEditButton, "ShowEditButton");
			Assert.AreEqual (true, copy.ShowInsertButton, "ShowInsertButton");
			Assert.AreEqual (true, copy.ShowSelectButton, "ShowSelectButton");
			Assert.AreEqual ("test", copy.UpdateImageUrl, "UpdateImageUrl");
			Assert.AreEqual ("test", copy.UpdateText, "UpdateText");
			Assert.AreEqual ("test", copy.CancelImageUrl, "CancelImageUrl");
			Assert.AreEqual ("test", copy.CancelText, "CancelText");

		}
 private void SetElementValues()
 {
     Log.Debug("SetElementValues");
     SettingsManager settingsManager = new SettingsManager();
     Settings settings = settingsManager.DeserializeFromXml();
     foreach (Page page in settings.Page)
     {
         if (page.Id == "ManageShopItems")
         {
             List<Setting> setting = page.Setting;
             hyperLinkManageShopItemsMain.Text = settingsManager.GetSettingValue("hyperLinkManageShopItemsMain",
                                                                                 setting);
             labelManageShopItemsBodyInputItems.Text =
                 settingsManager.GetSettingValue("labelManageShopItemsBodyInputItems", setting);
             labelManageShopItemsBodyInputShops.Text =
                 settingsManager.GetSettingValue("labelManageShopItemsBodyInputShops", setting);
             labelManageShopItemsBodyInputPriceGross.Text =
                 settingsManager.GetSettingValue("labelManageShopItemsBodyInputPriceGross", setting);
             labelManageShopItemsBodyInputPriceNet.Text =
                 settingsManager.GetSettingValue("labelManageShopItemsBodyInputPriceNet", setting);
             labelManageShopItemsBodyInputNumberOfItems.Text =
                 settingsManager.GetSettingValue("labelManageShopItemsBodyInputNumberOfItems", setting);
             labelManageShopItemsBodyTrackersInputShopItem.Text =
                 settingsManager.GetSettingValue("labelManageShopItemsBodyTrackersInputShopItem", setting);
             labelManageShopItemsBodyTrackersInputDateTime.Text =
                 settingsManager.GetSettingValue("labelManageShopItemsBodyTrackersInputDateTime", setting);
             labelManageShopItemsBodyTrackersInputSoldCount.Text =
                 settingsManager.GetSettingValue("labelManageShopItemsBodyTrackersInputSoldCount", setting);
             labelManageShopItemsBodyTrackersStatsTotal.Text =
                 settingsManager.GetSettingValue("labelManageShopItemsBodyTrackersStatsTotal", setting);
             labelManageShopItemsBodyTrackersStatsSold.Text =
                 settingsManager.GetSettingValue("labelManageShopItemsBodyTrackersStatsSold", setting);
             labelManageShopItemsBodyTrackersStatsGrossReceived.Text =
                 settingsManager.GetSettingValue("labelManageShopItemsBodyTrackersStatsGrossReceived", setting);
             labelManageShopItemsBodyTrackersStatsNetReceived.Text =
                 settingsManager.GetSettingValue("labelManageShopItemsBodyTrackersStatsNetReceived", setting);
             linkButtonManageShopItemsBodyInputAdd.Text =
                 settingsManager.GetSettingValue("linkButtonManageShopItemsBodyInputAdd", setting);
             linkButtonManageShopItemsBodyTrackersInputAdd.Text =
                 settingsManager.GetSettingValue("linkButtonManageShopItemsBodyTrackersInputAdd", setting);
             gridViewManageShopItemsBodyList.Columns[0].HeaderText =
                 settingsManager.GetSettingValue("tableManageShopItemsBodyListDateTimeText", setting);
             gridViewManageShopItemsBodyList.Columns[1].HeaderText =
                 settingsManager.GetSettingValue("tableManageShopItemsBodyListNumberOfItemsText", setting);
             gridViewManageShopItemsBodyList.Columns[2].HeaderText =
                 settingsManager.GetSettingValue("tableManageShopItemsBodyListPriceGrossText", setting);
             gridViewManageShopItemsBodyList.Columns[3].HeaderText =
                 settingsManager.GetSettingValue("tableManageShopItemsBodyListPriceNetText", setting);
             gridViewManageShopItemsBodyList.Columns[4].HeaderText =
                 settingsManager.GetSettingValue("tableManageShopItemsBodyListItemText", setting);
             gridViewManageShopItemsBodyList.Columns[5].HeaderText =
                 settingsManager.GetSettingValue("tableManageShopItemsBodyListShopText", setting);
             gridViewManageShopItemsBodyTrackersList.Columns[0].HeaderText =
                 settingsManager.GetSettingValue("ManageShopItemsBodyTrackersListDateTime", setting);
             gridViewManageShopItemsBodyTrackersList.Columns[1].HeaderText =
                 settingsManager.GetSettingValue("ManageShopItemsBodyTrackersListCount", setting);
             CommandField commandFieldDelete = new CommandField
                 {
                     ShowDeleteButton = true,
                     DeleteText = settingsManager.GetSettingValue("tableManageShopItemsBodyListDeleteText", setting)
                 };
             CommandField commandFieldSelect = new CommandField
             {
                 ShowDeleteButton = false,
                 ShowSelectButton = true,
                 SelectText = settingsManager.GetSettingValue("tableManageShopItemsBodyListSelectText", setting)
             };
             if (gridViewManageShopItemsBodyList.Columns.Count < 7)
             {
                 gridViewManageShopItemsBodyList.Columns.Add(commandFieldDelete);
                 gridViewManageShopItemsBodyList.Columns.Add(commandFieldSelect);
             }
         }
     }
 }
Esempio n. 20
0
 protected void GenerateColumns()
 {
     // remove all previous rows because we set EnableViewState="True"
     gvScholPrograms.Columns.Clear();
     /* set ScholID as the primary keys of each row */
     gvScholPrograms.DataKeyNames = new string[] { "ScholID" };
     /* 1st column = Scholarship Name */
     HyperLinkField hlf = new HyperLinkField();
     hlf.HeaderText = TextCode(10421);
     hlf.HeaderStyle.CssClass = "leftAlign";
     hlf.SortExpression = "ScholName";
     hlf.DataTextField = "ScholName";
     hlf.DataNavigateUrlFields = new string[] {"ScholID"};
     hlf.DataNavigateUrlFormatString = "ScholarshipAppDetails.aspx?LoginID=" + LoginID + "&ScholID={0}";
     hlf.ItemStyle.CssClass = "leftAlign";
     gvScholPrograms.Columns.Add(hlf);
     /* 2nd column = Deadline */
     BoundField bf2 = new BoundField();
     bf2.HeaderText = TextCode(10422);
     bf2.SortExpression = "DeadlineSorting";
     bf2.DataField = "Deadline";
     bf2.ItemStyle.CssClass = "leftAlign";
     gvScholPrograms.Columns.Add(bf2);
     /* 3rd column = Status */
     BoundField bf3 = new BoundField();
     bf3.HeaderText = TextCode(10423);
     bf3.SortExpression = "Status";
     bf3.DataField = "Status";
     bf3.ItemStyle.CssClass = "leftAlign";
     gvScholPrograms.Columns.Add(bf3);
     /* 4 column = Options */
     CommandField cf = new CommandField();
     cf.HeaderText = TextCode(9234);
     cf.ButtonType = ButtonType.Image;
     cf.ShowDeleteButton = true;
     cf.DeleteImageUrl = "/media/shared/ico_delete.gif";
     cf.DeleteText = TextCode(3488);
     cf.ShowEditButton = true;
     cf.EditImageUrl = "/media/shared/ico_edit.gif";
     cf.EditText = TextCode(3489);
     gvScholPrograms.Columns.Add(cf);
 }
Esempio n. 21
0
        /// <devdoc>
        ///   Creates the set of fields to be used to build up the control
        ///   hierarchy.
        ///   When AutoGenerateColumns is true, the fields are created to match the
        ///   datasource and are appended to the set of fields defined in the Fields
        ///   collection.
        /// </devdoc>
        protected virtual ICollection CreateColumns(PagedDataSource dataSource, bool useDataSource) {
            ArrayList fieldsArray = new ArrayList();
            bool autoGenEditButton = AutoGenerateEditButton;
            bool autoGenDeleteButton = AutoGenerateDeleteButton;
            bool autoGenSelectButton = AutoGenerateSelectButton;


            if (autoGenEditButton || autoGenDeleteButton || autoGenSelectButton) {
                CommandField commandField = new CommandField();
                commandField.ButtonType = ButtonType.Link;

                if (autoGenEditButton) {
                    commandField.ShowEditButton = true;
                }
                if (autoGenDeleteButton) {
                    commandField.ShowDeleteButton = true;
                }
                if (autoGenSelectButton) {
                    commandField.ShowSelectButton = true;
                }

                fieldsArray.Add(commandField);
            }


            foreach (DataControlField f in Columns) {
                fieldsArray.Add(f);
            }

            if (AutoGenerateColumns == true) {
                if (ColumnsGeneratorInternal is GridViewColumnsGenerator) {
                    ((GridViewColumnsGenerator)ColumnsGeneratorInternal).DataItem = dataSource;
                    ((GridViewColumnsGenerator)ColumnsGeneratorInternal).InDataBinding = useDataSource;
                }

                fieldsArray.AddRange(ColumnsGeneratorInternal.GenerateFields(this));
            }

            return fieldsArray;
        }
Esempio n. 22
0
        public void GenerateColumns()
        {
            if (this.AutoGenerateColumns)
            {
                throw new Exception("GridViewEx: AutoGenerateColumns must be set to false.");
            }

            var dataSource = this.GetDataSource() as ObjectDataSource;
            if (null == dataSource)
            {
                return;
            }

            Type dataObjectType = BuildManager.GetType(dataSource.DataObjectTypeName, false);

            if (null != dataObjectType)
            {
                IOrderedEnumerable<PropertyInfo> allProperties =
                    dataObjectType.GetProperties().Where(
                        x =>
                            x.PropertyType.IsPrimitive || x.PropertyType == typeof (string)
                            || x.PropertyType == typeof(DateTime) || x.PropertyType == typeof(DateTime?)).OrderBy(x => x.DeclaringType == dataObjectType);

                foreach (PropertyInfo property in allProperties)
                {
                    bool readOnly = this.ReadOnlyPropertiesList.Contains(property.Name);
                    bool visibility = !this.HiddenPropertiesList.Contains(property.Name);

                    if (property.PropertyType == typeof (bool))
                    {
                        var checkBoxField = new CheckBoxField
                        {
                            DataField = property.Name,
                            HeaderText = property.Name,
                            SortExpression = property.Name,
                            ReadOnly = readOnly,
                            Visible = visibility
                        };

                        this.Columns.Add(checkBoxField);
                    }
                    else
                    {
                        var field = new BoundField
                        {
                            DataField = property.Name,
                            HeaderText = property.Name,
                            SortExpression = property.Name,
                            ReadOnly = readOnly,
                            Visible = visibility
                        };

                        if (this.EditModeDropDownFields.ContainsKey(property.Name))
                        {
                            // TODO: set drop down as edit mode control
                        }

                        this.Columns.Add(field);
                    }

                    if (property.PropertyType == typeof(DateTime) || property.PropertyType == typeof(DateTime?))
                    {
                        var parameter = new Parameter
                        {
                            Type = TypeCode.DateTime,
                            DbType = DbType.Object,
                            Name = property.Name,
                            Direction = ParameterDirection.Input,
                            DefaultValue = null
                        };

                        dataSource.UpdateParameters.Add(parameter);
                    }
                }
            }

            if (this.EnableEdit || this.EnableDelete)
            {
                var cf = new CommandField
                {
                    ShowEditButton = this.EnableEdit,
                    ShowDeleteButton = this.EnableDelete,
                    HeaderText = "Commands"
                };

                this.Columns.Add(cf);
            }

            this.RowEditing += GridViewExRowEditing;
        }
 public CommandFieldItem(DataControlFieldsEditor fieldsEditor, CommandField runtimeField) : base(fieldsEditor, runtimeField, 12)
 {
     this.UpdateImageIndex();
 }
        private void LoadGridViewListaAlunos()
        {
            AlunoNegocio alunoNegocio = new AlunoNegocio();
            List<Aluno> listAlunos = alunoNegocio.ObterTodosAlunos();

            GridViewListaAlunos.Columns.Clear();

            GridViewListaAlunos.DataSource = listAlunos;
            GridViewListaAlunos.AutoGenerateColumns = false;

            BoundField bfNumeroPece = new BoundField();
            bfNumeroPece.DataField = "NumeroPece";
            bfNumeroPece.HeaderText = "Número Pece";
            GridViewListaAlunos.Columns.Add(bfNumeroPece);

            BoundField bfNome = new BoundField();
            bfNome.DataField = "Nome";
            bfNome.HeaderText = "Nome";
            GridViewListaAlunos.Columns.Add(bfNome);

            CommandField cmdField = new CommandField();
            cmdField.ButtonType = ButtonType.Image;
            cmdField.DeleteImageUrl = "Icons/cross.png";
            cmdField.EditImageUrl = "Icons/page_edit.png";
            cmdField.SelectImageUrl = "Icons/money_add.png";
            cmdField.ShowDeleteButton = true;
            cmdField.ShowEditButton = true;
            cmdField.ShowSelectButton = false;
            cmdField.EditText = "Editar Usuario";
            cmdField.DeleteText = "Remover Usuario";

            GridViewListaAlunos.Columns.Add(cmdField);
            GridViewListaAlunos.DataBind();
        }
 protected virtual ICollection CreateFieldSet(object dataItem, bool useDataSource)
 {
     ArrayList list = new ArrayList();
     if (this.AutoGenerateRows)
     {
         if (this.RowsGenerator == null)
         {
             object[] array = null;
             if (useDataSource)
             {
                 ICollection is2 = this.CreateAutoGeneratedRows(dataItem);
                 if (is2 != null)
                 {
                     array = new DataControlField[is2.Count];
                     is2.CopyTo(array, 0);
                 }
             }
             else if (this._autoGenFieldProps != null)
             {
                 int count = this._autoGenFieldProps.Count;
                 array = new DataControlField[count];
                 for (int i = 0; i < count; i++)
                 {
                     array[i] = this.CreateAutoGeneratedRow((AutoGeneratedFieldProperties) this._autoGenFieldProps[i]);
                 }
             }
             if (array != null)
             {
                 int length = array.Length;
                 for (int j = 0; j < length; j++)
                 {
                     list.Add(array[j]);
                 }
             }
         }
         else
         {
             list.AddRange(this.RowsGenerator.GenerateFields(this));
         }
     }
     foreach (DataControlField field in this.Fields)
     {
         list.Add(field);
     }
     if ((this.AutoGenerateInsertButton || this.AutoGenerateDeleteButton) || this.AutoGenerateEditButton)
     {
         CommandField field2 = new CommandField {
             ButtonType = ButtonType.Link
         };
         if (this.AutoGenerateInsertButton)
         {
             field2.ShowInsertButton = true;
         }
         if (this.AutoGenerateDeleteButton)
         {
             field2.ShowDeleteButton = true;
         }
         if (this.AutoGenerateEditButton)
         {
             field2.ShowEditButton = true;
         }
         list.Add(field2);
     }
     return list;
 }