Beispiel #1
0
        protected void lnk_View_Click(object sender, EventArgs e)
        {
            int           restId     = Convert.ToInt32((sender as LinkButton).CommandArgument);
            RestaurantBLL rBLL       = new RestaurantBLL();
            Restaurant    restaurant = rBLL.DoRetrieveRestaurantByRestID(restId);

            FoodItemBLL foodItemBLL = new FoodItemBLL();
            DataTable   dt          = new DataTable();

            dt = foodItemBLL.DoRetrieveAllFoodItemByRestId(restId);

            panelViewFoodItems.Visible = true;
            txtRName.Text = restaurant.RestName;

            if (dt != null)
            {
                gv_foodItem.DataSource = dt;
                gv_foodItem.DataBind();
            }

            else
            {
                alertFailure.Visible  = true;
                lblErrorRetrieve.Text = "Error in retrieving food item list";
            }
        }
Beispiel #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["isLogin"] == null)
            {
                Response.Redirect("Login.aspx");
            }

            gv_listofRestaurant.Visible = false;
            gv_listOfFood.Visible       = false;
            btnBack.Visible             = false;
            alertFailure.Visible        = false;
            alertSuccess.Visible        = false;

            OrderItemListBLL orderItemListBLL = new OrderItemListBLL();

            if (Session["generatedId"] == null)
            {
                string transactionId = GenerateRandomString();
                int    result        = orderItemListBLL.DoCheckIfTransactionIDExists(transactionId);

                while (result > 0)
                {
                    transactionId = GenerateRandomString();
                    result        = orderItemListBLL.DoCheckIfTransactionIDExists(transactionId);
                }

                Session["generatedId"] = transactionId;
            }

            else
            {
                Restaurant restaurant = orderItemListBLL.DoCheckOrderLineItemForExistingRestaurant((Session["generatedId"].ToString()));
                if (restaurant != null)
                {
                    btnSearch.Enabled = false;
                    btnBack.Enabled   = false;

                    FoodItemBLL foodItemBLL = new FoodItemBLL();
                    DataTable   dt          = new DataTable();
                    dt = foodItemBLL.DoRetrieveAllFoodItemByRestId(restaurant.RestId);

                    if (dt != null)
                    {
                        lblRestName.Text         = restaurant.RestName;
                        lblRestAddress.Text      = restaurant.RestAddress;
                        gv_listOfFood.DataSource = dt;
                        gv_listOfFood.DataBind();
                        gv_listOfFood.Visible = true;
                    }

                    else
                    {
                        alertFailure.Visible  = true;
                        lblErrorRetrieve.Text = "Error in retrieving food item list";
                    }
                }
            }
        }
Beispiel #3
0
        protected void lnk_Update_Click(object sender, EventArgs e)
        {
            panelViewFoodItem.Visible = true;

            int         foodId      = Convert.ToInt32((sender as LinkButton).CommandArgument);
            FoodItemBLL foodItemBLL = new FoodItemBLL();
            FoodItem    foodItem    = foodItemBLL.DoRetrieveFoodItemByFoodId(foodId);

            panelUpdateFoodItem.Visible = true;

            txtFId.Text = foodId.ToString();
            ddlFCategory.SelectedValue = foodItem.FoodCategory;
            txtFTitle.Text             = foodItem.FoodTitle;
            txtPrice.Text  = foodItem.Price.ToString();
            txtDLimit.Text = foodItem.DailyLimit.ToString();
        }
Beispiel #4
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (txtFTitle.Text.Length <= 0)
            {
                lblFTitleMsg.Text = "Food Title cannot be blank";
            }

            if (txtPrice.Text.Length <= 0)
            {
                lblPriceMsg.Text = "Price cannot be blank";
            }

            if (txtDLimit.Text.Length <= 0)
            {
                lblDLimitMsg.Text = "Daily Limit cannot be blank";
            }

            int    currCount = 0;
            string category  = ddlFCategory.SelectedValue;

            if (txtFTitle.Text.Length > 0 && txtPrice.Text.Length > 0 && txtDLimit.Text.Length > 0)
            {
                FoodItemBLL foodItemBLL = new FoodItemBLL();
                int         result      = foodItemBLL.DoCreateFoodItem(Convert.ToInt32(txtRestId.Text), category, txtFTitle.Text,
                                                                       Convert.ToDouble(txtPrice.Text), Convert.ToInt32(txtDLimit.Text), currCount);

                if (result > 0)
                {
                    alertFoodSuccess.Visible = true;
                }

                else
                {
                    alertFoodFailure.Visible = true;
                    lblFoodFailure.Text      = "Error in creating food item record";
                }

                //Refresh the table
                panelViewFoodItem.Visible = true;
                DataTable dt = new DataTable();
                dt = foodItemBLL.DoRetrieveAllFoodItemByRestId(Convert.ToInt32(txtRestId.Text));
                gv_foodItem.DataSource = dt;
                gv_foodItem.DataBind();
            }
        }
