private static List<ShopInfo> QueryAllShopList()
        {
            List<ShopInfo> ShopList = new List<ShopInfo>();
            MySql.Data.MySqlClient.MySqlConnection msqlConnection = OpenDbConnection();

            try
            {   //define the command reference
                MySql.Data.MySqlClient.MySqlCommand msqlCommand = new MySql.Data.MySqlClient.MySqlCommand();
                msqlCommand.Connection = msqlConnection;

                msqlCommand.CommandText = "Select * From shop;";
                MySql.Data.MySqlClient.MySqlDataReader msqlReader = msqlCommand.ExecuteReader();

                while (msqlReader.Read())
                {
                    ShopInfo Shop = new ShopInfo();

                    Shop.id = msqlReader.GetString("id");
                    Shop.name = msqlReader.GetString("name");
                    Shop.tag = msqlReader.GetString("tag");
                    Shop.type = msqlReader.GetString("type");
                    Shop.availableinfloor = msqlReader.GetString("availableinfloor");
                    Shop.rating = msqlReader.GetString("rating");
                    Shop.description = msqlReader.GetString("description");
                    Shop.availableProduct = msqlReader.GetString("availableProduct");

                    ShopList.Add(Shop);
                }
            }

            catch (Exception er)
            {
            }
            finally
            {

                msqlConnection.Close();
            }

            return ShopList;
        }
        private static List<ShopInfo> searchAllShopList(ShopInfo shopinfo)
        {
            List<ShopInfo> ShopList = new List<ShopInfo>();

            MySql.Data.MySqlClient.MySqlConnection msqlConnection = OpenDbConnection();

            try
            {   //define the command reference
                MySql.Data.MySqlClient.MySqlCommand msqlCommand = new MySql.Data.MySqlClient.MySqlCommand();
                msqlCommand.Connection = msqlConnection;

                msqlCommand.CommandText = "Select * From shop where id = @input or name = @input or tag = @input or type = @input or rating = @input or description = @input ; ";

                msqlCommand.Parameters.AddWithValue("@input", shopinfo.name);
                MySql.Data.MySqlClient.MySqlDataReader msqlReader = msqlCommand.ExecuteReader();

                while (msqlReader.Read())
                {
                    ShopInfo Shop = new ShopInfo();

                    Shop.id = msqlReader.GetString("id");
                    Shop.name = msqlReader.GetString("name");
                    Shop.tag = msqlReader.GetString("tag");
                    Shop.type = msqlReader.GetString("type");
                    Shop.availableinfloor = msqlReader.GetString("availableinfloor");
                    Shop.rating = msqlReader.GetString("rating");
                    Shop.description = msqlReader.GetString("description");

                    ShopList.Add(Shop);
                }

            }
            catch (Exception er)
            {
            }
            finally
            {
                //always close the connection
                msqlConnection.Close();
            }

            return ShopList;
        }
        public static List<ShopInfo> GetSelectedShopList(ShopInfo shopInfoObj)
        {
            List<ShopInfo> ShopList = new List<ShopInfo>();
            MySql.Data.MySqlClient.MySqlConnection msqlConnection = OpenDbConnection();

            try
            {   //define the command reference
                MySql.Data.MySqlClient.MySqlCommand msqlCommand = new MySql.Data.MySqlClient.MySqlCommand();
                msqlCommand.Connection = msqlConnection;

                msqlCommand.CommandText = "Select * From shop where name = @name;";
                MySql.Data.MySqlClient.MySqlDataReader msqlReader = msqlCommand.ExecuteReader();

                while (msqlReader.Read())
                {
                    ShopInfo Shop = new ShopInfo();
                    msqlCommand.Parameters.AddWithValue("@name", Shop.name);

                    ShopList.Add(Shop);
                }
            }

            catch (Exception er)
            {
            }
            finally
            {

                msqlConnection.Close();
            }

            return ShopList;
        }
 public static List<ShopInfo> searchShopList(ShopInfo shopinfo)
 {
     return searchAllShopList(shopinfo);
 }
 public static List<ShopInfo> getFirstFloorShopList(ShopInfo shopinfo)
 {
     return getFirstfloorAllShopList(shopinfo);
 }
 public static List<ShopInfo> getSecondFloorShopList(ShopInfo shopinfo)
 {
     return getSecondfloorAllShopList(shopinfo);
 }
        public static int DoEnterShop(ShopInfo NewShop)
        {
            int returnVal = 0;
            MySql.Data.MySqlClient.MySqlConnection msqlConnection = OpenDbConnection();

            try
            {
                //define the command reference
                MySql.Data.MySqlClient.MySqlCommand msqlCommand = new MySql.Data.MySqlClient.MySqlCommand();

                //define the connection used by the command object
                msqlCommand.Connection = msqlConnection;

                msqlCommand.CommandText = "INSERT INTO shop(id,name,tag,type,availableinfloor,rating,description,availableProduct) "
                                    + "VALUES(@id,@name,@tag,@type,@availableinfloor,@rating,@description,@availableProduct)";

                msqlCommand.Parameters.AddWithValue("@id", NewShop.id);
                msqlCommand.Parameters.AddWithValue("@name", NewShop.name);
                msqlCommand.Parameters.AddWithValue("@tag", NewShop.tag);
                msqlCommand.Parameters.AddWithValue("@type", NewShop.type);
                msqlCommand.Parameters.AddWithValue("@availableinfloor", NewShop.@availableinfloor);
                msqlCommand.Parameters.AddWithValue("@rating", NewShop.rating);
                msqlCommand.Parameters.AddWithValue("@description", NewShop.description);
                msqlCommand.Parameters.AddWithValue("@availableProduct", NewShop.availableProduct);
                msqlCommand.ExecuteNonQuery();

                returnVal = 1;
            }
            catch (Exception er)
            {
                returnVal = 0;
            }
            finally
            {
                //always close the connection
                msqlConnection.Close();
            }
            return returnVal;
        }
        public static void EditShop(ShopInfo newUpdateShop)
        {
            MySql.Data.MySqlClient.MySqlConnection msqlConnection = OpenDbConnection();

            try
            {
                //define the command reference
                MySql.Data.MySqlClient.MySqlCommand msqlCommand = new MySql.Data.MySqlClient.MySqlCommand();
                msqlCommand.Connection = msqlConnection;

                msqlCommand.CommandText = "UPDATE shop SET name=@name,tag=@tag,type=@type,availableinfloor=@availableinfloor,rating=@rating,description=@description  WHERE id=@id";

                msqlCommand.Parameters.AddWithValue("@name", newUpdateShop.name);
                msqlCommand.Parameters.AddWithValue("@tag", newUpdateShop.tag);
                msqlCommand.Parameters.AddWithValue("@type", newUpdateShop.type);
                msqlCommand.Parameters.AddWithValue("@availableinfloor", newUpdateShop.availableinfloor);
                msqlCommand.Parameters.AddWithValue("@rating", newUpdateShop.rating);
                msqlCommand.Parameters.AddWithValue("@description", newUpdateShop.description);
                msqlCommand.Parameters.AddWithValue("@id", newUpdateShop.id);

                msqlCommand.ExecuteNonQuery();

            }
            catch (Exception er)
            {
            }
            finally
            {
                //always close the connection
                msqlConnection.Close();
            }
        }
        private void goShopBtn_Click(object sender, RoutedEventArgs e)
        {
            //shopDetailsList.UnselectAll();
            if (shopNameSrchCB.Text == "")
                fetchShopData();
            else
            {
                ShopInfo shopInfo = new ShopInfo();
                shopInfo.name = shopNameSrchCB.Text;

                List<ShopInfo> shops = DbInteraction.searchShopList(shopInfo);

                _shopsCollection.Clear();

                foreach (ShopInfo shop in shops)
                {
                    _shopsCollection.Add(shop);
                }
            }
        }
        private void GetSelectedFirstFloorItem()
        {
            ShopInfo shopInfo = new ShopInfo();
            shopInfo.name = "First Floor";

            List<ShopInfo> shops = DbInteraction.getFirstFloorShopList(shopInfo);

            _frstfloorshopsCollection.Clear();

            foreach (ShopInfo shop in shops)
            {
                _frstfloorshopsCollection.Add(shop);
            }
        }
        private void GetSelectedGroundFloorItem()
        {
            ShopInfo shopInfo = new ShopInfo();
            shopInfo.name = "Ground Floor";

            List<ShopInfo> shops = DbInteraction.getGroundfloorShopList(shopInfo);

            _shopsCollection.Clear();

            foreach (ShopInfo shop in shops)
            {
                _shopsCollection.Add(shop);
            }
        }
        private void submitkShopmangBtn_Click(object sender, RoutedEventArgs e)
        {
            string availableProduct = "";

            for (int i = 0; i < availproductView.Items.Count; i++)
            {
                availableProduct += availproductView.Items[i].ToString() + ", ";
            }

            if (!shopnameTB.Text.Equals("") && !shopTagTB.Text.Equals("") && !shopTypeCB.Text.Equals("") && !shopRateTB.Text.Equals("") && !shopDescriptionTB.Text.Equals(""))
            {

            ShoppingMallData.ShopInfo newShop = new ShoppingMallData.ShopInfo();

            newShop.id = GenerateId();

            newShop.name = shopnameTB.Text;
            newShop.tag = shopTagTB.Text;
            newShop.type = shopTypeCB.Text;
            newShop.availableinfloor = availableShopFloorCB.Text;
            newShop.rating = shopRateTB.Text;
            newShop.description = shopDescriptionTB.Text;
            newShop.availableProduct = availableProduct;

            ShoppingMallDb.DbInteraction.DoEnterShop(newShop);
            clearShopFields();
            fetchShopData();
            }

            else
            {
                MessageBox.Show("Please Insert Info Properly");
            }
        }
        private void searchAdminShopmangBtn_Click(object sender, RoutedEventArgs e)
        {
            if (searchAdminShopmangTB.Text == "")
                fetchShopData();
            else
            {
                ShopInfo shopInfo = new ShopInfo();
                shopInfo.name = searchAdminShopmangTB.Text;

                List<ShopInfo> shops = DbInteraction.searchShopList(shopInfo);

                _shopsCollection.Clear();

                foreach (ShopInfo shop in shops)
                {
                    _shopsCollection.Add(shop);
                }
            }
        }