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);
            }
        }
        private bool Process(string personId, string protocolId)
        {
            try
            {
                var oprotocolDto = _protocolBl.GetProtocol(ref _operationResult, protocolId);
                var opersonDto   = _pacientBl.GetPerson(ref _operationResult, personId);

                _protocolDtos.Add(oprotocolDto);
                _personDtos.Add(opersonDto);

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
        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 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);
                }
            }
        }
        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();
            }
        }