コード例 #1
0
        public string AddMedicalExamFields(ref OperationResult pobjOperationResult, componentfieldDto pobjDtoEntity, componentfieldsDto pobjDtoEntitys, string pstrComponentId, List <string> ClientSession)
        {
            //mon.IsActive = true;
            string NewId = "(No generado)";

            try
            {
                SigesoftEntitiesModel dbContext = new SigesoftEntitiesModel();
                var query1 = (from a in dbContext.componentfield
                              join b in dbContext.componentfields on a.v_ComponentFieldId equals b.v_ComponentFieldId
                              where a.v_TextLabel.ToUpper() == pobjDtoEntity.v_TextLabel.ToUpper() && b.v_ComponentId == pobjDtoEntitys.v_ComponentId && b.v_Group == pobjDtoEntitys.v_Group
                              select a).ToList();
                if (query1.Count > 0)
                {
                    pobjOperationResult.ErrorMessage = "Nombre del componente duplicado";
                    return("0");
                }
                #region ComponentField
                componentfield objEntity = componentfieldAssembler.ToEntity(pobjDtoEntity);


                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, 18), "MF");

                objEntity.v_ComponentFieldId = NewId;



                dbContext.AddTocomponentfield(objEntity);
                dbContext.SaveChanges();
                #endregion

                #region ComponentFields
                componentfields objEntitys = componentfieldsAssembler.ToEntity(pobjDtoEntitys);
                objEntitys.v_ComponentFieldId = NewId;
                objEntitys.v_ComponentId      = pstrComponentId;
                objEntitys.d_InsertDate       = DateTime.Now;
                objEntitys.i_InsertUserId     = Int32.Parse(ClientSession[2]);
                objEntitys.i_IsDeleted        = 0;

                dbContext.AddTocomponentfields(objEntitys);
                dbContext.SaveChanges();

                #endregion

                pobjOperationResult.Success = 1;
                // Llenar entidad Log
                LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.CREACION, "EXAMEN MÉDICO CAMPO", "v_MedicalExamFieldsId=" + 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", "v_MedicalExamFieldsId=" + NewId.ToString(), Success.Failed, pobjOperationResult.ExceptionMessage);
                return("0");
            }
        }
コード例 #2
0
        public void AddComponentFields(ref OperationResult pobjOperationResult, List <componentfieldsDto> pobjcomponentfieldsAdd, List <componentfieldsDto> pobjcomponentfieldsUpdate, List <componentfieldsDto> pobjcomponentfieldsDelete, List <string> ClientSession)
        {
            try
            {
                OperationResult       objOperationResult = new OperationResult();
                SigesoftEntitiesModel dbContext          = new SigesoftEntitiesModel();
                int intNodeId = int.Parse(ClientSession[0]);
                #region Add Component Fields
                foreach (var item in pobjcomponentfieldsAdd)
                {
                    componentfields objEntity1 = new componentfields();
                    objEntity1.d_InsertDate   = DateTime.Now;
                    objEntity1.i_InsertUserId = Int32.Parse(ClientSession[2]);
                    objEntity1.i_IsDeleted    = 0;


                    objEntity1.v_ComponentFieldId = item.v_ComponentFieldId;
                    objEntity1.v_ComponentId      = item.v_ComponentId;
                    objEntity1.v_Group            = item.v_Group;

                    //Verificar si se encuentra en la BD eliminado
                    var objEntitySource1 = (from a in dbContext.componentfields
                                            where a.v_ComponentFieldId == item.v_ComponentFieldId && a.v_ComponentId == item.v_ComponentId
                                            select a).FirstOrDefault();

                    if (objEntitySource1 == null)
                    {
                        dbContext.AddTocomponentfields(objEntity1);
                    }
                    else
                    {
                        objEntitySource1.i_IsDeleted = 0;

                        objEntitySource1.d_UpdateDate   = DateTime.Now;
                        objEntitySource1.i_UpdateUserId = Int32.Parse(ClientSession[2]);
                    }
                }
                // Guardar los cambios
                dbContext.SaveChanges();
                #endregion

                #region Update Component Fields
                if (pobjcomponentfieldsUpdate != null)
                {
                    // Actualizar Componentes del protocolo
                    foreach (var item in pobjcomponentfieldsUpdate)
                    {
                        // Obtener la entidad fuente
                        var objEntitySource1 = (from a in dbContext.componentfields
                                                where a.v_ComponentFieldId == item.v_ComponentFieldId && a.v_ComponentId == item.v_ComponentId
                                                select a).FirstOrDefault();

                        // Crear la entidad con los datos actualizados

                        objEntitySource1.v_Group     = item.v_Group;
                        objEntitySource1.i_IsDeleted = 0;

                        objEntitySource1.d_UpdateDate   = DateTime.Now;
                        objEntitySource1.i_UpdateUserId = Int32.Parse(ClientSession[2]);
                    }
                }
                // Guardar los cambios
                dbContext.SaveChanges();
                #endregion

                #region Delete Component Fields
                if (pobjcomponentfieldsDelete != null)
                {
                    foreach (var item in pobjcomponentfieldsDelete)
                    {
                        // Obtener la entidad fuente
                        var objEntitySource1 = (from a in dbContext.componentfields
                                                where a.v_ComponentFieldId == item.v_ComponentFieldId && a.v_ComponentId == item.v_ComponentId
                                                select a).FirstOrDefault();

                        // Crear la entidad con los datos actualizados
                        objEntitySource1.d_UpdateDate   = DateTime.Now;
                        objEntitySource1.i_UpdateUserId = Int32.Parse(ClientSession[2]);
                        objEntitySource1.i_IsDeleted    = 1;
                    }
                }
                // Guardar los cambios
                dbContext.SaveChanges();
                #endregion

                pobjOperationResult.Success = 1;
                // Llenar entidad Log
                //LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.CREACION, "CAMPOS DEL COMPONENTE", "v_ComponentId=" + objEntity1.v_ComponentId + "v_ComponentFieldId= " + objEntity1.v_ComponentFieldId, Success.Ok, null);
                return;
            }
            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, "CAMPOS DEL COMPONENTE", "v_ComponentId= No generado ,v_ComponentFieldId= No generado ", Success.Failed, pobjOperationResult.ExceptionMessage);
                return;
            }
        }