Esempio n. 1
0
        public static string GetMainTableData(MDModel_Table _maintable, string _keyid)
        {
            StringBuilder _sql = new StringBuilder();

            _sql.Append("select ");
            string _fg = "";

            foreach (MDModel_Table_Column _tc in _maintable.Columns)
            {
                if (_tc.ColumnDefine.TableColumn.CanDisplay)
                {
                    _sql.Append(_fg);
                    _sql.Append(OraResultItemBuilder.BuildItem(_tc));
                    _fg = ",";
                }
            }
            _sql.Append(" from ");
            _sql.Append(_maintable.TableName);
            _sql.Append(" where ");
            _sql.Append(_maintable.TableDefine.Table.MainKey);
            _sql.Append(" = '");
            _sql.Append(_keyid);
            _sql.Append("' ");
            return(_sql.ToString());
        }
Esempio n. 2
0
        private void InsertQueryResult(MC_QueryRequsetFactory _queryRequestFactory)
        {
            _queryRequestFactory.AddResultTable(this._queryModel.MainTable);
            foreach (MDModel_Table_Column _tc in this._queryModel.MainTable.Columns)
            {
                if (_tc.ColumnDefine.DefaultResult)
                {
                    _queryRequestFactory.AddResultTableColumn(this._queryModel.MainTable, _tc);
                }
            }

            foreach (CheckedListBoxItem _item in this.checkedListBoxControl1.CheckedItems)
            {
                FixChildItem  _itemData = _item.Value as FixChildItem;
                MDModel_Table _table    = _itemData.TableDefine;
                _queryRequestFactory.AddResultTable(_table);
                foreach (MDModel_Table_Column _tc2 in _table.Columns)
                {
                    if (_tc2.ColumnDefine.DefaultResult)
                    {
                        _queryRequestFactory.AddResultTableColumn(_table, _tc2);
                    }
                }
            }
        }
Esempio n. 3
0
        public static string GetChildTableData(MDModel_QueryModel model, MDModel_Table childTable, string MainKey, SinoRequestUser RequestUser)
        {
            StringBuilder _sql = new StringBuilder();

            _sql.Append("select ");
            _sql.Append(childTable.TableName);
            _sql.Append(".");
            _sql.Append(childTable.MainKey);
            _sql.Append(" MAINKEY");
            foreach (MDModel_Table_Column _tc in childTable.Columns)
            {
                if (_tc.CanDisplay && _tc.CanResultShow)
                {
                    _sql.Append(",");
                    _sql.Append(OraResultItemBuilder.BuildItem(_tc, RequestUser));
                }
            }
            _sql.Append(" from ");
            _sql.Append(string.Format(" {0},{1} ", model.MainTable.TableName, childTable.TableName));
            _sql.Append(" where ");
            _sql.Append(string.Format(" {0}.{1} ", model.MainTable.TableName, model.MainTable.MainKey));
            _sql.Append(" = '");
            _sql.Append(MainKey);
            _sql.Append("'  and ");
            _sql.Append(childTable.TableRelation);
            _sql.Append(string.Format("  order by {0}.{1} ", childTable.TableName, childTable.MainKey));
            return(_sql.ToString());
        }
        public void AddResultTable(MDModel_Table _mtable)
        {
            string _tname = _mtable.TableName;

            if (this.queryRequest.MainResultTable != null && this.queryRequest.MainResultTable.TableName == _tname)
            {
                return;
            }
            if (this.queryRequest.ChildResultTables == null)
            {
                this.queryRequest.ChildResultTables = new List <MDQuery_ResultTable>();
            }
            var find = from _t in this.queryRequest.ChildResultTables
                       where _t.TableName == _tname
                       select _t;

            if (find != null && find.Count() > 0)
            {
                return;
            }
            MDQuery_ResultTable _table = new MDQuery_ResultTable();

            _table.TableName    = _mtable.TableName;
            _table.DisplayTitle = _mtable.TableDefine.DisplayTitle;
            if (_mtable.TableDefine.ViewTableType == MDType_ViewTable.MainTable)
            {
                this.queryRequest.MainResultTable = _table;
            }
            else
            {
                _table.Columns = new List <MDQuery_TableColumn>();
                this.queryRequest.ChildResultTables.Add(_table);
            }
        }
        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);
            }
        }
