Example #1
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     if (FileUpload1.HasFile)
     {
         try
         {
             string filename = System.IO.Path.GetFileName(FileUpload1.FileName);
             FileUpload1.SaveAs(Server.MapPath("~/images/blog/") + filename);
             StatusLabel.Text = "Upload status: File uploaded!";
         }
         catch (Exception ex)
         {
             StatusLabel.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message;
         }
     }
     using (DBInteractiobDataContext context = new DBInteractiobDataContext())
     {
         Post p = new Post();
         p.posttitle      = TextBox1.Text;
         p.writtencontent = TextBox2.Text;
         p.userid         = Convert.ToInt32(DropDownList1.Text);
         p.cuisineid      = Convert.ToInt32(DropDownList2.Text);
         p.headerimage    = FileUpload1.FileName;
         p.date_added     = DateTime.Now.ToLocalTime();
         context.Posts.InsertOnSubmit(p);
         context.SubmitChanges();
         Response.Write("<script>alert('inserted successfully!!');</script>");
     }
 }
Example #2
0
        public void commentinsertion()
        {
            DBInteractiobDataContext dc = new DBInteractiobDataContext();

            dc.Comments.InsertOnSubmit(c);

            dc.SubmitChanges();
        }
 protected void Submit_Click(object sender, EventArgs e)
 {
     using (DBInteractiobDataContext Ratingcontext = new DBInteractiobDataContext())
     {
         RatingValue rv = new RatingValue();
         rv.ratingvalue1 = TextBox1.Text;
         Ratingcontext.RatingValues.InsertOnSubmit(rv);
         Ratingcontext.SubmitChanges();
         Response.Write("<script>alert('inserted successfully!!');</script>");
     }
 }
Example #4
0
 protected void RatingButton_Click(object sender, EventArgs e)
 {
     using (DBInteractiobDataContext Ratingcontext1 = new DBInteractiobDataContext())
     {
         Rating r = new Rating();
         r.postsid       = Convert.ToInt32(DropDownListPost.Text);
         r.ratingvalueid = Convert.ToInt32(DropDownListRValue.Text);
         Ratingcontext1.Ratings.InsertOnSubmit(r);
         Ratingcontext1.SubmitChanges();
         Response.Write("<script>alert('inserted successfully!!');</script>");
     }
 }
 protected void SubmitButton_Click1(object sender, EventArgs e)
 {
     using (DBInteractiobDataContext context1 = new DBInteractiobDataContext())
     {
         Cuisine cu = new Cuisine();
         Response.Write("In");
         cu.cuisinename = CuisineNameTextBox.Text;
         context1.Cuisines.InsertOnSubmit(cu);
         context1.SubmitChanges();
         Response.Write("<script>alert('inserted successfully!!');</script>");
     }
 }
Example #6
0
 protected void UpdateImage(User u)
 {
     try
     {
         DBInteractiobDataContext dc = new DBInteractiobDataContext();
         string filename             = FileUpload1.FileName;
         FileUpload1.SaveAs(Server.MapPath("~/images/") + filename);
         u.img = filename;
         dc.SubmitChanges();
     }
     catch (Exception exc)
     {
         Response.Write("<script>alert('Some error occurred. Please Try later.');</script>");
     }
 }
 protected void Button1_Click(object sender, EventArgs e)
 {
     using (DBInteractiobDataContext Newslettercontext = new DBInteractiobDataContext())
     {
         Newsletter n = new Newsletter();
         n.newstitle   = TextBox1.Text;
         n.newssubject = TextBox2.Text;
         n.newscontent = TextBox3.Text;
         n.header      = TextBox4.Text;
         n.footer      = TextBox5.Text;
         Newslettercontext.Newsletters.InsertOnSubmit(n);
         Newslettercontext.SubmitChanges();
         Response.Write("<script>alert('inserted successfully!!');</script>");
     }
 }
Example #8
0
        public bool addUser()
        {
            DBInteractiobDataContext dc = new DBInteractiobDataContext();

            dc.Users.InsertOnSubmit(u);

            try
            {
                dc.SubmitChanges();
                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
Example #9
0
 protected void Button1_Click1(object sender, EventArgs e)
 {
     using (DBInteractiobDataContext Feedbackcontext = new DBInteractiobDataContext())
     {
         Feedback f = new Feedback();
         f.feedbackname    = NameTextBox.Value;
         f.feedbackemail   = EmailTextBox.Value;
         f.feedbackmessage = MessageTextArea.Value;
         f.feedbacksubject = SubjectTextBox.Value;
         Feedbackcontext.Feedbacks.InsertOnSubmit(f);
         try
         {
             Feedbackcontext.SubmitChanges();
             Response.Write("<script>alert('Thank you for your feedback. We\'ll revert to you shortly.');</script>");
             this.Page.Form.Dispose();
         }
         catch (Exception err)
         {
             Response.Write("<script>alert('An error occurred. We\'re sorry. Please try later.');</script>");
         }
     }
 }