Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            MedicalExamFieldValuesBL _objMedicalExamFieldValuesBL = new MedicalExamFieldValuesBL();
            OperationResult          objOperationResult           = new OperationResult();
            // Obtener los IDs de la fila seleccionada

            DialogResult Result = MessageBox.Show("¿Está seguro de eliminar este registro?:" + System.Environment.NewLine + objOperationResult.ExceptionMessage, "¡ADVERTENCIA!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (Result == System.Windows.Forms.DialogResult.Yes)
            {
                // Delete the item
                //Buscar si el componente C está en un protocolo P.Si está en un protocolo -> NO SE PUEDE ELIMINAR EL CAMPO X.En cualquier otro caso -> EL CAMPO X SE PUEDE ELIMINAR.
                ProtocolBL objProtocolBL = new ProtocolBL();

                if (objProtocolBL.ValidateComponentElimination(ref objOperationResult, strMedicalExamId) == true)
                {
                    MessageBox.Show("Este registro no se puede eliminar porque está referenciado en un protocolo.", "¡ADVERTENCIA!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                string strMedicalExamFieldId = grdDataMedicalExamFields.Selected.Rows[0].Cells[0].Value.ToString();

                var _objData = _objMedicalExamFieldValuesBL.GetMedicalExamFieldValuesPagedAndFiltered(ref objOperationResult, 0, null, "", "v_MedicalExamFieldsId ==" + "\"" + strMedicalExamFieldId + "\"");
                if (_objData.Count > 0)
                {
                    MessageBox.Show("Este registro no se puede eliminar porque tiene campos registrados.", "¡ADVERTENCIA!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    _objMedicalExamFieldsBL.DeleteMedicalExamFields(ref objOperationResult, strMedicalExamId, strMedicalExamFieldId, Globals.ClientSession.GetAsList());

                    BindGridMedicalExamFields(strMedicalExamId);
                }
            }
        }
Ejemplo n.º 2
0
        private void mnuGridDeleteMedicalExam_Click(object sender, EventArgs e)
        {
            OperationResult objOperationResult = new OperationResult();
            // Obtener los IDs de la fila seleccionada

            DialogResult Result = MessageBox.Show("¿Está seguro de eliminar este registro?:" + System.Environment.NewLine + objOperationResult.ExceptionMessage, "¡ADVERTENCIA!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (Result == System.Windows.Forms.DialogResult.Yes)
            {
                //Buscar si el componente C está en un protocolo P. Si está en un protocolo P, NO SE PUEDE ELIMINAR EL COMPONENTE C. En cualquier otro caso -> EL COMPONENTE C SE PUEDE ELIMINAR.
                ProtocolBL objProtocolBL = new ProtocolBL();

                if (objProtocolBL.ValidateComponentElimination(ref objOperationResult, strMedicalExamId) == true)
                {
                    MessageBox.Show("Este registro no se puede eliminar porque está referenciado en un protocolo.", "¡ADVERTENCIA!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                var _objData = _objMedicalExamFieldsBL.GetMedicalExamFieldsPagedAndFiltered(ref objOperationResult, 0, null, "", "v_ComponentId ==" + "\"" + strMedicalExamId + "\"");

                if (_objData.Count > 0)
                {
                    MessageBox.Show("Este registro no se puede eliminar porque tiene campos registrados.", "¡ADVERTENCIA!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    _objMedicalExamBL.DeleteMedicalExam(ref objOperationResult, strMedicalExamId, Globals.ClientSession.GetAsList());
                    btnFilter_Click(sender, e);
                }
            }
        }