Exemple #1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            KahnoUser authuser = new KahnoUser();

            if (KahnLib.Login(TextBox1.Text, KahnLib.HashPass(TextBox2.Text), ref authuser))
            {
                Session["localuser"] = authuser;
                Session["UID"]       = authuser.userid;
                if (authuser.isowner == "y")
                {
                    Session["RID"] = authuser.restaurantno;

                    Response.Redirect("Admin.aspx");
                }

                else
                {
                    Response.Redirect("UserHome.aspx");
                }
                //Label5.Text = authuser.ToString();
            }
            else
            {
                Label4.Visible = true;
            }
        }
Exemple #2
0
 protected void Button2_Click(object sender, EventArgs e)
 {
     KahnLib.removeUser(currentuser.userid);
     currentuser          = null;
     Session["localuser"] = null;
     Response.Redirect("Login.aspx");
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                //populating user object
                currentuser = (KahnoUser)Session["localuser"];
                if (currentuser.userid == 0)
                {
                    Response.Redirect("Login.aspx");
                }
                //populating restaurant object
                KahnLib.getRestaurant(currentuser.restaurantno, ref currentRestaurant);
                Session["currentRestaurant"] = currentRestaurant;
                //passing user to the new restaurant screen if they do not have one
                if (currentRestaurant.restaurantID == 0)
                {
                    Response.Redirect("CreateRestaurantForm.aspx");
                }
            }
            catch
            {
                Response.Redirect("Login.aspx");
            }

            if (!this.IsPostBack)
            {
                TextBox1.Text = currentRestaurant.restaurantname;
                TextBox2.Text = currentRestaurant.phone;
            }
        }
Exemple #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ////////checking if user is logged in, copy paste on every page, will redirect to login if not logged in and create the user object
            ///Don't use this one yet, we need a better version
            KahnoUser currentuser = new KahnoUser();

            currentuser = (KahnoUser)Session["localuser"];
            if (currentuser.userid == 0)
            {
                Response.Redirect("Login.aspx");
            }

            if (currentuser.restaurantno == 0)
            {
                Response.Redirect("CreateRestaurantForm.aspx");
            }
            if (currentuser.isowner == "n")
            {
                Response.Redirect("Login.aspx");
            }

            ////////////////////////////////////////////////////////////////

            /////////////creatign restaurant object
            ///
            KahnoRestaurant currentRestaurant = new KahnoRestaurant();

            KahnLib.getRestaurant(currentuser.restaurantno, ref currentRestaurant);
            Session["currentRestaurant"] = currentRestaurant;
            //////////////
            //Label3.Text = "Welcome " + currentuser.fname + " Your restaurant is " + currentRestaurant.restaurantname + currentuser.restaurantno + (Int32)Session["RID"];

            Label3.Text = "Welcome " + currentuser.fname + ", owner of " + currentRestaurant.restaurantname + " with restaurant ID: " + (Int32)Session["RID"];
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            FileUpload img = (FileUpload)imgUpload;

            if (img.HasFile && img.PostedFile != null)
            {
                //if has file
                HttpPostedFile File = imgUpload.PostedFile;

                if (KahnLib.UpdateRestaurantDetails(currentuser.restaurantno, TextBox1.Text, TextBox2.Text, File) > 0 && KahnLib.updateCoordinateDetails(currentRestaurant.coodinateid, Convert.ToDouble(TextBox4.Text), Convert.ToDouble(TextBox3.Text)) > 0)
                {
                    Label5.Text = "Successfully Updated!";
                }
                else
                {
                    Label5.Text = "Update not successful!";
                }
                Label5.Visible = true;
            }
            else
            {
                //if has no file
                if (KahnLib.UpdateRestaurantDetails(currentuser.restaurantno, TextBox1.Text, TextBox2.Text) > 0 && KahnLib.updateCoordinateDetails(currentRestaurant.coodinateid, Convert.ToDouble(TextBox4.Text), Convert.ToDouble(TextBox3.Text)) > 0)
                {
                    Label5.Text = "Successfully Updated!";
                }
                else
                {
                    Label5.Text = "Update not successful!";
                }
                Label5.Visible = true;
            }
        }
