@ -24,11 +24,29 @@ namespace eCompanies
private void updateCompanyItem ( Company updatingCompany )
{
if ( updatingCompany = = null ) return ;
var c = ( ( DataGrid ) companyGrid ) . DataContext as ObservableCollection < Company > ;
for ( int i = 0 ; i ! = c . Count ( ) ; i + + )
if ( c [ i ] . CompanyId . Equals ( updatingCompany . CompanyId ) )
c [ i ] = updatingCompany ;
companyGrid . Items . Refresh ( ) ;
}
private void companyGrid_AddingNewItem ( object sender , AddingNewItemEventArgs e )
{
e . NewItem = new Company ( ) ;
var newItem = e . NewItem as Company ;
newItem . dataGridRowStatus = DataGridRowStatus . NEW ;
var c = ( ( DataGrid ) sender ) . DataContext as ObservableCollection < Company > ;
if ( c . Count ! = 0 )
newItem . CompanyId = + + c [ c . Count - 1 ] . CompanyId ;
}
private void companyGrid_CellEditEnding ( object sender , DataGridCellEditEndingEventArgs e )
{
( ( Company ) e . Row . Item ) . dataGridRowStatus = DataGridRowStatus . UPDATED ;
var context = e . Row . DataContext as Company ;
if ( context . dataGridRowStatus ! = DataGridRowStatus . NEW )
context . dataGridRowStatus = DataGridRowStatus . UPDATED ;
}
private void RowEdit_Click ( object sender , RoutedEventArgs e )
@ -36,7 +54,7 @@ namespace eCompanies
UpdateCompanyGridDelegate d = updateCompanyItem ;
Company company = ( Company ) companyGrid . CurrentItem ;
if ( usersWindowInstance ! = null ) usersWindowInstance . Close ( ) ;
usersWindowInstance = new UsersWindow ( company , d , deletingUsersList ) ;
usersWindowInstance = new UsersWindow ( company , d ) ;
usersWindowInstance . Show ( ) ;
}