Пример #1
0
 /// <summary>
 /// This parameter is constructor.
 /// </summary>
 /// <param name="_magazine">This parameter is magazine.</param>
 public UC_Magazine(Magazine _magazine)
 {
     InitializeComponent();
     lblMagazineName.Text = _magazine.Name;
     lblIssue.Text        = _magazine.Issue;
     lblPrice.Text        = _magazine.Price;
     lblType.Text         = _magazine.Type;
     ID = _magazine.Id;
     picCoverPage.Image = Util.ResizeBitmap(Util.stringToImage(_magazine.CoverPage),
                                            picCoverPage.Width, picCoverPage.Height);
     picBox = _magazine.CoverPage;
 }
        /// <summary>
        /// This function delete magazine in database.
        /// </summary>
        private void btnDelete_Click(object sender, EventArgs e)
        {
            Logger.log("Click to Delete Magazine Button.");
            try
            {
                dgvMagazine.FirstDisplayedCell = null;
                dgvMagazine.ClearSelection();
                List <Product> MAList = Util.FillMagazineList();
                if (MAList.Count != 0)
                {
                    for (int i = 0; i < MAList.Count; i++)
                    {
                        selected_index = dgvMagazine.CurrentCell.RowIndex;

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

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

                        Magazine magazine = new Magazine(name, id, price, issue, type, image);
                        db.DeleteMagazine(magazine);

                        if (MAList.Count != 0)
                        {
                            MAList.Clear();
                        }
                        dgvMagazine.Rows.RemoveAt(selected_index);
                        selected_index = -1;
                    }
                }
                else
                {
                    MessageBox.Show("Magazine is Empty!");
                    btnDelete.Enabled = false;
                    btnUpdate.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                Logger.log("Exception: " + ex.Message);
            }
        }
Пример #3
0
 private void btnAddtocartmagazine_Click(object sender, EventArgs e)
 {
     if (tbMagazineName.Text != "" || tbMusicCDName.Text != "" || txtBookName.Text != "")
     {
         ItemToPurchase Item2    = new ItemToPurchase();
         Magazine       magazine = new Magazine("0", tbMagazineName.Text, Convert.ToDouble(tbMagazinePrice.Text));
         Item2.Product  = magazine;
         Item2.Quantity = int.Parse(tbquantiymagazine.Text);
         itemsOnCart.Add(Item2);
         MessageBox.Show("item is added to your shopping cart");
     }
     else
     {
         MessageBox.Show("Please Select Product To add Shoppingcart");
     }
 }
Пример #4
0
 /// <summary>
 /// This function is for deleting magazine from the database.
 /// </summary>
 /// <param name="magazine">This parameter is a magazine that will be delete from database.</param>
 public void DeleteMagazine(Magazine magazine)
 {
     try
     {
         connection.Connection();
         connection.Open();
         SqlCommand command = new SqlCommand("Delete from Tbl_Magazine where ID=@ProductId", connection.Connect);
         command.Parameters.AddWithValue("@ProductId", magazine.Id);
         command.ExecuteNonQuery();
         connection.Close();
         MessageBox.Show("Magazine deleted.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Пример #5
0
        static public Product FactoryObjeYarat(string Secim)
        {
            Product Selectedproduct = null;

            if (Secim == "Book")
            {
                Selectedproduct = new Book();
            }
            if (Secim == "Music")
            {
                Selectedproduct = new Music();
            }
            if (Secim == "Magazine")
            {
                Selectedproduct = new Magazine();
            }
            return(Selectedproduct);
        }
        public List <Product> MagazineLoader()
        {
            List <Product> magazinelist = new List <Product>();

            dh.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       = (double)reader["Price"];
                mg.Sale        = (double)reader["Sale"];

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

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

                magazinelist.Add(mg);
            }
            dh.connection.Close();
            return(magazinelist);
        }
 /// <summary>
 /// This function adds new magazine to database.
 /// </summary>
 private void btnAdd_Click(object sender, EventArgs e)
 {
     Logger.log("Click to Add Magazine Button.");
     try
     {
         bool           already_exists = false;
         List <Product> MAList         = Util.FillMagazineList();
         for (int i = 0; i < MAList.Count; i++)
         {
             Magazine tmp = new Magazine(_name, _id, _price, _issue, _type, _coverpage);
             tmp = (Magazine)MAList[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 != "" && txtIssue.Text != "" && picCoverPage.Image != null && txtType.Text != "")
             {
                 string   name     = txtName.Text;
                 string   id       = txtId.Text;
                 string   price    = txtPrice.Text;
                 string   type     = txtType.Text;
                 string   issue    = txtIssue.Text;
                 byte[]   image    = System.IO.File.ReadAllBytes(openFileDialogMagazine.FileName);
                 Magazine magazine = new Magazine(name, id, price, issue, type, image);
                 db.AddMagazine(magazine);
             }
             else
             {
                 MessageBox.Show("Please! Fill all fields!");
             }
         }
         Tb_Empty();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         Logger.log("Exception: " + ex.Message);
     }
 }
Пример #8
0
        /*  MAGAZINE    */

        /**
         *\brief A function to get a group box for a magazine
         *\param magazine: A magazine
         *\return A group box for the magazine
         */
        public static GroupBox GetBoxFor(Magazine magazine)
        {
            GroupBox MagazineBox = GetBox();

            string MagazineImagePath = @"..\..\..\ProductPictures\Magazine\img_" + magazine.Name + ".jpg";

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

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

            return(MagazineBox);
        }
Пример #9
0
        public override ArrayList GetData()
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(System.Windows.Forms.Application.StartupPath + @"\\MagazineList.xml");
            XmlNodeList nodelist = xmlDoc.SelectNodes("/ArrayOfMagazine/Magazine");

            foreach (XmlNode item in nodelist)
            {
                CreateProduct prdct       = new CreateProduct();
                Magazine      my_magazine = (Magazine)CreateProduct.FactoryObjeYarat("Magazine");
                my_magazine.Name1              = item.SelectSingleNode("MagazineName").InnerText;
                my_magazine.Category1          = item.SelectSingleNode("MagazineCategory").InnerText;
                my_magazine.ImageName1         = item.SelectSingleNode("MagazineImage").InnerText;
                my_magazine.MagazinePublisher1 = item.SelectSingleNode("MagazinePublisher").InnerText;
                my_magazine.Price1             = float.Parse(item.SelectSingleNode("MagazinePrice").InnerText);
                my_magazine.Image              = Properties.Resources.ResourceManager.GetObject(my_magazine.ImageName1) as Image;
                allmagazinerecord.Add(my_magazine);
            }
            return(allmagazinerecord);
        }
Пример #10
0
 /// <summary>
 /// This function is for pulling the magazine list from the database.
 /// </summary>
 public void MagazineList()
 {
     try
     {
         magazineTable.Clear();
         connection.Connection();
         connection.Open();
         SqlDataAdapter da = new SqlDataAdapter("Select * from Tbl_Magazine", connection.Connect);
         da.Fill(magazineTable);
         connection.Close();
         for (int i = 0; i < magazineTable.Rows.Count; i++)
         {
             magazine = new Magazine(magazineTable.Rows[i]["Name"].ToString(), magazineTable.Rows[i]["ID"].ToString(), magazineTable.Rows[i]["Price"].ToString(), magazineTable.Rows[i]["Issue"].ToString(), magazineTable.Rows[i]["Type"].ToString(), (byte[])magazineTable.Rows[i]["Coverpage"]);
             magazines.Add(magazine);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Пример #11
0
 /// <summary>
 /// This function is for updating magazines to the database.
 /// </summary>
 /// <param name="magazine">This parameter is magazine that will be add to database.</param>
 public void UpdateMagazine(Magazine magazine)
 {
     try
     {
         connection.Connection();
         connection.Open();
         SqlCommand command = new SqlCommand("Update Tbl_Magazine set Name=@Name,Price=@Price,Issue=@Issue,Type=@Type,CoverPage=@Coverpage where ID=@ProductId", connection.Connect);
         command.Parameters.AddWithValue("@Name", magazine.Name);
         command.Parameters.AddWithValue("@Price", magazine.Price);
         command.Parameters.AddWithValue("@Issue", magazine.Issue);
         command.Parameters.AddWithValue("@Type", magazine.Type);
         command.Parameters.AddWithValue("@Coverpage", magazine.CoverPage);
         command.Parameters.AddWithValue("@ProductId", magazine.Id);
         command.ExecuteNonQuery();
         connection.Close();
         MessageBox.Show("Update successful", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Пример #12
0
 /// <summary>
 /// This function is for adding magazines to the database.
 /// </summary>
 /// <param name="magazine">This parameter is magazine that will be add to database.</param>
 public void AddMagazine(Magazine magazine)
 {
     try
     {
         connection.Connection();
         connection.Open();
         SqlCommand command = new SqlCommand("Insert into Tbl_Magazine(ID,Name,Price,Issue,Type,Coverpage) values(@Id,@Name,@Price,@Issue,@Type,@Coverpage)", connection.Connect);
         command.Parameters.AddWithValue("@Id", magazine.Id);
         command.Parameters.AddWithValue("@Name", magazine.Name);
         command.Parameters.AddWithValue("@Price", magazine.Price);
         command.Parameters.AddWithValue("@Issue", magazine.Issue);
         command.Parameters.AddWithValue("@Type", magazine.Type);
         command.Parameters.AddWithValue("@Coverpage", magazine.CoverPage);
         command.ExecuteNonQuery();
         connection.Close();
         MessageBox.Show("Registration successful", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Пример #13
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                Magazine magazine = new Magazine();
                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\magazine\" + magazine.Name + ".png";

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

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

                pictureBox1.Image = Image.FromFile(filepath);
                cs.Image          = Image.FromFile(filepath);
            }
            catch { }
        }
Пример #14
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);
        }
Пример #15
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);
        }
Пример #16
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();
        }
Пример #17
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();
                     }
                 }
             }
         }
     }
 }
