コード例 #1
0
        public DataTable GetOilWellIfm(DataTable dtOil, int chooseItem)
        {
            DataTable        dt     = new DataTable();
            DataTable        dtTemp = new DataTable();
            ConnDatabaseUtil cdu    = new ConnDatabaseUtil();
            string           strSQL = string.Empty;

            for (int i = 0; i < dtOil.Rows.Count; i++)
            {
                if (chooseItem == 1)
                {
                    //OLEDB
                    strSQL = "select d.jh as 井号, d.ny as 年月, d.ycsl as 月产水量, round(a.avgsl, 4) as 全区月产水量平均值, d.ycyl as 月产液量, round(a.avgyl,4) as 全区月产液量平均值, d.bz as 备注 from dba04 as d, (select ny, avg(ycsl) as avgsl, avg(ycyl) as avgyl from dba04 group by ny having ny between '" + MainForm.strStartDate + "' and '" + MainForm.strEndDate + "') as a where a.ny = d.ny and d.jh = '" + dtOil.Rows[i]["JH"] + "' order by d.jh asc, d.ny asc";
                    dtTemp = cdu.SelectVFP(strSQL);
                    //Oracle
                    //strSQL = "select d.jh 井号, d.ny 年月, d.ycsl 月产水量, round(a.avgsl, 4) 全区月产水量平均值, d.ycyl 月产液量, round(a.avgyl,4) 全区月产液量平均值, d.bz 备注 from dba04 d, (select ny, avg(ycsl) as avgsl, avg(ycyl) as avgyl from dba04 group by ny having ny between '" + MainForm.strStartDate + "' and '" + MainForm.strEndDate + "') a where a.ny = d.ny and d.jh = '" + dtOil.Rows[i]["JH"] + "' order by d.jh asc, d.ny asc";
                    //dtTemp = cdu.SelectDatabase(strSQL);
                    dt.Merge(dtTemp);
                }
                else if (chooseItem == 2)
                {
                    //OLEDB
                    strSQL = "select d.jh as 井号, d.ny as 年月, d.ycsl as 月产水量, round(a.avgsl, 4) as 全区月产水量平均值, d.ycyl as 月产液量, round(a.avgyl,4) as 全区月产液量平均值, d.ly as 流压, round(a.aly,4) as 全区月流压平均值, d.hs as 含水, round(a.ahs,4) as 全区月含水平均值, d.bz as 备注 from dba04 as d, (select ny, avg(ycsl) as avgsl, avg(ycyl) as avgyl, avg(ly) as aly, avg(hs) as ahs from dba04 group by ny having ny between '" + MainForm.strStartDate + "' and '" + MainForm.strEndDate + "') as a where a.ny = d.ny and d.jh = '" + dtOil.Rows[i]["JH"] + "' order by d.jh asc, d.ny asc";
                    dtTemp = cdu.SelectVFP(strSQL);
                    //Oracle
                    //strSQL = "select d.jh 井号, d.ny 年月, d.ycsl 月产水量, round(a.avgsl, 4) 全区月产水量平均值, d.ycyl 月产液量, round(a.avgyl,4) 全区月产液量平均值, d.ly 流压, round(a.aly,4) 全区月流压平均值, d.hs 含水, round(a.ahs,4) 全区月含水平均值, d.bz 备注 from dba04 d, (select ny, avg(ycsl) as avgsl, avg(ycyl) as avgyl, avg(ly) as aly, avg(hs) ahs from dba04 group by ny having ny between '" + MainForm.strStartDate + "' and '" + MainForm.strEndDate + "') a where a.ny = d.ny and d.jh = '" + dtOil.Rows[i]["JH"] + "' order by d.jh asc, d.ny asc";
                    //dtTemp = cdu.SelectDatabase(strSQL);
                    dt.Merge(dtTemp);
                }
            }
            return(dt);
        }
コード例 #2
0
        public DataTable EndDateList()
        {
            string strSQL = "select distinct ny from DBA04 where ny > '" + MainForm.strStartDate + "' order by ny";

            return(cdu.SelectVFP(strSQL));
            //return cdu.SelectDatabase(strSQL);
        }
コード例 #3
0
        public DataTable LoadDate()
        {
            ConnDatabaseUtil cdu    = new ConnDatabaseUtil();
            string           strSQL = "select distinct ny from DBA04 order by ny";

            return(cdu.SelectVFP(strSQL));
            //return cdu.SelectDatabase(strSQL);
        }
