protected virtual void CreateGroupColumns(AtawFormConfigView formView, DataFormConfig dataformConfig)
 {
     dataformConfig.ColumnGroups.ForEach(group =>
     {
         var columnGroup         = new AtawColumnGroupConfigView();
         columnGroup.ShowType    = group.ShowType == 0 ? "ColShowType".AppKv <int>(4) : group.ShowType;
         columnGroup.Name        = group.Name;
         columnGroup.DisplayName = group.DisplayName;
         columnGroup.Columns     = new List <AtawColumnConfigView>();
         var hiddenColCount      = 0;
         group.Columns.ForEach(col =>
         {
             var colView = formView.Columns.FirstOrDefault(x => x.Name == col.Name);
             if (colView != null)
             {
                 columnGroup.Columns.Add(colView);
                 if (colView.ControlType == ControlType.Hidden)
                 {
                     hiddenColCount++;
                 }
             }
         });
         //组内没有成员,该组移除,若组内所有字段都是隐藏字段,该组隐藏
         if (columnGroup.Columns.Count > 0)
         {
             formView.ColumnGroups.Add(columnGroup);
             if (columnGroup.Columns.Count == hiddenColCount)
             {
                 columnGroup.IsHidden = true;
             }
         }
     });
 }
 public static void MergeColumns(FormConfig form, DataFormConfig dataForm, ModuleConfig moduleConfig)
 {
     if (form.FormColumnRight != null)
     {
         ColumnRightConfig columnRight     = null;
         string            columnRightname = form.FormColumnRight.Name;
         if (form.FormColumnRight.RegName.IsEmpty())
         {
             AtawDebug.AssertArgumentNullOrEmpty(columnRightname, "FormColumnRight中若没指定RegName,Name属性不能为空", moduleConfig);
             columnRight = moduleConfig.Right.ColumnRights.FirstOrDefault(a => a.Name == columnRightname);
             AtawDebug.AssertArgumentNull(columnRight, string.Format("ModuleXml中必须配置名为'{0}'的ColumnRight", columnRightname), moduleConfig);
         }
         else
         {
             IColumnRight columnRightPlug = form.FormColumnRight.RegName.CodePlugIn <IColumnRight>();
             columnRightname = columnRightPlug.GetColumnRightName();
             columnRight     = moduleConfig.Right.ColumnRights.FirstOrDefault(a => a.Name == columnRightname);
             AtawDebug.AssertArgumentNull(columnRight, string.Format("ModuleXml中必须配置名为'{0}'的ColumnRight", columnRightname), moduleConfig);
         }
         //if (columnRight.Delete != null)
         //{
         //    columnRight.Delete.ForEach(dCol =>
         //    {
         //        var col = dataForm.Columns.FirstOrDefault(baseCol => baseCol.Name.Equals(dCol.Name, StringComparison.OrdinalIgnoreCase));
         //        if (col != null)
         //            dataForm.Columns.Remove(col);
         //    });
         //}
         if (columnRight.Override != null)
         {
             columnRight.Override.ForEach(oCol =>
             {
                 var col = dataForm.Columns.FirstOrDefault(baseCol => baseCol.Name.Equals(oCol.BaseColumnName, StringComparison.OrdinalIgnoreCase));
                 if (col != null)
                 {
                     AssignColumn(oCol, col);
                 }
             });
         }
         if (columnRight.Add != null)
         {
             dataForm.Columns.AddRange(columnRight.Add);
         }
     }
 }
 private void MergeDelColumns(FormConfig form, DataFormConfig dataForm, ModuleConfig moduleConfig)
 {
     if (form.FormColumnRight != null)
     {
         ColumnRightConfig columnRight = GetColumnRight(form, dataForm, moduleConfig);
         if (columnRight.Delete != null)
         {
             columnRight.Delete.ForEach(dCol =>
             {
                 var col = dataForm.Columns.FirstOrDefault(baseCol => baseCol.Name.Equals(dCol.Name, StringComparison.OrdinalIgnoreCase));
                 if (col != null)
                 {
                     dataForm.Columns.Remove(col);
                 }
             });
         }
     }
 }
