Esempio n. 1
0
        public MusicCD GetMusicCD(int id)
        {
            MusicCD       musicCD    = null;
            SqlConnection connection = new SqlConnection(ConnectionString);

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

            while (reader.Read())
            {
                if (id == Convert.ToInt32(reader["id"]))
                {
                    MusicCDType type = MusicCD.getMusicCDType(reader["type"].ToString().Trim());
                    musicCD    = new MusicCD(reader["singer"].ToString().Trim(), type, reader["name"].ToString(), Convert.ToInt32(reader["id"]), Convert.ToDouble(reader["price"]), reader["demo"].ToString().Trim(), reader["picture"].ToString(), reader["issue"].ToString());
                    musicCD.Id = Convert.ToInt32(reader["id"]);
                    if (musicCD.Id > Product.Idcount)
                    {
                        Product.Idcount = musicCD.Id;
                    }
                }
            }
            connection.Close();
            return(musicCD);
        }
Esempio n. 2
0
        public void GetProduct(List <Product> productList)
        {
            SqlConnection connection = new SqlConnection(ConnectionString);

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

            while (reader.Read())
            {
                if (reader["type"].ToString().Trim() == "book")
                {
                    Book book = GetBook(Convert.ToInt32(reader["id"]));
                    productList.Add(book);
                }
                else if (reader["type"].ToString().Trim() == "musicCD")
                {
                    MusicCD musicCD = GetMusicCD(Convert.ToInt32(reader["id"]));
                    productList.Add(musicCD);
                }
                else if (reader["type"].ToString().Trim() == "magazine")
                {
                    Magazine magazine = GetMagazine(Convert.ToInt32(reader["id"]));
                    productList.Add(magazine);
                }
                else
                {
                    //invalid type.
                }
            }
            connection.Close();
        }
Esempio n. 3
0
        public void addNewMusicCD(String singer, MusicCDType type, String name, int id, double price, String picture, String issue)
        {
            MusicCD musicCD = (MusicCD)ProductFactory.CreateProduct(ProductNames.MusicCD, name, id, price, picture, issue);

            if (musicCD is MusicCD)
            {
                musicCD.Type   = type;
                musicCD.Singer = singer;
            }
            data.addmusicCD(musicCD);
        }
Esempio n. 4
0
        private void btnAddMusicCD_Click(object sender, EventArgs e)
        {
            ;
            MusicCDType type = MusicCD.getMusicCDType(cmbMusicType.SelectedItem.ToString());

            adminUser.addNewMusicCD(txtMusicSinger.Text, type, txtMusicName.Text, Product.Idcount, Convert.ToDouble(txtMusicPrice.Text.Trim()), txtMusicName.Text.Trim() + ".jpg", txtMusicIssue.Text);
            DataTable dataTable = new DataTable();

            DataTable             = data.datagrid(dataTable, "musicCD");
            dtgMusicCD.DataSource = DataTable;
        }
        public MusicCD addNewMusicCD(String singer, MusicCDType type, String name, int id, double price)
        {
            MusicCD musicCD = (MusicCD)ProductFactory.CreateProduct(ProductName.MusicCD, name, id, price);

            if (musicCD is MusicCD)
            {
                musicCD.Type   = type;
                musicCD.Singer = singer;
            }
            return(musicCD);
        }
Esempio n. 6
0
        void LoadMusicCD(String category)
        {
            foreach (Product item in products)
            {
                if (item is MusicCD)
                {
                    MusicCD musicCD = (MusicCD)item;

                    if (category == musicCD.Type.ToString())
                    {
                        currentProducts.Add(item);
                        ProductPanel productPanel = ProductPanelCreator.CreatePanel(item);
                        flPanel.Controls.Add(productPanel);
                    }
                }
            }
        }
Esempio n. 7
0
        public void addmusicCD(MusicCD musicCD)
        {
            SqlConnection connection = new SqlConnection(ConnectionString);
            string        sorgu      = "Insert into musicCD (id,name,price,type,picture,issue,singer,demo) values (@id,@name,@price,@type,@picture,@issue,@singer,@demo)";
            SqlCommand    komut      = new SqlCommand(sorgu, connection);

            komut.Parameters.AddWithValue("@id", musicCD.Id);
            komut.Parameters.AddWithValue("@singer", musicCD.Singer);
            komut.Parameters.AddWithValue("@name", musicCD.Name);
            komut.Parameters.AddWithValue("@price", musicCD.Price);
            komut.Parameters.AddWithValue("@demo", musicCD.Name + ".wav");
            komut.Parameters.AddWithValue("@type", musicCD.Type.ToString());
            komut.Parameters.AddWithValue("@picture", musicCD.Picture);
            komut.Parameters.AddWithValue("@issue", musicCD.Issue);
            connection.Open();
            komut.ExecuteNonQuery();
            connection.Close();
            addProduct("musicCD", musicCD.Id);
            updateProductCount(musicCD.Id);
        }
Esempio n. 8
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);
        }
 public MusicCDForm(MusicCD musicCD)
 {
     this.musicCD = musicCD;
     InitializeComponent();
 }
        public MusicCDPanel(MusicCD item)
        {
            musicCD          = 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\musicCds\" + 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.FlatAppearance.MouseDownBackColor = Color.Transparent;
            show.FlatAppearance.MouseOverBackColor = Color.Transparent;
            show.BackColor                         = 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);


            name           = new Label();
            name.AutoSize  = true;
            name.Text      = musicCD.Name;
            name.TextAlign = ContentAlignment.MiddleLeft;
            name.Font      = new Font("OCR A", (float)10, FontStyle.Bold);
            this.Controls.Add(name);

            Singer          = new Label();
            Singer.AutoSize = true;
            Singer.Text     = item.Singer;
            Singer.Font     = new Font("OCR A", (float)8.25);
            this.Controls.Add(Singer);



            Price          = new Label();
            Price.AutoSize = true;
            Price.Text     = musicCD.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);  // Author
            this.Controls[1].BringToFront();
            this.Controls[2].Location = new Point(125, 110); //  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);
        }