protected void Page_Load(object sender, EventArgs e)
        {
            String Form_user = "******";

            // *** Inicio da rotina de verificação
            String nome_3 = strNomeUser();

            if (nome_3 == null)
            {
                nome_3 = "";
                Response.Redirect("WebLogar1.aspx");
                Response.End();
            }
            else
            {
                // Verifica se Usuario tem permissao para uso

                // *****************************************************************************************
                string nodo_Form = Form_user;   // <<< **** Não esquecer de colocar o nome do Form **** >>>
                // *****************************************************************************************

                Funcoes1 busca_pro  = new Funcoes1();
                string   busca_pro1 = busca_pro.progr_user(nodo_Form, nome_3, strConx());

                if (busca_pro1 == "NAO_FAZ")
                {
                    Response.Redirect("Acessedenied.aspx");
                    Response.End();
                }
            }
        }
Beispiel #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // *** Inicio da rotina de verificação

            String strSessao3 = (string)Session["usuarSessa"];
            String strSenha3  = (string)Session["senhrSessa"];
            String nome_3     = strSessao3;

            if (nome_3 == null)
            {
                nome_3 = "";
                Response.Redirect("WebLogar1.aspx");
                Response.End();
            }
            else
            {
                // Verifica se Usuario tem permissao para uso

                // *****************************************************************************************
                string nodo_Form = "CapturaUser";   // <<< **** Não esquecer de colocar o nome do Form **** >>>
                // *****************************************************************************************

                Funcoes1 busca_pro  = new Funcoes1();
                string   busca_pro1 = busca_pro.progr_user(nodo_Form, nome_3, strConx());

                if (busca_pro1 == "NAO_FAZ")
                {
                    Response.Redirect("Acessedenied.aspx");
                    Response.End();
                }
            }
            // *** fim da rotina de verificação


            if (Request.QueryString["produto"] != "")
            {
                this.lblLabel1.Text  = Request.QueryString["produto"];
                this.lblmsgerro.Text = "";
                string cod_prod = "";
                int    cod_info = 0;
                cod_prod = Request.QueryString["codigo"];
                cod_info = Convert.ToInt32(Request.QueryString["inf"]);
            }
            else
            {
                Button2.Enabled = false;

                this.lblmsgerro.Text = "Menhum Usuario Encontrado !!!";
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string tabelaper = "tt_ser_01";
            String Form_user = "******";

            // *** Inicio da rotina de verificação
            String nome_3 = strNomeUser();

            if (nome_3 == null)
            {
                nome_3 = "";
                Response.Redirect("WebLogar1.aspx");
                Response.End();
            }
            else
            {
                // Verifica se Usuario tem permissao para uso

                // *****************************************************************************************
                string nodo_Form = Form_user;   // <<< **** Não esquecer de colocar o nome do Form **** >>>
                // *****************************************************************************************

                Funcoes1 busca_pro  = new Funcoes1();
                string   busca_pro1 = busca_pro.progr_user(nodo_Form, nome_3, strConx());

                if (busca_pro1 == "NAO_FAZ")
                {
                    Response.Redirect("Acessedenied.aspx");
                    Response.End();
                }

                // Verificar quais botoes pode ser usado

                string per_1 = "";
                string per_2 = "";
                string per_3 = "";
                string per_4 = "";

                // ******  Inicio da Busca do Programa
                using (MySqlConnection connection6 = new MySqlConnection(strConx()))
                {
                    MySqlCommand    cmd6;
                    MySqlDataReader dr6;
                    connection6.Open();
                    try
                    {
                        cmd6             = connection6.CreateCommand();
                        cmd6.CommandText = "SELECT * FROM permissoes WHERE login = '******' AND tabela = '" + tabelaper.ToUpper() + "'";
                        dr6 = cmd6.ExecuteReader();

                        if (dr6.Read())
                        {
                            per_1 = dr6["incluir"].ToString();
                            per_2 = dr6["alterar"].ToString();
                            per_3 = dr6["excluir"].ToString();
                            per_4 = dr6["imprimir"].ToString();
                        }

                        if (per_1 == "SIM")
                        {
                            this.Incluir.Enabled = true;
                        }
                        if (per_2 == "SIM")
                        {
                            this.Alterar.Enabled = true;
                        }
                        if (per_3 == "SIM")
                        {
                            this.Excluir.Enabled = true;
                        }
                        if (per_4 == "SIM")
                        {
                            this.Imprimir1.Enabled = true;
                        }
                    }
                    catch { }
                }
                // Fim da Verificacao dos botoes
            }

            if (!Page.IsPostBack)
            {
                // Consulta para voltar a mesma tela

                if (Request.QueryString["codigo"] != null)
                {
                    this.Fotoprod1.Enabled = true;

                    string cod_ret = "";
                    cod_ret = Request.QueryString["codigo"];

                    String query = "";
                    query = "SELECT * FROM tt_ser_01 WHERE login = '******'";


                    using (MySqlConnection con = new MySqlConnection(strConx()))
                    {
                        MySqlDataReader dr;
                        MySqlCommand    command = con.CreateCommand();
                        command.CommandText = query;

                        try
                        { con.Open(); }
                        catch { }

                        try
                        {
                            dr = command.ExecuteReader();
                            // Mostra registros na tela
                            if (dr.Read())
                            {
                                this.txtid.Value      = dr["id"].ToString();
                                this.txtlogin.Text    = dr["login"].ToString();
                                this.txtsenha.Text    = dr["senha2"].ToString();
                                this.txtData.Text     = dr["data"].ToString();
                                this.txtNome.Value    = dr["nome_l"].ToString();
                                this.txtMaquina.Value = dr["maquina"].ToString();
                                this.txtConta.ClearSelection();
                                this.txtConta.Items.Insert(0, dr["conta"].ToString());
                                this.txtPrograma.Value = dr["programas"].ToString();
                                this.txtHora1.Value    = dr["hora1"].ToString();
                                this.txtHora2.Value    = dr["hora2"].ToString();
                                this.txtTipo.ClearSelection();
                                this.txtTipo.Items.Insert(0, dr["tipo"].ToString());
                                this.txtSemana.Value   = dr["semana"].ToString();
                                this.txtEmail.Value    = dr["e_mail"].ToString();
                                this.txtfoto1.ImageUrl = dr["foto"].ToString();
                            }
                        }
                        catch { }
                    }
                }
                else
                {
                    this.Fotoprod1.Enabled = false;
                }
            }
        }
