Exemplo n.º 1
0
        //子记录表注册显示
        private void gridControl2_ViewRegistered(object sender, ViewOperationEventArgs e)
        {
            GridView _gv = e.View as GridView;

            _gv.ViewCaption             = "详细信息";
            _gv.CustomDrawRowIndicator += new RowIndicatorCustomDrawEventHandler(_gv_CustomDrawRowIndicator);
            GridColumn _gcm = _gv.Columns.ColumnByFieldName("MAINID");

            if (_gcm != null)
            {
                _gv.Columns.Remove(_gcm);
            }
            DataView _source = _gv.DataSource as DataView;
            string   _tName  = _source.Table.TableName;

            foreach (GridColumn _gc in _gv.Columns)
            {
                //待改进
                MDQuery_TableColumn _tc = MC_QueryModel.GetColumnDefineByAlias(this.QueryRequest, _tName, _gc.FieldName);
                if (_tc != null)
                {
                    _gc.Caption = _tc.ColumnTitle;
                    _gc.Width   = _tc.DisplayLength;
                }
                else
                {
                    _gc.Caption = _source.Table.Columns[_gc.FieldName].Caption;
                }
                _gc.BestFit();
                _gc.OptionsColumn.ReadOnly = true;
            }
            _gv.IndicatorWidth = _gv.RowCount.ToString().Length * 10 + 20;
            this.RaiseViewRegistered(e);
        }
Exemplo n.º 2
0
        private void gridControl1_ViewRegistered(object sender, DevExpress.XtraGrid.ViewOperationEventArgs e)
        {
            GridView _gv = (GridView)e.View;

            _gv.CustomDrawRowIndicator += new RowIndicatorCustomDrawEventHandler(_gv_CustomDrawRowIndicator);
            GridColumn _gcm = _gv.Columns.ColumnByFieldName("MAINID");

            if (_gcm != null)
            {
                _gv.Columns.Remove(_gcm);
            }
            DataView _source = _gv.DataSource as DataView;
            string   _tName  = _source.Table.TableName;

            foreach (GridColumn _gc in _gv.Columns)
            {
                //待改进
                MDQuery_TableColumn _tc = MC_QueryModel.GetColumnDefineByAlias(this.QueryRequest, _tName, _gc.FieldName);
                if (_tc != null)
                {
                    _gc.Caption = _tc.ColumnTitle;
                    _gc.Width   = _tc.DisplayLength;
                }
            }
            this.RaiseViewRegistered(e);
        }
Exemplo n.º 3
0
        public void AddResultTableColumn(MDModel_Table _mtable, MDModel_Table_Column _mColumn)
        {
            MDQuery_ResultTable _rtable = null;
            string _tname = _mtable.TableName;

            if (this.queryRequest.MainResultTable != null && this.queryRequest.MainResultTable.TableName == _tname)
            {
                _rtable = this.queryRequest.MainResultTable;
            }
            else
            {
                var _rts = from _c in this.queryRequest.ChildResultTables
                           where _c.TableName == _tname
                           select _c;
                if (_rts != null && _rts.Count() > 0)
                {
                    _rtable = _rts.First();
                }
            }
            if (_rtable.Columns == null)
            {
                _rtable.Columns = new List <MDQuery_TableColumn>();
            }

            string _cname = _mColumn.ColumnName;
            var    _find  = from _t in _rtable.Columns
                            where _t.ColumnName == _cname
                            select _t;

            if (_find == null || _find.Count() < 1)
            {
                MDQuery_TableColumn _column = new MDQuery_TableColumn(_mColumn);
                _rtable.Columns.Add(_column);
            }
        }
Exemplo n.º 4
0
        private static string BuildTableColumnResult(MDQuery_TableColumn _rColumn, MDModel_QueryModel _qv)
        {
            MDModel_Table_Column _mcolumn = MC_QueryModel.GetColumnDefineByName(_qv, _rColumn.TableName, _rColumn.ColumnName);

            if (_mcolumn == null)
            {
                return("");
            }
            return("," + BuildItem(_mcolumn));
        }
Exemplo n.º 5
0
        private static string BuildTableColumnResult(MDQuery_TableColumn rColumn, MDModel_QueryModel qv, SinoRequestUser requestUser)
        {
            MDModel_Table_Column _mcolumn = GetColumnDefineByName(qv, rColumn.TableName, rColumn.ColumnName);

            if (_mcolumn == null)
            {
                return("");
            }
            return("," + BuildItem(_mcolumn, requestUser));
        }
        /// <summary>
        /// 复制查询结果字段元数据定义
        /// </summary>
        /// <param name="_columnDefine"></param>
        /// <returns></returns>
        private static MDQuery_TableColumn CopyResultTableColumn(MDQuery_TableColumn _columnDefine)
        {
            MDQuery_TableColumn _ret = new MDQuery_TableColumn();

            _ret.ColumnAlgorithm = _columnDefine.ColumnAlgorithm;
            _ret.ColumnAlias     = _columnDefine.ColumnAlias;
            _ret.ColumnDataType  = _columnDefine.ColumnDataType;
            _ret.ColumnName      = _columnDefine.ColumnName;
            _ret.ColumnTitle     = _columnDefine.ColumnTitle;
            _ret.ColumnType      = _columnDefine.ColumnType;
            _ret.DisplayOrder    = _columnDefine.DisplayOrder;
            _ret.Source          = _columnDefine.Source;
            return(_ret);
        }
