Exemple #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 = "";
        }
        protected void btndelete_Click(object sender, EventArgs e)
        {
            lingtophonebookDataContext db = new lingtophonebookDataContext();
            phone _phone = db.phones.SingleOrDefault(c => c.Id == id);

            db.phones.DeleteOnSubmit(_phone);
            db.SubmitChanges();
            grdContent.DataSource = db.phones.Where(c => c.userid == Login.iduser).ToList();
            grdContent.DataBind();
            txtid.Text   = null;
            txtname.Text = txtfamily.Text = txtmobile.Text = txtphonenumber.Text = "";
        }
        protected void grdContent_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            lingtophonebookDataContext db = new lingtophonebookDataContext();
            phone _phone = db.phones.SingleOrDefault(c => c.Id.ToString() == grdContent.Rows[e.RowIndex].Cells[0].Text);

            db.phones.DeleteOnSubmit(_phone);
            db.SubmitChanges();
            grdContent.DataSource = db.phones.Where(c => c.userid == Login.iduser).ToList();
            grdContent.DataBind();
            txtid.Text   = null;
            txtname.Text = txtfamily.Text = txtmobile.Text = txtphonenumber.Text = "";
        }
Exemple #4
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 = "";
        }
        protected void btnsave_Click(object sender, EventArgs e)
        {
            lingtophonebookDataContext db = new lingtophonebookDataContext();
            phone _phone = new phone();

            _phone.name        = txtname.Text;
            _phone.family      = txtfamily.Text;
            _phone.mobile      = txtmobile.Text;
            _phone.phonenumber = txtphonenumber.Text;
            _phone.userid      = Login.iduser;
            db.phones.InsertOnSubmit(_phone);
            db.SubmitChanges();
            grdContent.DataSource = db.phones.Where(c => c.userid == Login.iduser).ToList();
            grdContent.DataBind();
            txtid.Text   = null;
            txtname.Text = txtfamily.Text = txtmobile.Text = txtphonenumber.Text = "";
        }
        protected void btnsaveuser_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(txtusernamesave.Value) || string.IsNullOrWhiteSpace(txtpasswordsave.Value))
                {
                    return;
                }

                lingtophonebookDataContext db = new lingtophonebookDataContext();
                User _user = new User();
                _user.username = txtusernamesave.Value;
                _user.password = txtpasswordsave.Value;
                _user.email    = txtemail.Value;
                db.Users.InsertOnSubmit(_user);
                db.SubmitChanges();

                txtusernamesave.Value = txtpasswordsave.Value = txtemail.Value = "";
            }
            catch (Exception)
            {
                throw;
            }
        }