コード例 #4
0
        public DataTable GetDataTable(string strNodeText)
        {
            ConnDatabaseUtil cdu    = new ConnDatabaseUtil();
            string           strSQL = string.Empty;

            if (strNodeText.Equals("井号库"))
            {
                strSQL = "select jh as 井号 from DAA01";
            }
            else if (strNodeText.Equals("井位坐标库"))
            {
                strSQL = "select jh as 井号, zzbx as 纵坐标X, hzby as 横坐标Y from DAA02";
            }
            else if (strNodeText.Equals("连通库"))
            {
                strSQL = "select jhy as 油井号, jhs as 水井号 from " + MainForm.strLTKName;
            }
            else if (strNodeText.Equals("标准小层库"))
            {
                strSQL = "select 井号, 层位 from T_DAA074";
            }
            else if (strNodeText.Equals("射孔库"))
            {
                strSQL = "select 井号, 层位, 微相, 砂岩厚度, 有效厚度, 渗透率 from T_DAA074";
            }
            else if (strNodeText.Equals("油井井史库"))
            {
                strSQL = "select jh as 井号, ny as 年月, scts as 生产天数, ly as 流压, hs as 含水, rcyl as 日产油量, rcsl as 日产水量, ycyl as 月产油量, ycsl as 月产水量, ljcyl as 累积产油量, ljcsl as 累积产水量, bz as 备注 from DBA04";
            }
            else if (strNodeText.Equals("水井井史库"))
            {
                strSQL = "select jh as 井号, ny as 年月, scts as 生产天数, yy as 油压, rzsl as 日注水量,  yzsl as 月注水量, ljzsl as 累积注水量, bz as 备注 from DBA05";
            }
            else if (strNodeText.Equals("吸水剖面"))
            {
                strSQL = "select * from (select f.jh as 井号, f.cw as 层位, f.csrq as 测试日期, f.sumsyhd as 砂岩厚度, round((f.sumsyhd * f.zrl/ g.syhd), 4) as 注入量, round((f.sumsyhd * f.zrbfs/ g.syhd), 4) as 注水百分数 from (select jh, csrq, zrl, zrbfs, jdds1, jdds2, sum(sumsyhd) as syhd from (select d.*,  e.csrq, e.zrl, e.zrbfs, e.jdds1, e.jdds2 from (select b.jh, b.cw, b.minsyds, (b.syds + c.syhd) as maxsyds, b.sumsyhd from (select jh, cw, min(syds) as minsyds, max(syds) as syds, sum(syhd) as sumsyhd from (select t.*, yczmc+dymc as cw from DAA074 as t where t.syds <> 0) group by jh, cw) as b, (select t.*, yczmc+dymc as cw from DAA074 as t where skqk = '1') as c where b.jh = c.jh and b.cw = c.cw and b.syds = c.syds) as d, (select jh, csrq, zrl, zrbfs, jdds1, jdds2 from DCB02 where zrl <> 0 and zrbfs <> 0) as e where d.jh = e.jh and ((d.minsyds between e.jdds1 and e.jdds2) or (d.maxsyds between e.jdds1 and e.jdds2) or ((d.minsyds > e.jdds1) and (d.maxsyds < e.jdds2)) or ((d.minsyds < e.jdds1) and (d.maxsyds > e.jdds2)))) as f group by jh, csrq, zrl, zrbfs, jdds1, jdds2) as g, (select d.*, e.csrq, e.zrl, e.zrbfs, e.jdds1, e.jdds2 from (select b.jh, b.cw, b.minsyds, (b.syds + c.syhd) as maxsyds, b.sumsyhd from (select jh, cw, min(syds) as minsyds, max(syds) as syds, sum(syhd) as sumsyhd from (select t.*, yczmc+dymc as cw from DAA074 as t where t.syds <> 0 and t.skqk = '1') group by jh, cw) as b, (select t.*, yczmc+dymc as cw from DAA074 as t) as c where b.jh = c.jh and b.cw = c.cw and b.syds = c.syds) as d, (select jh, csrq, zrl, zrbfs, jdds1, jdds2 from DCB02 where zrl <> 0 and zrbfs <> 0) as e where d.jh = e.jh and ((d.minsyds between e.jdds1 and e.jdds2) or (d.maxsyds between e.jdds1 and e.jdds2) or ((d.minsyds > e.jdds1) and (d.maxsyds < e.jdds2))) or ((d.minsyds < e.jdds1) and (d.maxsyds > e.jdds2))) as f where g.jh = f.jh and g.zrl = f.zrl and g.csrq = f.csrq and g.zrbfs = f.zrbfs and g.jdds1 = f.jdds1 and g.jdds2 = f.jdds2)";
            }
            else if (strNodeText.Equals("产液剖面"))
            {
                strSQL = "select * from (select f.jh as 井号, f.cw as 层位, f.csrq as 测试日期, f.sumsyhd as 砂岩厚度, f.hs as 含水, round((f.sumsyhd * f.rcyl1/ g.syhd), 4) as 日产液量 from (select jh, csrq, hs, rcyl1, jdds1, jdds2, sum(sumsyhd) as syhd from (select d.*,  e.csrq, e.hs, e.rcyl1, e.jdds1, e.jdds2 from (select b.jh, b.cw, b.minsyds, (b.syds + c.syhd) as maxsyds, b.sumsyhd from (select jh, cw, min(syds) as minsyds, max(syds) as syds, sum(syhd) as sumsyhd from (select t.*, yczmc+dymc as cw from DAA074 as t where t.syds <> 0) group by jh, cw) as b, (select t.*, yczmc+dymc as cw from DAA074 as t where skqk = '1') as c where b.jh = c.jh and b.cw = c.cw and b.syds = c.syds) as d, (select jh, csrq, hs, rcyl1, jdds1, jdds2 from DCB01 where hs <> 0 and rcyl1 <> 0) as e where d.jh = e.jh and ((d.minsyds between e.jdds1 and e.jdds2) or (d.maxsyds between e.jdds1 and e.jdds2) or ((d.minsyds > e.jdds1) and (d.maxsyds < e.jdds2)) or ((d.minsyds < e.jdds1) and (d.maxsyds > e.jdds2)))) as f group by jh, csrq, hs, rcyl1, jdds1, jdds2) as g, (select d.*, e.csrq, e.hs, e.rcyl1, e.jdds1, e.jdds2 from (select b.jh, b.cw, b.minsyds, (b.syds + c.syhd) as maxsyds, b.sumsyhd from (select jh, cw, min(syds) as minsyds, max(syds) as syds, sum(syhd) as sumsyhd from (select t.*, yczmc+dymc as cw from DAA074 as t where t.syds <> 0 and t.skqk = '1') group by jh, cw) as b, (select t.*, yczmc+dymc as cw from DAA074 t) as c where b.jh = c.jh and b.cw = c.cw and b.syds = c.syds) as d, (select jh, csrq, hs, rcyl1, jdds1, jdds2 from DCB01 where hs <> 0 and rcyl1 <> 0) as e where d.jh = e.jh and ((d.minsyds between e.jdds1 and e.jdds2) or (d.maxsyds between e.jdds1 and e.jdds2) or ((d.minsyds > e.jdds1) and (d.maxsyds < e.jdds2))) or ((d.minsyds < e.jdds1) and (d.maxsyds > e.jdds2))) as f where g.jh = f.jh and g.hs = f.hs and g.csrq = f.csrq and g.rcyl1 = f.rcyl1 and g.jdds1 = f.jdds1 and g.jdds2 = f.jdds2)";
            }
            return(cdu.SelectVFP(strSQL));
            //return cdu.SelectDatabase(strSQL);
        }
コード例 #5
0
        public DataTable GetWaterWellIfm(DataTable dtWater)
        {
            DataTable        dt     = new DataTable();
            DataTable        dtTemp = new DataTable();
            ConnDatabaseUtil cdu    = new ConnDatabaseUtil();
            string           strSQL = string.Empty;

            for (int i = 0; i < dtWater.Rows.Count; i++)
            {
                //OLEDB
                strSQL = "select b.jh as 井号, b.ny as 年月, b.sxszs as 视吸水指数, round(a.asx, 4) as 全区平均视吸水指数, b.zrqd as 注入强度, round(a.azr, 4) as 全区平均注入强度, b.bz as 备注 from (select d.bz, d.jh, d.ny, round(d.rzsl / d.yy, 4) as sxszs, round(d.rzsl / h.厚度, 4) as zrqd from DBA05 as d, (select 井号, sum(砂岩厚度) as 厚度 from T_DAA074 group by 井号) as h where d.jh = h.井号 and d.yy <> 0) as b,(select ny, avg(sxszs) as asx, avg(zrqd) as azr from (select d.jh, d.ny, round(d.rzsl / d.yy, 4) as sxszs, round(d.rzsl / h.厚度, 4) as zrqd from DBA05 as d, (select 井号, sum(砂岩厚度) as 厚度 from T_DAA074 group by 井号) as h where d.jh = h.井号 and d.yy <> 0 and d.ny between '" + MainForm.strStartDate + "' and '" + MainForm.strEndDate + "') group by ny) as a where a.ny = b.ny and b.jh = '" + dtWater.Rows[i]["JH"] + "' order by a.ny asc";
                dtTemp = cdu.SelectVFP(strSQL);
                //Oracle
                //strSQL = "select b.jh 井号, b.ny 年月, b.sxszs 视吸水指数, round(a.asx, 4) 全区平均视吸水指数, b.zrqd 注入强度, round(a.azr, 4) 全区平均注入强度, b.bz 备注 from (select d.bz, d.jh, d.ny, round(d.rzsl / d.yy, 4) as sxszs, round(d.rzsl / h.厚度, 4) as zrqd from DBA05 d, (select 井号, sum(砂岩厚度) as 厚度 from T_WELL_DAA074 group by 井号) h where d.jh = h.井号 and d.yy <> 0) b,(select ny, avg(sxszs) asx, avg(zrqd) azr from (select d.jh, d.ny, round(d.rzsl / d.yy, 4) as sxszs, round(d.rzsl / h.厚度, 4) as zrqd from DBA05 d, (select 井号, sum(砂岩厚度) as 厚度 from T_WELL_DAA074 group by 井号) h where d.jh = h.井号 and d.yy <> 0 and d.ny between '" + MainForm.strStartDate + "' and '" + MainForm.strEndDate + "') group by ny) a where a.ny = b.ny and b.jh = '" + dtWater.Rows[i]["JH"] + "' order by a.ny asc";
                //dtTemp = cdu.SelectDatabase(strSQL);
                dt.Merge(dtTemp);
            }
            return(dt);
        }
