Пример #1
0
        private int UpdateMGT_OP(MgtParameter mgt, int subbasinID, int hruID, int Month, int Day, int MGT_OP)
        {
            int          n      = 0;
            AccessHelper helper = new AccessHelper();

            if (MGT_OP == 1)
            {
                string sql = @"update mgt2 set [MONTH] =" + mgt.plant_month + ",[DAY] = " + mgt.plant_day + ",HUSC = " + mgt.plant_husc + ",PLANT_ID = " + mgt.plant_id + ",CURYR_MAT = " +
                             mgt.curyr_mat + ",HEATUNITS = " + mgt.heat_units + ",BIO_INIT = " + mgt.bio_init + ",HI_TARG = " + mgt.hi_targ + ",LAI_INIT = " + mgt.lai_init + ",BIO_TARG = " + mgt.bio_init + ",CNOP = " + mgt.plant_cnop +
                             " where SUBBASIN = " + subbasinID + " and HRU = " + hruID + " and MGT_OP = " + MGT_OP + " and MONTH = " + Month + " and DAY = " + Day;
                n = helper.ExcuteSql(sql);
            }
            else if (MGT_OP == 2)
            {
                string sql = @"update mgt2 set [MONTH] = " + mgt.irr_month + ",[DAY] = " + mgt.irr_day + ",HUSC = " + mgt.irr_husc + ",IRR_AMT = " + mgt.irr_amt + ",IRR_SALT = " + mgt.irr_salt +
                             ",IRR_EFM = " + mgt.irr_efm + ",IRR_SQ = " + mgt.irr_sq + ",IRR_SC = " + mgt.irr_sc + ",IRR_NO = " + mgt.irr_no +
                             " where SUBBASIN = " + subbasinID + " and HRU = " + hruID + " and MGT_OP = " + MGT_OP + " and MONTH = " + Month + " and DAY = " + Day;
                n = helper.ExcuteSql(sql);
            }
            else if (MGT_OP == 3)
            {
                string sql = @"update mgt2 set [MONTH] = " + mgt.frt_month + ",[DAY] = " + mgt.frt_day + ",HUSC = " + mgt.frt_husc + ",FERT_ID = " + mgt.fert_id + ",FRT_KG = " + mgt.frt_kg +
                             ",FRT_SURFACE = " + mgt.frt_surface +
                             " where SUBBASIN = " + subbasinID + " and HRU = " + hruID + " and MGT_OP = " + MGT_OP + " and MONTH = " + Month + " and DAY = " + Day;
                n = helper.ExcuteSql(sql);
            }
            else if (MGT_OP == 5)
            {
                string sql = @"update mgt2 set [MONTH] = " + mgt.harv_month + ",[DAY] = " + mgt.harv_day + ",HUSC = " + mgt.harv_husc + ",CNOP = " + mgt.harv_cnop +
                             " where SUBBASIN = " + subbasinID + " and HRU = " + hruID + " and MGT_OP = " + MGT_OP + " and MONTH = " + Month + " and DAY = " + Day;
                n = helper.ExcuteSql(sql);
            }
            return(n);
        }
Пример #2
0
        /// <summary>
        /// 根据指定的条件删除
        /// </summary>
        /// <param name="subbasinID"></param>
        /// <param name="hruID"></param>
        /// <param name="Month"></param>
        /// <param name="Day"></param>
        /// <param name="MGT_OP"></param>
        /// <returns></returns>
        private int DeleteMGT_OP(int subbasinID, int hruID, int Month, int Day, int MGT_OP)
        {
            string       sql    = "delete from mgt2 where SUBBASIN = " + subbasinID + " and HRU = " + hruID + " and MONTH = " + Month + " and DAY = " + Day + " and MGT_OP = " + MGT_OP;
            AccessHelper helper = new AccessHelper();
            int          n      = helper.ExcuteSql(sql);

            return(n);
        }
