/// <summary> /// 根据占补平衡id获取剩余面积 /// </summary> /// <param name="balanceId"></param> /// <returns></returns> public static RemainArea1 GetRemainAreaByBalanceId(int balanceId) { Model.T_DemandSupplyBalance model = bll_demand_supply_balance.GetModel(Convert.ToInt32(balanceId)); //获取该批次已经使用面积 decimal usedConsArea, usedAgriArea, usedArabArea; usedConsArea = usedAgriArea = usedArabArea = 0; DataSet ds = bll_batch_balance.GetList(" dsBalanceId=" + balanceId); if (ds.Tables[0].Rows.Count > 0) { foreach (DataRow dr in ds.Tables[0].Rows) { if (dr["agriArea"] != null) { usedAgriArea += Convert.ToDecimal(dr["agriArea"]); } if (dr["arabArea"] != null) { usedArabArea += Convert.ToDecimal(dr["arabArea"]); } } } RemainArea1 remainAreas = new RemainArea1(); remainAreas.consArea = 0; remainAreas.agriArea = (Decimal)model.agriArea - usedAgriArea; remainAreas.arabArea = (Decimal)model.arabArea - usedArabArea; return remainAreas; }
/// <summary> /// 获取该批次剩余面积 /// </summary> /// <param name="context"></param> private void GetRemainArea(HttpContext context) { string dsBalanceId = ""; if (null != context.Request.QueryString["dsBalanceId"]) { dsBalanceId = context.Request.QueryString["dsBalanceId"].ToString().Trim(); } Model.T_DemandSupplyBalance model = bll_demand_supply_balance.GetModel(Convert.ToInt32(dsBalanceId)); //获取该批次已经使用面积 decimal usedConsArea, usedAgriArea, usedArabArea; usedConsArea = usedAgriArea = usedArabArea = 0; DataSet ds = bll_batch_balance.GetList(" dsBalanceId=" + dsBalanceId); if (ds.Tables[0].Rows.Count > 0) { foreach (DataRow dr in ds.Tables[0].Rows) { if (dr["agriArea"] != null) { usedAgriArea += Convert.ToDecimal(dr["agriArea"]); } if (dr["arabArea"] != null) { usedArabArea += Convert.ToDecimal(dr["arabArea"]); } } } RemainArea1 remainAreas = new RemainArea1(); remainAreas.consArea = 0; remainAreas.agriArea = (Decimal)model.agriArea - usedAgriArea; remainAreas.arabArea = (Decimal)model.arabArea - usedArabArea; context.Response.Write(JsonHelper.Object2Json<RemainArea1>(remainAreas)); }