Ejemplo n.º 1
0
        protected void btndelete_Click(object sender, EventArgs e)
        {
            lingtophonebookDataContext db = new lingtophonebookDataContext();
            tblphone _phone = db.tblphones.SingleOrDefault(c => c.Id.ToString() == txtid.Text);

            db.tblphones.DeleteOnSubmit(_phone);
            db.SubmitChanges();
            GridView1.DataSource = db.tblphones.ToList();
            GridView1.DataBind();
            txtid.Text   = null;
            txtname.Text = txtfamily.Text = txtmobile.Text = txtphonenumber.Text = "";
        }
Ejemplo n.º 2
0
        protected void btnsearchid_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(txtid.Text))
            {
                return;
            }
            lingtophonebookDataContext db = new lingtophonebookDataContext();
            tblphone _phone = db.tblphones.SingleOrDefault(c => c.Id.ToString() == txtid.Text);

            txtname.Text         = _phone.name;
            txtfamily.Text       = _phone.family;
            txtmobile.Text       = _phone.mobile;
            txtphonenumber.Text  = _phone.phonenumber;
            GridView1.DataSource = db.tblphones.Where(c => c.Id.ToString() == txtid.Text).ToList();
            GridView1.DataBind();
        }
Ejemplo n.º 3
0
        protected void btnsave_Click(object sender, EventArgs e)
        {
            lingtophonebookDataContext db = new lingtophonebookDataContext();
            tblphone _phone = new tblphone();

            _phone.name        = txtname.Text;
            _phone.family      = txtfamily.Text;
            _phone.mobile      = txtmobile.Text;
            _phone.phonenumber = txtphonenumber.Text;
            db.tblphones.InsertOnSubmit(_phone);
            db.SubmitChanges();
            GridView1.DataSource = db.tblphones.ToList();
            GridView1.DataBind();
            txtid.Text   = null;
            txtname.Text = txtfamily.Text = txtmobile.Text = txtphonenumber.Text = "";
        }