示例#1
0
        public ActionResult EditSurvey(int Id)
        {
            var geosurvey = Database.Session.Load <GeoSurvey>(Id);

            ViewBag.CLientRegions    = new SelectList(Regions, "Id", "Name", geosurvey.Client.Region.Id.ToString());
            ViewBag.GeosurveyRegions = new SelectList(Regions, "Id", "Name", geosurvey.Region.Id.ToString());
            ViewBag.DistrictLists    = new SelectList(GetDistrict(geosurvey.Region.Id), "Id", "Name", geosurvey.District.Id.ToString());
            ViewBag.Staff            = new SelectList(Staffs, "Id", "Name", geosurvey.Staff.Id);
            //ViewBag.SurveyTypes1 = new SelectList(SurveyorDrop.surveyorTypes.ToList(), "Id", "Name", SurveyTypeId(surveyProfile[0].SurveyMethod));
            //ViewBag.SurveyTypes2 = new SelectList(SurveyorDrop.surveyorTypes.ToList(), "Id", "Name", SurveyTypeId(surveyProfile[1].SurveyMethod));
            //ViewBag.SurveyTypes3 = new SelectList(SurveyorDrop.surveyorTypes.ToList(), "Id", "Name", SurveyTypeId(surveyProfile[2].SurveyMethod));

            if (geosurvey == null)
            {
                return(HttpNotFound());
            }

            var model = new SurveyEdit();

            model.surveyId       = geosurvey.Id;
            model.Client.Name    = geosurvey.Client.Name;
            model.Client.Address = geosurvey.Client.Address;
            //model.Client.Region = geosurvey.Client.Region.Name;
            model.Client.Phone = geosurvey.Client.Phone;
            model.Client.Email = geosurvey.Client.Email;

            ViewBag.Village = geosurvey.Village;

            //model.Region1 = geosurvey.Region.Name;
            //model.District = geosurvey.District.Name;
            model.Village      = geosurvey.Village;
            model.SurveyorType = geosurvey.SurveyType;
            model.Cost         = geosurvey.Cost;
            //model.SurveyorName = geosurvey.Staff.Name;
            model.StartDate          = geosurvey.StartDate;
            model.EndDate            = geosurvey.EndDate;
            model.SiteRecommendation = geosurvey.SiteRecommendation;

            return(View(model));
        }
示例#2
0
        public ActionResult EditSurveyClient(SurveyEdit data, string prevBtn, string nextBtn)
        {
            //var geosurvey = Database.Session.Load<GeoSurvey>(Id);
            //List<SurveyProfile> surveyProfile = new List<SurveyProfile>();
            var surveyProfile = Database.Session.Query <SurveyProfile>().Where(x => x.GeoSurvey.Id == data.surveyId).ToList <SurveyProfile>();

            ViewBag.SurveyTypes1 = new SelectList(SurveyorDrop.surveyorTypes.ToList(), "Id", "Name", SurveyTypeId(surveyProfile[0].SurveyMethod));
            ViewBag.SurveyTypes2 = new SelectList(SurveyorDrop.surveyorTypes.ToList(), "Id", "Name", SurveyTypeId(surveyProfile[1].SurveyMethod));
            ViewBag.SurveyTypes3 = new SelectList(SurveyorDrop.surveyorTypes.ToList(), "Id", "Name", SurveyTypeId(surveyProfile[2].SurveyMethod));


            var model = new SurveyProfileEdit();

            model.SurveyId = data.surveyId;

            model.ProfileEditor1.Id        = surveyProfile[0].Id;
            model.ProfileEditor1.VESPoints = surveyProfile[0].VesPoint.ToString();
            model.ProfileEditor1.Northing  = surveyProfile[0].Northing;
            model.ProfileEditor1.Easting   = surveyProfile[0].Easting;
            model.ProfileEditor1.Elevation = surveyProfile[0].Elevation;
            //model.profileeditor1.surveymethod = surveyprofile[0].surveymethod;
            model.ProfileEditor1.Recommend = surveyProfile[0].Recommend;

            model.ProfileEditor1.SiteRecommendation = data.SiteRecommendation;


            model.ProfileEditor2.Id        = surveyProfile[1].Id;
            model.ProfileEditor2.VESPoints = surveyProfile[1].VesPoint.ToString();
            model.ProfileEditor2.Northing  = surveyProfile[1].Northing;
            model.ProfileEditor2.Easting   = surveyProfile[1].Easting;
            model.ProfileEditor2.Elevation = surveyProfile[1].Elevation;
            //model.profileeditor1.surveymethod = surveyprofile[0].surveymethod;
            model.ProfileEditor2.Recommend = surveyProfile[1].Recommend;

            model.ProfileEditor3.Id        = surveyProfile[2].Id;
            model.ProfileEditor3.VESPoints = surveyProfile[2].VesPoint.ToString();
            model.ProfileEditor3.Northing  = surveyProfile[2].Northing;
            model.ProfileEditor3.Easting   = surveyProfile[2].Easting;
            model.ProfileEditor3.Elevation = surveyProfile[2].Elevation;
            //model.profileeditor1.surveymethod = surveyprofile[0].surveymethod;
            model.ProfileEditor3.Recommend = surveyProfile[2].Recommend;

            SurveyWizard obj = GetSurvey();

            if (nextBtn != null)
            {
                ViewBag.VesPoints   = new SelectList(DropVs.VsPoints.ToList(), "Id", "Number");
                ViewBag.SurveyTypes = new SelectList(SurveyorDrop.surveyorTypes.ToList(), "Id", "Name");

                ViewBag.Village = data.Village;


                var client    = new Client();
                var geosurvey = new GeoSurvey();

                int regionClientId      = Convert.ToInt32(data.Client.Region);
                int regionGeosurveyId   = Convert.ToInt32(data.Region);
                int geosurveyDistrictId = Convert.ToInt32(data.District);
                int geosurveyStaffId    = Convert.ToInt32(data.SurveyorName);

                if (geosurveyStaffId == 0)
                {
                    geosurveyStaffId = 5;
                }

                client.Name    = data.Client.Name;
                client.Address = data.Client.Address;
                client.Region  = Regions.Where(x => x.Id == regionClientId).FirstOrDefault <Region>();
                client.Phone   = data.Client.Phone;
                client.Email   = data.Client.Email;

                geosurvey.Region     = Regions.Where(x => x.Id == regionGeosurveyId).FirstOrDefault <Region>();
                geosurvey.District   = Districts.Where(x => x.Id == geosurveyDistrictId).FirstOrDefault <District>();
                geosurvey.Village    = data.Village;
                geosurvey.SurveyType = data.SurveyorType;
                geosurvey.Cost       = data.Cost;
                geosurvey.Staff      = Staffs.Where(x => x.Id == geosurveyStaffId).FirstOrDefault <Staff>();
                geosurvey.StartDate  = data.StartDate;
                geosurvey.EndDate    = data.EndDate;

                obj.Client    = client;
                obj.GeoSurvey = geosurvey;

                return(PartialView("SurveyProfileEdit", model));
            }


            return(PartialView());
        }