|
|
@ -2,17 +2,8 @@ |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Collections.ObjectModel; |
|
|
|
using System.Linq; |
|
|
|
using System.Text; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using System.Windows; |
|
|
|
using System.Windows.Controls; |
|
|
|
using System.Windows.Data; |
|
|
|
using System.Windows.Documents; |
|
|
|
using System.Windows.Input; |
|
|
|
using System.Windows.Media; |
|
|
|
using System.Windows.Media.Imaging; |
|
|
|
using System.Windows.Navigation; |
|
|
|
using System.Windows.Shapes; |
|
|
|
|
|
|
|
namespace eCompanies |
|
|
|
{ |
|
|
@ -22,9 +13,8 @@ namespace eCompanies |
|
|
|
public delegate void UpdateCompanyGridDelegate(Company updatingCompany); |
|
|
|
public partial class MainWindow : Window |
|
|
|
{ |
|
|
|
List<int> deletingCompanyList = new List<int>(); |
|
|
|
List<int> updatingCompanyList = new List<int>(); |
|
|
|
UsersWindow usersWindowInstance = null; |
|
|
|
List<int> deletingCompanyList = new List<int>(); |
|
|
|
|
|
|
|
public MainWindow() |
|
|
|
{ |
|
|
@ -35,7 +25,7 @@ namespace eCompanies |
|
|
|
private void updateCompanyItem(Company updatingCompany) |
|
|
|
{ |
|
|
|
if (updatingCompany == null) return; |
|
|
|
updatingCompanyList.Add(updatingCompany.CompanyId); |
|
|
|
updatingCompany.needUpdate = true; |
|
|
|
var context = ((ObservableCollection<Company>)companyGrid.DataContext).ToList<Company>(); |
|
|
|
for (int i = 0; i < context.Count; i++) |
|
|
|
{ |
|
|
@ -43,7 +33,6 @@ namespace eCompanies |
|
|
|
{ |
|
|
|
context[i] = updatingCompany; |
|
|
|
companyGrid.DataContext = new ObservableCollection<Company>(context); |
|
|
|
updatingCompanyList.Add(updatingCompany.CompanyId); |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -108,13 +97,18 @@ namespace eCompanies |
|
|
|
else if (mbr == MessageBoxResult.No) |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (c.CompanyId == 0) |
|
|
|
App.addCompany(c); |
|
|
|
else if (c.needUpdate) |
|
|
|
App.updateCompany(c); |
|
|
|
} |
|
|
|
if (deletingCompanyList != null) |
|
|
|
App.removeCompany(deletingCompanyList); |
|
|
|
deletingCompanyList = null; |
|
|
|
// TODO: реализация обновления старых компаний и добавления новых
|
|
|
|
} |
|
|
|
|
|
|
|
private void companyGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) |
|
|
|
{ |
|
|
|
((Company)e.Row.Item).needUpdate = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|