private void button4_Click(object sender, EventArgs e) { if (_currentEditWorker != null && _currentEditWorker.idPrac > 0) { var status = LoadWorkerFromEditScreen(_currentEditWorker); if (!status) { MessageBox.Show("Sprawdź czy wymagane pola są wypełnione poprawnymi danymi!"); return; } var isEdit = WorkerService.UpdateWorker(_currentEditWorker); if (isEdit) { MessageBox.Show("Zaktualizowano dane pracownika!"); } else { MessageBox.Show("Błąd podczas aktualizacji danych pracownika"); } _currentEditWorker = WorkerService.GetWorker(_currentEditWorker.idPrac); ShowWorkerOnEditScreen(_currentEditWorker); } else { MessageBox.Show("Najpierw wybierz pracownika do edycji!"); } }
private void ShowSelectedWorkerOnEditScreen(int id) { var worker = WorkerService.GetWorker(id) ?? new PRACOWNICY(); ShowWorkerOnEditScreen(worker); _currentEditWorker = worker; EdytujPracownikaPanel.BringToFront(); }
private PRACOWNICY GetWorkerFromAddScreen() { PRACOWNICY newWorker = new PRACOWNICY(); var tmp = textBox42.TextOrDefault(); if (tmp == null) { return(null); } newWorker.Imie = tmp; newWorker.DrugieImie = textBox40.TextOrDefault(); tmp = textBox45.TextOrDefault(); if (tmp == null) { return(null); } newWorker.Nazwisko = tmp; tmp = textBox47.TextOrDefault(); if (tmp == null) { return(null); } newWorker.Adres = tmp; newWorker.Plec = (sbyte)comboBox3.SelectedIndex; tmp = maskedTextBox8.TextOrDefault(); if (tmp == null || tmp.Length < 9) { return(null); } newWorker.Telefon = tmp; newWorker.Email = textBox46.TextOrDefault(); var parse = DateTime.TryParse(maskedTextBox2.Text, out DateTime dataZat); if (!parse) { return(null); } newWorker.DataZatr = dataZat; parse = DateTime.TryParse(maskedTextBox3.Text, out DateTime dataUr); if (!parse) { return(null); } newWorker.DataUr = dataUr; newWorker.Login = "******" + newWorker.Imie + newWorker.DataUr.ToString("dd"); newWorker.Haslo = newWorker.Login; return(newWorker); }
private void textBox41_TextChanged(object sender, EventArgs e) { if (!int.TryParse(((TextBox)sender).Text, out int id)) { id = -1; } _currentEditWorker = WorkerService.GetWorker(id) ?? new PRACOWNICY(); ShowWorkerOnEditScreen(_currentEditWorker); }
private void ShowWorkerOnEditScreen(PRACOWNICY pracownicy) { textBox32.Text = pracownicy.Imie; textBox26.Text = pracownicy.DrugieImie; textBox35.Text = pracownicy.Nazwisko; textBox38.Text = pracownicy.Adres; comboBox2.SelectedIndex = pracownicy.Plec == 1 ? 1 : 0; textBox55.Text = pracownicy.Login; maskedTextBox6.Text = pracownicy.Telefon; textBox36.Text = pracownicy.Email; textBox24.Text = pracownicy.DataZatr.ToString("d"); textBox19.Text = pracownicy.DataUr.ToString("d"); //pictureBox9.Image = }
private bool LoadWorkerFromEditScreen(PRACOWNICY editWorker) { var tmp = textBox32.TextOrDefault(); if (tmp == null) { return(false); } editWorker.Imie = tmp; editWorker.DrugieImie = textBox26.TextOrDefault(); tmp = textBox35.TextOrDefault(); if (tmp == null) { return(false); } editWorker.Nazwisko = tmp; tmp = textBox38.TextOrDefault(); if (tmp == null) { return(false); } editWorker.Adres = tmp; tmp = maskedTextBox6.TextOrDefault(); if (tmp == null || tmp.Length < 9) { return(false); } editWorker.Telefon = tmp; editWorker.Email = textBox36.TextOrDefault(); return(true); }