コード例 #6
0
        public void AmendDCB01()
        {
            string           strTableName = "T_DCB01";
            ConnDatabaseUtil cdu          = new ConnDatabaseUtil();
            string           strSQL;
            //Oledb
            string strTablePath = strTableName + ".dbf";

            if (File.Exists("./Data/" + strTablePath))
            {
                File.Delete("./Data/" + strTablePath);
            }
            strSQL = "select f.jh as 井号, f.cw as 层位, f.csrq as 测试日期, f.sumsyhd as 砂岩厚度, f.hs as 含水, round((f.sumsyhd * f.rcyl1/ g.syhd), 4) as 日产液量 from (select jh, csrq, hs, rcyl1, jdds1, jdds2, sum(sumsyhd) as syhd from (select d.*,  e.csrq, e.hs, e.rcyl1, e.jdds1, e.jdds2 from (select b.jh, b.cw, b.minsyds, (b.syds + c.syhd) as maxsyds, b.sumsyhd from (select jh, cw, min(syds) as minsyds, max(syds) as syds, sum(syhd) as sumsyhd from (select t.*, yczmc+dymc as cw from DAA074 as t where t.syds <> 0) group by jh, cw) as b, (select t.*, yczmc+dymc as cw from DAA074 as t where skqk = '1') as c where b.jh = c.jh and b.cw = c.cw and b.syds = c.syds) as d, (select jh, csrq, hs, rcyl1, jdds1, jdds2 from DCB01 where hs <> 0 and rcyl1 <> 0) as e where d.jh = e.jh and ((d.minsyds between e.jdds1 and e.jdds2) or (d.maxsyds between e.jdds1 and e.jdds2) or ((d.minsyds > e.jdds1) and (d.maxsyds < e.jdds2)) or ((d.minsyds < e.jdds1) and (d.maxsyds > e.jdds2)))) as f group by jh, csrq, hs, rcyl1, jdds1, jdds2) as g, (select d.*, e.csrq, e.hs, e.rcyl1, e.jdds1, e.jdds2 from (select b.jh, b.cw, b.minsyds, (b.syds + c.syhd) as maxsyds, b.sumsyhd from (select jh, cw, min(syds) as minsyds, max(syds) as syds, sum(syhd) as sumsyhd from (select t.*, yczmc+dymc as cw from DAA074 as t where t.syds <> 0 and t.skqk = '1') group by jh, cw) as b, (select t.*, yczmc+dymc as cw from DAA074 t) as c where b.jh = c.jh and b.cw = c.cw and b.syds = c.syds) as d, (select jh, csrq, hs, rcyl1, jdds1, jdds2 from DCB01 where hs <> 0 and rcyl1 <> 0) as e where d.jh = e.jh and ((d.minsyds between e.jdds1 and e.jdds2) or (d.maxsyds between e.jdds1 and e.jdds2) or ((d.minsyds > e.jdds1) and (d.maxsyds < e.jdds2))) or ((d.minsyds < e.jdds1) and (d.maxsyds > e.jdds2))) as f where g.jh = f.jh and g.hs = f.hs and g.csrq = f.csrq and g.rcyl1 = f.rcyl1 and g.jdds1 = f.jdds1 and g.jdds2 = f.jdds2";
            DataTable dtSKYT = cdu.SelectVFP(strSQL);

            strSQL = "create table " + strTableName.ToUpper() + " (井号 varchar(16), 层位 varchar(16), 测试日期 varchar(8), 砂岩厚度 Decimal(16, 5), 含水 Decimal(17,2), 日产液量 Decimal(17, 1))";
            cdu.CreateOrDeleteVFP(strSQL);
            cdu.InsertVFP(dtSKYT, strTableName.ToUpper());
        }
コード例 #7
0
        private void CreateSlpfDB()
        {
            string           strTableName = "T_SLPF";
            string           strTablePath = strTableName + ".dbf";
            ConnDatabaseUtil cdu          = new ConnDatabaseUtil();
            string           strSQL;

            //Oledb
            if (File.Exists("./Data/" + strTablePath))
            {
                File.Delete("./Data/" + strTablePath);
            }

            strSQL = "select f.jh, f.cw, f.rq, round(g.渗透率*g.砂岩厚度,4) as kh from (select distinct jh, cw, rq from (select d.*, e.rq, e.jdds1, e.jdds2 from (select b.jh, b.cw, b.minsyds, (b.syds + c.syhd) as maxsyds, b.sumsyhd from (select jh, cw, min(syds) as minsyds, max(syds) as syds, sum(syhd) as sumsyhd from (select t.*, yczmc+dymc as cw from DAA074 as t where t.syds <> 0) group by jh, cw) as b, (select t.*, yczmc+dymc as cw from DAA074 as t) as c where b.jh = c.jh and b.cw = c.cw and b.syds = c.syds) as d, (select jh, rq, jdds1, jdds2 from DAA091) as e where d.jh = e.jh and ((d.minsyds between e.jdds1 and e.jdds2) or (d.maxsyds between e.jdds1 and e.jdds2) or ((d.minsyds > e.jdds1) and (d.maxsyds < e.jdds2)) or ((d.minsyds < e.jdds1) and (d.maxsyds > e.jdds2))))) as f, T_DAA074 as g where f.jh = g.井号 and f.cw = g.层位";
            DataTable dt = cdu.SelectVFP(strSQL);

            strSQL = "create table " + strTableName.ToUpper() + " (jh varchar(16), cw varchar(16), rq date, kh Decimal(16, 5))";
            cdu.CreateOrDeleteVFP(strSQL);
            cdu.InsertVFP(dt, strTableName.ToUpper());
        }
