示例#1
0
        public OBKContractProductViewModel SaveProduct(Guid contractId, OBKContractProductViewModel product)
        {
            var r = new OBKContractProductViewModel();

            r.ProductId = product.ProductId;
            if (product.Id != null)
            {
                OBK_RS_Products productInfo = AppContext.OBK_RS_Products.Where(x => x.Id == product.Id).FirstOrDefault();
                FillProduct(productInfo, product);
                AppContext.SaveChanges();

                DeleteSeries(productInfo.Id);
                SaveSeries(productInfo.Id, product.Series);

                DeleteMtParts(productInfo.Id);
                SaveMtParts(productInfo.Id, product.MtParts);

                r.Id = productInfo.Id;
            }
            else
            {
                OBK_RS_Products productInfo = new OBK_RS_Products();
                productInfo.ContractId = contractId;
                FillProduct(productInfo, product);
                AppContext.OBK_RS_Products.Add(productInfo);
                AppContext.SaveChanges();

                SaveSeries(productInfo.Id, product.Series);
                SaveMtParts(productInfo.Id, product.MtParts);

                r.Id = productInfo.Id;
            }
            return(r);
        }
示例#2
0
 private void FillProduct(OBK_RS_Products productInfo, OBKContractProductViewModel product)
 {
     productInfo.RegTypeId          = product.RegTypeId;
     productInfo.DegreeRiskId       = product.DegreeRiskId;
     productInfo.NameRu             = product.NameRu;
     productInfo.NameKz             = product.NameKz;
     productInfo.ProducerNameRu     = product.ProducerNameRu;
     productInfo.ProducerNameKz     = product.ProducerNameKz;
     productInfo.CountryNameRu      = product.CountryNameRu;
     productInfo.CountryNameKZ      = product.CountryNameKz;
     productInfo.KpvedCode          = product.KpvedCode;
     productInfo.TnvedCode          = product.TnvedCode;
     productInfo.Price              = product.Price;
     productInfo.DrugFormBoxCount   = product.DrugFormBoxCount;
     productInfo.DrugFormFullName   = product.DrugFormFullName;
     productInfo.DrugFormFullNameKz = product.DrugFormFullNameKz;
 }
        private SubUpdateField UpdateProduct(OBK_AssessmentDeclaration model, long?recordId, string fieldName,
                                             string fieldValue, string userId, string fieldDisplay)
        {
            OBK_RS_Products entity = null;

            if (recordId > 0)
            {
                entity = AppContext.Set <OBK_RS_Products>().FirstOrDefault(e => e.Id == recordId);
            }

            var property = entity.GetType().GetProperty(fieldName);

            if (property != null)
            {
                var t = Nullable.GetUnderlyingType(property.PropertyType) ?? property.PropertyType;

                object safeValue;
                if (string.IsNullOrEmpty(fieldValue))
                {
                    fieldValue = null;
                }
                if (t == typeof(Guid))
                {
                    safeValue = fieldValue == null ? null : Convert.ChangeType(new Guid(fieldValue), t);
                }
                else
                {
                    safeValue = fieldValue == null ? null : Convert.ChangeType(fieldValue, t);
                }
                property.SetValue(entity, safeValue, null);
            }
            if (entity.Id == 0)
            {
                AppContext.OBK_RS_Products.Add(entity);
            }
            AppContext.SaveChanges();

            SaveHistoryField(model.Id, fieldName, fieldValue, new Guid(userId), fieldDisplay);

            var subUpdateField = new SubUpdateField();

            subUpdateField.ModelId  = model.ObjectId;
            subUpdateField.RecordId = entity.Id;

            return(subUpdateField);
        }