Пример #3
0
        /// <summary>
        /// 同一个表中复制一条记录到另外一条记录(主键除外)
        /// </summary>
        /// <param name="subbasinID">子流域编号</param>
        /// <param name="hruID">hru编号</param>
        /// <param name="MGT_OP">操作编号</param>
        /// <param name="mgt">MGT参数类</param>
        private void CopyToSelf(int subbasinID, int hruID, int MGT_OP, MgtParameter mgt)
        {
            AccessHelper MGTHelper = new AccessHelper();

            /*
             * 改代码舍弃!!!存在严重BUG
             * 拷贝指定子流域下的指定HRU的一个副本,然后对该副本进行更新数据(利用原来的数据表格式)
             * 由于YEAR,MONTH,DAY,都是ACCESS的关键字,所以要加中括号(“[]”)
             */
//            string sql = @"INSERT INTO mgt2(SUBBASIN,HRU,LANDUSE,SOIL, SLOPE_CD, CROP, [YEAR], [MONTH], [DAY], HUSC, MGT_OP, HEATUNITS, PLANT_ID, CURYR_MAT, LAI_INIT,BIO_INIT,
//				                               HI_TARG, BIO_TARG,CNOP, IRR_AMT, FERT_ID,FRT_KG,FRT_SURFACE,PEST_ID,PST_KG,TILLAGE_ID,HARVEFF,HI_OVR,GRZ_DAYS,MANURE_ID,BIO_EAT,
//				                               BIO_TRMP,MANURE_KG,WSTRS_ID,AUTO_WSTRS,AFERT_ID,AUTO_NSTRS,AUTO_NAPP,AUTO_NYR,AUTO_EFF,AFRT_SURFACE,SWEEPEFF,FR_CURB,IMP_TRIG,
//				                               FERT_DAYS,CFRT_ID,IFRT_FREQ,CFRT_KG, PST_DEP,IHV_GBM,IRR_SALT,IRR_EFM,IRR_SQ,IRR_EFF,IRR_MX,IRR_ASQ, CPST_ID,PEST_DAYS,IPEST_FREQ,
//				                               CPST_KG,BURN_FRLB,OP_NUM,IRR_SC,IRR_NO,IRR_SCA,IRR_NOA)
//                                 SELECT TOP 1  SUBBASIN,HRU,LANDUSE,SOIL, SLOPE_CD, CROP, YEAR, MONTH, DAY, HUSC, MGT_OP, HEATUNITS, PLANT_ID, CURYR_MAT, LAI_INIT,	 BIO_INIT,
//				                               HI_TARG, BIO_TARG,CNOP, IRR_AMT, FERT_ID,FRT_KG,FRT_SURFACE,PEST_ID,PST_KG,TILLAGE_ID,HARVEFF,HI_OVR,GRZ_DAYS,MANURE_ID,BIO_EAT,
//				                               BIO_TRMP,MANURE_KG,WSTRS_ID,AUTO_WSTRS,AFERT_ID,AUTO_NSTRS,AUTO_NAPP,AUTO_NYR,AUTO_EFF,AFRT_SURFACE,SWEEPEFF,FR_CURB,IMP_TRIG,
//				                               FERT_DAYS,CFRT_ID,IFRT_FREQ,CFRT_KG, PST_DEP,IHV_GBM,IRR_SALT,IRR_EFM,IRR_SQ,IRR_EFF,IRR_MX,IRR_ASQ, CPST_ID,PEST_DAYS,IPEST_FREQ,
//				                               CPST_KG,BURN_FRLB,OP_NUM,IRR_SC,IRR_NO,IRR_SCA,IRR_NOA
//	                             FROM mgt2 WHERE SUBBASIN = " + subbasinID + "  AND HRU = " + hruID + " AND MGT_OP = " + MGT_OP;

            DataTable hru_info = getLandUse_Soil_SlopeBySUBAndHRU(subbasinID, hruID);  //获得hru的三项信息
            string    land_use = hru_info.Rows[0][0].ToString();
            string    soil     = hru_info.Rows[0][1].ToString();
            string    slope    = hru_info.Rows[0][2].ToString();
            string    sql      = @"INSERT INTO mgt2(SUBBASIN,HRU,LANDUSE,SOIL, SLOPE_CD, CROP, [YEAR], [MONTH], [DAY], HUSC, 
                 MGT_OP,HEATUNITS, PLANT_ID, CURYR_MAT, LAI_INIT,BIO_INIT,HI_TARG, BIO_TARG,CNOP, IRR_AMT,
                 FERT_ID,FRT_KG,FRT_SURFACE,PEST_ID,PST_KG,TILLAGE_ID,HARVEFF,HI_OVR,GRZ_DAYS,MANURE_ID,
                 BIO_EAT,BIO_TRMP,MANURE_KG,WSTRS_ID,AUTO_WSTRS,AFERT_ID,AUTO_NSTRS,AUTO_NAPP,AUTO_NYR,AUTO_EFF,
                 AFRT_SURFACE,SWEEPEFF,FR_CURB,IMP_TRIG,FERT_DAYS,CFRT_ID,IFRT_FREQ,CFRT_KG, PST_DEP,IHV_GBM,
                 IRR_SALT,IRR_EFM,IRR_SQ,IRR_EFF,IRR_MX,IRR_ASQ, CPST_ID,PEST_DAYS,IPEST_FREQ,CPST_KG,
                 BURN_FRLB,OP_NUM,IRR_SC,IRR_NO,IRR_SCA,IRR_NOA) 
          values(" + subbasinID + "," + hruID + ",'" + land_use + "','" + soil + "','" + slope + "','',1,1,1,0," +
                                 "1,0,0,0,0,0,0,0,0,0," +
                                 "0,0,0,0,0,0,0,0,0,0," +
                                 "0,0,0,0,0,0,0,0,0,0," +
                                 "0,0,0,0,0,0,0,0,0,0," +
                                 "0,0,0,0,0,0,0,0,0,0," +
                                 "0,0,0,0,0,0)";
            int n = MGTHelper.ExcuteSql(sql);

            //获取新加数据的OID编号
            sql = "select oid from mgt2 where subbasin = " + subbasinID + " and hru = " + hruID + " order by oid desc";
            DataTable dt  = MGTHelper.GetDataTableFromDB(sql);
            int       OID = Convert.ToInt32(dt.Rows[0][0]);

            //根据MGT_OP和OID更新数据
            if (MGT_OP == 1)    //种植
            {
                sql = @"update mgt2 set CROP = '" + mgt.crop + "',[YEAR] = 1" + ",[MONTH] = " + mgt.plant_month + ",[DAY] = " + mgt.plant_day + ",HUSC = 0" + ",MGT_OP = " + mgt.plant_mgt_op + ",HEATUNITS = " + mgt.heat_units + ",PLANT_ID = " + mgt.plant_id +
                      ",CURYR_MAT = " + mgt.curyr_mat + ",LAI_INIT = " + mgt.lai_init + ",HI_TARG = " + mgt.hi_targ + ",BIO_TARG = " + mgt.bio_targ + ",CNOP = " + mgt.plant_cnop + " WHERE OID =" + OID + " and subbasin = " + subbasinID + " and hru =" + hruID;
                n = MGTHelper.ExcuteSql(sql);
            }
            else if (MGT_OP == 2)   //灌溉
            {
                sql = @"update mgt2 set CROP = null,[YEAR] = 1" + ",[MONTH] = " + mgt.irr_month + ",[DAY] = " + mgt.irr_day + ",HUSC = " + mgt.irr_husc + ",MGT_OP = " + mgt.irr_mgt_op + ",IRR_AMT = " + mgt.irr_amt + ",IRR_SALT = " + mgt.irr_salt + ",IRR_EFM = " + mgt.irr_efm + ",IRR_SQ = " +
                      mgt.irr_sq + ",IRR_SC = " + mgt.irr_sc + ",IRR_NO = " + mgt.irr_no + " WHERE OID =" + OID + " and subbasin = " + subbasinID + " and hru =" + hruID;
                n = MGTHelper.ExcuteSql(sql);
            }
            else if (MGT_OP == 3)   //施肥
            {
                sql = @"update mgt2 set CROP = null,[YEAR] = 1" + ",[MONTH] = " + mgt.frt_month + ",[DAY] = " + mgt.frt_day + ",HUSC = " + mgt.frt_husc + ",MGT_OP =" + mgt.frt_mgt_op + ",FERT_ID = " + mgt.fert_id + ",FRT_KG = " + mgt.frt_kg + ",FRT_SURFACE = " + mgt.frt_surface
                      + " where OID = " + OID + " and subbasin = " + subbasinID + "  and hru = " + hruID;
                n = MGTHelper.ExcuteSql(sql);
            }
            else if (MGT_OP == 5)     //收割
            {
                sql = @"update mgt2 set CROP = null,[YEAR] = 1" + ",[MONTH] = " + mgt.harv_month + ",[DAY] = " + mgt.harv_day + ",HUSC = " + mgt.harv_husc + ",MGT_OP = " + mgt.harv_mgt_op + ",CNOP = " + mgt.harv_cnop
                      + "  where OID = " + OID + " and subbasin = " + subbasinID + "  and hru = " + hruID;
                n = MGTHelper.ExcuteSql(sql);
            }
        }