コード例 #8
0
        public void AmendDaa074Method()
        {
            string           strTableName = "T_DAA074";
            string           strTablePath = strTableName + ".dbf";
            ConnDatabaseUtil cdu          = new ConnDatabaseUtil();
            string           strSQL;

            //Oledb
            if (File.Exists("./Data/" + strTablePath))
            {
                File.Delete("./Data/" + strTablePath);
            }
            //Oracle
            //string strSQL = "select count(*) as count from user_tables where table_name = '" + strTableName.ToUpper() + "'";
            //DataTable dtExist = cdu.SelectDatabase(strSQL);
            //if (Convert.ToInt32(dtExist.Rows[0]["Count"]) > 0)
            //{
            //    strSQL = "drop table " + strTableName.ToUpper();
            //    cdu.CreateOrDeleteDatabase(strSQL);
            //}
            //Oledb
            strSQL = "select distinct b.jh as 井号, b.cw as 层位, b.wx as 微相, b.stl as 渗透率, c.syhd as 砂岩厚度, c.yxhd as 有效厚度 from (select a.jh, a.cw, a.stl, a.wx, a.kxd from (select a.jh, a.cw, max(a.syhd) as syhd from (select t.*, (yczmc + dymc) as cw from DAA074 as t where t.skqk = '1') as a group by a.jh, a.cw) as d, (select t.*, (yczmc+dymc) as cw from DAA074 as t where t.skqk = '1') as a where a.jh = d.jh and a.cw = d.cw and a.syhd = d.syhd) as b, (select a.jh, a.cw, sum(a.syhd) as syhd, sum(a.yxhd) as yxhd from (select t.*, (yczmc+dymc) as cw from DAA074 as t where t.skqk = '1') as a group by a.jh, a.cw) as c where b.jh = c.jh and b.cw = c.cw order by b.cw";
            DataTable dtSKYT = cdu.SelectVFP(strSQL);

            //Oracle
            //strSQL = "select distinct b.jh 井号, b.cw 层位, b.wx 微相, b.stl 渗透率, c.syhd 砂岩厚度, c.yxhd 有效厚度 from (select a.jh, a.cw, a.stl, a.wx, a.kxd from (select a.jh, a.cw, max(a.syhd) as syhd from (select t.*, (yczmc || dymc) as cw from DAA074 t where t.skqk = 1) a group by a.jh, a.cw) d, (select t.*, (yczmc || dymc) as cw from DAA074 t where t.skqk = 1) a where a.jh = d.jh and a.cw = d.cw and a.syhd = d.syhd) b, (select a.jh, a.cw, sum(a.syhd) as syhd, sum(a.yxhd) as yxhd from (select t.*, (yczmc || dymc) as cw from DAA074 t where t.skqk = 1) a group by a.jh, a.cw) c where b.jh = c.jh and b.cw = c.cw order by b.cw";
            //DataTable dtSKYT = cdu.SelectDatabase(strSQL);

            //Oledb
            strSQL = "create table " + strTableName.ToUpper() + " (井号 varchar(16), 层位 varchar(16), 微相 varchar(1), 渗透率 Decimal(16, 5), 砂岩厚度 Decimal(17, 1), 有效厚度 Decimal(17, 1))";
            cdu.CreateOrDeleteVFP(strSQL);
            cdu.InsertVFP(dtSKYT, strTableName.ToUpper());
            //Oracle
            //strSQL = "create table " + strTableName.ToUpper() + " (井号 varchar(16), 层位 varchar(16), 微相 varchar(1), 渗透率 number(16, 5), 砂岩厚度 number(17, 1), 有效厚度 number(17, 1))";
            //cdu.CreateOrDeleteDatabase(strSQL);
            //cdu.InsertDatabase(dtSKYT, strTableName.ToUpper());
        }
コード例 #9
0
        ///未测试
        /// <summary>
        /// 修正DAA074数据库中的数据
        /// 将有效厚度为0的列修正为1/4砂岩厚度
        /// 将渗透率为0的列按传入的储层参数模板进行修正
        /// 将微相为5的数修正为相应数据
        /// </summary>
        /// <param name="dtCM">传入的储层参数模板</param>
        ///
        public void AmendDaa074Method(DataTable dtCM)
        {
            string           strTableName = "T_DAA074";
            string           strTablePath = strTableName + ".dbf";
            ConnDatabaseUtil cdu          = new ConnDatabaseUtil();
            string           strSQL;

            //Oledb
            if (File.Exists("./Data/" + strTablePath))
            {
                File.Delete("./Data/" + strTablePath);
            }
            //Oracle
            //string strSQL = "select count(*) as count from user_tables where table_name = '" + strTableName.ToUpper() + "'";
            //DataTable dtExist = cdu.SelectDatabase(strSQL);
            //if (Convert.ToInt32(dtExist.Rows[0]["Count"]) > 0)
            //{
            //    strSQL = "drop table " + strTableName;
            //    cdu.CreateOrDeleteDatabase(strSQL);
            //}
            //Oledb
            strSQL = "select distinct b.jh as 井号, b.cw as 层位, b.wx as 微相, b.stl as 渗透率, c.syhd as 砂岩厚度, c.yxhd as 有效厚度 from (select a.jh, a.cw, a.stl, a.wx, a.kxd from (select a.jh, a.cw, max(a.syhd) as syhd from (select t.*, (yczmc + dymc) as cw from DAA074 as t where t.skqk = '1') as a group by a.jh, a.cw) as d, (select t.*, (yczmc+dymc) as cw from DAA074 as t where t.skqk = '1') as a where a.jh = d.jh and a.cw = d.cw and a.syhd = d.syhd) as b, (select a.jh, a.cw, sum(a.syhd) as syhd, sum(a.yxhd) as yxhd from (select t.*, (yczmc+dymc) as cw from DAA074 as t where t.skqk = '1') as a group by a.jh, a.cw) as c where b.jh = c.jh and b.cw = c.cw order by b.cw";
            DataTable dtSKYT = cdu.SelectVFP(strSQL);

            //Oracle
            //strSQL = "select distinct b.jh 井号, b.cw 层位, b.wx 微相, b.stl 渗透率, c.syhd 砂岩厚度, c.yxhd 有效厚度 from (select a.jh, a.cw, a.stl, a.wx, a.kxd from (select a.jh, a.cw, max(a.syhd) as syhd from (select t.*, (yczmc || dymc) as cw from DAA074 t where t.skqk = 1) a group by a.jh, a.cw) d, (select t.*, (yczmc || dymc) as cw from DAA074 t where t.skqk = 1) a where a.jh = d.jh and a.cw = d.cw and a.syhd = d.syhd) b, (select a.jh, a.cw, sum(a.syhd) as syhd, sum(a.yxhd) as yxhd from (select t.*, (yczmc || dymc) as cw from DAA074 t where t.skqk = 1) a group by a.jh, a.cw) c where b.jh = c.jh and b.cw = c.cw order by b.cw";
            //DataTable dtSKYT = cdu.SelectDatabase(strSQL);

            string[] arr = { "P112b", "P121a", "P121b", "P122", "P131", "P132", "P133a", "P133b" };

            DataRow[] drYXHD = dtSKYT.Select("有效厚度 = 0");
            foreach (DataRow dr in drYXHD)
            {
                dr["有效厚度"] = Convert.ToDouble(dr["砂岩厚度"]) / 4;
            }
            DataRow[] drSTL = dtSKYT.Select("渗透率 = 0");
            foreach (DataRow dr in drSTL)
            {
                DataRow[] stlRows = dtCM.Select("YCZMC = '" + dr["层位"] + "' AND STLX = '" + dr["微相"] + "'");
                if (stlRows.Count() == 0)
                {
                    string cw = dr["层位"] + "a";
                    stlRows = dtCM.Select("YCZMC = '" + cw + "' AND STLX = '" + dr["微相"] + "'");
                    if (stlRows.Count() == 0)
                    {
                        cw      = dr["层位"].ToString().Substring(0, dr["层位"].ToString().Length - 1);
                        stlRows = dtCM.Select("YCZMC = '" + cw + "' AND STLX = '" + dr["微相"] + "'");
                    }
                }
                dr["渗透率"] = Convert.ToDouble(stlRows[0]["STL"]) * Convert.ToDouble(dr["有效厚度"]);
            }
            DataRow[] drWX = dtSKYT.Select("微相 = 5");
            foreach (DataRow dr in drWX)
            {
                if (arr.Contains(dr["层位"].ToString()))
                {
                    if (Convert.ToDouble(dr["有效厚度"]) > 0.5)
                    {
                        dr["微相"] = "1";
                    }
                    else
                    {
                        dr["微相"] = "8";
                    }
                }
                else
                {
                    if (Convert.ToDouble(dr["有效厚度"]) > 0.5)
                    {
                        dr["微相"] = "2";
                    }
                    else
                    {
                        dr["微相"] = "3";
                    }
                }
            }
            //Oledb
            strSQL = "create table " + strTableName.ToUpper() + " (井号 varchar(16), 层位 varchar(16), 微相 varchar(1), 渗透率 Decimal(16, 5), 砂岩厚度 Decimal(17, 1), 有效厚度 Decimal(17, 1))";
            cdu.CreateOrDeleteVFP(strSQL);
            cdu.InsertVFP(dtSKYT, strTableName.ToUpper());
            //Oracle
            //strSQL = "create table " + strTableName.ToUpper() + " (井号 varchar(16), 层位 varchar(16), 微相 varchar(1), 渗透率 number(16, 5), 砂岩厚度 number(17, 1), 有效厚度 number(17, 1))";
            //cdu.CreateOrDeleteDatabase(strSQL);
            //cdu.InsertDatabase(dtSKYT, strTableName.ToUpper());
        }