示例#4
0
        public virtual ActionResult GetContract(Guid id)
        {
            var contract = new SafetyAssessmentRepository().GetContractById(id);

            if (contract == null)
            {
                return(Json(new { isSuccess = false }));
            }
            var products = new SafetyAssessmentRepository().GetRsProductsAndSeries(contract.Id);

            var result = new OBK_AssessmentDeclaration();

            var resultProducts = new List <OBK_RS_Products>();

            foreach (var product in products)
            {
                var prod = new OBK_RS_Products();
                prod.Id                 = product.Id;
                prod.NameRu             = product.NameRu;
                prod.NameKz             = product.NameKz;
                prod.ProducerNameRu     = product.ProducerNameRu;
                prod.ProducerNameKz     = product.ProducerNameKz;
                prod.CountryNameRu      = product.CountryNameRu;
                prod.CountryNameKZ      = product.CountryNameKZ;
                prod.DrugFormFullName   = product.DrugFormFullName;
                prod.DrugFormFullNameKz = product.DrugFormFullNameKz;
                prod.DrugFormBoxCount   = product.DrugFormBoxCount;
                //prod.TnvedCode = product.TnvedCode;
                //prod.KpvedCode = product.KpvedCode;
                prod.CurrencyId     = product.CurrencyId;
                prod.Price          = product.Price;
                prod.RegTypeId      = product.RegTypeId;
                prod.RegNumber      = product.RegNumber;
                prod.RegisterId     = product.RegisterId;
                prod.RegNumberKz    = product.RegNumberKz;
                prod.RegDate        = product.RegDate;
                prod.ExpirationDate = product.ExpirationDate;
                prod.NdName         = product.NdName;
                prod.NdNumber       = product.NdNumber;
                prod.Dimension      = product.Dimension;
                prod.ExpertisePlace = product.ExpertisePlace;
                foreach (var productSeries in product.OBK_Procunts_Series)
                {
                    var prodSeries = new OBK_Procunts_Series();
                    prodSeries.Id                = productSeries.Id;
                    prodSeries.Series            = productSeries.Series;
                    prodSeries.SeriesStartdate   = productSeries.SeriesStartdate;
                    prodSeries.SeriesEndDate     = productSeries.SeriesEndDate;
                    prodSeries.SeriesParty       = productSeries.SeriesParty;
                    prodSeries.SeriesShortNameRu = productSeries.sr_measures.short_name;
                    var obkStageExpDocumentSeries = new SafetyAssessmentRepository().GetStageExpDocument(prodSeries.Id);
                    if (obkStageExpDocumentSeries != null)
                    {
                        prodSeries.ExpId           = obkStageExpDocumentSeries.Id;
                        prodSeries.ProductSeriesId = obkStageExpDocumentSeries.ProductSeriesId;
                        prodSeries.ExpResult       = obkStageExpDocumentSeries.ExpResult ? "True" : "False";
                        prodSeries.ExpResultTitle  = obkStageExpDocumentSeries.ExpResult
                            ? "Соответствует требованиям"
                            : "Не соответствует требованиям";
                        prodSeries.ExpStartDate         = string.Format("{0:dd.MM.yyyy}", obkStageExpDocumentSeries.ExpStartDate);
                        prodSeries.ExpEndDate           = string.Format("{0:dd.MM.yyyy}", obkStageExpDocumentSeries.ExpEndDate);
                        prodSeries.ExpReasonNameRu      = obkStageExpDocumentSeries.ExpReasonNameRu;
                        prodSeries.ExpReasonNameKz      = obkStageExpDocumentSeries.ExpReasonNameKz;
                        prodSeries.ExpProductNameRu     = obkStageExpDocumentSeries.ExpProductNameRu;
                        prodSeries.ExpProductNameKz     = obkStageExpDocumentSeries.ExpProductNameKz;
                        prodSeries.ExpNomenclatureRu    = obkStageExpDocumentSeries.ExpNomenclatureRu;
                        prodSeries.ExpNomenclatureKz    = obkStageExpDocumentSeries.ExpNomenclatureKz;
                        prodSeries.ExpAddInfoRu         = obkStageExpDocumentSeries.ExpAddInfoRu;
                        prodSeries.ExpAddInfoKz         = obkStageExpDocumentSeries.ExpAddInfoKz;
                        prodSeries.ExpConclusionNumber  = obkStageExpDocumentSeries.ExpConclusionNumber;
                        prodSeries.ExpBlankNumber       = obkStageExpDocumentSeries.ExpBlankNumber;
                        prodSeries.ExpApplication       = obkStageExpDocumentSeries.ExpApplication;
                        prodSeries.ExpApplicationNumber = obkStageExpDocumentSeries.ExpApplicationNumber;
                    }
                    prod.OBK_Procunts_Series.Add(prodSeries);
                }
                foreach (var mtPart in product.OBK_MtPart)
                {
                    var mtParts = new OBK_MtPart();
                    mtParts.PartNumber    = mtPart.PartNumber;
                    mtParts.Model         = mtPart.Model;
                    mtParts.Specification = mtPart.Specification;
                    mtParts.ProducerName  = mtPart.ProducerName;
                    mtParts.CountryName   = mtPart.CountryName;
                    mtParts.Name          = mtPart.Name;
                    prod.OBK_MtPart.Add(mtParts);
                }
                resultProducts.Add(prod);
            }
            result.ObkRsProductses = resultProducts;
            return(Json(new { isSuccess = true, result }));
        }
