/// <summary>
        /// ürünü sepete ekleyen method.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddCart_Click(object sender, EventArgs e)
        {
            Logger.logger(musicCD.name + " Form Add Cart");
            if (nupQuantity.Text != "" && int.Parse(nupQuantity.Text) != 0)
            {
                foreach (var it in MainForm.shoppingCart.ItemsToPurchase)
                {
                    if (it.Product == this.musicCD)
                    {
                        it.Quantity += int.Parse(nupQuantity.Text);

                        if (it.Quantity > 99)
                        {
                            MessageBox.Show("You have reached maximum capacity." + Environment.NewLine + "Max Capacity: 99", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            it.Quantity = 99;
                        }
                        else
                        {
                            MessageBox.Show(int.Parse(nupQuantity.Text) + " " + it.Product.name + " has been added to your shopping cart.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        return;
                    }
                }
                ItemToPurchase item = new ItemToPurchase();
                item.Product  = this.musicCD;
                item.Quantity = int.Parse(nupQuantity.Text);
                MainForm.shoppingCart.ItemsToPurchase.Add(item);
                MessageBox.Show(item.Quantity + " " + item.Product.name + " has been added to your shopping cart.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
예제 #2
0
 /// <summary>
 ///  ürünü listeden silen method.
 /// </summary>
 /// <param name="item"></param>
 public void removeProduct(ItemToPurchase item)
 {
     ItemsToPurchase.Remove(item);
     foreach (var it in list)
     {
         if (it.item == item)
         {
             list.Remove(it);
             break;
         }
     }
     refreshPanel();
 }
예제 #3
0
        void addCart(object sender, EventArgs e)
        {
            Logger.logger(book.name + " Panel Add Cart");
            foreach (var it in MainForm.shoppingCart.ItemsToPurchase)
            {
                if (it.Product == this.book)
                {
                    it.Quantity++;
                    MessageBox.Show(it.Product.name + " has been added to your shopping cart.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }
            ItemToPurchase item = new ItemToPurchase();

            item.Product  = this.book;
            item.Quantity = 1;
            MainForm.shoppingCart.ItemsToPurchase.Add(item);
            MessageBox.Show(item.Product.name + " has been added to your shopping cart.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
예제 #4
0
        void addCart(object sender, EventArgs e) ///bir dergi sepete eklenince gerceklesen eylemleri iceren method
        {
            Logger.logger(magazine.name + " Panel Add Cart");
            foreach (var it in MainForm.shoppingCart.ItemsToPurchase)
            {
                if (it.Product == this.magazine)
                {
                    it.Quantity++;
                    MessageBox.Show(it.Product.name + " has been added to your shopping cart.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }
            ItemToPurchase item = new ItemToPurchase();

            item.Product  = this.magazine;
            item.Quantity = 1;
            MainForm.shoppingCart.ItemsToPurchase.Add(item);
            MessageBox.Show(item.Product.name + " has been added to your shopping cart.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        /// <summary>
        /// panelin içerdiği componentlerin oluşturulduğu constructor.
        /// </summary>
        /// <param name="item"></param>
        public ShoppingCardItemPanel(ItemToPurchase item)
        {
            this.item        = item;
            this.Size        = new Size(530, 90);
            this.BorderStyle = BorderStyle.FixedSingle;

            this.lblItemName = new System.Windows.Forms.Label();
            this.lblItemType = new System.Windows.Forms.Label();
            this.lblPrice    = new System.Windows.Forms.Label();
            this.btnRemove   = new System.Windows.Forms.Button();
            this.cbQuantity  = new System.Windows.Forms.ComboBox();
            this.pbThumbnail = new System.Windows.Forms.PictureBox();
            ((System.ComponentModel.ISupportInitialize)(this.pbThumbnail)).BeginInit();
            this.SuspendLayout();
            //
            // label1
            //
            this.lblItemName.AutoSize  = false;
            this.lblItemName.Size      = new System.Drawing.Size(200, 20);
            this.lblItemName.Text      = item.Product.name;
            this.lblItemName.BackColor = Color.Transparent;
            this.lblItemName.Font      = new Font("Century Gothic", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(162)));

            //
            // label2
            //
            this.lblItemType.AutoSize = false;
            this.lblItemType.Size     = new System.Drawing.Size(200, 15);
            this.lblItemName.Font     = new Font("Century Gothic", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(162)));
            this.lblItemType.TabIndex = 0;
            if (item.Product is Book)
            {
                lblItemType.Text = "Book";
            }
            else if (item.Product is Magazine)
            {
                lblItemType.Text = "Magazine";
            }
            else
            {
                lblItemType.Text = "Music CD";
            }
            lblItemType.BackColor = Color.Transparent;

            //
            // label3
            //
            this.lblPrice.AutoSize  = true;
            this.lblPrice.Size      = new System.Drawing.Size(100, 23);
            this.lblItemName.Font   = new Font("Century Gothic", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(162)));
            this.lblPrice.Text      = item.Product.discountedPrice * item.Quantity + " TL";
            this.lblPrice.BackColor = Color.Transparent;

            //
            // button1
            //
            this.btnRemove.Text       = "Remove Item";
            this.btnRemove.TextAlign  = ContentAlignment.MiddleRight;
            this.btnRemove.Size       = new System.Drawing.Size(130, 25);
            this.btnRemove.FlatStyle  = FlatStyle.Flat;
            this.btnRemove.BackColor  = Color.Snow;
            this.btnRemove.Click     += new EventHandler(butonClick);
            this.btnRemove.Image      = Properties.Resources.garbage_16;
            this.btnRemove.ImageAlign = ContentAlignment.MiddleLeft;


            //
            // comboBox1
            //
            for (int i = 1; i <= 100; i++)
            {
                this.cbQuantity.Items.Add(i.ToString());
            }
            this.cbQuantity.SelectedIndex         = item.Quantity - 1;
            this.cbQuantity.SelectedIndexChanged += new EventHandler(cbChange);
            this.cbQuantity.IntegralHeight        = false;
            this.cbQuantity.MaxDropDownItems      = 6;
            this.cbQuantity.Size     = new System.Drawing.Size(61, 21);
            this.cbQuantity.TabIndex = 0;

            //
            // pictureBox1
            //

            this.pbThumbnail.Size      = new System.Drawing.Size(59, 78);
            this.pbThumbnail.Image     = item.Product.image;
            this.pbThumbnail.SizeMode  = PictureBoxSizeMode.Zoom;
            this.pbThumbnail.BackColor = Color.Transparent;

            this.Controls.Add(lblItemName);
            this.Controls.Add(lblItemType);
            this.Controls.Add(lblPrice);
            this.Controls.Add(cbQuantity);
            this.Controls.Add(pbThumbnail);
            this.Controls.Add(btnRemove);



            this.Controls[0].Location = new Point(63, 24);  // Name label
            this.Controls[0].BringToFront();
            this.Controls[1].Location = new Point(63, 54);  // Type label
            this.Controls[1].BringToFront();
            this.Controls[2].Location = new Point(465, 26); // Price label
            this.Controls[2].BringToFront();
            this.Controls[3].Location = new Point(375, 24); //  Combobox
            this.Controls[3].BringToFront();
            this.Controls[4].Location = new Point(3, 3);    // picturebox
            this.Controls[4].BringToFront();
            this.Controls[5].Location = new Point(390, 55); //Button
        }