public void saveData() { ExamineeForm me = new ExamineeForm(); try { if (txtORnumber.Text.Trim() != "" && txtFirstname.Text.Trim() != "" && txtMiddlename.Text.Trim() != "" && txtLastname.Text.Trim() != "" && txtAge.Text.Trim() != "" && cbSex.Text.Trim() != "" && txtAddress.Text.Trim() != "" && dtpDate.Text.Trim() != "") { if (MessageBox.Show("Are you sure you want to save this?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { conn.Open(); cmd = new OleDbCommand("INSERT INTO examineetbl(orNumber, Fname, Mname, Lname, Age, Sex, Address, ExamDate) VALUES ('" + txtORnumber.Text.Trim() + "', '" + txtFirstname.Text.Trim() + "', '" + txtMiddlename.Text.Trim() + "', '" + txtLastname.Text.Trim() + "', '" + txtAge.Text.Trim() + "', '" + cbSex.Text.Trim() + "', '" + txtAddress.Text.Trim() + "', '" + dtpDate.Value.ToString() + "')", conn); dr = cmd.ExecuteReader(); MessageBox.Show("Data Saved"); this.Hide(); if (me.ShowDialog() == System.Windows.Forms.DialogResult.OK) { loadData(); } dr.Close(); } } else { MessageBox.Show("Please Complete The Form"); } } catch (OleDbException ex) { MessageBox.Show("Error in Saving: " + ex.Message); } finally { conn.Close(); } }
private void button1_Click(object sender, EventArgs e) { if (txtUsername.Text == "" || txtPassword.Text == "") { MessageBox.Show("Please Provide Textbox Fields"); } else { if (buttonuser.Text == "Confirm") { try { con.Open(); cmd.Connection = con; cmd.CommandText = "SELECT* FROM usertbl WHERE username = '******' AND password = '******'"; dr = cmd.ExecuteReader(); if (dr.Read() == true) { MessageBox.Show("Login Successful"); ExamineeForm exam = new ExamineeForm(); exam.Show(); } else { MessageBox.Show("Username/password"); } } catch (Exception ex) { MessageBox.Show("Error Login User" + ex.ToString()); } finally { con.Close(); } } if (buttonuser.Text == "Login") { try { con.Open(); cmd.Connection = con; cmd.CommandText = "SELECT * FROM admintbl WHERE username = '******' AND password = '******'"; dr = cmd.ExecuteReader(); if (dr.Read() == true) { MessageBox.Show("Succesful login Admin"); MainAdmin admin = new MainAdmin(); admin.Show(); } else { MessageBox.Show("Invalid Username/Password"); } } catch (Exception ex) { MessageBox.Show("Error Login Admin" + ex.Message); } finally { con.Close(); } } } }