Esempio n. 1
0
        public PartialViewResult _LabSheetsTranferred(int SamplingPlanID)
        {
            ViewBag.SamplingPlanController      = _SamplingPlanController;
            ViewBag.AdminContactModelList       = null;
            ViewBag.IsSamplingPlanner           = false;
            ViewBag.LabSheetModelAndA1SheetList = null;
            ViewBag.LastAnalyzeMethod           = AnalyzeMethodEnum.Error;
            ViewBag.LastSampleMatrix            = SampleMatrixEnum.Error;
            ViewBag.LastLaboratory                  = LaboratoryEnum.Error;
            ViewBag.MWQMSampleModelList             = new List <MWQMSampleModel>();
            ViewBag.SubsectorMWQMSiteModelList      = new List <SubsectorMWQMSiteModel>();
            ViewBag.SamplingPlanModel               = null;
            ViewBag.LabSheetSiteMonitoredCountsList = null;

            List <LabSheetModelAndA1Sheet> labSheetModelAndA1SheetList = new List <LabSheetModelAndA1Sheet>();

            SamplingPlanService SamplingPlanService = new SamplingPlanService(_TVItemService.LanguageRequest, _TVItemService.User);
            LabSheetService     labSheetService     = new LabSheetService(_TVItemService.LanguageRequest, _TVItemService.User);
            MWQMRunService      mwqmRunService      = new MWQMRunService(_TVItemService.LanguageRequest, _TVItemService.User);
            MWQMSampleService   mwqmSampleService   = new MWQMSampleService(_TVItemService.LanguageRequest, _TVItemService.User);
            MWQMSiteService     mwqmSiteService     = new MWQMSiteService(_TVItemService.LanguageRequest, _TVItemService.User);

            ContactModel contactModel = _ContactService.GetContactLoggedInDB();

            SamplingPlanModel SamplingPlanModel = SamplingPlanService.GetSamplingPlanModelWithSamplingPlanIDDB(SamplingPlanID);

            if (string.IsNullOrWhiteSpace(SamplingPlanModel.Error))
            {
                ViewBag.SamplingPlanModel = SamplingPlanModel;

                ViewBag.IsSamplingPlanner = false;
                if (contactModel.SamplingPlanner_ProvincesTVItemID.Contains(SamplingPlanModel.ProvinceTVItemID.ToString()))
                {
                    ViewBag.IsSamplingPlanner = true;
                }
                else
                {
                    List <ContactModel> adminContactModelList = _ContactService.GetAdminContactModelListDB();
                    ViewBag.AdminContactModelList = adminContactModelList;
                }

                List <LabSheetModel> labSheetModelList = labSheetService.GetLabSheetModelListWithSamplingPlanIDAndLabSheetStatusDB(SamplingPlanID, LabSheetStatusEnum.Transferred);
                foreach (LabSheetModel labSheetModel in labSheetModelList)
                {
                    LabSheetModelAndA1Sheet labSheetModelAndA1Sheet = new LabSheetModelAndA1Sheet();
                    labSheetModelAndA1Sheet.LabSheetModel   = labSheetModel;
                    labSheetModelAndA1Sheet.LabSheetA1Sheet = labSheetService.ParseLabSheetA1WithLabSheetID(labSheetModel.LabSheetID);
                    labSheetModelAndA1SheetList.Add(labSheetModelAndA1Sheet);
                }
                ViewBag.LabSheetModelAndA1SheetList = labSheetModelAndA1SheetList;

                if (labSheetModelAndA1SheetList.Count > 0)
                {
                    MWQMRunModel mwqmRunModelLast = mwqmRunService.GetMWQMRunModelLastWithSubsectorTVItemIDDB(labSheetModelAndA1SheetList[0].LabSheetModel.SubsectorTVItemID);
                    if (string.IsNullOrWhiteSpace(mwqmRunModelLast.Error))
                    {
                        if (mwqmRunModelLast.AnalyzeMethod != null)
                        {
                            ViewBag.LastAnalyzeMethod = (AnalyzeMethodEnum)mwqmRunModelLast.AnalyzeMethod;
                        }
                        if (mwqmRunModelLast.SampleMatrix != null)
                        {
                            ViewBag.LastSampleMatrix = (SampleMatrixEnum)mwqmRunModelLast.SampleMatrix;
                        }
                        if (mwqmRunModelLast.Laboratory != null)
                        {
                            ViewBag.LastLaboratory = (LaboratoryEnum)mwqmRunModelLast.Laboratory;
                        }
                    }
                }

                List <MWQMSampleModel> mwqmSampleModelList = new List <MWQMSampleModel>();
                foreach (LabSheetModelAndA1Sheet labSheetModelAndA1Sheet in labSheetModelAndA1SheetList)
                {
                    int Year  = 0;
                    int Month = 0;
                    int Day   = 0;
                    if (int.TryParse(labSheetModelAndA1Sheet.LabSheetA1Sheet.RunYear, out Year))
                    {
                        if (int.TryParse(labSheetModelAndA1Sheet.LabSheetA1Sheet.RunMonth, out Month))
                        {
                            if (int.TryParse(labSheetModelAndA1Sheet.LabSheetA1Sheet.RunDay, out Day))
                            {
                                MWQMRunModel mwqmRunModelNew = new MWQMRunModel()
                                {
                                    SubsectorTVItemID = labSheetModelAndA1Sheet.LabSheetA1Sheet.SubsectorTVItemID,
                                    DateTime_Local    = new DateTime(Year, Month, Day),
                                    RunSampleType     = labSheetModelAndA1Sheet.LabSheetA1Sheet.SampleType,
                                    RunNumber         = labSheetModelList[0].RunNumber,
                                };

                                MWQMRunModel mwqmRunModel = mwqmRunService.GetMWQMRunModelExistDB(mwqmRunModelNew);
                                if (string.IsNullOrWhiteSpace(mwqmRunModel.Error))
                                {
                                    List <MWQMSampleModel> mwqmSampleModelList2 = mwqmSampleService.GetMWQMSampleModelListWithMWQMRunTVItemIDDB(mwqmRunModel.MWQMRunTVItemID);
                                    foreach (MWQMSampleModel mwqmSampleModel in mwqmSampleModelList2)
                                    {
                                        mwqmSampleModelList.Add(mwqmSampleModel);
                                    }
                                }
                            }
                        }
                    }
                }
                ViewBag.MWQMSampleModelList = mwqmSampleModelList;


                if (labSheetModelAndA1SheetList.Count > 0)
                {
                    List <SubsectorMWQMSiteModel> subsectorMWQMSiteModelList = new List <SubsectorMWQMSiteModel>();

                    foreach (LabSheetModelAndA1Sheet labSheetModelAndA1Sheet in labSheetModelAndA1SheetList)
                    {
                        List <MWQMSiteModel> mwqmSiteModelList = mwqmSiteService.GetMWQMSiteModelListWithSubsectorTVItemIDDB(labSheetModelAndA1Sheet.LabSheetA1Sheet.SubsectorTVItemID);
                        subsectorMWQMSiteModelList.Add(new SubsectorMWQMSiteModel()
                        {
                            Subsector = labSheetModelAndA1Sheet.LabSheetA1Sheet.SubsectorName, MWQMSiteModelList = mwqmSiteModelList
                        });
                    }

                    ViewBag.SubsectorMWQMSiteModelList = subsectorMWQMSiteModelList;
                }

                List <LabSheetSiteMonitoredCounts> labSheetSiteMonitoredCountsList = labSheetService.GetLabSheetIDListAndCountSamplesWithSamplingPlanIDDB(SamplingPlanID);
                ViewBag.LabSheetSiteMonitoredCountsList = labSheetSiteMonitoredCountsList;
            }

            return(PartialView());
        }
