public bool Insert(FoodOrder a)
 {
     try
     {
         string query = "INSERT into OrderTable VALUES ('" + a.OrderId + "', '" + a.TotalPrice + "','" + a.AccountId + "','" + a.Status + "')";
         DatabaseConnectionClass dcc = new DatabaseConnectionClass();
         dcc.ConnectWithDB();
         int x = dcc.ExecuteSQL(query);
         dcc.CloseConnection();
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
        public List <Account> SearchAccounts(string text)
        {
            string                  query = "SELECT * from AccountTable WHERE AccountId LIKE '%" + text + "%' OR Name LIKE '%" + text + "%'";
            List <Account>          aList = new List <Account>();
            DatabaseConnectionClass dcc   = new DatabaseConnectionClass();

            dcc.ConnectWithDB();
            SqlDataReader sdr = dcc.GetData(query);

            while (sdr.Read())
            {
                Account a = new Account();
                a.AccountId   = sdr["AccountId"].ToString();
                a.Name        = sdr["Name"].ToString();
                a.AccountType = sdr["AccountType"].ToString();

                aList.Add(a);
            }
            return(aList);
        }
        public Food GetFoods(string foodname)
        {
            string query = "SELECT * from FoodTable WHERE FoodName='" + foodname + "'";
            Food   a     = null;
            DatabaseConnectionClass dcc = new DatabaseConnectionClass();

            dcc.ConnectWithDB();
            SqlDataReader sdr = dcc.GetData(query);

            if (sdr.Read())
            {
                a        = new Food();
                a.FoodId = sdr["FoodId"].ToString();


                a.FoodName  = sdr["FoodName"].ToString();
                a.FoodPrice = float.Parse((sdr["FoodPrice"].ToString()));
            }
            dcc.CloseConnection();
            return(a);
        }
        public FoodOrder GetPay(int OrderId)
        {
            string    query             = "SELECT * from OrderTable WHERE OrderId='" + OrderId + "'";
            FoodOrder a                 = null;
            DatabaseConnectionClass dcc = new DatabaseConnectionClass();

            dcc.ConnectWithDB();
            SqlDataReader sdr = dcc.GetData(query);

            if (sdr.Read())
            {
                a         = new FoodOrder();
                a.OrderId = int.Parse((sdr["OrderId"].ToString()));


                a.AccountId  = sdr["AccountId"].ToString();
                a.TotalPrice = float.Parse((sdr["TotalPrice"].ToString()));
            }
            dcc.CloseConnection();
            return(a);
        }
        public List <string> GetAccontid()
        {
            string                  query = "SELECT * from AccountTable";
            List <string>           aList = new List <string>();
            DatabaseConnectionClass dcc   = new DatabaseConnectionClass();

            dcc.ConnectWithDB();
            SqlDataReader sdr = dcc.GetData(query);

            while (sdr.Read())
            {
                Account a = new Account();
                a.AccountId = sdr["AccountId"].ToString();
                a.Password  = sdr["Password"].ToString();

                a.Name        = sdr["Name"].ToString();
                a.AccountType = sdr["AccountType"].ToString();

                aList.Add(a.AccountId);
            }
            return(aList);
        }
        public string UserLoginVerification(Account a)
        {
            string query = "SELECT * from AccountTable WHERE AccountId= '" + a.AccountId + "' AND Password= '******'";
            DatabaseConnectionClass dcc = new DatabaseConnectionClass();

            dcc.ConnectWithDB();
            SqlDataReader sdr = dcc.GetData(query);

            if (sdr.Read())
            {
                //a.Name = sdr["AccountName"].ToString();

                a.AccountType = sdr["AccountType"].ToString();
                dcc.CloseConnection();
                return(a.AccountType);
            }
            else
            {
                dcc.CloseConnection();
                return("false");
            }
        }
        public Account GetAccountType(string AccountId)
        {
            string  query = "SELECT * from AccountTable WHERE AccountId= '" + AccountId + "'";
            Account a     = null;
            DatabaseConnectionClass dcc = new DatabaseConnectionClass();

            dcc.ConnectWithDB();
            SqlDataReader sdr = dcc.GetData(query);

            if (sdr.Read())
            {
                a           = new Account();
                a.AccountId = sdr["AccountId"].ToString();
                a.Password  = sdr["Password"].ToString();
                a.Name      = sdr["Name"].ToString();


                a.AccountType = sdr["AccountType"].ToString();
            }
            dcc.CloseConnection();
            return(a);
        }
        public List <Food> GetAllFoods()
        {
            string                  query = "SELECT * from FoodTable";
            List <Food>             aList = new List <Food>();
            DatabaseConnectionClass dcc   = new DatabaseConnectionClass();

            dcc.ConnectWithDB();
            SqlDataReader sdr = dcc.GetData(query);

            while (sdr.Read())
            {
                Food a = new Food();
                a.FoodId = sdr["FoodId"].ToString();


                a.FoodName  = sdr["FoodName"].ToString();
                a.FoodPrice = float.Parse((sdr["FoodPrice"].ToString()));

                aList.Add(a);
            }
            return(aList);
        }
        public List <FoodOrder> GetStatusOrder(string status)
        {
            string                  query = "SELECT * from OrderTable WHERE Status='" + status + "'";
            List <FoodOrder>        aList = new List <FoodOrder>();
            DatabaseConnectionClass dcc   = new DatabaseConnectionClass();

            dcc.ConnectWithDB();
            SqlDataReader sdr = dcc.GetData(query);

            while (sdr.Read())
            {
                FoodOrder a = new FoodOrder();
                a.AccountId  = sdr["AccountId"].ToString();
                a.TotalPrice = float.Parse((sdr["TotalPrice"].ToString()));

                a.OrderId = int.Parse((sdr["OrderId"].ToString()));
                a.Status  = sdr["Status"].ToString();



                aList.Add(a);
            }
            return(aList);
        }