protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Insert")
        {
            var footer = GridView1.FooterRow;
            using (dbcms db = new dbcms())
            {
                user u = new user();
                try
                {
                    u.id = db.user.Max(d => d.id) + 1;
                }
                catch
                {
                    u.id = 1;
                }
                u.name  = ((TextBox)footer.Cells[1].FindControl("name")).Text;
                u.jb    = 1;
                u.pwd   = ((TextBox)footer.Cells[2].FindControl("pwd")).Text;
                u.email = ((TextBox)footer.Cells[1].FindControl("email")).Text;
                u.photo = ((TextBox)footer.Cells[1].FindControl("photo")).Text;
                db.user.InsertOnSubmit(u);
                user1 u1 = new user1();
                u1.uid = u.id;
                db.user1.InsertOnSubmit(u1);

                db.SubmitChanges();
                GridView1.DataBind();
            }
        }
    }
Exemplo n.º 2
0
 protected void ping_dele_Click(object sender, EventArgs e)
 {
     for (int i = 0; i < GridView1.Rows.Count; i++)
     {
         if (((CheckBox)GridView1.Rows[i].Cells[0].FindControl("cb")).Checked)
         {
             using (dbcms db = new dbcms())
             {
                 var p_dele = db.ping.First(d => d.id == Convert.ToInt32(GridView1.DataKeys[i].Value));
                 db.ping.DeleteOnSubmit(p_dele);
                 db.SubmitChanges();
                 GridView1.DataBind();
             }
         }
     }
 }
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Insert")
        {
            using (dbcms db = new dbcms())
            {
                cls c1     = new cls();
                var footer = ((GridView)sender).FooterRow;
                c1.name        = ((TextBox)footer.Cells[1].FindControl("t1")).Text;
                c1.keywords    = ((TextBox)footer.Cells[1].FindControl("t2")).Text;
                c1.description = ((TextBox)footer.Cells[1].FindControl("t3")).Text;
                string jb = ((DropDownList)footer.Cells[1].FindControl("drop")).Text;
                try
                {
                    c1.sort = Convert.ToInt32(((TextBox)footer.Cells[1].FindControl("t5")).Text);
                }
                catch
                {
                    c1.sort = null;
                }
                clsRepository cr = new clsRepository(db);
                c1.id = cr.MaxId() + 1;

                if (jb != "0")
                {
                    c1.jb = db.cls.Where(d => d.id == Convert.ToInt32(jb)).First().jb + c1.id + "|";
                }
                else
                {
                    c1.jb = c1.id + "|";
                }
                c1.display = true;
                db.cls.InsertOnSubmit(c1);
                db.SubmitChanges();
                GridView1.DataBind();
            }
        }
    }
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Insert")
        {
            using (dbcms db = new dbcms())
            {
                link link1  = new link();
                var  footer = ((GridView)sender).FooterRow;
                try
                {
                    link1.id = db.link.Max(d => d.id) + 1;
                }
                catch
                {
                    link1.id = 1;
                }
                link1.name = ((TextBox)footer.Cells[1].FindControl("name")).Text;
                link1.url  = ((TextBox)footer.Cells[2].FindControl("url")).Text;
                link1.logo = ((TextBox)footer.Cells[3].FindControl("logo")).Text;
                link1.demo = ((TextBox)footer.Cells[4].FindControl("demo")).Text;
                try
                {
                    link1.display = Convert.ToInt32(((TextBox)footer.Cells[5].FindControl("dispaly")).Text);
                }
                catch
                {
                    link1.display = 0;
                }
                link1.state = true;
                db.link.InsertOnSubmit(link1);
                db.SubmitChanges();

                GridView1.DataBind();
            }
        }
    }
 public virtual void Add(T t)
 {
     List().InsertOnSubmit(t);
     db.SubmitChanges();
 }