Пример #1
0
        protected void gvItems_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            bool _forceUpdate = false;

            if (e.CommandName == "Delete")
            {
                ItemUsageTbl _ItemUsage = new ItemUsageTbl();
                _ItemUsage.ClientUsageLineNo = Convert.ToInt32(e.CommandArgument);
                _ItemUsage.DeleteItemLine(_ItemUsage.ClientUsageLineNo);
                _forceUpdate = true;
            }
            else if (e.CommandName == "Update")
            {
                int _Idx = Convert.ToInt32(e.CommandArgument);

                TextBox      _tbxItemDate          = (TextBox)gvItems.Rows[_Idx].FindControl("tbxItemDate");
                DropDownList _ddlItems             = (DropDownList)gvItems.Rows[_Idx].FindControl("ddlItems");
                TextBox      _tbxAmountProvided    = (TextBox)gvItems.Rows[_Idx].FindControl("tbxAmountProvided");
                DropDownList _ddlPackaging         = (DropDownList)gvItems.Rows[_Idx].FindControl("ddlPackaging");
                TextBox      _tbxPrepTypeID        = (TextBox)gvItems.Rows[_Idx].FindControl("tbxPrepTypeID");
                TextBox      _tbxNotes             = (TextBox)gvItems.Rows[_Idx].FindControl("tbxNotes");
                Label        _lblClientUsageLineNo = (Label)gvItems.Rows[_Idx].FindControl("lblClientUsageLineNo");

                ItemUsageTbl _ItemUsage = new ItemUsageTbl();
                _ItemUsage.ItemDate          = Convert.ToDateTime(_tbxItemDate.Text);
                _ItemUsage.ItemProvidedID    = StringToInt32(_ddlItems.SelectedValue);
                _ItemUsage.AmountProvided    = StringToDouble(_tbxAmountProvided.Text);
                _ItemUsage.PackagingID       = StringToInt32(_ddlPackaging.SelectedValue);
                _ItemUsage.PrepTypeID        = StringToInt32(_tbxPrepTypeID.Text);
                _ItemUsage.Notes             = _tbxNotes.Text;
                _ItemUsage.CustomerID        = StringToInt64(CompanyIDLabel.Text);
                _ItemUsage.ClientUsageLineNo = StringToInt64(_lblClientUsageLineNo.Text);

                _ItemUsage.UpdateItemsUsed(_ItemUsage);

                _forceUpdate = true;
            }

            if (_forceUpdate)
            {
                //bool _ForceBinds = true;
                //Session[CONST_FORCE_GVITEMS_BIND] = _ForceBinds;
                odsItems.Select();
                gvItems.DataBind();
                upnlItems.Update();
            }
        }
Пример #2
0
        protected bool AddLastOrder(bool pSetDates)
        {
            //string _LastOrderSQL, _sFrom, _sWhere;
            //string _sCustID;
            bool _LastOrder = (Session[CONST_LINESADDED] != null) ? (bool)Session[CONST_LINESADDED] : false;

            if (ddlContacts.SelectedValue != null)
            {
                SetUpdateBools();
                // retrieve the last order items from the database.
                long _CustID = Convert.ToInt64(ddlContacts.SelectedValue);
                // if they want us to set the delivery and roast dates
                if (pSetDates)
                {
                    SetPrepAndDeliveryValues(_CustID);
                }

                ItemUsageTbl        _ItemUsage        = new ItemUsageTbl();
                List <ItemUsageTbl> _LastItemsOrdered = _ItemUsage.GetLastItemsUsed(_CustID, TrackerTools.CONST_SERVTYPECOFFEE);

                if (_LastItemsOrdered.Count > 0)
                {
                    foreach (ItemUsageTbl _LastItemOrder in _LastItemsOrdered)
                    {
                        if (_LastItemOrder.ItemProvidedID > 0) // now a a order line
                        {
                            _LastOrder = (AddNewOrderLine(_LastItemOrder.ItemProvidedID, _LastItemOrder.AmountProvided, _LastItemOrder.PackagingID) || (_LastOrder));
                            if (!string.IsNullOrEmpty(_LastItemOrder.Notes))
                            {
                                tbxNotes.Text += String.Format("{0}last order used a group item, so next item in group selected.", (tbxNotes.Text.Length > 0) ? "; " : "");
                            }
                        }
                    }
                }
                else
                {
                    TrackerTools _TT = new TrackerTools();
                    TrackerTools.ContactPreferedItems _ContactPreferedItems = _TT.RetrieveCustomerPrefs(_CustID);
                    _LastOrder = (AddNewOrderLine(_ContactPreferedItems.PreferedItem, _ContactPreferedItems.PreferedQty, _ContactPreferedItems.PrefPackagingID) || (_LastOrder));
                }
                Session[CONST_LINESADDED] = _LastOrder;
            }

            return(_LastOrder);
        }