Beispiel #4
0
        protected void Entrar_Click(object sender, EventArgs e)
        {
            string logindobando   = "";
            string senhadobando   = "";
            string senha64base    = "";
            string senhaMD5       = "";
            string programasbanco = "";
            string contabanco     = "";
            string acessobanco    = "";
            string hora1banco     = "";
            string hora2banco     = "";
            string semanabanco    = "";
            string tipobanco      = "";
            string entradabanco   = "";
            string saidabanco     = "";

            string retnome_3 = this.txtnome3.Value;
            string retsenh_3 = this.txtpass03.Value;

            string strCon8 = Application.Get("strConString").ToString();

            //string strCom = "Persist Security Info=False;server=localhost;database=sistema;uid=root;server=localhost;database=sistema;uid=root;pwd=12345";

            using (MySqlConnection connection = new MySqlConnection(strCon8))
            {
                MySqlCommand    cmd;
                MySqlDataReader dr;
                connection.Open();

                try
                {
                    cmd             = connection.CreateCommand();
                    cmd.CommandText = "SELECT login,senha2,programas,conta,acesso,hora1,hora2,semana,tipo,entrada,saida FROM tt_ser_01 WHERE login = '******'";

                    dr = cmd.ExecuteReader();

                    // Mostra registros na tela
                    if (dr.Read())
                    {
                        logindobando   = dr["login"].ToString();
                        senhadobando   = dr["senha2"].ToString();
                        programasbanco = dr["programas"].ToString();
                        contabanco     = dr["conta"].ToString();
                        acessobanco    = dr["acesso"].ToString();
                        hora1banco     = dr["hora1"].ToString();
                        hora2banco     = dr["hora2"].ToString();
                        semanabanco    = dr["semana"].ToString();
                        tipobanco      = dr["tipo"].ToString();
                        entradabanco   = dr["entrada"].ToString();
                        saidabanco     = dr["saida"].ToString();

                        senha64base = senhadobando;

                        senhaMD5 = GetMD5Hash(this.txtpass03.Value);
                    }


                    if (this.txtnome3.Value.ToUpper() == logindobando && senhaMD5 == senha64base)
                    {
                        // Verificar horario //
                        string   hora_atual = DateTime.Now.ToString("HH:mm");
                        DateTime ho_atu     = Convert.ToDateTime(hora_atual);

                        string   hora_banco = hora1banco;
                        DateTime ho_ban1    = Convert.ToDateTime(hora_banco);

                        string   hora_banco2 = hora2banco;
                        DateTime ho_ban2     = Convert.ToDateTime(hora_banco2);

                        // Gravando uma Variavel de Sessao
                        Session["usuarSessa"] = logindobando;
                        Session["senhrSessa"] = senha64base;
                        Session["ID_sessao"]  = Session.SessionID;


                        //Verifica se Conta nao esta Bloqueada
                        if (contabanco == "BLOQUEADA")
                        {
                            Response.Redirect("SemBloqueado.aspx");
                            Response.End();
                        }


                        Funcoes1 buscar_semana  = new Funcoes1();
                        string   buscar_semana2 = buscar_semana.verificadiasemana(logindobando, strCon8);

                        if (buscar_semana2 == "NAO_FAZ")
                        {
                            Response.Redirect("SemPermissao2.aspx");
                            Response.End();
                        }



                        if (ho_atu >= ho_ban1 && ho_atu <= ho_ban2)
                        {
                            //Gravar log de Eventos
                            string ip_log      = Request.ServerVariables["Request_ADDR"];
                            string dat_log     = DateTime.Now.ToString("d");
                            string hor1_log    = DateTime.Now.ToString("HH:mm:ss");
                            string evento_log  = "ENTRADA NO SISTEMA";
                            string arquivo_log = Request.ServerVariables["SCRIPT_NAME"];
                            string user_log    = retnome_3.ToUpper();

                            if (ip_log == null)
                            {
                                ip_log = "127.0.0.0";
                            }

                            // Regra de Inclusao
                            using (MySqlConnection connection2 = new MySqlConnection(strCon8))
                            {
                                MySqlCommand cmd2;
                                connection2.Open();

                                try
                                {
                                    cmd2             = connection2.CreateCommand();
                                    cmd2.CommandText = "INSERT INTO log_user_event (IP,DATA,EVENTO,HORA,USUARIO,ARQUIVO)" +
                                                       "VALUES(@ip, @data, @evento, @hora, @usuario, @arquivo)";
                                    cmd2.Parameters.AddWithValue("@ip", ip_log);
                                    cmd2.Parameters.AddWithValue("@data", dat_log);
                                    cmd2.Parameters.AddWithValue("@evento", evento_log);
                                    cmd2.Parameters.AddWithValue("@hora", hor1_log);
                                    cmd2.Parameters.AddWithValue("@usuario", user_log);
                                    cmd2.Parameters.AddWithValue("@arquivo", arquivo_log);
                                    cmd2.ExecuteNonQuery();
                                    cmd2.Dispose();
                                }
                                catch (Exception)
                                {
                                    Response.Write("<br> Não foi Incluido !!!<br>");
                                    //throw;
                                }

                                //connection2.Close();
                            }
                            // Grava Usuario on-line logado em Sessao
                            string   t1  = DateTime.Now.ToString("HH:mm:ss");
                            DateTime t2  = Convert.ToDateTime(t1);
                            string   ti1 = t2.TimeOfDay.Ticks.ToString();
                            //string time_stampin = ti1.ToString();
                            //int time_stampin2 = Convert.ToInt32(time_stampin);
                            string hora_par = DateTime.Now.ToString("HH:mm:ss");
                            var    parse1   = TimeSpan.Parse(hora_par);

                            long   time_stampin = DateTime.Now.Ticks;
                            string ip_online    = ip_log;
                            string arq_online   = arquivo_log;
                            string dat_online   = dat_log;
                            string hor_online   = hor1_log;
                            string use_online   = user_log;
                            string sessa_online = Session.SessionID;

                            string usuario_on = "";
                            string sessao_on  = "";
                            string hora_on    = "";
                            //string id_on = "";

                            // Regra de Pesquisa
                            using (MySqlConnection connection3 = new MySqlConnection(strCon8))
                            {
                                MySqlCommand    cmd3;
                                MySqlDataReader dr3;
                                connection3.Open();

                                try
                                {
                                    cmd3             = connection3.CreateCommand();
                                    cmd3.CommandText = "SELECT usuario,sessao,hora FROM useronline WHERE usuario = '" + user_log + "'";

                                    dr3 = cmd3.ExecuteReader();

                                    if (dr3.Read())
                                    {
                                        usuario_on = dr3["usuario"].ToString();
                                        sessao_on  = dr3["sessao"].ToString();
                                        hora_on    = dr3["hora"].ToString();
                                        //id_on = dr3["id"].ToString();
                                    }


                                    if (sessao_on == sessa_online)
                                    {
                                        // Entra sem avisar
                                        //Conexao.Open();

                                        using (MySqlConnection connection4 = new MySqlConnection(strCon8))
                                        {
                                            MySqlCommand cmd4;
                                            connection4.Open();

                                            try
                                            {
                                                cmd4             = connection4.CreateCommand();
                                                cmd4.CommandText = "UPDATE useronline SET hora = @hora_on WHERE usuario = '" + user_log.ToUpper() + "' AND sessao = '" + sessao_on + "'";
                                                cmd4.Parameters.AddWithValue("@hora_on", hor_online);
                                                cmd4.ExecuteNonQuery();
                                                cmd4.Dispose();
                                            }
                                            catch
                                            {
                                                // Regra de Inclusao
                                                using (MySqlConnection connection5 = new MySqlConnection(strCon8))
                                                {
                                                    MySqlCommand cmd5;
                                                    connection5.Open();

                                                    try
                                                    {
                                                        cmd5             = connection5.CreateCommand();
                                                        cmd5.CommandText = "INSERT INTO useronline (timestamp,ip,arquivo,data,hora,usuario,sessao)" +
                                                                           "VALUES(@stamp_usr, @ip_usr, @arquivo_usr, @data_usr, @hora_usr, @usuario_usr, @sessao_usr)";
                                                        cmd5.Parameters.AddWithValue("@stamp_usr", time_stampin);
                                                        cmd5.Parameters.AddWithValue("@ip_usr", ip_online);
                                                        cmd5.Parameters.AddWithValue("@arquivo_usr", arq_online);
                                                        cmd5.Parameters.AddWithValue("@data_usr", dat_online);
                                                        cmd5.Parameters.AddWithValue("@hora_usr", hor_online);
                                                        cmd5.Parameters.AddWithValue("@usuario_usr", use_online);
                                                        cmd5.Parameters.AddWithValue("@sessao_usr", sessa_online);
                                                        cmd5.ExecuteNonQuery();
                                                        cmd5.Dispose();
                                                    }
                                                    catch (Exception)
                                                    {
                                                        //Response.Write("<br> Não foi Incluido !!!<br>");
                                                        //throw;
                                                    }

                                                    //connection5.Close();
                                                }
                                            }
                                        }
                                    }
                                    else
                                    {
                                        // Consulta de o usuario on-line existe
                                        // Regra de Pesquisa
                                        using (MySqlConnection connection6 = new MySqlConnection(strCon8))
                                        {
                                            MySqlCommand    cmd6;
                                            MySqlDataReader dr6;
                                            connection6.Open();

                                            try
                                            {
                                                cmd6             = connection6.CreateCommand();
                                                cmd6.CommandText = "SELECT usuario,sessao,hora FROM useronline WHERE usuario = '" + retnome_3.ToUpper() + "'";

                                                dr6 = cmd6.ExecuteReader();

                                                if (dr6.Read())
                                                {
                                                    usuario_on = dr6["usuario"].ToString();
                                                    sessao_on  = dr6["sessao"].ToString();
                                                    hora_on    = dr6["hora"].ToString();
                                                    //id_on = dr6["id"].ToString();
                                                }

                                                if (usuario_on != "")
                                                {
                                                    Session["usuarSessa"] = logindobando.ToString();
                                                    Response.Redirect("OutraSessao.aspx");
                                                    Response.End();
                                                }
                                                else
                                                {
                                                    using (MySqlConnection connection5 = new MySqlConnection(strCon8))
                                                    {
                                                        MySqlCommand cmd5;
                                                        connection5.Open();

                                                        try
                                                        {
                                                            cmd5             = connection5.CreateCommand();
                                                            cmd5.CommandText = "INSERT INTO useronline (timestamp,  ip,      arquivo,      data,      hora,      usuario,      sessao)" +
                                                                               "VALUES(@stamp_usr, @ip_usr, @arquivo_usr, @data_usr, @hora_usr, @usuario_usr, @sessao_usr)";
                                                            cmd5.Parameters.AddWithValue("@stamp_usr", time_stampin);
                                                            cmd5.Parameters.AddWithValue("@ip_usr", ip_online);
                                                            cmd5.Parameters.AddWithValue("@arquivo_usr", arq_online);
                                                            cmd5.Parameters.AddWithValue("@data_usr", dat_online);
                                                            cmd5.Parameters.AddWithValue("@hora_usr", hor_online);
                                                            cmd5.Parameters.AddWithValue("@usuario_usr", use_online);
                                                            cmd5.Parameters.AddWithValue("@sessao_usr", sessa_online);
                                                            cmd5.ExecuteNonQuery();
                                                            cmd5.Dispose();
                                                        }
                                                        catch (Exception)
                                                        {
                                                            //Response.Write("<br> Não foi Incluido !!!<br>");
                                                            //throw;
                                                        }

                                                        //connection5.Close();
                                                    }
                                                    Response.Redirect("WebLogar1.aspx");
                                                    Response.End();
                                                }
                                            }
                                            catch (Exception)
                                            {
                                                //Response.Redirect("OutraSessao.aspx");
                                                //Response.End();
                                                //throw;
                                            }
                                        }
                                    }
                                }
                                catch (Exception)
                                {
                                    //Response.Redirect("OutraSessao.aspx");
                                    //Response.End();

                                    //throw;
                                }
                                //connection3.Close();
                            }


                            //Response.Write("não entrar nesse horario " + ho_atu.ToString("HH:mm"));
                            Response.Redirect("WebSistem1.aspx");
                            Response.End();
                            //throw;
                        }
                        else
                        {
                            //Response.Write("não entrar nesse horario " + ho_atu.ToString("HH:mm"));
                            Response.Redirect("SemPermissao.aspx");
                            Response.End();
                        }
                    }
                    else
                    {
                        lblmensage1.Text = "ERRO: Login ou senha incorretos !!!";
                        this.txtnome3.Focus();
                        //Response.End();
                    }
                }
                catch
                {
                    lblmensage1.Text = "ERRO(1): Não Foi possivel Conectar !!!";
                    //throw;
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {

                if (this.txtidforne.Value == "")
                {

                    CarregaCombo();

                }


            }
            string tabelaper = "Estoque";
            String Form_user = "******";

            // *** Inicio da rotina de verificação
            String nome_3 = strNomeUser();
            if (nome_3 == null)
            {

                nome_3 = "";
                Response.Redirect("WebLogar1.aspx");
                Response.End();

            }
            else
            {


                // *****************************************************************************************
                string nodo_Form = Form_user;   // <<< **** Não esquecer de colocar o nome do Form **** >>>
                // *****************************************************************************************

                Funcoes1 busca_pro = new Funcoes1();
                string busca_pro1 = busca_pro.progr_user(nodo_Form, nome_3, strConx());

                if (busca_pro1 == "NAO_FAZ")
                {
                    Response.Redirect("Acessedenied.aspx");
                    Response.End();
                }

                // Verificar quais botoes pode ser usado

                string per_1 = "";
                string per_2 = "";
                string per_3 = "";
                string per_4 = "";

                // ******  Inicio da Busca do Programa
                using (MySqlConnection connection6 = new MySqlConnection(strConx()))
                {
                    MySqlCommand cmd6;
                    MySqlDataReader dr6;
                    connection6.Open();
                    try
                    {
                        cmd6 = connection6.CreateCommand();
                        cmd6.CommandText = "SELECT * FROM permissoes WHERE login = '******' AND tabela = '" + tabelaper.ToUpper() + "'";
                        dr6 = cmd6.ExecuteReader();

                        if (dr6.Read())
                        {
                            per_1 = dr6["incluir"].ToString();
                            per_2 = dr6["alterar"].ToString();
                            per_3 = dr6["excluir"].ToString();
                            per_4 = dr6["imprimir"].ToString();
                        }

                        if (per_1 == "SIM") { this.Incluir.Enabled = true; }
                        if (per_2 == "SIM") { this.Alterar.Enabled = true; }
                        if (per_3 == "SIM") { this.Excluir.Enabled = true; }
                        if (per_4 == "SIM") { this.Imprimir1.Enabled = true; }
                    }
                    catch { }
                }
                // Fim da Verificacao dos botoes

            }


            if (!Page.IsPostBack)
            {

                // Consulta para voltar a mesma tela

                if (Request.QueryString["codigo"] != "")
                {
                    this.Fotoprod1.Enabled = true;

                    int cod_ret = 0;
                    cod_ret = Convert.ToInt32(Request.QueryString["codigo"]);

                    String query = "";
                    query = "SELECT * FROM estoque WHERE codigo = '" + cod_ret + "'";


                    //Request.QueryString["codigo"] = "";

                    using (MySqlConnection con = new MySqlConnection(strConx()))
                    {
                        MySqlDataReader dr;
                        MySqlCommand command = con.CreateCommand();
                        command.CommandText = query;

                        try
                        {
                            con.Open();

                        }
                        catch { }

                        try
                        {

                            dr = command.ExecuteReader();
                            // Mostra registros na tela
                            if (dr.Read())
                            {

                                this.txtid.Value = dr["id"].ToString();
                                this.txtCodigo.Value = dr["codigo"].ToString();
                                this.txtData.Text = dr["data"].ToString();
                                this.txtDescricao.Value = dr["descricao"].ToString();
                                this.txtUnidade.Value = dr["unidade"].ToString();
                                this.txtQtd.Value = dr["qtd_estq"].ToString();
                                this.txtMini.Value = dr["qtd_mini"].ToString();
                                this.txtClasse.Text = dr["classe"].ToString();
                                this.txtVencto.Text = dr["vencimento"].ToString();
                                this.txtFornecedor.ClearSelection();
                                this.txtFornecedor.Items.Insert(0, dr["fornecedor"].ToString());
                                this.txtidforne.Value = dr["fornecedor"].ToString();
                                this.txtRefere.Value = dr["referencia"].ToString();
                                this.txtSaldo.Value = dr["saldo"].ToString();
                                this.txtValor.Value = dr["valor"].ToString();
                                this.txtObs.Value = dr["obs"].ToString();
                                this.foto1.ImageUrl = dr["foto"].ToString();
                                this.lblBarra1.Text = "!0000000000" + this.txtCodigo.Value + "!";

                            }
                        }
                        catch { }
                    }
                }
                else
                {
                    this.Fotoprod1.Enabled = false;
                }
            }
            if (this.txtCodigo.Value != "" || this.txtCodigo.Value != null)
            {
                this.Fotoprod1.Enabled = true;
            }

        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string tabelaper = "fornecedor";
            String Form_user = "******";

            // *** Inicio da rotina de verificação
            String nome_3 = strNomeUser();

            if (nome_3 == null)
            {
                nome_3 = "";
                Response.Redirect("WebLogar1.aspx");
                Response.End();
            }
            else
            {
                // Verifica se Usuario tem permissao para uso

                // *****************************************************************************************
                string nodo_Form = Form_user;   // <<< **** Não esquecer de colocar o nome do Form **** >>>
                // *****************************************************************************************

                Funcoes1 busca_pro  = new Funcoes1();
                string   busca_pro1 = busca_pro.progr_user(nodo_Form, nome_3, strConx());

                if (busca_pro1 == "NAO_FAZ")
                {
                    Response.Redirect("Acessedenied.aspx");
                    Response.End();
                }

                // Verificar quais botoes pode ser usado
                string per_1 = "";
                string per_2 = "";
                string per_3 = "";
                string per_4 = "";

                // ******  Inicio da Busca do Programa
                using (MySqlConnection connection = new MySqlConnection(strConx()))
                {
                    MySqlCommand    cmd;
                    MySqlDataReader dr;
                    connection.Open();
                    try
                    {
                        cmd             = connection.CreateCommand();
                        cmd.CommandText = "SELECT * FROM permissoes WHERE login = '******' AND tabela = '" + tabelaper.ToUpper() + "'";
                        dr = cmd.ExecuteReader();

                        if (dr.Read())
                        {
                            per_1 = dr["incluir"].ToString();
                            per_2 = dr["alterar"].ToString();
                            per_3 = dr["excluir"].ToString();
                            per_4 = dr["imprimir"].ToString();
                        }

                        if (this.lblmodulo1.Text != "Inclusão")
                        {
                            // Abilita para uso os Bottoes
                            if (per_1 == "SIM")
                            {
                                this.Incluir.Enabled = true;
                            }
                            if (per_2 == "SIM")
                            {
                                this.Alterar.Enabled = true;
                            }
                            if (per_3 == "SIM")
                            {
                                this.Excluir.Enabled = true;
                            }
                            if (per_4 == "SIM")
                            {
                                this.Imprimir1.Enabled = true;
                            }
                        }
                    }
                    catch { }
                }
                // Fim da Verificacao dos botoes
            }

            if (!Page.IsPostBack)
            {
                // Consulta para voltar a mesma tela vindo de outra Pagina
                if (Request.QueryString["codigo"] != null)
                {
                    int cod_ret = 0;
                    cod_ret = Convert.ToInt32(Request.QueryString["codigo"]);

                    String query = "";
                    query = "SELECT * FROM fornecedor WHERE codigo = " + cod_ret + "";

                    using (MySqlConnection con = new MySqlConnection(strConx()))
                    {
                        MySqlDataReader dr;
                        MySqlCommand    command = con.CreateCommand();
                        command.CommandText = query;

                        try
                        { con.Open(); }
                        catch { }

                        try
                        {
                            dr = command.ExecuteReader();
                            // Mostra registros na tela
                            if (dr.Read())
                            {
                                this.txtid.Value     = dr["id"].ToString();
                                this.TxtCodigo.Text  = dr["codigo"].ToString();
                                this.txtData.Text    = dr["data"].ToString();
                                this.txtNome.Value   = dr["fornecedor"].ToString();
                                this.txtTel.Text     = dr["fone"].ToString();
                                this.txtCel.Text     = dr["celular"].ToString();
                                this.txtEmail.Text   = dr["e_mail"].ToString();
                                this.txtEnd.Value    = dr["endereco"].ToString();
                                this.txtNumero.Value = dr["numero"].ToString();
                                this.txtCep.Value    = dr["cep"].ToString();
                                this.txtBairro.Text  = dr["bairro"].ToString();
                                this.txtCidade.Value = dr["cidade"].ToString();
                                this.txtUf.Text      = dr["estado"].ToString();
                                this.txtObs.Value    = dr["obs"].ToString();
                            }
                        }
                        catch { }
                    }
                }
                else
                {
                }
            }
        }