public async Task <IHttpActionResult> AddDisBill(DischargeBillModel dischargebill) { if (dischargebill == null) { return(BadRequest("Please provide valid inputs!")); } if (await DIschargeBillService.AddDischargeBill(dischargebill)) { return(Ok("Patient Discharged Successfully!")); } else { return(BadRequest("Failed to Save Discharge Details!")); } }
public async Task <IHttpActionResult> UpdateDisDateRoomStatus(DischargeBillModel discharge) { if (discharge == null) { return(BadRequest("Please provide valid inputs!")); } if (await AddmissionService.UpdateDisDateRoomStatus(discharge)) { return(Ok("Date and Status Updated Successfully!")); } else { return(BadRequest("Failed to Update Details!")); } }//end of update
}//end of add ////discharge patient //public static async Task<bool> UpdateInPatient(InPatientModel inpatient) //{ // String SQL = "UPDATE In_Patient SET Discharged = @disDate WHERE PatientID = @ID"; // using (SqlConnection dbConn = new SqlConnection(connectionString)) // { // try // { // dbConn.Open(); // SqlCommand cmd = new SqlCommand(); // cmd.CommandType = CommandType.Text; // cmd.CommandText = SQL; // cmd.Connection = dbConn; // cmd.Parameters.AddWithValue("@ID", inpatient.PatientID); // cmd.Parameters.AddWithValue("@disDate", inpatient.DateDischarged); // await cmd.ExecuteNonQueryAsync(); // dbConn.Close(); // return true; // } // catch (Exception ex) // { // Console.WriteLine(ex); // return false; // } // finally // { // dbConn.Close(); // } // } //} //update the discharge date and room status public static async Task <bool> UpdateDisDateRoomStatus(DischargeBillModel discharge) { String SQL1 = "UPDATE Room SET IsAvailable = 1 WHERE ID =" + discharge.RoomID; String SQL2 = "UPDATE In_Patient SET DischargedDate = @dateDis where ID ='" + discharge.AdmissionID + "'"; using (SqlConnection dbConn = new SqlConnection(connectionString)) { try { //update the room status dbConn.Open(); SqlCommand cmd1 = new SqlCommand(); cmd1.CommandType = CommandType.Text; cmd1.CommandText = SQL1; cmd1.Connection = dbConn; await cmd1.ExecuteNonQueryAsync(); dbConn.Close(); //update the discharge date dbConn.Open(); SqlCommand cmd2 = new SqlCommand(); cmd2.CommandType = CommandType.Text; cmd2.CommandText = SQL2; cmd2.Connection = dbConn; cmd2.Parameters.AddWithValue("@dateDis", discharge.DischargedDate); await cmd2.ExecuteNonQueryAsync(); dbConn.Close(); return(true); } catch (Exception ex) { Console.WriteLine(ex); return(false); } finally { dbConn.Close(); } } }//end of update
public static async Task <bool> AddDischargeBill(DischargeBillModel disbill) { DateTime billeddate = DateTime.Now; String SQL = "INSERT INTO AdmissionBill(AdmissionID, MedBill, ReportBill, RoomCharge, Date)" + "VALUES('" + disbill.AdmissionID + "','" + disbill.MedBill + "','" + disbill.ReportBill + "','" + disbill.RoomBill + "', @billDate)"; //String SQL = "INSERT INTO AdmissionBill(AdmissionID, MedBill, ReportBill, RoomCharge, TotalBill, Date)" + // "VALUES('" + disbill.AdmissionID + "','" + disbill.MedBill + "','" + disbill.ReportBill + "','" + disbill.RoomBill + "','" + disbill.TotalBill + "','" + disbill.BilledDate + "')"; using (SqlConnection dbConn = new SqlConnection(connectionString)) { try { dbConn.Open(); SqlCommand cmd = new SqlCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = SQL; cmd.Connection = dbConn; cmd.Parameters.AddWithValue("@billDate", billeddate); await cmd.ExecuteNonQueryAsync(); dbConn.Close(); await AddmissionService.UpdateDisDateRoomStatus(disbill);//update the room status and discharge date return(true); } catch (Exception ex) { Console.WriteLine(ex); return(false); } finally { dbConn.Close(); } } }//end of add