コード例 #1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            Dictionary <SqlConnection, SqlTransaction> MyDict = new Dictionary <SqlConnection, SqlTransaction>();

            try
            {
                //获取当前数据在数据库中对应的id
                int FarmlandMegId = Convert.ToInt32(context.Request["hiddenID"]);

                //根据“农田信息”表中的id分别查出其他三个表中的id

                //土壤养分信息录入表
                SoilNutrientSoft.BLL.SoilNutrientMeg          newSoilNutrientMegBll  = new SoilNutrientSoft.BLL.SoilNutrientMeg();
                List <SoilNutrientSoft.Model.SoilNutrientMeg> newSoilNutrientMegList = newSoilNutrientMegBll.GetModelList(" All_id = " + FarmlandMegId);
                //获取其在土壤养分信息录入表中对应的id
                int SoilNutrientMegId = newSoilNutrientMegList[0].Id;


                //作物信息录入表
                SoilNutrientSoft.BLL.CropsMeg          newCropsMegBll  = new SoilNutrientSoft.BLL.CropsMeg();
                List <SoilNutrientSoft.Model.CropsMeg> newCropsMegList = newCropsMegBll.GetModelList(" All_id = " + FarmlandMegId);
                //获取其在作物信息录入表中对应的id
                int CropsMegId = newCropsMegList[0].Id;


                //农田管理建议表
                SoilNutrientSoft.BLL.FarmlandMSug          newFarmlandMSugBll  = new SoilNutrientSoft.BLL.FarmlandMSug();
                List <SoilNutrientSoft.Model.FarmlandMSug> newFarmlandMSugList = newFarmlandMSugBll.GetModelList(" All_id = " + FarmlandMegId);
                //获取其在农田管理建议表中对应的id
                int FarmlandMSugId = newFarmlandMSugList[0].Id;


                #region 第一张表单  农田信息

                SoilNutrientSoft.Model.FarmlandMeg newFarmlandMegModel = new SoilNutrientSoft.Model.FarmlandMeg();

                newFarmlandMegModel.Id                    = FarmlandMegId;
                newFarmlandMegModel.City                  = context.Request["city"];
                newFarmlandMegModel.County                = context.Request["country"];
                newFarmlandMegModel.Town                  = context.Request["townName"];
                newFarmlandMegModel.Village               = context.Request["villageName"];
                newFarmlandMegModel.Sample_name           = context.Request["SampleName"];
                newFarmlandMegModel.Lon                   = Convert.ToDecimal(String.IsNullOrEmpty(context.Request["LongitudeDegree"]) ? "0" : context.Request["LongitudeDegree"]);
                newFarmlandMegModel.Lat                   = Convert.ToDecimal(String.IsNullOrEmpty(context.Request["LatitudeDegree"]) ? "0" : context.Request["LatitudeDegree"]);
                newFarmlandMegModel.Name_of_householder   = context.Request["NameOfHouseholder"];
                newFarmlandMegModel.Phone_number          = context.Request["PhoneNumber"];
                newFarmlandMegModel.Irrigation_Conditions = Convert.ToInt32(String.IsNullOrEmpty(context.Request["IrrigationConditions"]) ? "1" : context.Request["IrrigationConditions"]);
                newFarmlandMegModel.Acreage               = Convert.ToDecimal(String.IsNullOrEmpty(context.Request["Acreage"]) ? "0" : context.Request["Acreage"]);
                newFarmlandMegModel.Fertility             = Convert.ToInt32(String.IsNullOrEmpty(context.Request["Fertility"]) ? "1" : context.Request["Fertility"]);
                newFarmlandMegModel.Weeds                 = context.Request["Weeds"];

                SoilNutrientSoft.BLL.FarmlandMeg newFarmlandMegBLL = new SoilNutrientSoft.BLL.FarmlandMeg();

                //更新数据,返回bool类型的值
                bool resultNumFLM = newFarmlandMegBLL.Update(newFarmlandMegModel, MyDict);

                #endregion

                #region 第二张表单 土壤养分信息

                SoilNutrientSoft.Model.SoilNutrientMeg newSoilNutrientMegModel = new SoilNutrientSoft.Model.SoilNutrientMeg();
                newSoilNutrientMegModel.Id            = SoilNutrientMegId;
                newSoilNutrientMegModel.N             = Convert.ToDecimal(String.IsNullOrEmpty(context.Request["N_SoilNutrient"]) ? "0" : context.Request["N_SoilNutrient"]);
                newSoilNutrientMegModel.P             = Convert.ToDecimal(String.IsNullOrEmpty(context.Request["P_SoilNutrient"]) ? "0" : context.Request["P_SoilNutrient"]);
                newSoilNutrientMegModel.K             = Convert.ToDecimal(String.IsNullOrEmpty(context.Request["K_SoilNutrient"]) ? "0" : context.Request["K_SoilNutrient"]);
                newSoilNutrientMegModel.HydrolyticN   = Convert.ToDecimal(String.IsNullOrEmpty(context.Request["HydrolyticN_SoilNutrient"]) ? "0" : context.Request["HydrolyticN_SoilNutrient"]);
                newSoilNutrientMegModel.QuickP        = Convert.ToDecimal(String.IsNullOrEmpty(context.Request["QuickP_SoilNutrient"]) ? "0" : context.Request["QuickP_SoilNutrient"]);
                newSoilNutrientMegModel.QUicK         = Convert.ToDecimal(String.IsNullOrEmpty(context.Request["QuickK_SoilNutrient"]) ? "0" : context.Request["QuickK_SoilNutrient"]);
                newSoilNutrientMegModel.OrganicMatter = Convert.ToDecimal(String.IsNullOrEmpty(context.Request["OrganicMatter_SoilNutrient"]) ? "0" : context.Request["OrganicMatter_SoilNutrient"]);
                newSoilNutrientMegModel.PH            = Convert.ToDecimal(String.IsNullOrEmpty(context.Request["PH_SoilNutrient"]) ? "0" : context.Request["PH_SoilNutrient"]);
                newSoilNutrientMegModel.All_id        = FarmlandMegId;


                //更新数据,返回bool类型的值
                bool resultNumSoil = newSoilNutrientMegBll.Update(newSoilNutrientMegModel, MyDict);

                #endregion

                #region 第三张表  作物信息

                SoilNutrientSoft.Model.CropsMeg newCropsMegModel = new SoilNutrientSoft.Model.CropsMeg();
                newCropsMegModel.Id               = CropsMegId;
                newCropsMegModel.CropType         = context.Request["CropType_CropInfo"];
                newCropsMegModel.Varieties        = context.Request["Varieties_CropInfo"];
                newCropsMegModel.Yield            = Convert.ToDecimal(String.IsNullOrEmpty(context.Request["Yield_CropInfo"]) ? "0" : context.Request["Yield_CropInfo"]);
                newCropsMegModel.urea             = Convert.ToDecimal(String.IsNullOrEmpty(context.Request["urea_CropInfo"]) ? "0" : context.Request["urea_CropInfo"]);
                newCropsMegModel.An               = Convert.ToDecimal(String.IsNullOrEmpty(context.Request["An_CropInfo"]) ? "0" : context.Request["An_CropInfo"]);
                newCropsMegModel.K                = Convert.ToDecimal(String.IsNullOrEmpty(context.Request["K_CropInfo"]) ? "0" : context.Request["K_CropInfo"]);
                newCropsMegModel.Organic_manure   = Convert.ToDecimal(String.IsNullOrEmpty(context.Request["Organic_manure_CropInfo"]) ? "0" : context.Request["Organic_manure_CropInfo"]);
                newCropsMegModel.Others           = Convert.ToDecimal(String.IsNullOrEmpty(context.Request["Others_CropInfo"]) ? "0" : context.Request["Others_CropInfo"]);
                newCropsMegModel.Irrigation_times = Convert.ToInt32(String.IsNullOrEmpty(context.Request["Irrigation_times"]) ? "0" : context.Request["Irrigation_times_CropInfo"]);
                newCropsMegModel.All_id           = FarmlandMegId;

                //更新数据,返回bool类型的值
                bool resultNumCrops = newCropsMegBll.Update(newCropsMegModel, MyDict);


                #endregion

                #region 第四张表    农田管理建议

                SoilNutrientSoft.Model.FarmlandMSug newFarmlandMSugModel = new SoilNutrientSoft.Model.FarmlandMSug();
                newFarmlandMSugModel.Id              = FarmlandMSugId;
                newFarmlandMSugModel.CropType        = context.Request["CropType_ManaSug"];
                newFarmlandMSugModel.Varieties       = context.Request["Varieties_ManaSug"];
                newFarmlandMSugModel.TargetYield     = Convert.ToDecimal(String.IsNullOrEmpty(context.Request["TargetYield_ManaSug"]) ? "0" : context.Request["TargetYield_ManaSug"]);
                newFarmlandMSugModel.urea            = Convert.ToDecimal(String.IsNullOrEmpty(context.Request["urea_ManaSug"]) ? "0" : context.Request["urea_ManaSug"]);
                newFarmlandMSugModel.An              = Convert.ToDecimal(String.IsNullOrEmpty(context.Request["An_ManaSug"]) ? "0" : context.Request["An_ManaSug"]);
                newFarmlandMSugModel.K               = Convert.ToDecimal(String.IsNullOrEmpty(context.Request["K_ManaSug"]) ? "0" : context.Request["K_ManaSug"]);
                newFarmlandMSugModel.OrganicManure   = Convert.ToDecimal(String.IsNullOrEmpty(context.Request["Organic_manure_ManaSug"]) ? "0" : context.Request["Organic_manure_ManaSug"]);
                newFarmlandMSugModel.Others          = Convert.ToDecimal(String.IsNullOrEmpty(context.Request["Others_ManaSug"]) ? "0" : context.Request["Others_ManaSug"]);
                newFarmlandMSugModel.IrrigationTimes = Convert.ToInt32(String.IsNullOrEmpty(context.Request["Irrigation_times_ManaSug"]) ? "0" : context.Request["Irrigation_times_ManaSug"]);
                newFarmlandMSugModel.SowingAmount    = Convert.ToDecimal(String.IsNullOrEmpty(context.Request["SowingAmount_ManaSug"]) ? "0" : context.Request["SowingAmount_ManaSug"]);
                newFarmlandMSugModel.SowingMethod    = context.Request["SowingMethod_ManaSug"];
                newFarmlandMSugModel.WeedControl     = context.Request["WeedControl_ManaSug"];
                newFarmlandMSugModel.PestControl     = context.Request["PestControl_ManaSug"];
                newFarmlandMSugModel.FieldManagement = context.Request["FieldManagement_ManaSug"];
                newFarmlandMSugModel.Remarks         = context.Request["Remarks_ManaSug"];
                newFarmlandMSugModel.All_id          = FarmlandMegId;

                //更新数据,返回bool类型的值
                bool resultFLMS = newFarmlandMSugBll.Update(newFarmlandMSugModel, MyDict);
                #endregion

                //判断四张表是否都更新
                if (resultFLMS && resultNumCrops && resultNumFLM && resultNumSoil)
                {
                    context.Response.Write("ok");
                }
                else
                {
                    context.Response.Write("信息录入失败");
                }
                QuitConnTrans(MyDict);
            }
            catch (Exception E)
            {
                ExceptionQuitConnTrans(MyDict);
                context.Response.Write("更新数据时发生异常:" + E.Message);
                //将信息返回给客户端,停止该页的执行
                context.Response.End();
            }
        }