Пример #18
0
        public MagazinePanel(Magazine item)
        {
            magazine         = item;
            this.BackColor   = Color.Transparent;
            this.Size        = new Size(290, 190);
            this.BorderStyle = BorderStyle.FixedSingle;


            picBox                       = new PictureBox();
            picBox.Size                  = new System.Drawing.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);

            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);

            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);

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

            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);

            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);   //Picturebox
            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
        }
Пример #19
0
        void getComboMagazine(List <Magazine> al)
        {
            for (int j = 0; j < al.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();
                Label lbl6 = 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();
                lbl6.Name = "lbl6_" + i.ToString();

                lbl1.Text      = al[j].Name.ToString();
                lbl2.Text      = al[j].Issue.ToString();
                lbl3.Text      = al[j].Type.ToString();
                lbl4.Text      = "Price: " + al[j].Price.ToString();
                magazinemiktar = al[j].Price;

                Point position = new Point(136, 33);
                lbl1.Location = position;
                Point position2 = new Point(136, 62);
                lbl2.Location = position2;
                Point position3 = new Point(136, 92);
                lbl3.Location = position3;
                Point position4 = new Point(136, 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    = al[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";

                Magazine magazine = new Magazine();
                magazine.ID = al[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", "Magazine");
                        komut.Parameters.AddWithValue("@p3", magazinemiktar);
                        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++;
            }
        }
Пример #20
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);
        }