예제 #1
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        LMSDataContext db = new LMSDataContext();

        Information info = new Information
        {
            Name       = txtName.Text,
            Address    = txtAddress.Text,
            CellNumber = txtCellNumber.Text,
            Gender     = txtGender.Text,
            Occupation = txtOccupation.Text
        };

        db.Informations.InsertOnSubmit(info);
        db.SubmitChanges();

        txtAddress.Text = txtCellNumber.Text = txtGender.Text = txtName.Text = txtOccupation.Text = "";
        Label1.Text     = "Data Successfully Inserted";
    }
예제 #2
0
    protected void Button2_Click(object sender, EventArgs e)
    {
        LMSDataContext db = new LMSDataContext();

        int bkid = Convert.ToInt32(ListBox1.SelectedValue);

        var info = db.Informations.First(b => b.id == bkid);

        info.Name       = txtName.Text;
        info.Address    = txtAddress.Text;
        info.CellNumber = txtCellNumber.Text;
        info.Gender     = txtName.Text;
        info.Occupation = txtOccupation.Text;

        db.SubmitChanges();
        update();
        Label1.Text     = "Data Successfully Updated";
        Button1.Visible = true;
        Button2.Visible = false;
    }