Beispiel #1
0
        private void btn_loadsample_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            DataTable dt = null;

            dt_TableAndField = new DataTable();
            string sheetName = "物理表汇总";
            string tablename = "T_WELL_SAMPLE";//采油井生产月报

            //string DabaBasePath = "provider=microsoft.jet.oledb.4.0; Data Source=" + Application.StartupPath + "\\Database.mdb";
            //string excelpath = Application.StartupPath + "\\ACCESS.xlsx";
            string TableAndField = string.Format("select 列显示名称 AS name ,库字段名称 as ID, 默认单位名称 as UNIT from [{0}$] where (库表名称='" + tablename + "')", sheetName);

            dt_TableAndField = OleDbHelper.ExcelToDataTable(sheetName, TableAndField);
            try
            {
                string sSql = "select ";
                for (int i = 0; i < dt_TableAndField.Rows.Count - 1; i++)
                {
                    sSql = sSql + string.Format("{0} AS {1}, ", dt_TableAndField.Rows[i][1], dt_TableAndField.Rows[i][0]);
                }
                sSql = sSql + string.Format("{0} AS {1} From {2}", dt_TableAndField.Rows[dt_TableAndField.Rows.Count - 1][1], dt_TableAndField.Rows[dt_TableAndField.Rows.Count - 1][0], tablename);
                dt   = OleDbHelper.getTable(sSql, Globalname.DabaBasePath);
            }
            catch
            {
            }
        }
Beispiel #2
0
        void AddDataBaseNodes(bool showall)
        {
            DataTable dt = null;
            //  string DabaBasePath="provider=microsoft.jet.oledb.4.0; Data Source=" + Application.StartupPath + "\\Database.mdb";



            string sSql = "SELECT T_DM_UNIT_CUR_INFOR.DM_UNIT_ID AS ParentID, T_WELL_INFOR.WELL_ID as KeyID,T_WELL_INFOR.WELL_NAME as Name FROM T_WELL_INFOR ,T_DM_UNIT_CUR_INFOR where T_WELL_INFOR.DM_UNIT_ID=T_DM_UNIT_CUR_INFOR.DM_UNIT_ID " +
                          "UNION SELECT PARENT_DM_UNIT_ID AS ParentID,DM_UNIT_ID as KeyID,DM_UNIT_NAME as Name FROM T_DM_UNIT_CUR_INFOR";

            try
            {
                dt = OleDbHelper.getTable(sSql, Globalname.DabaBasePath);
                if (dt == null || dt.Rows.Count == 0)
                {
                    double a = 1;
                }
            }
            catch (Exception ex)
            {
                //Common.DisplayMsg(this.Text, ex.Message.ToString());
            }

            treeView.Nodes.Clear();
            treeView.DataSource      = dt;
            treeView.ParentFieldName = "ParentID";

            treeView.KeyFieldName            = "KeyID";
            treeView.Columns["Name"].Caption = "通讯录";



            this.treeView.Nodes[0].Expanded = true; // 只显示1级目录
        }