示例#5
0
        public virtual ActionResult GetContract(Guid id)
        {
            var contract = new SafetyAssessmentRepository().GetContractById(id);

            if (contract == null)
            {
                return(Json(new { isSuccess = false }));
            }

            var declarant        = new SafetyAssessmentRepository().GetDeclarantById(contract.DeclarantId);
            var declarantContact = new SafetyAssessmentRepository().GetDeclarantContactById(contract.DeclarantContactId);
            var products         = new SafetyAssessmentRepository().GetRsProductsAndSeries(contract.Id);

            var result = new OBK_AssessmentDeclaration();

            result.StartDate          = string.Format("{0:dd.MM.yyyy}", contract.StartDate);
            result.EndDate            = string.Format("{0:dd.MM.yyyy}", contract.EndDate);
            result.OrganizationFormId = declarant?.OrganizationFormId ?? null;
            result.NameKz             = declarant?.NameKz ?? "нет данных";
            result.NameRu             = declarant?.NameRu ?? "нет данных";
            result.NameEn             = declarant?.NameEn ?? "нет данных";
            result.ChiefLastName      = declarantContact?.BossLastName ?? "нет данных";
            result.ChiefFirstName     = declarantContact?.BossFirstName ?? "нет данных";
            result.ChiefMiddleName    = declarantContact?.BossMiddleName ?? "нет данных";
            result.ChiefPosition      = declarantContact?.BossPosition ?? "нет данных";
            result.AddressFact        = declarantContact?.AddressFact ?? "нет данных";
            result.AddressLegal       = declarantContact?.AddressLegalRu ?? "нет данных";
            result.Phone      = declarantContact?.Phone ?? "нет данных";
            result.Email      = declarantContact?.Email ?? "нет данных";
            result.BankBik    = declarantContact?.BankBik ?? "нет данных";
            result.BankIik    = declarantContact?.BankIik ?? "нет данных";
            result.BankName   = declarantContact?.BankNameRu ?? "нет данных";
            result.CountryId  = declarant?.CountryId ?? null;
            result.CurrencyId = declarantContact?.CurrencyId ?? null;

            var resultProducts = new List <OBK_RS_Products>();

            foreach (var product in products)
            {
                var prod = new OBK_RS_Products();
                prod.Id               = product.Id;
                prod.NameRu           = product.NameRu;
                prod.NameKz           = product.NameKz;
                prod.ProducerNameRu   = product.ProducerNameRu;
                prod.ProducerNameKz   = product.ProducerNameKz;
                prod.CountryNameRu    = product.CountryNameRu;
                prod.CountryNameKZ    = product.CountryNameKZ;
                prod.TnvedCode        = product.TnvedCode;
                prod.KpvedCode        = product.KpvedCode;
                prod.Price            = product.Price;
                prod.CurrencyId       = product.CurrencyId;
                prod.DrugFormBoxCount = product.DrugFormBoxCount;
                prod.DrugFormFullName = product.DrugFormFullName;
                prod.RegTypeId        = product.RegTypeId;
                foreach (var productSeries in product.OBK_Procunts_Series)
                {
                    var prodSeries = new OBK_Procunts_Series();
                    prodSeries.Id                = productSeries.Id;
                    prodSeries.Series            = productSeries.Series;
                    prodSeries.SeriesStartdate   = productSeries.SeriesStartdate;
                    prodSeries.SeriesEndDate     = productSeries.SeriesEndDate;
                    prodSeries.SeriesParty       = productSeries.SeriesParty;
                    prodSeries.SeriesShortNameRu = productSeries.sr_measures.short_name;
                    prod.OBK_Procunts_Series.Add(prodSeries);
                }
                foreach (var mtPart in product.OBK_MtPart)
                {
                    var mtParts = new OBK_MtPart();
                    mtParts.PartNumber    = mtPart.PartNumber;
                    mtParts.Model         = mtPart.Model;
                    mtParts.Specification = mtPart.Specification;
                    mtParts.ProducerName  = mtPart.ProducerName;
                    mtParts.CountryName   = mtPart.CountryName;
                    mtParts.Name          = mtPart.Name;
                    prod.OBK_MtPart.Add(mtParts);
                }
                resultProducts.Add(prod);
            }
            result.ObkRsProductses = resultProducts;
            return(Json(new { isSuccess = true, result }));
        }