Exemple #6
0
        protected void deleteMenuItem_Click(object sender, EventArgs e)
        {
            int menuitemid = Convert.ToInt32((sender as Button).CommandArgument);

            KahnLib.removeMenuItem(menuitemid);

            Response.Redirect("EditMenuForm.aspx");
        }
        protected void lnkSelect_Click(object sender, EventArgs e)
        {
            int             restaurantID      = Convert.ToInt32((sender as Button).CommandArgument);
            KahnoRestaurant currentRestaurant = new KahnoRestaurant();

            KahnLib.getRestaurant(restaurantID, ref currentRestaurant);
            Session["currentRestaurant"] = currentRestaurant;

            Session["restaurantID"] = currentRestaurant.restaurantID;
            Response.Redirect("RestaurantMenuPage.aspx");
        }
Exemple #8
0
        protected void addToOrder(object sender, EventArgs e)
        {
            Button1.Enabled = true;
            int ItemID    = Convert.ToInt32((sender as Button).CommandArgument);
            int tempIndex = 0;
            int qty       = 0;

            List <int> CurrentCart         = new List <int>();
            List <int> CurrentCartQuantity = new List <int>();

            if (Session["list"] != null && Session["CartQuantity"] != null)
            {
                CurrentCart         = (List <int>)Session["list"];
                CurrentCartQuantity = (List <int>)Session["CartQuantity"];

                if (!CurrentCart.Contains(ItemID))
                {
                    CurrentCart.Add(ItemID);
                    CurrentCartQuantity.Add(1);
                }
                else
                {
                    tempIndex = CurrentCart.IndexOf(ItemID);

                    qty = CurrentCartQuantity[tempIndex];
                    qty = qty + 1;

                    CurrentCartQuantity[tempIndex] = qty;
                }
                Session["list"]         = CurrentCart;
                Session["CartQuantity"] = CurrentCartQuantity;
            }
            else
            {
                CurrentCart.Add(ItemID);
                CurrentCartQuantity.Add(1);
                Session["list"]         = CurrentCart;
                Session["CartQuantity"] = CurrentCartQuantity;
            }

            ListBox1.Items.Clear();
            Console.WriteLine(CurrentCart + " " + CurrentCartQuantity);
            int i = 0;

            foreach (int element in CurrentCart)
            {
                ListBox1.Items.Add(KahnLib.getOrder(CurrentCart[i], CurrentCartQuantity[i]));
                i++;
            }
        }
Exemple #9
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            double price;

            double.TryParse(txtPrice.Text, out price);
            FileUpload img = (FileUpload)imgUpload;

            if (img.HasFile && img.PostedFile != null)
            {
                HttpPostedFile File = imgUpload.PostedFile;

                KahnLib.addMenuItem(txtDescription.Text, price, txtItemName.Text, currentRestaurant.restaurantID, File);
                Response.Redirect("EditMenuForm.aspx");
            }
        }
Exemple #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            KahnoUser userPull = new KahnoUser();

            try
            {
                userPull = (KahnoUser)Session["localuser"];
                if (userPull.userid == 0)
                {
                    Response.Redirect("Login.aspx");
                }
                lblName.Text    = userPull.fname;
                lblPhone.Text   = userPull.phone;
                lblEmail.Text   = userPull.email;
                lblAddress.Text = (userPull.coodinateid).ToString();
                lblId.Text      = (userPull.userid).ToString();
            }
            catch
            {
                Response.Redirect("Login.aspx");
            }


            List <int> CurrentCart         = new List <int>();
            List <int> CurrentCartQuantity = new List <int>();

            if (Session["list"] != null && Session["CartQuantity"] != null)
            {
                CurrentCart         = (List <int>)Session["list"];
                CurrentCartQuantity = (List <int>)Session["CartQuantity"];
            }
            else
            {
                Response.Redirect("Login.aspx");
            }
            double total      = 0;
            double grandtotal = 0;
            int    i          = 0;

            foreach (int element in CurrentCart)
            {
                total       = CurrentCartQuantity[i] * KahnLib.getOrderPrice(CurrentCart[i]);
                grandtotal += total;
                ListBox1.Items.Add(" " + KahnLib.getOrder(CurrentCart[i], CurrentCartQuantity[i]) + " = R" + total);
                i++;
            }
            ListBox1.Items.Add(" Total: R" + grandtotal);
        }
