Ejemplo n.º 1
0
 internal string GenALogID()
 {
     dbman = new DBConnectionManager();
     if (dbman.DBConnect().State == ConnectionState.Open)
     {
         MySqlCommand cmd = dbman.DBConnect().CreateCommand();
         cmd.CommandText = "SELECT COUNT(log_id) FROM account_logs;";
         MySqlDataReader db_reader = cmd.ExecuteReader();
         while (db_reader.Read())
         {
             ret = "LOG-" + (db_reader.GetInt32("COUNT(log_id)") + 1);
         }
         //close Connection
         dbman.DBClose();
     }
     else
     {
     }
     return(ret);
 }
Ejemplo n.º 2
0
 internal string GenerateReceiptNum2()
 {
     dbman = new DBConnectionManager();
     if (dbman.DBConnect().State == ConnectionState.Open)
     {
         MySqlCommand cmd = dbman.DBConnect().CreateCommand();
         cmd.CommandText = "SELECT COUNT(transaction_id) FROM transactions;";
         MySqlDataReader db_reader = cmd.ExecuteReader();
         while (db_reader.Read())
         {
             ret = String.Format("{0:000000}", (db_reader.GetInt32("COUNT(transaction_id)") + 1));
         }
         //close Connection
         dbman.DBClose();
     }
     else
     {
     }
     return(ret);
 }
Ejemplo n.º 3
0
 internal string GenDirectoryID()
 {
     dbman = new DBConnectionManager();
     if (dbman.DBConnect().State == ConnectionState.Open)
     {
         MySqlCommand cmd = dbman.DBConnect().CreateCommand();
         cmd.CommandText = "SELECT COUNT(directory_id) FROM burial_directory;";
         MySqlDataReader db_reader = cmd.ExecuteReader();
         while (db_reader.Read())
         {
             ret = "DIR-" + (db_reader.GetInt32("COUNT(directory_id)") + 1);
         }
         //close Connection
         dbman.DBClose();
     }
     else
     {
     }
     return(ret);
 }
Ejemplo n.º 4
0
 internal string GetChurchName()
 {
     dbman = new DBConnectionManager();
     if (dbman.DBConnect().State == ConnectionState.Open)
     {
         MySqlCommand cmd = dbman.DBConnect().CreateCommand();
         cmd.CommandText = "SELECT key_value FROM settings WHERE key_name = @key_name;";
         cmd.Parameters.AddWithValue("@key_name", "Church Name");
         MySqlDataReader db_reader = cmd.ExecuteReader();
         while (db_reader.Read())
         {
             ret = db_reader.GetString("key_value");
         }
         //close Connection
         dbman.DBClose();
     }
     else
     {
     }
     return(ret);
 }
Ejemplo n.º 5
0
 internal string GetUsername(string uid)
 {
     dbman = new DBConnectionManager();
     if (dbman.DBConnect().State == ConnectionState.Open)
     {
         MySqlCommand cmd = dbman.DBConnect().CreateCommand();
         cmd.CommandText = "SELECT * FROM accounts WHERE account_id = @uid LIMIT 1;";
         cmd.Parameters.AddWithValue("@uid", uid);
         MySqlDataReader db_reader = cmd.ExecuteReader();
         while (db_reader.Read())
         {
             ret = db_reader.GetString("user_name");
         }
         //close Connection
         dbman.DBClose();
     }
     else
     {
     }
     return(ret);
 }