Exemplo n.º 7
0
        private static string BuildStatisticsColumnResult(MDQuery_TableColumn _rColumn, MDModel_QueryModel _qv)
        {
            string _itemString = "";

            if (_rColumn.ColumnDataType == "NUMBER")
            {
                _itemString = string.Format("Round( ({0}),20) {1}", _rColumn.ColumnAlgorithm, _rColumn.ColumnAlias);
            }
            else
            {
                _itemString = string.Format("({0}) {1}", _rColumn.ColumnAlgorithm, _rColumn.ColumnAlias);
            }

            return("," + _itemString);
        }
Exemplo n.º 8
0
        public static string BuildItem(MDQuery_TableColumn _rColumn, MDModel_QueryModel _qv)
        {
            switch (_rColumn.ColumnType)
            {
            case QueryColumnType.TableColumn:
                return(BuildTableColumnResult(_rColumn, _qv));

            case QueryColumnType.CalculationColumn:
                return(BuildCalculationColumnResult(_rColumn, _qv));

            case QueryColumnType.StatisticsColumn:
                return(BuildStatisticsColumnResult(_rColumn, _qv));;
            }
            return("");
        }
Exemplo n.º 9
0
        private static string BuildCalculationColumnResult(MDQuery_TableColumn rColumn, MDModel_QueryModel qv, SinoRequestUser requestUser)
        {
            string _itemString = "";

            if (rColumn.ColumnDataType == "NUMBER")
            {
                _itemString = string.Format("Round({0},20) {1}", rColumn.ColumnAlgorithm, rColumn.ColumnAlias);
            }
            else
            {
                _itemString = string.Format("{0} {1}", rColumn.ColumnAlgorithm, rColumn.ColumnAlias);
            }

            return("," + _itemString);
        }
Exemplo n.º 10
0
        public static string BuildItem(MDQuery_TableColumn rColumn, MDModel_QueryModel qv, SinoRequestUser requestUser)
        {
            switch (rColumn.ColumnType)
            {
            case QueryColumnType.TableColumn:
                return(BuildTableColumnResult(rColumn, qv, requestUser));

            case QueryColumnType.CalculationColumn:
                return(BuildCalculationColumnResult(rColumn, qv, requestUser));

            case QueryColumnType.StatisticsColumn:
                return(BuildStatisticsColumnResult(rColumn, qv, requestUser));;
            }
            return("");
        }
