// Kontragent məlumatlarının yenilənməsi: private void BtnUpdate_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrWhiteSpace(TxtCounterpartyName.Text)) { TxtCounterpartyName.BorderBrush = Brushes.Red; TxtCounterpartyName.BorderThickness = new Thickness(2); } if (string.IsNullOrWhiteSpace(TxtResponsiblePerson.Text)) { TxtResponsiblePerson.BorderBrush = Brushes.Red; TxtResponsiblePerson.BorderThickness = new Thickness(2); } if (string.IsNullOrWhiteSpace(TxtPhone.Text)) { TxtPhone.BorderBrush = Brushes.Red; TxtPhone.BorderThickness = new Thickness(2); } if (string.IsNullOrWhiteSpace(TxtAddress.Text)) { TxtAddress.BorderBrush = Brushes.Red; TxtAddress.BorderThickness = new Thickness(2); } if (string.IsNullOrWhiteSpace(TxtCounterpartyName.Text) || string.IsNullOrWhiteSpace(TxtResponsiblePerson.Text) || string.IsNullOrWhiteSpace(TxtPhone.Text) || string.IsNullOrWhiteSpace(TxtAddress.Text)) { TxtBlcAttention.Text = "Qırmızı sahələr doldurulmalıdır"; return; } if (CmbPosition.SelectedItem == null) { MessageBox.Show("Vəzifə seçin"); return; } TxtBlcAttention.Text = ""; if (db.Counterparties.Count(c => c.Phone == TxtPhone.Text) > 0 && TxtPhone.Text != selectedCounterparty.Phone) { TxtBlcAttention.Text = "Bu telefon nömrəsi artıq qeyd olunub"; TxtPhone.Focus(); return; } if (db.Counterparties.Count(c => c.Mobile == TxtMobile.Text) > 0 && TxtMobile.Text != selectedCounterparty.Mobile) { TxtBlcAttention.Text = "Bu telefon nömrəsi artıq qeyd olunub"; TxtMobile.Focus(); return; } Counterparty counterparty = db.Counterparties.Find(selectedCounterparty.Id); counterparty.Name = TxtCounterpartyName.Text; counterparty.ResponsiblePerson = TxtResponsiblePerson.Text; counterparty.PositionID = db.Positions.First(p => p.Name == CmbPosition.SelectedValue.ToString()).Id; counterparty.Phone = TxtPhone.Text; counterparty.Mobile = TxtMobile.Text; counterparty.Address = TxtAddress.Text; db.SaveChanges(); TxtBlcAttention.Text = "Kontragent yeniləndi"; crmWindow.Refresh(); }
// Kontragent məlumatlarının yenilənməsi: private void BtnSave_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrWhiteSpace(TxtEmployeeName.Text)) { TxtEmployeeName.BorderBrush = Brushes.Red; TxtEmployeeName.BorderThickness = new Thickness(2); } if (string.IsNullOrWhiteSpace(TxtEmployeeSurname.Text)) { TxtEmployeeSurname.BorderBrush = Brushes.Red; TxtEmployeeSurname.BorderThickness = new Thickness(2); } if (string.IsNullOrWhiteSpace(TxtPhone.Text)) { TxtPhone.BorderBrush = Brushes.Red; TxtPhone.BorderThickness = new Thickness(2); } if (string.IsNullOrWhiteSpace(TxtEmployeeName.Text) || string.IsNullOrWhiteSpace(TxtEmployeeSurname.Text) || string.IsNullOrWhiteSpace(TxtPhone.Text)) { TxtBlcAttention.Text = "Qırmızı sahələr doldurulmalıdır"; return; } if (CmbPosition.SelectedItem == null) { MessageBox.Show("Vəzifə seçin"); return; } TxtBlcAttention.Text = ""; if (db.Employees.Count(c => c.Phone == TxtPhone.Text) > 0) { TxtBlcAttention.Text = "Bu telefon nömrəsi artıq qeyd olunub"; TxtPhone.Focus(); return; } Employee employee = new Employee { Name = TxtEmployeeName.Text, Surname = TxtEmployeeSurname.Text, Phone = TxtPhone.Text, PositionID = db.Positions.First(p => p.Name == CmbPosition.SelectedValue.ToString()).Id, RecruitmentDate = DpRecruitmentDate.SelectedDate.Value.Date, }; db.Employees.Add(employee); db.SaveChanges(); TxtBlcAttention.Text = "Yeni işçi əlavə olundu."; crmWindow.Refresh(); }