Esempio n. 2
0
        public PartialViewResult _LabSheetsHistoryDetail(int SamplingPlanID, int LabSheetID)
        {
            ViewBag.SamplingPlanController  = _SamplingPlanController;
            ViewBag.AdminContactModelList   = null;
            ViewBag.IsSamplingPlanner       = false;
            ViewBag.LabSheetModelAndA1Sheet = null;
            ViewBag.AnalyzeMethod           = AnalyzeMethodEnum.Error;
            ViewBag.SampleMatrix            = SampleMatrixEnum.Error;
            ViewBag.Laboratory        = LaboratoryEnum.Error;
            ViewBag.MWQMSiteModelList = new List <MWQMSiteModel>();

            SamplingPlanService SamplingPlanService = new SamplingPlanService(_TVItemService.LanguageRequest, _TVItemService.User);
            LabSheetService     labSheetService     = new LabSheetService(_TVItemService.LanguageRequest, _TVItemService.User);
            MWQMRunService      mwqmRunService      = new MWQMRunService(_TVItemService.LanguageRequest, _TVItemService.User);
            MWQMSiteService     mwqmSiteService     = new MWQMSiteService(_TVItemService.LanguageRequest, _TVItemService.User);

            ContactModel contactModel = _ContactService.GetContactLoggedInDB();


            SamplingPlanModel SamplingPlanModel = SamplingPlanService.GetSamplingPlanModelWithSamplingPlanIDDB(SamplingPlanID);

            if (string.IsNullOrWhiteSpace(SamplingPlanModel.Error))
            {
                ViewBag.IsSamplingPlanner = false;
                if (contactModel.SamplingPlanner_ProvincesTVItemID.Contains(SamplingPlanModel.ProvinceTVItemID.ToString()))
                {
                    ViewBag.IsSamplingPlanner = true;
                }
                else
                {
                    List <ContactModel> adminContactModelList = _ContactService.GetAdminContactModelListDB();
                    ViewBag.AdminContactModelList = adminContactModelList;
                }

                LabSheetModel           labSheetModel           = labSheetService.GetLabSheetModelWithLabSheetIDDB(LabSheetID);
                LabSheetModelAndA1Sheet labSheetModelAndA1Sheet = new LabSheetModelAndA1Sheet();
                labSheetModelAndA1Sheet.LabSheetModel   = labSheetModel;
                labSheetModelAndA1Sheet.LabSheetA1Sheet = labSheetService.ParseLabSheetA1WithLabSheetID(labSheetModel.LabSheetID);
                ViewBag.LabSheetModelAndA1Sheet         = labSheetModelAndA1Sheet;

                if (labSheetModel.MWQMRunTVItemID != null)
                {
                    MWQMRunModel mwqmRunModel = mwqmRunService.GetMWQMRunModelWithMWQMRunTVItemIDDB((int)labSheetModel.MWQMRunTVItemID);
                    if (string.IsNullOrWhiteSpace(mwqmRunModel.Error))
                    {
                        if (mwqmRunModel.AnalyzeMethod != null)
                        {
                            ViewBag.AnalyzeMethod = (AnalyzeMethodEnum)mwqmRunModel.AnalyzeMethod;
                        }
                        if (mwqmRunModel.SampleMatrix != null)
                        {
                            ViewBag.SampleMatrix = (SampleMatrixEnum)mwqmRunModel.SampleMatrix;
                        }
                        if (mwqmRunModel.Laboratory != null)
                        {
                            ViewBag.Laboratory = (LaboratoryEnum)mwqmRunModel.Laboratory;
                        }
                    }
                }

                List <MWQMSiteModel> mwqmSiteModelList = mwqmSiteService.GetMWQMSiteModelListWithSubsectorTVItemIDDB(labSheetModelAndA1Sheet.LabSheetA1Sheet.SubsectorTVItemID);

                ViewBag.MWQMSiteModelList = mwqmSiteModelList;
            }

            return(PartialView());
        }