private void btnSearchProtocol_Click(object sender, EventArgs e)
        {
            Configuration.frmProtocolManagement frm = new Configuration.frmProtocolManagement("View", int.Parse(ddlServiceTypeId.SelectedValue.ToString()), int.Parse(ddlMasterServiceId.SelectedValue.ToString()));
            frm.ShowDialog();
            _ProtocolId = frm._pstrProtocolId;
            if (_ProtocolId == null)
            {
                return;
            }
            OperationResult objOperationResult = new OperationResult();
            ProtocolBL      _objProtocoltBL    = new ProtocolBL();
            protocolDto     objProtocolDto     = new protocolDto();
            ProtocolList    objProtocol        = new ProtocolList();

            objProtocol = _objProtocoltBL.GetProtocolById(ref objOperationResult, _ProtocolId);

            txtProtocolId.Text                   = objProtocol.v_ProtocolId;
            txtViewProtocol.Text                 = objProtocol.v_Protocol;
            txtViewOrganization.Text             = objProtocol.v_Organization;
            txtViewLocation.Text                 = objProtocol.v_Location;
            txtViewGroupOccupation.Text          = objProtocol.v_GroupOccupation;
            txtViewGes.Text                      = objProtocol.v_Ges;
            txtViewComponentType.Text            = objProtocol.v_EsoType;
            txtViewOccupation.Text               = objProtocol.v_Occupation;
            txtViewIntermediaryOrganization.Text = objProtocol.v_IntermediaryOrganization;
            txtIntermediaryOrganization.Text     = objProtocol.v_OrganizationInvoice;
        }
