예제 #1
0
        public void Update(Artist Artist)
        {
            using (SqlConnection con = DBUtil.BuildConnection())
            {
                // SqlCommand Cmd = new SqlCommand("UPDATE Artist SET ... WHERE ([ArtistId] = @ArtistId)");
                SqlCommand Cmd = new SqlCommand("UPDATE Artist " +
                                                "SET Username = @Username" +
                                                ", DisplayName = @DisplayName" +
                                                ", Email = @Email" +
                                                ", Passwd = @Passwd" +
                                                ", PasswordSalt = @PasswordSalt" +
                                                ", Bio = @Bio" +
                                                " WHERE ArtistId = @ArtistId", con
                                                );
                con.Open();
                Cmd.Parameters.AddWithValue("@ArtistId", Artist.Id);

                Cmd.Parameters.AddWithValue("@Username", Artist.Username);
                Cmd.Parameters.AddWithValue("@DisplayName", Artist.DisplayName);
                Cmd.Parameters.AddWithValue("@Email", Artist.Email);
                Cmd.Parameters.AddWithValue("@Passwd", Artist.Passwd);
                Cmd.Parameters.AddWithValue("@PasswordSalt", Artist.PasswordSalt);
                Cmd.Parameters.AddWithValue("@Bio", Artist.Bio);

                Cmd.ExecuteNonQuery();
                Quick.Print(Artist.Id);

                con.Close();
            }
        }
예제 #2
0
        public void Decrement(object sender, EventArgs e)
        {
            Button button = sender as Button;

            Quick.Print("hey this be a test");
            // todo
        }
예제 #3
0
        private void LoadBt()
        {
            // Get customer from session
            Customer customer = (Customer)Net.GetSession("customer");

            // Show the buttons status
            if (customer != null)
            {
                // Make buttons visible
                btnAddToWishlist.Visible = true;

                if (artpiece.IsForSale)
                {
                    btnAddToCart.Visible = true;
                }

                WishedArtDao dao = new WishedArtDao();
                wish = dao.GetSpecific(customer.Id, Net.GetQueryStr("id"));

                // If wish already exists, show Added to Wishlist
                if (wish != null)
                {
                    btnAddToWishlist.Text = "ADDED TO WISHLIST";
                }

                bool found = false;

                List <Order_Artwork> oaList = (List <Order_Artwork>)Net.GetSession("oaList");

                if (oaList != null)
                {
                    // Loop through order list in session to see if this artpiece already added to cart
                    foreach (Order_Artwork oa in oaList)
                    {
                        if (oa.ArtpieceId.ToLower() == Net.GetQueryStr("id").ToLower())
                        {
                            found = true;
                        }
                        Quick.Print(oa.ArtpieceId.ToLower() + " == " + Net.GetQueryStr("id"));
                    }
                }
                if (found)
                {
                    btnAddToCart.Text = "ADDED TO CART";
                }
                else
                {
                    btnAddToCart.Text = "ADD TO CART";
                }
            }
        }