コード例 #2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            //获取到标记对应的id
            int markerID = Convert.ToInt32(context.Request["id"]);

            //农田基本数据对象
            SoilNutrientSoft.BLL.FarmlandMeg   newFarmlandMegBll   = new SoilNutrientSoft.BLL.FarmlandMeg();
            SoilNutrientSoft.Model.FarmlandMeg newFarmlandMegModel = new SoilNutrientSoft.Model.FarmlandMeg();
            //根据id查询数据
            newFarmlandMegModel = newFarmlandMegBll.GetModel(markerID);

            //创建序列化对象
            JavaScriptSerializer JavaScriptSerializer = new JavaScriptSerializer();

            //转换成JSON字符串
            // var dataStr = JavaScriptSerializer.Serialize(newFarmlandMegModel);

            //**************************************************
            //土壤养分信息
            SoilNutrientSoft.BLL.SoilNutrientMeg          newSoilNutrientMegBll  = new SoilNutrientSoft.BLL.SoilNutrientMeg();
            List <SoilNutrientSoft.Model.SoilNutrientMeg> newSoilNutrientMegList = newSoilNutrientMegBll.GetModelList(" All_id = " + markerID.ToString());

            //转换成JSON字符串
            // var dataStr = JavaScriptSerializer.Serialize(newSoilNutrientMegList[0]);

            //**************************************************


            //作物数据
            SoilNutrientSoft.BLL.CropsMeg          newCropsMegBll  = new SoilNutrientSoft.BLL.CropsMeg();
            List <SoilNutrientSoft.Model.CropsMeg> newCropsMegList = newCropsMegBll.GetModelList(" All_id = " + markerID.ToString());

            //转换成JSON字符串
            //var dataStr = JavaScriptSerializer.Serialize(newCropsMegList[0]);

            //***************************************

            //农田建议
            SoilNutrientSoft.BLL.FarmlandMSug          newFarmlandMSugBll  = new SoilNutrientSoft.BLL.FarmlandMSug();
            List <SoilNutrientSoft.Model.FarmlandMSug> newFarmlandMSugList = newFarmlandMSugBll.GetModelList(" All_id = " + markerID.ToString());

            //转换成JSON字符串
            //var dataStr = JavaScriptSerializer.Serialize(newFarmlandMSugList[0]);


            //***************************************

            //图片
            SoilNutrientSoft.BLL.Picture newPictureBll = new SoilNutrientSoft.BLL.Picture();
            //得到数据集合
            List <SoilNutrientSoft.Model.Picture> newPictureModelList = newPictureBll.GetModelList(" All_id = " + markerID.ToString());

            //添加至内部类List中
            List <Pic> newPicList = new List <Pic>();

            foreach (var item in newPictureModelList)
            {
                newPicList.Add(new Pic()
                {
                    picPath = item.picturePath
                });
            }
            //转换成JSON字符串
            //var dataStr = JavaScriptSerializer.Serialize(newPicList);


            SerializeObject newSerializeObject = new SerializeObject()
            {
                FarmlandMegObject     = newFarmlandMegModel,
                SoilNutrientMegObject = newSoilNutrientMegList[0],
                CropsMegObject        = newCropsMegList[0],
                FarmlandMSugObject    = newFarmlandMSugList[0],
                PicObject             = newPicList
            };

            var dataStr = JavaScriptSerializer.Serialize(newSerializeObject);


            context.Response.Write(dataStr);
        }
