private void bntLogin_Click(object sender, RoutedEventArgs e) { //Check if the user logi controlling con = new controlling(); int ID = 0; bool openForm = false; if (rbnNewUser.IsChecked.Value) { //Create User ID = (con.Create_User(txtUsername.Text, txtPassword.Password)).UserID; openForm = true; } else { var user = con.Check_Credential(txtUsername.Text, txtPassword.Password); if (user != null) { ID = user.UserID; openForm = true; } else { MessageBox.Show("Username or Password not correct", "Login", MessageBoxButton.OK, MessageBoxImage.Warning); } } if (openForm) { //Show the diary selector con.Show_Diary(ID); this.Close(); } }
private void btnCreateDiary_Click(object sender, RoutedEventArgs e) { try { //create a instance of controlling controlling con = new controlling(); //Create a new diary if (string.IsNullOrEmpty(txtDiaryName.Text)) { throw new Exception("Name missing"); } else if (con.Diary_Exist(txtDiaryName.Text)) { throw new Exception($"Diary with the name {txtDiaryName.Text} already exists"); } else { int id = con.Create_Diary(txtDiaryName.Text, currentUserID); if (id == -1) { throw new Exception("Could not create the diary"); } con.Show_SearchWindow(id); this.Close(); } } catch (Exception error) { MessageBox.Show(error.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Warning); } }
public MainWindow() { InitializeComponent(); //Create first user, only when no other user exists in DB e_Tagebuch_Context DB = new e_Tagebuch_Context(); if (!DB.Users.Any()) { controlling con = new controlling(); con.Create_User("User", "Password"); } //Create all possible types string[] Types = new string[] { "Work", "Family", "Holidays", "Birthday", "School" }; foreach (string typeName in Types) { if (!DB.Types.Any(t => t.Name == typeName)) { DB.Types.Add(new Type() { Name = typeName }); } } DB.SaveChanges(); }
private void bntChange_Click(object sender, RoutedEventArgs e) { //closes the programm controlling con = new controlling(); con.Show_Diary(DiaryID); this.Close(); }
private void bntRemove_Click(object sender, RoutedEventArgs e) { if (dgView.SelectedItem != null) { controlling con = new controlling(); con.Remove_Entry(DiaryViewList[dgView.SelectedIndex]); Update_EntryView(); } }
private void BntClose_Click(object sender, RoutedEventArgs e) { //Gets the user back to the search window without saving the current editing diary controlling con = new controlling(); var diary = con.Get_DiaryFromEntry(EntryID); frmSearchWindow searchWindow = new frmSearchWindow(diary.DiaryID); searchWindow.Show(); this.Close(); }
private void Update_EntryView() { //Update list with all entries controlling control = new controlling(); var allEntries = control.Get_AllEntries(DiaryID); if (allEntries != null) { dgView.ItemsSource = allEntries.Select(d => new { Name = d.Name, Date = d.Date, EntryID = d.EntryID }); DiaryViewList = allEntries.Select(e => e.EntryID).ToList(); } }
public frmDiaryElector(int t_currentUserID) { currentUserID = t_currentUserID; InitializeComponent(); //Set combobox with diaries controlling con = new controlling(); foreach (var diary in con.Get_AllDiaries(currentUserID)) { cmbDiaries.Items.Add(diary); } }
private void BntSave_Click(object sender, RoutedEventArgs e) { //Saves current data controlling con = new controlling(); if (txtName.Text == null || dpDatepicker.SelectedDate == null || txtMain.Text == null || lblPicPath.Content == null) { MessageBox.Show("None of the values can be empty", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); } else { con.Save_Entry(EntryID, txtName.Text, dpDatepicker.SelectedDate.Value, txtMain.Text, lblPicPath.Content.ToString()); } }
private void BntOk_Click(object sender, RoutedEventArgs e) { //Save the types controlling con = new controlling(); System.Collections.ArrayList selected = new System.Collections.ArrayList(); foreach (CheckBox CheckBoxDomaene in GridCheckBox.Children) { if (CheckBoxDomaene.IsChecked == true) { selected.Add(CheckBoxDomaene.Content.ToString()); } } con.Save_types(entryID, (string[])selected.ToArray(typeof(string))); this.Close(); }
private void bntNew_Click(object sender, RoutedEventArgs e) { //Create a new Entry controlling con = new controlling(); //first check if there are more than 100 entires existing if (con.Check_MoreThan(DiaryID)) { int entryID = con.Create_Entry("New Entry", DiaryID); frmEditor editor = new frmEditor(entryID); editor.Show(); this.Close(); } else { MessageBox.Show("Can not create more than 100 entries"); } }
private void Button_Click(object sender, RoutedEventArgs e) { //create a instance of controlling controlling con = new controlling(); //Get id of the diary if (cmbDiaries.SelectedItem != null) { e_Tagebuch_Context DB = new e_Tagebuch_Context(); var diary = DB.Diaries.FirstOrDefault(d => d.Name == cmbDiaries.SelectedItem.ToString()); con.Show_SearchWindow(diary.DiaryID); this.Close (); } else { MessageBox.Show("No diary is selected", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); } }
private void bntShow_Click(object sender, RoutedEventArgs e) { //searches for all entries which match the given criterias //and adds them to the view controlling con = new controlling(); if (!string.IsNullOrEmpty(txtSuche.Text)) { dgView.ItemsSource = con.Search_Entries("Name", txtSuche.Text).Select(d => new { Name = d.Name, Date = d.Date, EntryID = d.EntryID }); } else if (chkDate.IsChecked == true && dpSearchDate.SelectedDate != null) { dgView.ItemsSource = con.Search_Entries("Date", dpSearchDate.SelectedDate.ToString()).Select(d => new { Name = d.Name, Date = d.Date, EntryID = d.EntryID }); } else if (chkType.IsChecked == true && cmbType.SelectedItem != null) { dgView.ItemsSource = con.Search_Entries("Type", cmbType.SelectedItem.ToString()).Select(d => new { Name = d.Name, Date = d.Date, EntryID = d.EntryID }); } else if (chkdateSince.IsChecked == true && dpFrom.SelectedDate.HasValue == true && dpTo.SelectedDate.HasValue == true) { dgView.ItemsSource = con.Get_EmptyDays(dpFrom.SelectedDate.Value, dpTo.SelectedDate.Value); } }
public frmTypeSelector(int t_EntryID) { entryID = t_EntryID; InitializeComponent(); //get current typ and set gui elements controlling con = new controlling(); var types = con.Get_types(entryID); if (types != null) { foreach (string name in types) { foreach (CheckBox CheckBoxDomaene in GridCheckBox.Children) { if ((types.Any(n => n == CheckBoxDomaene.Content.ToString()))) { CheckBoxDomaene.IsChecked = true; } } } } }