Example #1
0
        public List <IndexInstance> FindDistinctIndexInstance(int systemid)
        {
            OleDbConnection          conn            = DBHelper.getConn(); //得到连接对象
            String                   strCommand      = "SELECT DISTINCT(instanceid),instancename FROM TB_INDEX_INSTANCE where systemid = ?";
            OleDbCommand             command         = new OleDbCommand(strCommand, conn);
            OleDbParameterCollection paramCollection = command.Parameters;
            OleDbParameter           param1          = paramCollection.Add("systemid", OleDbType.Integer);

            param1.Value = systemid;
            conn.Open();

            OleDbDataReader reader;

            reader = command.ExecuteReader(); //执行command并得到相应的DataReader
            List <IndexInstance> list = new List <IndexInstance>();

            while (reader.Read())
            {
                IndexInstance indexInstance = new IndexInstance();
                //indexInstance.Indexid = int.Parse(reader["indexid"].ToString());
                indexInstance.Instanceid = int.Parse(reader["instanceid"].ToString());
                //indexInstance.Indexvalue = double.Parse(reader["indexvalue"].ToString());
                indexInstance.Instancename = reader["instancename"].ToString();
                list.Add(indexInstance);
            }
            reader.Close();
            conn.Close();
            return(list);
        }
Example #2
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            if (this.lsbIndexInstance.SelectedItem == null)
            {
                DevExpress.XtraEditors.XtraMessageBox.Show("请先选择指标实例!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
            }
            else
            {
                tlMatch.KeyFieldName    = "indexid";
                tlMatch.ParentFieldName = "pid";
                IndexInstance indexInstance = (IndexInstance)this.lsbIndexInstance.SelectedItem;
                DataSet       dataSet       = this.indexService.FindAllInstance(this.indexSystem.Systemid, indexInstance.Instanceid);
                DataTable     tb            = dataSet.Tables[0];

                DataColumn col1 = new DataColumn("colname", System.Type.GetType("System.String"));
                tb.Columns.Add(col1);
                col1.DefaultValue = "";

                DataTable oldtb = (DataTable)tlMatch.DataSource;
                //字段列名自动匹配处理
                for (int i = 0; i < tb.Rows.Count; i++)
                {
                    tb.Rows[i]["colname"] = oldtb.Rows[i]["colname"];
                }

                tlMatch.DataSource = tb;
                tlMatch.ExpandAll();
                tlMatch.BestFitColumns();
            }
        }