Example #1
0
        //Load Item Button
        private void button5_Click(object sender, EventArgs e)
        {
            String name     = RestaurantName.Text.ToString();
            String location = RestaurantLocation.Text.ToString();

            if (fieldCheckForRestaurant(name, location))
            {
                Restaurant restaurant = new Restaurant();
                restaurant.Name     = name;
                restaurant.Location = location;
                RestaurantService restaurantService = new RestaurantService();
                if (restaurantService.GetByLocation(restaurant) == "exist")
                {
                    int RID = restaurantService.GetRID(restaurant);
                    Load.Text = name + '-' + location;
                    cellFlag  = false;
                    LoadItem(RID);
                }
                else if (restaurantService.GetByLocation(restaurant) == "non-exist")
                {
                    MessageBox.Show("Restaurant Doesn't Exist!");
                }
            }
            else
            {
                MessageBox.Show("To load item kindly provide the restaurant name and location!");
            }
        }
        //Restaurant add button - recieves texts from RestaurantName, RestaurantLocation, EnvironmentRate, BehaviourRate and add to restaurant table
        private void button1_Click(object sender, EventArgs e)
        {
            String name              = RestaurantName.Text.ToString();
            String location          = RestaurantLocation.Text.ToString();
            String stringEnvironment = EnvironmentRate.Text.ToString();
            String stringBehaviour   = BehaviourRate.Text.ToString();
            int    environment       = 0;
            int    behaviour         = 0;
            int    eflag             = 0;
            int    bflag             = 0;

            if (fieldCheckForRestaurant(name, location, stringEnvironment, stringBehaviour))
            {
                if (RateVerify(EnvironmentRate))
                {
                    environment = int.Parse(stringEnvironment);
                    eflag       = 1;
                }
                if (RateVerify(BehaviourRate))
                {
                    behaviour = int.Parse(stringBehaviour);
                    bflag     = 1;
                }

                if (eflag == 1 && bflag == 1)
                {
                    Restaurant restaurant = new Restaurant();
                    restaurant.Name        = name;
                    restaurant.Environment = environment;
                    restaurant.Location    = location;
                    restaurant.Behaviour   = behaviour;

                    RestaurantService restaurantService = new RestaurantService();
                    if (restaurantService.GetByLocation(restaurant) == "non-exist")
                    {
                        int RID = restaurantService.GetRID();
                        restaurant.Rid = RID + 1;
                        if (restaurantService.AddRestaurant(restaurant) == 1)
                        {
                            MessageBox.Show("Restaurant Added Successfully!");
                            LoadRestaurant();
                        }
                        else
                        {
                            MessageBox.Show("Couldn't Add Restaurant!");
                        }
                    }
                    else if (restaurantService.GetByLocation(restaurant) == "exist")
                    {
                        MessageBox.Show("Restaurant Already Exist");
                    }
                }
            }
            else
            {
                MessageBox.Show("Please check all field is filled or not");
            }
        }
Example #3
0
        //Remove Restaurant and All item
        public void RemoveRestaurant()
        {
            String name     = RestaurantName.Text.ToString();
            String location = RestaurantLocation.Text.ToString();

            if (fieldCheckForRestaurant(name, location))
            {
                Restaurant restaurant = new Restaurant();
                restaurant.Name     = name;
                restaurant.Location = location;

                RestaurantService restaurantService = new RestaurantService();
                Item item = new Item();

                if (restaurantService.GetByLocation(restaurant) == "exist")
                {
                    int         rid         = restaurantService.GetRID(restaurant);
                    ItemService itemService = new ItemService();
                    item.Rid       = rid;
                    restaurant.Rid = rid;

                    if (restaurantService.RemoveRestaurant(restaurant) == 1)
                    {
                        MessageBox.Show("Restaurant Removed Successfully!");
                        LoadRestaurant();
                    }
                    else
                    {
                        MessageBox.Show("Couldn't Remove Restaurant!");
                    }

                    if (itemService.RemoveAllItem(item) == 1)
                    {
                        MessageBox.Show("Item of that Restaurant Removed Successfully!");
                    }
                    else
                    {
                        MessageBox.Show("No Item Exist For This Restaurant!");
                    }
                }
                else
                {
                    MessageBox.Show("Restaurant Doesn't Exist");
                }
            }
            else
            {
                MessageBox.Show("Please fill Restaurant name and location to delete");
            }
        }
Example #4
0
        //Remove Particular item
        public void RemoveItem()
        {
            String name     = RestaurantName.Text.ToString();
            String location = RestaurantLocation.Text.ToString();
            String iname    = textBox3.Text.ToString();

            if (fieldCheckForItem(name, location, iname))
            {
                Restaurant restaurant = new Restaurant();
                restaurant.Name     = name;
                restaurant.Location = location;
                RestaurantService restaurantService = new RestaurantService();

                if (restaurantService.GetByLocation(restaurant) == "exist")
                {
                    int         rid         = restaurantService.GetRID(restaurant);
                    ItemService itemService = new ItemService();
                    Item        item        = new Item();
                    item.Rid  = rid;
                    item.Name = iname;
                    if (itemService.RemoveItem(item) == 1)
                    {
                        MessageBox.Show("Item Removed Successfully!");
                        LoadItem(rid);
                    }
                    else
                    {
                        MessageBox.Show("Item Doesn't Exist!");
                    }
                }
                else
                {
                    MessageBox.Show("Restaurant Doesn't Exist");
                }
            }
            else
            {
                MessageBox.Show("Please fill Restaurant name, location and item name to delete");
            }
        }