예제 #4
0
        protected void uploadBt_Click(object sender, EventArgs e)
        {
            // Validate form first

            string errorMsg = ValidateForm();

            if (errorMsg != null)             // If there is an error
            {
                // Set the error msg
                lblUploadError = FormatLbl.Error(errorMsg);
            }
            else             // If there is no error
            {
                // Obtain artist info
                Artist artist = (Artist)Session["artist"];

                // Generate Artpiece Id
                IdGen  IdGen      = new IdGen();
                String ArtpieceId = IdGen.GenerateId("Artpiece");

                // Obtain the values from the form
                Classes.Artpiece artpiece = new Classes.Artpiece();
                artpiece.ArtpieceId = ArtpieceId;
                artpiece.ArtistId   = artist.Id;
                artpiece.Tags       = txtTags.Text;
                artpiece.About      = txtDescription.Text;
                artpiece.Title      = txtTitle.Text;
                artpiece.Price      = Convert.ToDouble(txtPrice.Text);

                artpiece.Stocks = Convert.ToInt32(txtStocks.Text);                  // Need to validate

                // NOTE! NEED TO CHANGE TO DROPDOWNLIST
                if (rblForSale.SelectedValue == "yes")                 // If the artpiece is for sale
                {
                    artpiece.IsForSale = true;
                }
                else
                {
                    artpiece.IsForSale = false;
                }

                // NOTE! NEED TO CHANGE TO DROPDOWNLIST
                if (rblIsPublic.SelectedValue == "yes")                 // If the artpiece is public
                {
                    artpiece.IsPublic = true;
                }
                else
                {
                    artpiece.IsPublic = false;
                }

                //debug
                Quick.Print("selected forsale is " + rblIsPublic.SelectedValue);

                FileUtil file = new FileUtil(fileBt, "~/Pics/");

                // Set image link
                artpiece.ImageLink = file.GetAddress();

                // VERIFY THAT IMAGE LINK DOES NOT HAVE DUPLICATE NAME
                ArtpieceDao      linkCheckDao  = new ArtpieceDao();
                Classes.Artpiece checkArtpiece = linkCheckDao.Get("IMAGELINK", file.GetAddress());

                if (checkArtpiece != null)                 // If there is a duplicate file name
                {
                    // Set the error msg
                    lblUploadError = FormatLbl.Error("An image with that name already exists. Please rename.");
                }
                else                 // If there is no duplicate
                {
                    Quick.Print(file.GetFileName().Substring(file.GetFileName().Length - 4));
                    // Check file type
                    if (file.GetFileName().Substring(file.GetFileName().Length - 4) != ".jpg" && file.GetFileName().Substring(file.GetFileName().Length - 4) != ".png" && file.GetFileName().Substring(file.GetFileName().Length - 5) != ".jpeg")
                    {
                        // Show error
                        lblUploadError = FormatLbl.Error("File must be a picture file that ends in jpg, png, or jpeg");
                    }
                    else
                    {
                        // Perform file upload
                        file.PerformUpload();

                        // Perform database insert
                        ArtpieceDao dao = new ArtpieceDao();
                        dao.Add(artpiece);

                        //To redirect user to the new artpiece
                        Response.Redirect("~/Pages/artpiece.aspx?Id=" + artpiece.ArtpieceId);
                    }
                }
            }
        }
예제 #5
0
        protected void saveBt_Click(object sender, EventArgs e)
        {
            bool outOfStocksError = false;
            // Get count
            List <Order_Artwork> oaList = (List <Order_Artwork>)Net.GetSession("oaList");
            Order order = (Order)Net.GetSession("order");

            order.TotalPrice = 0;             // Clear first
            int itemCount = oaList.Count;

            for (int i = 1; i <= itemCount; i++)
            {
                // Get quantity and price labels of artpiece order
                HiddenField lblQuantity = new HiddenField();
                lblQuantity = (HiddenField)gallery.FindControl("quantityHidden" + i);
                Label lblPrice = new Label();
                lblPrice = (Label)gallery.FindControl("priceHidden" + i);

                // Get the string value
                string quantityStr = lblQuantity.Value;
                string priceStr    = lblPrice.Text;

                //Get artpiece
                ArtpieceDao      artpieceDao = new ArtpieceDao();
                Classes.Artpiece artpiece    = artpieceDao.Get("ARTPIECEID", oaList[i - 1].ArtpieceId);

                // Check for sufficient stocks
                if (Convert.ToInt32(quantityStr) > artpiece.Stocks)
                {
                    // Show insufficient stock message
                    Quick.Print("Insufficient stock! Ordering " + oaList[i - 1].Quantity + " while Artpiece stock is " + artpiece.Stocks);
                    string error = "Not enough stocks for artpiece \"" + artpiece.Title + "\"";
                    Net.SetSession("cartOutOfStocks", error);
                    outOfStocksError = true;
                }
                else
                {
                    order.TotalPrice += Convert.ToDouble(priceStr) * Convert.ToInt32(quantityStr);

                    // Save to oa object
                    oaList[i - 1].Quantity = Convert.ToInt32(quantityStr);
                    Quick.Print("Quantity ordered: " + oaList[i - 1].Quantity);
                }
            }

            // Clear error if no error
            if (!outOfStocksError)
            {
                Net.SetSession("cartOutOfStocks", null);
            }

            lblPrice.Text = "RM " + Quick.FormatPrice(order.TotalPrice);

            // Save to session
            Net.SetSession("oaList", oaList);
            Net.SetSession("order", order);

            // Show that cart is saved
            if (oaList.Count > 0)
            {
                Net.SetSession("cartSaved", true);
            }

            //Refresh page
            Net.RefreshPage();
        }