Beispiel #5
0
        public void DoUpdateOrderCountOperation()
        {
            FoodItemBLL foodItemBLL = new FoodItemBLL();

            for (int i = 0; i < gv_currFoodItemList.Rows.Count; i++)
            {
                int      foodId   = int.Parse(gv_currFoodItemList.Rows[i].Cells[2].Text.ToString());
                FoodItem foodItem = foodItemBLL.DoRetrieveFoodItemByFoodId(foodId);

                foodItem.OrderCounter += int.Parse(gv_currFoodItemList.Rows[i].Cells[6].Text.ToString());
                int result = foodItemBLL.DoUpdateOrderCount(foodId, foodItem.OrderCounter);

                if (result < 0)
                {
                    alertFailure.Visible  = true;
                    lblErrorRetrieve.Text = "Unable to update order count for food item code " + foodId;
                    break;
                }
            }
        }
Beispiel #6
0
        protected void gv_listofRestaurant_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int         rowNo  = int.Parse(e.CommandArgument.ToString());
            GridViewRow row    = gv_listofRestaurant.Rows[rowNo];
            int         restId = int.Parse(row.Cells[0].Text);

            if (e.CommandName == "SelectFood")
            {
                lblRestName.Text    = row.Cells[1].Text.ToString();
                lblRestAddress.Text = row.Cells[2].Text.ToString();

                FoodItemBLL foodItemBLL = new FoodItemBLL();
                DataTable   dt          = new DataTable();
                dt = foodItemBLL.DoRetrieveAllFoodItemByRestId(restId);

                if (dt != null)
                {
                    gv_listOfFood.DataSource = dt;
                    gv_listOfFood.DataBind();
                    gv_listOfFood.Visible = true;
                    btnSearch.Enabled     = false;
                    btnBack.Visible       = true;
                }

                else
                {
                    alertFailure.Visible  = true;
                    lblErrorRetrieve.Text = "Error in retrieving food item list";
                }
            }

            if (e.CommandName == "RestaurantReview")
            {
                int restIds = int.Parse(row.Cells[0].Text);
                Response.Redirect("UserViewRestaurantReview.aspx?restId=" + restIds);
            }
        }
Beispiel #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["isLogin"] == null)
            {
                Response.Redirect("Login.aspx");
            }

            panelViewFoodItem.Visible   = false;
            panelUpdateFoodItem.Visible = false;
            alertFoodSuccess.Visible    = false;
            alertFoodFailure.Visible    = false;
            alertOthersFailure.Visible  = false;

            UserAccount user = (UserAccount)Session["UserAccountObj"];

            if (user.UserRole.Equals("Manager"))
            {
                lblAccessRight.Text = "YOU DO NOT HAVE STAFF RIGHTS TO ACCESS THIS FUNCTION";
            }

            else
            {
                if (!IsPostBack)
                {
                    StaffBLL staffBLL = new StaffBLL();
                    Staff    staff    = staffBLL.DoRetrieveStaffByID(user.UserId);

                    if (staff != null)
                    {
                        RestaurantBLL restaurantBLL = new RestaurantBLL();
                        Restaurant    restaurant    = restaurantBLL.DoRetrieveRestaurantByRestID(staff.RestId);

                        panelViewFoodItem.Visible = true;

                        if (restaurant != null)
                        {
                            txtRestId.Text   = restaurant.RestId.ToString();
                            txtRestName.Text = restaurant.RestName;

                            DataTable   dt          = new DataTable();
                            FoodItemBLL foodItemBLL = new FoodItemBLL();
                            dt = foodItemBLL.DoRetrieveAllFoodItemByRestId(restaurant.RestId);

                            if (dt != null)
                            {
                                if (dt.Rows.Count > 0)
                                {
                                    gv_foodItem.DataSource = dt;
                                    gv_foodItem.DataBind();
                                }

                                else
                                {
                                    lblNoFoodItem.Text = "There is currently no food item, you will need to add a new food item";
                                }
                            }

                            else
                            {
                                alertOthersFailure.Visible = true;
                                lblErrorRetrieve.Text      = "Unable to retrieve food item records";
                            }
                        }

                        else
                        {
                            alertOthersFailure.Visible = true;
                            lblErrorRetrieve.Text      = "Unable to retrieve restaurant record";
                        }
                    }

                    else
                    {
                        alertOthersFailure.Visible = true;
                        lblErrorRetrieve.Text      = "Unable to retrieve staff account";
                    }
                }
            }
        }