Exemplo n.º 1
0
        /// <summary>
        /// 从DataGridView中获取页面需要的控件参数
        /// </summary>
        /// <param name="gridViewMain">DataGirdView</param>
        /// <param name="filter">过滤类型,编辑页面控件、查询条件、列表控件</param>
        /// <returns></returns>
        private static List<PageControl> getPageControlList(DataGridView gridViewMain, EnumFilterType filter)
        {
            List<PageControl> pageControlList = new List<PageControl>();
            foreach (DataGridViewRow row in gridViewMain.Rows)
            {
                #region 编辑页面
                if (filter == EnumFilterType.编辑页面)
                {
                    bool isShowEdit = Convert.ToBoolean(row.Cells["ColumnIsEditControl"].Value);
                    if (isShowEdit)
                    {
                        PageControl pageControl = new PageControl();
                        pageControl.ControlName = row.Cells["ColumnName"].Value.ToString();
                        pageControl.ControlDesc = row.Cells["ColumnDesc"].Value.ToString();
                        pageControl.ColumnType = FormHelper.GetCSharpTypeByDBType(FormHelper.ConvertStrToCMD2DBType(row.Cells["ColumnType"].Value.ToString()));
                        pageControl.ControlType = row.Cells["ColumnControlType"].Value == null ? EnumControlType.FITextBox
                            : (EnumControlType)Enum.Parse(typeof(EnumControlType), row.Cells["ColumnControlType"].Value.ToString());
                        if (row.Cells["ColumnIsValidate"].Value == null)
                        {
                            if (string.IsNullOrWhiteSpace(row.Cells["ColumnIsNullable"].Value.ToString()))
                            {
                                pageControl.ControlValidate = EnumValidateType.必填;
                            }
                            else
                            {
                                pageControl.ControlValidate = EnumValidateType.无;
                            }
                        }
                        else
                        {
                            pageControl.ControlValidate = (EnumValidateType)Enum.Parse(typeof(EnumValidateType), row.Cells["ColumnIsValidate"].Value.ToString());
                        }
                        pageControlList.Add(pageControl);
                    }

                }
                #endregion

                #region 列表页面
                if (filter == EnumFilterType.列表页面)
                {
                    bool isQueryFilter = Convert.ToBoolean(row.Cells["ColumnIsQueryFilter"].Value);
                    if (isQueryFilter)
                    {
                        PageControl pageControl = new PageControl();
                        pageControl.ControlName = row.Cells["ColumnName"].Value.ToString();
                        pageControl.ControlDesc = row.Cells["ColumnDesc"].Value.ToString();
                        pageControl.ColumnType = FormHelper.GetCSharpTypeByDBType(FormHelper.ConvertStrToCMD2DBType(row.Cells["ColumnType"].Value.ToString()));
                        pageControl.ControlType = row.Cells["ColumnControlType"].Value == null ? EnumControlType.FITextBox : (EnumControlType)Enum.Parse(typeof(EnumControlType), row.Cells["ColumnControlType"].Value.ToString());
                        if (row.Cells["ColumnIsValidate"].Value == null)
                        {
                            if (string.IsNullOrWhiteSpace(row.Cells["ColumnIsNullable"].Value.ToString()))
                            {
                                pageControl.ControlValidate = EnumValidateType.必填;
                            }
                            else
                            {
                                pageControl.ControlValidate = EnumValidateType.无;
                            }
                        }
                        else
                        {
                            pageControl.ControlValidate = (EnumValidateType)Enum.Parse(typeof(EnumValidateType), row.Cells["ColumnIsValidate"].Value.ToString());
                        }
                        pageControlList.Add(pageControl);
                    }

                }
                #endregion

            }
            return pageControlList;
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取Grid栏位名称
        /// </summary>
        /// <param name="gridViewMain"></param>
        /// <returns></returns>
        private static List<PageControl> getGridColumnsList(DataGridView gridViewMain)
        {
            List<PageControl> listItems = new List<PageControl>();
            foreach (DataGridViewRow row in gridViewMain.Rows)
            {
                bool isGridColumn = Convert.ToBoolean(row.Cells["ColumnIsListControl"].Value);

                if (isGridColumn)
                {
                    PageControl listItem = new PageControl();
                    listItem.ControlName = row.Cells["ColumnName"].Value.ToString();
                    listItem.Sort = Convert.ToBoolean(row.Cells["ColumnIsOrderInListPage"].Value);
                    listItem.ControlDesc = row.Cells["ColumnDesc"].Value.ToString();
                    string type = FormHelper.GetCSharpTypeByDBType(FormHelper.ConvertStrToCMD2DBType(row.Cells["ColumnType"].Value.ToString()));
                    listItem.ColumnType = type;
                    listItem.DefaultSortExpression = Convert.ToBoolean(row.Cells["ColumnDefaultSortExpression"].Value);
                    listItems.Add(listItem);
                }
            }
            return listItems;
        }