private void ChangeDirectory(DirectoryNumber dir)
 {
     switch (dir)
     {
         case DirectoryNumber.MyImportant:
             lastData = new SQLiteWorker.QueryData
                            {
                                Where = "Performer=@GUID",
                                Join = "ImportantTasks it on it.TaskGUID=GUID",
                                Parameters =
                                    new List<SQLiteParameter>
                                        {new SQLiteParameter("GUID", Settings.CurrentUser.GUID)}
                            };
             getTasks(lastData, "Мои важные задания");
             break;
         case DirectoryNumber.MyToPerform:
             lastData = new SQLiteWorker.QueryData
                            {
                                Where = "Performer=@GUID",
                                Join = "ToPerformTasks pt on pt.TaskGUID=GUID",
                                Parameters =
                                    new List<SQLiteParameter> { new SQLiteParameter("GUID", Settings.CurrentUser.GUID) }
                            };
             getTasks(lastData, "Мои задания к выполнению");
             break;
         case DirectoryNumber.MyNotCompled:
             lastData = new SQLiteWorker.QueryData
                            {
                                Where = "Performer=@GUID and Percents<>@Percents",
                                Join = "",
                                Parameters = new List<SQLiteParameter>
                                                 {
                                                     new SQLiteParameter("GUID", Settings.CurrentUser.GUID),
                                                     new SQLiteParameter("Percents", 100)
                                                 }
                            };
             getTasks(lastData, "Мои незавершенные задания");
             break;
         case DirectoryNumber.MyAll:
             lastData = new SQLiteWorker.QueryData
                            {
                                Where = "Performer=@GUID",
                                Parameters =
                                    new List<SQLiteParameter>
                                        {new SQLiteParameter("GUID", Settings.CurrentUser.GUID)}
                            };
             getTasks(lastData, "Все мои задания");
             break;
         case DirectoryNumber.PutImportant:
             lastData = new SQLiteWorker.QueryData
                            {
                                Where = "Customer=@GUID",
                                Join = "ImportantTasks it on it.TaskGUID=GUID",
                                Parameters =
                                    new List<SQLiteParameter>
                                        {new SQLiteParameter("GUID", Settings.CurrentUser.GUID)}
                            };
             getTasks(lastData, "Поставленные важные задания");
             break;
         case DirectoryNumber.PutNotCompled:
             lastData = new SQLiteWorker.QueryData
                            {
                                Where = "Customer=@GUID and Percents<>@Percents",
                                Join = "",
                                Parameters = new List<SQLiteParameter>
                                                 {
                                                     new SQLiteParameter("GUID", Settings.CurrentUser.GUID),
                                                     new SQLiteParameter("Percents", 100)
                                                 }
                            };
             getTasks(lastData, "Поставленные незавершенные задания");
             break;
         case DirectoryNumber.PutAll:
             lastData = new SQLiteWorker.QueryData
                            {
                                Where = "Customer=@GUID",
                                Join = "",
                                Parameters =
                                    new List<SQLiteParameter>
                                        {new SQLiteParameter("GUID", Settings.CurrentUser.GUID)}
                            };
             getTasks(lastData, "Все поставленные задания");
             break;
         case DirectoryNumber.All:
             lastData = new SQLiteWorker.QueryData();
             getTasks(lastData, "Все поставленные задания", true);
             break;
     }
 }
        private void BuildFilterQuery()
        {
            StringBuilder where = new StringBuilder();
            SQLiteWorker.QueryData qd = new SQLiteWorker.QueryData
            {
                Where = lastData.Where,
                Join = lastData.Join,
                Parameters = lastData.Parameters ?? new List<SQLiteParameter>()
            };

            if (!string.IsNullOrWhiteSpace(TopicFilter.Text))
            {
                where.AppendFormat(" and Topic like @Topic\r\n");
                qd.Parameters.Add(new SQLiteParameter("Topic", "%" + TopicFilter.Text + "%"));
            }

            if (DateEndFilter.SelectedDate != null)
            {
                where.AppendFormat("\tand EndDate=@EndDate\r\n");
                qd.Parameters.Add(new SQLiteParameter(
                    "EndDate",
                    SQLiteWorker.DateTimeToSQLiteFormat(DateEndFilter.SelectedDate.Value, false)));
            }

            if (!string.IsNullOrWhiteSpace(CustomerFilter.Text))
            {
                qd.Join = "Users c on c.GUID=Customer and (c.Name like @Customer or c.Name=@Customer)";
                qd.Parameters.Add(new SQLiteParameter("Customer", "%" + CustomerFilter.Text + "%"));
            }

            if (!string.IsNullOrWhiteSpace(PerformerFilter.Text))
            {
                qd.Join += string.Concat(
                    string.IsNullOrWhiteSpace(qd.Join)
                        ? ""
                        : "join ",
                    "Users p on p.GUID=Performer and (p.Name like @Performer or p.Name=@Performer)");

                qd.Parameters.Add(new SQLiteParameter("Performer", "%" + PerformerFilter.Text + "%"));
            }

            if (!string.IsNullOrWhiteSpace(PercentsFilter.Text))
            {
                where.Append("\tand Percents=@Percents\r\n");
                qd.Parameters.Add(new SQLiteParameter("Percents", PercentsFilter.Text));
            }

            if(ImportantFilter.IsChecked)
            {
                qd.Join += string.Concat(
                    string.IsNullOrWhiteSpace(qd.Join)
                        ? ""
                        : " join ",
                    "ImportantTasks i on i.TaskGUID=Tasks.GUID");
            }

            if (!string.IsNullOrWhiteSpace(where.ToString()))
            {
                qd.Where += string.IsNullOrWhiteSpace(qd.Where)
                                ? where.ToString().Remove(0, 4)
                                : where.ToString();
                getTasks(qd);
            }
            else if (!string.IsNullOrWhiteSpace(qd.Join))
            {
                getTasks(qd);
            }
            else
            {
                RefreshList();
            }
        }