Ejemplo n.º 1
0
 private void btnResetAllControlAllUser_Click(object sender, EventArgs e)
 {
     if (DialogResult.Yes == XtraMessageBoxHelper.ShowYesNoAndTips("您确定要清除全部控件全部用户配置?"))
     {
         GridConfigFactory.Current.DeleteAllControlAllUserConfig();
     }
 }
Ejemplo n.º 2
0
 private void btnResetCurrentControlDefault_Click(object sender, EventArgs e)
 {
     if (DialogResult.Yes == XtraMessageBoxHelper.ShowYesNoAndTips("您确定要清除本控件配置?"))
     {
         GridConfigFactory.Current.DeleteCurrentControlConfig(TargetGrid.GridID);
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 设为默认设置
 /// </summary>
 private void btnSetAsDefault_Click(object sender, EventArgs e)
 {
     if (DialogResult.Yes == XtraMessageBoxHelper.ShowYesNoAndTips("您确定要把当前设置存为默认设置吗?"))
     {
         TargetGrid.SaveConfig(Guid.Empty);
     }
 }
Ejemplo n.º 4
0
        private void btnTemplateApple_Click(object sender, EventArgs e)
        {
            var entity = Grid.GetSelected <GridConfigTemplateEntity>();

            if (entity != null)
            {
                XtraMessageBoxHelper.ShowYesNoAndTips("确定要应用模板吗?", p => GridConfigTemplateFactory.Current.LoadConfig(TargetGrid, entity.Name));
            }
        }
Ejemplo n.º 5
0
 protected virtual void AsDefault()
 {
     if (DialogResult.Yes == XtraMessageBoxHelper.ShowYesNoAndTips("您确定要恢复默认设置吗?"))
     {
         GridConfigFactory.Current.DeleteConfig(TargetGrid.GridID, Guid.Empty);
         TargetGrid.LoadConfig();
         TargetGrid.IsConfigChange = false;
         Cancel();
     }
 }
 private void btnDelete_Click(object sender, EventArgs e)
 {
     XtraMessageBoxHelper.ShowYesNoAndWarning("确定要删除选中的数据吗?", d =>
     {
         var entity = Grid.GetSelected();
         if (entity != null)
         {
             Grid.Delete(entity);
         }
     });
 }
Ejemplo n.º 7
0
        private void btnAutoGenerated_Click(object sender, EventArgs e)
        {
            if (TargetGrid.EntityType == null)
            {
                XtraMessageBoxHelper.ShowWarning("没有指定表格的实体类型 EntityType");
                return;
            }
            string typeName = TargetGrid.EntityType.FullName;
            var    meta     = EntityMetadataFactory.Current.Get(typeName);

            if (meta == null)
            {
                XtraMessageBoxHelper.ShowWarning("没有指定实体元数据");
                return;
            }
            XtraMessageBoxHelper.ShowYesNoAndTips("确定自动生成列吗?", d =>
            {
                TargetGrid.View.OptionsBehavior.Editable = true;
                TargetGrid.View.Columns.Clear();

                #region 自动选择

                GridColumn colSelected              = new GridColumn();
                colSelected.FieldName               = "Selected";
                colSelected.Caption                 = "选择";
                colSelected.VisibleIndex            = 0;
                colSelected.OptionsColumn.AllowEdit = true;
                colSelected.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
                TargetGrid.View.Columns.Add(colSelected);
                #endregion

                for (int index = 0; index < meta.EntityFields.Count; index++)
                {
                    EntityField filed              = meta.EntityFields[index];
                    GridColumn column              = new GridColumn();
                    column.Name                    = "grid_{0}_{1}".FS(typeName, filed.FieldName);
                    column.FieldName               = filed.FieldName;
                    column.Caption                 = filed.FieldComment;
                    column.VisibleIndex            = index + 1;
                    column.OptionsColumn.AllowEdit = false;
                    var dataType                   = EntityMetadata.GetFastProperty(TargetGrid.EntityType, filed.FieldName).Property.PropertyType;
                    if (dataType == typeof(DateTime) || dataType == typeof(DateTime?))
                    {
                        column.DisplayFormat.FormatType   = DevExpress.Utils.FormatType.DateTime;
                        column.DisplayFormat.FormatString = "yyyy-MM-dd HH:mm:ss";
                    }
                    TargetGrid.View.Columns.Add(column);
                }
                Grid.RefreshData();
                TargetGrid.View.BestFitColumns();
            });
        }
Ejemplo n.º 8
0
        private void btnTemplateDelete_Click(object sender, EventArgs e)
        {
            var entity = Grid.GetSelected <GridConfigTemplateEntity>();

            if (entity != null)
            {
                XtraMessageBoxHelper.ShowYesNoAndTips("确定要删除模板吗?", p =>
                {
                    GridConfigTemplateFactory.Current.DeleteConfig(entity.ID);
                    InitData();
                    this.Grid.View.MoveLastVisible();
                });
            }
        }
Ejemplo n.º 9
0
        private void btnAutoGenerated_Click(object sender, EventArgs e)
        {
            if (TargetGrid.EntityType == null)
            {
                XtraMessageBoxHelper.ShowWarning("没有指定表格的实体类型 EntityType");
                return;
            }
            string typeName = TargetGrid.EntityType.FullName;
            var    meta     = EntityMetadataFactory.Current.Get(typeName);

            if (meta == null)
            {
                XtraMessageBoxHelper.ShowWarning("没有指定实体元数据");
                return;
            }
            XtraMessageBoxHelper.ShowYesNoAndTips("确定自动生成列吗?", d =>
            {
                TargetGrid.OptionsBehavior.AutoPopulateColumns = false;
                TargetGrid.OptionsBehavior.Editable            = true;
                TargetGrid.Columns.Clear();

                for (int index = 0; index < meta.EntityFields.Count; index++)
                {
                    EntityField filed              = meta.EntityFields[index];
                    TreeListColumn column          = TargetGrid.Columns.Add();
                    column.Name                    = "tree_{0}_{1}".FS(typeName, filed.FieldName);
                    column.FieldName               = filed.FieldName;
                    column.Caption                 = filed.FieldComment;
                    column.VisibleIndex            = index + 1;
                    column.OptionsColumn.AllowEdit = false;
                    var dataType                   = EntityMetadata.GetFastProperty(TargetGrid.EntityType, filed.FieldName).Property.PropertyType;
                    if (dataType == typeof(DateTime) || dataType == typeof(DateTime?))
                    {
                        column.Format.FormatType   = DevExpress.Utils.FormatType.DateTime;
                        column.Format.FormatString = "yyyy-MM-dd HH:mm:ss";
                    }
                }
                Grid.RefreshData();
                TargetGrid.BestFitColumns();
            });
        }