コード例 #1
0
        public static bool Login(string email, string passwordhash, ref KahnoUser authuser)
        {
            //checking if user exists
            SqlConnection conn = new SqlConnection(connectString);

            conn.Open();

            string     sqlGetUser = ("SELECT * FROM [USER] WHERE email = @email AND passwordHash = @passwordhash");
            SqlCommand commquery  = new SqlCommand(sqlGetUser, conn);

            commquery.Parameters.AddWithValue("@email", email);
            commquery.Parameters.AddWithValue("@passwordhash", passwordhash);
            SqlDataReader drquery = commquery.ExecuteReader();

            drquery.Read();


            if (drquery.HasRows)
            {
                authuser = new KahnoUser(drquery.GetInt32(0), drquery.GetValue(1).ToString(), drquery.GetValue(2).ToString(), drquery.GetValue(3).ToString(), drquery.GetValue(4).ToString(), drquery.GetInt32(6), drquery.GetValue(7).ToString(), drquery.GetInt32(8));
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
 protected void Button2_Click(object sender, EventArgs e)
 {
     KahnLib.removeUser(currentuser.userid);
     currentuser          = null;
     Session["localuser"] = null;
     Response.Redirect("Login.aspx");
 }
コード例 #3
0
        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;
            }
        }
コード例 #4
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;
            }
        }
コード例 #5
0
        public static int getOrderNumber()
        {
            int orderNumber = 0;

            KahnoUser userCurrent   = new KahnoUser();
            int       currentUserID = userCurrent.userid;

            SqlConnection conn = new SqlConnection(connectString);

            conn.Open();
            string     sqlGetUser = ("SELECT TOP 1 OrderNumber FROM [ORDER] ORDER BY OrderNumber DESC");
            SqlCommand commquery  = new SqlCommand(sqlGetUser, conn);

            commquery.Parameters.AddWithValue("@user", currentUserID);
            SqlDataReader drquery = commquery.ExecuteReader();

            drquery.Read();

            if (drquery.HasRows)
            {
                orderNumber = drquery.GetInt32(0);
                return(orderNumber);
            }
            else
            {
                return(0);
            }
        }
コード例 #6
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();

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

                if (currentuser.isowner == "n")
                {
                    Response.Redirect("Login.aspx");
                }
            }
            catch
            {
                Response.Redirect("Login.aspx");
            }
            ////////////////////////////////////////////////////////////////
            try
            {
                currentRestaurant = (KahnoRestaurant)Session["currentRestaurant"];
            }
            catch
            {
                Response.Redirect("Admin.aspx");
            }
            Label1.Text = "Menu for " + currentRestaurant.restaurantname;
        }
コード例 #7
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"];
        }
コード例 #8
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);
        }
コード例 #9
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
     try
     {
         currentuser = (KahnoUser)Session["localuser"];
         if (currentuser.userid == 0)
         {
             Response.Redirect("Login.aspx");
         }
     }
     catch
     {
         Response.Redirect("Login.aspx");
     }
     ////////////////////////////////////////////////////////////////
 }
コード例 #10
0
        public void Page_Load(object sender, EventArgs e)
        {
            myaccountbutton.Visible = false;
            registerbutton.Visible  = true;
            loginbutton.Visible     = true;
            homebutton.Visible      = false;
            adminhome.Visible       = false;
            logoutbutton.Visible    = false;
            editrestaurant.Visible  = false;
            editmenuform.Visible    = false;
            recieveorders.Visible   = false;


            if (Session["localuser"] != null)
            {
                currentuser = (KahnoUser)Session["localuser"];
                if (currentuser.isowner == "y")
                {
                    registerbutton.Visible  = false;
                    loginbutton.Visible     = false;
                    myaccountbutton.Visible = true;
                    homebutton.Visible      = false;
                    adminhome.Visible       = true;
                    logoutbutton.Visible    = true;
                    editrestaurant.Visible  = true;
                    editmenuform.Visible    = true;
                    recieveorders.Visible   = true;
                }
                else
                {
                    registerbutton.Visible  = false;
                    loginbutton.Visible     = false;
                    myaccountbutton.Visible = true;
                    homebutton.Visible      = true;
                    adminhome.Visible       = false;
                    logoutbutton.Visible    = true;
                }
            }
        }
コード例 #11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                currentuser = (KahnoUser)Session["localuser"];
                if (currentuser.userid == 0)
                {
                    Response.Redirect("Login.aspx");
                }
            }
            catch
            {
                Response.Redirect("Login.aspx");
            }

            if (!this.IsPostBack)
            {
                TextBox1.Text = currentuser.fname;
                TextBox2.Text = currentuser.lname;
                TextBox3.Text = currentuser.phone;
                TextBox4.Text = currentuser.email;
            }
        }
コード例 #12
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

            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);
        }
コード例 #13
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;
        }