Exemplo n.º 1
0
        public static List <DBRetailers> GetData()
        {
            List <DBRetailers> data = new List <DBRetailers>();

            MySqlConnection con = DBConnection.ConnectDatabase();

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

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        DBRetailers rawData = new DBRetailers();
                        rawData.Date       = reader.GetDateTime(0);
                        rawData.Wallet_Id  = reader.GetString(1);
                        rawData.Fname      = reader.GetString(2);
                        rawData.Lname      = reader.GetString(3);
                        rawData.Birth_Date = reader.GetDateTime(4);
                        rawData.Province   = reader.GetString(5);
                        rawData.City       = reader.GetString(6);
                        rawData.Barangay   = reader.GetString(7);
                        rawData.BlockStr   = reader.GetString(8);
                        rawData.Balance    = reader.GetFloat(9);
                        rawData.Frozen     = reader.GetFloat(10);
                        rawData.Sponsor_Id = reader.GetString(11);

                        data.Add(rawData);
                    }
                }

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

            return(data);
        }
Exemplo n.º 2
0
        public static DBRetailers GetDataByWallet(string wallet)
        {
            DBRetailers data = null;

            MySqlConnection con = DBConnection.ConnectDatabase();

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

                if (reader.HasRows)
                {
                    reader.Read();
                    data = new DBRetailers();

                    data.Date       = reader.GetDateTime(0);
                    data.Wallet_Id  = reader.GetString(1);
                    data.Fname      = reader.GetString(2);
                    data.Lname      = reader.GetString(3);
                    data.Birth_Date = reader.GetDateTime(4);
                    data.Province   = reader.GetString(5);
                    data.City       = reader.GetString(6);
                    data.Barangay   = reader.GetString(7);
                    data.BlockStr   = reader.GetString(8);
                    data.Balance    = reader.GetFloat(9);
                    data.Frozen     = reader.GetFloat(10);
                    data.Sponsor_Id = reader.GetString(11);
                }

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

            return(data);
        }