示例#6
0
        private void FillDeclarationControl(OBK_AssessmentDeclaration model)
        {
            var safetyRepository = new SafetyAssessmentRepository();

            ViewData["ContractList"] =
                new SelectList(safetyRepository.GetActiveContractListWithInfo(model.EmployeeId, model.Type_Id), "Id",
                               "ContractInfo", model.Contract_Id);

            if (model.Type_Id == int.Parse(CodeConstManager.OBK_SA_SERIAL))
            {
                ViewData["TypeList"] = new SelectList(safetyRepository.GetObkRefTypes(), "Id", "NameRu", model.Type_Id = safetyRepository.GetObkRefTypes(CodeConstManager.OBK_SA_SERIAL).Id);
            }
            if (model.Type_Id == int.Parse(CodeConstManager.OBK_SA_PARTY))
            {
                ViewData["TypeList"] = new SelectList(safetyRepository.GetObkRefTypes(), "Id", "NameRu", model.Type_Id = safetyRepository.GetObkRefTypes(CodeConstManager.OBK_SA_PARTY).Id);
            }
            if (model.Type_Id == int.Parse(CodeConstManager.OBK_SA_DECLARATION))
            {
                ViewData["TypeList"] = new SelectList(safetyRepository.GetObkRefTypes(), "Id", "NameRu", model.Type_Id = safetyRepository.GetObkRefTypes(CodeConstManager.OBK_SA_DECLARATION).Id);
            }

            if (model.Contract_Id != null)
            {
                var contract         = safetyRepository.GetContractById(model.Contract_Id);
                var declarant        = safetyRepository.GetDeclarantById(contract.DeclarantId);
                var declarantContact = safetyRepository.GetDeclarantContactById(contract.DeclarantContactId);
                var products         = safetyRepository.GetRsProductsAndSeries(contract.Id);

                //справочник стран
                var countries = safetyRepository.GetCounties();
                if (declarant?.CountryId == null)
                {
                    ViewData["Counties"] = new SelectList(countries, "Id", "Name");
                }
                else
                {
                    ViewData["Counties"] = new SelectList(countries, "Id", "Name",
                                                          model.CountryId = declarant.CountryId);
                }

                //Валюта
                var currency = safetyRepository.GetObkCurrencies();
                if (declarantContact?.CurrencyId == null)
                {
                    ViewData["Courrency"] = new SelectList(currency, "Id", "Name");
                }
                else
                {
                    ViewData["Courrency"] = new SelectList(currency, "Id", "Name",
                                                           model.CurrencyId = declarantContact.CurrencyId);
                }

                //Наличие сертификата GMP
                var repository = new ReadOnlyDictionaryRepository();
                var booleans   = repository.GetCertificateGMPCheck();
                ViewData["IsGMPList"] = new SelectList(booleans, "CertificateGMPCheck", "NameRu",
                                                       model.CertificateGMPCheck);

                var certType = safetyRepository.GetCertificateType();
                if (model.CertificateTypeId == null)
                {
                    ViewData["CertificateType"] = new SelectList(certType, "Id", "NameRu");
                }
                else
                {
                    ViewData["CertificateType"] = new SelectList(certType, "Id", "NameRu", model.CertificateTypeId);
                }

                //организационная форма
                var orgForm = safetyRepository.GetOrganizationForm();
                if (declarant?.OrganizationFormId == null)
                {
                    ViewData["OrganizationForm"] = new SelectList(orgForm, "Id", "Name");
                }
                else
                {
                    ViewData["OrganizationForm"] = new SelectList(orgForm, "Id", "Name",
                                                                  model.OrganizationFormId = declarant.OrganizationFormId);
                }

                model.StartDate       = string.Format("{0:dd.MM.yyyy}", contract.StartDate);
                model.EndDate         = string.Format("{0:dd.MM.yyyy}", contract.EndDate);
                model.NameKz          = declarant?.NameKz ?? "нет данных";
                model.NameRu          = declarant?.NameRu ?? "нет данных";
                model.NameEn          = declarant?.NameEn ?? "нет данных";
                model.ChiefLastName   = declarantContact?.BossLastName ?? "нет данных";
                model.ChiefFirstName  = declarantContact?.BossFirstName ?? "нет данных";
                model.ChiefMiddleName = declarantContact?.BossMiddleName ?? "нет данных";
                model.ChiefPosition   = declarantContact?.BossPosition ?? "нет данных";
                model.AddressFact     = declarantContact?.AddressFact ?? "нет данных";
                model.AddressLegal    = declarantContact?.AddressLegalRu ?? "нет данных";
                model.Phone           = declarantContact?.Phone ?? "нет данных";
                model.Email           = declarantContact?.Email ?? "нет данных";
                model.BankBik         = declarantContact?.BankBik ?? "нет данных";
                model.BankIik         = declarantContact?.BankIik ?? "нет данных";
                model.BankName        = declarantContact?.BankNameRu ?? "нет данных";

                var resultProducts = new List <OBK_RS_Products>();
                foreach (var product in products)
                {
                    var prod = new OBK_RS_Products();
                    prod.Id             = product.Id;
                    prod.NameRu         = product.NameRu;
                    prod.NameKz         = product.NameKz;
                    prod.ProducerNameRu = product.ProducerNameRu;
                    prod.ProducerNameKz = product.ProducerNameKz;
                    prod.CountryNameRu  = product.CountryNameRu;
                    prod.CountryNameKZ  = product.CountryNameKZ;
                    prod.TnvedCode      = product.TnvedCode;
                    prod.KpvedCode      = product.KpvedCode;
                    prod.Price          = product.Price;
                    foreach (var productSeries in product.OBK_Procunts_Series)
                    {
                        var prodSeries = new OBK_Procunts_Series();
                        prodSeries.Id                = productSeries.Id;
                        prodSeries.Series            = productSeries.Series;
                        prodSeries.SeriesStartdate   = productSeries.SeriesStartdate;
                        prodSeries.SeriesEndDate     = productSeries.SeriesEndDate;
                        prodSeries.SeriesParty       = productSeries.SeriesParty;
                        prodSeries.SeriesShortNameRu = productSeries.sr_measures.short_name;
                        prod.OBK_Procunts_Series.Add(prodSeries);
                    }
                    resultProducts.Add(prod);
                }
                model.ObkRsProductses = resultProducts;
            }
            else
            {
                var countries = safetyRepository.GetCounties();
                ViewData["Counties"] = new SelectList(countries, "Id", "Name");

                //Валюта
                var currency = safetyRepository.GetObkCurrencies();
                ViewData["Courrency"] = new SelectList(currency, "Id", "Name");

                var repository = new ReadOnlyDictionaryRepository();
                //Наличие сертификата GMP
                var booleans = repository.GetCertificateGMPCheck();
                ViewData["IsGMPList"] = new SelectList(booleans, "CertificateGMPCheck", "NameRu",
                                                       model.CertificateGMPCheck);

                var certType = safetyRepository.GetCertificateType();
                ViewData["CertificateType"] = new SelectList(certType, "Id", "NameRu");

                //организационная форма
                var orgForm = safetyRepository.GetOrganizationForm();
                ViewData["OrganizationForm"] = new SelectList(orgForm, "Id", "Name");
            }
        }