Example #1
0
        private bool LogARepair(RepairsTbl pRepair, bool pCalcOrderData)
        {
            bool _Success = false;
            // create a new order for delivery [RoastDate]
            OrderTblData _OrderData      = new OrderTblData();
            DateTime     _RequiredByDate = DateTime.Now.Date.AddDays(7);

            // add the default data to order
            _OrderData.CustomerId      = pRepair.CustomerID;
            _OrderData.ItemTypeID      = ItemTypeTbl.CONST_SERVICEITEMID;
            _OrderData.QuantityOrdered = 1;
            _OrderData.Notes           = "Collect/Swop out Machine for Service";

            // Calculate the Data from the customer details
            if (pCalcOrderData)
            {
                TrackerTools _TT = new TrackerTools();
                _OrderData.RoastDate = _TT.GetNextRoastDateByCustomerID(pRepair.CustomerID, ref _RequiredByDate);
                TrackerTools.ContactPreferedItems _ContactPreferedItems = _TT.RetrieveCustomerPrefs(pRepair.CustomerID);

                _OrderData.OrderDate      = DateTime.Now.Date;
                _OrderData.RequiredByDate = _RequiredByDate;
                if (_ContactPreferedItems.RequiresPurchOrder)
                {
                    _OrderData.PurchaseOrder = TrackerTools.CONST_POREQUIRED;
                }
                _OrderData.ToBeDeliveredBy = _ContactPreferedItems.DeliveryByID;
            }
            else
            {
                _OrderData.RoastDate      = _OrderData.OrderDate = DateTime.Now.Date;
                _OrderData.RequiredByDate = _RequiredByDate;
            }
            // save the data to the orders
            OrderTbl _Order = new OrderTbl();

            _Order.InsertNewOrderLine(_OrderData);
            pRepair.RelatedOrderID = _Order.GetLastOrderAdded(_OrderData.CustomerId, _OrderData.OrderDate, ItemTypeTbl.CONST_SERVICEITEMID);

            return(_Success);
        }