Windows Mobile v8.1如何将datepicker和timepicker检索到列表框?

时间:2015-07-04 20:39:23

标签: c# datepicker listbox timepicker

我在这里有点新意,所以如果我犯了任何错误,我想道歉。

我的DateTimeReservation.xmal

<TextBlock Margin="0,161,259,0" TextWrapping="Wrap" Text="Date:" VerticalAlignment="Top" Height="59" HorizontalAlignment="Right" Width="131" FontSize="30" />
<TextBlock Margin="0,243,259,0" TextWrapping="Wrap" Text="Time:" VerticalAlignment="Top" Height="59" HorizontalAlignment="Right" Width="131" FontSize="30" />
<DatePicker HorizontalAlignment="Left" VerticalAlignment="Top" Margin="243,154,0,0" YearVisible="True" x:Name="arrivalDatePicker" />
<TimePicker x:Name="Time1" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="243,233,0,0" MinuteIncrement="30"/>
<Button Content="Submit" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="243,305,0,0" Click="Button_Click"/>
<TextBlock TextWrapping="Wrap" Margin="10,54,10,484" x:Name="Alert" FontSize="25"/>

我的DateTimeReservation.xmal.cs

protected override void OnNavigatedTo(NavigationEventArgs e)
{
    Time1.DataContext = e.Parameter;
}

private void Button_Click(object sender, RoutedEventArgs e)
{

    Frame.Navigate(typeof(Table), Time1);
}

我要将我的日期和时间检索到的页面:Table.xmal

<ListBox BorderBrush="#FF141EE4" Height="auto" BorderThickness="2" MaxHeight="580" Grid.Row="1" x:Name="listBoxobj" SelectionChanged="listBoxobj_SelectionChanged" Background="Black">
    <ListBox.ItemTemplate>
        <DataTemplate>
            <Grid Background="Gray" Width="480">
                <Border BorderBrush="White" BorderThickness="1">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <TextBlock Grid.Row="0" x:Name="TableNoTxt" TextWrapping="Wrap" Text="{Binding Time}" FontSize="28" Foreground="White"/>                 
                    </Grid>
                </Border>
            </Grid>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>

Table.xmal.cs(我被困在这个部分)

DatabaseHelperClass Db_Helper = new DatabaseHelperClass();
Reservation currentcontact = new Reservation();

我的模型Reservation.cs

public int ReservationId { get; set; }
    public string Date { get; set; }
    public string Time { get; set; }
    public string Remarks { get; set; }
    public string Name { get; set;}
    public string ContactNumber {get; set;}
    public string TableNo { get; set; }

    public Reservation()
    {
        //empty constructor
    }
    public Reservation(string tableno, string name)
    {
        TableNo = tableno;
        Name = name;



    }

    public Reservation(string tableno, string name, string contactnumber)
    {
        this.TableNo = tableno;
        this.Name = name;
        this.ContactNumber = contactnumber;


    }

    public Reservation(string tableno, string name, string contactnumber, string date, string time)
    {
        this.TableNo = tableno;
        this.Name = name;
        this.ContactNumber = contactnumber;
        this.Date = date;
        this.Time = time;

    }

    public Reservation(string tableno, string name, string contactnumber, string date)
    {
        this.TableNo = tableno;
        this.Name = name;
        this.ContactNumber = contactnumber;
        this.Date = date;


    }

我的数据库

public Reservation ReadDateTime(string datetime)
    {
        using (var dbConn = new SQLiteConnection(App.DB_PATH))
        {
            var existingDateTime = dbConn.Query<Reservation>("select * from Reservation where Date =" + datetime).FirstOrDefault();
            return existingDateTime;
        }
    }

0 个答案:

没有答案