public Magazine addNewMagazine(MagazineType type, string issue, String name, int id, double price)
        {
            Magazine magazine = (Magazine)ProductFactory.CreateProduct(ProductName.Magazine, name, id, price);

            if (magazine is Magazine)
            {
                magazine.Type  = type;
                magazine.Issue = issue;
            }
            return(magazine);
        }
示例#2
0
 void LoadMagazine(String category)
 {
     foreach (Product item in products)
     {
         if (item is Magazine)
         {
             Magazine magazine = (Magazine)item;
             if (category == magazine.Type.ToString())
             {
                 currentProducts.Add(item);
                 ProductPanel productPanel = ProductPanelCreator.CreatePanel(item);
                 flPanel.Controls.Add(productPanel);
             }
         }
     }
 }
示例#3
0
        public void addMagazine(Magazine magazine)
        {
            SqlConnection connection = new SqlConnection(ConnectionString);
            string        sorgu      = "Insert into magazine (id,name,price,type,picture,issue) values (@id,@name,@price,@type,@picture,@issue)";
            SqlCommand    komut      = new SqlCommand(sorgu, connection);

            komut.Parameters.AddWithValue("@id", magazine.Id);
            komut.Parameters.AddWithValue("@name", magazine.Name);
            komut.Parameters.AddWithValue("@price", magazine.Price);
            komut.Parameters.AddWithValue("@type", magazine.Type.ToString());
            komut.Parameters.AddWithValue("@picture", magazine.Picture);
            komut.Parameters.AddWithValue("@issue", magazine.Issue);
            connection.Open();
            komut.ExecuteNonQuery();
            connection.Close();
            addProduct("magazine", magazine.Id);
            updateProductCount(magazine.Id);
        }
示例#4
0
        public static Product CreateProduct(ProductNames ProductName, String name, int id, double price, String picture, String issue)
        {
            Product product = null;

            switch (ProductName)
            {
            case ProductNames.Magazine:
                product = new Magazine(name, id, price, picture, issue);
                break;

            case ProductNames.MusicCD:
                product = new MusicCD(name, id, price, picture, issue);
                break;

            case ProductNames.Book:
                product = new Book(name, id, price, picture, issue);
                break;

            default:
                break;
            }

            return(product);
        }
示例#5
0
        public Magazine GetMagazine(int id)
        {
            Magazine      magazine   = null;
            SqlConnection connection = new SqlConnection(ConnectionString);

            connection.Open();
            SqlCommand    command = new SqlCommand("select * from magazine", connection);
            SqlDataReader reader  = command.ExecuteReader();

            while (reader.Read())
            {
                if (id == Convert.ToInt32(reader["id"]))
                {
                    MagazineType type = Magazine.getmagazine(reader["type"].ToString().Trim());
                    magazine    = new Magazine(type, reader["issue"].ToString(), reader["name"].ToString(), Convert.ToInt32(reader["id"]), Convert.ToDouble(reader["price"]));
                    magazine.Id = Convert.ToInt32(reader["id"]);
                    if (magazine.Id > Product.Idcount)
                    {
                        Product.Idcount = magazine.Id;
                    }
                }
            }
            return(magazine);
        }
        public MagazinePanel(Magazine item)
        {
            magazine         = item;
            this.BackColor   = Color.Transparent;
            this.Size        = new Size(400, 200);
            this.BorderStyle = BorderStyle.FixedSingle;


            picBox      = new PictureBox();
            picBox.Size = new Size(105, 160);
            try
            {
                picBox.BackgroundImage = Image.FromFile(Application.StartupPath + @"\resources\magazines\" + item.Picture);
            }
            catch
            {
                picBox.BackgroundImage = Image.FromFile(Application.StartupPath + @"\resources\not-found.png");
            }
            picBox.BackgroundImageLayout = ImageLayout.Zoom;

            show                                   = new Button();
            show.Size                              = new Size(64, 64);
            show.BackgroundImage                   = Image.FromFile(Application.StartupPath + @"\resources\show.png");
            show.BackgroundImageLayout             = ImageLayout.Zoom;
            show.FlatStyle                         = System.Windows.Forms.FlatStyle.Flat;
            show.FlatAppearance.BorderSize         = 0;
            show.BackColor                         = Color.Transparent;
            show.FlatAppearance.MouseDownBackColor = Color.Transparent;
            show.FlatAppearance.MouseOverBackColor = Color.Transparent;
            show.Cursor                            = Cursors.Hand;
            show.Click                            += new EventHandler(showClick);

            purchase                                   = new Button();
            purchase.Size                              = new Size(64, 64);
            purchase.BackgroundImage                   = Image.FromFile(Application.StartupPath + @"\resources\purchase.png");
            purchase.BackgroundImageLayout             = ImageLayout.Zoom;
            purchase.FlatStyle                         = System.Windows.Forms.FlatStyle.Flat;
            purchase.FlatAppearance.BorderSize         = 0;
            purchase.BackColor                         = Color.Transparent;
            purchase.FlatAppearance.MouseDownBackColor = Color.Transparent;
            purchase.FlatAppearance.MouseOverBackColor = Color.Transparent;
            purchase.Cursor                            = Cursors.Hand;
            purchase.Click                            += new EventHandler(purchaseClick);



            NameOfMagazine          = new Label();
            NameOfMagazine.AutoSize = true;
            NameOfMagazine.Text     = item.Name;
            NameOfMagazine.Font     = new Font("OCR A", (float)10, FontStyle.Bold);
            this.Controls.Add(NameOfMagazine);

            Issue           = new Label();
            Issue.AutoSize  = true;
            Issue.Text      = item.Type.ToString();
            Issue.Font      = new Font("OCR A", (float)8.25);
            Issue.ForeColor = Color.Black;
            this.Controls.Add(Issue);

            Price           = new Label();
            Price.AutoSize  = true;
            Price.Text      = magazine.Price.ToString() + " TL";
            Price.Font      = new Font("OCR A", (float)11.25, FontStyle.Bold);
            Price.ForeColor = Color.Black;
            this.Controls.Add(Price);



            this.Controls[0].Location = new Point(125, 20); //name
            this.Controls[0].BringToFront();
            this.Controls[1].Location = new Point(125, 50); //category
            this.Controls[1].BringToFront();
            this.Controls[2].Location = new Point(125, 80); //price
            this.Controls[2].BringToFront();
            this.Controls.Add(picBox);
            this.Controls[3].Location = new Point(10, 15); //Item image
            this.Controls.Add(show);
            this.Controls[4].Location = new Point(170, 140);
            this.Controls.Add(purchase);
            this.Controls[5].Location = new Point(240, 140);
        }
示例#7
0
 public MagazineForm(Magazine magazine) : base()
 {
     this.magazine = magazine;
     InitializeComponent();
 }