Пример #3
0
        ContactsUpdated CheckNoneCoffeeCustomer(ContactType pCustomer, ContactsUpdated pContact)
        {
            // customer is a none coffee customer check if this is correct
            ClientUsageLinesTbl _LatestUsageData = new ClientUsageLinesTbl();
            ItemUsageTbl        _LatestItemData  = new ItemUsageTbl();
            // the client is set to not have coffee tracked but has taken coffee check if they have taken anything else
            List <ItemUsageTbl> _LatestCoffeeItems = _LatestItemData.GetLastItemsUsed(pCustomer.CustomerID, TrackerTools.CONST_SERVTYPECOFFEE);

            _LatestItemData = _LatestItemData.GetLastMaintenanceItem(pCustomer.CustomerID);
            if (_LatestCoffeeItems.Count > 0)
            { // they ordered coffee from us but are marked as a none coffee client
                DateTime _InstallDate = _LatestUsageData.GetCustomerInstallDate(pCustomer.CustomerID);
                if (_LatestUsageData.LineDate >= _InstallDate)
                {
                    // there is only coffee for the installation date
                    if (_LatestItemData == null)
                    {
                        pContact.ContactTypeID = CustomerTypeTbl.CONST_INFO_ONLY; // they have no coffee or maint items so they are info only
                    }
                }
                else
                {
                    // they have take coffee past the install date
                    if (_LatestItemData == null)
                    {
                        pContact.ContactTypeID = CustomerTypeTbl.CONST_COFFEE_ONLY; // they have no maint items so they are coffee only
                    }
                }
                // else they should be set correctly
            }
            else
            {
                if (_LatestItemData == null)
                {
                    pContact.ContactTypeID = CustomerTypeTbl.CONST_INFO_ONLY; // they have no coffee or main items so they are info only
                }
            }

            _LatestCoffeeItems.Clear();
            return(pContact);
        }
Пример #4
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");
        }
Пример #5
0
        protected void btnSetClientType_Click(object sender, EventArgs e)
        {
            pnlSetClinetType.Visible = true;
            gvCustomerTypes.Visible  = true;

            List <ContactsUpdated> _ContactsUpdated = new List <ContactsUpdated>();

            ClientUsageLinesTbl _ClientUsageLines = new ClientUsageLinesTbl();
            ItemUsageTbl        _ItemUsageTbl     = new ItemUsageTbl();
            ContactType         _Customer         = new ContactType();

            string _fName = "c:\\temp\\" + String.Format("SetClientType_{0:ddMMyyyy hh mm}.txt", DateTime.Now);

            _ColsStream = new StreamWriter(_fName, false); // create new file
            _ColsStream.WriteLine("Task, Company Name, origType, newType, PredDisabled");
            List <ContactType> _Customers = null;
            int i = 0;

            try
            {
                _Customers = _Customer.GetAllContacts("CompanyName"); // get all client sort by Company name
//        _Customers.RemoveAll(x => !x.IsEnabled);   // delete all the disabled clients

                List <int> _CoffeeClients     = GetAllCoffeeClientTypes();
                List <int> _ServiceOnlyClient = GetAllServiceOnlyClientTypes();

                // for each client check if they have ordered stuff and if so then set them as a particular client

                while (i < _Customers.Count)
                {
                    ContactsUpdated _Contact = new ContactsUpdated();
                    // only if they are enabled and not set to info only
                    if (_Customers[i].CustomerTypeID != CustomerTypeTbl.CONST_INFO_ONLY)
                    {
                        _Contact.ContactName        = _Customers[i].CompanyName;
                        _Contact.ContactTypeID      = _Customers[i].CustomerTypeID;
                        _Contact.origContactTypeID  = _Customers[i].CustomerTypeID;
                        _Contact.PredictionDisabled = _Customers[i].PredictionDisabled;

                        if (_Contact.ContactTypeID == 0) // type not set then assume coffee client.
                        {
                            _Contact.ContactTypeID = CustomerTypeTbl.CONST_COFFEE_ONLY;
                        }
                        // if they are currently marked as coffee client then check if they have ordered since their install date and with in the last year
                        if (_CoffeeClients.Contains(_Contact.ContactTypeID))
                        {
                            _Contact = CheckCoffeeCustomerIsOne(_Customers[i], _Contact);
                        }
                        else // customer is set to only be info or something so lets check if that is true
                        {
                            _Contact = CheckNoneCoffeeCustomer(_Customers[i], _Contact);
                        }
                        /// Has it changed? is fo update
                        if (!_Contact.ContactTypeID.Equals(_Contact.origContactTypeID))
                        {
                            // copy the values that could have change across since C cannot clone with out a class def so we use the temp class instead
                            _Customers[i].CustomerTypeID     = _Contact.ContactTypeID;
                            _Customers[i].PredictionDisabled = _Contact.PredictionDisabled;
                            string _Result = _Customers[i].UpdateContact(_Customers[i]);
                            _ContactsUpdated.Add(_Contact);
                            if (String.IsNullOrEmpty(_Result))
                            {
                                _ColsStream.WriteLine("Added {0}-{1}: {2}, {3}, {4}, {5}", i, _ContactsUpdated.Count, _Contact.ContactName, _Contact.origContactTypeID, _Contact.ContactTypeID, _Contact.PredictionDisabled);
                            }
                            else
                            {
                                _ColsStream.WriteLine("Error {0} Adding: {1}, {2}, {3}, {4}, {5}", _Result, i, _Result, _Contact.ContactName, _Contact.origContactTypeID, _Contact.ContactTypeID, _Contact.PredictionDisabled);
                            }
                        }
                    }
                    i++;
                }
            }
            catch (Exception _ex)
            {
                string _errStr = _ex.Message;

                TrackerTools _TT    = new TrackerTools();
                string       _TTErr = _TT.GetTrackerSessionErrorString();
                if (!String.IsNullOrWhiteSpace(_TTErr))
                {
                    _errStr += " TTError: " + _TTErr;
                }

                showMessageBox _exMsg = new showMessageBox(this.Page, "Error", _errStr);
                if (_Customers != null)
                {
                    _ColsStream.WriteLine("ERROR AT: {0}, Name: {1}, ID: {2}, Pred: {3}", i, _Customers[i].CompanyName, _Customers[i].CustomerTypeID, _Customers[i].PredictionDisabled);
                }
                else
                {
                    _ColsStream.WriteLine("null customers");
                }
                _ColsStream.WriteLine("Error:" + _errStr);
                throw;
            }
            finally
            {
                _ColsStream.Close();
            }

            showMessageBox _sMsg = new showMessageBox(this.Page, "Info", String.Format("A Total of {0}, contacts were updated", _ContactsUpdated.Count));

            ltrlStatus.Text        = String.Format("A Total of {0}, contacts were updated", _ContactsUpdated.Count);
            ltrlStatus.Visible     = true;
            ResultsTitleLabel.Text = "Set client type results";
            gvResults.DataSource   = _ContactsUpdated;
            gvResults.DataBind();
            // upnlSystemToolsButtons.Update();
        }
Пример #6
0
        /// <summary>
        /// Add the actual items to the Usage table and Usage Detail Line from the temp tables checking that the customer
        /// Id is the one that the temp tables are populated with. Also exclude any n/a service types
        /// </summary>
        /// <param name="pCustomerID">for which customer</param>
        /// <param name="pIsActual">is this an actual count</param>
        /// <param name="pCupCount">what is teh starting CupCount</param>
        /// <returns>Cup Count</returns>
        private long AddItemsToClientUsageTbl(long pCustomerID, bool pIsActual, long pCupCount, double pStock, DateTime pDeliveryDate)
        {
            ClientUsageFromTempOrder        _ClientUsageFromTempOrderDAL = new ClientUsageFromTempOrder();
            List <ClientUsageFromTempOrder> _TempOrderDataLines          = _ClientUsageFromTempOrderDAL.GetAll(pCustomerID);
            // create null data records for the tables we are going to populate
            List <ItemUsageTbl>        _ItemUsageLines   = new List <ItemUsageTbl>();
            List <ClientUsageLinesTbl> _ClientUsageLines = new List <ClientUsageLinesTbl>();
            int _LineNo = 0;

            // use the note to make comments in the item usage table
            string _strNotes = (pIsActual) ? "actual count" : "estimate count";

            if (pStock > 0)
            {
                pCupCount  = pCupCount - Convert.ToInt64(pStock * TrackerTools.CONST_TYPICALNUMCUPSPERKG); // adjust cup count so that it reflects stock
                _strNotes += "; Stock of: " + pCupCount.ToString();
            }

            // For every holiday period int he last 6 remove the period from the data difference
            while (_TempOrderDataLines.Count > _LineNo)
            {
//        _strNotes = "";     // clear last notes, ready for new notes

                ClientUsageLinesTbl _ClientUsageItem = new ClientUsageLinesTbl();
                // now calc per item a total
                _ClientUsageItem.CustomerID    = _TempOrderDataLines[_LineNo].CustomerID;
                _ClientUsageItem.LineDate      = pDeliveryDate;
                _ClientUsageItem.ServiceTypeID = _TempOrderDataLines[_LineNo].ServiceTypeID;
                _ClientUsageItem.Qty           = 0;
                _ClientUsageItem.CupCount      = pCupCount;
                _ClientUsageItem.Notes         = _strNotes;

                do
                {
                    // add all quantities for this service type

                    _ClientUsageItem.Qty += (_TempOrderDataLines[_LineNo].Qty * _TempOrderDataLines[_LineNo].UnitsPerQty);
                    ItemUsageTbl _ItemUsageItem = new ItemUsageTbl();
                    // copy line item to an new line in item usage
                    _ItemUsageItem.CustomerID     = _TempOrderDataLines[_LineNo].CustomerID;
                    _ItemUsageItem.Date           = pDeliveryDate;
                    _ItemUsageItem.ItemProvided   = _TempOrderDataLines[_LineNo].ItemID;
                    _ItemUsageItem.AmountProvided = _TempOrderDataLines[_LineNo].Qty;
                    _ItemUsageItem.PackagingID    = _TempOrderDataLines[_LineNo].PackagingID;
                    _ItemUsageItem.Notes          = _strNotes;
                    _ItemUsageLines.Add(_ItemUsageItem);
                    _LineNo++;
                } while ((_TempOrderDataLines.Count > _LineNo) && (_ClientUsageItem.ServiceTypeID == _TempOrderDataLines[_LineNo].ServiceTypeID));

                _ClientUsageLines.Add(_ClientUsageItem);
            }
            // add client usage lineslines
            for (int i = 0; i < _ClientUsageLines.Count; i++)
            {
                _ClientUsageLines[i].InsertItemsUsed(_ClientUsageLines[i]);
            }

            // add item usage lineslines
            for (int i = 0; i < _ItemUsageLines.Count; i++)
            {
                _ItemUsageLines[i].InsertItemsUsed(_ItemUsageLines[i]);
            }
            return(pCupCount);
        }
