//////////////////// Add Button /////////////////// private void button1_Click(object sender, EventArgs e) { string connString = "Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source=E:\\ITS245\\STEFPROJ\\Database11.accdb"; OleDbConnection connection = new OleDbConnection(connString); OleDbCommand cmd = connection.CreateCommand(); connection.Open(); cmd.CommandText = "Insert into Patienttable (PtLastName, PtFirstName,DOB) VALUES" + "(" + "'" + Lname.Text + "'" + "," + "'" + Fname.Text + "'" + "," + "'" + AGE.Text + "'" + ")"; cmd.Connection = connection; OleDbDataReader reader = cmd.ExecuteReader(); connection.Close(); this.BackColor = Color.LightBlue; Lname.ReadOnly = true; Fname.ReadOnly = true; AGE.ReadOnly = true; listBox1.Update(); ADDButton.Hide(); Save.Hide(); }
//////////// Save Button //////////// private void Save_Click(object sender, EventArgs e) { string connString = "Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source=E:\\ITS245\\STEFPROJ\\Database11.accdb"; OleDbConnection connection = new OleDbConnection(connString); OleDbCommand cmd = connection.CreateCommand(); connection.Open(); cmd.Connection = connection; cmd.CommandText = "Update patienttable set PtLastName =" + "'" + Lname.Text + "'" + ",PtFirstname =" + "'" + Fname.Text + "'" + " where PatientID=" + PatientID.Text; OleDbDataReader reader2 = cmd.ExecuteReader(); reader2.Read(); reader2.Close(); connection.Close(); this.BackColor = Color.LightBlue; Lname.ReadOnly = true; Fname.ReadOnly = true; AGE.ReadOnly = true; listBox1.Update(); Save.Hide(); ADDButton.Hide(); }
////////////// Modify Button ////////// private void Modify_Click(object sender, EventArgs e) { //// send it the object made from class and leave the e//// Modname mod = new Modname(Fname.Text, Lname.Text, AGE.Text); Undo_Click(mod, e); this.BackColor = Color.Blue; Lname.ReadOnly = false; Fname.ReadOnly = false; AGE.ReadOnly = false; Save.Show(); ADDButton.Show(); }