Exemplo n.º 11
0
        private void AddColumn(MDQuery_TableColumn _qdf)
        {
            BandedGridColumn _col = new BandedGridColumn();

            this.bandedGridView1.Columns.AddRange(new DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn[] { _col });
            this.gridBand1.Columns.Add(_col);
            _col.Caption   = _qdf.ColumnTitle;
            _col.FieldName = _qdf.ColumnAlias;
            //_col.Options = ((DevExpress.XtraGrid.Columns.ColumnOptions)(((((((((DevExpress.XtraGrid.Columns.ColumnOptions.CanFiltered | DevExpress.XtraGrid.Columns.ColumnOptions.CanMoved)
            //        | DevExpress.XtraGrid.Columns.ColumnOptions.CanGrouped)
            //        | DevExpress.XtraGrid.Columns.ColumnOptions.CanResized)
            //        | DevExpress.XtraGrid.Columns.ColumnOptions.CanSorted)
            //        | DevExpress.XtraGrid.Columns.ColumnOptions.ReadOnly)
            //        | DevExpress.XtraGrid.Columns.ColumnOptions.FixedWidth)
            //        | DevExpress.XtraGrid.Columns.ColumnOptions.CanFocused)
            //        | DevExpress.XtraGrid.Columns.ColumnOptions.ShowInCustomizationForm)));
            _col.Visible      = true;
            _col.VisibleIndex = 0;
            _col.Width        = 120;
        }
        public static SinoSZ_TableRelationCompose Compse(MDQuery_Request _srcRequest, MDModel_QueryModel _srcModel, DataTable _srcChildTable)
        {
            SinoSZ_TableRelationCompose _ret = new SinoSZ_TableRelationCompose();

            #region 处理查询结果字段
            _ret.QueryRequest = new MDQuery_Request();
            _ret.ResultData   = new DataTable();
            _ret.ResultData.Columns.Add(new DataColumn("MAINID", typeof(String)));

            MDQuery_ResultTable _qrDefine = new MDQuery_ResultTable();

            _qrDefine.TableName = _srcRequest.MainResultTable.TableName;
            _qrDefine.TableName = _srcRequest.MainResultTable.DisplayTitle;
            _qrDefine.Columns   = new List <MDQuery_TableColumn>();
            //添加所有主表字段
            Dictionary <string, string> _aliasLib = new Dictionary <string, string>();
            int       _index     = 0;
            DataTable _mainTable = _srcChildTable.DataSet.Tables[_srcRequest.MainResultTable.TableName];
            foreach (MDQuery_TableColumn _col in _srcRequest.MainResultTable.Columns)
            {
                MDQuery_TableColumn _newcol = CopyResultTableColumn(_col);
                _newcol.ColumnAlias = string.Format("F{0}", _index++);
                _aliasLib.Add(string.Format("{0}.{1}", _col.TableName, _col.ColumnAlias), _newcol.ColumnAlias);
                _qrDefine.Columns.Add(_newcol);
                DataColumn _dc    = _mainTable.Columns[_col.ColumnAlias];
                DataColumn _newdc = new DataColumn(_newcol.ColumnAlias, _dc.DataType);
                _newdc.Caption = _dc.Caption;
                _ret.ResultData.Columns.Add(_newdc);
            }

            //添加所有子表字段
            var _find = from _t in _srcRequest.ChildResultTables
                        where _t.TableName == _srcChildTable.TableName
                        select _t;
            if (_find != null && _find.Count() > 0)
            {
                MDQuery_ResultTable _CResultTable = _find.First();
                foreach (MDQuery_TableColumn _col in _CResultTable.Columns)
                {
                    MDQuery_TableColumn _newcol = CopyResultTableColumn(_col);
                    _newcol.ColumnAlias = string.Format("F{0}", _index++);
                    _aliasLib.Add(string.Format("{0}.{1}", _col.TableName, _col.ColumnAlias), _newcol.ColumnAlias);
                    _qrDefine.Columns.Add(_newcol);

                    DataColumn _dc    = _srcChildTable.Columns[_col.ColumnAlias];
                    DataColumn _newdc = new DataColumn(_newcol.ColumnAlias, _dc.DataType);
                    _newdc.Caption = _dc.Caption;
                    _ret.ResultData.Columns.Add(_newdc);
                }
            }
            else
            {
                foreach (DataColumn _dc in _srcChildTable.Columns)
                {
                    if (_dc.ColumnName != "MAINID")
                    {
                        MDQuery_TableColumn _newcol = new MDQuery_TableColumn();
                        _newcol.ColumnAlias = _dc.ColumnName;
                        _newcol.ColumnTitle = "EXCEL_" + _dc.ColumnName;
                        _aliasLib.Add(string.Format("{0}.{1}", _srcChildTable.TableName, _dc.ColumnName), _dc.ColumnName);
                        _qrDefine.Columns.Add(_newcol);

                        DataColumn _newdc = new DataColumn(_dc.ColumnName, _dc.DataType);
                        _newdc.Caption = _dc.Caption;
                        _ret.ResultData.Columns.Add(_newdc);
                    }
                }
            }

            _ret.QueryRequest.MainResultTable = _qrDefine;

            #endregion

            #region 处理元数据定义字段

            #endregion

            #region 处理数据表


            //添加数据
            foreach (DataRow _dr in _srcChildTable.Rows)
            {
                DataRow _newrow = _ret.ResultData.NewRow();
                foreach (DataColumn _dc in _srcChildTable.Columns)
                {
                    if (_dc.ColumnName != "MAINID")
                    {
                        string _newFieldName = _aliasLib[string.Format("{0}.{1}", _dc.Table.TableName, _dc.ColumnName)];
                        _newrow[_newFieldName] = _dr[_dc.ColumnName];
                    }
                }
                DataRow _fatherRow = _dr.GetParentRow(_srcChildTable.ParentRelations[0].RelationName);
                foreach (DataColumn _dc in _fatherRow.Table.Columns)
                {
                    if (_dc.ColumnName == "MAINID")
                    {
                        _newrow["MAINID"] = _fatherRow[_dc.ColumnName];
                    }
                    else
                    {
                        string _newFieldName = _aliasLib[string.Format("{0}.{1}", _dc.Table.TableName, _dc.ColumnName)];
                        _newrow[_newFieldName] = _fatherRow[_dc.ColumnName];
                    }
                }
                _ret.ResultData.Rows.Add(_newrow);
            }
            #endregion



            return(_ret);
        }
