示例#1
0
        public MagazineControl(Magazine magazine, ShoppingCard shoppingCard)
        {
            this.magazine = magazine;
            InitializeComponent();
            this.shoppingCard = shoppingCard;

            txtbxName.Text   = magazine.Name;
            lbPrice.Text     = magazine.Price.ToString() + "₺ " + magazine.Sale.ToString() + "%";
            txtbxIssue.Text  = magazine.Issue;
            lbPrice1.Text    = magazine.Price.ToString();
            pctrxPhoto.Image = magazine.Photo1;
            lbPrice1.Text    = (magazine.Price * (100 - magazine.Sale) / 100).ToString() + "₺";
        }
示例#2
0
 /// <summary>
 /// the constructor
 /// </summary>
 /// <param name="magazine"></param>
 /// <param name="shoppingCard"></param>
 public MagazineForm(Magazine magazine, ShoppingCard shoppingCard)
 {
     InitializeComponent();
     this.magazine          = magazine;
     this.shoppingCard      = shoppingCard;
     this.Text              = magazine.Name;
     lbType.Text            = "Type : " + magazine.Mtype.ToString();
     lbMagazineName.Text    = magazine.Name;
     txtbxDescription.Text  = magazine.Description;
     pctrbxCoverPhoto.Image = this.magazine.Photo1;
     lbIssue.Text           = "Issue : " + this.magazine.Issue;
     lbPrice.Text           = magazine.Price.ToString() + "₺ " + magazine.Sale.ToString() + "%";
     lbPrice2.Text          = (magazine.Price * (100 - magazine.Sale) / 100).ToString() + "₺";
 }
示例#3
0
        /// <summary>
        /// yeni dergi ekleyen metot
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnSave_Click(object sender, EventArgs e)
        {
            Program.NotifyObserver(this.Name, ((Button)sender).Name);
            Magazine magazine = new Magazine();

            magazine.Name        = tbName.Text;
            magazine.Price       = Convert.ToInt32(tbPrice.Text);
            magazine.Photo1      = pbProductImage.Image;
            magazine.Description = tbDescription.Text;
            magazine.Sale        = Convert.ToInt32(tbSale.Text);
            magazine.Issue       = tbIssue.Text;
            magazine.Mtype       = (Magazine.MagazineType)cmbCdType.SelectedIndex;
            Admin admin = Admin.createAdmin();

            admin.addNewItem(magazine, filePath);
            this.Close();
        }
示例#4
0
        /// <summary>
        /// dergi güncelleyen metot
        /// </summary>
        /// <param name="magazine"></param>
        private void updateMagazine(Magazine magazine)
        {
            string magazineValues = magazine.Id + "#'" + magazine.Issue + "'#" + Convert.ToInt16(magazine.Mtype);

            dataBase.dataUpdate("productId,productIssue,productType", magazineValues, "MagazineBilgileriTablosu", "ProductId=" + magazine.Id);
        }