Esempio n. 4
0
        public ModuleFormInfo(DataSet dataSet, int pageSize, string keyValue, string foreignKeyValue,
                              string tableName, string primaryKey, string foreignKey, bool isFillEmpty, DataFormConfig dataFormConfig,
                              string order, DataBaseConfig dataBase, FormConfig moduleFormConfig)
        {
            DataSet         = dataSet;
            PageSize        = pageSize;
            KeyValue        = keyValue;
            ForeignKey      = foreignKey;
            ForeignKeyValue = foreignKeyValue;
            TableName       = tableName;
            PrimaryKey      = primaryKey;
            ForeignKey      = foreignKey;
            IsFillEmpty     = isFillEmpty;
            DataFormConfig  = dataFormConfig;
            Order           = order;

            DataBase         = dataBase;
            ModuleFormConfig = moduleFormConfig;
        }
        private static ColumnRightConfig GetColumnRight(FormConfig form, DataFormConfig dataForm, ModuleConfig moduleConfig)
        {
            ColumnRightConfig columnRight     = null;
            string            columnRightname = form.FormColumnRight.Name;

            if (form.FormColumnRight.RegName.IsEmpty())
            {
                AtawDebug.AssertArgumentNullOrEmpty(columnRightname, "FormColumnRight中若没指定RegName,Name属性不能为空", moduleConfig);
                columnRight = moduleConfig.Right.ColumnRights.FirstOrDefault(a => a.Name == columnRightname);
                AtawDebug.AssertArgumentNull(columnRight, string.Format("ModuleXml中必须配置名为'{0}'的ColumnRight", columnRightname), moduleConfig);
            }
            else
            {
                IColumnRight columnRightPlug = form.FormColumnRight.RegName.CodePlugIn <IColumnRight>();
                columnRightname = columnRightPlug.GetColumnRightName();
                columnRight     = moduleConfig.Right.ColumnRights.FirstOrDefault(a => a.Name == columnRightname);
                AtawDebug.AssertArgumentNull(columnRight, string.Format("ModuleXml中必须配置名为'{0}'的ColumnRight", columnRightname), moduleConfig);
            }
            return(columnRight);
        }
        public static void MergeColumns(FormConfig form, DataFormConfig dataForm, ModuleConfig moduleConfig, PageStyle pagestyle, out List <ColumnConfig> fullColumns)
        {
            if (form.FormColumnRight != null)
            {
                ColumnRightConfig columnRight = GetColumnRight(form, dataForm, moduleConfig);
                if (columnRight.Delete != null)
                {
                    columnRight.Delete.ForEach(dCol =>
                    {
                        var col = dataForm.Columns.FirstOrDefault(baseCol => baseCol.Name.Equals(dCol.Name, StringComparison.OrdinalIgnoreCase));
                        if (col != null)
                        {
                            dataForm.Columns.Remove(col);
                        }
                    });
                }
                if (columnRight.Override != null)
                {
                    columnRight.Override.ForEach(oCol =>
                    {
                        var col = dataForm.Columns.FirstOrDefault(baseCol => baseCol.Name.Equals(oCol.BaseColumnName, StringComparison.OrdinalIgnoreCase));
                        if (col != null)
                        {
                            AssignColumn(oCol, col);
                        }
                    });
                }
                if (columnRight.Add != null)
                {
                    dataForm.Columns.AddRange(columnRight.Add);
                }
            }
            fullColumns = new List <ColumnConfig>();

            fullColumns = dataForm.Columns;

            dataForm.Columns = dataForm.Columns.Where(a => a.ShowPage.HasFlag(pagestyle)).ToList();
        }
        protected virtual void CreateColumns(AtawFormConfigView formView, DataFormConfig dataformConfig, FormConfig formConfig)
        {
            foreach (var column in dataformConfig.Columns)
            {
                if ((column.ShowPage & PageStyle) != PageStyle)
                {
                    continue;
                }
                else
                {
                    //var col = CreateColumn(formView, column);
                    ////列表和明细页面的所有字段控件类型为Detail
                    //if (!column.IsKey && (PageStyle == PageStyle.Detail || PageStyle == PageStyle.List))
                    //    col.ControlType = ControlType.Detail;
                    //formView.Columns.Add(col);
                    formView.Columns.Add(CreateColumn(formView, column));

                    //if (column.Navigation != null && column.Navigation.IsAvailable == true)
                    //{
                    //    formView.NavigationColumns.Add(CreateColumnNavigation(formView, column));
                    //}
                }
            }
        }