Ejemplo n.º 2
0
        public protocolDto GetProtocol(ref OperationResult pobjOperationResult, string pstrProtocolId)
        {
            //mon.IsActive = true;
            try
            {
                SigesoftEntitiesModel dbContext    = new SigesoftEntitiesModel();
                protocolDto           objDtoEntity = null;

                var objEntity = (from a in dbContext.protocol
                                 where a.v_ProtocolId == pstrProtocolId
                                 select a).FirstOrDefault();

                if (objEntity != null)
                {
                    objDtoEntity = protocolAssembler.ToDTO(objEntity);
                }

                pobjOperationResult.Success = 1;
                return(objDtoEntity);
            }
            catch (Exception ex)
            {
                pobjOperationResult.Success          = 0;
                pobjOperationResult.ExceptionMessage = Common.Utils.ExceptionFormatter(ex);
                return(null);
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            OperationResult objOperationResult = new OperationResult();

            _protocolcomponentListDTO = new List <protocolcomponentDto>();
            if (uvProtocol.Validate(true, false).IsValid)
            {
                var id  = cbOrganization.SelectedValue.ToString().Split('|');
                var id1 = cbOrganizationInvoice.SelectedValue.ToString().Split('|');
                var id2 = cbIntermediaryOrganization.SelectedValue.ToString().Split('|');

                if (_protocolDTO == null)
                {
                    _protocolDTO = new protocolDto();
                }
                //if (_serviceDTO == null)
                //{
                //    _serviceDTO = new serviceDto();
                //}
                _serviceDTO = new ServiceBL().GetService(ref objOperationResult, _serviceId);

                _protocolDTO.v_Name = txtProtocolName.Text;
                _protocolDTO.v_EmployerOrganizationId = id[0];
                _protocolDTO.v_EmployerLocationId     = id[1];
                _protocolDTO.i_EsoTypeId              = int.Parse(cbEsoType.SelectedValue.ToString());
                _protocolDTO.v_GroupOccupationId      = cbGeso.SelectedValue.ToString();
                _protocolDTO.v_CustomerOrganizationId = id1[0];
                _protocolDTO.v_CustomerLocationId     = id1[1];
                _protocolDTO.v_WorkingOrganizationId  = id2[0];
                _protocolDTO.v_WorkingLocationId      = cbIntermediaryOrganization.SelectedValue.ToString() != "-1" ? id2[1] : "-1";
                _protocolDTO.i_MasterServiceId        = int.Parse(cbService.SelectedValue.ToString());
                _protocolDTO.i_MasterServiceTypeId    = int.Parse(cbServiceType.SelectedValue.ToString());
                _protocolDTO.v_ProtocolId             = _protocolId;
                _protocolDTO.v_ComentaryUpdate        = GetChangesProtocol();
                _protocolBL.UpdateProtocol(ref objOperationResult,
                                           _protocolDTO,
                                           _protocolcomponentListDTO,
                                           _protocolcomponentListDTO,
                                           _protocolcomponentListDTO,
                                           Globals.ClientSession.GetAsList());

                _serviceDTO.v_centrocosto = txtCentroCosto.Text;
                _serviceDTO.v_ServiceId   = _serviceId;
                //_ServiceBL.UpdateService(ref objOperationResult, _serviceDTO, Globals.ClientSession.GetAsList());
                _ServiceBL.UpdateService(ref objOperationResult, _serviceDTO, Globals.ClientSession.GetAsList());
            }

            if (objOperationResult.Success == 1)      // Operación sin error
            {
                MessageBox.Show("Se grabo correctamente.", "INFORMACION!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else      // Operación con error
            {
                MessageBox.Show(Constants.GenericErrorMessage, "ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void frmEditarServicio_Load(object sender, EventArgs e)
        {
            OperationResult objOperationResult = new OperationResult();

            LoadComboBox();
            LoadPerson();
            _protocolDTO = _protocolBL.GetProtocol(ref objOperationResult, _protocolId);
            string idOrgInter = "-1";

            // cabecera del protocolo
            txtProtocolName.Text    = _protocolDTO.v_Name;
            cbEsoType.SelectedValue = _protocolDTO.i_EsoTypeId.ToString();

            // Almacenar temporalmente
            _protocolName = txtProtocolName.Text;

            if (_protocolDTO.v_WorkingOrganizationId != "-1" && _protocolDTO.v_WorkingLocationId != "-1")
            {
                idOrgInter = string.Format("{0}|{1}", _protocolDTO.v_WorkingOrganizationId, _protocolDTO.v_WorkingLocationId);
            }

            cbIntermediaryOrganization.SelectedValue = idOrgInter;
            cbOrganizationInvoice.SelectedValue      = string.Format("{0}|{1}", _protocolDTO.v_CustomerOrganizationId, _protocolDTO.v_CustomerLocationId);
            cbOrganization.SelectedValue             = string.Format("{0}|{1}", _protocolDTO.v_EmployerOrganizationId, _protocolDTO.v_EmployerLocationId);
            cbGeso.SelectedValue        = _protocolDTO.v_GroupOccupationId;
            cbServiceType.SelectedValue = _protocolDTO.i_MasterServiceTypeId.ToString();
            cbService.SelectedValue     = _protocolDTO.i_MasterServiceId.ToString();
            //SERVICIO - CENTRO DE COSTO
            var servicio = new ServiceBL().GetService(ref objOperationResult, _serviceId);

            txtCentroCosto.Text = servicio.v_centrocosto;
            // Componentes del protocolo
            var   dataListPc = _ServiceBL.GetServiceComponentsLiquidacion(ref objOperationResult, _serviceId);
            float Total      = 0;

            foreach (var item in dataListPc)
            {
                Total = Total + item.r_Price.Value;
            }
            lblCostoTotal.Text = Total.ToString();

            grdDataLocation.DataSource = dataListPc;

            SetOldValuesPerson();
            SetOldValuesProtocol();
            if (objOperationResult.Success != 1)
            {
                MessageBox.Show("Error en operación:" + System.Environment.NewLine + objOperationResult.ExceptionMessage, "ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 5
0
        private void btnSearchProtocol_Click(object sender, EventArgs e)
        {
            OperationResult objOperationResult = new OperationResult();
            ProtocolBL      oProtocolBL        = new ProtocolBL();

            //List<ProtocolComponentList> ProtocolComponentList = new List<BE.ProtocolComponentList>();


            Configuration.frmProtocolManagement frm = new Configuration.frmProtocolManagement("View", -1, -1);
            frm.ShowDialog();
            if (frm._pstrProtocolId != null)
            {
                _ProtocolId = frm._pstrProtocolId;
            }

            if (frm.DialogResult == DialogResult.Cancel)
            {
                return;
            }

            if (_ProtocolId == null)
            {
                return;
            }

            ProtocolBL   _objProtocoltBL = new ProtocolBL();
            protocolDto  objProtocolDto  = new protocolDto();
            ProtocolList objProtocol     = new ProtocolList();

            objProtocol = _objProtocoltBL.GetProtocolById(ref objOperationResult, _ProtocolId);

            txtProtocolName.Text = objProtocol.v_Protocol;
            txtOrganitation.Text = objProtocol.v_Organization;
            txtContact.Text      = objProtocol.v_ContacName;
            txtAdress.Text       = objProtocol.v_Address;
            txttypeProtocol.Text = objProtocol.v_EsoType;

            //ProtocolComponentList = oProtocolBL.GetProtocolComponents(ref objOperationResult, _ProtocolId);

            //foreach (var item in ProtocolComponentList)
            //{
            //    CostoTotal += (float)item.r_Price;
            //}

            //grdData.DataSource = ProtocolComponentList;
            //txtTotal.Text = CostoTotal.ToString();
            //Calcular();
            txtNroTrabajadores.Focus();
        }
        private string CreateProtocol(ScheduleForProcess record, List <ComponentList> componentsBd)
        {
            var oprotocolDto = new protocolDto();

            var organizationIds             = cbOrganization.SelectedValue.ToString().Split('|');
            var organizationInvoiceIds      = cbOrganizationInvoice.SelectedValue.ToString().Split('|');
            var organizationIntermediaryIds = cbIntermediaryOrganization.SelectedValue.ToString().Split('|');

            oprotocolDto.v_Name = "&&&&" + CreateProtocolName(record.Geso);
            oprotocolDto.v_EmployerOrganizationId = organizationIds[0];
            oprotocolDto.v_EmployerLocationId     = organizationIds[1];
            oprotocolDto.i_EsoTypeId              = int.Parse(cbEsoType.SelectedValue.ToString());
            oprotocolDto.v_GroupOccupationId      = record.GesoId;// GetGesoId(organizationInvoiceIds[1]);
            oprotocolDto.v_CustomerOrganizationId = organizationInvoiceIds[0];
            oprotocolDto.v_CustomerLocationId     = organizationInvoiceIds[1];
            oprotocolDto.v_WorkingOrganizationId  = organizationIntermediaryIds[0];
            oprotocolDto.v_WorkingLocationId      = cbIntermediaryOrganization.SelectedValue.ToString() != "-1" ? organizationIntermediaryIds[1] : "-1";
            oprotocolDto.i_MasterServiceId        = (int)MasterService.Eso;
            oprotocolDto.v_CostCenter             = "";
            oprotocolDto.i_MasterServiceTypeId    = (int)ServiceType.Empresarial;
            oprotocolDto.i_HasVigency             = Convert.ToInt32(true);
            oprotocolDto.i_ValidInDays            = null;
            oprotocolDto.i_IsActive       = Convert.ToInt32(true);
            oprotocolDto.v_NombreVendedor = "";

            var inputComps = record.ComponentsByRecord.FindAll(p => p.Check);

            var protocolcomponentListDto = new List <protocolcomponentDto>();

            foreach (var item in inputComps)
            {
                var protocolComponent = new protocolcomponentDto();
                protocolComponent.v_ComponentId      = item.ComponetId;
                protocolComponent.r_Price            = componentsBd.Find(p => p.v_ComponentId == item.ComponetId).r_BasePrice;
                protocolComponent.i_OperatorId       = -1;
                protocolComponent.i_Age              = 0;
                protocolComponent.i_GenderId         = 3;
                protocolComponent.i_IsAdditional     = 0;
                protocolComponent.i_IsConditionalId  = 0;
                protocolComponent.i_GrupoEtarioId    = -1;
                protocolComponent.i_IsConditionalIMC = 0;
                protocolComponent.r_Imc              = (decimal?)0.00f;

                protocolcomponentListDto.Add(protocolComponent);
            }

            return(_protocolBl.AddProtocol(ref _operationResult, oprotocolDto, protocolcomponentListDto, Globals.ClientSession.GetAsList()));
        }
Ejemplo n.º 7
0
        private void ClonAction()
        {
            OperationResult             objOperationResult        = new OperationResult();
            protocolDto                 _protocolDTO              = new protocolDto();
            ProtocolBL                  _protocolBL               = new ProtocolBL();
            protocolcomponentDto        oprotocolcomponentDto     = null;
            List <protocolcomponentDto> _protocolcomponentListDTO = new List <protocolcomponentDto>();

            // Obtener los IDs de la fila seleccionada
            string ProtocolId = grdData.DataKeys[grdData.SelectedRowIndex][0].ToString();

            _protocolDTO              = _protocolBL.GetProtocol(ref objOperationResult, ProtocolId);
            _protocolDTO.v_Name       = _protocolDTO.v_Name + "_Copia";
            _protocolDTO.v_ProtocolId = null;
            // Componentes del protocolo
            var dataListPc = _protocolBL.GetProtocolComponents(ref objOperationResult, ProtocolId);

            foreach (var item in dataListPc)
            {
                oprotocolcomponentDto = new protocolcomponentDto();

                oprotocolcomponentDto.v_ProtocolComponentId = item.v_ProtocolComponentId;
                oprotocolcomponentDto.v_ProtocolId          = item.v_ProtocolId;
                oprotocolcomponentDto.v_ComponentId         = item.v_ComponentId;
                oprotocolcomponentDto.r_Price           = item.r_Price;
                oprotocolcomponentDto.i_OperatorId      = item.i_OperatorId;
                oprotocolcomponentDto.i_Age             = item.i_Age;
                oprotocolcomponentDto.i_GenderId        = item.i_GenderId;
                oprotocolcomponentDto.i_IsConditionalId = item.i_IsConditionalId;
                oprotocolcomponentDto.i_IsDeleted       = item.i_IsDeleted;
                //oprotocolcomponentDto.i_InsertUserId = item.i_InsertUserId;
                //oprotocolcomponentDto.d_InsertDate = item.d_InsertDate;
                //oprotocolcomponentDto.i_UpdateUserId = item.i_UpdateUserId;
                oprotocolcomponentDto.d_UpdateDate       = item.d_UpdateDate;
                oprotocolcomponentDto.i_IsConditionalIMC = item.i_IsConditionalIMC;
                oprotocolcomponentDto.r_Imc          = item.r_Imc;
                oprotocolcomponentDto.i_IsAdditional = item.i_isAdditional;
                _protocolcomponentListDTO.Add(oprotocolcomponentDto);
            }


            _protocolBL.AddProtocol(ref objOperationResult, _protocolDTO, _protocolcomponentListDTO, ((ClientSession)Session["objClientSession"]).GetAsList());
        }
        private void btnImprimirTicket_Click(object sender, EventArgs e)
        {
            OperationResult _objOperationResult = new OperationResult();

            using (new LoadingClass.PleaseWait(this.Location, "Generando..."))
            {
                this.Enabled = false;

                var MedicalCenter = _serviceBL.GetInfoMedicalCenter();

                var ticketId = grdData.Selected.Rows[0].Cells["v_TicketId"].Value.ToString();

                var lista = _hospitBL.BuscarTicketsDetalle(ticketId);

                //var serviceId = lista.SelectMany(p => p.Servicios.Select(q=>q.v_ServiceId));
                //int doctor = 1;
                Ticket  = _hospitBL.GetHospitServTicket(ticketId);
                hospser = _hospitBL.GetHospitServwithTicekt(Ticket.v_ServiceId);

                serv = _hospitBL.GetService(Ticket.v_ServiceId);
                prot = _hospitBL.GetProtocol(serv.v_ProtocolId);

                var datosP = _pacientBL.DevolverDatosPaciente(Ticket.v_ServiceId);

                string      ruta       = Common.Utils.GetApplicationConfigValue("rutaTicketsH").ToString();
                ServiceList personData = _serviceBL.GetServicePersonData(ref _objOperationResult, hospser.v_ServiceId);

                var hospitalizacion           = _hospitBL.GetHospitalizacion(ref _objOperationResult, hospser.v_HopitalizacionId);
                var hospitalizacionhabitacion = _hospitBL.GetHospitalizacionHabitacion(ref _objOperationResult, hospser.v_HopitalizacionId);
                var medicoTratante            = new ServiceBL().GetMedicoTratante(Ticket.v_ServiceId);

                string nombre = "Ticket N° " + ticketId + "_" + personData.v_DocNumber;

                TicketHosp.CreateTicket(ruta + nombre + ".pdf", MedicalCenter, lista, datosP, hospitalizacion, hospitalizacionhabitacion, medicoTratante, Ticket, prot);

                this.Enabled = true;
            }
            //this.Close();
        }
Ejemplo n.º 9
0
        private void btnSearchProtocol_Click(object sender, EventArgs e)
        {
            OperationResult objOperationResult = new OperationResult();

            Configuration.frmProtocolManagement frm = new Configuration.frmProtocolManagement("View", -1, -1);
            frm.ShowDialog();
            _ProtocolId = frm._pstrProtocolId;
            if (_ProtocolId == null)
            {
                return;
            }

            ProtocolBL   _objProtocoltBL = new ProtocolBL();
            protocolDto  objProtocolDto  = new protocolDto();
            ProtocolList objProtocol     = new ProtocolList();

            objProtocol = _objProtocoltBL.GetProtocolById(ref objOperationResult, _ProtocolId);

            txtProtocolName.Text = objProtocol.v_Protocol;

            btnSave.Enabled = (txtProtocolName.TextLength > 0);
        }
Ejemplo n.º 10
0
        public string AddProtocol(ref OperationResult pobjOperationResult, protocolDto pobjProtocol, List <protocolcomponentDto> pobjProtocolComponent, List <string> ClientSession)
        {
            //mon.IsActive = true;
            string NewId0 = null;

            try
            {
                SigesoftEntitiesModel dbContext = new SigesoftEntitiesModel();
                protocol objEntity = protocolAssembler.ToEntity(pobjProtocol);

                int intNodeId = 9;

                if (pobjProtocol.v_ProtocolId == null)
                {
                    objEntity.d_InsertDate   = DateTime.Now;
                    objEntity.i_InsertUserId = Int32.Parse(ClientSession[2]);
                    objEntity.i_IsDeleted    = 0;
                    // Autogeneramos el Pk de la tabla

                    NewId0 = Common.Utils.GetNewId(intNodeId, Utils.GetNextSecuentialId(intNodeId, 20), "PR");
                    objEntity.v_ProtocolId = NewId0;

                    dbContext.AddToprotocol(objEntity);
                    dbContext.SaveChanges();
                }
                else
                {
                    // Obtener la entidad fuente
                    var objEntitySource = (from a in dbContext.protocol
                                           where a.v_ProtocolId == pobjProtocol.v_ProtocolId
                                           select a).FirstOrDefault();

                    // Crear la entidad con los datos actualizados
                    pobjProtocol.i_IsDeleted    = 0;
                    pobjProtocol.d_UpdateDate   = DateTime.Now;
                    pobjProtocol.i_UpdateUserId = Int32.Parse(ClientSession[2]);

                    var objStrongEntity = protocolAssembler.ToEntity(pobjProtocol);

                    // Copiar los valores desde la entidad actualizada a la Entidad Fuente
                    dbContext.protocol.ApplyCurrentValues(objStrongEntity);
                }

                // Grabar detalle del protocolo
                foreach (var item in pobjProtocolComponent)
                {
                    protocolcomponent objEntity1 = protocolcomponentAssembler.ToEntity(item);

                    objEntity1.d_InsertDate   = DateTime.Now;
                    objEntity1.i_InsertUserId = Int32.Parse(ClientSession[2]);
                    objEntity1.i_IsDeleted    = 0;

                    var NewId1 = Common.Utils.GetNewId(intNodeId, Utils.GetNextSecuentialId(intNodeId, 21), "PC");
                    objEntity1.v_ProtocolComponentId = NewId1;
                    objEntity1.v_ProtocolId          = pobjProtocol.v_ProtocolId == null ? NewId0 : pobjProtocol.v_ProtocolId;

                    dbContext.AddToprotocolcomponent(objEntity1);
                    dbContext.SaveChanges();
                }

                pobjOperationResult.Success = 1;
            }
            catch (Exception ex)
            {
                pobjOperationResult.Success          = 0;
                pobjOperationResult.ExceptionMessage = Common.Utils.ExceptionFormatter(ex);
                // Llenar entidad Log
            }

            return(NewId0);
        }
Ejemplo n.º 11
0
        private void LoadData()
        {
            OperationResult objOperationResult = new OperationResult();

            #region Mayusculas - Normal
            var _EsMayuscula = int.Parse(Common.Utils.GetApplicationConfigValue("EsMayuscula"));
            if (_EsMayuscula == 1)
            {
                SearchControlAndSetEvents(this);
            }


            #endregion

            LoadComboBox();
            BindGridSystemUserExternal();

            if (_mode == "New")
            {
                // Additional logic here.
                txtProtocolName.Select();
            }
            else if (_mode == "Edit")
            {
                _protocolDTO = _protocolBL.GetProtocol(ref objOperationResult, _protocolId);
                string idOrgInter = "-1";

                // cabecera del protocolo
                txtProtocolName.Text         = _protocolDTO.v_Name;
                cbEsoType.SelectedValue      = _protocolDTO.i_EsoTypeId.ToString();
                cbOrganization.SelectedValue = string.Format("{0}|{1}", _protocolDTO.v_EmployerOrganizationId, _protocolDTO.v_EmployerLocationId);
                // Almacenar temporalmente
                _protocolName = txtProtocolName.Text;

                if (_protocolDTO.v_WorkingOrganizationId != "-1" && _protocolDTO.v_WorkingLocationId != "-1")
                {
                    idOrgInter = string.Format("{0}|{1}", _protocolDTO.v_WorkingOrganizationId, _protocolDTO.v_WorkingLocationId);
                }

                cbIntermediaryOrganization.SelectedValue = idOrgInter;
                cbOrganizationInvoice.SelectedValue      = string.Format("{0}|{1}", _protocolDTO.v_CustomerOrganizationId, _protocolDTO.v_CustomerLocationId);
                cbGeso.SelectedValue        = _protocolDTO.v_GroupOccupationId;
                cbServiceType.SelectedValue = _protocolDTO.i_MasterServiceTypeId.ToString();
                cbService.SelectedValue     = _protocolDTO.i_MasterServiceId.ToString();
                txtCostCenter.Text          = _protocolDTO.v_CostCenter;
                chkIsHasVigency.Checked     = Convert.ToBoolean(_protocolDTO.i_HasVigency);
                txtValidDays.Enabled        = chkIsHasVigency.Checked;
                txtValidDays.Text           = _protocolDTO.i_ValidInDays.ToString();
                chkIsActive.Checked         = Convert.ToBoolean(_protocolDTO.i_IsActive);
                cboVendedor.Text            = _protocolDTO.v_NombreVendedor;
                // Componentes del protocolo
                var dataListPc = _protocolBL.GetProtocolComponents(ref objOperationResult, _protocolId);

                grdProtocolComponent.DataSource = dataListPc;

                _tmpProtocolcomponentList = dataListPc;
                lblRecordCount2.Text      = string.Format("Se encontraron {0} registros.", dataListPc.Count());

                if (objOperationResult.Success != 1)
                {
                    MessageBox.Show("Error en operación:" + System.Environment.NewLine + objOperationResult.ExceptionMessage, "ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else if (_mode == "Clon")
            {
                txtProtocolName.Select();

                // Componentes del protocolo
                var dataListPc = _protocolBL.GetProtocolComponents(ref objOperationResult, _protocolId);

                grdProtocolComponent.DataSource = dataListPc;

                _tmpProtocolcomponentList = dataListPc;
                lblRecordCount2.Text      = string.Format("Se encontraron {0} registros.", dataListPc.Count());

                if (objOperationResult.Success != 1)
                {
                    MessageBox.Show("Error en operación:" + System.Environment.NewLine + objOperationResult.ExceptionMessage, "ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Ejemplo n.º 12
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            OperationResult objOperationResult = new OperationResult();

            _protocolcomponentListDTO = new List <protocolcomponentDto>();

            if (uvProtocol.Validate(true, false).IsValid)
            {
                #region Validations

                if (_tmpProtocolcomponentList == null || _tmpProtocolcomponentList.Count == 0)
                {
                    MessageBox.Show("Por favor agregue Examenes al protocolo", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                #endregion

                #region En un protocolo No se debe permitir agregar un Componente que tenga un campo formula que depende de otr componente que NO está en mismo protocolo. Si esto ocurre debe decir indicar lo siguiente: "El campo formula XXXXX depende de los campos YYY, ZZZZ que están en los componentes LLLLLL, y MMMMMM. Por favor agrege previamente los componentes LLLL y MMMM al protocolo.

                OperationResult objOperationResult1 = new OperationResult();

                string[] componentIdFromProtocol = _tmpProtocolcomponentList.FindAll(p => p.i_RecordStatus != (int)RecordStatus.EliminadoLogico)
                                                   .Select(p => p.v_ComponentId).ToArray();
                foreach (var item in componentIdFromProtocol)
                {
                    SiNo IsExists__ = _protocolBL.IsExistsFormula(ref objOperationResult1, componentIdFromProtocol, item);

                    if (IsExists__ == SiNo.NO)
                    {
                        MessageBox.Show(objOperationResult1.ReturnValue, "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                }

                #endregion

                var id  = cbOrganization.SelectedValue.ToString().Split('|');
                var id1 = cbOrganizationInvoice.SelectedValue.ToString().Split('|');
                var id2 = cbIntermediaryOrganization.SelectedValue.ToString().Split('|');

                if (_protocolDTO == null)
                {
                    _protocolDTO = new protocolDto();
                }

                _protocolDTO.v_Name = txtProtocolName.Text;
                _protocolDTO.v_EmployerOrganizationId = id[0];
                _protocolDTO.v_EmployerLocationId     = id[1];
                _protocolDTO.i_EsoTypeId              = int.Parse(cbEsoType.SelectedValue.ToString());
                _protocolDTO.v_GroupOccupationId      = cbGeso.SelectedValue.ToString();
                _protocolDTO.v_CustomerOrganizationId = id1[0];
                _protocolDTO.v_CustomerLocationId     = id1[1];
                _protocolDTO.v_WorkingOrganizationId  = id2[0];
                _protocolDTO.v_WorkingLocationId      = cbIntermediaryOrganization.SelectedValue.ToString() != "-1" ? id2[1] : "-1";
                _protocolDTO.i_MasterServiceId        = int.Parse(cbService.SelectedValue.ToString());
                _protocolDTO.v_CostCenter             = txtCostCenter.Text;
                _protocolDTO.i_MasterServiceTypeId    = int.Parse(cbServiceType.SelectedValue.ToString());
                _protocolDTO.i_HasVigency             = Convert.ToInt32(chkIsHasVigency.Checked);
                _protocolDTO.i_ValidInDays            = txtValidDays.Text != string.Empty ? int.Parse(txtValidDays.Text) : (int?)null;
                _protocolDTO.i_IsActive       = Convert.ToInt32(chkIsActive.Checked);
                _protocolDTO.v_NombreVendedor = cboVendedor.Text;

                // Grabar componentes del protocolo
                if (_mode == "New" || _mode == "Clon")
                {
                    #region Validar Nombre del prorocolo

                    if (IsExistsProtocolName())
                    {
                        MessageBox.Show("Por favor Ingrese otro nombre de protocolo, este nombre ya existe", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }

                    #endregion

                    foreach (var item in _tmpProtocolcomponentList)
                    {
                        protocolcomponentDto protocolComponent = new protocolcomponentDto();

                        protocolComponent.v_ComponentId     = item.v_ComponentId;
                        protocolComponent.r_Price           = item.r_Price;
                        protocolComponent.i_OperatorId      = item.i_OperatorId;
                        protocolComponent.i_Age             = item.i_Age;
                        protocolComponent.i_GenderId        = item.i_GenderId;
                        protocolComponent.i_IsAdditional    = item.i_isAdditional;
                        protocolComponent.i_IsConditionalId = item.i_IsConditionalId;

                        protocolComponent.i_IsConditionalIMC = item.i_IsConditionalIMC;
                        protocolComponent.r_Imc = item.r_Imc;

                        _protocolcomponentListDTO.Add(protocolComponent);
                    }

                    _protocolId = _protocolBL.AddProtocol(ref objOperationResult, _protocolDTO, _protocolcomponentListDTO, Globals.ClientSession.GetAsList());

                    //Agregar Usuario Externo
                    _protocolBL.AgregarUsuarioExterno(_protocolDTO.v_CustomerOrganizationId, _protocolId, Globals.ClientSession.GetAsList());

                    if (!string.IsNullOrEmpty(_protocolId))
                    {
                        _mode         = "Edit";
                        _protocolName = txtProtocolName.Text;
                    }
                }
                else if (_mode == "Edit")
                {
                    #region Validar Nombre del prorocolo

                    if (txtProtocolName.Text != _protocolName)
                    {
                        if (IsExistsProtocolName())
                        {
                            MessageBox.Show("Por favor Ingrese otro nombre de protocolo, este nombre ya existe", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }
                    }

                    #endregion

                    _protocolDTO.v_ProtocolId = _protocolId;

                    _protocolcomponentListDTOUpdate = new List <protocolcomponentDto>();
                    _protocolcomponentListDTODelete = new List <protocolcomponentDto>();

                    foreach (var item in _tmpProtocolcomponentList)
                    {
                        // Add
                        if (item.i_RecordType == (int)RecordType.Temporal && item.i_RecordStatus == (int)RecordStatus.Agregado)
                        {
                            protocolcomponentDto protocolComponent = new protocolcomponentDto();

                            protocolComponent.v_ProtocolComponentId = item.v_ProtocolComponentId;
                            protocolComponent.v_ComponentId         = item.v_ComponentId;
                            protocolComponent.r_Price            = item.r_Price;
                            protocolComponent.i_OperatorId       = item.i_OperatorId;
                            protocolComponent.i_Age              = item.i_Age;
                            protocolComponent.i_GenderId         = item.i_GenderId;
                            protocolComponent.i_IsAdditional     = item.i_isAdditional;
                            protocolComponent.i_IsConditionalIMC = item.i_IsConditionalIMC;
                            protocolComponent.r_Imc              = item.r_Imc;

                            protocolComponent.i_IsConditionalId = item.i_IsConditionalId;
                            _protocolcomponentListDTO.Add(protocolComponent);
                        }

                        // Update
                        if (item.i_RecordType == (int)RecordType.NoTemporal && item.i_RecordStatus == (int)RecordStatus.Modificado)
                        {
                            protocolcomponentDto protocolComponent = new protocolcomponentDto();

                            protocolComponent.v_ProtocolComponentId = item.v_ProtocolComponentId;
                            protocolComponent.v_ComponentId         = item.v_ComponentId;
                            protocolComponent.r_Price            = item.r_Price;
                            protocolComponent.i_OperatorId       = item.i_OperatorId;
                            protocolComponent.i_Age              = item.i_Age;
                            protocolComponent.i_GenderId         = item.i_GenderId;
                            protocolComponent.i_IsAdditional     = item.i_isAdditional;
                            protocolComponent.i_IsConditionalIMC = item.i_IsConditionalIMC;
                            protocolComponent.r_Imc              = item.r_Imc;
                            protocolComponent.i_IsConditionalId  = item.i_IsConditionalId;
                            _protocolcomponentListDTOUpdate.Add(protocolComponent);
                        }

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

                            protocolComponent.v_ProtocolComponentId = item.v_ProtocolComponentId;
                            _protocolcomponentListDTODelete.Add(protocolComponent);
                        }
                    }
                    _protocolBL.UpdateProtocol(ref objOperationResult,
                                               _protocolDTO,
                                               _protocolcomponentListDTO,
                                               _protocolcomponentListDTOUpdate.Count == 0 ? null : _protocolcomponentListDTOUpdate,
                                               _protocolcomponentListDTODelete.Count == 0 ? null : _protocolcomponentListDTODelete,
                                               Globals.ClientSession.GetAsList());
                }

                // Analizar el resultado de la operación
                if (objOperationResult.Success == 1)  // Operación sin error
                {
                    //this.DialogResult = DialogResult.OK;
                    MessageBox.Show("Se grabo correctamente.", "INFORMACION!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    _mode = "Edit";
                    LoadData();
                    //this.Close();
                }
                else  // Operación con error
                {
                    MessageBox.Show(Constants.GenericErrorMessage, "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);
            }
        }
Ejemplo n.º 13
0
        public static void CreateTicket(string filePDF,
                                        organizationDto infoEmpresaPropietaria, List <TicketDetalleList> detalleTicket,
                                        PacientList datosPac, hospitalizacionDto hospit,
                                        hospitalizacionhabitacionDto hospitHabit, MedicoTratanteAtenciones medico, ticketDto ticket, protocolDto protocolo)
        {
            Document document = new Document(PageSize.A4, 30f, 30f, 45f, 41f);

            document.SetPageSize(iTextSharp.text.PageSize.A4);

            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(filePDF, FileMode.Create));
            pdfPage   page   = new pdfPage();

            writer.PageEvent = page;
            document.Open();

            #region Declaration Tables
            var             subTitleBackGroundColor = new BaseColor(System.Drawing.Color.Gray);
            string          include       = string.Empty;
            List <PdfPCell> cells         = null;
            float[]         columnWidths  = null;
            string[]        columnValues  = null;
            string[]        columnHeaders = null;
            PdfPTable       header2       = new PdfPTable(6);
            header2.HorizontalAlignment = Element.ALIGN_CENTER;
            header2.WidthPercentage     = 100;
            float[] widths1 = new float[] { 16.6f, 18.6f, 16.6f, 16.6f, 16.6f, 16.6f };
            header2.SetWidths(widths1);
            PdfPTable companyData = new PdfPTable(6);
            companyData.HorizontalAlignment = Element.ALIGN_CENTER;
            companyData.WidthPercentage     = 100;
            float[] widthscolumnsCompanyData = new float[] { 16.6f, 16.6f, 16.6f, 16.6f, 16.6f, 16.6f };
            companyData.SetWidths(widthscolumnsCompanyData);
            PdfPTable filiationWorker = new PdfPTable(4);
            PdfPTable table           = null;
            PdfPCell  cell            = null;
            document.Add(new Paragraph("\r\n"));
            #endregion

            #region Fonts
            Font fontTitle1               = FontFactory.GetFont("Calibri", 10, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitle2               = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTable           = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTableNegro      = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontSubTitle             = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.White));
            Font fontSubTitleNegroNegrita = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            Font fontColumnValue         = FontFactory.GetFont("Calibri", 8, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValue1        = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueBold     = FontFactory.GetFont("Calibri", 8, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueBold1    = FontFactory.GetFont("Calibri", 9, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueApendice = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            #endregion

            #region TÍTULO

            cells = new List <PdfPCell>();

            if (infoEmpresaPropietaria.b_Image != null)
            {
                iTextSharp.text.Image imagenEmpresa = iTextSharp.text.Image.GetInstance(HandlingItextSharp.GetImage(infoEmpresaPropietaria.b_Image));
                imagenEmpresa.ScalePercent(25);
                imagenEmpresa.SetAbsolutePosition(40, 790);
                document.Add(imagenEmpresa);
            }
            //iTextSharp.text.Image imagenMinsa = iTextSharp.text.Image.GetInstance("C:/Banner/Minsa.png");
            //imagenMinsa.ScalePercent(10);
            //imagenMinsa.SetAbsolutePosition(400, 785);
            //document.Add(imagenMinsa);
            var tamaño_celda = 15f;
            var cellsTit     = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("TICKET " + ticket.v_TicketId, fontTitle1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 20f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
            };
            columnWidths = new float[] { 100f };
            table        = HandlingItextSharp.GenerateTableFromCells(cellsTit, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion
            #region DATOS
            string titular = "";
            if (datosPac.v_OwnerName == "")
            {
                titular = datosPac.v_FirstName + " " + datosPac.v_FirstLastName + " " + datosPac.v_SecondLastName;
            }
            else
            {
                titular = datosPac.v_OwnerName;
            }
            string n_habitac = "";
            if (hospitHabit.i_HabitacionId == 1)
            {
                n_habitac = "201";
            }
            else if (hospitHabit.i_HabitacionId == 2)
            {
                n_habitac = "202";
            }
            else if (hospitHabit.i_HabitacionId == 3)
            {
                n_habitac = "203";
            }
            else if (hospitHabit.i_HabitacionId == 4)
            {
                n_habitac = "204";
            }
            else if (hospitHabit.i_HabitacionId == 5)
            {
                n_habitac = "205";
            }
            else if (hospitHabit.i_HabitacionId == 6)
            {
                n_habitac = "206";
            }
            else if (hospitHabit.i_HabitacionId == 7)
            {
                n_habitac = "207";
            }
            else if (hospitHabit.i_HabitacionId == 8)
            {
                n_habitac = "208";
            }
            else if (hospitHabit.i_HabitacionId == 9)
            {
                n_habitac = "301";
            }
            else if (hospitHabit.i_HabitacionId == 10)
            {
                n_habitac = "302";
            }
            else if (hospitHabit.i_HabitacionId == 11)
            {
                n_habitac = "303";
            }
            else if (hospitHabit.i_HabitacionId == 12)
            {
                n_habitac = "304";
            }
            else if (hospitHabit.i_HabitacionId == 13)
            {
                n_habitac = "305";
            }
            else if (hospitHabit.i_HabitacionId == 14)
            {
                n_habitac = "306";
            }
            else if (hospitHabit.i_HabitacionId == 15)
            {
                n_habitac = "307";
            }
            else if (hospitHabit.i_HabitacionId == 16)
            {
                n_habitac = "308";
            }
            else
            {
                n_habitac = "- - -";
            }
            string med = "";

            if (medico != null)
            {
                med = medico.Nombre;
            }
            else
            {
                med = "CLINICA SAN LORENZO";
            }
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("SERViCIO: ", fontColumnValueBold))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase(protocolo.v_Name, fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("CÓDIGO INTERNO: ", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase(hospitHabit.v_HopitalizacionId, fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },

                new PdfPCell(new Phrase("PACIENTE: ", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(datosPac.v_FirstName + " " + datosPac.v_FirstLastName + " " + datosPac.v_SecondLastName, fontColumnValue))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("TITULAR: ", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(titular, fontColumnValue))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("HIST. CLINICA : ", fontColumnValueBold))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(datosPac.v_DocNumber, fontColumnValueBold1))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("CAMA : ", fontColumnValueBold))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(n_habitac, fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("EMPRESA: ", fontColumnValueBold))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(datosPac.v_Employer, fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("INGRESO :", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(hospit.d_FechaIngreso.ToString() == null?"":hospit.d_FechaIngreso.ToString().Split(' ')[0], fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },


                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("MEDICO A CARGO: ", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(med, fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 6, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 5f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
            };
            columnWidths = new float[] { 15f, 30f, 15f, 15f, 10F, 15F };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion
            #region DATOS
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("DETALLE", fontColumnValueBold))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                },

                new PdfPCell(new Phrase("FECHA", fontColumnValueBold))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("TICKET", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("NOMBRE", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("CANT", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                },
            };
            columnWidths = new float[] { 12f, 12f, 66f, 10f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion


            #region Parte Dinámica
            cells = new List <PdfPCell>();
            int    tamañoTickets = 0;
            string enfermera     = "";
            if (detalleTicket != null)
            {
                var detalletickets = detalleTicket.FindAll(p => p.d_Cantidad != 0);
                tamañoTickets = detalletickets.Count();

                cell = new PdfPCell(new Phrase(ticket.d_Fecha.ToString().Split(' ')[0], fontColumnValue))
                {
                    Rowspan = tamañoTickets, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE, MinimumHeight = 15f
                };
                cells.Add(cell);

                cell = new PdfPCell(new Phrase(ticket.i_TipoCuentaId.ToString() == "1" ? "\nSOP" : ticket.i_TipoCuentaId.ToString() == "2" ? "\nPROC - SOP" : ticket.i_TipoCuentaId.ToString() == "3" ? "\nHOSP" : ticket.i_TipoCuentaId.ToString() == "4" ? "\nI. SERV." : string.Empty, fontColumnValue))
                {
                    Rowspan = tamañoTickets, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE, MinimumHeight = 15f
                };
                cells.Add(cell);

                foreach (var item in detalleTicket)
                {
                    cell = new PdfPCell(new Phrase(item.v_Descripcion, fontColumnValue))
                    {
                        HorizontalAlignment = PdfPCell.ALIGN_LEFT, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE, MinimumHeight = 15f
                    };
                    cells.Add(cell);
                    int cantidad = (int)item.d_Cantidad;
                    cell = new PdfPCell(new Phrase(cantidad.ToString(), fontColumnValue))
                    {
                        HorizontalAlignment = PdfPCell.ALIGN_CENTER, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE, MinimumHeight = 15f
                    };
                    cells.Add(cell);
                    enfermera = item.UsuarioCrea;
                }
            }
            columnWidths = new float[] { 12f, 12f, 66f, 10f };

            filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, "", fontTitleTable);

            document.Add(filiationWorker);
            #endregion

            #region Enfermera
            cells = new List <PdfPCell>();

            cell = new PdfPCell(new Phrase("Enfermera: ", fontColumnValue))
            {
                HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, MinimumHeight = 25f
            };
            cells.Add(cell);
            cell = new PdfPCell(new Phrase(enfermera, fontColumnValueBold))
            {
                Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, MinimumHeight = 25f
            };
            cells.Add(cell);


            cell = new PdfPCell(new Phrase("", fontColumnValue))
            {
                Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, MinimumHeight = 50f
            };
            cells.Add(cell);


            cell = new PdfPCell(new Phrase("", fontColumnValue))
            {
                HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, MinimumHeight = 13f
            };
            cells.Add(cell);
            cell = new PdfPCell(new Phrase("_______________________________________", fontColumnValue))
            {
                HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, MinimumHeight = 13f
            };
            cells.Add(cell);
            cell = new PdfPCell(new Phrase("", fontColumnValue))
            {
                HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, MinimumHeight = 13f
            };
            cells.Add(cell);
            cell = new PdfPCell(new Phrase("_______________________________________", fontColumnValue))
            {
                HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, MinimumHeight = 13f
            };
            cells.Add(cell);
            cell = new PdfPCell(new Phrase("", fontColumnValue))
            {
                HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, MinimumHeight = 13f
            };
            cells.Add(cell);

            cell = new PdfPCell(new Phrase("", fontColumnValue))
            {
                HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, MinimumHeight = 13f
            };
            cells.Add(cell);
            cell = new PdfPCell(new Phrase("FARMACIA", fontColumnValue1))
            {
                HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, MinimumHeight = 13f
            };
            cells.Add(cell);
            cell = new PdfPCell(new Phrase("", fontColumnValue))
            {
                HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, MinimumHeight = 13f
            };
            cells.Add(cell);
            cell = new PdfPCell(new Phrase("PACIENTE: " + datosPac.v_FirstLastName + " " + datosPac.v_SecondLastName + ", " + datosPac.v_FirstName + "\nDNI: " + datosPac.v_DocNumber, fontColumnValue1))
            {
                HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, MinimumHeight = 13f
            };
            cells.Add(cell);
            cell = new PdfPCell(new Phrase("", fontColumnValue))
            {
                HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, MinimumHeight = 13f
            };
            cells.Add(cell);



            cell = new PdfPCell(new Phrase("", fontColumnValue))
            {
                Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, MinimumHeight = 30f
            };
            cells.Add(cell);

            columnWidths = new float[] { 10f, 34f, 12f, 34f, 10f };

            filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, "", fontTitleTable);

            document.Add(filiationWorker);
            #endregion
            document.Close();
            writer.Close();
            writer.Dispose();
            RunFile(filePDF);
        }
Ejemplo n.º 14
0
        private void LoadData()
        {
            OperationResult objOperationResult = new OperationResult();
            string          Mode = Request.QueryString["Mode"].ToString();

            if (Mode == "New")
            {
                Session["ListaCompletaComponentes"] = null;
                BindGridNew();
            }
            else if (Mode == "Edit")
            {
                string ProtocolId = null;
                string idOrgInter = "-1";

                if (Request.QueryString["v_ProtocolId"] != null)
                {
                    ProtocolId = Request.QueryString["v_ProtocolId"].ToString();
                }
                Session["ProtocolId"] = ProtocolId;
                _protocolDTO          = _protocolBL.GetProtocol(ref objOperationResult, ProtocolId);

                // cabecera del protocolo
                txtProtocolName.Text         = _protocolDTO.v_Name;
                cbEsoType.SelectedValue      = _protocolDTO.i_EsoTypeId.ToString();
                cbOrganization.SelectedValue = string.Format("{0}|{1}", _protocolDTO.v_EmployerOrganizationId, _protocolDTO.v_EmployerLocationId);


                if (_protocolDTO.v_WorkingOrganizationId != "-1" && _protocolDTO.v_WorkingLocationId != "-1")
                {
                    idOrgInter = string.Format("{0}|{1}", _protocolDTO.v_WorkingOrganizationId, _protocolDTO.v_WorkingLocationId);
                }

                cbIntermediaryOrganization.SelectedValue = idOrgInter;
                cbOrganizationInvoice.SelectedValue      = string.Format("{0}|{1}", _protocolDTO.v_CustomerOrganizationId, _protocolDTO.v_CustomerLocationId);

                LoadcbGESO();
                cbGeso.SelectedValue        = _protocolDTO.v_GroupOccupationId;
                cbServiceType.SelectedValue = _protocolDTO.i_MasterServiceTypeId.ToString();
                LoadcbServiceType();
                cbService.SelectedValue = _protocolDTO.i_MasterServiceId.ToString();
                txtCostCenter.Text      = _protocolDTO.v_CostCenter;

                // Componentes del protocolo
                var dataListPc = _protocolBL.GetProtocolComponents(ref objOperationResult, ProtocolId);
                dataListPc.Sort((y, x) => x.v_CategoryName.CompareTo(y.v_CategoryName));
                //Obtener Lista Completa de Componentes

                var ListaCompletaComponentes = GetData(grdData.PageIndex, grdData.PageSize, "v_CategoryName,v_Name,AtSchool", "");
                ListaCompletaComponentes.Sort((y, x) => x.v_CategoryName.CompareTo(y.v_CategoryName));

                foreach (var Componentes in ListaCompletaComponentes)
                {
                    foreach (var ProtocoloComponente in dataListPc)
                    {
                        if (ProtocoloComponente.v_ComponentId == Componentes.v_ComponentId)
                        {
                            Componentes.AtSchool     = true;
                            Componentes.r_Price      = ProtocoloComponente.r_Price;
                            Componentes.Adicional    = ProtocoloComponente.i_isAdditional == 0 ? false : true;
                            Componentes.Condicional  = ProtocoloComponente.i_IsConditionalId == 0 ? false : true;
                            Componentes.i_OperatorId = int.Parse(ProtocoloComponente.i_OperatorId.ToString());
                            Componentes.i_Age        = ProtocoloComponente.i_Age;
                            Componentes.i_GenderId   = int.Parse(ProtocoloComponente.i_GenderId.ToString());
                            //System.Web.UI.WebControls.DropDownList ddlGender = (System.Web.UI.WebControls.DropDownList)row.FindControl("ddlGender");
                            //Componentes.
                        }
                    }
                }
                // obligatorio para que los controles se dibujen en orden adecuado

                ListaCompletaComponentes.Sort((y, x) => x.AtSchool.CompareTo(y.AtSchool));

                Session["ListaCompletaComponentes"] = ListaCompletaComponentes;
                grdData.DataSource = ListaCompletaComponentes;
                grdData.DataBind();
            }
        }
Ejemplo n.º 15
0
        protected void btnSaveRefresh_Click(object sender, EventArgs e)
        {
            string          Mode = Request.QueryString["Mode"].ToString();
            OperationResult objOperationResult = new OperationResult();

            _protocolcomponentListDTO = new List <protocolcomponentDto>();

            _protocolDTO = new protocolDto();
            var id  = cbOrganization.SelectedValue.ToString().Split('|');
            var id1 = cbOrganizationInvoice.SelectedValue.ToString().Split('|');
            var id2 = cbIntermediaryOrganization.SelectedValue.ToString().Split('|');

            _protocolDTO.v_Name = txtProtocolName.Text;
            _protocolDTO.v_EmployerOrganizationId = id[0];
            _protocolDTO.v_EmployerLocationId     = id[1];
            _protocolDTO.i_EsoTypeId              = int.Parse(cbEsoType.SelectedValue.ToString());
            _protocolDTO.v_GroupOccupationId      = cbGeso.SelectedValue.ToString();
            _protocolDTO.v_CustomerOrganizationId = id1[0];
            _protocolDTO.v_CustomerLocationId     = id1[1];
            _protocolDTO.v_WorkingOrganizationId  = id2[0];
            _protocolDTO.v_WorkingLocationId      = cbIntermediaryOrganization.SelectedValue.ToString() != "-1" ? id2[1] : "-1";
            _protocolDTO.i_MasterServiceId        = int.Parse(cbService.SelectedValue.ToString());
            _protocolDTO.v_CostCenter             = txtCostCenter.Text;
            _protocolDTO.i_MasterServiceTypeId    = int.Parse(cbServiceType.SelectedValue.ToString());
            _protocolDTO.i_HasVigency             = 0;
            _protocolDTO.i_ValidInDays            = 0;
            _protocolDTO.i_IsActive       = 1;
            _protocolDTO.v_NombreVendedor = "";

            if (Mode == "New")
            {
                if (IsExistsProtocolName())
                {
                    Alert.Show("Este protocolo ya existe");
                    return;
                }

                CheckBoxField field1 = (CheckBoxField)grdData.FindColumn("CheckBoxField2");

                for (int i = 0; i < grdData.Rows.Count; i++)
                {
                    if (field1.GetCheckedState(i) == true)
                    {
                        _protocolDTO.v_ProtocolId = null;
                        GridRow row = grdData.Rows[i];
                        System.Web.UI.WebControls.TextBox txtPrice = (System.Web.UI.WebControls.TextBox)row.FindControl("r_Price");


                        protocolcomponentDto protocolComponent = new protocolcomponentDto();

                        protocolComponent.v_ComponentId = grdData.Rows[i].Values[5];
                        protocolComponent.r_Price       = float.Parse(txtPrice.Text.ToString());// float.Parse(grdData.Rows[i].Values[4].ToString());
                        //protocolComponent.i_OperatorId = -1;
                        //protocolComponent.i_Age = 0;
                        //protocolComponent.i_GenderId = 3;
                        //protocolComponent.i_IsAdditional = 0;
                        //protocolComponent.i_IsConditionalId =0;
                        System.Web.UI.WebControls.TextBox txtEdad = (System.Web.UI.WebControls.TextBox)row.FindControl("i_Age");
                        CheckBoxField fieldAdicional   = (CheckBoxField)grdData.FindColumn("CheckBoxField3");
                        bool          ChecAdicional    = fieldAdicional.GetCheckedState(i);
                        CheckBoxField fieldCondicional = (CheckBoxField)grdData.FindColumn("CheckBoxField4");
                        bool          ChecCondicional  = fieldCondicional.GetCheckedState(i);

                        protocolComponent.i_Age             = int.Parse(txtEdad.Text.ToString());
                        protocolComponent.i_IsAdditional    = ChecAdicional == true ? 1 : 0;
                        protocolComponent.i_IsConditionalId = ChecCondicional == true ? 1 : 0;

                        System.Web.UI.WebControls.DropDownList ddlOperador = (System.Web.UI.WebControls.DropDownList)grdData.Rows[i].FindControl("ddlOperador");
                        System.Web.UI.WebControls.DropDownList ddlGender   = (System.Web.UI.WebControls.DropDownList)grdData.Rows[i].FindControl("ddlGender");



                        protocolComponent.i_GenderId   = int.Parse(ddlGender.SelectedValue.ToString());
                        protocolComponent.i_OperatorId = int.Parse(ddlOperador.SelectedValue.ToString());

                        protocolComponent.i_IsConditionalIMC = 0;
                        protocolComponent.r_Imc = 0;

                        _protocolcomponentListDTO.Add(protocolComponent);
                    }
                }

                _protocolBL.AddProtocol(ref objOperationResult, _protocolDTO, _protocolcomponentListDTO, ((ClientSession)Session["objClientSession"]).GetAsList());
            }
            else if (Mode == "Edit")
            {
                _protocolDTO.v_ProtocolId = Session["ProtocolId"].ToString();
                //Eliminar Fisicamente registros de protocolcomponent
                _protocolBL.EliminarProtocolComponentByProtocolId(ref objOperationResult, Session["ProtocolId"].ToString());

                //Grabar de nuevo la entidad
                CheckBoxField field1 = (CheckBoxField)grdData.FindColumn("CheckBoxField2");

                for (int i = 0; i < grdData.Rows.Count; i++)
                {
                    if (field1.GetCheckedState(i) == true)
                    {
                        protocolcomponentDto protocolComponent = new protocolcomponentDto();
                        GridRow row = grdData.Rows[i];

                        System.Web.UI.WebControls.TextBox txtPrice = (System.Web.UI.WebControls.TextBox)row.FindControl("r_Price");
                        System.Web.UI.WebControls.TextBox txtEdad  = (System.Web.UI.WebControls.TextBox)row.FindControl("i_Age");
                        CheckBoxField fieldAdicional   = (CheckBoxField)grdData.FindColumn("CheckBoxField3");
                        bool          ChecAdicional    = fieldAdicional.GetCheckedState(i);
                        CheckBoxField fieldCondicional = (CheckBoxField)grdData.FindColumn("CheckBoxField4");
                        bool          ChecCondicional  = fieldCondicional.GetCheckedState(i);

                        System.Web.UI.WebControls.DropDownList ddlOperador = (System.Web.UI.WebControls.DropDownList)grdData.Rows[i].FindControl("ddlOperador");
                        System.Web.UI.WebControls.DropDownList ddlGender   = (System.Web.UI.WebControls.DropDownList)grdData.Rows[i].FindControl("ddlGender");



                        protocolComponent.v_ComponentId     = grdData.Rows[i].Values[5];
                        protocolComponent.r_Price           = float.Parse(txtPrice.Text.ToString());
                        protocolComponent.i_Age             = int.Parse(txtEdad.Text.ToString());
                        protocolComponent.i_IsAdditional    = ChecAdicional == true ? 1:0;
                        protocolComponent.i_IsConditionalId = ChecCondicional == true ? 1 : 0;



                        protocolComponent.i_GenderId   = int.Parse(ddlGender.SelectedValue.ToString());
                        protocolComponent.i_OperatorId = int.Parse(ddlOperador.SelectedValue.ToString());


                        protocolComponent.i_IsConditionalIMC = 0;
                        protocolComponent.r_Imc = 0;

                        _protocolcomponentListDTO.Add(protocolComponent);
                    }
                }

                _protocolBL.AddProtocol(ref objOperationResult, _protocolDTO, _protocolcomponentListDTO, ((ClientSession)Session["objClientSession"]).GetAsList());
            }
            //Analizar el resultado de la operación
            if (objOperationResult.Success == 1)  // Operación sin error
            {
                // Cerrar página actual y hacer postback en el padre para actualizar
                PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
            }
            else  // Operación con error
            {
                Alert.ShowInTop("Error en operación:" + System.Environment.NewLine + objOperationResult.ExceptionMessage);
                // Se queda en el formulario.
            }
        }