コード例 #1
0
 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";
         }
     }
 }
コード例 #2
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);
                    }
                }
            }
        }