private void AddNewStudentToDB(object obj) { var childWindow = new EditStudentWindow() { DataContext = this, Title="Add new Student"}; CloseCommand = new Action(() => childWindow.Close()); StudentName = null; StudentLastName = null; StudentEmail = null; StudentBirthdate = new DateTime(2000, 01, 01); StudentPhoto = null; //StudentPhoto = new BitmapImage(new Uri("bin/Debug/no_img.jpg", UriKind.Relative)); ButtonName = "Add"; SaveButton = new Command<object>(AddStudent, (s)=>!string.IsNullOrWhiteSpace(StudentName) && !string.IsNullOrWhiteSpace(StudentLastName) && StudentBirthdate!=null); childWindow.ShowDialog(); }
private void EditStudentFromDB(University_Student obj) { var childWindow = new EditStudentWindow() { DataContext = this, Title="Edit Student" }; CloseCommand = new Action(() => childWindow.Close()); StudentName = obj.First_Name; StudentLastName = obj.Last_Name; StudentEmail = obj.Email; StudentBirthdate = obj.Birthday; if (obj.Photo == null) StudentPhoto = null; else StudentPhoto = ByteToImage(obj.Photo); ButtonName = "Edit"; SaveButton = new Command<object>(UpdateStudent, (s)=>!string.IsNullOrWhiteSpace(StudentName) && !string.IsNullOrWhiteSpace(StudentLastName)&& StudentBirthdate!=null); childWindow.ShowDialog(); }