Example #1
0
    public static string AgregarEstado(int IdPais, string Estado)
    {
        CObjeto Respuesta = new CObjeto();

        CUnit.Firmado(delegate(CDB Conn)
        {
            string Error      = "";
            CSecurity permiso = new CSecurity();
            if (permiso.tienePermiso("puedeAgregarEstado"))
            {
                if (Conn.Conectado)
                {
                    CObjeto Datos   = new CObjeto();
                    CEstado cEstado = new CEstado();
                    cEstado.IdPais  = IdPais;
                    cEstado.Estado  = Estado;
                    Error           = ValidarEstado(cEstado);
                    if (Error == "")
                    {
                        CObjeto Valida = new CObjeto();
                        int IdEstado   = CEstado.ValidaExiste(IdPais, Estado, Conn);
                        if (IdEstado != 0)
                        {
                            Error = Error + "<li>Ya existe este Estado.</li>";
                        }
                        else
                        {
                            cEstado.Agregar(Conn);
                        }
                    }
                    Respuesta.Add("Datos", Datos);
                }
                else
                {
                    Error = Error + "<li>" + Conn.Mensaje + "</li>";
                }
            }
            else
            {
                Error = Error + "<li>No tienes los permisos necesarios</li>";
            }

            Respuesta.Add("Error", Error);
        });

        return(Respuesta.ToString());
    }