/// <summary>
 /// This function update elements of the ProductList.xml file.
 /// </summary>
 /// <param name="product">This parameter is a object of Product class.</param>
 /// <returns> This function does not return a value </returns>
 public static void Update(Product product)
 {
     try
     {
         XDocument xDoc        = XDocument.Load(@"data/ProductList.xml");
         XElement  rootElement = xDoc.Root;
         foreach (XElement item in rootElement.Elements())
         {
             if (item.Attribute("ID").Value == product.ID1)
             {
                 if (product is Book)
                 {
                     Book temp = (Book)product;
                     item.Element("Name").Value      = temp.Name;
                     item.Element("Price").Value     = temp.Price.ToString();
                     item.Element("Image").Value     = UtilConvert.ImageToBase64(temp.Image, temp.Image.RawFormat);
                     item.Element("ISBN").Value      = temp.ISBN1;
                     item.Element("Author").Value    = temp.Author;
                     item.Element("Publisher").Value = temp.Publisher;
                     item.Element("Pages").Value     = temp.Pages.ToString();
                     xDoc.Save(@"data/ProductList.xml");
                     return;
                 }
                 else if (product is Magazine)
                 {
                     Magazine temp = (Magazine)product;
                     item.Element("Name").Value         = temp.Name;
                     item.Element("Price").Value        = temp.Price.ToString();
                     item.Element("Image").Value        = UtilConvert.ImageToBase64(temp.Image, temp.Image.RawFormat);
                     item.Element("Issue").Value        = temp.Issue;
                     item.Element("MagazineType").Value = temp.Type.ToString();
                     xDoc.Save(@"data/ProductList.xml");
                     return;
                 }
                 else
                 {
                     MusicCD temp = (MusicCD)product;
                     item.Element("Name").Value        = temp.Name;
                     item.Element("Price").Value       = temp.Price.ToString();
                     item.Element("Image").Value       = UtilConvert.ImageToBase64(temp.Image, temp.Image.RawFormat);
                     item.Element("Singer").Value      = temp.Singer;
                     item.Element("MusicCDType").Value = temp.Type.ToString();
                     xDoc.Save(@"data/ProductList.xml");
                     return;
                 }
             }
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
Beispiel #2
0
 public MagazineForm(Magazine magazine)
 {
     InitializeComponent();
     this.magazine       = magazine;
     this.Text           = magazine.Name;
     txtName.Text        = magazine.Name;
     txtCategory.Text    = magazine.Category;
     txtPrice.Text       = magazine.Price + " TL";
     txtContent.Text     = magazine.Issue;
     pbMagazine.Image    = magazine.Picture;
     pbMagazine.SizeMode = PictureBoxSizeMode.StretchImage;
     txtCounter.Text     = "1";
     txtIsbn.Text        = magazine.Isbn;
 }
Beispiel #3
0
        /// <summary>
        /// This function update selected magazine button click operation.
        /// This function is used to changed enabled.
        /// </summary>
        /// <returns> This function does not return a value  </returns>
        private void btnUpdateSelected_Click(object sender, EventArgs e)
        {
            Logger.GetLogger().WriteLog(LoginedCustomer.getInstance().User.Username, btnUpdateSelected.Text, DateTime.Now);
            if (selectedIndex == -1)
            {
                MessageBox.Show("Please select a book from list!");
                return;
            }
            panelAddMagazine.Visible = true;
            selectedID = listViewMagazines.Items[selectedIndex].SubItems[0].Text;
            foreach (Product product in StoreMainScreen.productList)
            {
                if (product.ID1 == selectedID)
                {
                    Magazine magazine = (Magazine)product;
                    pboxMagazine.Image = magazine.Image;
                    txtName.Text       = magazine.Name;
                    txtID.Text         = magazine.ID1;
                    txtPrice.Text      = magazine.Price.ToString();
                    txtIssue.Text      = magazine.Issue;
                    switch (magazine.Type)
                    {
                    case Magazine_Type.Actual:
                        cBoxType.SelectedIndex = 0;
                        break;

                    case Magazine_Type.Computer:
                        cBoxType.SelectedIndex = 1;
                        break;

                    case Magazine_Type.News:
                        cBoxType.SelectedIndex = 2;
                        break;

                    case Magazine_Type.Sport:
                        cBoxType.SelectedIndex = 3;
                        break;

                    case Magazine_Type.Technology:
                        cBoxType.SelectedIndex = 4;
                        break;
                    }
                    break;
                }
            }
            btnAdd.Visible    = false;
            btnUpdate.Visible = true;
            txtID.Enabled     = false;
        }
Beispiel #4
0
 /// <summary>
 /// This function holds the magazine information and create listview item.
 /// </summary>
 /// <returns> This function does not return a value  </returns>
 private void ToListView()
 {
     foreach (Product product in StoreMainScreen.productList)
     {
         if (product is Magazine)
         {
             Magazine     magazine    = (Magazine)product;
             string       id          = magazine.ID1;
             string       name        = magazine.Name;
             string       price       = magazine.Price.ToString();
             string       issue       = magazine.Issue;
             string       type        = magazine.Type.ToString();
             string[]     stringItems = { id, name, price, issue, type };
             ListViewItem item        = new ListViewItem(stringItems);
             listViewMagazines.Items.Add(item);
         }
     }
 }
        public static Product createProduct(ProductType pType, string id, string name, double price)
        {
            Product product = null;

            switch (pType)
            {
            case ProductType.Book:
                product = new Book(id, name, price);
                break;

            case ProductType.Magazine:
                product = new Magazine(id, name, price);
                break;

            case ProductType.MusicCD:
                product = new MusicCD(id, name, price);
                break;

            default:
                break;
            }
            return(product);
        }
        public MagazinePanel(Magazine magazine)
        {
            this.magazine    = magazine;
            this.BackColor   = Color.FromArgb(160, 0, 190, 190);
            this.Size        = new Size(290, 190);
            this.BorderStyle = BorderStyle.None;

            Picture                       = new PictureBox();
            Picture.Size                  = new System.Drawing.Size(105, 160);
            Picture.BackgroundImage       = magazine.Picture;
            Picture.BackgroundImageLayout = ImageLayout.Stretch;
            Picture.BackColor             = Color.Transparent;

            Show_Details                       = new PictureBox();
            Show_Details.Size                  = new Size(32, 32);
            Show_Details.BackgroundImage       = Properties.Resources.loupe;
            Show_Details.BackgroundImageLayout = ImageLayout.Stretch;
            Show_Details.Cursor                = Cursors.Hand;
            Show_Details.Click                += new EventHandler(Show_DetailsClick);
            Show_Details.BackColor             = Color.Transparent;

            Add_Cart                       = new PictureBox();
            Add_Cart.Size                  = new Size(32, 32);
            Add_Cart.BackgroundImage       = Properties.Resources.showDetails;
            Add_Cart.BackgroundImageLayout = ImageLayout.Stretch;
            Add_Cart.Cursor                = Cursors.Hand;
            Add_Cart.Click                += new EventHandler(Add_CartClick);
            Add_Cart.BackColor             = Color.Transparent;

            name           = new Label();
            name.AutoSize  = true;
            name.Text      = magazine.Name;
            name.BackColor = Color.Transparent;
            name.TextAlign = ContentAlignment.MiddleLeft;
            name.ForeColor = Color.White;
            name.Font      = new Font("Calibri", (float)12);
            this.Controls.Add(name);

            Type           = new Label();
            Type.AutoSize  = true;
            Type.BackColor = Color.Transparent;
            Type.Text      = magazine.Category;
            Type.Font      = new Font("Calibri", (float)10);
            Type.ForeColor = Color.White;
            this.Controls.Add(Type);

            Price           = new Label();
            Price.AutoSize  = true;
            Price.BackColor = Color.Transparent;
            Price.Text      = magazine.Price + " TL";
            Price.ForeColor = Color.White;
            this.Controls.Add(Price);

            this.Controls[0].Location = new Point(125, 20);  // Name label
            this.Controls[0].BringToFront();
            this.Controls[1].Location = new Point(125, 55);  // Type label
            this.Controls[1].BringToFront();
            this.Controls[2].Location = new Point(125, 110); //  Price label
            this.Controls[2].BringToFront();
            this.Controls.Add(Picture);
            this.Controls[3].Location = new Point(10, 15);   //Picturebox
            this.Controls.Add(Show_Details);
            this.Controls[4].Location = new Point(170, 140); //Magnifier image
            this.Controls.Add(Add_Cart);
            this.Controls[5].Location = new Point(225, 140); //Add to cart image
        }