コード例 #3
0
        public List <SoilAllInfo> GetListSoilAllInfo(int ProvinceNum, int CountryNum)
        {
            string strwhere = "";

            //查询到满足条件的集合
            if (ProvinceNum == -1 && CountryNum == -1)
            {
                //表示所有都全选
                strwhere = "1 > 0";
            }
            else if (ProvinceNum >= 0 && CountryNum == -1)
            {
                //表示只有“区县”全选
                strwhere = "City = " + ProvinceNum.ToString();
            }
            else
            {
                strwhere = "City = " + ProvinceNum.ToString() + " and County = " + CountryNum.ToString();
                //测试为全选
            }

            //农田基本数据对象
            SoilNutrientSoft.BLL.FarmlandMeg newFarmlandMegBll = new SoilNutrientSoft.BLL.FarmlandMeg();
            List <Model.FarmlandMeg>         TmpFarmlanMeg     = newFarmlandMegBll.GetModelList(strwhere);

            //作物数据
            SoilNutrientSoft.BLL.CropsMeg newCropsMegBll = new SoilNutrientSoft.BLL.CropsMeg();
            //农田建议
            SoilNutrientSoft.BLL.FarmlandMSug newFarmlandMSugBll = new SoilNutrientSoft.BLL.FarmlandMSug();
            //土壤养分信息
            SoilNutrientSoft.BLL.SoilNutrientMeg newSoilNutrientMegBll = new SoilNutrientSoft.BLL.SoilNutrientMeg();

            //通过查询出来的id来获取其他三张表的信息
            foreach (var tmp in TmpFarmlanMeg)
            {
                var tmpInfo = new SoilAllInfo();

                tmpInfo.CropsMegCity                 = tmp.City;
                tmpInfo.CropsMegCounty               = tmp.County;
                tmpInfo.CropsMegTown                 = tmp.Town;
                tmpInfo.CropsMegVillage              = tmp.Village;
                tmpInfo.CropsMegSampleName           = tmp.Sample_name;
                tmpInfo.CropsMegLon                  = tmp.Lon;
                tmpInfo.CropsMegLat                  = tmp.Lat;
                tmpInfo.CropsMegNameOfHouseholder    = tmp.Name_of_householder;
                tmpInfo.CropsMegPhoneNumber          = tmp.Phone_number;
                tmpInfo.CropsMegIrrigationConditions = tmp.Irrigation_Conditions;
                tmpInfo.CropsMegAcreage              = tmp.Acreage;
                tmpInfo.CropsMegFertility            = tmp.Fertility;
                tmpInfo.CropsMegWeeds                = tmp.Weeds;

                //根据id分别获取  作物数据    农田建议    土壤养分信息

                Model.CropsMeg tmpCropsMegs = (newCropsMegBll.GetModelList("id=" + tmp.Id.ToString()))[0];
                tmpInfo.CropsMegCropType       = tmpCropsMegs.CropType;
                tmpInfo.CropMegVarieties       = tmpCropsMegs.Varieties;
                tmpInfo.CropMegYield           = tmpCropsMegs.Yield;
                tmpInfo.CropMegUrea            = tmpCropsMegs.urea;
                tmpInfo.CropMegAn              = tmpCropsMegs.An;
                tmpInfo.CropMegK               = tmpCropsMegs.K;
                tmpInfo.CropMegOrganicManure   = tmpCropsMegs.Organic_manure;
                tmpInfo.CropMegOthers          = tmpCropsMegs.Others;
                tmpInfo.CropMegIrrigationTimes = tmpCropsMegs.Irrigation_times;

                Model.FarmlandMSug tmpFarmlandMSug = (newFarmlandMSugBll.GetModelList("id=" + tmp.Id.ToString()))[0];
                tmpInfo.MSugCropType        = tmpFarmlandMSug.CropType;
                tmpInfo.MSugVarieties       = tmpFarmlandMSug.Varieties;
                tmpInfo.MSugTargetYield     = tmpFarmlandMSug.TargetYield;
                tmpInfo.MSugUrea            = tmpFarmlandMSug.urea;
                tmpInfo.MSugAn              = tmpFarmlandMSug.An;
                tmpInfo.MSugK               = tmpFarmlandMSug.K;
                tmpInfo.MSugOrganicManure   = tmpFarmlandMSug.OrganicManure;
                tmpInfo.MSugOthers          = tmpFarmlandMSug.Others;
                tmpInfo.MSugIrrigationTimes = tmpFarmlandMSug.IrrigationTimes;
                tmpInfo.MSugSowingAmout     = tmpFarmlandMSug.SowingAmount;
                tmpInfo.MSugSowingMethod    = tmpFarmlandMSug.SowingMethod;
                tmpInfo.MSugWeedControl     = tmpFarmlandMSug.WeedControl;
                tmpInfo.MSugFieldManagement = tmpFarmlandMSug.FieldManagement;
                tmpInfo.MSugRemarkers       = tmpFarmlandMSug.Remarks;

                Model.SoilNutrientMeg tmpSoilNutrientMeg = (newSoilNutrientMegBll.GetModelList("id=" + tmp.Id.ToString()))[0];
                tmpInfo.SoilNutrientN             = tmpSoilNutrientMeg.N;
                tmpInfo.SoilNutrientP             = tmpSoilNutrientMeg.P;
                tmpInfo.SoilNutrientK             = tmpSoilNutrientMeg.K;
                tmpInfo.SoilNutrientHydrolyticN   = tmpSoilNutrientMeg.HydrolyticN;
                tmpInfo.SoilNutrientQuickP        = tmpSoilNutrientMeg.QUicK;
                tmpInfo.SoilNutrientQuickK        = tmpSoilNutrientMeg.QUicK;
                tmpInfo.SoilNutrientOrganicMatter = tmpSoilNutrientMeg.OrganicMatter;
                tmpInfo.SoilNutrientPh            = tmpSoilNutrientMeg.PH;

                ListSoilAllInfo.Add(tmpInfo);
            }
            return(ListSoilAllInfo);
        }