コード例 #10
0
        public void GetSlpfData()
        {
            //FileStream fsw = new FileStream(@"F:\研究生\油工数据\五厂项目\20161109\kh2.txt", FileMode.Append);
            //StreamWriter sw = new StreamWriter(fsw);
            if (dtSLPF.Columns.Count == 0)
            {
                dtSLPF.Columns.Add("JH", System.Type.GetType("System.String"));
                dtSLPF.Columns.Add("NY", System.Type.GetType("System.String"));
                dtSLPF.Columns.Add("SLPF", System.Type.GetType("System.Double"));
                dtSLPF.Columns.Add("DYHS", System.Type.GetType("System.Double"));
            }

            //if (dtSLPF.Rows.Count == 0)
            //{
            //    FileStream fs = new FileStream("处理连通库水量劈分.txt", FileMode.Open);
            //    StreamReader sr = new StreamReader(fs);
            //    string strReadLine = sr.ReadLine();
            //    while (strReadLine != null)
            //    {
            //        string[] strArray = Regex.Split(strReadLine, @"\s+");
            //        DataRow dr = dtSLPF.NewRow();
            //        dr["NY"] = strArray[0];
            //        dr["JH"] = strArray[1];
            //        dr["SLPF"] = Convert.ToDouble(strArray[2]);
            //        dtSLPF.Rows.Add(dr);

            //        strReadLine = sr.ReadLine();
            //    }
            //    sr.Close();
            //    fs.Close();

            //}

            //整个代码块 -   从数据库中计算
            if (dtSLPF.Rows.Count >= 0)
            {
                dtSLPF.Clear();
                CreateSlpfDB();

                ConnDatabaseUtil cdu = new ConnDatabaseUtil();
                DataTable        dtSLPFTable = cdu.SelectVFP("select * from T_SLPF");
                string           jhy = string.Empty, jhs = string.Empty;

                string strSQL = string.Empty;


                DateTime date;
                double   totalInj  = 0;
                double   currentKH = 0;
                double   totalKH   = 0;
                strSQL = "select jh, ny from DBA04 where ny between '" + MainForm.strStartDate + "' and '" + MainForm.strEndDate + "' order by jh asc, ny asc"; // 在油井库里将油井按井号 年月排序
                DataTable dtOil = cdu.SelectVFP(strSQL);
                //DataTable dtOil = cdu.SelectDatabase(strSQL);

                for (int m = 0; m < dtOil.Rows.Count; m++)
                {
                    date   = DateTime.ParseExact((string)dtOil.Rows[m]["NY"], "yyyyMM", null);
                    strSQL = "select distinct jhs, jhy from " + MainForm.strLTKName + " where jhy = '" + (string)dtOil.Rows[m]["JH"] + "'";//查询当前油井连通的水井
                    DataTable dtLTWater = cdu.SelectVFP(strSQL);
                    //DataTable dtLTWater = cdu.SelectDatabase(strSQL);


                    if (dtLTWater.Rows.Count == 0)
                    {
                        strSQL = "select count(jh) as cnt from DBA04 where jh = '" + (string)dtOil.Rows[m]["JH"] + "'";//查询当前油井个数

                        DataTable dtCNT = cdu.SelectVFP(strSQL);
                        //DataTable dtCNT = cdu.SelectDatabase(strSQL);
                        m += Convert.ToInt32(dtCNT.Rows[0]["CNT"]) - 1;
                        continue;
                    }
                    else
                    {
                        //strSQL = "select * from T_SLPF where jh = '" + (string)dtOil.Rows[m]["JH"] + "' and rq < to_date('" + date + "', 'yyyy/mm/dd hh24:mi:ss')";
                        DataTable dtYSK = new DataTable();//油射孔
                        DataRow[] drYSK = dtSLPFTable.Select("JH = '" + (string)dtOil.Rows[m]["JH"] + "' AND RQ < #" + date + "#");
                        if (drYSK.Count() > 0)
                        {
                            dtYSK = drYSK.CopyToDataTable();
                        }
                        for (int i = 0; i < dtLTWater.Rows.Count; i++)
                        {
                            //strSQL = "select * from T_SLPF  where jh = '" + (string)dtLTWater.Rows[i]["JHS"] + "' and rq < to_date('" + date + "', 'yyyy/mm/dd hh24:mi:ss')";
                            //DataTable dtSSK = cdu.SelectDatabase(strSQL);//水射孔
                            DataTable dtSSK = new DataTable();//油射孔
                            DataRow[] drSSK = dtSLPFTable.Select("JH = '" + (string)dtLTWater.Rows[i]["JHS"] + "' AND RQ < #" + date + "#");
                            if (drSSK.Count() > 0)
                            {
                                dtSSK = drSSK.CopyToDataTable();
                            }
                            if (dtSSK.Rows.Count > 0)
                            {
                                for (int j = 0; j < dtYSK.Rows.Count; j++)
                                {
                                    DataRow[] rows = dtSSK.Select("CW = '" + (string)dtYSK.Rows[j]["CW"] + "'");
                                    if (rows.Count() != 0)
                                    {
                                        currentKH += ((Convert.ToDouble(dtYSK.Rows[j]["KH"]) + Convert.ToDouble(rows[0]["KH"])) / 2);
                                    }
                                }
                                strSQL = "select distinct jhy, jhs from LTK where jhs = '" + (string)dtLTWater.Rows[i]["JHS"] + "'";
                                DataTable dtOthrOil = cdu.SelectVFP(strSQL);
                                //DataTable dtOthrOil = cdu.SelectDatabase(strSQL);
                                for (int j = 0; j < dtOthrOil.Rows.Count; j++) //查找其他油井于当前水井所在的连通层
                                {
                                    //strSQL = "select * from T_WELL_SLPF where jh = '" + (string)dtOthrOil.Rows[j]["JHY"] + "' and rq < to_date('" + date + "', 'yyyy/mm/dd hh24:mi:ss')";
                                    //DataTable dtOthrOilSK = cdu.SelectDatabase(strSQL);

                                    DataTable dtOthrOilSK = new DataTable();
                                    DataRow[] drOthrOilSK = dtSLPFTable.Select("JH = '" + (string)dtOthrOil.Rows[j]["JHY"] + "' AND RQ < #" + date + "#");
                                    if (drOthrOilSK.Count() > 0)
                                    {
                                        dtOthrOilSK = drOthrOilSK.CopyToDataTable();
                                    }

                                    for (int k = 0; k < dtOthrOilSK.Rows.Count; k++)
                                    {
                                        DataRow[] rows = dtSSK.Select("CW = '" + (string)dtOthrOilSK.Rows[k]["CW"] + "'");
                                        if (rows.Count() != 0)
                                        {
                                            totalKH += ((Convert.ToDouble(dtOthrOilSK.Rows[k]["KH"]) + Convert.ToDouble(rows[0]["KH"])) / 2);
                                        }
                                    }
                                }
                                if (totalKH != 0)
                                {
                                    double ratio = currentKH / totalKH;

                                    strSQL = "select jh, ny, round(yzsl * 30 / scts, 4) as yzsl1 from DBA05 where scts <> 0 and jh= '" + (string)dtLTWater.Rows[i]["JHS"] + "' and ny = '" + date.ToString("yyyyMM") + "'";
                                    DataTable dtZRL = cdu.SelectVFP(strSQL);
                                    //DataTable dtZRL = cdu.SelectDatabase(strSQL);
                                    if (dtZRL.Rows.Count > 0)
                                    {
                                        double dblQwo = Convert.ToDouble(dtZRL.Rows[0]["YZSL1"]) * ratio;
                                        totalInj += dblQwo;
                                    }
                                }

                                totalKH   = 0;
                                currentKH = 0;
                            }
                        }
                        DataRow dr = dtSLPF.NewRow();
                        dr["JH"]   = dtOil.Rows[m]["JH"];
                        dr["NY"]   = dtOil.Rows[m]["NY"];
                        dr["SLPF"] = totalInj;
                        dtSLPF.Rows.Add(dr);

                        totalInj = 0;
                    }
                }
            }
        }
