Example #1
0
        private TrackerTools.ContactPreferedItems SetPrepAndDeliveryValues(long pCustomerID)
        {
            DateTime     _DeliveryDate = DateTime.Now.Date;
            TrackerTools _TT           = new classes.TrackerTools(); // . from TrackerDotNet.classes.

            DateTime _dtNextRoastDay = _TT.GetNextRoastDateByCustomerID(pCustomerID, ref _DeliveryDate);

            TrackerTools.ContactPreferedItems _ContactPreferedItems = _TT.RetrieveCustomerPrefs(pCustomerID);

            // set dates
            tbxRoastDate.Text      = String.Format("{0:d}", _dtNextRoastDay);
            tbxRequiredByDate.Text = String.Format("{0:d}", _DeliveryDate);
            // make sure the default delivery person can delvier on that day
            PersonsTbl _Person     = new PersonsTbl();
            int        _DeliveryBy = _Person.IsNormalDeliveryDoW(_ContactPreferedItems.DeliveryByID, (int)(_DeliveryDate.DayOfWeek) + 1) ?
                                     _ContactPreferedItems.DeliveryByID : TrackerTools.CONST_DEFAULT_DELIVERYBYID;

            // ad a note if we changed it
            if (!_DeliveryBy.Equals(_ContactPreferedItems.DeliveryByID))
            {
                tbxNotes.Text += ((tbxNotes.Text.Length > 0) ? " " : "") + "!!!default delivery person changed due to DoW calculation";
            }
            if (ddlToBeDeliveredBy.Items.FindByValue(_DeliveryBy.ToString()) != null)
            {
                ddlToBeDeliveredBy.SelectedValue = _DeliveryBy.ToString();
            }
            if (_ContactPreferedItems.RequiresPurchOrder)
            {
                tbxPurchaseOrder.Text = TrackerTools.CONST_POREQUIRED;
            }

            return(_ContactPreferedItems);
        }
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            QOnT.classes.TrackerTools tt = new classes.TrackerTools();
            DateTime dt = tt.GetClosestNextRoastDate(DateTime.Now);

            lblRoastDate.Text = "<b>Next Roast date:</b> " + dt.ToShortDateString();

            // gvClients.EnableViewState = false;
        }
Example #3
0
        private void InitializeOrderVars()
        {
            QOnT.classes.TrackerTools tt = new classes.TrackerTools();
            DateTime dt = tt.GetClosestNextRoastDate(DateTime.Now);

            OrderValues _MyOrderValues = new OrderValues();

            _MyOrderValues.CustomerID   = 0;
            _MyOrderValues.dtOrder      = DateTime.Now;
            _MyOrderValues.dtRoast      = dt;
            _MyOrderValues.dtRequiredBy = dt.AddDays(1);
            _MyOrderValues.DeliverByID  = Convert.ToInt16(ConfigurationManager.AppSettings["DefaultDeliveryID"]); // mzukisi?
            _MyOrderValues.IsConfirmed  = true;

            Session[SV_ORDERVALUES] = _MyOrderValues;
        }
Example #4
0
        protected void ddlContacts_SelectedIndexChanged(object sender, EventArgs e)
        {
            QOnT.classes.TrackerTools tt = new classes.TrackerTools();
            DropDownList _ddlCustomers   = (DropDownList)sender;
            // roast day vars
            DateTime _dtNextRoastDay;
            DateTime _dtDelivery = DateTime.Now;
            // preference vars;
            Int64 _CustID = Convert.ToInt64(_ddlCustomers.SelectedValue);

            // int _preferredDlvryBy = 3;

            _dtNextRoastDay = tt.GetNextRoastDateByCustomerID(_CustID, ref _dtDelivery);

            tbxRoastDate.Text      = String.Format("{0:d}", _dtNextRoastDay);
            tbxRequiredByDate.Text = String.Format("{0:d}", _dtDelivery);

            // setup values
            SetUpdateBools();
        }
