private void addNote(string note, string doctor, string appointment) { DoctorVisitNotes.DoctorVisitNotes doctorvisitnotes = new DoctorVisitNotes.DoctorVisitNotes(); doctorvisitnotes.note = note; doctorvisitnotes.date = DateTime.Now.ToShortDateString(); doctorvisitnotes.docID = doctor; doctorvisitnotes.appointmentID = appointment; bool success = doctorvisitnotes.Insert(doctorvisitnotes, this); if (success == true) { CustomMessageBox cm = new CustomMessageBox("Successfully Recorded Note", this, GotoIndividualAppointment); removeErrors(); ClearField(); cm.Show(); } }
public bool Insert(DoctorVisitNotes doctorvisitnotes, Form form) { bool isSuccess = false; SqlConnection conn = new SqlConnection(myconnstring); try { string query = "INSERT INTO Doctor_Visit_Notes (note_id, doc_id, appointment_id, visit_note_date, note) VALUES (NEXT VALUE FOR visit_notes_seq ,@doctor, @appointment, @date, @note)"; SqlCommand cmd = new SqlCommand(query, conn); cmd.Parameters.AddWithValue("@date", doctorvisitnotes.date); cmd.Parameters.AddWithValue("@appointment", doctorvisitnotes.appointmentID); cmd.Parameters.AddWithValue("@doctor", doctorvisitnotes.docID); cmd.Parameters.AddWithValue("@note", doctorvisitnotes.note); conn.Open(); int rows = cmd.ExecuteNonQuery(); if (rows > 0) { isSuccess = true; } else { isSuccess = false; } } catch (Exception ex) { //CustomMessageBox cm = new CustomMessageBox("Failed to add Note to database", form); //cm.Show(); MessageBox.Show(ex.ToString()); } finally { conn.Close(); } return(isSuccess); }