Exemple #1
0
        public string ToSqlString()
        {
            var propId   = Property.Id;
            var tenantId = Tenant.Id;
            var price    = MonthlyPrice.ToString(CultureInfo.InvariantCulture);

            return($"{propId}, {tenantId}, {price}, " +
                   $"{CastUtils.FormatSqlDate(StartDate)}, {CastUtils.FormatSqlDate(EndDate)}");
        }
        private string BuildFilter()
        {
            var city  = PropCityCBox.SelectedIndex == -1 ? SqlNull : $"N'{PropCityCBox.SelectedItem}'";
            var today = CastUtils.FormatSqlDate(DateTime.Now);

            var rented    = SqlNull;
            var available = SqlNull;

            if (RentedChBox.IsChecked == true)
            {
                rented = SqlTrue;
            }
            else if (RentedChBox.IsChecked == false)
            {
                available = SqlTrue;
            }

            var res = ResidentialChBox.IsChecked == null ? SqlNull :
                      ResidentialChBox.IsChecked == true ? SqlTrue : SqlFalse;
            var furn = FurnishedChBox.IsChecked == null ? SqlNull :
                       FurnishedChBox.IsChecked == true ? SqlTrue : SqlFalse;
            var park = ParkingChBox.IsChecked == null ? SqlNull :
                       ParkingChBox.IsChecked == true ? SqlTrue : SqlFalse;

            var minArea = string.IsNullOrEmpty(MinAreaTextBox.Text) ? SqlNull : MinAreaTextBox.Text;
            var maxArea = string.IsNullOrEmpty(MaxAreaTextBox.Text) ? SqlNull : MaxAreaTextBox.Text;

            var checkedRb = RoomsCount.Children.OfType <RadioButton>()
                            .FirstOrDefault(r => r.IsChecked.GetValueOrDefault());
            var rooms    = BuildRoomCountString(checkedRb);
            var maxRooms = checkedRb?.Name == "Rooms5RButton" ? "5" : SqlNull;

            return
                ($"(({city} is null) or city = {city}) and " +
                 $"(({rented} is null) or lease.end_date >= {today}) and " +
                 $"(({available} is null) or (lease.end_date < {today} or lease.id is null)) and " +
                 $"(({res} is null) or residential = {res}) and " +
                 $"(({furn} is null) or furnished = {furn}) and " +
                 $"(({park} is null) or has_parking = {park}) and " +
                 $"(({minArea} is null) or area >= {minArea}) and " +
                 $"(({maxArea} is null) or area <= {maxArea}) and " +
                 $"(({rooms} is null) or room_count = {rooms}) and " +
                 $"(({maxRooms} is null) or room_count >= {maxRooms})");
        }
        private string BuildFilter()
        {
            var today   = CastUtils.FormatSqlDate(DateTime.Now);
            var current = SqlNull;
            var expired = SqlNull;

            if (CurrentChBox.IsChecked == true)
            {
                current = SqlTrue;
            }
            else if (CurrentChBox.IsChecked == false)
            {
                expired = SqlTrue;
            }

            var sd = string.IsNullOrEmpty(StartDatePicker.Text)
                ? SqlNull
                : CastUtils.FormatSqlDate(Convert.ToDateTime(StartDatePicker.Text));
            var ed = string.IsNullOrEmpty(EndDatePicker.Text)
                ? SqlNull
                : CastUtils.FormatSqlDate(Convert.ToDateTime(EndDatePicker.Text));

            var city = CityCBox.SelectedIndex == -1 ? SqlNull : $"N'{CityCBox.SelectedItem}'";
            var tId  = SqlNull;

            if (TenantCBox.SelectedIndex != -1)
            {
                tId = (Tenant)TenantCBox.SelectedItem == null
                    ? SqlNull
                    : ((Tenant)TenantCBox.SelectedItem).Id.ToString();
            }

            return
                ($"(({current} is null) or end_date >= {today}) and " +
                 $"(({expired} is null) or end_date < {today}) and " +
                 $"(({sd} is null) or start_date = {sd}) and " +
                 $"(({ed} is null) or end_date = {ed}) and " +
                 $"(({city} is null) or property.city = {city}) and " +
                 $"(({tId} is null) or tenant.id = {tId})");
        }
Exemple #4
0
 public string ToSqlString()
 {
     return($"N'{Surname}', N'{Name}', N'{Patronym}', {CastUtils.FormatSqlDate(DateOfBirth)}");
 }