public SEC_UserENT SelectPK(SqlInt32 UserID) { try { SqlDatabase sqlDB = new SqlDatabase(myConnectionString); DbCommand dbCMD = sqlDB.GetStoredProcCommand("PR_SEC_User_SelectByPK"); sqlDB.AddInParameter(dbCMD, "@UserID", SqlDbType.Int, UserID); SEC_UserENT entSEC_User = new SEC_UserENT(); DataBaseHelper DBH = new DataBaseHelper(); using (IDataReader dr = DBH.ExecuteReader(sqlDB, dbCMD)) { while (dr.Read()) { if (!dr["UserID"].Equals(System.DBNull.Value)) { entSEC_User.UserID = Convert.ToInt32(dr["UserID"]); } if (!dr["UserName"].Equals(System.DBNull.Value)) { entSEC_User.UserName = Convert.ToString(dr["UserName"]); } if (!dr["Password"].Equals(System.DBNull.Value)) { entSEC_User.Password = Convert.ToString(dr["Password"]); } if (!dr["Email"].Equals(System.DBNull.Value)) { entSEC_User.Email = Convert.ToString(dr["Email"]); } if (!dr["CreationDate"].Equals(System.DBNull.Value)) { entSEC_User.CreationDate = Convert.ToDateTime(dr["CreationDate"]); } if (!dr["ModificationDate"].Equals(System.DBNull.Value)) { entSEC_User.ModificationDate = Convert.ToDateTime(dr["ModificationDate"]); } } } return(entSEC_User); } catch (SqlException sqlex) { Message = SQLDataExceptionMessage(sqlex); if (SQLDataExceptionHandler(sqlex)) { throw; } return(null); } catch (Exception ex) { Message = ExceptionMessage(ex); if (ExceptionHandler(ex)) { throw; } return(null); } }
public MST_HospitalENT SelectPK(SqlInt32 HospitalID) { try { SqlDatabase sqlDB = new SqlDatabase(myConnectionString); DbCommand dbCMD = sqlDB.GetStoredProcCommand("PR_MST_Hospital_SelectByPK"); sqlDB.AddInParameter(dbCMD, "@HospitalID", SqlDbType.Int, HospitalID); MST_HospitalENT entMST_Hospital = new MST_HospitalENT(); DataBaseHelper DBH = new DataBaseHelper(); using (IDataReader dr = DBH.ExecuteReader(sqlDB, dbCMD)) { while (dr.Read()) { if (!dr["HospitalID"].Equals(System.DBNull.Value)) { entMST_Hospital.HospitalID = Convert.ToInt32(dr["HospitalID"]); } if (!dr["HospitalName"].Equals(System.DBNull.Value)) { entMST_Hospital.HospitalName = Convert.ToString(dr["HospitalName"]); } if (!dr["CityID"].Equals(System.DBNull.Value)) { entMST_Hospital.CityID = Convert.ToInt32(dr["CityID"]); } if (!dr["CategoryID"].Equals(System.DBNull.Value)) { entMST_Hospital.CategoryID = Convert.ToInt32(dr["CategoryID"]); } if (!dr["CategoryTypeID"].Equals(System.DBNull.Value)) { entMST_Hospital.CategoryTypeID = Convert.ToInt32(dr["CategoryTypeID"]); } if (!dr["Address"].Equals(System.DBNull.Value)) { entMST_Hospital.Address = Convert.ToString(dr["Address"]); } if (!dr["MobileNumber"].Equals(System.DBNull.Value)) { entMST_Hospital.MobileNumber = Convert.ToString(dr["MobileNumber"]); } if (!dr["TelephoneNumber"].Equals(System.DBNull.Value)) { entMST_Hospital.TelePhoneNumber = Convert.ToString(dr["TelephoneNumber"]); } if (!dr["Fax"].Equals(System.DBNull.Value)) { entMST_Hospital.Fax = Convert.ToString(dr["Fax"]); } if (!dr["Website"].Equals(System.DBNull.Value)) { entMST_Hospital.Website = Convert.ToString(dr["Website"]); } if (!dr["EmailID"].Equals(System.DBNull.Value)) { entMST_Hospital.EmailID = Convert.ToString(dr["EmailID"]); } if (!dr["AmbulancePhoneNumber"].Equals(System.DBNull.Value)) { entMST_Hospital.AmbulancePhoneNumber = Convert.ToString(dr["AmbulancePhoneNumber"]); } if (!dr["EmergencyNumber"].Equals(System.DBNull.Value)) { entMST_Hospital.EmergencyNumber = Convert.ToString(dr["EmergencyNumber"]); } if (!dr["HospitalImage"].Equals(System.DBNull.Value)) { entMST_Hospital.HospitalImage = Convert.ToString(dr["HospitalImage"]); } if (!dr["LocationCoordinates"].Equals(System.DBNull.Value)) { entMST_Hospital.LocationCoordinates = Convert.ToString(dr["LocationCoordinates"]); } } } return(entMST_Hospital); } catch (SqlException sqlex) { Message = SQLDataExceptionMessage(sqlex); if (SQLDataExceptionHandler(sqlex)) { throw; } return(null); } catch (Exception ex) { Message = ExceptionMessage(ex); if (ExceptionHandler(ex)) { throw; } return(null); } }