Beispiel #3
0
        public static void AddWellStimuNodes(DevExpress.XtraTreeList.TreeList treeView)
        {
            DataTable dt = null;
            //string DabaBasePath = "provider=microsoft.jet.oledb.4.0; Data Source=" + Application.StartupPath + "\\Database.mdb";



            //            string sSql = "SELECT T_DM_UNIT_CUR_INFOR.DM_UNIT_ID AS ParentID, T_WELL_INFOR.WELL_ID as WELLID,T_WELL_INFOR.WELL_NAME as Name, T_WELL_INFOR.WELL_CC as wellCode FROM T_WELL_INFOR ,T_DM_UNIT_CUR_INFOR where T_WELL_INFOR.DM_UNIT_ID=T_DM_UNIT_CUR_INFOR.DM_UNIT_ID " +
            //"UNION SELECT PARENT_DM_UNIT_ID AS ParentID,DM_UNIT_ID as KeyID,DM_UNIT_NAME as Name , DM_UNIT_NAME as wellCode FROM T_DM_UNIT_CUR_INFOR";
            string sSql = @"SELECT T_DM_UNIT_CUR_INFOR.DM_UNIT_ID AS ParentID, T_WELL_INFOR.WELL_ID as WELLID,T_WELL_INFOR.WELL_NAME as Name, T_WELL_INFOR.WELL_CC as wellCode FROM T_WELL_INFOR ,T_DM_UNIT_CUR_INFOR 
where T_WELL_INFOR.DM_UNIT_ID=T_DM_UNIT_CUR_INFOR.DM_UNIT_ID
UNION 
SELECT PARENT_DM_UNIT_ID AS ParentID,DM_UNIT_ID as KeyID,DM_UNIT_NAME as Name , DM_UNIT_NAME as wellCode FROM T_DM_UNIT_CUR_INFOR
UNION
SELECT T2.WELL_ID, T2.WELL_ID&t2.stimu_code & t2.end_date as stim,t2.stimu_code &'@' & t2.end_date as NAME, T2.end_date as wellCode FROM t_well_stimu_rec T2";

            try
            {
                dt = OleDbHelper.getTable(sSql, Globalname.DabaBasePath);
                if (dt == null || dt.Rows.Count == 0)
                {
                    double a = 1;
                }
            }
            catch (Exception ex)
            {
                //Common.DisplayMsg(this.Text, ex.Message.ToString());
            }

            treeView.Nodes.Clear();
            if (dt == null)
            {
                return;
            }
            treeView.DataSource                  = dt;
            treeView.ParentFieldName             = "ParentID";
            treeView.KeyFieldName                = "WELLID";
            treeView.Columns["Name"].Caption     = "通讯录";
            treeView.Columns["wellCode"].Visible = false;


            treeView.Nodes[0].Expanded = true; // 只显示1级目录
        }
Beispiel #4
0
        private DataTable GetProductData(string wellid, string tablename = "T_OW_M")
        {
            DataTable dt = null;


            try
            {
                //采油井生产月报

                //string DabaBasePath = "provider=microsoft.jet.oledb.4.0; Data Source=" + Application.StartupPath + "\\Database.mdb";
                //string excelpath = Application.StartupPath + "\\ACCESS.xlsx";
                string[] dataname;

                dt_TableAndField = new DataTable();
                string sheetName = "物理表汇总";

                string TableAndField = string.Format("select 列显示名称 AS name ,库字段名称 as ID, 默认单位名称 as UNIT from [{0}$] where (库表名称='" + tablename + "')", sheetName);
                dt_TableAndField = OleDbHelper.ExcelToDataTable(sheetName, TableAndField);


                //          string sSql = "SELECT T_DM_UNIT_CUR_INFOR.DM_UNIT_ID AS ParentID, T_WELL_INFOR.WELL_ID as KeyID,T_WELL_INFOR.WELL_NAME as Name FROM T_WELL_INFOR ,T_DM_UNIT_CUR_INFOR where T_WELL_INFOR.DM_UNIT_ID=T_DM_UNIT_CUR_INFOR.DM_UNIT_ID " +
                //"UNION SELECT PARENT_DM_UNIT_ID AS ParentID,DM_UNIT_ID as KeyID,DM_UNIT_NAME as Name FROM T_DM_UNIT_CUR_INFOR";where [{0}$].库表名称 + tablename
                string sSql = "select ";


                for (int i = 0; i < dt_TableAndField.Rows.Count - 1; i++)
                {
                    sSql = sSql + string.Format("{0} AS {1}, ", dt_TableAndField.Rows[i][1], dt_TableAndField.Rows[i][0]);
                }
                sSql = sSql + string.Format("{0} AS {1} From {2} where WELL_ID='{3}'", dt_TableAndField.Rows[dt_TableAndField.Rows.Count - 1][1], dt_TableAndField.Rows[dt_TableAndField.Rows.Count - 1][0], tablename, wellid);
                dt   = OleDbHelper.getTable(sSql, Globalname.DabaBasePath);

                return(dt);
            }
            catch
            {
                return(dt);
            }
        }