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 btnIssue_Click(object sender, EventArgs e) { DataSet mDataSet = new DataSet(); string selectedItem = cbBooks.SelectedValue.ToString(); UserHelper.getInstance().bookID = int.Parse(selectedItem); mDataSet = dbHandler.Select("SELECT * FROM books WHERE bookID=" + UserHelper.getInstance().bookID); int bookQuantitiy = int.Parse(mDataSet.Tables[0].Rows[0][4].ToString()); if (bookQuantitiy > 0) { dbHandler.Insert("INSERT INTO BookBorrow (takenDate, loginID, bookID, studentID) VALUES ('" + dtpBorrowDate.Value.ToShortDateString() + "'," + UserHelper.getInstance().userID + "," + UserHelper.getInstance().bookID + "," + UserHelper.getInstance().studentID + ")"); bookQuantitiy = bookQuantitiy - 1; dbHandler.Update("UPDATE books SET bookQuantity=" + bookQuantitiy + "WHERE bookID =" + UserHelper.getInstance().bookID); MessageBox.Show("Book issued!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Selected book is no more", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
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); } }