Exemplo n.º 1
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            Student st = new Student();
            st.stuId = int.Parse(idtxt.Text);
            st.stuName = nametxt.Text;
            st.age = int.Parse(agetxt.Text);
            st.image = imagelbl.Text;
            st.deptID = (int)cmb1.SelectedValue;

            stdDataClasses1DataContext std = new stdDataClasses1DataContext();
            std.Students.InsertOnSubmit(st);
            std.SubmitChanges();
            MessageBox.Show("Added succesfully....!");
            listbox1.ItemsSource = std.Students;
            cmb1.ItemsSource = std.Departments;
        }
 partial void DeleteStudent(Student instance);
 partial void UpdateStudent(Student instance);
 partial void InsertStudent(Student instance);
		private void detach_Students(Student entity)
		{
			this.SendPropertyChanging();
			entity.Department = null;
		}
		private void attach_Students(Student entity)
		{
			this.SendPropertyChanging();
			entity.Department = this;
		}