private void buttonAcceptAddException_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     if (idAddExceptionApplication > 0 || idAddExceptionApplication == -1)
     {
         if (!string.IsNullOrEmpty(nameApplicationToException.Text) && !nameApplicationToException.Text.Equals(defaultContentnameApplicationToException))
         {
             if (idAddExceptionApplication > 0)
             {
                 if (!ExceptionApplication_db.CheckIfExistApplication(idAddExceptionApplication))
                 {
                     ExceptionApplication_db.AddExceptionApplication(idAddExceptionApplication);
                 }
             }
             else
             {
                 foreach (string application in idAddExceptionApplicationList)
                 {
                     if (!ExceptionApplication_db.CheckIfExistApplication(Convert.ToInt32(application)))
                     {
                         ExceptionApplication_db.AddExceptionApplication(Convert.ToInt32(application));
                     }
                 }
             }
             SetDefaultDesignForException();
             LoadExceptionApplication();
         }
     }
     else
     {
         if (FindApplication())
         {
             buttonAcceptAddException.Content = "Dodaj";
         }
     }
 }
        private void deleteExceptionButton_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if ((sender as Label).Name.Contains("M"))
            {
                idAddExceptionApplication     = Convert.ToInt32((sender as Label).Name.Replace("ID_", string.Empty).Replace("M", string.Empty));
                idAddExceptionApplicationList = ActiveApplication_db.GetNameApplicationDictionaryWithGroup(idAddExceptionApplication).Select(x => x.Key).ToList();

                foreach (string element in idAddExceptionApplicationList)
                {
                    ExceptionApplication_db.DeleteExceptionApplication(element);
                }
            }
            else
            {
                idAddExceptionApplication = Convert.ToInt32((sender as Label).Name.Replace("ID_", string.Empty));
                ExceptionApplication_db.DeleteExceptionApplication(idAddExceptionApplication.ToString());
            }

            idAddExceptionApplication = 0;
            idAddExceptionApplicationList.Clear();
            LoadExceptionApplication();
        }
Beispiel #3
0
        private void AddNameTitleToTableDailyUse()
        {
            string contentCommand = string.Empty;

            if (!ActiveApplication_db.CheckIfExistTitle(nameTitle))
            {
                contentCommand = "INSERT INTO activeapplications (Title, IdNameActivity) VALUES ( "
                                 + nameTitle + " , " + 1 + " )";
                DataBase.ExecuteNonQuery(contentCommand);
            }

            contentCommand = "INSERT INTO dailyuseofapplication (IdTitle, ActivityTime) " +
                             "SELECT activeapplications.ID, 1 " +
                             "FROM activeapplications WHERE activeapplications.Title = " + nameTitle;
            DataBase.ExecuteNonQuery(contentCommand);

            Dictionary <string, string> filters = Membership_db.GetFilterDictionaryIfIsFullConfiguration();

            if (filters.Any())
            {
                Regex regex;
                int   idNameTitle = 0;
                foreach (KeyValuePair <string, string> filter in filters)
                {
                    regex = new Regex(filter.Value, RegexOptions.IgnoreCase);
                    if (regex.Matches(nameTitle).Count > 0)
                    {
                        idNameTitle = (Convert.ToInt32(ActiveApplication_db.GetIdActivityByName(nameTitle)));
                        ActiveApplication_db.AddGroupToApplications(new List <int> {
                            idNameTitle
                        }, (filter.Key).ToString());
                        ActiveApplication_db.AddActivityToApplicationWithGroup((filter.Key).ToString(), idNameTitle.ToString());
                        ExceptionApplication_db.AddExceptionApplication(idNameTitle);
                    }
                }
            }
        }
        private void LoadExceptionApplication()
        {
            exceptionApplicationCanvas.Children.Clear();
            exceptionApplicationCanvas.Height = 220;
            int nextIndex = 0;

            Dictionary <string, string> nameApplicationDictionary = ExceptionApplication_db.GetNameApplicationDictionary();
            Dictionary <string, string> temp = ExceptionApplication_db.GetNameApplicationWitGroupDictionary();

            foreach (var element in temp)
            {
                nameApplicationDictionary.Add(element.Key + "M", element.Value);
            }

            foreach (KeyValuePair <string, string> name in nameApplicationDictionary)
            {
                Label application = ButtonCreator.CreateButton(exceptionApplicationCanvas, (nextIndex + 1) + ".    " + (name.Value + " ").Remove((name.Value.Length > 25) ? 25 : name.Value.Length), 250, 29, 12, 20, 0 + (nextIndex * 32),
                                                               Color.FromArgb(255, 255, 255, 255), Color.FromArgb(255, 155, 155, 155), horizontalAlignment: HorizontalAlignment.Left);
                application.Background  = new SolidColorBrush(Color.FromArgb((byte)(50 + (nextIndex % 2 * 30)), 0, 125, 255));
                application.MouseEnter += buttonContent_MouseEnter;
                application.MouseLeave += buttonContent_MouseLeave;

                Label deleteButton = ButtonCreator.CreateButton(exceptionApplicationCanvas, "X", 22, 22, 8, 244, 3 + (nextIndex * 32),
                                                                Color.FromArgb(255, 255, 255, 255), Color.FromArgb(255, 155, 155, 155), 1);
                deleteButton.Background           = new SolidColorBrush(Color.FromArgb(100, 250, 0, 0));
                deleteButton.Name                 = "ID_" + name.Key;
                deleteButton.MouseEnter          += deleteButton_MouseEnter;
                deleteButton.MouseLeave          += deleteButton_MouseLeave;
                deleteButton.MouseLeftButtonDown += deleteExceptionButton_MouseLeftButtonDown;

                exceptionApplicationCanvas.Height += 32;
                nextIndex++;
            }
            exceptionApplicationCanvas.Height = ((exceptionApplicationCanvas.Height - 220) < 220) ? 220 : exceptionApplicationCanvas.Height - 219;
            idAddExceptionApplication         = 0;
        }