delete

Apr 10, 2009 at 8:31 PM
Hi,

I am new to this and am trying to add the delete SQL statement here (DELETE FROM InspectorTime  WHERE TimeID=@TimeID)

Where would that fit in the code below?  Txs

<dg:DataGrid.Columns>
                <dg:DataGridTextColumn IsReadOnly="True" Header="" Binding="{Binding Path=TimeID}" Visibility="Hidden"    />
                <dg:DataGridTextColumn IsReadOnly="True" Header="Route Priority" Binding="{Binding Path=RoutePriority}" MinWidth="100" />
                <dg:DataGridTextColumn IsReadOnly="True" Header="Job Address" Binding="{Binding Path=JobAddress}" MinWidth="100" />
                <dg:DataGridTextColumn IsReadOnly="True" Header="Permit #"  Binding="{Binding Path=PermitNumber}" MinWidth="100" />
                <dg:DataGridTextColumn IsReadOnly="True" Header="Inspection Type"  Binding="{Binding Path=TimeOptionEntry}" MinWidth="100" />
                <dg:DataGridTextColumn IsReadOnly="True" Header="Start Time"  Binding="{Binding Path=StartTime}" MinWidth="100" />
                <dg:DataGridTextColumn IsReadOnly="True" Header="End Time"  Binding="{Binding Path=EndTime}" MinWidth="100" />
                <dg:DataGridTemplateColumn Header="Void" Visibility="Visible" MinWidth="50" MaxWidth="50" >
                    <dg:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Button Content="Void" Foreground="Black" FontSize="12" VerticalAlignment="Center" MaxWidth="50" Click="VoidButton_Click" Tag="{Binding Path=TimeID}" Uid="{Binding Path=TimeID}"  />
                        </DataTemplate>
                    </dg:DataGridTemplateColumn.CellTemplate>
                </dg:DataGridTemplateColumn>

            </dg:DataGrid.Columns>



        private void VoidButton_Click(object sender, RoutedEventArgs e)
        {
            
            if (MessageBox.Show("Are you sure you want to void the time?", "Void Inspection", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
            // delete SQL query
         {
            try
             {

                 MessageBox.Show("Information Updated.", "Update");
             }
             catch (Exception oEx)
             {
                 MessageBox.Show("Information not Updated.", "Update");
             }
        
          }
        }