Esempio n. 6
0
 private void treeList1_GetSelectImage(object sender, DevExpress.XtraTreeList.GetSelectImageEventArgs e)
 {
     if ((string)e.Node.GetValue("ItemType") == "TABLE")
     {
         MDModel_Table _tb = e.Node.GetValue("Data") as MDModel_Table;
         if (_tb.TableDefine.ViewTableRelationType == MDType_ViewTableRelation.SingleChildRecord)
         {
             e.NodeImageIndex = 0;
         }
         else
         {
             e.NodeImageIndex = 1;
         }
     }
     else if ((string)e.Node.GetValue("ItemType") == "COLUMN")
     {
         MDModel_Table_Column _tc = e.Node.GetValue("Data") as MDModel_Table_Column;
         if (_tc.ColumnType == QueryColumnType.TableColumn)
         {
             e.NodeImageIndex = 2;
         }
         else if (_tc.ColumnType == QueryColumnType.StatisticsColumn)
         {
             e.NodeImageIndex = 4;
         }
         else if (_tc.ColumnType == QueryColumnType.CalculationColumn)
         {
             e.NodeImageIndex = 3;
         }
     }
 }
Esempio n. 7
0
        public FrmMenuGroup GetMenuGroup()
        {
            bool _showSum     = false;
            bool _showCompute = false;

            if (this.treeList1.FocusedNode != null)
            {
                if ((string)this.treeList1.FocusedNode.GetValue("ItemType") == "TABLE")
                {
                    _showCompute = true;
                    MDModel_Table _tb = this.treeList1.FocusedNode.GetValue("Data") as MDModel_Table;
                    if (_tb.TableName == this.queryModel.MainTable.TableName)
                    {
                        _showSum = true;
                    }
                }
            }

            FrmMenuGroup _thisGroup = new FrmMenuGroup("数据字段管理");

            _thisGroup.MenuItems = new List <FrmMenuItem>();
            FrmMenuItem _item = new FrmMenuItem("计算项字段", "计算项字段", global::SinoSZMetaDataQuery.Properties.Resources.b5, _showCompute);

            _thisGroup.MenuItems.Add(_item);

            _item = new FrmMenuItem("统计项字段", "统计项字段", global::SinoSZMetaDataQuery.Properties.Resources.b6, _showSum);
            _thisGroup.MenuItems.Add(_item);


            return(_thisGroup);
        }
Esempio n. 8
0
        private void RefreshTableSelected(MDQuery_ResultTable _mtable)
        {
            TreeListNode  _mtableNode = FindTableNode(_mtable.TableName);
            MDModel_Table _tb         = _mtableNode.GetValue("Data") as MDModel_Table;

            if (_mtableNode != null)
            {
                foreach (TreeListNode _cnode in _mtableNode.Nodes)
                {
                    MDModel_Table_Column _mColumn = _cnode.GetValue("Data") as MDModel_Table_Column;
                    var _find = from _c in _mtable.Columns
                                where _c.ColumnName == _mColumn.ColumnName
                                select _c;
                    if (_find != null && _find.Count() > 0)
                    {
                        _cnode.SetValue("State", 2);
                        SetTableState(_cnode, 2);
                    }
                }

                foreach (MDQuery_TableColumn _rtc in _mtable.Columns)
                {
                    if (_rtc.ColumnType == QueryColumnType.CalculationColumn)
                    {
                        AddCalculationField(_rtc.ColumnTitle, _rtc.ColumnAlgorithm, this.queryModel.FullQueryModelName, _tb,
                                            _rtc.ColumnDataType);
                    }

                    if (_rtc.ColumnType == QueryColumnType.StatisticsColumn)
                    {
                        AddStaticsticsField(_rtc.ColumnTitle, _rtc.ColumnAlgorithm, _rtc.ColumnDataType, _tb);
                    }
                }
            }
        }
        public void AddResultTable(MDModel_Table _mtable)
        {
            string _tname = _mtable.TableName;

            if (this.queryRequest.MainResultTable != null && this.queryRequest.MainResultTable.TableName == _tname)
            {
                return;
            }
            if (this.queryRequest.ChildResultTables.ContainsKey(_tname))
            {
                return;
            }
            MDQuery_ResultTable _table = new MDQuery_ResultTable();

            _table.TableName    = _mtable.TableName;
            _table.DisplayTitle = _mtable.TableDefine.DisplayTitle;
            if (_mtable.TableDefine.ViewTableType == MDType_ViewTable.MainTable)
            {
                this.queryRequest.MainResultTable = _table;
            }
            else
            {
                this.queryRequest.ChildResultTables.Add(_tname, _table);
            }
        }
