Example #1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (TextBox_title.Text.Length == 0)
            {
                lbl_info.ForeColor = Color.Red;
                lbl_info.Text      = "Please enter new title!";
                return;
            }
            else if (TextBox_content.Text.Length == 0)
            {
                lbl_info.ForeColor = Color.Red;
                lbl_info.Text      = "Please enter new content!";
                return;
            }

            tbl_New nw = new tbl_New();

            nw.Title           = TextBox_title.Text;
            nw.NewContent      = TextBox_content.Text;
            nw.Date            = DateTime.Now;
            lbl_info.ForeColor = Color.Green;
            lbl_info.Text      = "New added Successfully!";
            db.tbl_News.InsertOnSubmit(nw);
            db.SubmitChanges();
        }
Example #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Request.QueryString["nid"] != null)
         {
             tbl_New ne   = new tbl_New();
             var     item = from u in db.tbl_News
                            where u.NewID == int.Parse(Request.QueryString["nid"])
                            select u;
             foreach (var z in item)
             {
                 db.tbl_News.DeleteOnSubmit(z);
             }
             db.SubmitChanges();
         }
     }
 }
 partial void Deletetbl_New(tbl_New instance);
 partial void Updatetbl_New(tbl_New instance);
 partial void Inserttbl_New(tbl_New instance);