Esempio n. 1
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
Esempio n. 2
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();
                }
            }
        }
Esempio n. 3
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