Диплом: Автоматизация управления персоналом ТОО "КАЗЦИНК ТЕМИР-ТРАНС"

Внимание! Если размещение файла нарушает Ваши авторские права, то обязательно сообщите нам
122
Продолжение приложения 3
IRepository<Educations, Model.Display> educationsRepository = new
EducationsRepository(_db);
IRepository<Nationalities, Model.Display> nationalitiesRepository = new
NationalitiesRepository(_db);
IRepositoryPartial<Professions, Model.ProfessionsAndRolesPartial>
professionsAndRolesPartialRepository = new ProfessionsRepository(_db);
IRepository<DegreeOfRelatednesses, Model.Display>
degreeOfRelatednessesRepository = new DegreeOfRelatednessesRepository(_db);
IRepository<Militaries, Model.Display> militariesRepository = new
MilitariesRepository(_db);
IRepository<MilitaryRanks, Model.DisplayMilitaryRank> militaryRanksRepository
= new MilitaryRanksRepository(_db);
try
{
CbDoc.ItemsSource = await documentsRepository.ItemsDisplay.ToListAsync();
CbEducation.ItemsSource = await
educationsRepository.ItemsDisplay.ToListAsync();
CbNationality.ItemsSource = await
nationalitiesRepository.ItemsDisplay.ToListAsync();
List<Model.DisplayMilitaryRank> displayMilitaryRanks = await
militaryRanksRepository.ItemsDisplay.ToListAsync();
ListCollectionView collectionMilitaryRank = new
ListCollectionView(displayMilitaryRanks);
collectionMilitaryRank.GroupDescriptions.Add(new
PropertyGroupDescription("GroupMilitaryRank"));
CbMilitaryRank.ItemsSource = collectionMilitaryRank;
CbMilitaryRank.SelectedIndex = -1;
List<Model.ProfessionsAndRolesPartial> professionsPartials = await
professionsAndRolesPartialRepository.ItemsPartial.OrderBy(x =>
x.Profession).ToListAsync();
ListCollectionView collection = new
ListCollectionView(professionsPartials);
PropertyGroupDescription propertyGroupDescription = new
PropertyGroupDescription("EngineeringTechnician");
propertyGroupDescription.Converter = new Convertors.GroupConvert();
collection.GroupDescriptions.Add(propertyGroupDescription);
CbProfession.ItemsSource = collection;
CbProfession.SelectedIndex = -1;
CbMilitaries.ItemsSource = await
militariesRepository.ItemsDisplay.ToListAsync();
CbCitizenship.ItemsSource = await
citizenshipsRepository.ItemsDisplay.ToListAsync();
CbDepartment.ItemsSource = await departmentsRepository.Items.Where(x =>
x.SweatshopId == sweatshopId).OrderBy(x => x.Department).Select(x => new Model.Display
{
Id = x.Id,
DisplayPatch = x.Department
}).ToListAsync();
DgcbcDegreeOfRelatedness.ItemsSource = await
degreeOfRelatednessesRepository.ItemsDisplay.ToListAsync();
int count = await _workersRepository.Items.Include(x =>
x.Dismissals).Where(x => x.SweatshopId == sweatshopId && x.Dismissals.Dismissing ==
"Принят")
.CountAsync();
myNavigator.Count = count;
if (count > 0)
123
Продолжение приложения 3
myNavigator.Pos = 1;
else
myNavigator.Pos = 0;
Model.WorkersPartial workersPartial;
if (count > 0)
workersPartial = await GetWorkersPartial(0);
else
workersPartial = null;
await SetDataContext(workersPartial);
}
catch
{
MessageBox.Show("Ошибка базы данных", "Ошибка", MessageBoxButton.OK,
MessageBoxImage.Error);
this.Close();
}
}
private void Owner_Closed(object sender, EventArgs e)
{
this.Close();
}
private void WebCam_Click(object sender, RoutedEventArgs e)
{
WindowWebCam win = new WindowWebCam
{
Owner = this
};
win.ShowDialog();
}
private void OpenImag_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog opf = new OpenFileDialog
{
Filter = "Файлы фотографий|*.jpg;*.jpeg;",
Multiselect = false
};
if (opf.ShowDialog().Value)
{
BitmapImage bmp = new BitmapImage();
using (FileStream stream = File.OpenRead(opf.FileName))
{
try
{
bmp.BeginInit();
bmp.StreamSource = stream;
bmp.CacheOption = BitmapCacheOption.OnLoad;
bmp.EndInit();
ImgWorker.Source = bmp;
}
catch
{
MessageBox.Show("Ошибка открытия файла", "Ошибка",
MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}
}
private async void MyNavigator_MyContextChanged(object sender, RoutedEventArgs e)
{
Model.WorkersPartial workersPartial = await
GetWorkersPartial(myNavigator.Index);
124
Продолжение приложения 3
await SetDataContext(workersPartial);
}
private async void MyNavigator_Edit(object sender, RoutedEventArgs e)
{
isAdd = myNavigator.IsAdd;
if (isAdd)
{
temp = (Model.WorkersPartial)GWin.DataContext;
await SetDataContext(new Model.WorkersPartial
{
DateOfBirth = DateTime.Now,
DateOfIssue = DateTime.Now,
DeviceDate = DateTime.Now,
SweatshopId = sweatshopId,
});
}
}
private async void MyNavigator_Delete(object sender, RoutedEventArgs e)
{
switch (MessageBox.Show("Вы уверены что хотите удалить приведенные вагоны?",
"Вопрос", MessageBoxButton.YesNo, MessageBoxImage.Question))
{
case MessageBoxResult.Yes:
bool b = false;
Model.WorkersPartial workersPartial =
(Model.WorkersPartial)GWin.DataContext;
try
{
b = await
((IRepository<Workers>)_workersRepository).DeleteAsync(workersPartial.Id);
if (b)
{
int key = _dictionary.Where(x => x.Value.Id ==
workersPartial.Id).Select(x => x.Key).FirstOrDefault();
_dictionary.Remove(key);
myNavigator.Count = await _workersRepository.Items.Include(x
=> x.Dismissals)
.Where(x => x.SweatshopId == sweatshopId &&
x.Dismissals.Dismissing == "Принят").CountAsync();
workersPartial = await GetWorkersPartial(myNavigator.Index);
await SetDataContext(workersPartial);
}
isChanget = true;
}
catch
{
MessageBox.Show("Ошибка базы данных", "Ошибка",
MessageBoxButton.OK, MessageBoxImage.Error);
}
break;
case MessageBoxResult.No:
default:
break;
}
}
private async void MyNavigator_NotEdit(object sender, RoutedEventArgs e)
{
if (isAdd)
await SetDataContext(temp);
foreach (Border border in FindVisualChildren<Border>(GPersonalData))
{
if (border.Tag != null && (string)border.Tag == "brd")
125
Продолжение приложения 3
border.BorderThickness = thickness;
}
foreach (Border border in FindVisualChildren<Border>(GDocumentData))
{
if (border.Tag != null && (string)border.Tag == "brd")
border.BorderThickness = thickness;
}
foreach (Border border in FindVisualChildren<Border>(GProfessionalSkill))
{
if (border.Tag != null && (string)border.Tag == "brd")
border.BorderThickness = thickness;
}
foreach (Border border in WorkersBox.FindVisualChildren<Border>(GFamilyData))
{
if (border.Tag != null && (string)border.Tag == "brd")
border.BorderThickness = thickness;
}
foreach (Border border in WorkersBox.FindVisualChildren<Border>(GMilitaries))
{
if (border.Tag != null && (string)border.Tag == "brd")
border.BorderThickness = thickness;
}
foreach (Border border in WorkersBox.FindVisualChildren<Border>(GEducation))
{
if (border.Tag != null && (string)border.Tag == "brd")
border.BorderThickness = thickness;
}
isAdd = false;
}
private async void MyNavigator_Save(object sender, RoutedSaveEventArgs e)
{
bool b = false;
DependencyObject obj;
ComboBox comboBox;
TextBox textBox;
int count;
foreach (Border border in
WorkersBox.FindVisualChildren<Border>(GPersonalData))
{
count = VisualTreeHelper.GetChildrenCount(border);
if (count > 0)
{
obj = VisualTreeHelper.GetChild(border, 0);
if (obj != null)
{
if (obj is TextBox)
{
textBox = obj as TextBox;
if (String.IsNullOrEmpty(textBox.Text))
{
MessageBox.Show("Поле не должно быть пустым", "Внимание",
MessageBoxButton.OK, MessageBoxImage.Warning);
border.BorderThickness = redThickness;
textBox.TextChanged += TextBox_TextChanged;
TiPersonalData.IsSelected = true;
b = true;
break;
}
}
if (obj is ComboBox)
{
comboBox = obj as ComboBox;
126
Продолжение приложения 3
if (comboBox.SelectedIndex == -1)
{
MessageBox.Show("Невыбран елемент в списке", "Внимание",
MessageBoxButton.OK, MessageBoxImage.Warning);
border.BorderThickness = redThickness;
comboBox.SelectionChanged += ComboBox_SelectionChanged;
TiPersonalData.IsSelected = true;
b = true;
break;
}
}
}
}
}
if (b)
{
e.IsCancel = true;
return;
}
foreach (Border border in
WorkersBox.FindVisualChildren<Border>(GDocumentData))
{
count = VisualTreeHelper.GetChildrenCount(border);
if (count > 0)
{
obj = VisualTreeHelper.GetChild(border, 0);
if (obj != null)
{
if (obj is TextBox)
{
textBox = obj as TextBox;
if (String.IsNullOrEmpty(textBox.Text))
{
MessageBox.Show("Поле не должно быть пустым", "Внимание",
MessageBoxButton.OK, MessageBoxImage.Warning);
border.BorderThickness = redThickness;
textBox.TextChanged += TextBox_TextChanged;
TiDocumentData.IsSelected = true;
b = true;
break;
}
if (textBox.Name == "TxtBoxNambeDoc" && textBox.Text.Length <
12)
{
MessageBox.Show("Номер должен иметь десять знаков",
"Внимание", MessageBoxButton.OK, MessageBoxImage.Warning);
border.BorderThickness = redThickness;
textBox.TextChanged += TextBox_TextChanged;
TiDocumentData.IsSelected = true;
b = true;
break;
}
if (textBox.Name == "TxtBoxIIN" && textBox.Text.Length < 9)
{
MessageBox.Show("Номер должен иметь десять знаков",
"Внимание", MessageBoxButton.OK, MessageBoxImage.Warning);
border.BorderThickness = redThickness;
textBox.TextChanged += TextBox_TextChanged;
TiDocumentData.IsSelected = true;
b = true;
break;
}
127
Продолжение приложения 3
}
if (obj is ComboBox)
{
comboBox = obj as ComboBox;
if (comboBox.SelectedIndex == -1)
{
MessageBox.Show("Невыбран елемент в списке", "Внимание",
MessageBoxButton.OK, MessageBoxImage.Warning);
border.BorderThickness = redThickness;
comboBox.SelectionChanged += ComboBox_SelectionChanged;
TiDocumentData.IsSelected = true;
b = true;
break;
}
}
}
}
}
if (b)
{
e.IsCancel = true;
return;
}
foreach (Border border in WorkersBox.FindVisualChildren<Border>(GFamilyData))
{
count = VisualTreeHelper.GetChildrenCount(border);
if (count > 0)
{
obj = VisualTreeHelper.GetChild(border, 0);
if (obj != null && obj is ComboBox)
{
comboBox = obj as ComboBox;
if (comboBox.SelectedIndex == -1)
{
MessageBox.Show("Невыбран елемент в списке", "Внимание",
MessageBoxButton.OK, MessageBoxImage.Warning);
border.BorderThickness = redThickness;
comboBox.SelectionChanged += ComboBox_SelectionChanged;
TiFamilyData.IsSelected = true;
b = true;
break;
}
}
}
}
if (b)
{
e.IsCancel = true;
return;
}
foreach (Border border in
WorkersBox.FindVisualChildren<Border>(GProfessionalSkill))
{
count = VisualTreeHelper.GetChildrenCount(border);
if (count > 0)
{
obj = VisualTreeHelper.GetChild(border, 0);
if (obj != null)
{
if (obj is TextBox)
{
textBox = obj as TextBox;
128
Продолжение приложения 3
if (String.IsNullOrEmpty(textBox.Text))
{
MessageBox.Show("Поле не должно быть пустым", "Внимание",
MessageBoxButton.OK, MessageBoxImage.Warning);
border.BorderThickness = redThickness;
textBox.TextChanged += TextBox_TextChanged;
TiProfessionalSkill.IsSelected = true;
b = true;
break;
}
}
if (obj is ComboBox)
{
comboBox = obj as ComboBox;
if (comboBox.SelectedIndex == -1)
{
MessageBox.Show("Невыбран елемент в списке", "Внимание",
MessageBoxButton.OK, MessageBoxImage.Warning);
border.BorderThickness = redThickness;
comboBox.SelectionChanged += ComboBox_SelectionChanged;
TiProfessionalSkill.IsSelected = true;
b = true;
break;
}
}
}
}
}
if (b)
{
e.IsCancel = true;
return;
}
if (CbMilitaries.SelectedIndex > 0)
{
foreach (Border border in
WorkersBox.FindVisualChildren<Border>(GMilitaries))
{
count = VisualTreeHelper.GetChildrenCount(border);
if (count > 0)
{
obj = VisualTreeHelper.GetChild(border, 0);
if (obj != null)
{
if (obj is ComboBox)
{
comboBox = obj as ComboBox;
if (comboBox.SelectedIndex == -1)
{
MessageBox.Show("Невыбран елемент в списке",
"Внимание", MessageBoxButton.OK, MessageBoxImage.Warning);
border.BorderThickness = redThickness;
comboBox.SelectionChanged +=
ComboBox_SelectionChanged;
TiDocumentData.IsSelected = true;
PMilitaries.IsOpen = true;
b = true;
break;
}
}
}
}
129
Продолжение приложения 3
}
if (b)
{
e.IsCancel = true;
return;
}
}
if (CbEducation.SelectedIndex > 0)
{
foreach (Border border in
WorkersBox.FindVisualChildren<Border>(GEducation))
{
count = VisualTreeHelper.GetChildrenCount(border);
if (count > 0)
{
obj = VisualTreeHelper.GetChild(border, 0);
if (obj != null)
{
if (obj is TextBox)
{
textBox = obj as TextBox;
if (String.IsNullOrEmpty(textBox.Text))
{
MessageBox.Show("Поле не должно быть пустым",
"Внимание", MessageBoxButton.OK, MessageBoxImage.Warning);
border.BorderThickness = redThickness;
textBox.TextChanged += TextBox_TextChanged;
TiProfessionalSkill.IsSelected = true;
PEducation.IsOpen = true;
b = true;
break;
}
}
}
}
}
if (b)
{
e.IsCancel = true;
return;
}
}
isChanget = await SaveData();
if (isChanget)
{
int workersCount = await _workersRepository.Items.Include(x =>
x.Dismissals)
.Where(x => x.SweatshopId == sweatshopId && x.Dismissals.Dismissing
== "Принят").CountAsync();
myNavigator.Count = workersCount;
if (isAdd)
myNavigator.Pos = workersCount;
_dictionary.Clear();
await SetDataContext(await GetWorkersPartial(myNavigator.Pos - 1));
}
else { MessageBox.Show("Ошибка базы данных", "Ошибка", MessageBoxButton.OK,
MessageBoxImage.Error); }
e.IsCancel = isChanget;
}
private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs
e)
{
130
Продолжение приложения 3
ComboBox comboBox = e.Source as ComboBox;
if (comboBox.IsDropDownOpen)
{
if (comboBox.SelectedIndex != -1)
{
DependencyObject obj = VisualTreeHelper.GetParent(comboBox);
if (obj != null && obj is Border)
{
Border border = obj as Border;
border.BorderThickness = thickness;
comboBox.SelectionChanged -= ComboBox_SelectionChanged;
}
}
}
}
private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
{
TextBox textBox = e.Source as TextBox;
if (!String.IsNullOrEmpty(textBox.Text))
{
DependencyObject obj = VisualTreeHelper.GetParent(textBox);
if (obj != null && obj is Border)
{
Border border = obj as Border;
border.BorderThickness = thickness;
textBox.TextChanged -= TextBox_TextChanged;
}
}
}
private void BntOpenPopupMilitaries_Click(object sender, RoutedEventArgs e)
{
BntOpenPopupMilitaries.IsEnabled = false;
PMilitaries.IsOpen = true;
}
private void BntOpenPopupEducation_Click(object sender, RoutedEventArgs e)
{
BntOpenPopupEducation.IsEnabled = false;
PEducation.IsOpen = true;
}
private void PEducation_Opened(object sender, EventArgs e)
{
if (GEducation.DataContext == null)
{
GEducation.DataContext = new DiplomInf
{
DateEnd = DateTime.Now
};
}
}
private void PMilitaries_Opened(object sender, EventArgs e)
{
if (GMilitaries.DataContext == null)
{
GMilitaries.DataContext = new MilitaryDuties();
}
}
private void PEducation_Closed(object sender, EventArgs e)
{
BntOpenPopupEducation.IsEnabled = true;
}
private void PMilitaries_Closed(object sender, EventArgs e)
{
131
Продолжение приложения 3
BntOpenPopupMilitaries.IsEnabled = true;
}
private async void CbMilitaries_SelectionChanged(object sender,
SelectionChangedEventArgs e)
{
if (CbMilitaries.IsDropDownOpen)
{
Model.Display display = (Model.Display)CbMilitaries.SelectedItem;
if (GMilitaries.DataContext != null)
{
if (CbMilitaries.SelectedIndex == -1 || display.DisplayPatch ==
"Невоеннообязанный")
{
int id = ((MilitaryDuties)GMilitaries.DataContext).Id;
bool b = false;
if (id != 0)
{
b = await _militaryDutiesRepository.DeleteItemAsync(id);
if (b)
GMilitaries.DataContext = null;
}
else
GMilitaries.DataContext = null;
}
}
}
}
private async void CbEducation_SelectionChanged(object sender,
SelectionChangedEventArgs e)
{
if (CbEducation.IsDropDownOpen)
{
Model.Display display = (Model.Display)CbEducation.SelectedItem;
if (GEducation.DataContext != null)
{
if (CbEducation.SelectedIndex == -1 || display.DisplayPatch ==
"Среднее")
{
int id = ((DiplomInf)GEducation.DataContext).Id;
bool b = false;
if (id != 0)
{
b = await _diplomInfRepository.DeleteItemAsync(id);
if (b)
GEducation.DataContext = null;
}
else
GEducation.DataContext = null;
}
}
}
}
private void BntAdd_Click(object sender, RoutedEventArgs e)
{
if (CbFamilyStatus.SelectedIndex > 1 && GWin.DataContext != null &&
GWin.DataContext is Model.WorkersPartial)
{
FamilyBox win = new FamilyBox
{
Owner = this
};
if (win.ShowDialog().Value)

Смотрите также:

"Автоматизация обработки заявок ООО "Проектно-Строительная Компания"
"Автоматизация процесса аттестации персонала для ООО "Нэт Бай Нэт Холдинг"
"Анализ интернет-активности конкурентов ( на примере конкурентов "Газпром нефть")
"Бухгалтерский учёт и аудит расчётов с подотчётними лицами в организации на примере ООО "ЛОЦ 10""
«Психологическое сопровождение персонала в организации на примере ООО «Крокус»
Cовершенствование деловой оценки персонала в организации (на примере ООО "Даймонд кейтеринг развитие")
IPO - инструмент финансирования деятельности организации. На примере ПАО «Нефтяная компания «Лукойл»
PR как средство продвижения организации (на примере ПАО "Тамбовский завод "Комсомолец им. Н.С. Артемова")
PR-коммуникации в сфере общественного питания (на примере кафе-кондитерской «Cream Cheese»)
SMM как средство повышения эффективности работы учреждений социокультурной сферы (на примере Малого театра)