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;
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 /// when this button clicked,
 /// if user == null the login page appear
 /// else the pnlUserNameClicked appear or vice versa
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void bttnUserName_Click(object sender, EventArgs e)
 {
     Program.NotifyObserver(this.Name, ((Button)sender).Name);
     if (user == null)
     {
         LoginForm    login  = new LoginForm();
         DialogResult result = login.ShowDialog();
         if (result == DialogResult.Yes)
         {
             bttnUserName.Text = user.Name;
             VeritabaniIslemleri database = VeritabaniIslemleri.bagOlustur("SatisVeritabani");
             string    query = "select * from SepetTablosu where customerId = " + user.UserID + " and siparisId = 'none'";
             DataTable table = database.veriCek(query);
             foreach (DataRow item in table.Rows)
             {
                 query = "select * from UrunlerTablosu where productId = '" + item[1].ToString() + "'";
                 DataTable tablee = database.veriCek(query);
                 shoppingCard.addProduct(new ItemToPurchase(addNewProductFromDatabase.CreateNewItem(tablee.Rows[0]), Convert.ToInt32(item[3])));
             }
             query = "delete from SepetTablosu where customerId = " + user.UserID + " and siparisId = 'none'";
             database.veriKaydet(query);
             query = "delete from ShoppingCartTable where CustomerId = " + user.UserID + " and siparisId = 'none'";
             database.veriKaydet(query);
         }
     }
     else
     {
         if (pnlUserNameClicked.Visible == false)
         {
             pnlUserNameClicked.Visible = true;
         }
         else
         {
             pnlUserNameClicked.Visible = false;
         }
     }
     this.MainForm_Activated(this, new EventArgs());
 }