|
@ -20,7 +20,8 @@ namespace eCompanies |
|
|
{ |
|
|
{ |
|
|
InitializeComponent(); |
|
|
InitializeComponent(); |
|
|
currentCompany = c; |
|
|
currentCompany = c; |
|
|
currentCompany.Users = App.getUsers(c.CompanyId); |
|
|
if (currentCompany.dataGridRowStatus == DataGridRowStatus.DEFAULT) |
|
|
|
|
|
currentCompany.Users = App.getUsers(c.CompanyId); |
|
|
updateCompanyItem = d; |
|
|
updateCompanyItem = d; |
|
|
updateUsersGrid(c); |
|
|
updateUsersGrid(c); |
|
|
} |
|
|
} |
|
@ -42,20 +43,21 @@ namespace eCompanies |
|
|
currentCompany.Users.Clear(); |
|
|
currentCompany.Users.Clear(); |
|
|
foreach (Users u in (ObservableCollection<Users>)usersGrid.DataContext) |
|
|
foreach (Users u in (ObservableCollection<Users>)usersGrid.DataContext) |
|
|
{ |
|
|
{ |
|
|
if ((u.Login == null || u.Password == null || u.Name == null) |
|
|
if (u.dataGridRowStatus != DataGridRowStatus.REMOVED) |
|
|
&& (u.dataGridRowStatus != DataGridRowStatus.REMOVED)) |
|
|
if (u.Login == null || u.Password == null || u.Name == null) |
|
|
switch (App.fieldHasNotFilled()) |
|
|
switch (App.fieldHasNotFilled()) |
|
|
{ |
|
|
{ |
|
|
case MessageBoxResult.No: return; |
|
|
case MessageBoxResult.No: return; |
|
|
case MessageBoxResult.Yes: e.Cancel = true; return; |
|
|
case MessageBoxResult.Yes: e.Cancel = true; return; |
|
|
} |
|
|
} |
|
|
u.CompanyId = currentCompany.CompanyId; |
|
|
u.CompanyId = currentCompany.CompanyId; |
|
|
u.Company = currentCompany; |
|
|
u.Company = currentCompany; |
|
|
currentCompany.Users.Add(u); |
|
|
currentCompany.Users.Add(u); |
|
|
} |
|
|
} |
|
|
currentCompany.ContractStatus = contractStatusComboBox.SelectedIndex; |
|
|
currentCompany.ContractStatus = contractStatusComboBox.SelectedIndex; |
|
|
currentCompany.Name = companyNameBox.Text; |
|
|
currentCompany.Name = companyNameBox.Text; |
|
|
currentCompany.dataGridRowStatus = DataGridRowStatus.UPDATED; |
|
|
if (currentCompany.dataGridRowStatus != DataGridRowStatus.NEW) |
|
|
|
|
|
currentCompany.dataGridRowStatus = DataGridRowStatus.UPDATED; |
|
|
updateCompanyItem(currentCompany); |
|
|
updateCompanyItem(currentCompany); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -77,9 +79,6 @@ namespace eCompanies |
|
|
e.NewItem = new Users(); |
|
|
e.NewItem = new Users(); |
|
|
var newItem = e.NewItem as Users; |
|
|
var newItem = e.NewItem as Users; |
|
|
newItem.dataGridRowStatus = DataGridRowStatus.NEW; |
|
|
newItem.dataGridRowStatus = DataGridRowStatus.NEW; |
|
|
var c = ((DataGrid)sender).DataContext as ObservableCollection<Users>; |
|
|
|
|
|
if (c.Count != 0) |
|
|
|
|
|
newItem.UserId = c[c.Count - 1].UserId + 1; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|