コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int ID   = Convert.ToInt32(Session["LoggedInUserID"]);
            var user = sr.GetUser(ID);

            if (Session["LoggedInUserID"] != null)
            {
                if (user.Usertype.Equals("client"))
                {
                    btn_removeProduct.Visible = false;
                }
                else if (user.Usertype.Equals("admin"))
                {
                    btn_AddtoCart.Visible = false;
                }
            }

            var itemid = Request.QueryString["ID"];
            var mask   = sr.GetProduct(Convert.ToInt32(itemid));

            string displayi = " ";
            string display  = " ";

            displayi        += "<center><img src='" + mask.Image + "' alt='" + mask.Name + "' class='img-fluid'></center>";
            display         += "<center><h1>" + mask.Name + "</h1><p>" + mask.Description + "</p><p> R" + Math.Round(mask.Unit_Price, 2) + "</p></center>";
            pimage.InnerHtml = displayi;
            prod.InnerHtml   = display;
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int client_id = 7;

            clientId   = client_id;
            deliveries = SR.GetAllDeliveries();
            user       = SR.GetUser(SR.GetClient(client_id).User_Id);
            quant      = SR.CalculateTotalQuantity(client_id);
            total      = SR.CalculateTotalPrice(client_id);
            shipping   = quant >= 10000 ? 0 : Math.Round(total * (decimal)0.02, 2);
            discount   = quant > 5000 ? Math.Round(total * (decimal)0.05) : 0;
            absTot     = total + shipping - discount;
        }
コード例 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["LoggedInUserID"] != null)
            {
                int ID   = Convert.ToInt32(Session["LoggedInUserID"]);
                var user = sr.GetUser(ID);

                if (!IsPostBack)
                {
                    Username.Value = user.Username;
                    Name.Value     = user.Name;
                    Email.Value    = user.Email;
                    Contact.Value  = user.Contact_Number;
                    Address.Value  = user.Address;

                    if (user.Usertype.Equals("client"))
                    {
                        var c = sr.GetClient(ID);
                        BusinessT.Value = c.Business_Type;
                    }
                    else if (user.Usertype.Equals("admin"))
                    {
                        var a = sr.GetAdmin(ID);
                        BusinessT.Value = a.Surname;
                    }
                    else
                    {
                        error.Text = "User not found";
                    }
                }
            }
            else
            {
                Response.Redirect("Home.aspx");
            }
        }
コード例 #4
0
        protected void login_Click(object sender, EventArgs e)
        {
            int Id   = sr.Login(Email.Value, Password.Value);
            var user = sr.GetUser(Id);

            if (Id == 0)
            {
                error.Visible = true;
            }
            else
            {
                Session["LoggedInUserID"] = Id;
                Response.Redirect("Home.aspx");
            }
        }
コード例 #5
0
        protected void btn_register(object sender, EventArgs e)
        {
            string admin = sr.AddAdmin(sr.GetUser(Convert.ToInt32(UserId.Value)), Surname.Value);

            if (admin == "added")
            {
                Response.Redirect("Login.aspx");
            }
            else if (admin == "Something went wrong try again")
            {
                error.Text    = "Something went wrong, please try again later";
                error.Visible = true;
            }
            else if (admin == "unsuccessful")
            {
                error.Text = "The admin already exists";
            }
        }
コード例 #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Get the logged in user's id
            int client_ID = 5 /*Convert.ToInt32(Session["LoggedInUser"])*/;

            //If user is logged in
            if (client_ID > 0)
            {
                //Get the client's invoice/s
                dynamic allInvoices = SR.GetInvoicebyclient(client_ID);
                //Get client's details
                var    user           = SR.GetUser(client_ID);
                string displayInvoice = "";

                //Loop through all the invoices
                foreach (Order_Table i in allInvoices)
                {
                    //Get one invoice based off id
                    Order_Table invoice = SR.GetInvoice(i.Order_Id);

                    displayInvoice += "<tr><td class='name'>" + user.Name + "</td>";
                    displayInvoice += "<td class='date'>" + invoice.Order_date + "</td>";
                    displayInvoice += "<td class='quantity'>" + invoice.Order_Quantity + "</td>";
                    displayInvoice += "<td class='status'>" + invoice.Order_Status + "</td>";
                    displayInvoice += "<td class='total'>R" + Math.Round(invoice.Order_Total, 2) + "</td>";
                    displayInvoice += "<td class='see-more'><div class='seeMore-btn'><div class='row'><div class='col-lg-5 offset-lg-1 text-left text-lg-right'>";
                    displayInvoice += " <a href='Invoice.aspx'?ID=" + invoice.Order_Id + "class='site-btn update-btn'>See more</a></div></div></div></td></tr>";

                    invoice = null;
                }
                AllInvoiceID.InnerHtml = displayInvoice;
            }
            //If user is not logged in
            else
            {
                Response.Redirect("Home.aspx");
            }
        }
コード例 #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //On home page, show the number of different items there are in the cart

            if (Session["LoggedInUserID"] != null)
            {
                int ID   = Convert.ToInt32(Session["LoggedInUserID"]);
                var user = sr.GetUser(ID);

                if (user.Usertype.Equals("Admin"))
                {
                    ClientNav.Visible = false;
                }
                else if (user.Usertype.Equals("Client"))
                {
                    AdminNav.Visible = false;
                }
            }
            else
            {
                AdminNav.Visible = false;
            }
        }