Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            lingtophonebookDataContext db = new lingtophonebookDataContext();

            GridView1.DataSource = db.tblphones.ToList();
            GridView1.DataBind();
        }
Example #2
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 = "";
        }
Example #5
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            lingtophonebookDataContext db = new lingtophonebookDataContext();
            var q = db.Users.SingleOrDefault(c => c.username == txtusername.Text && c.password == txtpassword.Text);

            if (q == null)
            {
                return;
            }
            iduser = q.Id;
            user   = q.username;
            Response.Redirect("phonepage.aspx");
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Login.iduser == 0)

            {
                Response.Redirect("Login.aspx");
            }

            lbluser.InnerText = Login.user;
            lingtophonebookDataContext db = new lingtophonebookDataContext();

            grdContent.DataSource = db.phones.Where(c => c.userid == Login.iduser).ToList(); grdContent.DataBind();
        }
        protected void grdContent_SelectedIndexChanged(object sender, EventArgs e)
        {
            lingtophonebookDataContext db = new lingtophonebookDataContext();
            phone _phone = db.phones.SingleOrDefault(c => c.Id.ToString() == grdContent.SelectedRow.Cells[0].Text);

            id                  = _phone.Id;
            txtname.Text        = _phone.name;
            txtfamily.Text      = _phone.family;
            txtmobile.Text      = _phone.mobile;
            txtphonenumber.Text = _phone.phonenumber;
            // grdContent.DataSource = db.phone.Where(c => c.Id.ToString() == txtid.Text).ToList();
            // grdContent.DataBind();
        }
Example #8
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();
        }
Example #9
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 = "";
        }
Example #10
0
        protected void btnsearch_Click(object sender, EventArgs e)
        {
            lingtophonebookDataContext db = new lingtophonebookDataContext();

            if (string.IsNullOrWhiteSpace(txtsearch.Text))
            {
                Page_Load(null, null);
            }
            GridView1.DataSource = db.tblphones.Where(c =>
                                                      c.name.Contains(txtsearch.Text) ||
                                                      c.family.Contains(txtsearch.Text) ||
                                                      c.mobile.Contains(txtsearch.Text) ||
                                                      c.phonenumber.Contains(txtsearch.Text)).ToList();
            GridView1.DataBind();
            txtid.Text   = null;
            txtname.Text = txtfamily.Text = txtmobile.Text = txtphonenumber.Text = "";
        }
        protected void btnsearchid_Click(object sender, EventArgs e)
        {
            lingtophonebookDataContext db = new lingtophonebookDataContext();

            if (string.IsNullOrWhiteSpace(txtid.Text))
            {
                Page_Load(null, null); return;
            }
            grdContent.DataSource = db.phones.Where(c => (
                                                        c.name.Contains(txtid.Text) ||
                                                        c.family.Contains(txtid.Text) ||
                                                        c.mobile.Contains(txtid.Text) ||
                                                        c.phonenumber.Contains(txtid.Text)) && c.userid == Login.iduser).ToList();
            grdContent.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 = "";
        }
Example #13
0
        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;
            }
        }