Пример #1
0
        public List <InvoiceTypeTbl> GetAll(string SortBy)
        {
            List <InvoiceTypeTbl> _DataItems = new List <InvoiceTypeTbl>();
            TrackerDb             _TDB       = new TrackerDb();
            string _sqlCmd = CONST_SQL_SELECT;

            if (!String.IsNullOrEmpty(SortBy))
            {
                _sqlCmd += " ORDER BY " + SortBy;                              // Add order by string
            }
            // params would go here if need
            IDataReader _DataReader = _TDB.ExecuteSQLGetDataReader(_sqlCmd);

            if (_DataReader != null)
            {
                while (_DataReader.Read())
                {
                    InvoiceTypeTbl _DataItem = new InvoiceTypeTbl();

                    #region StoreThisDataItem
                    _DataItem.InvoiceTypeID   = (_DataReader["InvoiceTypeID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["InvoiceTypeID"]);
                    _DataItem.InvoiceTypeDesc = (_DataReader["InvoiceTypeDesc"] == DBNull.Value) ? string.Empty : _DataReader["InvoiceTypeDesc"].ToString();
                    _DataItem.Enabled         = (_DataReader["Enabled"] == DBNull.Value) ? false : Convert.ToBoolean(_DataReader["Enabled"]);
                    _DataItem.Notes           = (_DataReader["Notes"] == DBNull.Value) ? string.Empty : _DataReader["Notes"].ToString();
                    #endregion
                    _DataItems.Add(_DataItem);
                }
                _DataReader.Close();
            }
            _TDB.Close();
            return(_DataItems);
        }
Пример #2
0
        public string Insert(InvoiceTypeTbl pInvoiceTypeTbl)
        {
            string _result = string.Empty;

            if (pInvoiceTypeTbl.InvoiceTypeID > 0)
            {
                // they have called insert by mistake ( or the environment has)
                _result = Update(pInvoiceTypeTbl, 0);
            }
            else
            {
                TrackerDb _TDB = new TrackerDb();

                #region InsertParameters
                _TDB.AddParams(pInvoiceTypeTbl.InvoiceTypeDesc, DbType.String, "@InvoiceTypeDesc");
                _TDB.AddParams(pInvoiceTypeTbl.Enabled, DbType.Boolean, "@Enabled");
                _TDB.AddParams(pInvoiceTypeTbl.Notes, DbType.String, "@Notes");
                #endregion
                // Now we have the parameters excute the SQL
                _result = _TDB.ExecuteNonQuerySQL(CONST_SQL_INSERT);
                _TDB.Close();
            }
            return(_result);
        }
Пример #3
0
        public string Update(InvoiceTypeTbl pInvoiceTypeTbl, int pOrignal_InvoiceTypeID)
        {
            string    _result = string.Empty;
            TrackerDb _TDB    = new TrackerDb();

            #region UpdateParameters
            if (pOrignal_InvoiceTypeID > 0)
            {
                _TDB.AddWhereParams(pOrignal_InvoiceTypeID, DbType.Int32); // check this line it assumes id field is int32
            }
            else
            {
                _TDB.AddWhereParams(pInvoiceTypeTbl.InvoiceTypeID, DbType.Boolean, "@InvoiceTypeID");
            }

            _TDB.AddParams(pInvoiceTypeTbl.InvoiceTypeDesc, DbType.String, "@InvoiceTypeDesc");
            _TDB.AddParams(pInvoiceTypeTbl.Enabled, DbType.Boolean, "@Enabled");
            _TDB.AddParams(pInvoiceTypeTbl.Notes, DbType.String, "@Notes");
            #endregion
            // Now we have the parameters excute the SQL
            _result = _TDB.ExecuteNonQuerySQL(CONST_SQL_UPDATE);
            _TDB.Close();
            return(_result);
        }
Пример #4
0
 public string Delete(InvoiceTypeTbl pInvoiceType)
 {
     return(Delete(pInvoiceType.InvoiceTypeID));
 }
Пример #5
0
 public string Update(InvoiceTypeTbl pInvoiceTypeTbl)
 {
     return(Update(pInvoiceTypeTbl, 0));
 }