private void insert_Click(object sender, EventArgs e) { int?SL = null; universityData.Teacher_Insert(textBox2.Text, textBox3.Text, ref SL); textBox1.Text = SL.ToString(); universityData.SubmitChanges(); ///aita te akta jhamela ache ata insert korar por just akta value update hoy ak tar ashi hoy na //Table<Teacher> teachers = universityData.Teachers; //dataGridView1.DataSource = teachers; ShowtheTables(); }
private void button1_Click(object sender, EventArgs e) { UniversityDataDataContext universityData = new UniversityDataDataContext();//conn established if (textBox1.ReadOnly == false) { Student student = new Student(); student.Id = Convert.ToInt32(textBox1.Text); // or, student.Id = int.Parse(textBox1.Text); student.S_Name = textBox2.Text; student.Reg = textBox3.Text; universityData.Students.InsertOnSubmit(student); //inserting on student table as a row universityData.SubmitChanges(); //comminting the changes MessageBox.Show("Record inserted into the Student Table"); } else { Student student = universityData.Students.SingleOrDefault(E => E.Id == int.Parse(textBox1.Text)); student.Id = int.Parse(textBox1.Text); student.S_Name = textBox2.Text; student.Reg = textBox3.Text; universityData.SubmitChanges();//comminting the changes MessageBox.Show("Record updated into the Student Table"); } }
private void button3_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count > 0) { if (MessageBox.Show("Are you sure of deleting the selected row?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { int rowsel = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells[0].Value); Student student = universityData.Students.SingleOrDefault(E => E.Id == rowsel); universityData.Students.DeleteOnSubmit(student); universityData.SubmitChanges();//comminting the changes LoadTable(); } } else { MessageBox.Show("Please Select the entire Row "); } }