public List <PersonsTbl> GetAll(string SortBy) { List <PersonsTbl> _DataItems = new List <PersonsTbl>(); string _connectionStr = ConfigurationManager.ConnectionStrings[CONST_CONSTRING].ConnectionString; using (OleDbConnection _conn = new OleDbConnection(_connectionStr)) { string _sqlCmd = CONST_SQL_SELECT; if (!String.IsNullOrEmpty(SortBy)) { _sqlCmd += " ORDER BY " + SortBy; // Add order by string } else { _sqlCmd += " ORDER BY Abreviation"; // add default order } OleDbCommand _cmd = new OleDbCommand(_sqlCmd, _conn); // run the qurey we have built _conn.Open(); OleDbDataReader _DataReader = _cmd.ExecuteReader(); while (_DataReader.Read()) { PersonsTbl _DataItem = new PersonsTbl(); _DataItem.PersonID = (_DataReader["PersonID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["PersonID"]); _DataItem.Person = (_DataReader["Person"] == DBNull.Value) ? string.Empty : _DataReader["Person"].ToString(); _DataItem.Abreviation = (_DataReader["Abreviation"] == DBNull.Value) ? string.Empty : _DataReader["Abreviation"].ToString(); _DataItem.Enabled = (_DataReader["Enabled"] == DBNull.Value) ? false : Convert.ToBoolean(_DataReader["Enabled"]); _DataItems.Add(_DataItem); } } return(_DataItems); }
/// <summary> /// Insert an item into the log using the securityusername /// </summary> /// <param name="pSecurityUserName">security user name as per the Members table</param> /// <param name="pSectionID">Section's ID</param> /// <param name="pTranasctionTypeID">Transaction's Type ID</param> /// <param name="pDetails">Detai of what was done</param> /// <param name="pNotes">Notes of what was done</param> /// <returns>if the item was insertted</returns> public bool InsertLogItem(string pSecurityUserName, int pSectionID, int pTransactionTypeID, long pCustomerID, string pDetails, string pNotes) { bool _inserted = false; PersonsTbl _Persons = new PersonsTbl(); int _SecurityUserID = _Persons.PersonsIDoFSecurityUsers(pSecurityUserName); TrackerDb _TDB = new TrackerDb(); _TDB.AddParams(DateTime.Now, DbType.Date); _TDB.AddParams(_SecurityUserID, DbType.Int32); _TDB.AddParams(pSectionID, DbType.Int32); _TDB.AddParams(pTransactionTypeID, DbType.Int32); _TDB.AddParams(pCustomerID, DbType.Int64); _TDB.AddParams(pDetails); _TDB.AddParams(pNotes); _inserted = string.IsNullOrWhiteSpace(_TDB.ExecuteNonQuerySQL(CONST_SQL_INSERT)); _TDB.Close(); return(_inserted); }