Example #5
0
        //Rate Item method
        public void rateItem()
        {
            String ItemName = iName.Text.ToString();
            String ItemRate = iRate.Text.ToString();

            int rate  = 0;
            int rflag = 0;

            //Check field is filled or not
            if (fieldCheckForItemRate(ItemName, ItemRate))
            {
                //Check rate if it's a number from 0 - 10
                if (numberVerify(iRate))
                {
                    rate  = int.Parse(ItemRate);
                    rflag = 1;
                }

                if (rflag == 1)
                {
                    Item item = new Item();
                    item.Name   = ItemName;
                    item.Rating = rate;

                    ItemService itemService = new ItemService();

                    Restaurant restaurant = new Restaurant();
                    restaurant.Name     = name;
                    restaurant.Location = location;

                    RestaurantService restaurantService = new RestaurantService();

                    if (restaurantService.GetByLocation(restaurant) == "exist")
                    {
                        int RID = restaurantService.GetRID(restaurant);
                        item.Rid = RID;
                        if (itemService.GetByItemName(item) == "exist")
                        {
                            if (itemService.RateItem(item) == 1)
                            {
                                MessageBox.Show("Item Rated Successfully!");
                                ratingsetDel.Invoke(name, location);
                            }
                            else
                            {
                                MessageBox.Show("Couldn't Rate Item!");
                            }
                        }
                        else
                        {
                            MessageBox.Show("Item Doesn't Exist!");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Restaurant Doesn't Exist");
                    }
                }
                else
                {
                    MessageBox.Show("Please check item rate is given or not");
                }
            }
            else
            {
                MessageBox.Show("Please check Item Name and Rate is filled or not");
            }
        }
Example #6
0
        //Add new item method
        public void addNewItem()
        {
            String ItemName = textBox5.Text.ToString();
            String ItemRate = textBox6.Text.ToString();
            int    rate     = 0;
            int    rflag    = 0;

            if (fieldCheckForItemRate(ItemName, ItemRate))
            {
                if (numberVerify(textBox6))
                {
                    rate  = int.Parse(ItemRate);
                    rflag = 1;
                }

                if (rflag == 1)
                {
                    Item item = new Item();
                    item.Name   = ItemName;
                    item.Rating = rate;

                    ItemService itemService = new ItemService();

                    Restaurant restaurant = new Restaurant();
                    restaurant.Name     = name;
                    restaurant.Location = location;

                    RestaurantService restaurantService = new RestaurantService();

                    if (restaurantService.GetByLocation(restaurant) == "exist")
                    {
                        int RID = restaurantService.GetRID(restaurant);
                        item.Rid = RID;
                        if (itemService.GetByItemName(item) == "non-exist")
                        {
                            int IID = itemService.GetIID();
                            item.Iid = IID + 1;

                            if (itemService.AddItem(item) == 1)
                            {
                                MessageBox.Show("Item Created and Rated Successfully!");
                                ratingsetDel.Invoke(name, location);
                            }
                            else
                            {
                                MessageBox.Show("Couldn't Create Item!");
                            }
                        }
                        else
                        {
                            MessageBox.Show("Item Already Exist!");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Restaurant Doesn't Exist");
                    }
                }
                else
                {
                    MessageBox.Show("Please check new item rate is given or not");
                }
            }
            else
            {
                MessageBox.Show("Please check Item Name and Rate is filled or not");
            }
        }
        //Item add button recieves texts from ItemName, ItemRate and add to item table
        private void button2_Click(object sender, EventArgs e)
        {
            String name     = RestaurantName.Text.ToString();
            String location = RestaurantLocation.Text.ToString();
            String IName    = ItemName.Text.ToString();
            String IRate    = ItemRate.Text.ToString();
            int    rate     = 0;
            int    rflag    = 0;

            if (fieldCheckForItem(name, location, IName, IRate))
            {
                if (RateVerify(ItemRate))
                {
                    rate  = int.Parse(IRate);
                    rflag = 1;
                }

                if (rflag == 1)
                {
                    Item item = new Item();
                    item.Name   = IName;
                    item.Rating = rate;

                    ItemService itemService = new ItemService();

                    Restaurant restaurant = new Restaurant();
                    restaurant.Name     = name;
                    restaurant.Location = location;

                    RestaurantService restaurantService = new RestaurantService();

                    if (restaurantService.GetByLocation(restaurant) == "exist")
                    {
                        int RID = restaurantService.GetRID(restaurant);
                        item.Rid = RID;
                        if (itemService.GetByItemName(item) == "non-exist")
                        {
                            int IID = itemService.GetIID();
                            item.Iid = IID + 1;

                            if (itemService.AddItem(item) == 1)
                            {
                                MessageBox.Show("Item Added Successfully!");
                                LoadItem(item.Rid);
                            }
                            else
                            {
                                MessageBox.Show("Couldn't Add Item!");
                            }
                        }
                        else if (itemService.GetByItemName(item) == "exist")
                        {
                            MessageBox.Show("Item Already Exist!");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Restaurant Doesn't Exist");
                    }
                }
                else
                {
                    MessageBox.Show("Please check new item rate is given or not");
                }
            }
            else
            {
                MessageBox.Show("Please check restaurant Name, Location, Item Name and Rate is filled or not");
            }
        }