Example #5
0
        protected void ddlCustomer_SelectedIndexChanged(object sender, EventArgs e)
        {
            QOnT.classes.TrackerTools tt = new classes.TrackerTools();
            DropDownList _ddlCustomers   = (DropDownList)sender;
            // roast day vars
            DateTime _dtNextRoastDay; // = Convert.ToDateTime(((TextBox)myDetailsView.FindControl(DV_CONTROL_ROAST_DATE)).Text);
            DateTime _dtDelivery = DateTime.Now;
            // preference vars;
            Int64  _CustID           = Convert.ToInt64(_ddlCustomers.SelectedValue);
            int    _preferredDlvryBy = 1; // = ((DropDownList)myDetailsView.FindControl(DV_CONTROL_DELIVERY_BY)).SelectedValue ;
            int    _preferredItem    = 1; // = ((DropDownList)myDetailsView.FindControl(DV_CONTROL_ITEMDESC)).SelectedValue;
            double _preferredQty     = 1;

            _dtNextRoastDay = tt.GetNextRoastDateByCustomerID(_CustID, ref _dtDelivery);

            tt.RetrieveCustomerPrefs(_CustID, ref _preferredDlvryBy, ref _preferredItem, ref _preferredQty);

            ((TextBox)dvOrderEdit.FindControl(DV_CONTROL_ROAST_DATE)).Text       = String.Format("{0:d}", _dtNextRoastDay);
            ((TextBox)dvOrderEdit.FindControl(DV_CONTROL_REQUIRED_BY_DATE)).Text = String.Format("{0:d}", _dtDelivery);

            DropDownList _ddl = (DropDownList)dvOrderEdit.FindControl(DV_CONTROL_DELIVERY_BY);
            int          i    = 0;

            while ((i < _ddl.Items.Count) && (_ddl.Items[i].Value != _preferredDlvryBy.ToString()))
            {
                i++;
            }
            if (i < _ddl.Items.Count)
            {
                ((DropDownList)dvOrderEdit.FindControl(DV_CONTROL_DELIVERY_BY)).SelectedIndex = i;
            }

            // ((DropDownList)dvOrderEdit.FindControl(DV_CONTROL_DELIVERY_BY)).SelectedValue = _preferredDlvryBy.ToString();
            //((TextBox)dvOrderEdit.FindControl(DV_CONTROL_QTY)).Text = "1";
            ((DropDownList)dvOrderEdit.FindControl(DV_CONTROL_ITEMDESC)).SelectedValue = _preferredItem.ToString();
            ((TextBox)dvOrderEdit.FindControl(DV_CONTROL_QTY)).Text = String.Format("{0:N}", _preferredQty);
        }
Example #6
0
        private List <ContactToRemindWithItems> GetReocurringContacts()
        {
            // General VAR definitions
            List <ContactToRemindWithItems> _ContactsToRemind = new List <ContactToRemindWithItems>();
            TrackerTools _TrackerTools = new classes.TrackerTools(); // . from TrackerDotNet.classes.
            DateTime     _dtTemp       = DateTime.MinValue;
            DateTime     _dtNextRoast  = DateTime.MinValue;

            // get the syustem minimum date for if we are closed
            SysDataTbl _SysData = new SysDataTbl();
            DateTime   _MinDate = _SysData.GetMinReminderDate();

            // 1.
            // make sure the dates in the Reoccuring table match the last delivery date
            ReoccuringOrderDAL _ReoccuringOrderDAL = new ReoccuringOrderDAL();

            // Need to add this to the classs
            if (!_ReoccuringOrderDAL.SetReoccuringItemsLastDate())
            {
                showMessageBox _smb = new showMessageBox(this.Page, "Set Reoccuring Item Last Date", "Could not set the re-occuring last date");
                return(_ContactsToRemind);
            }
            // if we get here we could set the last date  ??????????????

            /* 2. For each enabled record in the ReoccuringTbl:
             *   if the LastDatePerItem + DateAdd(ReocurranceType) < NextCityDeliveryDate
             *     then add them into the temporary reminder table, but set the value in the tempoary reminder table to remember that it is a reoccuring and an auto fulfil.
             */

            // now make sure that only records the are enbabled and need to be added from Reoccuring Are added
            List <ReoccuringOrderExtData> _ReoccuringOrders = _ReoccuringOrderDAL.GetAll(ReoccuringOrderDAL.CONST_ENABLEDONLY, "CustomersTbl.CustomerID"); // -1 is all re

            ///////////// perhaps we should return all details in the above query?
            for (int i = 0; i < _ReoccuringOrders.Count; i++)
            {
                switch (_ReoccuringOrders[i].ReoccuranceTypeID)
                {
                case ReoccuranceTypeTbl.CONST_WEEKTYPEID:
                    _ReoccuringOrders[i].NextDateRequired = _ReoccuringOrders[i].DateLastDone.AddDays(_ReoccuringOrders[i].ReoccuranceValue * 7).Date;
                    break;

                case ReoccuranceTypeTbl.CONST_DAYOFMONTHID:
                    _ReoccuringOrders[i].NextDateRequired = _ReoccuringOrders[i].DateLastDone.AddMonths(1).Date;
                    _ReoccuringOrders[i].NextDateRequired = new DateTime(_ReoccuringOrders[i].NextDateRequired.Year, _ReoccuringOrders[i].NextDateRequired.Month, _ReoccuringOrders[i].ReoccuranceValue).Date;
                    break;

                default:
                    break; // not a type we know so exit
                }
                // disable the order if this is the last time
                if ((_ReoccuringOrders[i].RequireUntilDate > TrackerTools.STATIC_TrackerMinDate) && (_ReoccuringOrders[i].NextDateRequired > _ReoccuringOrders[i].RequireUntilDate))
                {
                    _ReoccuringOrders[i].Enabled = false;
                }

                _dtNextRoast = _TrackerTools.GetNextRoastDateByCustomerID(_ReoccuringOrders[i].CustomerID, ref _dtTemp);
                // check if the the Next roast date is less than the system Minimum date
                if (_dtNextRoast < _MinDate)
                {
                    _dtNextRoast = _MinDate;
                }
                // if DateNext < NextDeliveryDate for client the add to list
                if (_ReoccuringOrders[i].NextDateRequired <= _dtNextRoast)
                {
                    // we have a winner we need to add this item but first check if there is an order for this item type.
                    OrderCheck            _orderCheck    = new OrderCheck();
                    List <OrderCheckData> _OrdersToCheck = _orderCheck.GetSimilarItemInOrders(_ReoccuringOrders[i].CustomerID, _ReoccuringOrders[i].ItemRequiredID,
                                                                                              DateTimeExtensions.GetFirstDayOfWeek(_dtNextRoast),
                                                                                              DateTimeExtensions.GetLastDayOfWeek(_dtNextRoast));
                    if (_OrdersToCheck == null)
                    {
                        // there are no orders that have the same item type

                        ItemContactRequires _ItemRequired = new ItemContactRequires();

                        _ItemRequired.CustomerID   = _ReoccuringOrders[i].CustomerID;
                        _ItemRequired.AutoFulfill  = false; // it is a reoccuring order not auto ff
                        _ItemRequired.ReoccurID    = _ReoccuringOrders[i].ReoccuringOrderID;
                        _ItemRequired.ReoccurOrder = true;  // remember it is from reoccuring
                        _ItemRequired.ItemID       = _ReoccuringOrders[i].ItemRequiredID;
                        _ItemRequired.ItemQty      = _ReoccuringOrders[i].QtyRequired;
                        _ItemRequired.ItemPackagID = _ReoccuringOrders[i].PackagingID;

                        // check if the customer exists
                        if (!_ContactsToRemind.Exists(x => x.CustomerID == _ItemRequired.CustomerID))
                        {
                            ContactToRemindWithItems _ContactToRemind = new ContactToRemindWithItems();
                            _ContactToRemind = _ContactToRemind.GetCustomerDetails(_ItemRequired.CustomerID);
                            _ContactToRemind.ItemsContactRequires.Add(_ItemRequired);
                            _ContactsToRemind.Add(_ContactToRemind);
                        }
                        else
                        {
                            int _ContactIdx = _ContactsToRemind.FindIndex(x => x.CustomerID == _ItemRequired.CustomerID);
                            _ContactsToRemind[_ContactIdx].ItemsContactRequires.Add(_ItemRequired);
                        }
                    }
                    else
                    {
                        List <OrderCheckData> _OrderCheckData = null;
                        // store that and order has identified
                        if (Session[CONST_SESSIONVAR_EXISTINGORDERS] == null)
                        {
                            _OrderCheckData = new List <OrderCheckData>();
                        }
                        else
                        {
                            _OrderCheckData = (List <OrderCheckData>)Session[CONST_SESSIONVAR_EXISTINGORDERS];
                        }

                        for (int j = 0; j < _OrdersToCheck.Count; j++)
                        {
                            _OrderCheckData.Add(_OrdersToCheck[j]);
                        }

//            this.gvReminderOfOrdersPlaced.DataSource = _OrderCheckData;
//            this.gvReminderOfOrdersPlaced.DataBind();
//            Session[CONST_SESSIONVAR_EXISTINGORDERS] = _OrderCheckData;
                    }
                } /// we found an item in reoccuring that we need to send a reminder too
            }

            return(_ContactsToRemind);
        }