public static EstadoOperacion eliminarValidacionCampo(VALIDACION_CAMPO vcampo)
        {
            DbFactory Factoria = DataAccessFactory.ObtenerProveedor();
            try
            {
                using (Switch contexto = new Switch())
                {
                    using (contexto.CreateConeccionScope())
                    {
                        string query = "DELETE FROM [VALIDACON_CAMPO] " +
                                       "WHERE [VLC_CODIGO] = @codigo";

                        DbCommand Comando = contexto.CreateCommand(query, CommandType.Text);
                        Comando.Parameters.Add(Factoria.CrearParametro("@codigo", vcampo.VLC_CODIGO));

                        if (Comando.ExecuteNonQuery() != 1)
                        {
                            return new EstadoOperacion(false, null, null);
                        }

                        return new EstadoOperacion(true, null, null);
                    }
                }
            }
            catch (Exception e)
            {
                return new EstadoOperacion(false, e.Message, e);
            }
        }
 public bool Validar(VALIDACION_CAMPO vcampo, Valor valor)
 {
     bool pasaValidacion;
     switch (vcampo.VLC_INCLUSION_EXCLUSION)
     {
         case (int)EnumCriterioAplicacion.Inclusion:
             pasaValidacion = vcampo.VLC_CONDICION != null ? EvaluarInclusionPorCondicion((int)vcampo.VLC_CONDICION, vcampo.VLC_VALOR, valor) :
                                                             EvaluarInclusionPorTabla(vcampo.TABLA.TBL_NOMBRE, vcampo.COLUMNA.COL_NOMBRE, valor);
             break;
         case (int)EnumCriterioAplicacion.Procedimiento:
             pasaValidacion = EvaluarProcedimiento(vcampo.VLC_PROCEDIMIENTO, valor);
             break;
         case (int)EnumCriterioAplicacion.Componente:
             pasaValidacion = EvaluarComponente(vcampo.VLC_COMPONENTE, vcampo.VLC_CLASE, vcampo.VLC_METODO, valor);
             break;
         default:
             pasaValidacion = false;
             break;
     }
     return pasaValidacion;
 }
        protected void btnAceptar_Click(object sender, EventArgs e)
        {
            VALIDACION_CAMPO vcampo = new VALIDACION_CAMPO();
            vcampo.GRV_CODIGO = Convert.ToInt32(Request.QueryString["codigo"]);
            vcampo.MEN_CODIGO = Convert.ToInt32(Request.QueryString["mensaje"]);
            vcampo.CAM_CODIGO = Convert.ToInt32(Request.QueryString["campo"]);
            int criterio = Convert.ToInt32(ddlCriterio.SelectedValue);
            vcampo.VLC_INCLUSION_EXCLUSION = criterio;
            if (criterio == BusinessLayer.Mensajeria.ValidacionCampoBL.obtenerCriterioAplicacionInclusion())
            {
                //Inclusión o Exclusión
                int tipoRegla = Convert.ToInt32(ddlTipoRegla.SelectedValue);
                if (tipoRegla == BusinessLayer.Mensajeria.ValidacionCampoBL.obtenerTipoReglaCondicion())
                {
                    //Condición
                    vcampo.VLC_CONDICION = Convert.ToInt32(ddlCondicion.SelectedValue);
                    vcampo.VLC_VALOR = txtValorComparacion.Text;
                }
                else
                {
                    //Tabla de valores
                    //TABLA tabla = BusinessLayer.Mensajeria.TablaBL.obtenerTablaPorCodigo();
                    vcampo.TABLA = new TABLA() { TBL_CODIGO = Convert.ToInt32(ddlNombreTabla.SelectedValue) };
                    //COLUMNA columna = BusinessLayer.Mensajeria.ColumnaBL.obtenerColumnaPorCodigo(Convert.ToInt32(ddlNombreTabla.SelectedValue));
                    vcampo.COLUMNA = new COLUMNA() { COL_CODIGO = Convert.ToInt32(ddlNombreTabla.SelectedValue) };
                }
            }
            else
            {
                //Especial
                vcampo.VLC_PROCEDIMIENTO = txtProcedure.Text;
            }

            BusinessLayer.Mensajeria.ValidacionCampoBL.insertarValidacionCampo(vcampo);

            Response.Redirect("ConsultarDetalleReglasValidacion.aspx?codigo=" + Request.QueryString["codigo"] + "&grupo=" + Request.QueryString["grupo"] + "&mensaje=" + Request.QueryString["mensaje"] + "&campo=" + Request.QueryString["campo"]);
        }
        public static EstadoOperacion insertarValidacionCampo(VALIDACION_CAMPO vcampo)
        {
            try
            {
                using (Switch contexto = new Switch())
                {
                    using (contexto.CreateConeccionScope())
                    {
                        int idValidacionCampo = (from c in contexto.VALIDACION_CAMPO
                                                 orderby c.VLC_CODIGO descending
                                                 select c.VLC_CODIGO).FirstOrDefault() + 1;
                        vcampo.VLC_CODIGO = idValidacionCampo;

                        string insert = "INSERT INTO [VALIDACION_CAMPO]" +
                                        "([VLC_CODIGO]" +
                                        ",[GRV_CODIGO]" +
                                        ",[MEN_CODIGO]" +
                                        ",[CAM_CODIGO]" +
                                        ",[VLC_INCLUSION_EXCLUSION]" +
                                        ",[VLC_CONDICION]" +
                                        ",[VLC_VALOR]" +
                                        ",[TBL_CODIGO]" +
                                        ",[COL_CODIGO]" +
                                        ",[VLC_PROCEDIMIENTO])" +
                                        " VALUES(@codigo,@grupo,@mensaje,@campo,@incexc,@condicion,@valor,@tabla,@columna,@procedimiento)";

                        SqlCommand ComandoInsert = (SqlCommand)contexto.CreateCommand(insert, CommandType.Text);

                        ComandoInsert.Parameters.Add(new SqlParameter("@codigo", vcampo.VLC_CODIGO));
                        ComandoInsert.Parameters.Add(new SqlParameter("@grupo", vcampo.GRV_CODIGO));
                        ComandoInsert.Parameters.Add(new SqlParameter("@mensaje", vcampo.MEN_CODIGO));
                        ComandoInsert.Parameters.Add(new SqlParameter("@campo", vcampo.CAM_CODIGO));
                        ComandoInsert.Parameters.Add(new SqlParameter("@incexc", vcampo.VLC_INCLUSION_EXCLUSION));
                        if (vcampo.VLC_CONDICION != null)
                            ComandoInsert.Parameters.Add(new SqlParameter("@condicion", vcampo.VLC_CONDICION));
                        else
                            ComandoInsert.Parameters.Add(new SqlParameter("@condicion", DBNull.Value));
                        if (vcampo.VLC_VALOR != null)
                            ComandoInsert.Parameters.Add(new SqlParameter("@valor", vcampo.VLC_VALOR));
                        else
                            ComandoInsert.Parameters.Add(new SqlParameter("@valor", DBNull.Value));
                        if (vcampo.TABLA != null)
                            ComandoInsert.Parameters.Add(new SqlParameter("@tabla", vcampo.TABLA.TBL_CODIGO));
                        else
                            ComandoInsert.Parameters.Add(new SqlParameter("@tabla", DBNull.Value));
                        if (vcampo.COLUMNA != null)
                            ComandoInsert.Parameters.Add(new SqlParameter("@columna", vcampo.COLUMNA.COL_CODIGO));
                        else
                            ComandoInsert.Parameters.Add(new SqlParameter("@columna", DBNull.Value));
                        if (vcampo.VLC_PROCEDIMIENTO != null)
                            ComandoInsert.Parameters.Add(new SqlParameter("@procedimiento", vcampo.VLC_PROCEDIMIENTO));
                        else
                            ComandoInsert.Parameters.Add(new SqlParameter("@procedimiento", DBNull.Value));

                        if (ComandoInsert.ExecuteNonQuery() != 1)
                        {
                            return new EstadoOperacion(false, null, null);
                        }

                        return new EstadoOperacion(true, null, null);
                    }
                }
            }
            catch (Exception e)
            {
                return new EstadoOperacion(false, e.Message, e);
            }
        }
        public static EstadoOperacion modificarValidacionCampo(VALIDACION_CAMPO vcampo)
        {
            DbFactory Factoria = DataAccessFactory.ObtenerProveedor();
            try
            {
                using (Switch contexto = new Switch())
                {
                    using (contexto.CreateConeccionScope())
                    {
                        string query =
                            "UPDATE [VALIDACION_CAMPO]" +
                            "SET [VLC_INCLUSION_EXCLUSION] = @incexc" +
                            ",[VLC_CONDICION] = @condicion" +
                            ",[VLC_VALOR] = @valor" +
                            ",[TBL_CODIGO] = @tabla" +
                            ",[COL_CODIGO] = @columna" +
                            ",[VLC_PROCEDIMIENTO] = @procedimiento" +
                            " WHERE [VLC_CODIGO] = @codigo;";

                        DbCommand Comando = contexto.CreateCommand(query, CommandType.Text);

                        Comando.Parameters.Add(Factoria.CrearParametro("@codigo", vcampo.VLC_CODIGO));
                        Comando.Parameters.Add(Factoria.CrearParametro("@incexc", vcampo.VLC_INCLUSION_EXCLUSION));
                        if (vcampo.VLC_CONDICION != null)
                            Comando.Parameters.Add(Factoria.CrearParametro("@condicion", vcampo.VLC_CONDICION));
                        else
                            Comando.Parameters.Add(Factoria.CrearParametro("@condicion", DBNull.Value));
                        if (vcampo.VLC_VALOR != null)
                            Comando.Parameters.Add(Factoria.CrearParametro("@valor", vcampo.VLC_VALOR));
                        else
                            Comando.Parameters.Add(Factoria.CrearParametro("@valor", DBNull.Value));
                        if (vcampo.TABLA != null)
                            Comando.Parameters.Add(Factoria.CrearParametro("@tabla", vcampo.TABLA.TBL_CODIGO));
                        else
                            Comando.Parameters.Add(Factoria.CrearParametro("@tabla", DBNull.Value));
                        if (vcampo.COLUMNA != null)
                            Comando.Parameters.Add(Factoria.CrearParametro("@columna", vcampo.COLUMNA.COL_CODIGO));
                        else
                            Comando.Parameters.Add(Factoria.CrearParametro("@columna", DBNull.Value));
                        if (vcampo.VLC_PROCEDIMIENTO != null)
                            Comando.Parameters.Add(Factoria.CrearParametro("@procedimiento", vcampo.VLC_PROCEDIMIENTO));
                        else
                            Comando.Parameters.Add(Factoria.CrearParametro("@procedimiento", DBNull.Value));

                        if (Comando.ExecuteNonQuery() != 1)
                        {
                            return new EstadoOperacion(false, null, null);
                        }

                        return new EstadoOperacion(true, null, null);
                    }
                }
            }
            catch (Exception e)
            {
                return new EstadoOperacion(false, e.Message, e);
            }
        }
 public static EstadoOperacion modificarValidacionCampo(VALIDACION_CAMPO vcampo)
 {
     return ValidacionCampoDA.modificarValidacionCampo(vcampo);
 }
 public static EstadoOperacion insertarValidacionCampo(VALIDACION_CAMPO vcampo)
 {
     return ValidacionCampoDA.insertarValidacionCampo(vcampo);
 }
 public static EstadoOperacion eliminarValidacionCampo(VALIDACION_CAMPO vcampo)
 {
     return ValidacionCampoDA.eliminarValidacionCampo(vcampo);
 }