Exemplo n.º 1
0
 public void removeProduct(ItemToPurchase item)
 {
     ItemsToPurchase.Remove(item);
     foreach (var it in list)
     {
         if (it.item == item)
         {
             list.Remove(it);
             break;
         }
     }
     refreshPanel();
 }
Exemplo n.º 2
0
 /// <summary>
 /// This function write product information.
 /// </summary>
 /// <param name="item">This parameter is a object of ItemToPurchase class.</param>
 /// <returns> This function does not return a value  </returns>
 public MyOrdersDesign(ItemToPurchase item)
 {
     InitializeComponent();
     lbName.Text  = item.Product.Name;
     lbPrice.Text = item.Product.Price.ToString() + " ₺";
     if (item.Quantity == 1)
     {
         lbQuantity.Text = item.Quantity.ToString() + " piece";
     }
     else
     {
         lbQuantity.Text = item.Quantity.ToString() + " pcs";
     }
     ProductPic.Image = item.Product.Image;
 }
Exemplo n.º 3
0
        void addCart(object sender, EventArgs e)
        {
            foreach (var it in MainForm.ShoppingCart.ItemsToPurchase)
            {
                if (it.Product == this.musicCD)
                {
                    it.Quantity++;
                    MessageBox.Show(it.Product.Name.Trim() + " sepetinize eklendi.", "Bilgi", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }
            ItemToPurchase item = new ItemToPurchase();

            item.Product  = this.musicCD;
            item.Quantity = 1;
            MainForm.ShoppingCart.ItemsToPurchase.Add(item);
            MessageBox.Show(item.Product.Name.Trim() + " sepetinize eklendi.", "Bilgi", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Exemplo n.º 4
0
 /// <summary>
 /// This function used to write product information.
 /// </summary>
 /// <param name="itemToPurchase">This parameter is a object of ItemToPurchase class.</param>
 /// <returns> This function does not return a value  </returns>
 public ListProduct(ItemToPurchase itemToPurchase)
 {
     InitializeComponent();
     lblProductName.Text = itemToPurchase.Product.Name;
     lblNumber.Text      = itemToPurchase.Quantity.ToString();
     lblPrice.Text       = (itemToPurchase.Product.Price * itemToPurchase.Quantity).ToString() + " ₺";
     ProductImage.Image  = itemToPurchase.Product.Image;
     if (itemToPurchase.Product is Book)
     {
         lblItemtype.Text = "Book";
     }
     else if (itemToPurchase.Product is Magazine)
     {
         lblItemtype.Text = "Magazine";
     }
     else
     {
         lblItemtype.Text = "MusicCD";
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// This function includes Add button click operation.
        /// This function used to called the add product for shopping card and save for util function.
        /// </summary>
        /// <returns> This function does not return a value </returns>
        private void btnAdd_Click(object sender, EventArgs e)
        {
            Logger.GetLogger().WriteLog(LoginedCustomer.getInstance().User.Username, btnAdd.Text, DateTime.Now);
            ItemToPurchase itemToPurchase = new ItemToPurchase();

            itemToPurchase.Product = book;
            foreach (ItemToPurchase item in StoreMainScreen.shoppingCards[LoginScreen.shoppingCardIndex].itemsToPurchase)
            {
                if (item.Product.ID1 == itemToPurchase.Product.ID1)
                {
                    MessageBox.Show("It's already in the cart!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            itemToPurchase.Quantity = quantityBook;
            StoreMainScreen.shoppingCards[LoginScreen.shoppingCardIndex].AddProduct(itemToPurchase);
            int i = StoreMainScreen.shoppingCards[LoginScreen.shoppingCardIndex].itemsToPurchase.Count;

            UtilSave.Save(StoreMainScreen.shoppingCards[LoginScreen.shoppingCardIndex], i);
            MessageBox.Show("Added!", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Exemplo n.º 6
0
        public ShoppingCartPanel(ItemToPurchase item)
        {
            this.item        = item;
            this.Size        = new Size(550, 85);
            this.BackColor   = Color.FromArgb(160, 0, 190, 190);
            this.BorderStyle = BorderStyle.FixedSingle;

            lbProductName           = new Label();
            lbProductName.AutoSize  = false;
            lbProductName.Size      = new Size(200, 20);
            lbProductName.Text      = item.Product.Name;
            lbProductName.BackColor = Color.Transparent;
            lbProductName.Font      = new Font("Calibri", (float)11.25);
            this.Controls.Add(lbProductName);

            lbProductType          = new Label();
            lbProductType.AutoSize = false;
            lbProductType.Size     = new Size(200, 15);
            lbProductType.Font     = new Font("Calibri", (float)10.25);
            if (item.Product is Book)
            {
                lbProductType.Text = "Kitap";
            }
            else if (item.Product is Magazine)
            {
                lbProductType.Text = "Dergi";
            }
            else
            {
                lbProductType.Text = "Musik CD";
            }
            lbProductType.BackColor = Color.Transparent;
            this.Controls.Add(lbProductType);

            lbPrice           = new Label();
            lbPrice.AutoSize  = true;
            lbPrice.Font      = new Font("Calibri", (float)10.25);
            lbPrice.Text      = item.Product.Price * item.Quantity + " TL";
            lbPrice.BackColor = Color.Transparent;
            this.Controls.Add(lbPrice);

            cmbQuantity = new ComboBox();
            for (int i = 1; i <= 100; i++)
            {
                cmbQuantity.Items.Add(i.ToString());
            }
            cmbQuantity.SelectedIndex         = item.Quantity - 1;
            cmbQuantity.SelectedIndexChanged += new EventHandler(cbChange);
            cmbQuantity.Size             = new Size(61, 21);
            cmbQuantity.IntegralHeight   = false;
            cmbQuantity.DropDownStyle    = ComboBoxStyle.DropDownList;
            cmbQuantity.MaxDropDownItems = 6;
            this.Controls.Add(cmbQuantity);

            pbThumbnail           = new PictureBox();
            pbThumbnail.Image     = item.Product.Picture;
            pbThumbnail.SizeMode  = PictureBoxSizeMode.StretchImage;
            pbThumbnail.Size      = new Size(59, 78);
            pbThumbnail.BackColor = Color.Transparent;
            this.Controls.Add(pbThumbnail);

            btnRemoveItem            = new Button();
            btnRemoveItem.Text       = "Sepetten Çıkar";
            btnRemoveItem.TextAlign  = ContentAlignment.MiddleCenter;
            btnRemoveItem.Size       = new Size(100, 25);
            btnRemoveItem.FlatStyle  = FlatStyle.Flat;
            btnRemoveItem.BackColor  = Color.FromArgb(34, 36, 49);
            btnRemoveItem.ForeColor  = Color.White;
            btnRemoveItem.Click     += new EventHandler(buttonClick);
            btnRemoveItem.Image      = Properties.Resources.closeiconblue;
            btnRemoveItem.ImageAlign = ContentAlignment.MiddleLeft;
            this.Controls.Add(btnRemoveItem);

            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(466, 26); // Price label
            this.Controls[2].BringToFront();
            this.Controls[3].Location = new Point(316, 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(440, 55); //Button
        }
Exemplo n.º 7
0
        /// <summary>
        ///  This function loads the elements of the ShoppingCard.xml file.
        /// </summary>
        /// <param name="shoppingCardList">This parameter is a list of ShoppingCard class.</param>
        /// <returns> This function does not return a value  </returns>
        public static void Load(List <ShoppingCard> shoppingCardList)
        {
            if (!File.Exists(@"data/ShoppingCard.xml"))
            {
                XmlTextWriter writer = new XmlTextWriter(@"data/ShoppingCard.xml", System.Text.Encoding.UTF8);
                writer.WriteStartDocument(true);
                writer.Formatting  = Formatting.Indented;
                writer.Indentation = 2;
                writer.WriteStartElement("ShoppingCards");
                writer.WriteEndElement();
                writer.WriteEndDocument();
                writer.Close();
                return;
            }
            XDocument        xDoc = XDocument.Load(@"data/ShoppingCard.xml");
            XElement         shoppingCardRootElement = xDoc.Root;
            NumberFormatInfo info = new NumberFormatInfo();

            info.NumberDecimalSeparator = ".";
            foreach (XElement shoppingCard in shoppingCardRootElement.Elements())
            {
                string      customerID = shoppingCard.FirstAttribute.Value;
                double      amount     = Convert.ToDouble(shoppingCard.Element("PaymentAmount").Value, info);
                PaymentType type       = PaymentType.cash;
                if (shoppingCard.Element("PaymentType").Value == "creditcard")
                {
                    type = PaymentType.creditcard;
                }
                List <ItemToPurchase> tempitemsToPurchase = new List <ItemToPurchase>();
                XElement itemToPurchaseRootElement        = shoppingCard.Element("ItemToPurchaseList");
                foreach (XElement item in itemToPurchaseRootElement.Elements())
                {
                    ItemToPurchase itemToPurchase = new ItemToPurchase();
                    string         classType      = item.FirstAttribute.Value;
                    string         ID             = item.Element("id").Value;
                    string         name           = item.Element("name").Value;
                    double         price          = Convert.ToDouble(item.Element("price").Value, info);
                    Image          image          = UtilConvert.Base64ToImage(item.Element("image").Value);
                    Creator        c;
                    if (classType == "Book")
                    {
                        c = new BookFactory(name, ID, price, "", "", "", 0, image);
                        itemToPurchase.Product = c.FactoryMethod();
                    }
                    else if (classType == "Magazine")
                    {
                        c = new MagazineFactory(name, ID, price, "", Magazine_Type.Actual, image);
                        itemToPurchase.Product = c.FactoryMethod();
                    }
                    else
                    {
                        c = new MusicCdFactory(name, ID, price, "", MusicCD_Type.Country, image);
                        itemToPurchase.Product = c.FactoryMethod();
                    }
                    itemToPurchase.Quantity = Int32.Parse(item.Element("quantity").Value);
                    tempitemsToPurchase.Add(itemToPurchase);
                }
                ShoppingCard shoppCard = new ShoppingCard();
                shoppCard.itemsToPurchase = tempitemsToPurchase;
                shoppCard.PaymentAmount   = amount;
                shoppCard.CustomerID      = customerID;
                shoppCard.Type            = type;
                shoppingCardList.Add(shoppCard);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        ///  This function loads the elements of the MyOrders.xml file.
        /// </summary>
        /// <param name="OrderList">This parameter is a list of ShoppingCard class.</param>
        /// <returns> This function does not return a value  </returns>
        public static void LoadOrder(List <ShoppingCard> OrderList)
        {
            if (!File.Exists(@"data/MyOrders.xml"))
            {
                XmlTextWriter writer = new XmlTextWriter(@"data/MyOrders.xml", System.Text.Encoding.UTF8);
                writer.WriteStartDocument(true);
                writer.Formatting  = Formatting.Indented;
                writer.Indentation = 2;
                writer.WriteStartElement("Orders");
                writer.WriteEndElement();
                writer.WriteEndDocument();
                writer.Close();
                return;
            }
            XDocument        xDoc             = XDocument.Load(@"data/MyOrders.xml");
            XElement         OrderRootElement = xDoc.Root;
            NumberFormatInfo info             = new NumberFormatInfo();

            info.NumberDecimalSeparator = ".";
            foreach (XElement order in OrderRootElement.Elements())
            {
                string      customerID = order.FirstAttribute.Value;
                double      amount     = Convert.ToDouble(order.Element("PaymentAmount").Value, info);
                PaymentType type       = PaymentType.cash;
                if (order.Element("PaymentType").Value == "creditcard")
                {
                    type = PaymentType.creditcard;
                }
                else if (order.Element("PaymentType").Value == "transfer")
                {
                    type = PaymentType.transfer;
                }
                OrderStatus orderStatus = OrderStatus.canceled;
                if (order.Element("OrderStatus").Value == "received")
                {
                    orderStatus = OrderStatus.received;
                }
                else if (order.Element("OrderStatus").Value == "shipped")
                {
                    orderStatus = OrderStatus.shipped;
                }
                else if (order.Element("OrderStatus").Value == "waitForShip")
                {
                    orderStatus = OrderStatus.waitForShip;
                }
                int cargoamount = Convert.ToInt32(order.Element("CargoAmount").Value);
                int oid         = Convert.ToInt32(order.LastAttribute.Value);
                List <ItemToPurchase> tempitemsToPurchase = new List <ItemToPurchase>();
                XElement itemToPurchaseRootElement        = order.Element("ItemToPurchaseList");
                foreach (XElement item in itemToPurchaseRootElement.Elements())
                {
                    ItemToPurchase itemToPurchase = new ItemToPurchase();
                    string         id             = item.Element("id").Value;
                    string         name           = item.Element("name").Value;
                    double         price          = Convert.ToDouble(item.Element("price").Value, info);
                    int            quantity       = Convert.ToInt32(item.Element("quantity").Value);
                    Image          image          = UtilConvert.Base64ToImage(item.Element("image").Value);
                    Creator        c;
                    if (item.FirstAttribute.Value == "Book")
                    {
                        c = new BookFactory(name, id, price, "", "", "", 0, image);
                        itemToPurchase.Product  = c.FactoryMethod();
                        itemToPurchase.Quantity = quantity;
                        tempitemsToPurchase.Add(itemToPurchase);
                    }
                    else if (item.FirstAttribute.Value == "Magazine")
                    {
                        c = new MagazineFactory(name, id, price, "", Magazine_Type.Actual, image);
                        itemToPurchase.Product  = c.FactoryMethod();
                        itemToPurchase.Quantity = quantity;
                        tempitemsToPurchase.Add(itemToPurchase);
                    }
                    else
                    {
                        c = new MusicCdFactory(name, id, price, "", MusicCD_Type.Country, image);
                        itemToPurchase.Product  = c.FactoryMethod();
                        itemToPurchase.Quantity = quantity;
                        tempitemsToPurchase.Add(itemToPurchase);
                    }
                }
                ShoppingCard _order = new ShoppingCard();
                _order.itemsToPurchase = tempitemsToPurchase;
                _order.PaymentAmount   = amount;
                _order.CustomerID      = customerID;
                _order.Type            = type;
                _order.Status          = orderStatus;
                _order.CargoAmount     = cargoamount;
                _order.OID             = oid;
                OrderList.Add(_order);
            }
        }