private void btnSave_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(tbEnterprise.Text)) { MessageBox.Show("Название предприятия не должно быть пустым.", "Проверка"); return; } if (tbEnterprise.Text.Length > 30) { MessageBox.Show("Слишком длинное слово.", "Проверка"); return; } if ((!string.IsNullOrEmpty(tbEnterprise.Text))) { EnterpriseDto countr = new EnterpriseDto(); countr.NameEnterprise = tbEnterprise.Text; IEnterpriseProcess workProcess = ProcessFactory.GetEnterpriseProcess(); if (_id == 0) { workProcess.Add(countr); } else { countr.IDEnterprise = _id; workProcess.Add(countr); } Close(); } }
private void btnAddE_Click(object sender, RoutedEventArgs e) { WinEnterprise window = new WinEnterprise(); window.ShowDialog(); dgEnterprise.ItemsSource = ProcessFactory.GetEnterpriseProcess().GetList(); }
private void btnSave_Click(object sender, RoutedEventArgs e) { if (tbAddress.Text == "") { tbAddress.BorderBrush = Brushes.Red; } if (tbNameEnterprise.Text == "") { tbNameEnterprise.BorderBrush = Brushes.Red; } if (tbPhone.Text == "") { tbPhone.BorderBrush = Brushes.Red; } if (tbRepresent.Text == "") { tbRepresent.BorderBrush = Brushes.Red; } try { EnterprisesDto enter = new EnterprisesDto(); enter.Address = tbAddress.Text; enter.Email = tbEmail.Text; enter.NameEnterprise = tbNameEnterprise.Text; enter.Note = tbNote.Text; enter.Phone = Convert.ToDouble(tbPhone.Text); enter.Representative = tbRepresent.Text; IEnterpriseProcessDb enterProcess = ProcessFactory.GetEnterpriseProcess(); if (_id == 0) { enterProcess.Add(enter); } else { enter.IDEnterprise = _id; enterProcess.Update(enter); } } catch { return; } Close(); }
private void btnDeleteE_Click(object sender, RoutedEventArgs e) { EnterpriseDto item = dgEnterprise.SelectedItem as EnterpriseDto; if (item == null) { MessageBox.Show("Выберите запись для удаления", "Удаление предприятия"); return; } MessageBoxResult result = MessageBox.Show("Удалить " + item.NameEnterprise + "?", "Удаление предприятия", MessageBoxButton.YesNo, MessageBoxImage.Warning); if (result != MessageBoxResult.Yes) { return; } ProcessFactory.GetEnterpriseProcess().Delete(item.IDEnterprise); btnUpdateE_Click(sender, e); }
private void SearchEnterpriseNow(object sender, RoutedEventArgs e) { this.FindedEnterprise = ProcessFactory.GetEnterpriseProcess().SearchEnterprises(this.tbNameEnterprise.Text, this.tbAddress.Text); this.exec = true; this.Close(); }
private void btnUpdateE_Click(object sender, RoutedEventArgs e) { dgEnterprise.ItemsSource = ProcessFactory.GetEnterpriseProcess().GetList(); }