private void AddBtn_Click(object sender, EventArgs e) { if (!IsInList(new User(NameTB.Text, SurnameTB.Text, HobbyTB.Text, ProffTB.Text)) && NameTB.Text != "" && SurnameTB.Text != "") { users.Add(new User(NameTB.Text, SurnameTB.Text, HobbyTB.Text, ProffTB.Text)); DataLB.Items.Add(NameTB.Text + ' ' + SurnameTB.Text); NameTB.ResetText(); SurnameTB.ResetText(); HobbyTB.ResetText(); ProffTB.ResetText(); SurnameTB.BackColor = _myColor; NameTB.BackColor = _myColor; } else { if (NameTB.Text != "" && SurnameTB.Text != "") { NameTB.BackColor = Color.Coral; SurnameTB.BackColor = Color.Coral; } if (NameTB.Text == "") { NameTB.BackColor = Color.Coral; } if (SurnameTB.Text == "") { SurnameTB.BackColor = Color.Coral; } // System.Media.SoundPlayer player = new System.Media.SoundPlayer("SolutionItems/error.wav"); // player.Play(); } }
private void SurnameTB_GotFocus(object sender, RoutedEventArgs e) { if (SurnameTB.Text == "Vorname") { SurnameTB.Clear(); } }
private void ClearFields() { LoginTB.Clear(); PasswordTB.Clear(); CPasswordTB.Clear(); SurnameTB.Clear(); NameTB.Clear(); PatronymicTB.Clear(); FacultyCB.Text = ""; DepartmentCB.Text = ""; DepartmentCB.Enabled = false; }
private void CreatePatientBut_Click(object sender, EventArgs e) { //try //{ Patients pat = new Patients(); LoadFormInPatient(pat); ctx.Patients.Add(pat); ctx.SaveChanges(); MessageBox.Show("Пацієнта створено"); patient = pat; m = mode.Redact; Configure(); //} //catch //{ MessageBox.Show("Для створення нового пацієнта необхідно заповнити прізвище та ім'я"); SurnameTB.Select(); // } }
public StudentModal(object owner, Modes mode = Modes.CREATE, Student student = null) { Student = mode == Modes.CREATE ? new Student() : student; Mode = mode; Parant = (MainWindow)owner; DataContext = this; InitializeComponent(); if (mode == Modes.EDIT) { if (student is null) { throw new ArgumentNullException("Student can not be null when modal opened in edit mode"); } SetUpEditMode(student); } SurnameTB.Focus(); }
void Add_Click(object sender, EventArgs e) { if (NameTB.Text.Trim().Length < 1 || SurnameTB.Text.Trim().Length < 1 || PatronymicTB.Text.Trim().Length < 1 || FacultyCB.SelectedIndex == -1 || SpecialtyCB.SelectedIndex == -1 || MarkTB.Text.Trim().Length < 1) { MessageBox.Show("Fill all data"); return; } if (!Single.TryParse(MarkTB.Text.Trim().Replace(',', '.'), out var mark) || mark < 50 || mark > 100) { MessageBox.Show("Enter mark between 50 and 100"); return; } var b = BirthdayDT.Value; bool result = new Student { Surname = SurnameTB.Text.Trim(), Name = NameTB.Text.Trim(), Patronymic = PatronymicTB.Text.Trim(), Gender = Male.Checked, Birthday = new DateTime(b.Year, b.Month, b.Day), Mark = mark }.Insert(); if (!result) { MessageBox.Show("An error occured"); } DB.Connection.Open(); string query = "SELECT MAX(id) " + "FROM mycursa4_Db.Student;"; var reader = new MySqlCommand(query, DB.Connection).ExecuteReader(); reader.Read(); int studentId = (int)reader[0]; DB.Connection.Close(); result = new Course { CourseNum = (int)CourseUD.Value }.Insert(); if (!result) { MessageBox.Show("An error occured"); } DB.Connection.Open(); var cmd = DB.Connection.CreateCommand(); cmd.CommandText = "INSERT INTO mycursa4_Db.showStudent (student, faculty, specialty, course) " + $"VALUES ('{studentId}','{FacultyId}','{SpecialtyId}', '{(int)CourseUD.Value}');"; cmd.ExecuteNonQuery(); DB.Connection.Close(); NameTB.Text = SurnameTB.Text = PatronymicTB.Text = MarkTB.Text = String.Empty; FacultyCB.SelectedItem = SpecialtyCB.SelectedItem = null; CourseUD.Value = 1; Male.Checked = true; SurnameTB.Focus(); }