예제 #1
0
        public string AddMedicalExamFieldValues(ref OperationResult pobjOperationResult, List <ComponentFieldValuesRestrictionList> ComponentFieldValuesRestrictionList, List <ComponentFieldValuesRecommendationList> ComponentFieldValuesRecommendationList, componentfieldvaluesDto pobjDtoEntity, List <string> ClientSession)
        {
            //mon.IsActive = true;
            string NewId = "(No generado)";

            try
            {
                SigesoftEntitiesModel dbContext = new SigesoftEntitiesModel();
                componentfieldvalues  objEntity = componentfieldvaluesAssembler.ToEntity(pobjDtoEntity);
                componentfieldvaluesrestrictionDto    objcomponentfieldvaluesrestrictionDto    = new componentfieldvaluesrestrictionDto();
                componentfieldvaluesrecommendationDto objcomponentfieldvaluesrecommendationDto = new componentfieldvaluesrecommendationDto();

                objEntity.d_InsertDate   = DateTime.Now;
                objEntity.i_InsertUserId = Int32.Parse(ClientSession[2]);
                objEntity.i_IsDeleted    = 0;
                // Autogeneramos el Pk de la tabla
                int intNodeId = int.Parse(ClientSession[0]);
                NewId = Common.Utils.GetNewId(intNodeId, Utils.GetNextSecuentialId(intNodeId, 19), "MV");
                objEntity.v_ComponentFieldValuesId = NewId;

                dbContext.AddTocomponentfieldvalues(objEntity);
                dbContext.SaveChanges();

                if (ComponentFieldValuesRestrictionList != null)
                {
                    for (int i = 0; i < ComponentFieldValuesRestrictionList.Count; i++)
                    {
                        objcomponentfieldvaluesrestrictionDto.v_ComponentFieldValuesId             = NewId;
                        objcomponentfieldvaluesrestrictionDto.v_MasterRecommendationRestricctionId = ComponentFieldValuesRestrictionList[i].v_MasterRecommendationRestricctionId;

                        AddRestriction(ref pobjOperationResult, objcomponentfieldvaluesrestrictionDto, ClientSession);
                    }
                }

                if (ComponentFieldValuesRecommendationList != null)
                {
                    for (int i = 0; i < ComponentFieldValuesRecommendationList.Count; i++)
                    {
                        objcomponentfieldvaluesrecommendationDto.v_ComponentFieldValuesId = NewId;
                        objcomponentfieldvaluesrecommendationDto.v_ComponentFieldValuesRecommendationId = ComponentFieldValuesRecommendationList[i].v_MasterRecommendationRestricctionId;

                        AddRecommendation(ref pobjOperationResult, objcomponentfieldvaluesrecommendationDto, ClientSession);
                    }
                }

                pobjOperationResult.Success = 1;
                // Llenar entidad Log
                LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.CREACION, "EXAMEN MÉDICO CAMPO VALOR", "v_MedicalExamFieldValuesId=" + NewId.ToString(), Success.Ok, null);
                return(NewId);
            }
            catch (Exception ex)
            {
                pobjOperationResult.Success          = 0;
                pobjOperationResult.ExceptionMessage = Common.Utils.ExceptionFormatter(ex);
                // Llenar entidad Log
                LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.CREACION, "EXAMEN MÉDICO CAMPO VALOR", "v_MedicalExamFieldValuesId=" + NewId.ToString(), Success.Failed, pobjOperationResult.ExceptionMessage);
                return(null);
            }
        }