Exemple #11
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (KahnLib.updateCoordinateDetails(currentuser.coodinateid, Convert.ToDouble(txtLongitude.Text), Convert.ToDouble(txtLatitude.Text)) > 0)
            {
                Label5.Text = "Successfully Updated!";

                Response.Redirect("Login.aspx");
            }

            if (KahnLib.UpdateUserDetails(currentuser.userid, TextBox1.Text, TextBox2.Text, TextBox3.Text, TextBox4.Text) > 0)
            {
            }
            else
            {
                Label5.Text = "Update not successful!";
            }
            Label5.Visible = true;
        }
        protected void Register_Click(object sender, EventArgs e)
        {
            FileUpload img = (FileUpload)imgUpload;
            //Byte[] imgByte = null;
            int RID = 0;

            if (img.HasFile && img.PostedFile != null)
            {
                HttpPostedFile File = imgUpload.PostedFile;
                RID = KahnLib.NewRestaurant(TextBox1.Text, TextBox4.Text, double.Parse(TextBox7.Text), double.Parse(TextBox8.Text), File);
            }


            if (RID > 0)
            {
                KahnLib.AssignRestaurant(RID, currentuser.userid);
                Response.Redirect("Login.aspx");
            }
            else
            {
                Label8.Visible = true;
            }
        }
        protected void Register_Click(object sender, EventArgs e)
        {
            double longitude = 0;
            double latitude  = 0;

            if (!double.TryParse(TextBox7.Text, out latitude))
            {
                latitude = 0;
            }

            if (!double.TryParse(TextBox8.Text, out longitude))
            {
                longitude = 0;
            }

            if (KahnLib.NewUser(TextBox1.Text, TextBox2.Text, TextBox3.Text, TextBox4.Text, KahnLib.HashPass(TextBox5.Text), latitude, longitude))
            {
                Response.Redirect("Login.aspx");
            }
            else
            {
                Label8.Visible = true;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            ////////checking if user is logged in, copy paste on every page, will redirect to login if not logged in and create the user object
            ///Don't use this one yet, we need a better version

            try
            {
                currentuser = (KahnoUser)Session["localuser"];
                if (currentuser.userid == 0)
                {
                    Response.Redirect("Login.aspx");
                }
                Session["UserID"] = currentuser.userid;
            }
            catch
            {
                Response.Redirect("Login.aspx");
            }
            ////////////////////////////////////////////////////////////////
            ///
            Label1.Text = "Welcome " + currentuser.fname + " " + currentuser.lname;
            int lastID = KahnLib.getLastOrderID(currentuser.userid);

            if (lastID == 0)
            {
                Label3.Text       = "You haven't placed any orders yet!";
                ratingdiv.Visible = false;
            }
            else
            if (KahnLib.ratingUpToDate(currentuser.userid))
            {
                ratingdiv.Visible = false;
                Label3.Text       = "Your ratings are up to date!";
            }
            Label2.Text = KahnLib.getLastOrderDate(lastID);
        }
Exemple #15
0
        protected void btnConfirm_Click(object sender, EventArgs e)
        {
            restaurant = (KahnoRestaurant)Session["currentRestaurant"];


            DateTime time      = DateTime.Now;
            string   format    = "yyyy-MM-dd HH:mm:ss";
            string   finaltime = time.ToString(format);

            user = (KahnoUser)Session["localuser"];

            int user1 = Convert.ToInt32(user.userid);

            int restaurantSend = restaurant.restaurantID;

            //insert into db first then get orderNumber
            KahnLib.InsertOrder(finaltime, user1, restaurantSend);

            int orderNumber = KahnLib.getOrderNumber();

            List <int> CurrentCart         = new List <int>();
            List <int> CurrentCartQuantity = new List <int>();

            if (Session["list"] != null && Session["CartQuantity"] != null)
            {
                CurrentCart         = (List <int>)Session["list"];
                CurrentCartQuantity = (List <int>)Session["CartQuantity"];
            }
            else
            {
                Response.Redirect("Login.aspx");
            }

            double total = 0;
            int    i     = 0;

            foreach (int element in CurrentCart)
            {
                total = CurrentCartQuantity[i] * KahnLib.getOrderPrice(CurrentCart[i]);
                KahnLib.getOrder(CurrentCart[i], CurrentCartQuantity[i]);
                string        connectString = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\KahnoDB.mdf;Integrated Security=True;Connect Timeout=30";
                SqlConnection conn          = new SqlConnection(connectString);
                conn.Open();
                SqlDataAdapter adapter      = new SqlDataAdapter();
                SqlConnection  con          = new SqlConnection(connectString);
                string         insert_query = "INSERT INTO [ORDERDETAIL] (Quantity,OrderNumber,PricePaidPerItem,ItemNumber) VALUES(@quantity,@OrderNo,@total,@itemNo)";
                SqlCommand     comm         = new SqlCommand(insert_query, conn);

                comm.Parameters.AddWithValue("@quantity", CurrentCartQuantity[i]);
                comm.Parameters.AddWithValue("@OrderNo", orderNumber);
                comm.Parameters.AddWithValue("@total", total);
                comm.Parameters.AddWithValue("@itemNo", CurrentCart[i]);
                comm.ExecuteNonQuery();
                con.Close();
                comm.Dispose();
                i++;
            }
            Response.Redirect("Success.aspx");
            Session["list"]         = null;
            Session["CartQuantity"] = null;
        }
Exemple #16
0
        protected void RemoveFromOrder(object sender, EventArgs e)
        {
            //this is the function triggered by the "remove from cart" button, ItemID is the id of the selected item, do with it what you will
            int ItemID = Convert.ToInt32((sender as Button).CommandArgument);

            Session["itemId"] = ItemID;
            Session["orderCount" + Session["itemId"]] = (Convert.ToInt32(Session["orderCount" + Session["itemId"]]) - 1).ToString();

            int tempIndex = 0;
            int qty       = 0;

            List <int> CurrentCart         = new List <int>();
            List <int> CurrentCartQuantity = new List <int>();

            //Check if session is empty - if it is it will create new and if it does have values will move to the remove side.
            if (Session["list"] != null && Session["CartQuantity"] != null)
            {
                //set both lists to the sessions holding values for order
                CurrentCart         = (List <int>)Session["list"];
                CurrentCartQuantity = (List <int>)Session["CartQuantity"];

                if (CurrentCart.Contains(ItemID))
                {
                    tempIndex = CurrentCart.IndexOf(ItemID);

                    qty = CurrentCartQuantity[tempIndex];
                    if (qty > 1)
                    {
                        qty = qty - 1;
                        CurrentCartQuantity[tempIndex] = qty;
                    }
                    else
                    {
                        CurrentCart.RemoveAt(tempIndex);
                        CurrentCartQuantity.RemoveAt(tempIndex);
                    }
                }
                else
                {
                    ListBox1.Items.Add("Could not remove non exsisting item. try again.");
                }
                Session["list"]         = CurrentCart;
                Session["CartQuantity"] = CurrentCartQuantity;
            }
            else
            {
                ListBox1.Items.Add("Could not remove non exsisting item. try again.");
            }

            //doubt I will need the else in the remove from order function.

            /*else
             * {
             *  CurrentCart.Add(ItemID);
             *  CurrentCartQuantity.Add(1);
             *  Session["list"] = CurrentCart;
             *  Session["CartQuantity"] = CurrentCartQuantity;
             * }*/

            //this will be the same to display the items with quantity
            ListBox1.Items.Clear();
            //Console.WriteLine(CurrentCart + " " + CurrentCartQuantity);
            int i = 0;

            foreach (int element in CurrentCart)
            {
                ListBox1.Items.Add(KahnLib.getOrder(CurrentCart[i], CurrentCartQuantity[i]));
                i++;
            }
        }
 protected void Button2_Click1(object sender, EventArgs e)
 {
     KahnLib.createNewRating(currentuser.userid, int.Parse(TextBox1.Text), KahnLib.getLastOrderID(currentuser.userid));
     Response.Redirect("UserHome.aspx");
 }