Beispiel #1
0
        protected void btnSignUpRestaurant_Click(object sender, EventArgs e)
        {
            if (ValidateRestaurantSignUp())
            {
                DataSet ds;
                string  name           = txtSURName.Text;
                string  logo           = txtSURLogo.Text;
                string  email          = txtSUREmail.Text;
                string  password       = txtSURPassword.Text;
                string  phoneNumber    = txtSURPhoneNumber.Text;
                string  type           = txtSURType.Text;
                string  bankingAccount = txtSURAccount.Text;
                string  bankingRoute   = txtSURRouting.Text;

                ds = gd.GetProfile(email);
                //Makes sure that the email is not already in use
                if (ds.Tables[0].Rows.Count == 0)
                {
                    sd.CreateRestaurant(email, password, "Restaurant", name, logo, phoneNumber, type);

                    DataSet user   = gd.GetProfile(email);
                    string  userid = user.Tables[0].Rows[0]["userID"].ToString();

                    int walletID = apic.CreateWalletUser(userid, email, password, bankingAccount, bankingRoute);

                    sd.AddWalletID(int.Parse(userid), walletID);

                    LogInAsRestaurant(email);
                }
                else
                {
                    ErrorLabel.FillError("That email is already connected to an account");
                }
            }
        }
Beispiel #2
0
        internal void LogInAsCustomer(string email)
        {
            DataSet user     = gd.GetProfile(email);
            DataSet customer = gd.GetCustomer(user.Tables[0].Rows[0]["userID"].ToString());
            DataSet key      = gd.GetAPIKey();

            if (customer.Tables.Count > 0)
            {
                Customer c = CreateCustomer(
                    user.Tables[0].Rows[0]["userID"].ToString(),
                    customer.Tables[0].Rows[0]["firstName"].ToString(),
                    customer.Tables[0].Rows[0]["lastName"].ToString(),
                    user.Tables[0].Rows[0]["email"].ToString(),
                    user.Tables[0].Rows[0]["password"].ToString(),
                    customer.Tables[0].Rows[0]["phoneNumber"].ToString(),
                    customer.Tables[0].Rows[0]["billingAddress"].ToString(),
                    customer.Tables[0].Rows[0]["deliveryAddress"].ToString(),
                    key.Tables[0].Rows[0]["apiKey"].ToString());
                Session["User"] = c;

                Response.Redirect(lh.RestaurantSelection);
            }
            else
            {
                ErrorLabel.FillError("That customer does not exist");
            }
        }
        internal bool CheckPassword()
        {
            Customer c = (Customer)Session["User"];

            if (txtPasswordCheck.Text.Equals(c.Password))
            {
                ErrorLabel.FillError("");
                return(true);
            }
            else
            {
                ErrorLabel.FillError("That is the wrong password");
                return(false);
            }
        }
Beispiel #4
0
 internal bool ValidateCustomerSignUp()
 {
     if (!CheckIfTxtFilled(txtSUCFirstName))
     {
         ErrorLabel.FillError("Please fill in the first name");
         return(false);
     }
     else if (!CheckIfTxtFilled(txtSUCLastName))
     {
         ErrorLabel.FillError("Please fill in the last name");
         return(false);
     }
     else if (!CheckIfTxtFilled(txtSUCEmail))
     {
         ErrorLabel.FillError("Please fill in the email");
         return(false);
     }
     else if (!CheckIfTxtFilled(txtSUCPassword))
     {
         ErrorLabel.FillError("Please fill in the password");
         return(false);
     }
     else if (!CheckIfTxtFilled(txtSUCPhoneNumber))
     {
         ErrorLabel.FillError("Please fill in the phonenumber");
         return(false);
     }
     else if (!CheckIfTxtFilled(txtSUCDeliveryAddress))
     {
         ErrorLabel.FillError("Please fill in the delivery address");
         return(false);
     }
     else if (!CheckIfTxtFilled(txtSUCBillingAddress))
     {
         ErrorLabel.FillError("Please fill in the billing address");
         return(false);
     }
     else
     {
         ErrorLabel.FillError("");
     }
     return(true);
 }
Beispiel #5
0
 internal bool ValidateLogin()
 {
     ErrorLabel.FillError("Checking login");
     if (!CheckIfTxtFilled(txtLoginUsername))
     {
         ErrorLabel.FillError("Please fill in the email");
         return(false);
     }
     else if (!CheckIfTxtFilled(txtLoginPassword))
     {
         ErrorLabel.FillError("Please fill in the password");
         return(false);
     }
     else
     {
         ErrorLabel.FillError("");
     }
     return(true);
 }
Beispiel #6
0
        protected void btnSignUpCustomer_Click(object sender, EventArgs e)
        {
            if (ValidateCustomerSignUp())
            {
                DataSet ds;
                string  firstName       = txtSUCFirstName.Text;
                string  lastName        = txtSUCLastName.Text;
                string  email           = txtSUCEmail.Text;
                string  password        = txtSUCPassword.Text;
                string  phoneNumber     = txtSUCPhoneNumber.Text;
                string  deliveryAddress = txtSUCDeliveryAddress.Text;
                string  billingAddress  = txtSUCBillingAddress.Text;
                string  bankingAccount  = txtSUCAccount.Text;
                string  bankingRoute    = txtSUCRouting.Text;

                ds = gd.GetProfile(email);
                //Makes sure that the email is not already in use
                if (ds.Tables[0].Rows.Count == 0)
                {
                    sd.CreateCustomer(email, password, "Customer", firstName, lastName, phoneNumber, deliveryAddress, billingAddress);

                    DataSet user   = gd.GetProfile(email);
                    string  userid = user.Tables[0].Rows[0]["userID"].ToString();

                    try
                    {
                        int walletID = apic.CreateWalletUser(userid, email, password, bankingAccount, bankingRoute);
                        sd.AddWalletID(int.Parse(userid), walletID);
                    }
                    catch
                    {
                        ErrorLabel.FillError("Unable to create virtual wallet. Please contact your chosen restaurant about payment");
                    }

                    LogInAsCustomer(email);
                }
                else
                {
                    ErrorLabel.FillError("That email is already connected to an account");
                }
            }
        }
