コード例 #1
0
        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()));
        }
コード例 #2
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());
        }
コード例 #3
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);
            }
        }
コード例 #4
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.
            }
        }