Ejemplo n.º 6
0
 internal string GetAccountType(string uid)
 {
     dbman = new DBConnectionManager();
     if (dbman.DBConnect().State == ConnectionState.Open)
     {
         MySqlCommand cmd = dbman.DBConnect().CreateCommand();
         cmd.CommandText = "SELECT * FROM accounts WHERE account_id = @uid LIMIT 1;";
         cmd.Parameters.AddWithValue("@uid", uid);
         MySqlDataReader db_reader = cmd.ExecuteReader();
         while (db_reader.Read())
         {
             if (db_reader.GetInt32("account_type") == 1)
             {
                 ret = "Administrator";
             }
             else if (db_reader.GetInt32("account_type") == 2)
             {
                 ret = "Secretary";
             }
             else if (db_reader.GetInt32("account_type") == 3)
             {
                 ret = "Cashier";
             }
             else if (db_reader.GetInt32("account_type") == 4)
             {
                 ret = "Registrar";
             }
             else
             {
                 ret = "Custom";
             }
         }
         //close Connection
         dbman.DBClose();
     }
     else
     {
     }
     return(ret);
 }
Ejemplo n.º 7
0
 internal string GetPrintFee(string type)
 {
     dbman = new DBConnectionManager();
     if (dbman.DBConnect().State == ConnectionState.Open)
     {
         MySqlCommand cmd = dbman.DBConnect().CreateCommand();
         cmd.CommandText = "SELECT key_value FROM settings WHERE key_name = @key_name;";
         if (type == "Baptismal")
         {
             cmd.Parameters.AddWithValue("@key_name", "Print Fee Baptismal");
         }
         else if (type == "Confirmation")
         {
             cmd.Parameters.AddWithValue("@key_name", "Print Fee Confirmation");
         }
         else if (type == "Matrimonial")
         {
             cmd.Parameters.AddWithValue("@key_name", "Print Fee Matrimonial");
         }
         else if (type == "Burial")
         {
             cmd.Parameters.AddWithValue("@key_name", "Print Fee Burial");
         }
         MySqlDataReader db_reader = cmd.ExecuteReader();
         while (db_reader.Read())
         {
             ret = db_reader.GetString("key_value");
         }
         //close Connection
         dbman.DBClose();
     }
     else
     {
     }
     return(ret);
 }
Ejemplo n.º 8
0
        internal int InsertTransaction(string type, string status, string targetID, double fee)
        {
            string uid = Application.Current.Resources["uid"].ToString();

            string[] dt = GetServerDateTime().Split(null);
            cDate   = Convert.ToDateTime(dt[0]);
            cTime   = DateTime.Parse(dt[1] + " " + dt[2]);
            curDate = cDate.ToString("yyyy-MM-dd");
            curTime = cTime.ToString("HH:mm:ss");

            dbman = new DBConnectionManager();
            //TODO
            try
            {
                string       tID = GenTransactionID();
                MySqlCommand cmd = dbman.DBConnect().CreateCommand();
                cmd.CommandText =
                    "INSERT INTO transactions(transaction_id, type, status, tran_date, tran_time, completion_date, completion_time, placed_by, completed_by, target_id, fee)" +
                    "VALUES(@transaction_id, @type, @status, @tran_date, @tran_time, @completion_date, @completion_time, @placed_by, @completed_by, @target_id, @fee)";
                cmd.Prepare();
                cmd.Parameters.AddWithValue("@transaction_id", tID);
                cmd.Parameters.AddWithValue("@type", type);
                cmd.Parameters.AddWithValue("@status", status);
                cmd.Parameters.AddWithValue("@tran_date", curDate);
                cmd.Parameters.AddWithValue("@tran_time", curTime);
                cmd.Parameters.AddWithValue("@completion_date", null);
                cmd.Parameters.AddWithValue("@completion_time", null);
                cmd.Parameters.AddWithValue("@placed_by", uid);
                cmd.Parameters.AddWithValue("@completed_by", null);
                cmd.Parameters.AddWithValue("@target_id", targetID);
                cmd.Parameters.AddWithValue("@fee", fee);
                //cmd.Parameters.AddWithValue("@or_number", this.GenerateReceiptNum());
                int stat_code = cmd.ExecuteNonQuery();
                dbman.DBClose();
                //string tmp = pmsutil.LogRecord(recID, "LOGC-01");
                return(stat_code);
            }
            catch (MySqlException ex)
            {
                Console.WriteLine("Error: {0}", ex.ToString());
                return(0);
            }
        }