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 { 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 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 { 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 static string data_counter(string table_name) { int counter = 0; OleDbConnection con = new OleDbConnection(); //Initialize OleDBConnection Conf.conf dbcon; con = new OleDbConnection(); dbcon = new Conf.conf(); con.ConnectionString = dbcon.getConnectionString(); try { con.Open(); string cmd = "SELECT * FROM " + table_name + ""; { OleDbCommand command = new OleDbCommand(cmd, con); OleDbDataReader rdr = command.ExecuteReader(); if (rdr.HasRows) { while (rdr.Read()) { //trans_code = rdr.GetValue(1).ToString(); counter += 1; } } } con.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } return(counter.ToString()); }
private static string get_match_ref(string table_name, string acct_name, string acct_num, string amount) { string match_ref = ""; try { OleDbConnection con = new OleDbConnection(); //Initialize OleDBConnection Conf.conf dbcon; con = new OleDbConnection(); dbcon = new Conf.conf(); con.ConnectionString = dbcon.getConnectionString(); con.Open(); string cmd = "SELECT ID FROM " + table_name + " where acct_name='" + acct_name + "' and acct_num='" + acct_num + "' and amount=" + amount.Replace(",", "") + ""; { OleDbCommand command = new OleDbCommand(cmd, con); OleDbDataReader rdr = command.ExecuteReader(); if (rdr.HasRows) { while (rdr.Read()) { match_ref = rdr.GetValue(0).ToString(); } } } con.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } return(match_ref); }
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); }
private static string db_location(string filepath) { OleDbConnection connection = new OleDbConnection(); //Initialize OleDBConnection Conf.conf dbconnection; connection = new OleDbConnection(); dbconnection = new Conf.conf(); connection.ConnectionString = dbconnection.getConnectionString(); string holder = ""; string command_text = "SELECT scanned_path,icbs_path from settings"; { connection.Open(); OleDbCommand command = new OleDbCommand(command_text, connection); OleDbDataReader rdr = command.ExecuteReader(); rdr.Read(); if (filepath == "scanned_path") { holder = rdr.GetValue(0).ToString(); } else { holder = rdr.GetValue(1).ToString(); } connection.Close(); } return(holder); }
private static string get_image_path() { OleDbConnection con = new OleDbConnection(); //Initialize OleDBConnection Conf.conf dbcon; con = new OleDbConnection(); dbcon = new Conf.conf(); con.ConnectionString = dbcon.getConnectionString(); string img_path = ""; try { con.Open(); string cmd = "SELECT image_path FROM settings"; { OleDbCommand command = new OleDbCommand(cmd, con); OleDbDataReader rdr = command.ExecuteReader(); rdr.Read(); img_path = rdr.GetValue(0).ToString(); } con.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } return(img_path); }
private static string get_image_name(string acct_name, string acct_num, string amount) { OleDbConnection con = new OleDbConnection(); //Initialize OleDBConnection Conf.conf dbcon; con = new OleDbConnection(); dbcon = new Conf.conf(); con.ConnectionString = dbcon.getConnectionString(); string image_name = ""; try { con.Open(); string cmd = "SELECT image_path FROM scanned_trans where acct_name = '" + acct_name + "' and acct_num='" + acct_num + "'"; { OleDbCommand command = new OleDbCommand(cmd, con); OleDbDataReader rdr = command.ExecuteReader(); rdr.Read(); image_name = rdr.GetValue(0).ToString(); } con.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } return(image_name); }
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;"); //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 void conString() { con = new OleDbConnection(); dbcon = new Conf.conf(); con.ConnectionString = dbcon.getConnectionString(); }