コード例 #11
0
        public void ComputeOilHIMethod()
        {
            //FileStream fs = new FileStream(@"F:\研究生\油工数据\五厂项目\20161107\一次筛选.txt", FileMode.Append);
            //StreamWriter sw = new StreamWriter(fs);
            if (dtOilHI.Rows.Count == 0)
            {
                if (dtOilHI.Columns.Count == 0)
                {
                    dtOilHI.Columns.Add("JH", System.Type.GetType("System.String"));
                    dtOilHI.Columns.Add("RCYLHI", System.Type.GetType("System.Double"));
                    dtOilHI.Columns.Add("RCSLHI", System.Type.GetType("System.Double"));
                    dtOilHI.Columns.Add("SLPFHI", System.Type.GetType("System.Double"));
                }


                ConnDatabaseUtil cdu = new ConnDatabaseUtil();

                string strSQL = string.Empty;

                double dblTotalRcylHI = 0, dblTotalRcslHI = 0, dblTotalSlpfHI = 0;
                double dblSlpfMax = 0, dblSlpfMin = 0;
                strSQL = "select jh, ny, rcsl, rcyl from dba04 where ny between '" + MainForm.strStartDate + "' and '" + MainForm.strEndDate + "' order by jh asc, ny asc"; // 在油井库里将油井按井号 年月排序
                DataTable dtDBA04 = cdu.SelectVFP(strSQL);
                //DataTable dtDBA04 = cdu.SelectDatabase(strSQL);
                DataTable dtDBA04JH = dtDBA04.DefaultView.ToTable(true, "JH");
                for (int i = 0; i < dtDBA04JH.Rows.Count; i++)
                {
                    DataRow[] rows = dtDBA04.Select("JH = '" + dtDBA04JH.Rows[i]["JH"] + "'");
                    if (rows.Count() > 0)
                    {
                        double dblRcylMax = GroupFunction(dtDBA04, "MAX", "RCYL", "JH = '" + dtDBA04JH.Rows[i]["JH"] + "'");
                        double dblRcylMin = GroupFunction(dtDBA04, "MIN", "RCYL", "JH = '" + dtDBA04JH.Rows[i]["JH"] + "'");
                        double dblRcslMax = GroupFunction(dtDBA04, "MAX", "RCSL", "JH = '" + dtDBA04JH.Rows[i]["JH"] + "'");
                        double dblRcslMin = GroupFunction(dtDBA04, "MIN", "RCSL", "JH = '" + dtDBA04JH.Rows[i]["JH"] + "'");
                        if (SlpfDAL.dtSLPF.Rows.Count > 0)
                        {
                            DataRow[] dr = SlpfDAL.dtSLPF.Select("JH = '" + dtDBA04JH.Rows[i]["JH"] + "' AND NY >= '" + MainForm.strStartDate + "' AND NY <= '" + MainForm.strEndDate + "'");
                            if (dr.Count() > 0)
                            {
                                dblSlpfMax = GroupFunction(SlpfDAL.dtSLPF, "MAX", "SLPF", "JH = '" + dtDBA04JH.Rows[i]["JH"] + "' AND NY >= '" + MainForm.strStartDate + "' AND NY <= '" + MainForm.strEndDate + "'");
                                dblSlpfMin = GroupFunction(SlpfDAL.dtSLPF, "MIN", "SLPF", "JH = '" + dtDBA04JH.Rows[i]["JH"] + "' AND NY >= '" + MainForm.strStartDate + "' AND NY <= '" + MainForm.strEndDate + "'");
                            }
                            else
                            {
                                continue;
                            }
                        }
                        else
                        {
                            SlpfDAL slpf = new SlpfDAL();
                            ///前台创建提示 先计算水量劈分
                            slpf.GetSlpfData();
                        }



                        if (((dblRcylMax - dblRcylMin) != 0) && ((dblRcslMax - dblRcslMin) != 0) && ((dblSlpfMax - dblSlpfMin) != 0))
                        {
                            foreach (DataRow dr in rows)
                            {
                                DataRow[] drSlpf = SlpfDAL.dtSLPF.Select("JH = '" + dr["JH"] + "' AND NY = '" + dr["NY"] + "'");
                                if (drSlpf.Count() > 0)
                                {
                                    double dblRcylAvg = GroupFunction(dtDBA04, "AVG", "RCYL", "NY = '" + dr["NY"] + "'");
                                    double dblRcslAvg = GroupFunction(dtDBA04, "AVG", "RCSL", "NY = '" + dr["NY"] + "'");
                                    double dblSlpfAvg = GroupFunction(SlpfDAL.dtSLPF, "AVG", "SLPF", "NY = '" + dr["NY"] + "'");

                                    dblTotalRcylHI += (Convert.ToDouble(dr["RCYL"]) - dblRcylAvg) / (dblRcylMax - dblRcylMin);
                                    dblTotalRcslHI += (Convert.ToDouble(dr["RCSL"]) - dblRcslAvg) / (dblRcslMax - dblRcslMin);
                                    dblTotalSlpfHI += (Convert.ToDouble(drSlpf[0]["SLPF"]) - dblSlpfAvg) / (dblSlpfMax - dblSlpfMin);
                                }
                            }
                            DataRow drHI = dtOilHI.NewRow();
                            drHI["JH"]     = dtDBA04JH.Rows[i]["JH"];
                            drHI["RCYLHI"] = dblTotalRcylHI;
                            drHI["RCSLHI"] = dblTotalRcslHI;
                            drHI["SLPFHI"] = dblTotalSlpfHI;
                            dtOilHI.Rows.Add(drHI);

                            dblTotalRcylHI = 0;
                            dblTotalRcslHI = 0;
                            dblTotalSlpfHI = 0;
                        }
                    }
                }
            }
            DataRow[] drTemp = dtOilHI.Select("RCSLHI > 0 AND RCYLHI >0 AND SLPFHI > 0");
            if (drTemp.Count() > 0)
            {
                dtOilFirstFilterHI1 = drTemp.CopyToDataTable();
            }
            drTemp = dtOilHI.Select("RCSLHI > 0 AND RCYLHI >0 AND SLPFHI < 0");
            if (drTemp.Count() > 0)
            {
                dtOilFirstFilterHI2 = drTemp.CopyToDataTable();
            }
            drTemp = dtOilHI.Select("RCSLHI < 0 AND RCYLHI >0 AND SLPFHI > 0");
            if (drTemp.Count() > 0)
            {
                dtOilFirstFilterHI3 = drTemp.CopyToDataTable();
            }
            drTemp = dtOilHI.Select("RCSLHI < 0 AND RCYLHI >0 AND SLPFHI < 0");
            if (drTemp.Count() > 0)
            {
                dtOilFirstFilterHI4 = drTemp.CopyToDataTable();
            }
            drTemp = dtOilHI.Select("RCSLHI < 0 AND RCYLHI < 0 AND SLPFHI > 0");
            if (drTemp.Count() > 0)
            {
                dtOilFirstFilterHI5 = drTemp.CopyToDataTable();
            }
            drTemp = dtOilHI.Select("RCSLHI < 0 AND RCYLHI <0 AND SLPFHI < 0");
            if (drTemp.Count() > 0)
            {
                dtOilFirstFilterHI6 = drTemp.CopyToDataTable();
            }
            drTemp = dtOilHI.Select("RCSLHI > 0 AND RCYLHI < 0 AND SLPFHI > 0");
            if (drTemp.Count() > 0)
            {
                dtOilFirstFilterHI7 = drTemp.CopyToDataTable();
                //foreach (DataRow dr in dtOilFirstFilterHI7.Rows)
                //{
                //    sw.WriteLine(dr["JH"] + " " + dr["RCSLHI"] + " " + dr["RCYLHI"] + " " + dr["SLPFHI"] + " ");
                //}
            }
            drTemp = dtOilHI.Select("RCSLHI > 0 AND RCYLHI <0 AND SLPFHI < 0");
            if (drTemp.Count() > 0)
            {
                dtOilFirstFilterHI8 = drTemp.CopyToDataTable();
            }
            //sw.Close();
            //fs.Close();
        }
