public bool EditLabService(LabService labService, int serviceId, Form form) { bool isSuccess = false; SqlConnection conn = new SqlConnection(myconnstring); try { string query = "Update Lab_Services Set service = @service, cost = @cost WHERE service_id = @drugId"; SqlCommand cmd = new SqlCommand(query, conn); cmd.Parameters.AddWithValue("@service", labService.service); cmd.Parameters.AddWithValue("@cost", labService.cost); cmd.Parameters.AddWithValue("@drugId", serviceId); conn.Open(); int rows = cmd.ExecuteNonQuery(); if (rows > 0) { isSuccess = true; } else { isSuccess = false; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); //CustomMessageBox cm = new CustomMessageBox("Failed to add patient", form); //cm.Show(); } finally { conn.Close(); } return(isSuccess); }
public bool AddNewLabService(LabService labservice, Form form) { bool isSuccess = false; SqlConnection conn = new SqlConnection(myconnstring); try { string query = "INSERT INTO Lab_Services (service_id, service, cost) VALUES (NEXT VALUE FOR lab_service_seq ,@service, @cost)"; SqlCommand cmd = new SqlCommand(query, conn); cmd.Parameters.AddWithValue("@service", labservice.service); cmd.Parameters.AddWithValue("@cost", labservice.cost); conn.Open(); int rows = cmd.ExecuteNonQuery(); if (rows > 0) { isSuccess = true; } else { isSuccess = false; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); //CustomMessageBox cm = new CustomMessageBox("Failed to add Lab Service", form); //cm.Show(); } finally { conn.Close(); } return(isSuccess); }