Пример #1
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (tbxGroupItem.Text.Equals(string.Empty))
            {
                showMessageBox _MsgBox = new showMessageBox(this.Page, "Error no item", "Please enter a Group Item Name");
            }
            else
            {
                TrackerDotNet.control.ItemTypeTbl _ITT = new ItemTypeTbl();

                if (_ITT.GroupOfThisNameExists(tbxGroupItem.Text))
                {
                    showMessageBox _MsgBox = new showMessageBox(this.Page, "name exists", "Group Name: " + tbxGroupItem.Text + " Exists. Please enter a different Group Item Name");
                }
                else
                {
                    SysDataTbl _SysData = new SysDataTbl();

                    _ITT.ItemDesc            = tbxGroupItem.Text;
                    _ITT.ItemDetail          = tbxGroupDesc.Text;
                    _ITT.ItemEnabled         = true;
                    _ITT.ItemsCharacteritics = "Group Item";
                    _ITT.ItemShortName       = tbxGroupShortName.Text;
                    _ITT.ServiceTypeID       = _SysData.GetGroupItemTypeID();
                    _ITT.SortOrder           = ItemTypeTbl.CONST_NEEDDESCRIPTION_SORT_ORDER + 5;

                    bool           _success = _ITT.InsertItem(_ITT);
                    showMessageBox _MsgBox  = new showMessageBox(this.Page, "Status", _success ? "Group item added" : "Error adding group item");
                    ReturnToPrevPage();
                }
            }
        }
Пример #2
0
// - code for update
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            if (tbxGroupItem.Text.Equals(string.Empty))
            {
                showMessageBox _MsgBox = new showMessageBox(this.Page, "Error no item", "Please enter a Group Item Name");
            }
            else
            {
                TrackerDotNet.control.ItemTypeTbl _ITT = new ItemTypeTbl();

                SysDataTbl _SysData = new SysDataTbl();

                _ITT.ItemDesc            = tbxGroupItem.Text;
                _ITT.ItemDetail          = tbxGroupDesc.Text;
                _ITT.ItemEnabled         = true;
                _ITT.ItemsCharacteritics = "Group Item-update";
                _ITT.ItemShortName       = tbxGroupShortName.Text;
                _ITT.ServiceTypeID       = _SysData.GetGroupItemTypeID();
                _ITT.SortOrder           = ItemTypeTbl.CONST_NEEDDESCRIPTION_SORT_ORDER + 5;
                _ITT.ItemTypeID          = Convert.ToInt32(lblGroupItemID.Text);
                bool           _success = _ITT.UpdateItem(_ITT);
                showMessageBox _MsgBox  = new showMessageBox(this.Page, "Status", _success ? "Group item update" : "Error updating group item");
                ReturnToPrevPage();
            }
        }
Пример #3
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);
        }