Exemplo n.º 1
0
        }//

        /// <summary>
        ///
        /// </summary>
        /// <param name="login"></param>
        /// <param name="senha"></param>
        /// <param name="ativo"></param>
        /// <param name="perfil"></param>
        /// <param name="email"></param>
        /// <param name="con"></param>
        /// <returns></returns>
        public static Boolean cadastraUsuario(string login, string senha, bool ativo, int perfil, string email, OleDbConnection con)
        {
            bool   flag = false;
            string sql  = "Insert Into Usuarios(login,senha,ativo,perfil,email) values(?,?,?,?,?)";

            try
            {
                OleDbCommand cmd = new OleDbCommand(sql, con);

                cmd.Parameters.Add(new System.Data.OleDb.OleDbParameter("login", login));
                cmd.Parameters.Add(new System.Data.OleDb.OleDbParameter("senha", Acesso.GerarHash(senha)));
                cmd.Parameters.Add(new System.Data.OleDb.OleDbParameter("ativo", ativo));
                cmd.Parameters.Add(new System.Data.OleDb.OleDbParameter("perfil", perfil));
                cmd.Parameters.Add(new System.Data.OleDb.OleDbParameter("email", email));

                int rg = cmd.ExecuteNonQuery();
                if (rg > 0)
                {
                    flag = true;
                }
                else
                {
                    flag = false;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(flag);
        }//
Exemplo n.º 2
0
        }//

        /// <summary>
        ///         ///
        /// </summary>
        /// <param name="login"></param>
        /// <param name="senha"></param>
        /// <param name="con"></param>
        /// <returns></returns>
        public static Boolean alteraSenha(string login, string senha, OleDbConnection con)
        {
            bool   flag = false;
            string sql  = "Update Usuarios set senha = ? Where login = ?";

            try
            {
                OleDbCommand cmd = new OleDbCommand(sql, con);

                cmd.Parameters.Add(new System.Data.OleDb.OleDbParameter("login", login));
                cmd.Parameters.Add(new System.Data.OleDb.OleDbParameter("senha", Acesso.GerarHash(senha)));
                int rg = cmd.ExecuteNonQuery();
                if (rg > 0)
                {
                    flag = true;
                }
                else
                {
                    flag = false;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(flag);
        }//
Exemplo n.º 3
0
        }//fim preencheLancamento

        /// <summary>
        ///
        /// </summary>
        /// <param name="Combo"></param>
        /// <param name="strSql"></param>
        /// <param name="Display"></param>
        /// <param name="Value"></param>
        public static void preencheComboBox(ComboBox Combo, string strSql, string Display, string Value)
        {
            using (OleDbConnection con = Acesso.GetConnection())
            {
                try
                {
                    con.Open();
                    string           sql = strSql;
                    OleDbCommand     cmd = new OleDbCommand(sql, con);
                    OleDbDataAdapter da  = new OleDbDataAdapter(cmd);
                    DataTable        dt  = new DataTable();
                    da.Fill(dt);
                    //coloque as definições na ordem abaixo
                    Combo.DisplayMember = Display;
                    Combo.ValueMember   = Value;
                    Combo.DataSource    = dt;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    con.Close();
                }
            }
        }//fim preencheComboBox
Exemplo n.º 4
0
        }//fim preencheComboBox

        //----------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// <param name="codigo"></param>
        /// <returns></returns>
        public static string getData(int codigo)
        {
            OleDbDataReader dr    = null;
            string          banco = "";

            using (OleDbConnection con = Acesso.GetConnection())
            {
                try
                {
                    con.Open();
                    string       sql = "Select desc_conta from tblcontas where cod_conta=" + codigo;
                    OleDbCommand cmd = new OleDbCommand(sql, con);
                    dr = cmd.ExecuteReader();
                    if (dr.HasRows)
                    {
                        while (dr.Read())
                        {
                            banco = dr["desc_conta"].ToString();
                        }
                        return(banco);
                    }
                    else
                    {
                        return(banco);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    con.Close();
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sql"></param>
        /// <returns></returns>
        public static DataTable preencheLancamentos(string sql)
        {
            using (OleDbConnection con = Acesso.GetConnection())
            {
                try
                {
                    con.Open();

                    OleDbCommand     cmd = new OleDbCommand(sql, con);
                    OleDbDataAdapter da  = new OleDbDataAdapter(cmd);
                    DataTable        dt  = new DataTable();
                    da.Fill(dt);
                    return(dt);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    con.Close();
                }
            }
        }//fim preencheLancamento