Esempio n. 1
0
        private static int get_id(string acct_num, string table_name)
        {
            int             var_id = 0;
            OleDbConnection con    = new OleDbConnection(); //Initialize OleDBConnection

            Conf.conf dbcon;
            con   = new OleDbConnection();
            dbcon = new Conf.conf();
            con.ConnectionString = dbcon.getConnectionString();
            try
            {
                //OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\PC-23\Desktop\TVVS.accdb; Persist Security Info=False;");
                con.Open();
                string cmd = "SELECT * FROM " + table_name + " where acct_num = '" + acct_num + "'";
                {
                    OleDbCommand    command = new OleDbCommand(cmd, con);
                    OleDbDataReader rdr     = command.ExecuteReader();
                    if (rdr.HasRows)
                    {
                        while (rdr.Read())
                        {
                            var_id = Convert.ToInt32(rdr.GetValue(0).ToString());
                        }
                    }
                }
                con.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            return(var_id);
        }
Esempio n. 2
0
        private static string items_counter(string table_name)
        {
            string          items = "";
            OleDbConnection con   = new OleDbConnection(); //Initialize OleDBConnection

            Conf.conf dbcon;
            con   = new OleDbConnection();
            dbcon = new Conf.conf();
            con.ConnectionString = dbcon.getConnectionString();
            try
            {
                //OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\PC-23\Desktop\TVVS.accdb; Persist Security Info=False;");
                //Matched.conString();
                con.Open();
                string cmd = "SELECT COUNT(acct_name) FROM " + table_name + " where match_code <> 'U'";
                {
                    OleDbCommand    command = new OleDbCommand(cmd, con);
                    OleDbDataReader rdr     = command.ExecuteReader();
                    rdr.Read();
                    items = rdr.GetValue(0).ToString();
                }
                con.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return(items);
        }
Esempio n. 3
0
        private static string amount_sum(string table_name)
        {
            string          amount = "";
            OleDbConnection con    = new OleDbConnection(); //Initialize OleDBConnection

            Conf.conf dbcon;
            con   = new OleDbConnection();
            dbcon = new Conf.conf();
            con.ConnectionString = dbcon.getConnectionString();

            try
            {
                //OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\PC-23\Desktop\TVVS.accdb; Persist Security Info=False;");
                //conString();
                con.Open();
                string cmd = "SELECT sum(amount) FROM " + table_name + " where match_code = 'U'";
                {
                    OleDbCommand    command = new OleDbCommand(cmd, con);
                    OleDbDataReader rdr     = command.ExecuteReader();
                    rdr.Read();
                    {
                        amount = String.Format("{0:n}", Double.Parse(rdr.GetValue(0).ToString()));
                    }
                }
                con.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return(amount);
        }
Esempio n. 4
0
 private void conString()
 {
     con   = new OleDbConnection();
     dbcon = new Conf.conf();
     con.ConnectionString = dbcon.getConnectionString();
 }