예제 #2
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            OperationResult objOperationResult = new OperationResult();

            _componentfieldvaluesrestrictionListDto    = new List <componentfieldvaluesrestrictionDto>();
            _componentfieldvaluesrecommendationListDto = new List <componentfieldvaluesrecommendationDto>();

            if (uvMedicalExamFiedValues.Validate(true, false).IsValid)
            {
                if (txtAnalyzeValue1.Text.Trim() == "")
                {
                    MessageBox.Show("Por favor ingrese un nombre apropiado para el Nombre Valor Analizar 1.", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                if (MessageBox.Show("¿Está seguro de agregar / modificar la Campos al examen?.", "Pregunta", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
                {
                    return;
                }
                if (Mode == "New")
                {
                    _objmedicalexamfieldValuesDto = new componentfieldvaluesDto();
                    // Populate the entity+
                    _objmedicalexamfieldValuesDto.v_ComponentFieldId = MedicalExamFliedId;
                    _objmedicalexamfieldValuesDto.v_AnalyzingValue1  = txtAnalyzeValue1.Text;
                    _objmedicalexamfieldValuesDto.v_AnalyzingValue2  = txtAnalyzeValue2.Text;
                    _objmedicalexamfieldValuesDto.i_OperatorId       = Int32.Parse(ddlOperatorId.SelectedValue.ToString());
                    _objmedicalexamfieldValuesDto.i_GenderId         = int.Parse(ddlSexTypeId.SelectedValue.ToString());
                    _objmedicalexamfieldValuesDto.v_LegalStandard    = txtLegalStandard.Text;
                    _objmedicalexamfieldValuesDto.i_IsAnormal        = Int32.Parse(ddlIsAnormal.SelectedValue.ToString());
                    _objmedicalexamfieldValuesDto.v_DiseasesId       = _objDiseasesList.v_DiseasesId;
                    // Save the data
                    _MedicalExamFliedValueId = _objMedicalExamFieldsBL.AddMedicalExamFieldValues(ref objOperationResult, _TempComponentFieldValuesRestrictionList, _TempComponentFieldValuesRecommendationList, _objmedicalexamfieldValuesDto, Globals.ClientSession.GetAsList());
                }
                else if (Mode == "Edit")
                {
                    _componentfieldvaluesrestrictionListDtoDelete    = new List <componentfieldvaluesrestrictionDto>();
                    _componentfieldvaluesrecommendationListDtoDelete = new List <componentfieldvaluesrecommendationDto>();
                    // Populate the entity
                    _objmedicalexamfieldValuesDto.v_ComponentFieldId = MedicalExamFliedId;
                    _objmedicalexamfieldValuesDto.v_AnalyzingValue1  = txtAnalyzeValue1.Text;
                    _objmedicalexamfieldValuesDto.v_AnalyzingValue2  = txtAnalyzeValue2.Text;
                    _objmedicalexamfieldValuesDto.i_OperatorId       = Int32.Parse(ddlOperatorId.SelectedValue.ToString());
                    _objmedicalexamfieldValuesDto.i_GenderId         = int.Parse(ddlSexTypeId.SelectedValue.ToString());

                    _objmedicalexamfieldValuesDto.v_LegalStandard = txtLegalStandard.Text;
                    _objmedicalexamfieldValuesDto.i_IsAnormal     = Int32.Parse(ddlIsAnormal.SelectedValue.ToString());
                    _objmedicalexamfieldValuesDto.v_DiseasesId    = _objDiseasesList.v_DiseasesId;

                    //Temporal de Restricción
                    foreach (var item in _TempComponentFieldValuesRestrictionList)
                    {
                        // Add
                        if (item.i_RecordType == (int)RecordType.Temporal && item.i_RecordStatus == (int)RecordStatus.Agregado)
                        {
                            componentfieldvaluesrestrictionDto componentfieldvaluesrestrictionDto = new componentfieldvaluesrestrictionDto();

                            componentfieldvaluesrestrictionDto.v_ComponentFieldValuesRestrictionId  = item.v_ComponentFieldValuesRestrictionId;
                            componentfieldvaluesrestrictionDto.v_ComponentFieldValuesId             = item.v_ComponentFieldValuesId;
                            componentfieldvaluesrestrictionDto.v_MasterRecommendationRestricctionId = item.v_MasterRecommendationRestricctionId;

                            _componentfieldvaluesrestrictionListDto.Add(componentfieldvaluesrestrictionDto);
                        }

                        // Delete
                        if (item.i_RecordType == (int)RecordType.NoTemporal && item.i_RecordStatus == (int)RecordStatus.EliminadoLogico)
                        {
                            componentfieldvaluesrestrictionDto componentfieldvaluesrestrictionDto = new componentfieldvaluesrestrictionDto();

                            componentfieldvaluesrestrictionDto.v_ComponentFieldValuesRestrictionId = item.v_ComponentFieldValuesRestrictionId;
                            _componentfieldvaluesrestrictionListDtoDelete.Add(componentfieldvaluesrestrictionDto);
                        }
                    }

                    //Temporal de Recomendaciones
                    foreach (var item in _TempComponentFieldValuesRecommendationList)
                    {
                        // Add
                        if (item.i_RecordType == (int)RecordType.Temporal && item.i_RecordStatus == (int)RecordStatus.Agregado)
                        {
                            componentfieldvaluesrecommendationDto componentfieldvaluesrecommendationDto = new componentfieldvaluesrecommendationDto();

                            componentfieldvaluesrecommendationDto.v_ComponentFieldValuesRecommendationId = item.v_ComponentFieldValuesRecommendationId;
                            componentfieldvaluesrecommendationDto.v_ComponentFieldValuesId             = item.v_ComponentFieldValuesId;
                            componentfieldvaluesrecommendationDto.v_MasterRecommendationRestricctionId = item.v_MasterRecommendationRestricctionId;

                            _componentfieldvaluesrecommendationListDto.Add(componentfieldvaluesrecommendationDto);
                        }

                        // Delete
                        if (item.i_RecordType == (int)RecordType.NoTemporal && item.i_RecordStatus == (int)RecordStatus.EliminadoLogico)
                        {
                            componentfieldvaluesrecommendationDto componentfieldvaluesrecommendationDto = new componentfieldvaluesrecommendationDto();

                            componentfieldvaluesrecommendationDto.v_ComponentFieldValuesRecommendationId = item.v_ComponentFieldValuesRecommendationId;
                            _componentfieldvaluesrecommendationListDtoDelete.Add(componentfieldvaluesrecommendationDto);
                        }
                    }

                    // Save the data
                    _objMedicalExamFieldsBL.UpdateMedicalExamFieldValues(ref objOperationResult,
                                                                         _componentfieldvaluesrestrictionListDto,
                                                                         _componentfieldvaluesrestrictionListDtoDelete,
                                                                         _componentfieldvaluesrecommendationListDto,
                                                                         _componentfieldvaluesrecommendationListDtoDelete,
                                                                         _objmedicalexamfieldValuesDto,
                                                                         Globals.ClientSession.GetAsList());
                }

                //// Analizar el resultado de la operación
                if (objOperationResult.Success == 1)  // Operación sin error
                {
                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                    this.Close();
                }
                else  // Operación con error
                {
                    MessageBox.Show("Error en operación:" + System.Environment.NewLine + objOperationResult.ExceptionMessage, "ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    // Se queda en el formulario.
                }
            }
            else
            {
                MessageBox.Show("Por favor corrija la información ingresada. Vea los indicadores de error.", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }