Exemple #1
0
        public List <ContactToRemindDetails> GetAllContacts(string SortBy)
        {
            List <ContactToRemindDetails> _DataItems = new List <ContactToRemindDetails>();

            string _sqlCmd = CONST_SQL_SELECTALLCONTACTS;

            _sqlCmd += (!String.IsNullOrEmpty(SortBy)) ? " ORDER BY " + SortBy : " ORDER BY CompanyName"; // add default order

            TrackerDb   _TDB        = new TrackerDb();
            IDataReader _DataReader = _TDB.ExecuteSQLGetDataReader(_sqlCmd);

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

                    _DataItem.TCCID               = (_DataReader["TCCID"] == DBNull.Value) ? 0 : Convert.ToInt64(_DataReader["TCCID"]);
                    _DataItem.CustomerID          = (_DataReader["CustomerID"] == DBNull.Value) ? 0 : Convert.ToInt64(_DataReader["CustomerID"]);
                    _DataItem.CompanyName         = (_DataReader["CompanyName"] == DBNull.Value) ? string.Empty : _DataReader["CompanyName"].ToString();
                    _DataItem.ContactFirstName    = (_DataReader["ContactFirstName"] == DBNull.Value) ? string.Empty : _DataReader["ContactFirstName"].ToString();
                    _DataItem.ContactAltFirstName = (_DataReader["ContactAltFirstName"] == DBNull.Value) ? string.Empty : _DataReader["ContactAltFirstName"].ToString();
                    _DataItem.CityID              = (_DataReader["CityID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["CityID"]);
                    _DataItem.EmailAddress        = (_DataReader["EmailAddress"] == DBNull.Value) ? string.Empty : _DataReader["EmailAddress"].ToString();
                    _DataItem.AltEmailAddress     = (_DataReader["AltEmailAddress"] == DBNull.Value) ? string.Empty : _DataReader["AltEmailAddress"].ToString();
                    _DataItem.CustomerTypeID      = (_DataReader["CityID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["CityID"]);
                    _DataItem.EquipTypeID         = (_DataReader["EquipTypeID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["EquipTypeID"]);
                    _DataItem.TypicallySecToo     = (_DataReader["TypicallySecToo"] == DBNull.Value) ? false : Convert.ToBoolean(_DataReader["TypicallySecToo"]);
                    _DataItem.PreferedAgentID     = (_DataReader["PreferedAgentID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["PreferedAgentID"]);
                    _DataItem.SalesAgentID        = (_DataReader["SalesAgentID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["SalesAgentID"]);
                    _DataItem.UsesFilter          = (_DataReader["UsesFilter"] == DBNull.Value) ? false : Convert.ToBoolean(_DataReader["UsesFilter"]);
                    _DataItem.enabled             = (_DataReader["enabled"] == DBNull.Value) ? false : Convert.ToBoolean(_DataReader["enabled"]);
                    _DataItem.AlwaysSendChkUp     = (_DataReader["AlwaysSendChkUp"] == DBNull.Value) ? false : Convert.ToBoolean(_DataReader["AlwaysSendChkUp"]);
                    _DataItem.RequiresPurchOrder  = (_DataReader["RequiresPurchOrder"] == DBNull.Value) ? false : Convert.ToBoolean(_DataReader["RequiresPurchOrder"]);
                    _DataItem.ReminderCount       = (_DataReader["ReminderCount"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["ReminderCount"]);
                    _DataItem.NextPrepDate        = (_DataReader["NextPrepDate"] == DBNull.Value) ? DateTime.MaxValue : Convert.ToDateTime(_DataReader["NextPrepDate"]).Date;
                    _DataItem.NextDeliveryDate    = (_DataReader["NextDeliveryDate"] == DBNull.Value) ? DateTime.MaxValue : Convert.ToDateTime(_DataReader["NextDeliveryDate"]).Date;
                    _DataItem.NextCoffee          = (_DataReader["NextCoffee"] == DBNull.Value) ? DateTime.MaxValue : Convert.ToDateTime(_DataReader["NextCoffee"]).Date;
                    _DataItem.NextClean           = (_DataReader["NextClean"] == DBNull.Value) ? DateTime.MaxValue : Convert.ToDateTime(_DataReader["NextClean"]).Date;
                    _DataItem.NextFilter          = (_DataReader["NextFilter"] == DBNull.Value) ? DateTime.MaxValue : Convert.ToDateTime(_DataReader["NextFilter"]).Date;
                    _DataItem.NextDescal          = (_DataReader["NextDescal"] == DBNull.Value) ? DateTime.MaxValue : Convert.ToDateTime(_DataReader["NextDescal"]).Date;
                    _DataItem.NextService         = (_DataReader["NextService"] == DBNull.Value) ? DateTime.MaxValue : Convert.ToDateTime(_DataReader["NextService"]).Date;

                    _DataItems.Add(_DataItem);
                }
                _DataReader.Close();
            }
            _TDB.Close();

            return(_DataItems);
        }
Exemple #2
0
        /// <summary>
        /// Insert Contact item into Temp Header
        /// </summary>
        /// <param name="pHeaderData">Contact Header Data to add</param>
        /// <returns>success or failure</returns>
        public bool InsertContacts(ContactToRemindDetails pHeaderData)
        {
            bool _Success = false;

            TrackerDb _TDB = new TrackerDb();

            #region Parameters
            // Add data sent CustomerId, OrderDate, RoastDate, RequiredByDate, ToBeDeliveredByID, Confirmed, Done, Notes
            _TDB.AddParams(pHeaderData.CustomerID, DbType.Int64, "@CustomerID");
            _TDB.AddParams(pHeaderData.CompanyName, DbType.String, "@CompanyName");
            _TDB.AddParams(pHeaderData.ContactFirstName, DbType.String, "@ContactFirstName");
            _TDB.AddParams(pHeaderData.ContactAltFirstName, DbType.String, "@ContactAltFirstName");
            _TDB.AddParams(pHeaderData.CityID, DbType.Int32, "@CityID");
            _TDB.AddParams(pHeaderData.EmailAddress, DbType.String, "@EmailAddress");
            _TDB.AddParams(pHeaderData.AltEmailAddress, DbType.String, "@AltEmailAddress");
            _TDB.AddParams(pHeaderData.CityID, DbType.Int32, "@CityID");
            _TDB.AddParams(pHeaderData.EquipTypeID, DbType.Int32, "@EquipTypeID");
            _TDB.AddParams(pHeaderData.TypicallySecToo, DbType.Boolean, "@TypicallySecToo");
            _TDB.AddParams(pHeaderData.PreferedAgentID, DbType.Int32, "@PreferedAgentID");
            _TDB.AddParams(pHeaderData.SalesAgentID, DbType.Int32, "@SalesAgentID");
            _TDB.AddParams(pHeaderData.UsesFilter, DbType.Boolean, "@UsesFilter");
            _TDB.AddParams(pHeaderData.enabled, DbType.Boolean, "@enabled");
            _TDB.AddParams(pHeaderData.AlwaysSendChkUp, DbType.Boolean, "@AlwaysSendChkUp");
            _TDB.AddParams(pHeaderData.RequiresPurchOrder, DbType.Boolean, "@RequiresPurchOrder");
            _TDB.AddParams(pHeaderData.ReminderCount, DbType.Int32, "@ReminderCount");
            _TDB.AddParams(pHeaderData.NextPrepDate, DbType.Date, "@NextPrepDate");
            _TDB.AddParams(pHeaderData.NextDeliveryDate, DbType.Date, "@NextDeliveryDate");
            _TDB.AddParams(pHeaderData.NextCoffee, DbType.Date, "@NextCoffee");
            _TDB.AddParams(pHeaderData.NextClean, DbType.Date, "@NextClean");
            _TDB.AddParams(pHeaderData.NextFilter, DbType.Date, "@NextFilter");
            _TDB.AddParams(pHeaderData.NextDescal, DbType.Date, "@NextDescal");
            _TDB.AddParams(pHeaderData.NextService, DbType.Date, "@NextService");
            #endregion

            _Success = String.IsNullOrEmpty(_TDB.ExecuteNonQuerySQL(CONST_SQL_INSERTNEWCONTACTS));
            _TDB.Close();

            return(_Success);
        }