private bool DeleteXRayFilmUsedDetails(Entities.XRayFilmUsed xRayFilmUsed, DbTransaction dbTransaction) { bool IsXRayFilmUsedDeleted = false; try { using (DbCommand dbCommand = database.GetStoredProcCommand(DBStoredProcedure.DeleteXRayFilmsUsed)) { database.AddInParameter(dbCommand, "@xray_film_used_id", DbType.Int32, xRayFilmUsed.XRayFilmUsedId); database.AddInParameter(dbCommand, "@deleted_by", DbType.Int32, xRayFilmUsed.DeletedBy); database.AddInParameter(dbCommand, "@deleted_by_ip", DbType.String, xRayFilmUsed.DeletedByIP); database.AddOutParameter(dbCommand, "@return_value", DbType.Int32, 0); var result = database.ExecuteNonQuery(dbCommand, dbTransaction); if (database.GetParameterValue(dbCommand, "@return_value") != DBNull.Value) { IsXRayFilmUsedDeleted = Convert.ToBoolean(database.GetParameterValue(dbCommand, "@return_value")); } } } catch (Exception e) { throw e; } return(IsXRayFilmUsedDeleted); }
private Int32 AddXRayFilmUsedDetails(Entities.XRayFilmUsed xRayFilmUsed, DbTransaction dbTransaction) { var XRayFilmUsedId = 0; try { using (DbCommand dbCommand = database.GetStoredProcCommand(DBStoredProcedure.InsertXRayFilmsUsed)) { database.AddInParameter(dbCommand, "@xray_film_used_id", DbType.Int32, xRayFilmUsed.XRayFilmUsedId); database.AddInParameter(dbCommand, "@xray_issue_id", DbType.Int32, xRayFilmUsed.XRayIssueId); database.AddInParameter(dbCommand, "@drug_id", DbType.Int32, xRayFilmUsed.DrugId); database.AddInParameter(dbCommand, "@dispense_qty", DbType.Decimal, xRayFilmUsed.DispenseQty); database.AddInParameter(dbCommand, "@rate", DbType.Decimal, xRayFilmUsed.PurchaseRate); database.AddInParameter(dbCommand, "@created_by", DbType.Int32, xRayFilmUsed.CreatedBy); database.AddInParameter(dbCommand, "@created_by_ip", DbType.String, xRayFilmUsed.CreatedByIP); database.AddOutParameter(dbCommand, "@return_value", DbType.Int32, 0); XRayFilmUsedId = database.ExecuteNonQuery(dbCommand, dbTransaction); if (database.GetParameterValue(dbCommand, "@return_value") != DBNull.Value) { XRayFilmUsedId = Convert.ToInt32(database.GetParameterValue(dbCommand, "@return_value")); } } } catch (Exception e) { throw e; } return(XRayFilmUsedId); }
public List <Entities.XRayFilmUsed> GetFilmUsedDetailsByXRayIssueId(Int32 xrayIssueId) { var xRayFilmsUsed = new List <Entities.XRayFilmUsed>(); try { using (DbCommand dbCommand = database.GetStoredProcCommand(DBStoredProcedure.GetXRayFilmsUsedDetailsByXRayIssueId)) { database.AddInParameter(dbCommand, "@xray_issue_id", DbType.Int32, xrayIssueId); using (IDataReader reader = database.ExecuteReader(dbCommand)) { while (reader.Read()) { var xRayFilmUsed = new Entities.XRayFilmUsed() { XRayFilmUsedId = DRE.GetNullableInt32(reader, "xray_film_used_id", null), XRayIssueId = DRE.GetNullableInt32(reader, "xray_issue_id", null), DrugId = DRE.GetNullableInt32(reader, "drug_id", null), DrugCode = DRE.GetNullableInt32(reader, "drug_code", null), DrugName = DRE.GetNullableString(reader, "drug_name", null), DispenseQty = DRE.GetNullableDecimal(reader, "dispense_qty", null), BalanceQty = DRE.GetNullableDecimal(reader, "balance_qty", null), PurchaseRate = DRE.GetNullableDecimal(reader, "purchase_rate", null), Amount = DRE.GetNullableDecimal(reader, "amount", null) }; xRayFilmsUsed.Add(xRayFilmUsed); } } } } catch (Exception e) { throw e; } return(xRayFilmsUsed); }
public Int32 SaveXRayFilmUsed(Entities.XRayFilmUsed xRayFilmUsed, DbTransaction dbTransaction) { var xrayFilmUsedId = 0; if (xRayFilmUsed.XRayFilmUsedId == null || xRayFilmUsed.XRayFilmUsedId == 0) { xrayFilmUsedId = AddXRayFilmUsedDetails(xRayFilmUsed, dbTransaction); } else if (xRayFilmUsed.ModifiedBy != null || xRayFilmUsed.ModifiedBy > 0) { xrayFilmUsedId = UpdateXRayFilmUsedDetails(xRayFilmUsed, dbTransaction); } else if (xRayFilmUsed.IsDeleted == true) { var result = DeleteXRayFilmUsedDetails(xRayFilmUsed, dbTransaction); if (result) { xrayFilmUsedId = (int)xRayFilmUsed.XRayFilmUsedId; } } return(xrayFilmUsedId); }