Esempio n. 10
0
        private static string CreateTableRelationString(MDModel_QueryModel _qv, List <string> _usedTableList, SinoRequestUser RequestUser)
        {
            StringBuilder _ret = new StringBuilder();

            foreach (string _tname in _usedTableList)
            {
                if (_tname != _qv.MainTable.TableName)
                {
                    MDModel_Table _cTable = (from _t in _qv.ChildTables
                                             where _t.TableName == _tname
                                             select _t).First();

                    if (_cTable != null)
                    {
                        if (_cTable.TableRelation != string.Empty)
                        {
                            _ret.Append(string.Format("and {0} ", ReplaceExtSecret(_qv, _cTable.TableRelation, RequestUser)));
                        }
                    }
                }
            }

            if (_ret.Length > 3)
            {
                return("(" + _ret.ToString().Substring(3) + ") and ");
            }
            else
            {
                return("");
            }
        }
Esempio n. 11
0
        public static string GetChildTableData(MDModel_Table _maintable, MDModel_Table _childTable, string _keyid)
        {
            StringBuilder _sql = new StringBuilder();

            _sql.Append("select ");
            string _fg = "";

            foreach (MDModel_Table_Column _tc in _childTable.Columns)
            {
                if (_tc.ColumnDefine.TableColumn.CanDisplay && _tc.ColumnDefine.CanShowAsResult)
                {
                    _sql.Append(_fg);
                    _sql.Append(OraResultItemBuilder.BuildItem(_tc));
                    _fg = ",";
                }
            }
            _sql.Append(" from ");
            _sql.Append(string.Format(" {0},{1} ", _maintable.TableName, _childTable.TableName));
            _sql.Append(" where ");
            _sql.Append(string.Format(" {0}.{1} ", _maintable.TableName, _maintable.TableDefine.Table.MainKey));
            _sql.Append(" = '");
            _sql.Append(_keyid);
            _sql.Append("'  and ");
            _sql.Append(_childTable.TableDefine.RelationString);
            return(_sql.ToString());
        }
Esempio n. 12
0
        private Panel CreatePanel(MDModel_Table _ctable)
        {
            Panel _panel = new Panel();

            _panel.Height = 0;
            DataTable _cdt;

            using (MetaDataQueryServiceClient _msc = new MetaDataQueryServiceClient())
            {
                _cdt = _msc.GetChildTableDataByKey(this.QueryModel.FullQueryModelName,
                                                   _ctable.TableName, this.MainKeyID);
            }
            if (_cdt != null)
            {
                int i = 1;
                foreach (DataRow _dr in _cdt.Rows)
                {
                    SinoSZUC_RecordData _crd = new SinoSZUC_RecordData(_ctable, _dr, i++);
                    _crd.Dock = DockStyle.Top;
                    _panel.Controls.Add(_crd);
                    _crd.BringToFront();
                    _panel.Height += _crd.Height;
                }
            }
            _panel.Visible = false;
            _panel.Dock    = DockStyle.Top;
            this.PanelDetail.Controls.Add(_panel);
            ChildTablePanel.Add(_ctable.TableName, _panel);
            return(_panel);
        }
 public SinoSZUC_ChildRecordIndex(MDModel_Table _table, int _recNum)
 {
     InitializeComponent();
     TableDefine = _table;
     RecordCount = _recNum;
     initForm();
 }
