示例#1
0
 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 {
     if (value is bool b1 && bool.TryParse(CheckFor.ToString(), out var b2))
     {
         if ((b1 == b2) == IsEqual)
         {
             return(Visibility.Visible);
         }
         else
         {
             return(Visibility.Collapsed);
         }
     }
        static void CheckUnique(string column, string table, CheckFor check)
        {
            SQLResult result = DB.Characters.Query("SELECT DISTINCT {0} FROM {1}", column, table);

            if (result.IsEmpty())
            {
                Log.outInfo(LogFilter.Sql, "Table {0} is empty.", table);
                return;
            }

            bool          found = false;
            StringBuilder ss    = new();

            do
            {
                uint id = result.Read <uint>(0);
                if (!check(id))
                {
                    if (!found)
                    {
                        ss.AppendFormat("DELETE FROM {0} WHERE {1} IN(", table, column);
                        found = true;
                    }
                    else
                    {
                        ss.Append(',');
                    }

                    ss.Append(id);
                }
            }while (result.NextRow());

            if (found)
            {
                ss.Append(')');
                DB.Characters.Execute(ss.ToString());
            }
        }