예제 #1
0
        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();
            }
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
        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();
        }
예제 #4
0
        private void bntChange_Click(object sender, RoutedEventArgs e)
        {
            //closes the programm
            controlling con = new controlling();

            con.Show_Diary(DiaryID);
            this.Close();
        }
예제 #5
0
 private void bntRemove_Click(object sender, RoutedEventArgs e)
 {
     if (dgView.SelectedItem != null)
     {
         controlling con = new controlling();
         con.Remove_Entry(DiaryViewList[dgView.SelectedIndex]);
         Update_EntryView();
     }
 }
예제 #6
0
        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();
        }
예제 #7
0
        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();
            }
        }
예제 #8
0
        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);
            }
        }
예제 #9
0
        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());
            }
        }
예제 #10
0
        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();
        }
예제 #11
0
        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");
            }
        }
예제 #12
0
        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);
            }
        }
예제 #13
0
        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);
            }
        }
예제 #14
0
        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;
                        }
                    }
                }
            }
        }