예제 #1
0
        protected void FillViewBag(EXP_DrugDeclaration model)
        {
            var drugPrimaryRepo = new DrugPrimaryRepository();

            ViewData["ContractList"] =
                new SelectList(new ContractRepository(false).GetActiveContractListWithInfo(model.OwnerId), "Id",
                               "ContractInfo", model.ContractId);
            var repository = new ReadOnlyDictionaryRepository();

            ViewData["AccelerationTypeList"] = new SelectList(repository.GetAccelerationTypes(), "Id",
                                                              "NameRu", model.AccelerationTypeId);

            ViewData["TypeList"] = new SelectList(repository.GetDicTypes(), "Id",
                                                  "NameRu", model.TypeId);

            if (model.RegisterId > 0 && model.sr_register != null)
            {
                model.ReestrNumber  = model.sr_register.reg_number + "/" + model.sr_register.reg_number_kz;
                model.ReestrRegDate = model.sr_register.reg_date.ToShortDateString();
                if (model.sr_register.expiration_date != null)
                {
                    model.ReestrExpirationDate = model.sr_register.expiration_date.Value.ToShortDateString();
                }
                var reestrDrug = new ExternalRepository().GEtRegisterDrugById(model.RegisterId);
                if (reestrDrug != null)
                {
                    model.NumberNd = reestrDrug.nd_number;
                }
            }

            if (model.ExpDrugChangeTypes.Count == 0)
            {
                model.ExpDrugChangeTypes.Add(new EXP_DrugChangeType());
            }
            if (model.ExpDrugProtectionDocs.Count == 0)
            {
                model.ExpDrugProtectionDocs.Add(new EXP_DrugProtectionDoc());
            }
            if (model.ExpDrugOtherCountries.Count == 0)
            {
                model.ExpDrugOtherCountries.Add(new EXP_DrugOtherCountry());
            }
            if (model.ExpDrugExportTrades.Count == 0)
            {
                model.ExpDrugExportTrades.Add(new EXP_DrugExportTrade());
            }
            if (model.ExpDrugPatents.Count == 0)
            {
                model.ExpDrugPatents.Add(new EXP_DrugPatent());
            }
            if (model.ExpDrugTypes.Count == 0)
            {
                model.ExpDrugTypes.Add(new EXP_DrugType());
            }

            /*  if (model.ExpDrugWrappings.Count == 0)
             * {
             *    model.ExpDrugWrappings.Add(new EXP_DrugWrapping());
             * }*/

            if (model.ExpDrugOrganizationses.Count == 0)
            {
                model.ExpDrugOrganizationses.Add(new EXP_DrugOrganizations());
            }
            if (model.ExpDrugDosages.Count == 0)
            {
                model.ExpDrugDosages.Add(new EXP_DrugDosage());
            }

            /*if (model.ExpDrugPrices.Count == 0)
             * {
             *  model.ExpDrugPrices.Add(new EXP_DrugPrice());
             * }*/
            var externalRepository = new ExternalRepository();
            var countries          = externalRepository.GetCounties().ToArray();

            ViewData["Counties"] = new SelectList(countries, "Id", "name", 0);
            for (var i = 0; i < model.ExpDrugExportTrades.Count; i++)
            {
                ViewData["Counties" + i] = new SelectList(countries, "Id", "name",
                                                          model.ExpDrugExportTrades[i].CountryId);
            }

            var types     = repository.GetDrugType().ToArray();
            var typeKinds = repository.GetDrugTypeKinds().ToArray();

            ViewData["DrugTypes"]     = new SelectList(types, "Id", "NameRu", 0);
            ViewData["DrugTypeKinds"] = new SelectList(typeKinds, "Id", "NameRu", 0);
            for (var i = 0; i < model.ExpDrugTypes.Count; i++)
            {
                ViewData["DrugTypes" + i]     = new SelectList(types, "Id", "NameRu", model.ExpDrugTypes[i].DrugTypeId);
                ViewData["DrugTypeKinds" + i] = new SelectList(typeKinds, "Id", "NameRu",
                                                               model.ExpDrugTypes[i].DrugTypeKind);
            }

            model.AtcCodeses = externalRepository.GetAtcList();

            var methods = externalRepository.GetUseMethods();

            model.MethodUseList = new MultiSelectList(methods, "id", "name", model.MethodUseIds);

            /*  ViewData["SaleTypeList"] = new SelectList(repository.GetSaleType(), "Id",
             *    "NameRu", model.SaleTypeId);*/

            var measures = externalRepository.GetMeasures();

            ViewData["MeasureList"] = new SelectList(measures, "Id",
                                                     "name", null);
            var wrappingTypes = repository.GetWrappingTypes().ToArray();
            var boxes         = externalRepository.GetBoxes().ToArray();

            ViewData["WrappingTypes"]     = new SelectList(wrappingTypes, "Id", "NameRu", 0);
            ViewData["Boxes"]             = new SelectList(boxes, "id", "name", 0);
            ViewData["MeasureShortList"]  = new SelectList(measures, "id", "short_name", 0);
            ViewData["SizeMeasureList"]   = new SelectList(measures, "id", "short_name", 0);
            ViewData["VolumeMeasureList"] = new SelectList(measures, "id", "short_name", 0);

            var booleans = repository.GetBooleanList();

            ViewData["Booleans"] = new SelectList(booleans, "IsSign", "NameRu", false);

            var origins        = repository.GetOrigins().ToArray();
            var plantKinds     = repository.GetPlantKinds().ToArray();
            var normDocs       = repository.GetExpDicNormDocFarms().ToArray();
            var substanceTypes = externalRepository.GetSubstanceTypes().ToArray();

            ViewData["SubstanceTypes"]       = new SelectList(substanceTypes, "Id", "name", null);
            ViewData["Origins"]              = new SelectList(origins, "Id", "NameRu", null);
            ViewData["NormDocs"]             = new SelectList(normDocs, "Id", "NameRu", null);
            ViewData["PlantKinds"]           = new SelectList(plantKinds, "Id", "NameRu", null);
            ViewData["IsControlList"]        = new SelectList(booleans, "IsSign", "NameRu", null);
            ViewData["IsPoisonList"]         = new SelectList(booleans, "IsSign", "NameRu", null);
            ViewData["SubstanceCounties"]    = new SelectList(countries, "Id", "name", 0);
            ViewData["SubstanceMeasureList"] = new SelectList(measures, "id", "short_name", 0);
            var sales = repository.GetSaleType().ToList();

            ViewData["SaleTypeList"] = new SelectList(sales, "Id", "NameRu", null);
            ViewData["BestBeforeMeasureTypeList"] = new SelectList(measures, "id", "short_name",
                                                                   null);
            ViewData["AppPeriodMixMeasureList"] = new SelectList(measures, "id", "short_name",
                                                                 null);
            ViewData["AppPeriodOpenMeasureList"] = new SelectList(measures, "id", "short_name",
                                                                  null);



            var drugDeclarationRepository = new DrugDeclarationRepository();

            for (var i = 0; i < model.ExpDrugDosages.Count; i++)
            {
                var dosage = model.ExpDrugDosages[i];
                if (dosage.ExpDrugWrappings == null || dosage.ExpDrugWrappings.Count == 0)
                {
                    dosage.ExpDrugWrappings = new List <EXP_DrugWrapping> {
                        new EXP_DrugWrapping()
                    };
                }
                if (dosage.ExpDrugSubstances == null || dosage.ExpDrugSubstances.Count == 0)
                {
                    dosage.ExpDrugSubstances = new List <EXP_DrugSubstance> {
                        new EXP_DrugSubstance()
                        {
                            ExpDrugSubstanceManufactures = new List <EXP_DrugSubstanceManufacture>()
                            {
                                new EXP_DrugSubstanceManufacture()
                            }
                        }
                    };
                }
                if (dosage.ExpDrugPrices == null)
                {
                    dosage.ExpDrugPrices = new List <EXP_DrugPrice>();
                }

                ViewData["MeasureList" + dosage.Id] = new SelectList(measures, "Id", "name",
                                                                     model.ExpDrugDosages[i].DosageMeasureTypeId);
                ViewData["SaleTypeList" + dosage.Id] = new SelectList(sales, "Id", "NameRu", model.ExpDrugDosages[i].SaleTypeId);
                ViewData["BestBeforeMeasureTypeList" + dosage.Id] = new SelectList(measures, "id", "short_name",
                                                                                   model.ExpDrugDosages[i].BestBeforeMeasureTypeDicId);
                ViewData["AppPeriodMixMeasureList" + dosage.Id] = new SelectList(measures, "id", "short_name",
                                                                                 model.ExpDrugDosages[i].AppPeriodMixMeasureDicId);
                ViewData["AppPeriodOpenMeasureList" + dosage.Id] = new SelectList(measures, "id", "short_name",
                                                                                  model.ExpDrugDosages[i].AppPeriodOpenMeasureDicId);
                for (var j = 0; j < dosage.ExpDrugWrappings.Count; j++)
                {
                    var wrap = dosage.ExpDrugWrappings[j];
                    ViewData["WrappingTypes" + wrap.Id] = new SelectList(wrappingTypes, "Id", "NameRu",
                                                                         wrap.WrappingTypeId);
                    ViewData["Boxes" + wrap.Id]           = new SelectList(boxes, "Id", "name", wrap.WrappingKindId);
                    ViewData["SizeMeasureList" + wrap.Id] = new SelectList(measures, "Id", "short_name",
                                                                           wrap.SizeMeasureId);
                    ViewData["VolumeMeasureList" + wrap.Id] = new SelectList(measures, "Id", "short_name",
                                                                             wrap.VolumeMeasureId);
                }

                for (var j = 0; j < dosage.ExpDrugPrices.Count; j++)
                {
                    var price = dosage.ExpDrugPrices[j];
                    model.ExpDrugDosages[i].ExpDrugPrices[j].PrimaryText      = drugDeclarationRepository.GetNameByWrappingNames(price.PrimaryValue);
                    model.ExpDrugDosages[i].ExpDrugPrices[j].SecondaryText    = drugDeclarationRepository.GetNameByWrappingNames(price.SecondaryValue);
                    model.ExpDrugDosages[i].ExpDrugPrices[j].IntermediateText = drugDeclarationRepository.GetNameByWrappingNames(price.IntermediateValue);
                }

                for (var j = 0; j < dosage.ExpDrugSubstances.Count; j++)
                {
                    var id = dosage.ExpDrugSubstances[j].Id.ToString();
                    dosage.ExpDrugSubstances[j].CategoryName = GetCategoryName(dosage.ExpDrugSubstances[j].sr_substances);
                    dosage.ExpDrugSubstances[j].CategoryPos  = dosage.ExpDrugSubstances[j].sr_substances?.category_pos;
                    ViewData["SubstanceTypes" + id]          = new SelectList(substanceTypes, "Id", "name",
                                                                              dosage.ExpDrugSubstances[j].SubstanceTypeId);
                    ViewData["Origins" + id]    = new SelectList(origins, "Id", "NameRu", dosage.ExpDrugSubstances[j].OriginId);
                    ViewData["NormDocs" + id]   = new SelectList(normDocs, "Id", "NameRu", dosage.ExpDrugSubstances[j].NormDocFarmId);
                    ViewData["PlantKinds" + id] = new SelectList(plantKinds, "Id", "NameRu",
                                                                 dosage.ExpDrugSubstances[j].PlantKindId);
                    ViewData["SubstanceMeasureList" + id] = new SelectList(measures, "Id", "short_name",
                                                                           dosage.ExpDrugSubstances[j].MeasureId);

                    /*          ViewData["SubstanceCounties" + id] = new SelectList(countries, "Id", "name",
                     *            dosage.ExpDrugSubstances[j].CountryId);*/
                    ViewData["IsControlList" + id] = new SelectList(booleans, "IsSign", "NameRu",
                                                                    dosage.ExpDrugSubstances[j].IsControl);
                    ViewData["IsPoisonList" + id] = new SelectList(booleans, "IsSign", "NameRu",
                                                                   dosage.ExpDrugSubstances[j].IsPoison);

                    /*  ViewData["SubstanceCounties" + i] = new SelectList(countries, "Id", "name",
                     *    dosage.ExpDrugSubstances[j].CountryId);*/
                    if (dosage.ExpDrugSubstances[j].ExpDrugSubstanceManufactures != null)
                    {
                        for (var k = 0; k < dosage.ExpDrugSubstances[j].ExpDrugSubstanceManufactures.Count; k++)
                        {
                            ViewData[
                                "SubstanceCounties" + dosage.ExpDrugSubstances[j].ExpDrugSubstanceManufactures[k].Id
                            ] =
                                new SelectList(countries, "Id", "name",
                                               dosage.ExpDrugSubstances[j].ExpDrugSubstanceManufactures[k].CountryId);
                        }
                    }
                    else
                    {
                        dosage.ExpDrugSubstances[j].ExpDrugSubstanceManufactures =
                            new List <EXP_DrugSubstanceManufacture> {
                            new EXP_DrugSubstanceManufacture()
                        };
                    }
                }
            }



            ViewData["IsGrlsList"] = new SelectList(booleans, "IsSign", "NameRu", model.IsGrls);
            ViewData["IsGmpList"]  = new SelectList(booleans, "IsSign", "NameRu", model.IsGmp);

            var manufactures = repository.GetManufactureTypeList();

            ViewData["ManufactureTypeList"] = new SelectList(manufactures, "Id", "NameRu", model.ManufactureTypeId);

            /*    ViewData["BestBeforeMeasureTypeList"] = new SelectList(measures, "id", "short_name",
             *      model.BestBeforeMeasureTypeDicId);
             *  ViewData["AppPeriodMixMeasureList"] = new SelectList(measures, "id", "short_name",
             *      model.AppPeriodMixMeasureDicId);
             *  ViewData["AppPeriodOpenMeasureList"] = new SelectList(measures, "id", "short_name",
             *      model.AppPeriodOpenMeasureDicId);
             */
            for (var i = 0; i < model.ExpDrugOtherCountries.Count; i++)
            {
                ViewData["OtherCounties" + i] = new SelectList(countries, "Id", "name",
                                                               model.ExpDrugOtherCountries[i].CountryId);
            }

            var orgManufactureTypes = repository.GetDictionaries(CodeConstManager.DIC_ORG_MANUFACTURE_TYPE);
            var countyDics          = repository.GetDictionaries(CodeConstManager.DIC_COUNTRY_TYPE);
            var opfTypeDics         = repository.GetDictionaries(CodeConstManager.DIC_OPF_TYPE);

            ViewData["OrgManufactureTypes"] = new SelectList(orgManufactureTypes, "Id", "Name", null);
            ViewData["CountryDics"]         = new SelectList(countyDics, "Id", "Name", null);
            ViewData["OpfTypeDics"]         = new SelectList(opfTypeDics, "Id", "Name", null);

            for (var i = 0; i < model.ExpDrugOrganizationses.Count; i++)
            {
                var id = model.ExpDrugOrganizationses[i].Id.ToString();
                ViewData["OrgManufactureTypes" + id] = new SelectList(orgManufactureTypes, "Id", "name",
                                                                      model.ExpDrugOrganizationses[i].OrgManufactureTypeDicId);
                ViewData["CountryDics" + id] = new SelectList(countyDics, "Id", "name",
                                                              model.ExpDrugOrganizationses[i].CountryDicId);
                ViewData["OpfTypeDics" + id] = new SelectList(opfTypeDics, "Id", "name",
                                                              model.ExpDrugOrganizationses[i].OpfTypeDicId);
                var manufacture = repository.GetDictionaryById(CodeConstManager.DIC_ORG_MANUFACTURE_TYPE,
                                                               model.ExpDrugOrganizationses[i].OrgManufactureTypeDicId);
                if (manufacture != null)
                {
                    model.ExpDrugOrganizationses[i].ManufactureName = manufacture.Name;
                }
            }
            var changeTypes = repository.GetDicChangeTypes().ToArray();

            ViewData["ChangeTypes"] = new SelectList(changeTypes, "Id", "Code", 0);
            for (var i = 0; i < model.ExpDrugChangeTypes.Count; i++)
            {
                ViewData["ChangeTypes" + i] = new SelectList(changeTypes, "Id", "Code",
                                                             model.ExpDrugChangeTypes[i].ChangeTypeId);
            }

            var markList = drugPrimaryRepo.GetPrimaryMarkList(model.Id, null);

            var remarkTypes = repository.GetRemarkTypes().ToArray();

            ViewData["RemarkTypes" + model.Id] = new SelectList(remarkTypes, "Id", "NameRu",
                                                                null);
            model.ExpExpertiseStageRemarks = new List <EXP_ExpertiseStageRemark>();
            foreach (var expDrugPrimaryRemark in markList)
            {
                model.ExpExpertiseStageRemarks.Add(expDrugPrimaryRemark);
            }

            if (model.ExpExpertiseStageRemarks.Count == 0)
            {
                model.ExpExpertiseStageRemarks.Add(new EXP_ExpertiseStageRemark());
            }
            else
            {
                model.IsShowRemark = true;
            }

            foreach (var expDrugPrimaryRemark in model.ExpExpertiseStageRemarks)
            {
                ViewData["RemarkTypes" + model.Id + "_" + expDrugPrimaryRemark.Id] = new SelectList(remarkTypes,
                                                                                                    "Id", "NameRu",
                                                                                                    expDrugPrimaryRemark.RemarkTypeId);
            }
            ViewBag.PaymentOverdue = model.EXP_DirectionToPays.Any(e => e.Type == 1 &&
                                                                   e.Status.Code == Dictionary.ExpDirectionToPayStatus.PaymentExpired);
            model.Letters = new List <EXP_DrugCorespondence>(drugPrimaryRepo.GetDrugCorespondences(model.Id, true));
        }