コード例 #12
0
        public void ComputeWaterHIMethod()
        {
            if (dtWaterHI.Rows.Count == 0)
            {
                if (dtWaterHI.Columns.Count == 0)
                {
                    dtWaterHI.Columns.Add("JH", System.Type.GetType("System.String"));
                    dtWaterHI.Columns.Add("SXSZSHI", System.Type.GetType("System.Double"));
                    dtWaterHI.Columns.Add("ZRQDHI", System.Type.GetType("System.Double"));
                }
                ConnDatabaseUtil cdu = new ConnDatabaseUtil();

                string strSQL = string.Empty;

                double dblTotalSxszsHI = 0, dblTotalZrqdHI = 0;
                strSQL = "select d.jh, d.ny, round(d.rzsl / d.yy, 4) as sxszs, round(d.rzsl / h.厚度, 4) as zrqd from DBA05 as d, (select 井号, sum(砂岩厚度) as 厚度 from T_DAA074 group by 井号) as h where d.jh = h.井号 and d.yy <> 0 and d.ny between '" + MainForm.strStartDate + "' and '" + MainForm.strEndDate + "' order by d.jh asc, d.ny asc"; // 在水井库里将水井按井号 年月排序
                DataTable dtDBA05 = cdu.SelectVFP(strSQL);
                //DataTable dtDBA05 = cdu.SelectDatabase(strSQL);
                DataTable dtDBA05JH = dtDBA05.DefaultView.ToTable(true, "JH");

                for (int i = 0; i < dtDBA05JH.Rows.Count; i++)
                {
                    DataRow[] rows = dtDBA05.Select("JH = '" + dtDBA05JH.Rows[i]["JH"] + "'");
                    if (rows.Count() > 0)
                    {
                        double dblSxszsMax = GroupFunction(dtDBA05, "MAX", "SXSZS", "JH = '" + dtDBA05JH.Rows[i]["JH"] + "'");
                        double dblSxszsMin = GroupFunction(dtDBA05, "MIN", "SXSZS", "JH = '" + dtDBA05JH.Rows[i]["JH"] + "'");
                        double dblZrqdMax  = GroupFunction(dtDBA05, "MAX", "ZRQD", "JH = '" + dtDBA05JH.Rows[i]["JH"] + "'");
                        double dblZrqdMin  = GroupFunction(dtDBA05, "MIN", "ZRQD", "JH = '" + dtDBA05JH.Rows[i]["JH"] + "'");



                        if (((dblSxszsMax - dblSxszsMin) != 0) && ((dblZrqdMax - dblZrqdMin) != 0))
                        {
                            foreach (DataRow dr in rows)
                            {
                                double dblSxszsAvg = GroupFunction(dtDBA05, "AVG", "SXSZS", "NY = '" + dr["NY"] + "'");
                                double dblZrqdAvg  = GroupFunction(dtDBA05, "AVG", "ZRQD", "NY = '" + dr["NY"] + "'");

                                dblTotalSxszsHI += (Convert.ToDouble(dr["SXSZS"]) - dblSxszsAvg) / (dblSxszsMax - dblSxszsMin);
                                dblTotalZrqdHI  += (Convert.ToDouble(dr["ZRQD"]) - dblZrqdAvg) / (dblZrqdMax - dblZrqdMin);
                            }
                            DataRow drHI = dtWaterHI.NewRow();
                            drHI["JH"]      = dtDBA05JH.Rows[i]["JH"];
                            drHI["SXSZSHI"] = dblTotalSxszsHI;
                            drHI["ZRQDHI"]  = dblTotalZrqdHI;
                            dtWaterHI.Rows.Add(drHI);

                            dblTotalSxszsHI = 0;
                            dblTotalZrqdHI  = 0;
                        }
                    }
                }
            }



            DataRow[] drTemp = dtWaterHI.Select("ZRQDHI > 0 AND SXSZSHI >0");
            //DataRow[] drTemp = dtWaterHI.Select("ZRQDHI > -0.5 AND SXSZSHI >-0.5");
            if (drTemp.Count() > 0)
            {
                dtWaterFirstFilterHI1 = drTemp.CopyToDataTable();
            }
            drTemp = dtWaterHI.Select("ZRQDHI < 0 AND SXSZSHI >0");
            if (drTemp.Count() > 0)
            {
                dtWaterFirstFilterHI2 = drTemp.CopyToDataTable();
            }
            drTemp = dtWaterHI.Select("ZRQDHI < 0 AND SXSZSHI <0");
            if (drTemp.Count() > 0)
            {
                dtWaterFirstFilterHI3 = drTemp.CopyToDataTable();
            }
            drTemp = dtWaterHI.Select("ZRQDHI > 0 AND SXSZSHI <0");
            if (drTemp.Count() > 0)
            {
                dtWaterFirstFilterHI4 = drTemp.CopyToDataTable();
            }
        }