示例#5
0
        /// <summary>
        /// yeni bir dergi ekleyen metot
        /// </summary>
        /// <param name="magazine"></param>
        private void AddNewMagazine(Magazine magazine)
        {
            string magazineValues = maxId + ",'" + magazine.Issue + "'," + Convert.ToInt16(magazine.Mtype);

            dataBase.veriKaydet("productId,productIssue,productType", magazineValues, "MagazineBilgileriTablosu");
        }
        /// <summary>
        /// it create a product from database
        /// </summary>
        /// <param name="dataRow">the row from urunlertablosu </param>
        /// <returns>product</returns>
        public Product CreateNewItem(DataRow dataRow)
        {
            try
            {
                VeritabaniIslemleri database = VeritabaniIslemleri.bagOlustur("SatisVeritabani");
                Product             product  = new Book();
                if (Convert.ToInt32(dataRow[6]) == 1)
                {
                    product = new Book();
                    DataTable BookTable    = database.veriCek("SELECT * FROM kitapBilgileriTablosu WHERE productId = " + dataRow[0] + " and " + " visibility = 1 ");
                    DataRow   BookTableRow = BookTable.Rows[0];
                    //product is filled with database
                    product.Id                = Convert.ToInt32(dataRow[0]);
                    product.Name              = dataRow[1].ToString();
                    product.Price             = Convert.ToInt32(dataRow[2]);
                    product.Photo1            = new Bitmap(dataRow[3].ToString());
                    product.Description       = dataRow[4].ToString();
                    product.Sale              = Convert.ToInt32(dataRow[5]);
                    ((Book)product).Author    = BookTableRow[1].ToString();
                    ((Book)product).Isbn      = Convert.ToInt64(BookTableRow[2]);
                    ((Book)product).Publisher = BookTableRow[3].ToString();
                    ((Book)product).Page      = Convert.ToInt32(BookTableRow[4]);
                    ((Book)product).size      = BookTableRow[5].ToString();
                    ((Book)product).type      = (Book.BookType)BookTableRow[6];
                    ((Book)product).l_anguage = (Book.Language)BookTableRow[7];
                    return(product);
                }
                else if (Convert.ToInt32(dataRow[6]) == 2)
                {
                    product = new MusicCD();
                    DataTable MusicTable    = database.veriCek("SELECT * FROM CdBilgileriTablosu WHERE productId = " + dataRow[0] + " and " + " visibility = 1");
                    DataRow   MusicTableRow = MusicTable.Rows[0];
                    //product is filled with database
                    product.Id                 = Convert.ToInt32(dataRow[0]);
                    product.Name               = dataRow[1].ToString();
                    product.Price              = Convert.ToInt32(dataRow[2]);
                    product.Photo1             = new Bitmap(dataRow[3].ToString());
                    product.Description        = dataRow[4].ToString();
                    product.Sale               = Convert.ToInt32(dataRow[5]);
                    ((MusicCD)product).Mcdtype = (MusicCD.MusicCDType)MusicTableRow[1];
                    ((MusicCD)product).Singer  = MusicTableRow[2].ToString();
                    return(product);
                }
                else//(Convert.ToInt32(dataRow[6]) == 3)
                {
                    product = new Magazine();
                    DataTable magazineTable = database.veriCek("SELECT * FROM MagazineBilgileriTablosu WHERE productId = " + dataRow[0] + " and " + " visibility = 1 ");

                    DataRow magazineTableRow = magazineTable.Rows[0];
                    //product is filled with database
                    product.Id                = Convert.ToInt32(dataRow[0]);
                    product.Name              = dataRow[1].ToString();
                    product.Price             = Convert.ToInt32(dataRow[2]);
                    product.Photo1            = new Bitmap(dataRow[3].ToString());
                    product.Description       = dataRow[4].ToString();
                    product.Sale              = Convert.ToInt32(dataRow[5]);
                    product.Name              = dataRow[1].ToString();
                    ((Magazine)product).Issue = magazineTableRow[1].ToString();
                    ((Magazine)product).Mtype = (Magazine.MagazineType)magazineTableRow[2];
                    return(product);
                }
            }
            catch (Exception)
            {
                return(null);
            }
        }
 /// <summary>
 /// it create specific product from database
 /// </summary>
 /// <param name="datatableRow">the row from urunlertablosu</param>
 /// <param name="productType">product type</param>
 /// <returns>product</returns>
 public Product CreateNewItemfilter(DataRow datatableRow, int productType)        //it thakes the rows of product table
 {
     try
     {
         VeritabaniIslemleri database = VeritabaniIslemleri.bagOlustur("SatisVeritabani");
         Product             product;
         if (productType == 1)
         {
             product = new Book();
             DataTable ProductTable   = database.veriCek("SELECT * FROM UrunlerTablosu WHERE productId = " + datatableRow[0] + " and visibility = 1");
             DataRow   producttablrow = ProductTable.Rows[0];
             //product is filled with database
             product.Id                = Convert.ToInt32(producttablrow[0]);
             product.Name              = producttablrow[1].ToString();
             product.Price             = Convert.ToInt32(producttablrow[2]);
             product.Photo1            = new Bitmap(producttablrow[3].ToString());
             product.Description       = producttablrow[4].ToString();
             product.Sale              = Convert.ToInt32(producttablrow[5]);
             ((Book)product).Author    = datatableRow[1].ToString();
             ((Book)product).Isbn      = Convert.ToInt64(datatableRow[2]);
             ((Book)product).Publisher = datatableRow[3].ToString();
             ((Book)product).Page      = Convert.ToInt32(datatableRow[4]);
             ((Book)product).size      = datatableRow[5].ToString();
             ((Book)product).type      = (Book.BookType)datatableRow[6];
             ((Book)product).l_anguage = (Book.Language)datatableRow[7];
             return(product);
         }
         else if (productType == 2)
         {
             product = new MusicCD();
             DataTable MusicTable     = database.veriCek("SELECT * FROM UrunlerTablosu WHERE productId = " + datatableRow[0] + " and visibility = 1");
             DataRow   producttablrow = MusicTable.Rows[0];
             //product is filled with database
             product.Id                 = Convert.ToInt32(producttablrow[0]);
             product.Name               = producttablrow[1].ToString();
             product.Price              = Convert.ToInt32(producttablrow[2]);
             product.Photo1             = new Bitmap(producttablrow[3].ToString());
             product.Description        = producttablrow[4].ToString();
             product.Sale               = Convert.ToInt32(producttablrow[5]);
             ((MusicCD)product).Mcdtype = (MusicCD.MusicCDType)datatableRow[1];
             ((MusicCD)product).Singer  = datatableRow[2].ToString();
             return(product);
         }
         else                //(Convert.ToInt32(dataRow[6]) == 3)
         {
             product = new Magazine();
             DataTable magazineTable  = database.veriCek("SELECT * FROM UrunlerTablosu WHERE productId = " + datatableRow[0] + " and visibility = 1");
             DataRow   producttablrow = magazineTable.Rows[0];
             //product is filled with database
             product.Id          = Convert.ToInt32(producttablrow[0]);
             product.Name        = producttablrow[1].ToString();
             product.Price       = Convert.ToInt32(producttablrow[2]);
             product.Photo1      = new Bitmap(producttablrow[3].ToString());
             product.Description = producttablrow[4].ToString();
             product.Sale        = Convert.ToInt32(producttablrow[5]);
             //product.Name = producttablrow[1].ToString();
             ((Magazine)product).Issue = datatableRow[1].ToString();
             ((Magazine)product).Mtype = (Magazine.MagazineType)datatableRow[2];
             return(product);
         }
     }
     catch
     {
         return(null);
     }
 }