private void SignUpBtnClick() { string username = tbUserName.Text; string password = tbPassword.Text; string passwordRepeat = tbPasswordRepeat.Text; string query = "SELECT * FROM loginTable WHERE username = '******'"; if (tbUserName.Text.Length > 0 && tbPassword.Text.Length > 0) { if (dbHandler.RowExist(query) == false) { if (password == passwordRepeat) { dbHandler.Insert("INSERT INTO loginTable (username, password) VALUES ('" + username + "', '" + password + "')"); MessageBox.Show("User successfully registered!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information); ProgramManager.getInstance().SwitchScreen(this, new Form1()); } else { MessageBox.Show("Passwords aren't matching!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("Username already exists!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Please enter username or password!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void btnSaveClick() { if (MessageBox.Show("Are you sure you want to save student?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (tbName.Text != "" && cbGender.SelectedIndex != 0 && tbStudentClass.Text != "" && key != "") { if (dbHandler.RowExist("SELECT * FROM student WHERE enrollment ='" + key + "'") == false) { dbHandler.Insert("INSERT INTO student (studentName, birthdate, gender, class, enrollment) VALUES ('" + tbName.Text + "','" + dtpBirthdate.Value.ToShortDateString() + "','" + cbGender.SelectedValue.ToString() + "','" + tbStudentClass.Text + "','" + key + "')"); MessageBox.Show("Student inserted!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information); key = ""; } } else { MessageBox.Show("Some fields are empty\n\n or wrong value", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("Student not saved!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information); } }