コード例 #13
0
        public void OilSecondFilterHIMethod()
        {
            //FileStream fs = new FileStream(@"F:\研究生\油工数据\五厂项目\20161107\LYHS2.txt", FileMode.Append);
            //StreamWriter sw = new StreamWriter(fs);

            DataTable dtOilSecondFilterHI = dtOilFirstFilterHI1.Copy();

            dtOilSecondFilterHI.Merge(dtOilFirstFilterHI2);
            dtOilSecondFilterHI.Merge(dtOilFirstFilterHI5);
            dtOilSecondFilterHI.Merge(dtOilFirstFilterHI6);

            dtOilSecondFilterHI.Columns.Add("LYHI", System.Type.GetType("System.Double"));
            dtOilSecondFilterHI.Columns.Add("HSHI", System.Type.GetType("System.Double"));
            if (dtOilSecondFilterHI.Rows.Count > 0)
            {
                ConnDatabaseUtil cdu = new ConnDatabaseUtil();

                string strSQL = string.Empty;

                double dblTotalLyHI = 0, dblTotalHsHI = 0;
                strSQL = "select jh, ny, ly, hs from dba04 where ny between '" + MainForm.strStartDate + "' and '" + MainForm.strEndDate + "' order by jh asc, ny asc"; // 在油井库里将油井按井号 年月排序
                DataTable dtDBA04 = cdu.SelectVFP(strSQL);
                //DataTable dtDBA04 = cdu.SelectDatabase(strSQL);

                foreach (DataRow dr in dtOilSecondFilterHI.Rows)
                {
                    DataRow[] rows = dtDBA04.Select("JH = '" + dr["JH"] + "'");
                    if (rows.Count() > 0)
                    {
                        double dblLyMax = GroupFunction(dtDBA04, "MAX", "LY", "JH = '" + dr["JH"] + "'");
                        double dblLyMin = GroupFunction(dtDBA04, "MIN", "LY", "JH = '" + dr["JH"] + "'");
                        double dblHsMax = GroupFunction(dtDBA04, "MAX", "HS", "JH = '" + dr["JH"] + "'");
                        double dblHsMin = GroupFunction(dtDBA04, "MIN", "HS", "JH = '" + dr["JH"] + "'");



                        if (((dblLyMax - dblLyMin) != 0) && ((dblHsMax - dblHsMin) != 0))
                        {
                            foreach (DataRow drLyHs in rows)
                            {
                                double dblLyAvg = GroupFunction(dtDBA04, "AVG", "LY", "NY = '" + drLyHs["NY"] + "'");
                                double dblHsAvg = GroupFunction(dtDBA04, "AVG", "HS", "NY = '" + drLyHs["NY"] + "'");

                                dblTotalLyHI += (Convert.ToDouble(drLyHs["LY"]) - dblLyAvg) / (dblLyMax - dblLyMin);
                                dblTotalHsHI += (Convert.ToDouble(drLyHs["HS"]) - dblHsAvg) / (dblHsMax - dblHsMin);
                            }

                            dr["LYHI"] = dblTotalLyHI;
                            dr["HSHI"] = dblTotalHsHI;

                            dblTotalLyHI = 0;
                            dblTotalHsHI = 0;
                        }
                    }
                }
            }

            DataRow[] drTemp = dtOilSecondFilterHI.Select("HSHI > 0 AND LYHI >0");
            if (drTemp.Count() > 0)
            {
                dtOilSecondFilterHI1 = drTemp.CopyToDataTable();
                //for (int i = 0; i < drTemp.Count(); i++)
                //{
                //    sw.WriteLine(drTemp[i]["JH"] + " " + drTemp[i]["HSHI"] + " " + drTemp[i]["LYHI"]);
                //}
            }
            drTemp = dtOilSecondFilterHI.Select("HSHI < 0 AND LYHI >0");
            if (drTemp.Count() > 0)
            {
                dtOilSecondFilterHI2 = drTemp.CopyToDataTable();
            }
            drTemp = dtOilSecondFilterHI.Select("HSHI < 0 AND LYHI <0");
            if (drTemp.Count() > 0)
            {
                dtOilSecondFilterHI3 = drTemp.CopyToDataTable();
            }
            drTemp = dtOilSecondFilterHI.Select("HSHI > 0 AND LYHI <0");
            if (drTemp.Count() > 0)
            {
                dtOilSecondFilterHI4 = drTemp.CopyToDataTable();
            }
            //sw.Close();
            //fs.Close();
        }