Пример #1
0
/*
 *    string _connectionStr = ConfigurationManager.ConnectionStrings[CONST_CONSTRING].ConnectionString;
 *
 *    using (OleDbConnection _conn = new OleDbConnection(_connectionStr))
 *    {
 *      string _sqlCmd = CONST_SQL_SELECT;
 *      OleDbCommand _cmd = new OleDbCommand(_sqlCmd, _conn);                    // run the query we have built
 *      _conn.Open();
 *      OleDbDataReader _DataReader = _cmd.ExecuteReader();
 *      if (_DataReader.Read())
 *      {
 *        _DataItem.SCEMTID = (_DataReader["SCEMTID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["SCEMTID"]);
 *        _DataItem.Header = (_DataReader["Header"] == DBNull.Value) ? string.Empty : _DataReader["Header"].ToString();
 *        _DataItem.Body = (_DataReader["Body"] == DBNull.Value) ? string.Empty : _DataReader["Body"].ToString();
 *        _DataItem.Footer = (_DataReader["Footer"] == DBNull.Value) ? string.Empty : _DataReader["Footer"].ToString();
 *        _DataItem.DateLastChange = (_DataReader["DateLastChange"] == DBNull.Value) ? System.DateTime.Now : Convert.ToDateTime(_DataReader["DateLastChange"]);
 *        _DataItem.Notes = (_DataReader["Notes"] == DBNull.Value) ? string.Empty : _DataReader["Notes"].ToString();
 *      }
 *    }
 *    return _DataItem;
 *  }
 */
        public string UpdateTexts(SendCheckEmailTextsData pEmailTextsData, int pOriginalID)
        {
            string    _errString = "";
            TrackerDb _TDB       = new TrackerDb();

            #region Parameters
            // Add data sent
            _TDB.AddParams(pEmailTextsData.Header, DbType.String, "@Header");
            _TDB.AddParams(pEmailTextsData.Body, DbType.String, "@Body");
            _TDB.AddParams(pEmailTextsData.Footer, DbType.String, "@Footer");
            _TDB.AddParams(DateTime.Now.Date, DbType.Date, "@DateLastChange");
            _TDB.AddParams(pEmailTextsData.Notes, DbType.String, "@Notes");
            //                                     " WHERE SCEMTID = ?)";
            _TDB.AddWhereParams(pOriginalID, DbType.Int32, "@SCEMTID");
            #endregion

            _errString = _TDB.ExecuteNonQuerySQL(CONST_SQL_UPDATE);
            _TDB.Close();
            return(_errString);
        }
Пример #2
0
        public SendCheckEmailTextsData GetTexts()
        {
            SendCheckEmailTextsData _DataItem = new SendCheckEmailTextsData();
            TrackerDb _TDB = new TrackerDb();

            IDataReader _DataReader = _TDB.ExecuteSQLGetDataReader(CONST_SQL_SELECT);

            if (_DataReader != null)
            {
                if (_DataReader.Read())
                {
                    _DataItem.SCEMTID        = (_DataReader["SCEMTID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["SCEMTID"]);
                    _DataItem.Header         = (_DataReader["Header"] == DBNull.Value) ? string.Empty : _DataReader["Header"].ToString();
                    _DataItem.Body           = (_DataReader["Body"] == DBNull.Value) ? string.Empty : _DataReader["Body"].ToString();
                    _DataItem.Footer         = (_DataReader["Footer"] == DBNull.Value) ? string.Empty : _DataReader["Footer"].ToString();
                    _DataItem.DateLastChange = (_DataReader["DateLastChange"] == DBNull.Value) ? System.DateTime.Now.Date : Convert.ToDateTime(_DataReader["DateLastChange"]).Date;
                    _DataItem.Notes          = (_DataReader["Notes"] == DBNull.Value) ? string.Empty : _DataReader["Notes"].ToString();
                }
                _DataReader.Close();
            }
            _TDB.Close();

            return(_DataItem);
        }