public static List <DBPrepaidCableTransactions> GetDataByWallet(string wallet, DateTime past, DateTime present)
        {
            List <DBPrepaidCableTransactions> data = new List <DBPrepaidCableTransactions>();

            MySqlConnection con = DBConnection.ConnectDatabase();

            try
            {   // AND
                MySqlCommand    cmd    = new MySqlCommand("SELECT * FROM " + tablename + " WHERE (date BETWEEN '" + past.ToString("yyyy-MM-dd") + " 0:0:0" + "' AND '" + present.ToString("yyyy-MM-dd") + " 23:59:59" + "') AND wallet_id ='" + wallet + "' ORDER BY id DESC", con);
                MySqlDataReader reader = cmd.ExecuteReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        DBPrepaidCableTransactions rawData = new DBPrepaidCableTransactions();
                        rawData.Id              = reader.GetInt32(0);
                        rawData.Wallet_id       = reader.GetString(1);
                        rawData.Code            = reader.GetString(2);
                        rawData.Box_number      = reader.GetString(3);
                        rawData.Amount          = reader.GetInt32(4);
                        rawData.Discount        = reader.GetFloat(5);
                        rawData.Pin             = reader.GetString(6);
                        rawData.Customer_number = reader.GetString(7);
                        rawData.Date            = reader.GetDateTime(8);
                        rawData.Status          = reader.GetString(9);

                        data.Add(rawData);
                    }
                }


                reader.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                con.Close();
            }

            return(data);
        }
        public static List <DBPrepaidCableTransactions> GetData()
        {
            List <DBPrepaidCableTransactions> data = new List <DBPrepaidCableTransactions>();

            MySqlConnection con = DBConnection.ConnectDatabase();

            try
            {
                MySqlCommand    cmd    = new MySqlCommand("SELECT * FROM " + tablename + " ORDER BY id DESC", con);
                MySqlDataReader reader = cmd.ExecuteReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        DBPrepaidCableTransactions rawData = new DBPrepaidCableTransactions();
                        rawData.Id              = reader.GetInt32(0);
                        rawData.Wallet_id       = reader.GetString(1);
                        rawData.Code            = reader.GetString(2);
                        rawData.Box_number      = reader.GetString(3);
                        rawData.Amount          = reader.GetInt32(4);
                        rawData.Discount        = reader.GetFloat(5);
                        rawData.Pin             = reader.GetString(6);
                        rawData.Customer_number = reader.GetString(7);
                        rawData.Date            = reader.GetDateTime(8);
                        rawData.Status          = reader.GetString(9);

                        data.Add(rawData);
                    }
                }

                reader.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                con.Close();
            }

            return(data);
        }
        public static DBPrepaidCableTransactions GetDataSendingStatus(string s)
        {
            DBPrepaidCableTransactions data = null;

            MySqlConnection con = DBConnection.ConnectDatabase();

            try
            {
                MySqlCommand    cmd    = new MySqlCommand("SELECT * FROM " + tablename + " WHERE status='" + s + "'", con);
                MySqlDataReader reader = cmd.ExecuteReader();

                if (reader.HasRows)
                {
                    reader.Read();
                    data                 = new DBPrepaidCableTransactions();
                    data.Id              = reader.GetInt32(0);
                    data.Wallet_id       = reader.GetString(1);
                    data.Code            = reader.GetString(2);
                    data.Box_number      = reader.GetString(3);
                    data.Amount          = reader.GetInt32(4);
                    data.Discount        = reader.GetFloat(5);
                    data.Pin             = reader.GetString(6);
                    data.Customer_number = reader.GetString(7);
                    data.Date            = reader.GetDateTime(8);
                    data.Status          = reader.GetString(9);
                }

                reader.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                con.Close();
            }

            return(data);
        }
        public static DBPrepaidCableTransactions GetDataById(int idx)
        {
            DBPrepaidCableTransactions data = null;

            MySqlConnection con = DBConnection.ConnectLocalAddressDatabase();

            try
            {
                MySqlCommand    cmd    = new MySqlCommand("SELECT * FROM " + tablename + " WHERE id=" + idx, con);
                MySqlDataReader reader = cmd.ExecuteReader();

                if (reader.HasRows)
                {
                    reader.Read();
                    data                 = new DBPrepaidCableTransactions();
                    data.Id              = reader.GetInt32(0);
                    data.Wallet_id       = reader.GetString(1);
                    data.Code            = reader.GetString(2);
                    data.Box_number      = reader.GetString(3);
                    data.Amount          = reader.GetInt32(4);
                    data.Discount        = reader.GetFloat(5);
                    data.Pin             = reader.GetString(6);
                    data.Customer_number = reader.GetString(7);
                    data.Date            = reader.GetDateTime(8);
                    data.Status          = reader.GetString(9);
                }

                reader.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                con.Close();
            }

            return(data);
        }