Esempio n. 14
0
        /// <summary>
        /// 构建单查询语句的表间关系语句
        /// </summary>
        /// <param name="_qv"></param>
        /// <param name="_usedTables"></param>
        /// <returns></returns>
        public static string CreateTableRelationString(MDModel_QueryModel _qv, List <string> _usedTableList)
        {
            StringBuilder _ret = new StringBuilder();

            foreach (string _tname in _usedTableList)
            {
                if (_tname != _qv.MainTable.TableName)
                {
                    if (_qv.ChildTableDict.ContainsKey(_tname))
                    {
                        MDModel_Table _cTable = _qv.ChildTableDict[_tname];
                        if (_cTable != null)
                        {
                            if (_cTable.TableDefine.RelationString != string.Empty)
                            {
                                _ret.Append(string.Format("and {0} ", ReplaceExtSecret(_cTable.TableDefine.RelationString, _qv.FullQueryModelName)));
                            }
                        }
                    }
                }
            }
            if (_ret.Length > 3)
            {
                return("(" + _ret.ToString().Substring(3) + ") and ");
            }
            else
            {
                return("");
            }
        }
Esempio n. 15
0
        public SinoUC_FunctionParam(string _paramName, string _type, MDModel_Table _table)
        {
            InitializeComponent();
            CurrentType = _type;
            this.comboBoxEdit1.Properties.Items.Clear();
            this.label1.Text = _paramName;
            if (_table == null)
            {
                return;
            }
            switch (_type.ToUpper())
            {
            case "VARCHAR":
            case "CHAR":
            case "VARCHAR2":
            case "NVARCHAR":
            case "NVARCHAR2":
                AddCharField(_table);
                break;

            case "NUMBER":
                AddNumField(_table);
                break;

            case "DATE":
                AddDateField(_table);
                break;
            }
        }
Esempio n. 16
0
        public static MDModel_Table_Column GetColumnDefineByName(MDModel_QueryModel qv, string tName, string cName)
        {
            MDModel_Table_Column _ret = null;

            if (qv.MainTable.TableName == tName)
            {
                _ret = (from _c in qv.MainTable.Columns
                        where _c.ColumnName == cName
                        select _c).First();
            }
            else
            {
                MDModel_Table _tb = (from _t in qv.ChildTables
                                     where _t.TableName == tName
                                     select _t).First();
                if (_tb == null)
                {
                    return(null);
                }

                _ret = (from _c in _tb.Columns
                        where _c.ColumnName == cName
                        select _c).First();
            }
            return(_ret);
        }
Esempio n. 17
0
 public SinoSZUC_RecordData(MDModel_Table _tableDefine, DataRow _dr, int _num)
 {
     InitializeComponent();
     TableDefine             = _tableDefine;
     TableRecordData         = _dr;
     this.groupControl1.Text = TableDefine.TableDefine.DisplayTitle + string.Format(" [{0}]", _num);
     AddColumns();
 }
Esempio n. 18
0
 public SinoSZUC_RecordData(MDModel_Table _tableDefine, DataRow _dr)
 {
     InitializeComponent();
     TableDefine             = _tableDefine;
     TableRecordData         = _dr;
     this.groupControl1.Text = TableDefine.TableDefine.DisplayTitle;
     AddColumns();
 }
Esempio n. 19
0
 private void AddALLField(MDModel_Table _table)
 {
     foreach (MDModel_Table_Column _tc in _table.Columns)
     {
         ColumnListItem _item = new ColumnListItem(_tc);
         this.cb_Field.Properties.Items.Add(_item);
     }
 }
Esempio n. 20
0
 public frmSinoSZ_ChildDetail(MDModel_QueryModel _model, MDModel_Table _ctable, string _keyid)
 {
     InitializeComponent();
     QueryModel  = _model;
     TabelDefine = _ctable;
     MainKeyID   = _keyid;
     this.Text   = string.Format("{0}的详细信息", _ctable.TableDefine.DisplayTitle);
     ShowData();
 }
Esempio n. 21
0
        private void InsertStatisticsField()
        {
            Dialog_CreateStatisticsField _f = new Dialog_CreateStatisticsField(this.QueryModel);

            if (_f.ShowDialog() == DialogResult.OK)
            {
                MDModel_Table _tb = this.queryModel.MainTable;
                AddStaticsticsField(_f.FieldName, _f.QueryString, _f.ResultDataType, _tb);
            }
        }
 /// <summary>
 /// 显示表的固定查询项
 /// </summary>
 /// <param name="_mainTable"></param>
 private void ShowFixCondition(MDModel_Table _table)
 {
     foreach (MDModel_Table_Column _tc in _table.Columns)
     {
         if (_tc.ColumnDefine.IsFixQueryItem && _tc.ColumnDefine.CanShowAsCondition)
         {
             AddConditionItem(_tc);
         }
     }
 }
