/*! \fn void addNewMagazine(int id, string nm, double prc, string img, Magazine.Type type, string Issue,string des,int stok) * \brief A void function. * \details It is used to add magazine into magazine table in database. * \param id (int) id of magazine * \param nm (string) name of magazine * \param prc (double) price of magazine * \param img (string) Cover Page Picture's directory of magazine * \param type (Magazine.Type) type of magazine * \param Issue (string) Issue of magazine * \param des (string) Description of magazine * \param stok (int) Stock Information of magazine * \return void */ public void addNewMagazine(int id, string nm, double prc, string img, Magazine.Type type, string Issue, string des, int stok) { Magazine magazine = new Magazine(id, nm, prc, img, type, Issue, des, stok); Database database = Database.get_instance(); database.add_magazine("INSERT INTO MagazineTable(Id,Name,Price,Image,Type,Issue,Description,Stock) values(@Id,@Name,@Price,@Image,@Type,@Issue,@Description,@Stock)", magazine);//parametreler databasedeki sıraya göre alındı. }
/*! \fn void btnMagAdd_Click(object sender, EventArgs e) * \brief A click listener function. * \details It is used to add magazine into magazine table in database. * \param sender an object. * \param e an EventArgs. * \return void */ private void btnMagAdd_Click(object sender, EventArgs e) { string filename = Application.StartupPath + @"\Magazine\" + (database.MagazineList.Count + 1) + ".jpg"; using (FileStream fstream = new FileStream(filename, FileMode.Create)) { pcbImage.Image.Save(fstream, ImageFormat.Jpeg); fstream.Close(); } Magazine.Type typ = (Magazine.Type)cmbMagTyp.SelectedItem; Double price = Double.Parse(txtPrice.Text); admin.addNewMagazine((database.MagazineList.Count + 1), txtName.Text, price, null, typ, txtIssue.Text, txtDescription.Text, Convert.ToInt32(StockTxt.Text)); MessageBox.Show("Succes"); }