Esempio n. 8
0
 public void Migrations(DataFormConfig dataFormConfig)
 {
     dataFormConfig.AddBaseColumns("BaseForm.xml");
     if (dataFormConfig == null)
     {
         return;
     }
     if (dataFormConfig.TableName.IsEmpty())
     {
         dataFormConfig.TableName = dataFormConfig.Name;
     }
     if (dataFormConfig.TableName.ToUpper().IndexOf("VIEW") == 0)
     {
         return;
     }                                                                       //若是试图,不执行任何操作
     if (HaveTable(dataFormConfig.TableName))
     {
         List <string> tableFields = GetTableFields(dataFormConfig.TableName);
         string        sql         = string.Empty;
         string        commentSql  = string.Empty;
         //SqlParameter[] sqlParameters;
         foreach (var column in dataFormConfig.Columns)
         {
             if (column.Kind == ColumnKind.Data && column.SourceName.IsEmpty())
             {
                 if (tableFields.FirstOrDefault <string>(n => n == column.Name.Trim().ToUpper()) == default(string))
                 {
                     sql = string.Format(ObjectUtil.SysCulture, "{0} ALTER TABLE [{1}] Add [{2}] {3}", sql, dataFormConfig.TableName, column.Name, ConvertToDataBaseType(column));
                     if (column.IsKey)
                     {
                         sql = sql + " PRIMARY KEY";
                     }
                     commentSql = string.Format(ObjectUtil.SysCulture, " {0} EXECUTE sp_addextendedproperty N'MS_Description', '{1}', N'user', N'dbo', N'table', N'{2}', N'column', N'{3}'", commentSql, column.DisplayName, dataFormConfig.TableName, column.Name);
                 }
                 //sqlParameters = new SqlParameter[]
                 //{
                 //    new SqlParameter("@tableName",dataFormConfig.TableName),
                 //    new SqlParameter("@fieldName",column.Name),
                 //    new SqlParameter("@fieldType",ConvertToDataBaseType(column.ControlType,column.Length))
                 //};
             }
         }
         if (!string.IsNullOrEmpty(sql))
         {
             AtawAppContext.Current.UnitOfData.RegisterSqlCommand(sql);
             AtawAppContext.Current.UnitOfData.RegisterSqlCommand(commentSql);
             this.IsMigrations = true;
             logMessages.Add(new SqlLogMessage {
                 SqlStr = sql
             });
         }
     }
     else
     {
         string commentSql = string.Empty;
         string sql        = "CREATE TABLE [" + dataFormConfig.TableName + "] (";
         foreach (var column in dataFormConfig.Columns)
         {
             if (column.Kind == ColumnKind.Data)
             {
                 if (column.IsKey)
                 {
                     sql = string.Format(ObjectUtil.SysCulture, "{0} [{1}] {2} PRIMARY KEY,", sql, column.Name, ConvertToDataBaseType(column));
                 }
                 else
                 {
                     sql = string.Format(ObjectUtil.SysCulture, "{0} [{1}] {2},", sql, column.Name, ConvertToDataBaseType(column));
                 }
                 commentSql = string.Format(ObjectUtil.SysCulture, " {0} EXECUTE sp_addextendedproperty N'MS_Description', '{1}', N'user', N'dbo', N'table', N'{2}', N'column', N'{3}'", commentSql, column.DisplayName, dataFormConfig.TableName, column.Name);
             }
         }
         sql = sql.Substring(0, sql.Length - 1) + ")";
         AtawAppContext.Current.UnitOfData.RegisterSqlCommand(sql);
         AtawAppContext.Current.UnitOfData.RegisterSqlCommand(commentSql);
         this.IsMigrations = true;
         logMessages.Add(new SqlLogMessage {
             SqlStr = sql
         });
     }
     //AtawAppContext.Current.UnitOfData.Submit();
 }
