public QI_VISTA_GRP_REC GetVistaGroupById(Guid VistaGroupId) { QI_VISTA_GRP_REC vistaGroup = new QI_VISTA_GRP_REC(); using (SqlConnection dbConn = m_SqlHelpers.GetDbConnection(m_AwareDbConnString)) { string sqlText = "usp_GetVistaGroupById"; SqlCommand sqlCmd = new SqlCommand(sqlText, dbConn); sqlCmd.CommandType = System.Data.CommandType.StoredProcedure; sqlCmd.Parameters.AddWithValue("@VistaGroupId", VistaGroupId); SqlDataReader dr = sqlCmd.ExecuteReader(); while (dr.Read()) { try { try { vistaGroup.VistaGrpID = dr.GetGuid(0); } catch (SqlNullValueException Exception) { vistaGroup.VistaGrpID = new Guid(); } try { vistaGroup.Name = dr.GetString(1); } catch (SqlNullValueException ex) { vistaGroup.Name = string.Empty; } try { vistaGroup.AwareGrpId = dr.GetGuid(2); } catch (SqlNullValueException ex) { vistaGroup.AwareGrpId = new Guid(); } try { vistaGroup.FacilityId = dr.GetGuid(3); } catch (SqlNullValueException ex) { vistaGroup.FacilityId = new Guid(); } } catch (InvalidCastException ex) { } } dr.Close(); dbConn.Close(); } return(vistaGroup); }
public List <QI_VISTA_GRP_REC> GetVistaGroupCollection() { List <QI_VISTA_GRP_REC> vistaGroupsCollection = new List <QI_VISTA_GRP_REC>(); using (SqlConnection dbConn = m_SqlHelpers.GetDbConnection(m_AwareDbConnString)) { string sqlText = "usp_GetVistaGroups"; SqlCommand sqlCmd = new SqlCommand(sqlText, dbConn); SqlDataReader dr = sqlCmd.ExecuteReader(); sqlCmd.CommandType = System.Data.CommandType.StoredProcedure; while (dr.Read()) { try { QI_VISTA_GRP_REC rec = new QI_VISTA_GRP_REC(); try{ rec.VistaGrpID = dr.GetGuid(0); }catch (SqlNullValueException Exception) { rec.VistaGrpID = new Guid(); } try{ rec.Name = dr.GetString(1); }catch (SqlNullValueException ex) { rec.Name = string.Empty; } try{ rec.AwareGrpId = dr.GetGuid(2); }catch (SqlNullValueException ex) { rec.AwareGrpId = new Guid(); } try{ rec.FacilityId = dr.GetGuid(3); }catch (SqlNullValueException ex) { rec.FacilityId = new Guid(); } rec.ViewAllProv = _DoesViewAllProvsRightExist(new Guid(), rec.VistaGrpID); vistaGroupsCollection.Add(rec); } catch (InvalidCastException ex) { } } dr.Close(); dbConn.Close(); } return(vistaGroupsCollection); }
public void UpdateVistaGroup(ref QI_VISTA_GRP_REC group) { using (SqlConnection awareDbConn = m_SqlHelpers.GetDbConnection(m_AwareDbConnString)) { string sqlText = "usp_UpdateVistaGroupMapping"; SqlCommand sqlCmd = new SqlCommand(sqlText, awareDbConn); sqlCmd.CommandType = System.Data.CommandType.StoredProcedure; sqlCmd.Parameters.AddWithValue("@GroupName", group.Name); sqlCmd.Parameters.AddWithValue("@FacilityId", group.FacilityId); sqlCmd.Parameters.AddWithValue("@AwareGrpId", group.AwareGrpId); sqlCmd.Parameters.AddWithValue("@VistaGrpId", group.VistaGrpID); sqlCmd.ExecuteNonQuery(); awareDbConn.Close(); } if ((true == group.ViewAllProv) && (false == _DoesViewAllProvsRightExist(group.VistaGrpID, new Guid()))) { using (SqlConnection awareDbConn = m_SqlHelpers.GetDbConnection(m_AwareDbConnString)) { string sqlText = "usp_AddSecurityRight"; SqlCommand sqlCmd = new SqlCommand(sqlText, awareDbConn); sqlCmd.CommandType = System.Data.CommandType.StoredProcedure; sqlCmd.Parameters.AddWithValue("@ObjTypeId", (int)AwareObjectTypes.VIEW_ALL_PROVIDERS); sqlCmd.Parameters.AddWithValue("@ObjectId", group.VistaGrpID); sqlCmd.Parameters.AddWithValue("@EntityId", new Guid()); sqlCmd.ExecuteNonQuery(); awareDbConn.Close(); } } else if ((false == group.ViewAllProv) && (true == _DoesViewAllProvsRightExist(new Guid(), group.VistaGrpID))) { using (SqlConnection awareDbConn = m_SqlHelpers.GetDbConnection(m_AwareDbConnString)) { string sqlText = "usp_DeleteSecurityRight"; SqlCommand sqlCmd = new SqlCommand(sqlText, awareDbConn); sqlCmd.CommandType = System.Data.CommandType.StoredProcedure; sqlCmd.Parameters.AddWithValue("@EntityId", new Guid()); sqlCmd.Parameters.AddWithValue("@ObjectType", (int)AwareObjectTypes.VIEW_ALL_PROVIDERS); sqlCmd.Parameters.AddWithValue("@ObjectId", group.VistaGrpID); sqlCmd.ExecuteNonQuery(); awareDbConn.Close(); } } }