Esempio n. 23
0
 public SinoSZUC_FieldTreeItem(MDModel_Table _mt)
 {
     id           = _mt.TableDefine.TableID;
     parentID     = "";
     state        = 0;
     data         = _mt;
     itemType     = "TABLE";
     displayTitle = _mt.TableDefine.DisplayTitle;
     isDefault    = true;
 }
        public void ShowConditionItems(MDModel_QueryModel _queryModel)
        {
            Clear();
            QueryModel = _queryModel;
            MDModel_Table _mainTable = _queryModel.MainTable;

            ShowFixCondition(_mainTable);
            foreach (MDModel_Table _cTable in _queryModel.ChildTableDict.Values)
            {
                ShowFixCondition(_cTable);
            }
        }
Esempio n. 25
0
        public static MDModel_Table_Column GetColumnByName(this MDModel_Table Table, string ColumnName)
        {
            var _find = from _c in Table.Columns
                        where _c.ColumnName == ColumnName
                        select _c;

            if (_find == null || _find.Count() < 1)
            {
                return(null);
            }
            return(_find.First());
        }
Esempio n. 26
0
 private void AddNumField(MDModel_Table _table)
 {
     foreach (MDModel_Table_Column _tc in _table.Columns)
     {
         ColumnListItem _item = new ColumnListItem(_tc);
         switch (_tc.ColumnDataType.ToUpper())
         {
         case "NUMBER":
             this.comboBoxEdit1.Properties.Items.Add(_item);
             break;
         }
     }
 }
Esempio n. 27
0
 private void AddDateField(MDModel_Table _table)
 {
     foreach (MDModel_Table_Column _tc in _table.Columns)
     {
         ColumnListItem _item = new ColumnListItem(_tc);
         switch (_tc.ColumnDataType.ToUpper())
         {
         case "DATE":
             this.cb_Field.Properties.Items.Add(_item);
             break;
         }
     }
 }
Esempio n. 28
0
        private static void CreateComboTableColumn(MDModel_QueryModel QueryModel, MDQuery_ResultTable _resultTable, DataTable _ret)
        {
            MDModel_Table _tableDefine = MC_QueryModel.GetTableDefine(QueryModel, _resultTable.TableName);

            foreach (MDQuery_TableColumn _rc in _resultTable.Columns)
            {
                string     FieldName = _rc.TableName + "_" + _rc.ColumnName;
                DataColumn _dc       = new DataColumn(FieldName);
                _dc.Caption = _rc.ColumnTitle;
                bool _isRefTable = (_rc.RefDMB == null || _rc.RefDMB == "") ? false : true;
                _dc.DataType = CreateTypeByMeta(_rc.ColumnDataType, _isRefTable);
                _ret.Columns.Add(_dc);
            }
        }
Esempio n. 29
0
        private void treeList1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            TreeListNode _node = this.treeList1.FocusedNode;

            if (_node != null)
            {
                if (_node.Tag != null)
                {
                    MDModel_Table         _table = _node.Tag as MDModel_Table;
                    frmSinoSZ_ChildDetail _form  = new frmSinoSZ_ChildDetail(this.QueryModel, _table, this.MainKeyID);
                    _application.AddForm(_table.TableName + this.MainKeyID, _form);
                }
            }
        }
Esempio n. 30
0
        public static string GetChildTableCountData(MDModel_QueryModel model, MDModel_Table childTable, string mainKey, SinoRequestUser requestUser)
        {
            StringBuilder _sql = new StringBuilder();

            _sql.Append(string.Format("select count({0}.{1}) ", childTable.TableName, childTable.MainKey));
            _sql.Append(" from ");
            _sql.Append(string.Format(" {0},{1} ", model.MainTable.TableName, childTable.TableName));
            _sql.Append(" where ");
            _sql.Append(string.Format(" {0}.{1} ", model.MainTable.TableName, model.MainTable.MainKey));
            _sql.Append(" = '");
            _sql.Append(mainKey);
            _sql.Append("'  and ");
            _sql.Append(childTable.TableRelation);
            return(_sql.ToString());
        }