Ejemplo n.º 1
0
        /// <summary>
        /// This function updates music.
        /// </summary>
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                string name   = txtName.Text;
                string id     = txtId.Text;
                string singer = txtSinger.Text;
                string type   = txtType.Text;
                string price  = txtPrice.Text;

                MusicCD musicCD = new MusicCD(name, id, price, singer, type, update_image);
                db.UpdateMusicCD(musicCD);
                List <Product> MCD = Util.FillMusicCDList();
                if (MCD.Count != 0)
                {
                    MCD.Clear();
                }
                ListMusicCDs(MCD);
                dgvMusicCDs.Show();
                selected_index = -1;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 2
0
        void getMusicCD()
        {
            SqlCommand    komut = new SqlCommand("Select * From Tbl_MusicCD", bgl.baglanti());
            SqlDataReader dr    = komut.ExecuteReader();

            while (dr.Read())
            {
                MusicCD musicCD = new MusicCD();
                musicCD.ID     = Convert.ToUInt16(dr[0]);
                musicCD.Singer = dr[1].ToString();
                musicCD.Type   = dr[2].ToString();
                musicCD.Name   = dr[3].ToString();
                musicCD.Price  = Convert.ToDouble(dr[4]);

                try
                {
                    musicCD.Image = Image.FromFile(Application.StartupPath + @"\Resources\müzik\" + musicCD.Name + ".png");
                }
                catch
                {
                    musicCD.Image = Resources.notfound;
                }
                musicCDlist.Add(musicCD);
            }
            bgl.baglanti().Close();
        }
Ejemplo n.º 3
0
        /**
         *\brief A function to get the music CD list
         *\return The music CD list
         */
        public static List <MusicCD> GetMusicCDList()
        {
            SqlCommand     sqlSelectCommand = MusicCD.GetSelectCommand();
            List <MusicCD> MusicCDList      = new List <MusicCD>();

            try
            {
                DatabaseHandler.SQL_CONNECTION.Open();

                SqlDataReader reader = sqlSelectCommand.ExecuteReader();
                while (reader.HasRows && reader.Read())
                {
                    object[] attributesOfMagazine = new object[5];      //  MusicCD class has 5 attributes.
                    reader.GetValues(attributesOfMagazine);             //  Get the first row.

                    MusicCD newMusicCD = new MusicCD(0, "a", 0);
                    newMusicCD.Fill(attributesOfMagazine);
                    MusicCDList.Add(newMusicCD);
                }

                DatabaseHandler.SQL_CONNECTION.Close();

                return(MusicCDList);
            }
            catch (Exception error)
            {
                MessageBox.Show(error.Message);
                return(null);
            }
        }
Ejemplo n.º 4
0
        public static void ItemPicture_Click(object sender, EventArgs e)
        {
            PictureBox item = (PictureBox)sender;
            GroupBox   gb   = (GroupBox)item.Parent;

            string itemName        = gb.Controls[1].Text;
            string sourceTableName = PresentTabTableName();

            if (sourceTableName == "tblBook")
            {
                List <Book> BookList    = Factory.GetBookList();
                Book        clickedBook = BookList.First(book => book.Name == itemName);
                clickedBook.PrintProperties();
            }
            else if (sourceTableName == "tblMagazine")
            {
                List <Magazine> MagazineList    = Factory.GetMagazineList();
                Magazine        clickedMagazine = MagazineList.First(magazine => magazine.Name == itemName);
                clickedMagazine.PrintProperties();
            }
            else if (sourceTableName == "tblMusicCD")
            {
                List <MusicCD> MusicCDList    = Factory.GetMusicCDList();
                MusicCD        clickedMusicCD = MusicCDList.First(magazine => magazine.Name == itemName);
                clickedMusicCD.PrintProperties();
            }
        }
Ejemplo n.º 5
0
 public MusicForm(MusicCD musicCD)
 {
     this.musicCD = musicCD;
     InitializeComponent();
     this.Text       = musicCD.name;
     picBox.Image    = musicCD.image;
     picBox.SizeMode = PictureBoxSizeMode.StretchImage;
     name.Text       = musicCD.name;
     singer.Text     = musicCD.Singer;
     category.Text   = "Category:" + musicCD.Category;
     if (musicCD.Sale > 0 && musicCD.Sale < 100)
     {
         price1.Text = musicCD.price + " TL  %" + musicCD.Sale;
     }
     else
     {
         price1.Text = "";
     }
     price2.Text = (musicCD.price - musicCD.price * (musicCD.Sale / 100)) + " TL";
     string[] descriptionText = musicCD.Description.Split('$');
     lblDescription.Text = "";
     for (int i = 0; i < descriptionText.Length; i++)
     {
         lblDescription.Text += descriptionText[i] + Environment.NewLine;
     }
     mtQuantity.Text = "01";
     picBox.BackgroundImageLayout = ImageLayout.Zoom;
 }
Ejemplo n.º 6
0
 public static MusicCD getInstance()
 {
     if (instance == null)
     {
         instance = new MusicCD();
     }
     return(instance);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// This parameter is constructor.
 /// </summary>
 /// <param name="_musicCD">This parameter is musicCD.</param>
 public UC_MusicCD(MusicCD _musicCD)
 {
     this.Size = new Size(284, 453);
     InitializeComponent();
     lblMusicCDName.Text  = _musicCD.Name;
     lblSinger.Text       = _musicCD.Singer;
     lblType.Text         = _musicCD.Type;
     lblMusicCDPrice.Text = _musicCD.Price;
     ID = _musicCD.Id;
     picCoverPage.Image = Util.ResizeBitmap(Util.stringToImage(_musicCD.CoverPage),
                                            picCoverPage.Width, picCoverPage.Height);
     picBox = _musicCD.CoverPage;
 }
Ejemplo n.º 8
0
 private void btnaddtocartmusic_Click(object sender, EventArgs e)
 {
     if (tbMagazineName.Text != "" || tbMusicCDName.Text != "" || txtBookName.Text != "")
     {
         ItemToPurchase Item3 = new ItemToPurchase();
         MusicCD        music = new MusicCD("0", tbMusicCDName.Text, Convert.ToDouble(tbMusicCDPrice.Text));
         Item3.Product  = music;
         Item3.Quantity = int.Parse(tbquantymusic.Text);
         itemsOnCart.Add(Item3);
         MessageBox.Show("item is added to your shopping cart");
     }
     else
     {
         MessageBox.Show("Please Select Product To add Shoppingcart");
     }
 }
Ejemplo n.º 9
0
        /// <summary>
        /// This function deletes music in database.
        /// </summary>
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                dgvMusicCDs.FirstDisplayedCell = null;
                dgvMusicCDs.ClearSelection();
                List <Product> MUList = Util.FillMusicCDList();
                if (MUList.Count != 0)
                {
                    for (int i = 0; i < MUList.Count; i++)
                    {
                        selected_index = dgvMusicCDs.CurrentCell.RowIndex;

                        MemoryStream ms  = new MemoryStream();
                        Bitmap       img = (Bitmap)dgvMusicCDs.Rows[selected_index].Cells[0].Value;
                        img.Save(ms, ImageFormat.Jpeg);
                        byte[] image = ms.ToArray();

                        string name   = dgvMusicCDs.Rows[selected_index].Cells[1].Value.ToString();
                        string price  = dgvMusicCDs.Rows[selected_index].Cells[2].Value.ToString();
                        string id     = dgvMusicCDs.Rows[selected_index].Cells[3].Value.ToString();
                        string singer = dgvMusicCDs.Rows[selected_index].Cells[4].Value.ToString();
                        string type   = dgvMusicCDs.Rows[selected_index].Cells[5].Value.ToString();

                        MusicCD musicCD = new MusicCD(name, id, price, singer, type, image);

                        db.DeleteMusicCD(musicCD);
                        if (MUList.Count != 0)
                        {
                            MUList.Clear();
                        }
                        dgvMusicCDs.Rows.RemoveAt(selected_index);
                        selected_index = -1;
                    }
                }
                else
                {
                    MessageBox.Show("MusicCD is Empty!");
                    btnDelete.Enabled = false;
                    btnUpdate.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 10
0
 /// <summary>
 /// This function is for deleting mucicCD from the database.
 /// </summary>
 /// <param name="music">This parameter is a music that will be delete from database.</param>
 public void DeleteMusicCD(MusicCD music)
 {
     try
     {
         connection.Connection();
         connection.Open();
         SqlCommand command = new SqlCommand("Delete from Tbl_Music where ID=@ProductId", connection.Connect);
         command.Parameters.AddWithValue("@ProductId", music.Id);
         command.ExecuteNonQuery();
         connection.Close();
         MessageBox.Show("MusicCD deleted.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        public List <Product> MusicCDLoader()
        {
            List <Product> musiclist = new List <Product>();

            dh.connection.Open();
            SqlCommand    command = new SqlCommand("SELECT * FROM [dbo].[MusicCD]", connection);
            SqlDataReader reader  = command.ExecuteReader();
            MusicCD       mc;

            while (reader.Read())
            {
                mc             = new MusicCD();
                mc.ProductID   = (int)reader["ID"];
                mc.name        = (string)reader["Name"];
                mc.Singer      = (string)reader["Singer"];
                mc.Description = (string)reader["Description"];
                mc.demo        = (string)reader["Demo"];
                mc.price       = (double)reader["Price"];
                mc.Sale        = (double)reader["Sale"];

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

                mc.Category = (string)reader["Category"];
                try
                {
                    mc.image = Image.FromFile(Application.StartupPath + @"\Resources\MusicCdPictures\" + (string)reader["Image"] + ".png");
                }
                catch (Exception)
                {
                    mc.image = Properties.Resources.noimage;
                }
                musiclist.Add(mc);
            }
            dh.connection.Close();
            return(musiclist);
        }
Ejemplo n.º 12
0
 /// <summary>
 /// This function add new music to database.
 /// </summary>
 private void btnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         bool           already_exists = false;
         List <Product> MUList         = Util.FillMusicCDList();
         for (int i = 0; i < MUList.Count; i++)
         {
             MusicCD tmp = new MusicCD(_name, _id, _price, _singer, _type, _coverpage);
             tmp = (MusicCD)MUList[i];
             if (tmp.Id == txtId.Text)
             {
                 already_exists = true;
                 MessageBox.Show(tmp.Id + " ID already exists! Please change!");
             }
         }
         if (already_exists == false)
         {
             if (txtName.Text != "" && txtId.Text != "" && txtPrice.Text != "" && txtSinger.Text != "" && picCoverPage.Image != null && txtType.Text != "")
             {
                 string  name   = txtName.Text;
                 string  id     = txtId.Text;
                 string  price  = txtPrice.Text;
                 string  type   = txtType.Text;
                 string  singer = txtSinger.Text;
                 byte[]  image  = System.IO.File.ReadAllBytes(openFileDialogMusicCDs.FileName);
                 MusicCD music  = new MusicCD(name, id, price, singer, type, image);
                 db.AddMusicCD(music);
             }
             else
             {
                 MessageBox.Show("Please! Fill all fields!");
             }
         }
         Tb_Empty();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Ejemplo n.º 13
0
 /// <summary>
 /// This function is for pulling the MusicCD list from the database.
 /// </summary>
 public void MusicCDList()
 {
     try
     {
         musicTable.Clear();
         connection.Connection();
         connection.Open();
         SqlDataAdapter da = new SqlDataAdapter("Select * from Tbl_Music", connection.Connect);
         da.Fill(musicTable);
         connection.Close();
         for (int i = 0; i < musicTable.Rows.Count; i++)
         {
             music = new MusicCD(musicTable.Rows[i]["Name"].ToString(), musicTable.Rows[i]["ID"].ToString(), musicTable.Rows[i]["Price"].ToString(), musicTable.Rows[i]["Singer"].ToString(), musicTable.Rows[i]["Type"].ToString(), (byte[])musicTable.Rows[i]["Coverpage"]);
             musics.Add(music);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Ejemplo n.º 14
0
 /// <summary>
 /// This function is for adding MusicCD to the database.
 /// </summary>
 /// <param name="music">This parameter is a music that will be add to database.</param>
 public void AddMusicCD(MusicCD music)
 {
     try
     {
         connection.Connection();
         connection.Open();
         SqlCommand command = new SqlCommand("Insert into Tbl_Music(ID,Name,Price,Singer,Type,Coverpage) values(@Id,@Name,@Price,@Singer,@Type,@Coverpage)", connection.Connect);
         command.Parameters.AddWithValue("@Id", music.Id);
         command.Parameters.AddWithValue("@Name", music.Name);
         command.Parameters.AddWithValue("@Price", music.Price);
         command.Parameters.AddWithValue("@Singer", music.Singer);
         command.Parameters.AddWithValue("@Type", music.Type);
         command.Parameters.AddWithValue("@Coverpage", music.CoverPage);
         command.ExecuteNonQuery();
         connection.Close();
         MessageBox.Show("Registration successful", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Ejemplo n.º 15
0
        /*  MUSIC CD    */

        /**
         *\brief A function to get a group box for a music CD
         *\param musicCD: A music CD
         *\return A group box for a music CD
         */
        public static GroupBox GetBoxFor(MusicCD musicCD)
        {
            GroupBox MusicCDBox = GetBox();

            string MusicCDImagePath = @"..\..\..\ProductPictures\MusicCD\img_" + musicCD.Name + ".jpg";

            try
            {
                Image itemImage = Image.FromFile(MusicCDImagePath);
                ((PictureBox)MusicCDBox.Controls[0]).Image = Image.FromFile(MusicCDImagePath);
            }
            catch (Exception)
            {
                ((PictureBox)MusicCDBox.Controls[0]).Image = Image.FromFile(@"..\..\..\ProductPictures\img_Error.png");
            }


            ((Label)MusicCDBox.Controls[1]).Text = musicCD.Name;
            ((Label)MusicCDBox.Controls[2]).Text = musicCD.Price.ToString() + " ₺";

            return(MusicCDBox);
        }
Ejemplo n.º 16
0
        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                MusicCD musicCD = new MusicCD();
                openFileDialog1.Multiselect = false;
                openFileDialog1.Filter      = "All Files |*.png; *.jpeg;*.jpg| PNG Files (*.png)|*.png|JPEG Files (*.jpeg)|*.jpeg|JPG Files (*.jpg)|*.jpg";
                openFileDialog1.Title       = "Dosya seçiniz.";
                openFileDialog1.ShowDialog();
                string filepath = openFileDialog1.FileName;
                string destPath = Application.StartupPath + @"\Resources\müzik\" + musicCD.Name + ".png";

                Directory.CreateDirectory(Application.StartupPath + @"\Resources\müzik\");
                File.Copy(filepath, destPath, true);

                txt_imageName.Text = openFileDialog1.FileName.ToString();

                pictureBox1.Image = Image.FromFile(filepath);
                cs.Image          = Image.FromFile(filepath);
            }
            catch { }
        }
Ejemplo n.º 17
0
 /// <summary>
 /// This function is for updating musicCDs to the database.
 /// </summary>
 /// <param name="music">This parameter is a music that will be update to database.</param>
 public void UpdateMusicCD(MusicCD music)
 {
     try
     {
         connection.Connection();
         connection.Open();
         SqlCommand command = new SqlCommand("Update Tbl_Music set Name=@Name,Price=@Price,Singer=@Singer,Type=@Type,CoverPage=@Coverpage where ID=@ProductId", connection.Connect);
         command.Parameters.AddWithValue("@Name", music.Name);
         command.Parameters.AddWithValue("@Price", music.Price);
         command.Parameters.AddWithValue("@Singer", music.Singer);
         command.Parameters.AddWithValue("@Type", music.Type);
         command.Parameters.AddWithValue("@Coverpage", music.CoverPage);
         command.Parameters.AddWithValue("@ProductId", music.Id);
         command.ExecuteNonQuery();
         connection.Close();
         MessageBox.Show("Update successful", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Ejemplo n.º 18
0
        public Product FactoryMethod(ProductType productType)
        {
            Product product = null;

            switch (productType)
            {
            case ProductType.Book:
                product = new Book();
                break;

            case ProductType.Magazine:
                product = new Magazine();
                break;

            case ProductType.MusicCD:
                product = new MusicCD();
                break;

            default:
                break;
            }

            return(product);
        }
Ejemplo n.º 19
0
        /*  DATA ADAPTER    &&      DATA SET    */

        /**
         *\brief A function to get the SQL data adapter for the given table name
         *\param sourceTableName: Name of the source table
         *\return The SQL data adapter
         */
        public static SqlDataAdapter GetDataAdapterFor(string sourceTableName)
        {
            if (sourceTableName == "tblCustomer")
            {
                return(new SqlDataAdapter(Customer.GetSelectCommand().CommandText, DatabaseHandler.CONNECTION_STRING));
            }

            if (sourceTableName == "tblBook")
            {
                return(new SqlDataAdapter(Book.GetSelectCommand().CommandText, DatabaseHandler.CONNECTION_STRING));
            }

            if (sourceTableName == "tblMagazine")
            {
                return(new SqlDataAdapter(Magazine.GetSelectCommand().CommandText, DatabaseHandler.CONNECTION_STRING));
            }

            if (sourceTableName == "tblMusicCD")
            {
                return(new SqlDataAdapter(MusicCD.GetSelectCommand().CommandText, DatabaseHandler.CONNECTION_STRING));
            }

            return(null);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// This function assigns datas into the datagrid for list. .
        /// </summary>
        /// <param name="_musicCDs">This parameter is product list.</param>
        private void ListMusicCDs(List <Product> _musicCDs)
        {
            try
            {
                dgvMusicCDs.Rows.Clear();
                for (int i = 0; i < _musicCDs.Count; i++)
                {
                    MusicCD tmp = new MusicCD(_name, _id, _price, _singer, _type, _coverpage);
                    tmp = (MusicCD)_musicCDs[i];
                    dgvMusicCDs.Rows.Add();

                    dgvMusicCDs.Rows[i].Cells[0].Value = Util.ResizeBitmap(Util.stringToImage(tmp.CoverPage), 50, 50);
                    dgvMusicCDs.Rows[i].Cells[1].Value = tmp.Name;
                    dgvMusicCDs.Rows[i].Cells[2].Value = tmp.Price;
                    dgvMusicCDs.Rows[i].Cells[3].Value = tmp.Id;
                    dgvMusicCDs.Rows[i].Cells[4].Value = tmp.Singer;
                    dgvMusicCDs.Rows[i].Cells[5].Value = tmp.Type;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 21
0
        public MusicCDPanel(MusicCD item)
        {
            musicCD          = item;
            this.BackColor   = Color.Transparent;
            this.Size        = new Size(290, 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(panelClick);

            name           = new Label();
            name.AutoSize  = true;
            name.Text      = item.name;
            name.TextAlign = ContentAlignment.MiddleLeft;
            name.Font      = new Font("Microsoft Sans Serif", (float)9.75, FontStyle.Italic);
            this.Controls.Add(name);

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

            Type           = new Label();
            Type.AutoSize  = true;
            Type.Text      = item.Category;
            Type.Font      = new Font("Microsoft Sans Serif", (float)8.25);
            Type.ForeColor = Color.DarkGray;
            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("Microsoft Sans Serif", (float)11.25, FontStyle.Strikeout | FontStyle.Italic);
            Price1.ForeColor = Color.DarkGray;
            this.Controls.Add(Price1);

            Price2          = new Label();
            Price2.AutoSize = true;
            Price2.Text     = item.discountedPrice + " TL";
            Price2.Font     = new Font("Microsoft Sans Serif", (float)11.25, FontStyle.Bold);
            this.Controls.Add(Price2);

            playBtn                       = new PictureBox();
            playBtn.Size                  = new Size(32, 32);
            playBtn.BackgroundImage       = Properties.Resources.pnlPlay;
            playBtn.BackgroundImageLayout = ImageLayout.Zoom;
            playBtn.Cursor                = Cursors.Hand;
            playBtn.Click                += new EventHandler(playBtnClick);
            this.Controls.Add(playBtn);

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

            this.Controls[0].Location = new Point(125, 20);  // Name label
            this.Controls[0].BringToFront();
            this.Controls[1].Location = new Point(125, 50);  // Singer label
            this.Controls[1].BringToFront();
            this.Controls[2].Location = new Point(125, 80);  // Type 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[5].Location = new Point(120, 140); // Play demo button
            this.Controls[5].BringToFront();
            this.Controls.Add(picBox);
            this.Controls[6].Location = new Point(10, 15);   //Picturebox
            this.Controls.Add(magnifier);
            this.Controls[7].Location = new Point(175, 140); //Magnifier image
            this.Controls.Add(picAdd);
            this.Controls[8].Location = new Point(225, 140); //Add to cart image
        }
Ejemplo n.º 22
0
 private void btnRemoveProduct_Click(object sender, EventArgs e)
 {
     if (cbRemovedProductQuantity.Text == "")
     {
         MessageBox.Show("Please Set Quantity!");
     }
     else
     {
         string[] properties;
         int      place = 0;
         for (int i = 0; i < listProducts.Items.Count; i++)
         {
             if (listProducts.Items[i].Selected == true)
             {
                 int newQuantity = 0;
                 if (Convert.ToInt32(listProducts.Items[i].SubItems[0].Text) > 100 && Convert.ToInt32(listProducts.Items[i].SubItems[0].Text) < 200)
                 {
                     properties = new string[PropertiesCountOfItem("Book")];
                     Book myBook = new Book();
                     place      = Convert.ToInt32(listProducts.Items[i].SubItems[0].Text) - 100;
                     properties = myBook.printProperties(place);
                     myBook.setID(Convert.ToInt32(properties[0]));
                     myBook.setName(properties[1]);
                     myBook.setPrice(Convert.ToInt32(properties[2]));
                     myBook.setISBN(Convert.ToInt32(properties[3]));
                     myBook.setAuthor(properties[4]);
                     myBook.setPublisher(properties[5]);
                     ItemToPurchase item = new ItemToPurchase(myBook, Convert.ToInt32(cbRemovedProductQuantity.Text));
                     myShoppingCart.removeProduct(item);
                     if (Convert.ToInt32(cbRemovedProductQuantity.Text) >= Convert.ToInt32(listProducts.Items[i].SubItems[3].Text))
                     {
                         listProducts.Items[i].Remove();
                     }
                     else
                     {
                         newQuantity = Convert.ToInt32(listProducts.Items[i].SubItems[3].Text) - Convert.ToInt32(cbRemovedProductQuantity.Text);
                         listProducts.Items[i].SubItems[3].Text = newQuantity.ToString();
                         listProducts.Refresh();
                     }
                 }
                 else if (Convert.ToInt32(listProducts.Items[i].SubItems[0].Text) > 200 && Convert.ToInt32(listProducts.Items[i].SubItems[0].Text) < 300)
                 {
                     properties = new string[PropertiesCountOfItem("Magazine")];
                     Magazine myMagazine = new Magazine();
                     place      = Convert.ToInt32(listProducts.Items[i].SubItems[0].Text) - 200;
                     properties = myMagazine.printProperties(place);
                     myMagazine.setID(Convert.ToInt32(properties[0]));
                     myMagazine.setName(properties[1]);
                     myMagazine.setPrice(Convert.ToInt32(properties[2]));
                     myMagazine.setissue(properties[3]);
                     myMagazine.setType(properties[4]);
                     ItemToPurchase item = new ItemToPurchase(myMagazine, Convert.ToInt32(cbRemovedProductQuantity.Text));
                     myShoppingCart.removeProduct(item);
                     if (Convert.ToInt32(cbRemovedProductQuantity.Text) >= Convert.ToInt32(listProducts.Items[i].SubItems[3].Text))
                     {
                         listProducts.Items[i].Remove();
                     }
                     else
                     {
                         newQuantity = Convert.ToInt32(listProducts.Items[i].SubItems[3].Text) - Convert.ToInt32(cbRemovedProductQuantity.Text);
                         listProducts.Items[i].SubItems[3].Text = newQuantity.ToString();
                         listProducts.Refresh();
                     }
                 }
                 else
                 {
                     properties = new string[PropertiesCountOfItem("MusicCD")];
                     MusicCD myMusicCD = new MusicCD();
                     place      = Convert.ToInt32(listProducts.Items[i].SubItems[0].Text) - 300;
                     properties = myMusicCD.printProperties(place);
                     myMusicCD.setID(Convert.ToInt32(properties[0]));
                     myMusicCD.setName(properties[1]);
                     myMusicCD.setPrice(Convert.ToInt32(properties[2]));
                     myMusicCD.setsinger(properties[3]);
                     myMusicCD.setType(properties[4]);
                     ItemToPurchase item = new ItemToPurchase(myMusicCD, Convert.ToInt32(cbRemovedProductQuantity.Text));
                     myShoppingCart.removeProduct(item);
                     if (Convert.ToInt32(cbRemovedProductQuantity.Text) >= Convert.ToInt32(listProducts.Items[i].SubItems[3].Text))
                     {
                         listProducts.Items[i].Remove();
                     }
                     else
                     {
                         newQuantity = Convert.ToInt32(listProducts.Items[i].SubItems[3].Text) - Convert.ToInt32(cbRemovedProductQuantity.Text);
                         listProducts.Items[i].SubItems[3].Text = newQuantity.ToString();
                         listProducts.Refresh();
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 23
0
        void SearchBook()
        {
            BookSearch.Clear();
            flowLayoutPanel1.Controls.Clear();
            SqlCommand    komut = new SqlCommand("Select * From Tbl_Book where author like '%" + TxtAra.Text + "%' or  publisher like  '%" + TxtAra.Text + "%' or isbnNumber like '%" + TxtAra.Text + "%' or BookName like '%" + TxtAra.Text + "%'", bgl.baglanti());
            SqlDataReader dr    = komut.ExecuteReader();

            while (dr.Read())
            {
                Book book = new Book();
                book.ID          = Convert.ToUInt16(dr[0]);
                book.ISBN_Number = dr[1].ToString();
                book.Author      = dr[2].ToString();
                book.Page        = Convert.ToInt16(dr[3]);
                book.Publisher   = dr[4].ToString();
                book.Name        = dr[6].ToString();
                book.Price       = Convert.ToDouble(dr[7]);
                try
                {
                    book.Image = Image.FromFile(Application.StartupPath + @"\Resources\book\" + book.Name + ".png");
                }
                catch
                {
                    book.Image = Resources.notfound;
                }

                BookSearch.Add(book);
            }
            bgl.baglanti().Close();
            getComboBook(BookSearch);


            MagazineSearch.Clear();
            SqlCommand    komut3 = new SqlCommand("Select * From Tbl_Magazine where issue like '%" + TxtAra.Text + "%'  or type like '%" + TxtAra.Text + "%' or MagazineName like '%" + TxtAra.Text + "%'", bgl.baglanti());
            SqlDataReader dr3    = komut3.ExecuteReader();

            while (dr3.Read())
            {
                Magazine magazine = new Magazine();
                magazine.ID    = Convert.ToUInt16(dr3[0]);
                magazine.Issue = dr3[1].ToString();
                magazine.Type  = dr3[2].ToString();
                magazine.Name  = dr3[3].ToString();
                magazine.Price = Convert.ToDouble(dr3[4]);

                try
                {
                    magazine.Image = Image.FromFile(Application.StartupPath + @"\Resources\magazine\" + magazine.Name + ".png");
                }
                catch
                {
                    magazine.Image = Resources.notfound;
                }

                MagazineSearch.Add(magazine);
            }
            bgl.baglanti().Close();
            getComboMagazine(MagazineSearch);

            MusicSearch.Clear();
            SqlCommand    komut2 = new SqlCommand("Select * From Tbl_MusicCD where singer like '%" + TxtAra.Text + "%'  or type like '%" + TxtAra.Text + "%' or MusicName like '%" + TxtAra.Text + "%'", bgl.baglanti());
            SqlDataReader dr2    = komut2.ExecuteReader();

            while (dr2.Read())
            {
                MusicCD musicCD = new MusicCD();
                musicCD.ID     = Convert.ToUInt16(dr2[0]);
                musicCD.Singer = dr2[1].ToString();
                musicCD.Type   = dr2[2].ToString();
                musicCD.Name   = dr2[3].ToString();
                musicCD.Price  = Convert.ToDouble(dr2[4]);

                try
                {
                    musicCD.Image = Image.FromFile(Application.StartupPath + @"\Resources\müzik\" + musicCD.Name + ".png");
                }
                catch
                {
                    musicCD.Image = Resources.notfound;
                }

                MusicSearch.Add(musicCD);
            }
            bgl.baglanti().Close();
            getComboMusicCD(MusicSearch);
        }
Ejemplo n.º 24
0
        void getComboMusicCD(List <MusicCD> bul)
        {
            for (int j = 0; j < bul.Count; j++)
            {
                Panel Pnl = new Panel();
                Pnl.BackColor   = Color.White;
                Pnl.BorderStyle = BorderStyle.FixedSingle;
                Pnl.Name        = "Pnl" + i.ToString();
                Size sz = new Size(263, 214);
                Pnl.Size = sz;
                Label lbl1 = new Label();
                Label lbl2 = new Label();
                Label lbl3 = new Label();
                Label lbl4 = new Label();
                Label lbl5 = new Label();
                lbl1.Name = "lbl1_" + i.ToString();
                lbl2.Name = "lbl2_" + i.ToString();
                lbl3.Name = "lbl3_" + i.ToString();
                lbl4.Name = "lbl4_" + i.ToString();
                lbl5.Name = "lbl5_" + i.ToString();

                lbl1.Text   = bul[j].Name;
                lbl2.Text   = bul[j].Singer.ToString();
                lbl3.Text   = bul[j].Type;
                lbl4.Text   = "Price: " + bul[j].Price.ToString();
                musicmiktar = bul[j].Price;

                Point position = new Point(135, 33);
                lbl1.Location = position;
                Point position2 = new Point(135, 62);
                lbl2.Location = position2;
                Point position3 = new Point(135, 92);
                lbl3.Location = position3;
                Point position4 = new Point(135, 150);
                lbl4.Location = position4;

                PictureBox pcbox = new PictureBox();
                pcbox.Name = "pcbox" + i.ToString();

                Size sizePic = new Size(115, 154);
                pcbox.Size = sizePic;
                Point position6 = new Point(2, 22);
                pcbox.Location = position6;

                pcbox.SizeMode = PictureBoxSizeMode.StretchImage;
                pcbox.Image    = bul[j].Image;


                Button btn         = new Button();
                Point  positionBtn = new Point(192, 183);
                btn.Location = positionBtn;
                Size sizeBtn = new Size(58, 23);
                btn.Size = sizeBtn;
                btn.Name = "btn" + i.ToString();
                btn.Text = "Add";

                MusicCD musicCD = new MusicCD();
                musicCD.ID = bul[j].ID;

                ComboBox cmbox         = new ComboBox();
                Point    locationCmbox = new Point(143, 183);
                cmbox.Location = locationCmbox;
                Size sizeCmbox = new Size(44, 23);
                cmbox.Size = sizeCmbox;

                for (int k = 1; k < 10; k++)
                {
                    cmbox.Items.Add(k);
                }
                cmbox.SelectedIndex = 0;

                btn.Click += delegate
                {
                    for (int l = 0; l < Convert.ToInt16(cmbox.Text); l++)
                    {
                        SqlCommand komut = new SqlCommand("insert into Tbl_ShoppingCard (Customerid,ItemtoPurchase,PaymentAmount,PaymentType) values (@p1,@p2,@p3,@p4)", bgl.baglanti());
                        komut.Parameters.AddWithValue("@p2", "MusicCD");
                        komut.Parameters.AddWithValue("@p3", musicmiktar);
                        komut.Parameters.AddWithValue("@p1", cs.CustomerID);
                        komut.Parameters.AddWithValue("@p4", 1);

                        komut.ExecuteNonQuery();
                    }
                    bgl.baglanti().Close();
                    MessageBox.Show("Sepete eklendi.");
                };

                Pnl.Controls.Add(lbl1);
                Pnl.Controls.Add(lbl2);
                Pnl.Controls.Add(lbl3);
                Pnl.Controls.Add(lbl4);
                Pnl.Controls.Add(lbl5);
                Pnl.Controls.Add(pcbox);
                Pnl.Controls.Add(btn);
                Pnl.Controls.Add(cmbox);
                flowLayoutPanel1.Controls.Add(Pnl);
                i++;
            }
        }
Ejemplo n.º 25
0
        void Listele()
        {
            SqlCommand    komut = new SqlCommand("Select * From Tbl_ShoppingCard", bgl.baglanti());
            SqlDataReader dr    = komut.ExecuteReader();
            int           i     = 0;

            totalPrice = 0;
            bookList.Clear();
            magazinelist.Clear();
            musicCDlist.Clear();
            while (dr.Read())
            {
                int csID = Convert.ToInt16(dr[0]);
                if (csID == cs.CustomerID)
                {
                    string type = dr[1].ToString();
                    if (type == "Book")
                    {
                        SqlCommand    komut2 = new SqlCommand("Select * From Tbl_Book", bgl.baglanti());
                        SqlDataReader dr2    = komut2.ExecuteReader();
                        while (dr2.Read())
                        {
                            int tblShopping = Convert.ToInt16(dr[0]);
                            int tblBook     = Convert.ToInt16(dr2[0]);

                            Book book = new Book();
                            book.ID          = Convert.ToUInt16(dr2[0]);
                            book.ISBN_Number = dr2[1].ToString();
                            book.Author      = dr2[2].ToString();
                            book.Page        = Convert.ToInt16(dr2[3]);
                            book.Publisher   = dr2[4].ToString();
                            book.Name        = dr2[6].ToString();
                            //try
                            //{
                            //    book.Image = Image.FromFile(Application.StartupPath + @"\Resources\BookPictures\" + dr2["Product_Name"] + ".png");
                            //}
                            //catch
                            //{
                            //    book.Image = Resources.notfound;
                            //}
                            bookList.Add(book);
                            Panel Pnl = new Panel();
                            Pnl.BackColor   = Color.White;
                            Pnl.BorderStyle = BorderStyle.FixedSingle;
                            Pnl.Name        = "Pnl" + i.ToString();
                            Size sz = new Size(513, 115);
                            Pnl.Size = sz;
                            Label lbl1 = new Label();
                            Label lbl2 = new Label();

                            lbl1.Name = "lbl1_" + i.ToString();
                            lbl2.Name = "lbl2_" + i.ToString();

                            lbl1.Text = book.Name;

                            Point position = new Point(119, 48);
                            lbl1.Location = position;
                            Point position2 = new Point(385, 48);
                            lbl2.Location = position2;

                            PictureBox pcbox = new PictureBox();
                            pcbox.Name = "pcbox";
                            Point position3 = new Point(4, 4);
                            pcbox.Location = position3;
                            Size sizePic = new Size(84, 105);
                            pcbox.Size     = sizePic;
                            pcbox.SizeMode = PictureBoxSizeMode.StretchImage;
                            pcbox.Image    = book.Image;

                            ComboBox cmbox = new ComboBox();
                            for (int j = 1; j < 9; j++)
                            {
                                cmbox.Items.Add(j);
                            }
                            cmbox.SelectedIndex = 0;
                            Point position4 = new Point(296, 43);
                            cmbox.Location = position4;
                            Size sizeCmBox = new Size(48, 24);
                            cmbox.Size             = sizeCmBox;
                            shopping.PaymentAmount = Convert.ToInt16(cmbox.Text);
                            lbl2.Text = shopping.PaymentAmount.ToString() + " TL";

                            PictureBox pcRemove = new PictureBox();
                            pcRemove.Name = "pcRemove_" + i.ToString();
                            Point position5 = new Point(475, 77);
                            pcRemove.Location = position5;
                            Size sizePicRemove = new Size(33, 33);
                            pcRemove.Size = sizePicRemove;
                            //pcRemove.Image = Resources.remove;
                            pcRemove.SizeMode = PictureBoxSizeMode.StretchImage;
                            pcRemove.Cursor   = Cursors.Hand;
                            pcRemove.Click   += delegate
                            {
                                SqlCommand komut3 = new SqlCommand("DELETE FROM Tbl_ShoppingCard WHERE Customerid=@p1", bgl.baglanti());
                                komut3.Parameters.AddWithValue("p1", book.ID);
                                komut3.ExecuteNonQuery();
                                bgl.baglanti().Close();
                                flowLayoutPanel1.Controls.Clear();
                                Listele();
                            };

                            CheckBox chbox = new CheckBox();
                            chbox.Name = "chbox_" + i.ToString();
                            Point location6 = new Point(464, 47);
                            chbox.Location = location6;
                            chbox.UseVisualStyleBackColor = true;
                            Size sizeCheck = new Size(15, 14);
                            chbox.Size = Size;
                            chbox.Text = "Seçim";

                            Pnl.Controls.Add(lbl1);
                            Pnl.Controls.Add(lbl2);
                            Pnl.Controls.Add(pcbox);
                            //Pnl.Controls.Add(cmbox);
                            Pnl.Controls.Add(pcRemove);
                            Pnl.Controls.Add(chbox);
                            flowLayoutPanel1.Controls.Add(Pnl);
                            i++;
                        }
                        bgl.baglanti().Close();
                    }
                    else if (type == "Magazine")
                    {
                        SqlCommand    komut2 = new SqlCommand("Select * From Tbl_Magazine", bgl.baglanti());
                        SqlDataReader dr2    = komut2.ExecuteReader();
                        while (dr2.Read())
                        {
                            int tblShopping = Convert.ToInt16(dr[0]);
                            int tblMagazine = Convert.ToInt16(dr2[0]);
                            if (tblShopping == tblMagazine)
                            {
                                Magazine magazine = new Magazine();
                                magazine.ID    = Convert.ToUInt16(dr2[0]);
                                magazine.Issue = dr2[1].ToString();
                                magazine.Type  = dr2[2].ToString();
                                magazine.Name  = dr2[3].ToString();

                                //try
                                //{
                                //    magazine.Image = Image.FromFile(Application.StartupPath + @"\Resources\MagazinePictures\" + dr2["Product_Name"] + ".png");
                                //}
                                //catch
                                //{
                                //    magazine.Image = Resources.notfound;
                                //}
                                magazinelist.Add(magazine);
                                Panel Pnl = new Panel();
                                Pnl.BackColor   = Color.White;
                                Pnl.BorderStyle = BorderStyle.FixedSingle;
                                Pnl.Name        = "Pnl" + i.ToString();
                                Size sz = new Size(513, 115);
                                Pnl.Size = sz;
                                Label lbl1 = new Label();
                                Label lbl2 = new Label();

                                lbl1.Name = "lbl1_" + i.ToString();
                                lbl2.Name = "lbl2_" + i.ToString();

                                lbl1.Text = magazine.Name;
                                lbl2.Text = magazine.Price.ToString() + " TL";

                                Point position = new Point(119, 48);
                                lbl1.Location = position;
                                Point position2 = new Point(385, 48);
                                lbl2.Location = position2;

                                PictureBox pcbox = new PictureBox();
                                pcbox.Name = "pcbox";
                                Point position3 = new Point(4, 4);
                                pcbox.Location = position3;
                                Size sizePic = new Size(84, 105);
                                pcbox.Size     = sizePic;
                                pcbox.SizeMode = PictureBoxSizeMode.StretchImage;
                                pcbox.Image    = magazine.Image;

                                ComboBox cmbox = new ComboBox();
                                for (int j = 1; j < 9; j++)
                                {
                                    cmbox.Items.Add(j);
                                }
                                cmbox.SelectedIndex = 0;
                                Point position4 = new Point(296, 43);
                                cmbox.Location = position4;
                                Size sizeCmBox = new Size(48, 24);
                                cmbox.Size = sizeCmBox;

                                PictureBox pcRemove = new PictureBox();
                                pcRemove.Name = "pcRemove_" + i.ToString();
                                Point position5 = new Point(475, 77);
                                pcRemove.Location = position5;
                                Size sizePicRemove = new Size(33, 33);
                                pcRemove.Size = sizePicRemove;
                                //pcRemove.Image = Resources.remove;
                                pcRemove.SizeMode = PictureBoxSizeMode.StretchImage;
                                pcRemove.Cursor   = Cursors.Hand;
                                pcRemove.Click   += delegate
                                {
                                    SqlCommand komut3 = new SqlCommand("DELETE FROM Tbl_ShoppingCard WHERE Customerid=@p1", bgl.baglanti());
                                    komut3.Parameters.AddWithValue("p1", magazine.ID);
                                    komut3.ExecuteNonQuery();
                                    bgl.baglanti().Close();
                                    flowLayoutPanel1.Controls.Clear();
                                    Listele();
                                };

                                Pnl.Controls.Add(lbl1);
                                Pnl.Controls.Add(lbl2);
                                Pnl.Controls.Add(pcbox);
                                //Pnl.Controls.Add(cmbox);
                                Pnl.Controls.Add(pcRemove);
                                flowLayoutPanel1.Controls.Add(Pnl);
                                i++;
                            }
                        }
                        bgl.baglanti().Close();
                    }
                    else if (type == "Music")
                    {
                        SqlCommand    komut2 = new SqlCommand("Select * From Tbl_Music", bgl.baglanti());
                        SqlDataReader dr2    = komut2.ExecuteReader();
                        while (dr2.Read())
                        {
                            int tblShopping = Convert.ToInt16(dr[0]);
                            int tblMusic    = Convert.ToInt16(dr2[0]);
                            if (tblShopping == tblMusic)
                            {
                                MusicCD musicCD = new MusicCD();
                                musicCD.ID     = Convert.ToUInt16(dr2[0]);
                                musicCD.Singer = dr2[1].ToString();
                                musicCD.Type   = dr2[2].ToString();
                                musicCD.Name   = dr2[3].ToString();

                                //try
                                //{
                                //    musicCD.Image = Image.FromFile(Application.StartupPath + @"\Resources\MusicPictures\" + dr2["Product_Name"] + ".png");
                                //}
                                //catch
                                //{
                                //    musicCD.Image = Resources.notfound;
                                //}
                                musicCDlist.Add(musicCD);
                                Panel Pnl = new Panel();
                                Pnl.BackColor   = Color.White;
                                Pnl.BorderStyle = BorderStyle.FixedSingle;
                                Pnl.Name        = "Pnl" + i.ToString();
                                Size sz = new Size(513, 115);
                                Pnl.Size = sz;
                                Label lbl1 = new Label();
                                Label lbl2 = new Label();

                                lbl1.Name = "lbl1_" + i.ToString();
                                lbl2.Name = "lbl2_" + i.ToString();

                                lbl1.Text = musicCD.Name;
                                lbl2.Text = musicCD.Price.ToString() + " TL";

                                Point position = new Point(119, 48);
                                lbl1.Location = position;
                                Point position2 = new Point(385, 48);
                                lbl2.Location = position2;

                                PictureBox pcbox = new PictureBox();
                                pcbox.Name = "pcbox";
                                Point position3 = new Point(4, 4);
                                pcbox.Location = position3;
                                Size sizePic = new Size(84, 105);
                                pcbox.Size     = sizePic;
                                pcbox.SizeMode = PictureBoxSizeMode.StretchImage;
                                pcbox.Image    = musicCD.Image;

                                ComboBox cmbox = new ComboBox();
                                for (int j = 1; j < 9; j++)
                                {
                                    cmbox.Items.Add(j);
                                }
                                cmbox.SelectedIndex = 0;
                                Point position4 = new Point(296, 43);
                                cmbox.Location = position4;
                                Size sizeCmBox = new Size(48, 24);
                                cmbox.Size = sizeCmBox;

                                PictureBox pcRemove = new PictureBox();
                                pcRemove.Name = "pcRemove_" + i.ToString();
                                Point position5 = new Point(475, 77);
                                pcRemove.Location = position5;
                                Size sizePicRemove = new Size(33, 33);
                                pcRemove.Size = sizePicRemove;
                                //pcRemove.Image = Resources.remove;
                                pcRemove.SizeMode = PictureBoxSizeMode.StretchImage;
                                pcRemove.Cursor   = Cursors.Hand;
                                pcRemove.Click   += delegate
                                {
                                    SqlCommand komut3 = new SqlCommand("DELETE FROM Tbl_ShoppingCard WHERE Product_ID=@p1", bgl.baglanti());
                                    komut3.Parameters.AddWithValue("p1", musicCD.ID);
                                    komut3.ExecuteNonQuery();
                                    bgl.baglanti().Close();
                                    flowLayoutPanel1.Controls.Clear();
                                    Listele();
                                };

                                Pnl.Controls.Add(lbl1);
                                Pnl.Controls.Add(lbl2);
                                Pnl.Controls.Add(pcbox);
                                // Pnl.Controls.Add(cmbox);
                                Pnl.Controls.Add(pcRemove);
                                flowLayoutPanel1.Controls.Add(Pnl);
                                i++;
                            }
                        }
                        bgl.baglanti().Close();
                    }
                }
            }
            bgl.baglanti().Close();

            for (int k = 0; k < bookList.Count; k++)
            {
                totalPrice += bookList[k].Price;
            }
            for (int k = 0; k < magazinelist.Count; k++)
            {
                totalPrice += magazinelist[k].Price;
            }
            for (int k = 0; k < musicCDlist.Count; k++)
            {
                totalPrice += musicCDlist[k].Price;
            }
            lbl_price.Text = totalPrice.ToString();
        }