Exemplo n.º 1
0
        private void sendReceipt(Order order, List <Order_Artwork> oaList, string emailAddress)
        {
            string subject = "Thank you for your purchase!";
            string body    =
                "<h1>Your order has been successfully confirmed</h1>"
                + "\n<h2>Order ID: " + order.OrderId + "</h2>"
                + "\n<h2>Order Date: " + order.OrderDate + "</h2>"
                + "\n<h3>Delivering to: " + order.DeliveryAddress + "</h2>"
                + "\n<hr/>"
                + "\n<h4>Order Items</h5>";



            foreach (Order_Artwork oa in oaList)
            {
                // Get artpiece name
                ArtpieceDao      artpieceDao = new ArtpieceDao();
                Classes.Artpiece artpiece    = artpieceDao.Get("ARTPIECEID", oa.ArtpieceId);

                // Get artist name
                ArtistDao      artistDao = new ArtistDao();
                Classes.Artist artist    = artistDao.Get("ARTISTID", artpiece.ArtistId);

                body += "<b>" + artpiece.Title + "</b> by <i>" + artist.DisplayName + "</i> ( x" + oa.Quantity + " )<br/>";
            }

            // Display total
            body += "\n<h4>Total: RM" + Quick.FormatPrice(order.TotalPrice) + "</h4>";

            // Send email
            Email.SendEmail(emailAddress, subject, body);
        }
Exemplo n.º 2
0
        private bool ErrorInEdit(Artist artist)
        {
            bool hasError = false;

            // Check for existing username from both tables
            CustomerDao custUsernameDao   = new CustomerDao();
            Customer    checkCust         = custUsernameDao.Get("USERNAME", username.Text);
            ArtistDao   artistUsernameDao = new ArtistDao();
            Artist      checkArtist       = artistUsernameDao.Get("USERNAME", username.Text);


            if (checkArtist != null)
            {
                if (checkArtist.Username == artist.Username)
                {
                    checkArtist = null;
                }
            }

            if (checkCust != null || checkArtist != null)
            {
                // There is an existing username
                lblEditError    = FormatLbl.Error("An account with this username already exists.");
                lblEditError.ID = "lblEditError";
                hasError        = true;
            }

            // Reset values
            checkCust   = null;
            checkArtist = null;

            // Check for existing email
            CustomerDao custEmailDao = new CustomerDao();

            checkCust = custEmailDao.Get("EMAIL", email.Text);
            ArtistDao artistEmailDao = new ArtistDao();

            checkArtist = artistEmailDao.Get("EMAIL", email.Text);

            if (checkArtist != null)
            {
                if (checkArtist.Email == artist.Email)
                {
                    checkArtist = null;
                }
            }

            if (checkCust != null || checkArtist != null)
            {
                // There is an existing email
                lblEditError    = FormatLbl.Error("An account with this email already exists.");
                lblEditError.ID = "lblEditError";
                hasError        = true;
            }

            return(hasError);
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            FormatLbl = new FormatLabel(lblEditError);

            if (Session["artist"] == null)
            {
                Response.Redirect("~/Pages/LoginRegister.aspx");
            }
            else
            {
                // Clear error message
                lblEditError.Text = "";

                if (!IsPostBack)
                {
                    ArtistDao dao    = new ArtistDao();
                    Artist    artist = (Artist)Session["artist"];

                    // Update the one in the session and page
                    artist            = dao.Get("ARTISTID", artist.Id);
                    Session["artist"] = artist;

                    //nameLbl.Text = artist.Username + " " + artist.DisplayName;
                    //usernameLbl.Text = artist.Id;
                    lblName.Text     = artist.DisplayName;
                    lblUsername.Text = "@" + artist.Username;
                    lblBio.Text      = artist.Bio;

                    username.Text    = artist.Username;
                    displayName.Text = artist.DisplayName;
                    email.Text       = artist.Email;
                    bio.Text         = artist.Bio;
                }
            }

            if (Request.QueryString["Edit"] != null)
            {
                lblEditError = FormatLbl.Success("Account successfully updated");
            }
        }
Exemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Redirects
            if (Request.QueryString["username"] == null)
            {
                Net.Redirect("~/Pages/Home.aspx");
            }

            if (Request.QueryString["username"].ToString().Equals("session") && Net.GetSession("artist") == null && Net.GetSession("customer") == null)
            {
                Net.Redirect("~/Pages/LoginRegister.aspx");
            }

            Net.AllowOnly("artist");

            /*if (Net.GetSession("artist") == null && Net.GetSession("customer") != null)
             * {
             * Net.Redirect("~/Pages/CustomerProfile.aspx?username=session");
             * }*/

            // To ensure that a valid username is entered

            try
            {
                username = Request.QueryString["username"].ToString();
            }
            catch (Exception ex)
            {
                // Show error msg
            }

            int offsetAmt = 0;
            int ItemLimit = 9;             // How many items per page


            // Convert page into number
            try
            {
                pageNo = Convert.ToInt32(Request.QueryString["page"].ToString());
                LoadButtons(ItemLimit);
            }
            catch (Exception ex)
            {
                Net.Redirect("~/Pages/ArtistProfile.aspx?username="******"&page=1");
            }

            if (pageNo < 1)
            {
                Net.Redirect("~/Pages/ArtistProfile.aspx?username="******"&page=1");
            }

            offsetAmt = CalculateOffset(ItemLimit);

            // Clear parameters
            GallerySource.SelectParameters.Clear();

            GallerySource.SelectCommand = "SELECT ARTPIECE.TITLE, ARTPIECE.IMAGELINK AS URL, ARTPIECE.ArtpieceId, ARTIST.USERNAME, ARTIST.DisplayName FROM ARTPIECE INNER JOIN ARTIST ON ARTPIECE.ARTISTID = ARTIST.ARTISTID WHERE (ARTPIECE.ISPUBLIC = 1) AND ARTIST.USERNAME = @USERNAME ORDER BY ARTPIECE.ARTPIECEID DESC OFFSET @OFFSETAMT ROWS FETCH NEXT @ItemLimit ROWS ONLY";
            GallerySource.SelectParameters.Add("offsetAmt", System.Data.DbType.Int32, offsetAmt + "");
            GallerySource.SelectParameters.Add("ItemLimit", System.Data.DbType.Int32, ItemLimit + "");
            GallerySource.SelectParameters.Add("USERNAME", username);

            //Fetch from DB
            Artist Artist = null;

            if (username.Equals("session"))
            {
                Artist = (Artist)Net.GetSession("artist");
            }
            else
            {
                ArtistDao Dao = new ArtistDao();
                Artist = Dao.Get("username", username);
            }

            if (Artist == null)
            {
                lblName.Text = "Artist does not exist.";
            }
            else
            {
                lblHandle.Text = "@" + Artist.Username;
                lblName.Text   = Artist.DisplayName;
                lblBio.Text    = Artist.Bio + "<br><span style='font-size: 20px; color: grey;'>Viewing " + Artist.DisplayName + "'s artworks.</span>";
            }

            ArtRepeater.DataSource = GallerySource;
            ArtRepeater.DataBind();
        }
Exemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Initialize
            FormatLbl = new FormatLabel(lblEditError);

            artpiece = new Classes.Artpiece();

            // To ensure that a valid username is entered
            string artpieceId = "";

            try
            {
                artpieceId = Request.QueryString["id"].ToString();
            }
            catch (Exception ex)
            {
                //Show error msg
            }

            // Get from DB
            ArtpieceDao dao = new ArtpieceDao();

            artpiece = dao.Get("ARTPIECEID", artpieceId);

            // Validate artpiece ID
            if (artpiece == null)
            {
                Net.Redirect("Artpiece.aspx?id=UNKNOWN");
            }
            else
            {
                // Get Artist info
                ArtistDao artistDao = new ArtistDao();
                artist = artistDao.Get("ARTISTID", artpiece.ArtistId);

                // Will be null if currently logged in user is not an artist
                Artist currentArtist = (Artist)Session["Artist"];

                // Redirect if not original artist
                if (currentArtist == null || artpiece.ArtistId != currentArtist.Id)
                {
                    Net.Redirect("Artpiece.aspx?id=" + artpiece.ArtpieceId);
                }
                else
                {
                    // Show private artpiece to the original artist
                    if (!artpiece.IsPublic && currentArtist.Id == artist.Id)
                    {
                        if (!IsPostBack)
                        {
                            //Display artpiece details
                            lblArtist.Text        = artist.DisplayName;
                            lblDescription.Text   = artpiece.About;
                            lblTitle.Text         = artpiece.Title + "(PRIVATE ARTPIECE)";
                            txtStocks.Text        = artpiece.Stocks + "";
                            artpieceImg.ImageUrl  = artpiece.ImageLink;
                            lblArtpiecePrice.Text = Quick.FormatPrice(artpiece.Price);

                            if (!artpiece.IsForSale)
                            {
                                lblForSale.Text     = "NOT FOR SALE";
                                lblForSale.CssClass = "notforsale";
                            }
                        }
                    }
                    else                     // Show public artpiece
                    {
                        if (!IsPostBack)
                        {
                            //Display artpiece details
                            lblArtist.Text        = artist.DisplayName;
                            lblDescription.Text   = artpiece.About;
                            lblTitle.Text         = artpiece.Title;
                            txtStocks.Text        = artpiece.Stocks + "";
                            lblArtpiecePrice.Text = Quick.FormatPrice(artpiece.Price);
                            artpieceImg.ImageUrl  = artpiece.ImageLink;


                            if (!artpiece.IsForSale)
                            {
                                lblForSale.Text     = "NOT FOR SALE";
                                lblForSale.CssClass = "notforsale";
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            artpiece = new Classes.Artpiece();

            // Hide edit button first
            btnEdit.Visible = false;

            //Hide buttons first
            btnAddToWishlist.Visible = false;
            btnAddToCart.Visible     = false;
            btnViewArtist.Visible    = false;


            // To ensure that a valid username is entered
            string artpieceId = "";

            try
            {
                artpieceId = Request.QueryString["id"].ToString();
            }
            catch (Exception ex)
            {
                //Show error msg
            }

            // Get from DB
            ArtpieceDao dao = new ArtpieceDao();

            artpiece = dao.Get("ARTPIECEID", artpieceId);

            // Validate artpiece ID
            if (artpiece == null)
            {
                lblTitle.Text = "Artpiece does not exist";
            }
            else
            {
                // Get Artist info
                ArtistDao artistDao = new ArtistDao();
                artist = artistDao.Get("ARTISTID", artpiece.ArtistId);

                // Will be null if currently logged in user is not an artist
                Artist currentArtist = (Artist)Session["Artist"];

                // Block private artpiece from customer
                if (!artpiece.IsPublic && currentArtist == null)
                {
                    lblTitle.Text = "Artpiece is private";
                }
                else
                {
                    // Block private artpiece from other artists
                    if (!artpiece.IsPublic && currentArtist.Id != artist.Id)
                    {
                        lblTitle.Text = "Artpiece is private";
                    }
                    // Show private artpiece to the original artist
                    else if (!artpiece.IsPublic && currentArtist.Id == artist.Id)
                    {
                        //Display artpiece details
                        lblArtist.Text        = artist.DisplayName;
                        lblDescription.Text   = artpiece.About;
                        lblTitle.Text         = artpiece.Title + "(PRIVATE ARTPIECE)";
                        lblStocks.Text        = artpiece.Stocks + "";
                        artpieceImg.ImageUrl  = artpiece.ImageLink;
                        lblArtpiecePrice.Text = Quick.FormatPrice(artpiece.Price);

                        if (!artpiece.IsForSale)
                        {
                            lblForSale.Text     = "NOT FOR SALE";
                            lblForSale.CssClass = "notforsale";
                        }
                    }
                    else                     // Show public artpiece
                    {
                        LoadBt();

                        // Make buttons visible
                        btnViewArtist.Visible = true;

                        //Display artpiece details
                        lblArtist.Text        = artist.DisplayName;
                        lblDescription.Text   = artpiece.About;
                        lblTitle.Text         = artpiece.Title;
                        lblStocks.Text        = artpiece.Stocks + "";
                        lblArtpiecePrice.Text = Quick.FormatPrice(artpiece.Price);
                        artpieceImg.ImageUrl  = artpiece.ImageLink;


                        if (!artpiece.IsForSale)
                        {
                            lblForSale.Text     = "NOT FOR SALE";
                            lblForSale.CssClass = "notforsale";
                        }
                    }

                    // Show edit button if this is the original artist
                    if (currentArtist != null && currentArtist.Id == artist.Id)
                    {
                        btnEdit.Visible = true;
                    }
                }
            }
        }
Exemplo n.º 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Net.AllowOnly("customer");


            // Check for out of stock error if any
            string errorMsg = (string)Net.GetSession("cartOutOfStocks");

            if (errorMsg != null)
            {
                lblErrorMsg.Text = errorMsg;
            }

            bool cartSaved = false;

            // Get orders from Session
            List <Order_Artwork> oaList = (List <Order_Artwork>)Net.GetSession("oaList");
            Order order = (Order)Net.GetSession("order");

            if (Net.GetSession("cartSaved") == null || errorMsg != null)
            {
                checkoutBt.Visible = false;
            }
            else
            {
                cartSaved = (bool)Net.GetSession("cartSaved");
            }

            if (!cartSaved)
            {
                checkoutBt.Visible = false;
            }

            /* ----------------------------------------------------------------------------------------------------
             * Get session attributes to manipulate
             * ---------------------------------------------------------------------------------------------------- */
            Customer customer = (Customer)Net.GetSession("customer");

            if (customer == null)
            {
                Net.Redirect("~/Pages/LoginRegister.aspx");                 // Redirect if not logged in as customer
            }
            /* FOR DEBUG PURPOSES */
            //oaList = new List<Order_Artwork>();
            //oaList.Add(new Order_Artwork("testorder", "MILO", 1, oaList));
            //oaList.Add(new Order_Artwork("testorder", "LILO", 5, oaList));
            /* END */



            /* ----------------------------------------------------------------------------------------------------
             * Initialise daos to use
             * ---------------------------------------------------------------------------------------------------- */
            ArtpieceDao artpieceDao = new ArtpieceDao();
            ArtistDao   artistDao   = new ArtistDao();

            /* ----------------------------------------------------------------------------------------------------
             * Display statics in page header
             * ---------------------------------------------------------------------------------------------------- */

            // TODO TODO TODO
            // TODO TODO TODO
            // TODO TODO TODO
            // TODO TODO TODO
            // TODO TODO TODO

            /* ----------------------------------------------------------------------------------------------------
             * Display items in cart
             * ---------------------------------------------------------------------------------------------------- */
            Control gallery = this.FindControl("gallery");

            int loopCounter = 0;

            // if cart is empty
            if (oaList == null || oaList.Count == 0)
            {
                // Don't show checkout button
                checkoutBt.Visible = false;
            }
            else
            {
                lblItems.Text = oaList.Count + "";
                gallery.Controls.Add(new LiteralControl("<table class='gallery'>"));

                foreach (Order_Artwork orderArtwork in oaList)
                {
                    // Get corresponding artpiece and artist
                    Classes.Artpiece artpiece = artpieceDao.Get("ArtpieceId", orderArtwork.ArtpieceId);
                    Artist           artist   = artistDao.Get("ArtistId", artpiece.ArtistId);

                    if (loopCounter % 3 == 0)
                    {
                        if (loopCounter != 0)
                        {
                            gallery.Controls.Add(new LiteralControl("</tr>"));
                        }
                        gallery.Controls.Add(new LiteralControl("<tr>"));
                    }

                    // ---

                    gallery.Controls.Add(new LiteralControl("" +
                                                            "<td>" +
                                                            "<a href='#'>"));

                    // ---

                    Image image = new Image();
                    image.ImageUrl = artpiece.ImageLink;

                    gallery.Controls.Add(image);

                    // ---

                    gallery.Controls.Add(new LiteralControl("" +
                                                            "</a>" +
                                                            "<div class='details'>" +
                                                            "<div class='of_artpiece'>"));

                    // ---

                    /*Label lblTitle = new Label();
                     * lblTitle.ID = "lblTitle" + loopCounter.ToString();
                     * lblTitle.Text = artpiece.Title;
                     * lblTitle.CssClass = "label title";
                     *
                     * gallery.Controls.Add(lblTitle);*/

                    //gallery.Controls.Add(new LiteralControl("<asp:Label ID='lblTitle" + loopCounter + "' runat='server' Text='" + artpiece.Title + "' CssClass='label title'></asp:Label>"));

                    gallery.Controls.Add(new LiteralControl("<a class='title'>" + artpiece.Title + "</a>"));

                    /*Label lblArtist = new Label();
                     * lblArtist.ID = "lblArtist" + loopCounter.ToString();
                     * lblArtist.Text = artist.DisplayName;
                     * lblTitle.CssClass = "label artist";
                     *
                     * gallery.Controls.Add(lblArtist);*/

                    //gallery.Controls.Add(new LiteralControl("<asp:Label ID='lblArtist" + loopCounter + "' runat='server' Text='" + artist.DisplayName + "' CssClass='label artist'></asp:Label>"));

                    gallery.Controls.Add(new LiteralControl("<a class='artist'>" + artist.DisplayName + "</a>"));

                    // ---

                    gallery.Controls.Add(new LiteralControl("" +
                                                            "</div>" +
                                                            "<div class='of_order'>" +
                                                            "<div class='quantity'>"));

                    // ---

                    /*Button btnDecrement = new Button();
                    *                   btnDecrement.ID = "btnDecrement" + (loopCounter + 1).ToString();
                    *                   btnDecrement.Text = "-";
                    *                   btnDecrement.CssClass = "decrement";
                    *  //btnDecrement.Click += Decrement;
                    *
                    *                   gallery.Controls.Add(btnDecrement);*/

                    gallery.Controls.Add(new LiteralControl("<input type='button' id='btnDecrement" + (loopCounter + 1).ToString() + "' class='decrement' value='-'>"));

                    Label lblQuantity = new Label();
                    lblQuantity.ID       = "lblQuantity" + (loopCounter + 1).ToString();
                    lblQuantity.Text     = orderArtwork.Quantity.ToString() + " PCS";
                    lblQuantity.CssClass = "label";
                    lblQuantity.Visible  = false;

                    gallery.Controls.Add(lblQuantity);

                    gallery.Controls.Add(new LiteralControl("<a id='quantity" + (loopCounter + 1).ToString() + "'>" + orderArtwork.Quantity.ToString() + " PCS</a>"));

                    /*Button btnIncrement = new Button();
                    *                   btnIncrement.ID = "btnIncrement" + (loopCounter + 1).ToString();
                    *                   btnIncrement.Text = "+";
                    *                   btnIncrement.CssClass = "increment";
                    *  //btnIncrement.Click += Increment;
                    *
                    *                   gallery.Controls.Add(btnIncrement);*/

                    gallery.Controls.Add(new LiteralControl("<input type='button' id='btnIncrement" + (loopCounter + 1).ToString() + "' class='increment' value='+'>"));

                    // ---

                    gallery.Controls.Add(new LiteralControl("" +
                                                            "</div>" +
                                                            "<div class='subtotal'>" +
                                                            "<a class='caption'>SUBTOTAL</a>"));

                    // ---
                    Label priceHidden = new Label();
                    priceHidden.ID       = "priceHidden" + (loopCounter + 1).ToString();
                    priceHidden.Text     = Convert.ToString(artpiece.Price);
                    priceHidden.CssClass = "label value";
                    priceHidden.Visible  = false;
                    gallery.Controls.Add(priceHidden);

                    HiddenField quantityHidden = new HiddenField();

                    quantityHidden.ID    = "quantityHidden" + (loopCounter + 1).ToString();
                    quantityHidden.Value = Convert.ToString(orderArtwork.Quantity);

                    gallery.Controls.Add(quantityHidden);
                    gallery.Controls.Add(new LiteralControl("<input type='hidden' class='value' value='" + artpiece.Price + "' id='hiddenPriceHTML" + (loopCounter + 1).ToString() + "'/>"));

                    //string priceStr = (artpiece.Price * (double)orderArtwork.Quantity).ToString();
                    gallery.Controls.Add(new LiteralControl("<a class='value' id='subtotal" + (loopCounter + 1).ToString() + "'>RM " + Quick.FormatPrice((artpiece.Price * (double)orderArtwork.Quantity)) + "</a>"));



                    // ---

                    gallery.Controls.Add(new LiteralControl("" +
                                                            "</div>" +
                                                            "</div>" +
                                                            "</div>" +
                                                            "</td>"));

                    // ---

                    loopCounter++;
                }

                if (oaList.Count > 0)
                {
                    gallery.Controls.Add(new LiteralControl("</tr>"));
                }

                gallery.Controls.Add(new LiteralControl("</table>"));

                // Set total price
                lblPrice.Text = "RM " + Quick.FormatPrice(order.TotalPrice);
            }
        }