Esempio n. 1
0
        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;
        }
Esempio n. 2
0
 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;
 }
Esempio n. 3
0
        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;
        }