Beispiel #1
0
        public List <Product> MagazineLoader() ///dergilerin listesi, yuklemesi yapilir
        {
            List <Product> magazinelist = new List <Product>();

            db.connection.Open();
            SqlCommand    command = new SqlCommand("SELECT * FROM [dbo].[MAGAZINE]", connection);
            SqlDataReader reader  = command.ExecuteReader();
            Magazine      mg;

            while (reader.Read())
            {
                mg             = new Magazine();
                mg.ProductID   = (int)reader["ID"];
                mg.name        = (string)reader["NAME"];
                mg.Description = (string)reader["DESCRIPTION"];
                mg.Issue       = "Issue: " + reader["ISSUE"];
                mg.price       = Convert.ToDouble(reader["PRICE"]);
                mg.Sale        = Convert.ToDouble(reader["SALE"]);
                mg.Category    = (string)reader["TYPE"];

                if (mg.Sale <= 0 || mg.Sale >= 100)
                {
                    mg.discountedPrice = mg.price;
                }
                else
                {
                    mg.discountedPrice = mg.price - (mg.price * mg.Sale) / 100;
                }

                try
                {
                    mg.image = Image.FromFile(Application.StartupPath + @"\Resources\MagazinePictures\" + (string)reader["IMAGEDEST"] + ".png");
                }
                catch (Exception)
                {
                    mg.image = Properties.Resources.dasdas;
                }

                magazinelist.Add(mg);
            }
            db.connection.Close();
            return(magazinelist);
        }
        public MagazinePanel(Magazine item) ///sergilenen tum dergileri belirli bir standartta sergilemek icin olusturulan paneldir
        {
            magazine         = item;
            this.BackColor   = Color.Transparent;
            this.Size        = new Size(350, 190);
            this.BorderStyle = BorderStyle.FixedSingle;


            picBox                       = new PictureBox();
            picBox.Size                  = new Size(105, 160);
            picBox.BackgroundImage       = item.image;
            picBox.BackgroundImageLayout = ImageLayout.Zoom;


            magnifier                       = new PictureBox();
            magnifier.Size                  = new Size(32, 32);
            magnifier.BackgroundImage       = Properties.Resources.magnifier;
            magnifier.BackgroundImageLayout = ImageLayout.Zoom;
            magnifier.Cursor                = Cursors.Hand;
            magnifier.Click                += new EventHandler(magnifierClick);

            picAdd                       = new PictureBox();
            picAdd.Size                  = new Size(32, 32);
            picAdd.BackgroundImage       = Properties.Resources.cart;
            picAdd.BackgroundImageLayout = ImageLayout.Zoom;
            picAdd.Cursor                = Cursors.Hand;
            picAdd.Click                += new EventHandler(addCart);


            name           = new Label();
            name.AutoSize  = true;
            name.Text      = item.name;
            name.TextAlign = ContentAlignment.MiddleLeft;
            name.Font      = new Font("Century Gothic", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(162)));
            this.Controls.Add(name);

            Issue          = new Label();
            Issue.AutoSize = true;
            Issue.Text     = item.Issue;
            Issue.Font     = new Font("Century Gothic", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(162)));
            this.Controls.Add(Issue);

            Type           = new Label();
            Type.AutoSize  = true;
            Type.Text      = item.Category;
            Type.Font      = new Font("Century Gothic", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(162)));
            Type.ForeColor = Color.Black;
            this.Controls.Add(Type);

            Price1          = new Label();
            Price1.AutoSize = true;

            if (item.Sale > 0 && item.Sale < 100)
            {
                Price1.Text = item.price + "TL  %" + item.Sale;
            }
            else
            {
                Price1.Text = "";
            }

            Price1.Font      = new Font("Century Gothic", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(162)));
            Price1.ForeColor = Color.Black;
            this.Controls.Add(Price1);

            Price2          = new Label();
            Price2.AutoSize = true;
            Price2.Text     = item.discountedPrice + " TL";
            Price2.Font     = new Font("Century Gothic", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(162)));
            this.Controls.Add(Price2);

            this.Controls[0].Location = new Point(125, 20);  /// Name label
            this.Controls[0].BringToFront();
            this.Controls[1].Location = new Point(125, 50);  /// Author label
            this.Controls[1].BringToFront();
            this.Controls[2].Location = new Point(125, 80);  /// Publisher label
            this.Controls[2].BringToFront();
            this.Controls[3].Location = new Point(125, 110); ///  Price1 label
            this.Controls[3].BringToFront();
            this.Controls[4].Location = new Point(210, 110); /// Price2 label
            this.Controls[4].BringToFront();
            this.Controls.Add(picBox);
            this.Controls[5].Location = new Point(10, 15);   /// Item image
            this.Controls.Add(magnifier);
            this.Controls[6].Location = new Point(170, 140); /// Magnifier image
            this.Controls.Add(picAdd);
            this.Controls[7].Location = new Point(225, 140); /// Add to cart image
        }