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); }
private static string get_match_code(string table_name, string acct_num) { string match_code = ""; 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 * FROM " + table_name + " where acct_num = '" + acct_num + "'"; { OleDbCommand command = new OleDbCommand(cmd, con); OleDbDataReader rdr = command.ExecuteReader(); if (rdr.HasRows) { rdr.Read(); match_code = rdr.GetValue(6).ToString(); } } con.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } return(match_code); }
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); }
private void conString() { con = new OleDbConnection(); dbcon = new Conf.conf(); con.ConnectionString = dbcon.getConnectionString(); }