コード例 #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count > 0)
            {
                if (MessageBox.Show("sure to delete row?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    int         s_id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells[0].Value);
                    InfoStudent obj  = sdc.InfoStudents.SingleOrDefault(i => i.student_id == s_id);
                    sdc.InfoStudents.DeleteOnSubmit(obj);
                    sdc.SubmitChanges();


                    dataGridView1.DataSource = sdc.InfoStudents;
                }
            }
        }
コード例 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            StudentsDBDataContext sdc        = new StudentsDBDataContext();
            InfoStudent           infstudent = new InfoStudent();

            if (textBox1.ReadOnly == true)
            {
                InfoStudent inf = sdc.InfoStudents.SingleOrDefault(i => i.student_id == int.Parse(textBox1.Text));

                inf.student_name     = textBox2.Text;
                inf.parent_name      = textBox4.Text;
                inf.phone_number     = long.Parse(textBox3.Text);
                inf.addressOfStudent = textBox6.Text;
                inf.city             = textBox5.Text;
                inf.country          = textBox8.Text;
                inf.blood_group      = textBox7.Text;

                sdc.SubmitChanges();
                MessageBox.Show("record updated in table");
            }
            else
            {
                infstudent.student_id       = int.Parse(textBox1.Text);
                infstudent.student_name     = textBox2.Text;
                infstudent.parent_name      = textBox4.Text;
                infstudent.phone_number     = long.Parse(textBox3.Text);
                infstudent.addressOfStudent = textBox6.Text;
                infstudent.city             = textBox5.Text;
                infstudent.country          = textBox8.Text;
                infstudent.blood_group      = textBox7.Text;

                sdc.InfoStudents.InsertOnSubmit(infstudent);
                sdc.SubmitChanges();

                MessageBox.Show("record inserted to table");
            }
        }
コード例 #3
0
 partial void DeleteInfoStudent(InfoStudent instance);
コード例 #4
0
 partial void UpdateInfoStudent(InfoStudent instance);
コード例 #5
0
 partial void InsertInfoStudent(InfoStudent instance);