Example #1
0
        public Magazine GetMagazine(int id)
        {
            Magazine      magazine   = null;
            SqlConnection connection = new SqlConnection(ConnectionString);

            connection.Open();
            SqlCommand    command = new SqlCommand("select * from magazine", connection);
            SqlDataReader reader  = command.ExecuteReader();

            while (reader.Read())
            {
                if (id == Convert.ToInt32(reader["id"]))
                {
                    MagazineType type = Magazine.getmagazine(reader["type"].ToString().Trim());
                    magazine    = new Magazine(type, reader["issue"].ToString(), reader["name"].ToString(), Convert.ToInt32(reader["id"]), Convert.ToDouble(reader["price"]), reader["picture"].ToString());
                    magazine.Id = Convert.ToInt32(reader["id"]);
                    if (magazine.Id > Product.Idcount)
                    {
                        Product.Idcount = magazine.Id;
                    }
                }
            }
            connection.Close();
            return(magazine);
        }
Example #2
0
        private void btnAddMagazine_Click(object sender, EventArgs e)
        {
            MagazineType type = Magazine.getmagazine(cmbMagazineTypes.SelectedItem.ToString());

            adminUser.addNewMagazine(type, txtMagazineIssue.Text, txtMagazineName.Text, Product.Idcount, Convert.ToDouble(txtMagazinePrice.Text.Trim()), txtMagazineName.Text.Trim() + ".jpg");
            DataTable dataTable = new DataTable();

            DataTable = data.datagrid(dataTable, "magazine");
            dtgMagazine.DataSource = DataTable;
        }