Beispiel #1
0
        private void AbsenceMinus_OnClick(object sender, RoutedEventArgs e)
        {
            // Get object

            var button = sender as Button;

            var dataObject = button.DataContext as AbsenceItem;

            var index = TempAbsenceItems.IndexOf(dataObject);

            // Show warning if at 0

            if (TempAbsenceItems[index].TimesAbsent - 1 < 0)
            {
                var anim1 = AbsencesList.Blur(5);
                var anim2 = AbsencesList.Blur();

                AbsenceNotification.Closing += async(o, args) =>
                {
                    await anim2.StartAsync();

                    anim1.Stop();
                    AbsencesList.IsHitTestVisible = true;
                };

                AbsenceNotification.Opening += async(o, args) =>
                {
                    AbsencesList.IsHitTestVisible = false;
                    await anim1.StartAsync();
                };

                AbsenceNotification.Show(2000);


                return;
            }

            // Update database

            using (var connection = new SqlConnection(Helpers.FunctionsAndInterfaces.connectionString))
            {
                connection.Open();

                var query =
                    $"UPDATE UserAbsences SET TimesAbsent -= 1 WHERE UserID = {CurrentUserId} AND CourseID = {CurrentCourseId} AND AbsenceCategoryID = {dataObject.AbsenceCategoryID};";

                var command = new SqlCommand(query, connection);
                using (command.ExecuteReader())
                {
                }

                connection.Close();
            }

            // Update view

            TempAbsenceItems[index].TimesAbsent -= 1;
        }
Beispiel #2
0
 private void GetAbsencesList()
 {
     try
     {
         Logger.Info("GetAbsencesList Method");
         var absencesList = DatabaseHelper.GetList <Absences>();
         AbsencesList.Clear();
         foreach (var item in absencesList)
         {
             AbsencesList.Add(item);
         }
     }
     catch (Exception ex)
     {
         Logger.Error(ex, "Exception occured from getting absences list");
     }
 }
Beispiel #3
0
        private void AbsencePlus_OnClick(object sender, RoutedEventArgs e)
        {
            // Get object

            var button = sender as Button;

            var dataObject = button.DataContext as AbsenceItem;

            var index = TempAbsenceItems.IndexOf(dataObject);

            // Show warning if at max allowed

            if (TempAbsenceItems[index].TimesAbsent + 1 == dataObject.MaxTimesAbsent)
            {
                BeforeTooManyNotifTxt.Text = "Ne smiješ više izostati\n";

                switch (dataObject.AbsenceCategory)
                {
                case "Predavanja":
                    BeforeTooManyNotifTxt.Text += "s predavanja";
                    break;

                case "Seminari":
                    BeforeTooManyNotifTxt.Text += "sa seminara";
                    break;

                case "Laboratorijske vježbe":
                    BeforeTooManyNotifTxt.Text += "s laboratorijskih vježbi";
                    break;

                case "Dolasci na TZK":
                    BeforeTooManyNotifTxt.Text += "s TZK";
                    break;
                }

                var anim1 = AbsencesList.Blur(5, 200);
                var anim2 = AbsencesList.Blur(0, 200);

                BeforeTooManyAbsencesNotification.Closing += async(o, args) =>
                {
                    await anim2.StartAsync();

                    anim1.Stop();
                    AbsencesList.IsHitTestVisible = true;
                };

                BeforeTooManyAbsencesNotification.Opening += async(o, args) =>
                {
                    AbsencesList.IsHitTestVisible = false;
                    await anim1.StartAsync();
                };

                BeforeTooManyAbsencesNotification.Show(1500);
            }

            // Show warning if at more than allowed

            if (TempAbsenceItems[index].TimesAbsent + 1 > dataObject.MaxTimesAbsent)
            {
                TooManyNotifTxt.Text = "Imaš previše izostanaka\n";

                switch (dataObject.AbsenceCategory)
                {
                case "Predavanja":
                    TooManyNotifTxt.Text += "s predavanja";
                    break;

                case "Seminari":
                    TooManyNotifTxt.Text += "sa seminara";
                    break;

                case "Laboratorijske vježbe":
                    TooManyNotifTxt.Text += "s laboratorijskih vježbi";
                    break;

                case "Dolasci na TZK":
                    TooManyNotifTxt.Text += "s TZK";
                    break;
                }

                var anim1 = AbsencesList.Blur(5);
                var anim2 = AbsencesList.Blur();

                TooManyAbsencesNotification.Closing += async(o, args) =>
                {
                    await anim2.StartAsync();

                    anim1.Stop();
                    AbsencesList.IsHitTestVisible = true;
                };

                TooManyAbsencesNotification.Opening += async(o, args) =>
                {
                    AbsencesList.IsHitTestVisible = false;
                    await anim1.StartAsync();
                };

                TooManyAbsencesNotification.Show(2000);
            }

            // Update database

            using (var connection = new SqlConnection(Helpers.FunctionsAndInterfaces.connectionString))
            {
                connection.Open();

                var query =
                    $"UPDATE UserAbsences SET TimesAbsent += 1 WHERE UserID = {CurrentUserId} AND CourseID = {CurrentCourseId} AND AbsenceCategoryID = {dataObject.AbsenceCategoryID};";

                var command = new SqlCommand(query, connection);
                using (command.ExecuteReader())
                {
                }

                connection.Close();
            }

            // Update view

            TempAbsenceItems[index].TimesAbsent += 1;
        }