public void upload()
        {
            flytbBook.Controls.Clear();
            flytbMusic.Controls.Clear();
            flytbMagazine.Controls.Clear();

            VeritabaniIslemleri database = VeritabaniIslemleri.bagOlustur("SatisVeritabani");
            int       i     = 0;
            string    query = "select * from UrunlerTablosu where productType = 1 and visibility= 1";
            DataTable table = database.veriCek(query);

            foreach (DataRow item in table.Rows)
            {
                Product     book = addNewProductFromDatabase.CreateNewItem(item);
                BookControl cont = new BookControl((Book)book, mainform.shoppingCard);
                flytbBook.Controls.Add(cont);
                i++;
                if (i == 6)
                {
                    break;
                }
            }
            pctrbxsitephoto.Image = new Bitmap("kitap" + (pictureindex % 3 + 1).ToString() + ".jpg");
            query = "select * from UrunlerTablosu where productType = 2 and visibility= 1";
            table = database.veriCek(query);
            i     = 0;
            foreach (DataRow item in table.Rows)
            {
                Product        music = addNewProductFromDatabase.CreateNewItem(item);
                MusicCdControl cont  = new MusicCdControl((MusicCD)music, mainform.shoppingCard);
                flytbMusic.Controls.Add(cont);
                i++;
                if (i == 6)
                {
                    break;
                }
            }
            query = "select * from UrunlerTablosu where productType = 3 and visibility= 1";
            table = database.veriCek(query);
            i     = 0;
            foreach (DataRow item in table.Rows)
            {
                Product         magazine = addNewProductFromDatabase.CreateNewItem(item);
                MagazineControl cont     = new MagazineControl((Magazine)magazine, mainform.shoppingCard);
                flytbMagazine.Controls.Add(cont);
                i++;
                if (i == 6)
                {
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// when filter is activated it works.
        /// </summary>
        /// <param name="type"> the product type </param>
        public void pnlShowClear(string type)
        {
            pnlShow.Controls.Clear();
            FlowLayoutPanel panel = new FlowLayoutPanel();
            //p.Controls.Add(panel);
            VeritabaniIslemleri database = VeritabaniIslemleri.bagOlustur("SatisVeritabani");

            if (type == "Book")            //it list the products which are books
            {
                string    query = "select * from UrunlerTablosu where productType = 1 AND  visibility = 1 ";
                DataTable table = database.veriCek(query);
                foreach (DataRow item in table.Rows)
                {
                    Product     book = addNewProductFromDatabase.CreateNewItem(item);                //factory pattern
                    BookControl cont = new BookControl((Book)book, shoppingCard);
                    pnlShow.Controls.Add(cont);
                }
            }
            else if (type == "Music")            //it list the products which are music
            {
                string    query = "select * from UrunlerTablosu where productType = 2 AND  visibility = 1 ";
                DataTable table = database.veriCek(query);
                foreach (DataRow item in table.Rows)
                {
                    Product        music = addNewProductFromDatabase.CreateNewItem(item);             //factory pattern
                    MusicCdControl cont  = new MusicCdControl((MusicCD)music, shoppingCard);
                    pnlShow.Controls.Add(cont);
                }
            }
            else if (type == "Magazine")            //it list the products which are books
            {
                string    query = "select * from UrunlerTablosu where productType = 3 AND  visibility = 1 ";
                DataTable table = database.veriCek(query);
                foreach (DataRow item in table.Rows)
                {
                    Product         magazine = addNewProductFromDatabase.CreateNewItem(item);            //factory pattern
                    MagazineControl cont     = new MagazineControl((Magazine)magazine, shoppingCard);
                    pnlShow.Controls.Add(cont);
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// this event for filter panel
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tvFilter_AfterSelect(object sender, TreeViewEventArgs e)
        {
            Program.NotifyObserver(this.Name, ((TreeView)sender).Name);
            int index = e.Node.Index;
            int level = e.Node.Level;

            if (level == 0)
            {
                switch (index)
                {
                case 0:
                    pnlShow.Controls.Clear();
                    this.pnlShowClear("Book");
                    break;

                case 1:
                    pnlShow.Controls.Clear();
                    this.pnlShowClear("Music");
                    break;

                case 2:
                    pnlShow.Controls.Clear();
                    this.pnlShowClear("Magazine");
                    break;

                default:
                    break;
                }
            }
            if (level == 1)
            {
                int parentindex = e.Node.Parent.Index;
                VeritabaniIslemleri database = VeritabaniIslemleri.bagOlustur("SatisVeritabani");
                string query;
                //DataTable dataTable = database.veriCek(query);

                switch (parentindex)
                {
                case 0:
                    pnlShow.Controls.Clear();
                    query = "select * from kitapBilgileriTablosu where type = " + index + " and  visibility = 1";
                    DataTable dataTable = database.veriCek(query);
                    foreach (DataRow row in dataTable.Rows)
                    {
                        Product     book = addNewProductFromDatabase.CreateNewItemfilter(row, 1);
                        BookControl cont = new BookControl((Book)book, shoppingCard);
                        pnlShow.Controls.Add(cont);
                    }
                    break;

                case 1:
                    pnlShow.Controls.Clear();
                    query = "select * from CdBilgileriTablosu where productType = " + index + " and  visibility = 1";
                    DataTable dataTabl = database.veriCek(query);
                    foreach (DataRow row in dataTabl.Rows)
                    {
                        Product        book = addNewProductFromDatabase.CreateNewItemfilter(row, 2);
                        MusicCdControl cont = new MusicCdControl((MusicCD)book, shoppingCard);
                        pnlShow.Controls.Add(cont);
                    }
                    break;

                case 2:
                    pnlShow.Controls.Clear();
                    query = "select * from MagazineBilgileriTablosu where productType = " + index + " and  visibility = 1";
                    DataTable dataTabe = database.veriCek(query);
                    foreach (DataRow row in dataTabe.Rows)
                    {
                        Product         book = addNewProductFromDatabase.CreateNewItemfilter(row, 3);
                        MagazineControl cont = new MagazineControl((Magazine)book, shoppingCard);
                        pnlShow.Controls.Add(cont);
                    }
                    break;

                default:
                    break;
                }
            }
        }