protected void food_drifters_menu(FoodDriftersdb db)
        {
            food_menu.InnerHtml = "";
            string searchkey = "";

            string query = "select * from foodblogpages";

            if (searchkey != "")
            {
                query += " WHERE foodblogtitle like '%" + searchkey + "%' ";
                query += " or chefname like '%" + searchkey + "%' ";
                query += " or foodblogbody like '%" + searchkey + "%' ";
            }


            List <Dictionary <String, String> > rs = db.List_Query(query);

            foreach (Dictionary <String, String> row in rs)
            {
                food_menu.InnerHtml += "<div class=\"listitem\">";

                string foodblogid = row["foodblogid"];

                string foodblogtitle = row["foodblogtitle"];
                food_menu.InnerHtml += "<a href=\"ShowFoodBolg.aspx? foodblogid = " + foodblogid + "\">" + foodblogtitle + "</a>";
            }
        }
Exemplo n.º 2
0
        protected void ShowFoodBlogInfo(FoodDriftersdb db)
        {
            bool   valid      = true;
            string foodblogid = Request.QueryString["foodblogid"];

            if (String.IsNullOrEmpty(foodblogid))
            {
                valid = false;
            }


            if (valid)
            {
                Debug.WriteLine("show the data");
                FoodBlog foodblog_record = db.FindFoodBlog(Int32.Parse(foodblogid));

                foodblogtitle.Text = foodblog_record.GetFoodBlogTitle();
                chefname.Text      = foodblog_record.GetChefName();
                foodblogbody.Text  = foodblog_record.GetFoodBlogBody();
            }

            if (!valid)
            {
                ErrorBox.InnerHtml = "There was an error finding that foodblog.";
            }
        }
Exemplo n.º 3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         FoodDriftersdb db = new FoodDriftersdb();
         ShowFoodBlogInfo(db);
     }
 }
        //delete the record
        protected void Delete_FoodBlog(object sender, EventArgs e)
        {
            bool   valid      = true;
            string foodblogid = Request.QueryString["foodblogid"];

            if (String.IsNullOrEmpty(foodblogid))
            {
                valid = false;
            }

            FoodDriftersdb db = new FoodDriftersdb();

            //deleting the foodblog from the system
            if (valid)
            {
                db.DeleteFoodBlog(Int32.Parse(foodblogid));
                Response.Redirect("FoodBlogList.aspx");
            }
        }
        protected void Add_Recipe(object sender, EventArgs e)
        {
            FoodDriftersdb db = new FoodDriftersdb();

            //create a new particular FoodBlog
            FoodBlog new_recipe = new FoodBlog();

            //set that FoodBlog data
            new_recipe.SetFoodBlogTitle(foodblogtitle.Text);
            new_recipe.SetChefName(chefname.Text);
            new_recipe.SetFoodBlogBody(foodblogbody.Text);


            //add the food blog to the database
            db.AddFoodBlog(new_recipe);


            Response.Redirect("FoodBlogList.aspx");
        }
Exemplo n.º 6
0
        protected void Update_FoodBlog(object sender, EventArgs e)
        {
            Debug.WriteLine("Please allow me to update");

            FoodDriftersdb db = new FoodDriftersdb();

            bool   valid      = true;
            string foodblogid = Request.QueryString["foodblogid"];

            if (String.IsNullOrEmpty(foodblogid))
            {
                valid = false;
            }
            if (valid)
            {
                FoodBlog new_foodblog = new FoodBlog();
                //set that food blog data
                new_foodblog.SetFoodBlogTitle(foodblogtitle.Text);
                new_foodblog.SetChefName(chefname.Text);
                new_foodblog.SetFoodBlogBody(foodblogbody.Text);

                //add the food blog to the database
                try
                {
                    db.UpdateFoodBlog(Int32.Parse(foodblogid), new_foodblog);
                    Response.Redirect("ShowFoodBolg.aspx?foodblogid=" + foodblogid);
                }
                catch
                {
                    valid = false;
                }
            }

            if (!valid)
            {
                foodblog.InnerHtml = "There was an error updating that student.";
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            foodblogs_result.InnerHtml = "";
            string searchkey = "";

            if (Page.IsPostBack)
            {
                searchkey = blog_search.Text;
            }
            string query = "select * from foodblogpages";

            if (searchkey != "")
            {
                query += " WHERE foodblogtitle like '%" + searchkey + "%' ";
                query += " or chefname like '%" + searchkey + "%' ";
                query += " or foodblogbody like '%" + searchkey + "%' ";
            }

            var db = new FoodDriftersdb();
            List <Dictionary <String, String> > rs = db.List_Query(query);

            foreach (Dictionary <String, String> row in rs)
            {
                foodblogs_result.InnerHtml += "<div class=\"listitem\">";

                string foodblogid = row["foodblogid"];

                string foodblogtitle = row["foodblogtitle"];
                foodblogs_result.InnerHtml += "<div class=\"col2\"><a href=\"ShowFoodBolg.aspx?foodblogid=" + foodblogid + "\">" + foodblogtitle + "</a></div>";

                string chefname = row["chefname"];
                foodblogs_result.InnerHtml += "<div class=\"col2\">" + chefname + "</div>";

                string foodblogbody = row["foodblogbody"];
                foodblogs_result.InnerHtml += "<div class=\"col2last\">" + foodblogbody + "</div>";
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            FoodDriftersdb db = new FoodDriftersdb();

            food_drifters_menu(db);
        }