Beispiel #7
0
        protected void btnCheckOut_Click(object sender, EventArgs e)
        {
            try
            {
                Cart CheckOutCart = new Cart();
                FillCartFromGridView(ref CheckOutCart, gvCart);
                Customer user          = (Customer)Session["User"];
                string   restaurantNum = Session["Restaurant"].ToString();

                apic.ProcessPayment(user.WalletID, restaurantNum, CheckOutCart.GetCartTotal().ToString(), "Payment");

                Session["Cart"] = null;

                sd.CreateOrder(int.Parse(user.UserID), int.Parse(restaurantNum), CheckOutCart);

                ErrorLabel.FillError("Your order has been placed successfully");
            }
            catch
            {
                ErrorLabel.FillError("An error occured while processing your payment. You may not have enough money. Please go to your profile and add funds. Then you can return here and place your order.");
            }
        }
Beispiel #8
0
 internal bool ValidateRestaurantSignUp()
 {
     if (!CheckIfTxtFilled(txtSURName))
     {
         ErrorLabel.FillError("Please fill in the restaurant name");
         return(false);
     }
     else if (!CheckIfTxtFilled(txtSURLogo))
     {
         ErrorLabel.FillError("Please fill in the logo url");
         return(false);
     }
     else if (!CheckIfTxtFilled(txtSUREmail))
     {
         ErrorLabel.FillError("Please fill in the email");
         return(false);
     }
     else if (!CheckIfTxtFilled(txtSURPassword))
     {
         ErrorLabel.FillError("Please fill in the password");
         return(false);
     }
     else if (!CheckIfTxtFilled(txtSURPhoneNumber))
     {
         ErrorLabel.FillError("Please fill in the phone number");
         return(false);
     }
     else if (!CheckIfTxtFilled(txtSURType))
     {
         ErrorLabel.FillError("Please fill in the type");
         return(false);
     }
     else
     {
         ErrorLabel.FillError("");
     }
     return(true);
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            WalletUser wu = new WalletUser();
            Customer   c  = (Customer)Session["User"];

            try
            {
                wu                 = apic.GetWalletUser(c.Email);
                wu.email           = c.Email;
                wu.password        = c.Password;
                txtSUCRouting.Text = wu.bankRouting;
                txtSUCAccount.Text = wu.bankAccount;
            }
            catch
            {
                ErrorLabel.FillError("A problem has occured with the API. Please try again later.");
            }


            txtAccountBalance.Text = "$" + wu.amount.ToString();

            txtSUCBillingAddress.Text  = c.BillingAddress;
            txtSUCDeliveryAddress.Text = c.DeliveryAddress;
            txtSUCEmail.Text           = c.Email;
            txtSUCFirstName.Text       = c.FirstName;
            txtSUCLastName.Text        = c.LastName;
            txtSUCPassword.Text        = c.Password;
            txtSUCPhoneNumber.Text     = c.PhoneNumber;


            if (!IsPostBack)
            {
                DataSet ds = gd.GetOrders(int.Parse(c.UserID));

                gvPreviousOrders.DataSource = ds;
                gvPreviousOrders.DataBind();
            }
        }
Beispiel #10
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            if (ValidateLogin())
            {
                string username = txtLoginUsername.Text;
                string password = txtLoginPassword.Text;

                DataSet ds = gd.GetProfile(username);

                if (ds.Tables[0].Rows[0]["type"].Equals("Customer"))
                {
                    LogInAsCustomer(username);
                }
                else if (ds.Tables[0].Rows[0]["type"].Equals("Restaurant"))
                {
                    LogInAsRestaurant(username);
                }
                else
                {
                    ErrorLabel.FillError("User type is invalid, please contact support");
                }
            }
        }
Beispiel #11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ErrorLabel.FillError("");

                if (Session["Cart"] != null)
                {
                    int   totalQuantity = 0;
                    float total         = 0;

                    Cart cart = (Cart)Session["Cart"];
                    gvCart.DataSource = cart.GetList();
                    gvCart.DataBind();

                    for (int i = 0; i < cart.GetSize(); i++)
                    {
                        totalQuantity = totalQuantity + int.Parse(((TextBox)gvCart.Rows[i].FindControl("txtQuantity")).Text);
                        total         = total + float.Parse(gvCart.Rows[i].Cells[PRICEROW].Text.Substring(1));
                    }

                    gvCart.Columns[0].FooterText            = "Total Quantity";
                    gvCart.Columns[QUANTITYROW].FooterText  = totalQuantity.ToString();
                    gvCart.Columns[PRICEROW - 1].FooterText = "Total Price:";
                    gvCart.Columns[PRICEROW].FooterText     = total.ToString();

                    gvCart.DataBind();
                }
                else
                {
                    ErrorLabel.FillError("Your cart is empty, please select some items and comeback.");
                    btnCheckOut.Visible = false;
                    btnClear.Visible    = false;
                    btnDelete.Visible   = false;
                }
            }
        }
Beispiel #12
0
 protected void btnDelete_Click(object sender, EventArgs e)
 {
     ErrorLabel.FillError("Your cart has been deleted");
     Session["Cart"] = null;
 }