コード例 #1
0
        public static bool AcessoLiberado(string func)
        {
            funcao = func;
            //if (UsuarioAdmin == "N")
            //{
            UsuarioAdmin = "N";
            Formularios.frmLiberaAcesso frm = new Formularios.frmLiberaAcesso();
            frm.ShowDialog();

            if (UsuarioAdmin == "N")
            {
                if (tentativaLogin == 3)
                {
                    Geral.Erro("O sistema será fechado!");
                    Application.Exit();
                }
                return(false);
            }
            else
            {
                UsuarioAdmin   = "N";
                tentativaLogin = 0;
                return(true);
            }
            //}
            //else
            //return true;
        }
コード例 #2
0
        //Aula 26
        public static bool AcessoLiberado(string Func)
        {
            Funcao = Func;
            //if (UsuarioAdmin == "N")
            //{

            UsuarioAdmin = "N";
            Formularios.FrmLiberaPermissao frm = new Formularios.FrmLiberaPermissao();
            frm.ShowDialog();

            if (UsuarioAdmin == "N")
            {
                if (TentativaLogin == 3)
                {
                    Geral.Erro("Lamento, mas o sistema será fechado!");
                    Application.Exit();
                }
                return(false);
            }
            else
            {
                UsuarioAdmin   = "N";
                TentativaLogin = 0;
                return(true);
            }
            //}
            //else

            //return true;
        }
コード例 #3
0
        public static string ExecutarProcedure(string nome, string[] Valores, string Mensagem = "")
        {
            string sql = "SELECT ID FROM " + nome + "(";

            int i = 0;

            foreach (string item in Valores)
            {
                //Tratamento para o paramêtro ID
                if (i == 0)
                {
                    i = 1;
                    if (item == "")
                    {
                        sql += "null, ";
                    }
                    else
                    {
                        sql += item + ", ";
                    }
                }
                else
                {
                    if (item == "null")
                    {
                        sql += "null, ";
                    }
                    else
                    {
                        sql += "'" + item.Replace("'", "''") + "', ";
                    }
                }
            }

            sql += ")";
            sql  = sql.Replace(", )", ")");

            //aqui é o ponto onde o sql será construido
            //assims endo dá para copiar ele por aqui
            //vou apertar F5 para rodar até esse ponto
            //prtonto agora basta deixa o mouse emcima da variavel sql
            //copiar seu valor

            string id = Buscar(sql).Rows[0][0].ToString();

            if (Convert.ToInt32(id) > 0 && Mensagem != "")
            {
                if (Valores[0] == "")
                {
                    Geral.OK(Mensagem + " Salvo com Sucesso!");
                }
                else
                {
                    Geral.OK(Mensagem + " Alterado com Sucesso!");
                }
            }

            return(id);
        }
コード例 #4
0
        public static string ExecutarProcedure(string nome, string[] Valores, string Mensagem = "")
        {
            string sql = "SELECT ID FROM " + nome + "(";

            int i = 0;

            foreach (string item in Valores)
            {
                //Tratando o parâmetro id
                if (i == 0)
                {
                    i = 1;
                    if (item == "")
                    {
                        sql += "null, ";
                    }
                    else
                    {
                        sql += item + ", ";
                    }
                }
                else
                {
                    if (item == "null")
                    {
                        sql += "null, ";
                    }
                    else
                    {
                        sql += "'" + item.Replace("'", "''") + "', ";
                    }
                }
            }
            sql += ")";
            sql  = sql.Replace(", )", ")");

            string id = Buscar(sql).Rows[0][0].ToString();

            if (Convert.ToInt32(id) > 0 && Mensagem != "")
            {
                if (Valores[0] == "")
                {
                    Geral.Ok(Mensagem + " salvos com sucesso!");
                }
                else
                {
                    Geral.Ok(Mensagem + " alterados com sucesso!");
                }
            }

            return(id);
        }
コード例 #5
0
        public static void Ativar(string Tabela, string Id, string Status)
        {
            Geral.Pergunta("Deseja realmente alterar o status do registro?");

            if (!Geral.Resposta)
            {
                return;
            }

            string sql = "update " + Tabela + " SET ativo = '" + Status + "' where " + Tabela + "_id = " + Id;

            ExecutarSQL(sql);
        }
コード例 #6
0
        public static void Excluir(string Tabela, string Id)
        {
            Geral.Pergunta("Deseja realmente exclur o registro?");

            if (!Geral.Resposta)
            {
                return;
            }

            string sql = "delete from " + Tabela + " where " + Tabela + "_id = " + Id;

            ExecutarSQL(sql);
        }
コード例 #7
0
        public static void Ativar(string Tabela, string id, string status)
        {
            Geral.Pergunta("Deseja alterar o status desse registro?");

            if (!Geral.Resposta)
            {
                return;
            }

            string sql = "update " + Tabela;

            sql += " SET ativo = '" + status;
            sql += "' where " + Tabela + "_id = " + id;

            ExecutarSQL(sql);
        }
コード例 #8
0
        public static bool Excluir(string Tabela, string id)
        {
            Geral.Pergunta("Deseja realmente excluir esse registro?");

            if (!Geral.Resposta)
            {
                return(false);
            }

            string sql = "delete from " + Tabela;

            sql += " where " + Tabela + "_id = " + id;
            ExecutarSQL(sql);

            return(true);
        }