Esempio n. 9
0
        private void InternalInitialize(DataSet dataSet, int pageSize, string keyValue, string foreignKeyValue, string tableName, string primaryKey, string foreignKey, bool isFillEmpty, DataFormConfig dataFormConfig)
        {
            // ColumnLegalHashTable = new HashSet<string>();
            this.DataFormConfig = dataFormConfig;

            UniqueList          = this.DataFormConfig.Columns.Where(a => a.IsUniqueKey).Select(a => a.Name).ToList();
            SingleUploadColumns = this.DataFormConfig.Columns.FindAll(
                a => (a.ControlType == ControlType.SingleImageUpload || a.ControlType == ControlType.SingleFileUpload) && (a.Upload != null && a.Upload.HasKey)).ToList();
            MultiUploadColumns = this.DataFormConfig.Columns.FindAll(
                a => (a.ControlType == ControlType.MultiImageUpload || a.ControlType == ControlType.MultiFileUpload) && (a.Upload != null && a.Upload.HasKey)).ToList();
            MomeryColumns = this.DataFormConfig.Columns.FindAll(
                a => (a.ControlType == ControlType.Momery && !a.RegName.IsEmpty())
                ).ToList();
            this.KeyValues   = new List <string>();
            this.IsFillEmpty = isFillEmpty;
            this.PostDataSet = dataSet;
            this.KeyValue    = keyValue;
            if (dataSet != null)
            {
                var _dtPageSys = dataSet.Tables["PAGE_SYS"];

                if (_dtPageSys != null && _dtPageSys.Rows.Count > 0)
                {
                    if (_dtPageSys.Columns.Contains("PageStyle"))
                    {
                        this.PageStyle = _dtPageSys.Rows[0]["PageStyle"].Value <PageStyle>();
                    }
                }

                var dt = dataSet.Tables["_KEY"];
                if (dt != null && dt.Rows.Count > 0)
                {
                    List <string> keyValueList = new List <string>();
                    foreach (DataRow row in dt.Rows)
                    {
                        string _key = row["KeyValue"].ToString();
                        keyValueList.Add(_key);
                    }
                    KeyValues = keyValueList;
                }
            }

            // if (dataSet.Tables["PAGE"])
            if (RegName.IsEmpty())
            {
                fRegName = tableName;
            }
            if (PrimaryKey.IsEmpty())
            {
                PrimaryKey = primaryKey;
            }
            if (ForeignKey.IsEmpty())
            {
                ForeignKey = foreignKey;
            }
            if (!ForeignKey.IsEmpty())
            {
                if (foreignKeyValue.IsEmpty())
                {
                    this.ForeignKeyValue = KeyValues.Count() == 1 ? KeyValues.First() : foreignKeyValue;
                }
                else
                {
                    this.ForeignKeyValue = foreignKeyValue;
                }
            }
            if (dataSet != null)
            {
                this.Pagination = new Pagination().FormDataTable(dataSet.Tables["PAGER"]);
            }
            else
            {
                this.Pagination = new Pagination()
                {
                    //TableName = RegName,
                    DataTime = DateTime.Now,
                    PageSize = pageSize
                }
            };
            this.Pagination.TableName = RegName;
            if (this.Pagination.PageSize == 0)
            {
                this.Pagination.PageSize = pageSize;
            }
            if (this.Pagination.PageSize == 0)
            {
                this.Pagination.PageSize = 20;
            }
        }
        protected AtawFormConfigView CreateFormView(DataFormConfig dataForm, FormConfig formConfig)
        {
            AtawFormConfigView formView = new AtawFormConfigView();

            formView.FormType           = formConfig.FormType;
            formView.ShowKind           = formConfig.ShowKind;
            formView.AfterInitFunName   = formConfig.AfterInitFunName;
            formView.VerticalTab        = formConfig.VerticalTab; //布局方式
            formView.HasBatchInsert     = false;
            formView.HasPager           = false;
            formView.HasSearch          = false;
            formView.ParentFieldName    = formConfig.ParentFieldName;
            formView.TextFieldName      = formConfig.TextFieldName;
            formView.IsParentFieldName  = formConfig.IsParentFieldName;
            formView.IsSafeMode         = formConfig.IsSafeMode;
            formView.HasReview          = formConfig.HasReview;
            formView.Calendar           = formConfig.Calendar;
            formView.ExpandDetailPlug   = formConfig.ExpandDetailPlug;
            formView.RowTpl             = formConfig.RowTpl;
            formView.ContentTpl         = formConfig.ContentTpl;
            formView.DisableColumnGroup = formConfig.Group.IsDisabled.ToLower() == "true" || formConfig.Group.IsDisabled == "1" ? true : false;
            // formView.Tpl = formConfig.Tpl;
            var _bean = formConfig.Tpls.FirstOrDefault(a => a.PageStyle == PageStyle);

            if (_bean != null)
            {
                formView.Tpl = _bean.Item;
            }


            formView.IsInner          = formConfig.IsInner;
            formView.HaveNoSwitchForm = formConfig.HaveNoSwitchForm;
            formView.HaveNoSortBar    = formConfig.HaveNoSortBar;
            //var NavigationList = dataForm.Columns.Where(a => a.Navigation != null);
            //if (NavigationList.Count() > 0)
            //{
            //    formView.HasNavigation = true;
            //     List<ColumnConfig> columns = NavigationList.ToList();
            //     foreach (var column in columns)
            //     {
            //         AtawColumnConfigView colView = new AtawColumnConfigView();
            //         if (column.Navigation != null && column.Navigation.IsAvailable == true && (column.ControlType == ControlType.CheckBox || column.ControlType == ControlType.Combo || column.ControlType == ControlType.Radio || column.ControlType == ControlType.TreeSingleSelector || column.ControlType == ControlType.TreeMultiSelector))
            //         {
            //             if (column.ControlType == ControlType.CheckBox)
            //             {
            //                 colView.ControlType = ControlType.CheckBoxNavi;
            //             }
            //             else if (column.ControlType == ControlType.Radio || column.ControlType == ControlType.Combo)
            //             {
            //                 colView.ControlType = ControlType.RadioNavi;
            //             }
            //             else if (column.ControlType == ControlType.TreeSingleSelector)
            //             {
            //                 colView.ControlType = ControlType.TreeSingleNavi;
            //             }
            //             else
            //             {
            //                 colView.ControlType = ControlType.TreeMultiNavi;
            //             }
            //         }
            //     }
            //}
            formView.TableName = formConfig.TableName;
            //if (formView.TableName.IsEmpty())
            //    formView.TableName = dataForm.TableName;
            //if (formView.TableName.IsEmpty())
            //    formView.TableName = formConfig.DataPlug.PlugInPageGet<IListDataTable>().RegName;

            formView.Title = formConfig.Title;
            //if (formView.Title.IsEmpty())
            //    formView.Title = dataForm.Title;
            //if (formView.Title.IsEmpty())
            //    formView.Title = ModuleConfig.Title;
            if (ModuleConfig.Mode == ModuleMode.None)
            {
                formView.Title = formView.Title;
            }
            else
            {
                switch (PageStyle)
                {
                case PageStyle.List:
                    formView.Title = formView.Title + "列表";
                    break;

                case PageStyle.Detail:
                    formView.Title = formView.Title + "明细";
                    break;

                case PageStyle.Update:
                    formView.Title = formView.Title + "修改";
                    break;

                case PageStyle.Insert:
                    formView.Title = formView.Title + "新增";
                    break;
                }
            }

            formView.Name = formConfig.Name;
            //if (formView.Name.IsEmpty())
            //    formView.Name = dataForm.Name;
            //if (formView.Name.IsEmpty())
            //    formView.Name = formView.TableName;
            //string msg = string.Format("数据源为{0}插件的form的名称不能为空", formConfig.DataPlug);
            //AtawDebug.AssertNotNullOrEmpty(formView.Name, msg, this);
            formView.Columns = new List <AtawColumnConfigView>();
            CreateColumns(formView, dataForm, formConfig);

            formView.ColumnGroups = new List <AtawColumnGroupConfigView>();
            CreateGroupColumns(formView, dataForm);

            formView.NavigationColumns = new List <AtawNaviColumnConfigView>(); //可能有多个navi(目前只有一个)
            if (PageStyle == Core.PageStyle.List)
            {
                var navigation = dataForm.Columns.FindAll(a => a.Navigation != null && a.Navigation.IsAvailable);
                foreach (var navi in navigation)
                {
                    if (navigation != null)
                    {
                        var viewColumn = formView.Columns.FirstOrDefault(a => a.Name == navi.Name);
                        var viewNavi   = CreateColumnNavigation(viewColumn, navi);
                        if (viewNavi != null)
                        {
                            formView.NavigationColumns.Add(viewNavi);
                        }
                    }
                }
            }
            return(formView);
        }