Пример #7
0
        private void AddAllContactsToRemind(ref List <ContactToRemindWithItems> pContactsToRemind) //, ref List<string> strs, ref List<DateTime> dts)
        {
//      strs.Add("add all the rest of the clients");
//      dts.Add(DateTime.Now);

            /* now add all the rest of the clients
             * /// 3. Then for all the other clies not in the temp table, and have not received reminders today (see below)
             * /// and whose nextrequireddate for each serviceitem is < NextCityDeliveryDate add to temp table
             * /// check if item type is the same and also
             */
            ContactsThatMayNeedNextWeek _ContactsThatMayNeedNextWeek = new control.ContactsThatMayNeedNextWeek();

//      strs.Add("GetContactsThatMayNeedNextWeek");
//      dts.Add(DateTime.Now);
            List <ContactsThayMayNeedData> _ContactsThayMayNeed = _ContactsThatMayNeedNextWeek.GetContactsThatMayNeedNextWeek();

//      List<ContactToRemind> _ContactsToRemind = new List<ContactToRemind>();
            CustomerTrackedServiceItems _CustomterTrackerItem = new CustomerTrackedServiceItems();

//      strs.Add("add them including a check for if they need other items: " + _ContactsThayMayNeedData.Count.ToString());
//      dts.Add(DateTime.Now);
            for (int i = 0; i < _ContactsThayMayNeed.Count; i++)
            {
                ///// now add them including a check for if they need other items.
                List <CustomerTrackedServiceItems.CustomerTrackedServiceItemsData> _ThisCustItems = _CustomterTrackerItem.GetAllByCustomerTypeID(_ContactsThayMayNeed[i].CustomerData.CustomerTypeID);

                ContactToRemindWithItems _ContactToRemind = new ContactToRemindWithItems();

                // copy all data across
                _ContactToRemind.CustomerID          = _ContactsThayMayNeed[i].CustomerData.CustomerID;
                _ContactToRemind.CompanyName         = _ContactsThayMayNeed[i].CustomerData.CompanyName;
                _ContactToRemind.ContactFirstName    = _ContactsThayMayNeed[i].CustomerData.ContactFirstName;
                _ContactToRemind.ContactAltFirstName = _ContactsThayMayNeed[i].CustomerData.ContactAltFirstName;
                _ContactToRemind.EmailAddress        = _ContactsThayMayNeed[i].CustomerData.EmailAddress;
                _ContactToRemind.AltEmailAddress     = _ContactsThayMayNeed[i].CustomerData.AltEmailAddress;
                _ContactToRemind.CityID             = _ContactsThayMayNeed[i].CustomerData.City;
                _ContactToRemind.CustomerTypeID     = _ContactsThayMayNeed[i].CustomerData.CustomerTypeID;
                _ContactToRemind.enabled            = _ContactsThayMayNeed[i].CustomerData.enabled;
                _ContactToRemind.EquipTypeID        = _ContactsThayMayNeed[i].CustomerData.EquipType;
                _ContactToRemind.TypicallySecToo    = _ContactsThayMayNeed[i].CustomerData.TypicallySecToo;
                _ContactToRemind.PreferedAgentID    = _ContactsThayMayNeed[i].CustomerData.PreferedAgent;
                _ContactToRemind.SalesAgentID       = _ContactsThayMayNeed[i].CustomerData.SalesAgentID;
                _ContactToRemind.UsesFilter         = _ContactsThayMayNeed[i].CustomerData.UsesFilter;
                _ContactToRemind.enabled            = _ContactsThayMayNeed[i].CustomerData.enabled;
                _ContactToRemind.AlwaysSendChkUp    = _ContactsThayMayNeed[i].CustomerData.AlwaysSendChkUp;
                _ContactToRemind.RequiresPurchOrder = _ContactsThayMayNeed[i].RequiresPurchOrder;
                _ContactToRemind.ReminderCount      = _ContactsThayMayNeed[i].CustomerData.ReminderCount;
                // prep and delivery dates
                _ContactToRemind.NextPrepDate     = _ContactsThayMayNeed[i].NextRoastDateByCityData.PrepDate.Date;
                _ContactToRemind.NextDeliveryDate = _ContactsThayMayNeed[i].NextRoastDateByCityData.DeliveryDate.Date;

                // usage dates
                /// ClientUsageTbl _ClientUsage = new ClientUsageTbl();

                // _ClientUsage.GetUsageData(_ContactToRemind.CustomerID);
                _ContactToRemind.NextCoffee  = _ContactsThayMayNeed[i].ClientUsageData.NextCoffeeBy.Date;
                _ContactToRemind.NextClean   = _ContactsThayMayNeed[i].ClientUsageData.NextCleanOn.Date;
                _ContactToRemind.NextDescal  = _ContactsThayMayNeed[i].ClientUsageData.NextDescaleEst.Date;
                _ContactToRemind.NextFilter  = _ContactsThayMayNeed[i].ClientUsageData.NextFilterEst.Date;
                _ContactToRemind.NextService = _ContactsThayMayNeed[i].ClientUsageData.NextServiceEst.Date;
                /// now add the items the customer needs.
                DateTime            _dtNextRequired = DateTime.MaxValue;
                ItemUsageTbl        _ItemUsage      = new ItemUsageTbl();
                List <ItemUsageTbl> _LastItemsOrder = null;
                for (int j = 0; j < _ThisCustItems.Count; j++)
                {
                    switch (_ThisCustItems[j].ServiceTypeID)
                    {
                    case TrackerTools.CONST_SERVTYPECOFFEE:
                        _dtNextRequired = _ContactToRemind.NextCoffee;
                        break;

                    case TrackerTools.CONST_SERVTYPECLEAN:
                        _dtNextRequired = _ContactToRemind.NextClean;
                        break;

                    case TrackerTools.CONST_SERVTYPEDESCALE:
                        _dtNextRequired = _ContactToRemind.NextDescal;
                        break;

                    case TrackerTools.CONST_SERVTYPEFILTER:
                        _dtNextRequired = _ContactToRemind.NextFilter;
                        break;

                    case TrackerTools.CONST_SERVTYPESERVICE:
                        _dtNextRequired = _ContactToRemind.NextService;
                        break;

                    default:
                        _dtNextRequired = DateTime.MaxValue;
                        break;
                    }
                    // do a tweak so that if they have had this thing for over year they do not get reminded and then if the will need?
                    if ((_dtNextRequired > DateTime.Now.AddYears(-1)) && (_dtNextRequired <= _ContactsThayMayNeed[i].NextRoastDateByCityData.DeliveryDate))
                    {
                        // add items they are marked as needing
                        _LastItemsOrder = _ItemUsage.GetLastItemsUsed(_ContactsThayMayNeed[i].CustomerData.CustomerID, _ThisCustItems[j].ServiceTypeID);
                        // they are done for needing this item
                        for (int k = 0; k < _LastItemsOrder.Count; k++)
                        {
                            // only add an item if they need that item
                            ItemContactRequires _ItemRequired = new ItemContactRequires();

                            _ItemRequired.CustomerID   = _ContactsThayMayNeed[i].CustomerData.CustomerID;
                            _ItemRequired.AutoFulfill  = _ContactsThayMayNeed[i].CustomerData.autofulfill; // we mark it as an autofulfill so it gets added
                            _ItemRequired.ReoccurID    = 0;                                                /// false it is not from reoccuring
                            _ItemRequired.ItemID       = _LastItemsOrder[k].ItemProvidedID;
                            _ItemRequired.ItemQty      = _LastItemsOrder[k].AmountProvided;
                            _ItemRequired.ItemPackagID = _LastItemsOrder[k].PackagingID;

                            // check if the customer exists
                            if (!pContactsToRemind.Exists(x => x.CustomerID == _ItemRequired.CustomerID))
                            {
                                _ContactToRemind.ItemsContactRequires.Add(_ItemRequired);
                                pContactsToRemind.Add(_ContactToRemind);
                            }
                            else
                            {
                                int _ContactIdx = pContactsToRemind.FindIndex(x => x.CustomerID == _ItemRequired.CustomerID);
                                if (!pContactsToRemind[_ContactIdx].ItemsContactRequires.Exists(x => x.ItemID == _ItemRequired.ItemID))
                                {
                                    // only add an item if it does not exists
                                    pContactsToRemind[_ContactIdx].ItemsContactRequires.Add(_ItemRequired);
                                }
                            }
                        }
                    } // if they need this before the next delivery date.
//          _LastItemsOrder = null;
                }
            }
        }