コード例 #1
0
        // --- ALL Pure retrieval rotuines below, the do a simple Query and return the data, and a prefixed with Get

        /// <summary>
        /// Get the latest usage data from the client usage table
        /// </summary>
        /// <param name="pCustomerID">which customer</param>
        /// <param name="pServiceTypeID">which service type of data , or "" for no service type</param>
        /// <returns></returns>
        public LineUsageData GetLatestUsageData(long pCustomerID, int pServiceTypeID)
        {
            LineUsageData _LatestUsageData = new LineUsageData();

            ClientUsageLinesTbl _UsageData = new ClientUsageLinesTbl();

            _UsageData = _UsageData.GetLatestUsageData(pCustomerID, pServiceTypeID);

            if (_UsageData.CupCount > 0)
            {
                _LatestUsageData.LastCount = _UsageData.CupCount;
                _LatestUsageData.LastQty   = _UsageData.Qty;
                _LatestUsageData.UsageDate = _UsageData.LineDate;
            }

            return(_LatestUsageData);
        }
コード例 #2
0
        ContactsUpdated CheckCoffeeCustomerIsOne(ContactType pCustomer, ContactsUpdated pContact)
        {
            // if the customer type is set not to be reminded about coffee
            ClientUsageLinesTbl _LatestUsageData = new ClientUsageLinesTbl();
            ItemUsageTbl        _LatestItemData  = new ItemUsageTbl();
            DateTime            _InstallDate     = DateTime.MinValue;

            _LatestUsageData = _LatestUsageData.GetLatestUsageData(pCustomer.CustomerID, TrackerDotNet.classes.TrackerTools.CONST_SERVTYPECOFFEE);
            if (_LatestUsageData != null)
            {
                _InstallDate = _LatestUsageData.GetCustomerInstallDate(pCustomer.CustomerID);
                if (_LatestUsageData.LineDate <= _InstallDate)
                {
                    // they have not ordered since the first time, so are they a service client?
                    _LatestItemData = _LatestItemData.GetLastMaintenanceItem(pCustomer.CustomerID);
                    if (_LatestItemData == null)
                    { // they have not ordered since the first order so set prediction to disabled
                        pContact.ContactTypeID      = CustomerTypeTbl.CONST_INFO_ONLY;
                        pContact.PredictionDisabled = true;
                    }
                    else // they have ordered other stuff from us but not coffee
                    {
                        pContact.ContactTypeID = CustomerTypeTbl.CONST_SERVICE_ONLY; // set it to the first time of service ony client
                    }
                }
                else
                {
                    // they have ordered coffee have they ordered anything else, and they have been a client for long enough?
                    if (_InstallDate.AddMonths(CONST_MINMONTHS) <= _LatestUsageData.LineDate)
                    {
                        // we have a client that has been ordering for a while if they have not ordered maint stuff then sert them as coffee only or green only
                        _LatestItemData = _LatestItemData.GetLastMaintenanceItem(pCustomer.CustomerID);
                        if (_LatestItemData == null)
                        {
                            pContact.ContactTypeID = CustomerTypeTbl.CONST_COFFEE_ONLY;
                        }
                        else
                        { // they have ordered other stuff if they are set to coffee only set them to something else
                            if (pContact.ContactTypeID == CustomerTypeTbl.CONST_COFFEE_ONLY)
                            {
                                pContact.ContactTypeID = CustomerTypeTbl.CONST_COFFEEANDMAINT; // not they will be reminded of maintenance too
                            }
                        }
                    }
                    else
                    {
                    }
                }
            }
            else
            {
                // they have no coffee in thier list are they a none coffee client?
                _LatestItemData = _LatestItemData.GetLastMaintenanceItem(pCustomer.CustomerID);
                if (_LatestItemData != null)
                {
                    // they have ordered maitenance stuff but not coffee stuff before
                    pContact.ContactTypeID = CustomerTypeTbl.CONST_SERVICE_ONLY; // set it to the first time of service ony client
                }
                else
                {
                    pContact.ContactTypeID = CustomerTypeTbl.CONST_INFO_ONLY; // nothing has been ordered so set as prediction
                }
            }
            return(pContact);
            //_ColsStream.WriteLine("CheckCoffeeCustomerIsOne: 16");
        }