Exemplo n.º 13
0
        public static void SaveToPAnalize(DevExpress.XtraGrid.Views.Base.BaseView _bv)
        {
            DataTable             _savedt = null;
            Dialog_SelectPAnalize _f      = new Dialog_SelectPAnalize();

            _f.InitData();
            if (_f.ShowDialog() == DialogResult.OK)
            {
                DataView  _dv = _bv.DataSource as DataView;
                DataTable _dt = _dv.Table;

                string _tname = _f.TableDisplayName;
                List <MD_PATable_Column> columnDefine = new List <MD_PATable_Column>();

                if (_bv is GridView)
                {
                    MD_PATable_Column _col      = null;
                    GridView          _gridview = _bv as GridView;
                    foreach (GridColumn _gc in _gridview.Columns)
                    {
                        MDQuery_TableColumn _cdefine = _gc.Tag as MDQuery_TableColumn;
                        DataColumn          _dc      = _dt.Columns[_gc.FieldName];
                        if (_cdefine == null)
                        {
                            _col = new MD_PATable_Column("", "", "", _gc.FieldName, _gc.Caption, CovertColumnType(_dc.DataType), _dc.MaxLength, _gc.VisibleIndex);
                        }
                        else
                        {
                            _col = new MD_PATable_Column("", "", "", _gc.FieldName, _gc.Caption, _cdefine.ColumnDataType,
                                                         _cdefine.ColumnLength, _gc.VisibleIndex, _cdefine.RefDMB, _cdefine.DisplayFormat, _cdefine.RefWord);
                        }
                        columnDefine.Add(_col);
                    }
                }

                //验证有无MAINID字段
                //bool _findMainID = false;
                //foreach (MD_PATable_Column _col in columnDefine)
                //{
                //        if (_col.ColumnName == "MAINID")
                //        {
                //                _findMainID = true;
                //        }
                //}
                //没有则添加
                //if (!_findMainID)
                //{

                //
                //}

                //代码表和字符串类型长度验证
                foreach (MD_PATable_Column _col in columnDefine)
                {
                    switch (_col.ColumnType)
                    {
                    case "VARCHAR2":
                    case "NVARCHAR2":
                    case "VARCHAR":
                    case "NVARCHAR":
                    case "CHAR":
                        CheckLength(_col, _dt);
                        break;

                    default:
                        if (_col.RefDMB == null || _col.RefDMB == "")
                        {
                        }
                        else
                        {
                            //转换
                            CheckLength(_col, _dt);
                        }
                        break;
                    }
                }

                #region 判断是否存在计算字段
                bool _haveComputData = false;
                foreach (DataColumn _dc in _dt.Columns)
                {
                    if (_dc.Expression.Length > 0)
                    {
                        _haveComputData = true;
                        break;
                    }
                }
                if (_haveComputData)
                {
                    _savedt = new DataTable();
                    foreach (MD_PATable_Column _col in columnDefine)
                    {
                        switch (_col.ColumnType)
                        {
                        case "VARCHAR2":
                        case "NVARCHAR2":
                        case "VARCHAR":
                        case "NVARCHAR":
                        case "CHAR":
                            _savedt.Columns.Add(_col.ColumnName, typeof(string));
                            break;

                        default:
                            if (_col.RefDMB.Length > 0)
                            {
                                //转换
                                _savedt.Columns.Add(_col.ColumnName, typeof(string));
                            }
                            else
                            {
                                _savedt.Columns.Add(_col.ColumnName, _dt.Columns[_col.ColumnName].DataType);
                            }
                            break;
                        }
                    }

                    foreach (DataRow _dr in _dt.Rows)
                    {
                        DataRow _newrow = _savedt.NewRow();
                        foreach (MD_PATable_Column _col in columnDefine)
                        {
                            _newrow[_col.ColumnName] = _dr[_col.ColumnName];
                        }
                        _savedt.Rows.Add(_newrow);
                    }
                }
                else
                {
                    _savedt = _dt;
                }

                #endregion


                //所有数据都添加新主建
                _savedt = _savedt.Copy();
                columnDefine.Add(new MD_PATable_Column("", "", "", "PAMAINID", "主键", "VARCHAR2", 50, 0));
                _savedt.Columns.Add("PAMAINID", typeof(string));
                foreach (DataRow _dr in _savedt.Rows)
                {
                    _dr["PAMAINID"] = Guid.NewGuid().ToString();
                }

                _savedt.AcceptChanges();



                //存入个人分析空间
                //if (SinoSZQueryConfig.MetaDataFactroy.SaveDataToPAnalize(_f.CurrentProject, _f.TableDisplayName, columnDefine, _savedt))
                //{
                //        XtraMessageBox.Show("保存成功!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //        return;
                //}
                //else
                //{
                //        XtraMessageBox.Show("保存失败!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //        return;
                //}
            }
        }