Ejemplo n.º 1
0
        public List <PaymentTermsTbl> GetAll(string SortBy)
        {
            List <PaymentTermsTbl> _DataItems = new List <PaymentTermsTbl>();
            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())
                {
                    PaymentTermsTbl _DataItem = new PaymentTermsTbl();

                    #region StoreThisDataItem
                    _DataItem.PaymentTermID   = (_DataReader["PaymentTermID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["PaymentTermID"]);
                    _DataItem.PaymentTermDesc = (_DataReader["PaymentTermDesc"] == DBNull.Value) ? string.Empty : _DataReader["PaymentTermDesc"].ToString();
                    _DataItem.PaymentDays     = (_DataReader["PaymentDays"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["PaymentDays"]);
                    _DataItem.DayOfMonth      = (_DataReader["DayOfMonth"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["DayOfMonth"]);
                    _DataItem.UseDays         = (_DataReader["UseDays"] == DBNull.Value) ? false : Convert.ToBoolean(_DataReader["UseDays"]);
                    _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);
        }
Ejemplo n.º 2
0
        public string Update(PaymentTermsTbl pPaymentTermsTbl, int pOrignal_PaymentTermID)
        {
            string    _result = string.Empty;
            TrackerDb _TDB    = new TrackerDb();

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

            _TDB.AddParams(pPaymentTermsTbl.PaymentTermDesc, DbType.String, "@PaymentTermDesc");
            _TDB.AddParams(pPaymentTermsTbl.PaymentDays, DbType.Int32, "@PaymentDays");
            _TDB.AddParams(pPaymentTermsTbl.DayOfMonth, DbType.Int32, "@DayOfMonth");
            _TDB.AddParams(pPaymentTermsTbl.UseDays, DbType.Boolean, "@UseDays");
            _TDB.AddParams(pPaymentTermsTbl.Enabled, DbType.Boolean, "@Enabled");
            _TDB.AddParams(pPaymentTermsTbl.Notes, DbType.String, "@Notes");
            #endregion
            // Now we have the parameters excute the SQL
            _result = _TDB.ExecuteNonQuerySQL(CONST_SQL_UPDATE);
            _TDB.Close();
            return(_result);
        }
Ejemplo n.º 3
0
        public string Insert(PaymentTermsTbl pPaymentTermsTbl)
        {
            string    _result = string.Empty;
            TrackerDb _TDB    = new TrackerDb();

            #region InsertParameters
            _TDB.AddParams(pPaymentTermsTbl.PaymentTermDesc, DbType.String, "@PaymentTermDesc");
            _TDB.AddParams(pPaymentTermsTbl.PaymentDays, DbType.Int32, "@PaymentDays");
            _TDB.AddParams(pPaymentTermsTbl.DayOfMonth, DbType.Int32, "@DayOfMonth");
            _TDB.AddParams(pPaymentTermsTbl.UseDays, DbType.Boolean, "@UseDays");
            _TDB.AddParams(pPaymentTermsTbl.Enabled, DbType.Boolean, "@Enabled");
            _TDB.AddParams(pPaymentTermsTbl.Notes, DbType.String, "@Notes");
            #endregion
            // Now we have the parameters excute the SQL
            _result = _TDB.ExecuteNonQuerySQL(CONST_SQL_INSERT);
            _TDB.Close();
            return(_result);
        }
Ejemplo n.º 4
0
 public string Delete(PaymentTermsTbl pPaymentTermsTbl)
 {
     return(Delete(pPaymentTermsTbl.PaymentTermID));
 }
Ejemplo n.º 5
0
 public string Update(PaymentTermsTbl pPaymentTermsTbl)
 {
     return(Update(pPaymentTermsTbl, 0));
 }