public bool EliminatePhoto(PhotoCriteria pCriteriaKey, String pCriteriaValue) { bool mBoolSuccess = false; String mStrSQL = ""; List<Object> ArrCriteria = GetDBFieldByCriteria(pCriteriaKey, pCriteriaValue); mStrSQL = "DELETE FROM PHOTOS " + "WHERE " + Convert.ToString(ArrCriteria[cCRITERIAKEY]) + " = "; if (pCriteriaKey == PhotoCriteria.cID) { mStrSQL += Convert.ToString(ArrCriteria[cCRITERIAVALUE]); } else { mStrSQL += (byte[])(ArrCriteria[cCRITERIAVALUE]); } try { oConnection.OpenConnection(); oConnection.UpdateSQL(mStrSQL,null); mBoolSuccess = true; } catch (Exception ex) { throw ex; } finally { oConnection.CloseConnection(); } return mBoolSuccess; }
private List<Object> GetDBFieldByCriteria(PhotoCriteria pCriteriaKey, Object pCriteriaValue) { List<Object> ArrCriteriaField = new List<Object>(); switch (pCriteriaKey) { case PhotoCriteria.cID: ArrCriteriaField[cCRITERIAKEY] = "ID"; ArrCriteriaField[cCRITERIAVALUE] = pCriteriaValue; break; case PhotoCriteria.cPHOTO: ArrCriteriaField[cCRITERIAKEY] = "PHOTOSRC"; ArrCriteriaField[cCRITERIAVALUE] = pCriteriaValue; break; default: ArrCriteriaField[cCRITERIAKEY] = ""; ArrCriteriaField[cCRITERIAVALUE] = pCriteriaValue; break; } return ArrCriteriaField; }
public Object[,] ListPhotosByCriteria(PhotoCriteria pCriteriaKey, Object pCriteriaValue) { Object[,] ArrPhotos; List<Object> ArrCriteria = GetDBFieldByCriteria(pCriteriaKey, pCriteriaValue); String mStrSQL = ""; mStrSQL = "SELECT ID, PHOTOSRC " + "FROM PHOTOS " + "WHERE " + ArrCriteria[cCRITERIAKEY] + " = " + ArrCriteria[cCRITERIAVALUE]; try { oConnection.OpenConnection(); ArrPhotos = oConnection.QuerySQLResultList(mStrSQL); //oConnection.CloseConnection(); } catch (Exception ex) { throw ex; } finally { oConnection.CloseConnection(); } return ArrPhotos; }