Example #1
0
        public void SaveHistory(Enums.HistoryType changeType, ReceiptItem original, string uid)
        {
            History h = new History();

            h.ObjectTypeName = this.GetType().ToString();
            h.Identifier     = ReceiptItemID;
            h.OrganizationID = POItem.PurchaseOrder.OrganizationID;
            h.ChangeType     = changeType;

            switch (changeType)
            {
            case org.secc.Purchasing.Enums.HistoryType.ADD:
                h.OriginalXML = null;
                h.UpdatedXML  = Serialize(this);
                break;

            case org.secc.Purchasing.Enums.HistoryType.UPDATE:
                h.OriginalXML = Serialize(original);
                h.UpdatedXML  = Serialize(this);
                break;

            case org.secc.Purchasing.Enums.HistoryType.DELETE:
                h.OriginalXML = Serialize(this);
                h.UpdatedXML  = null;
                break;
            }

            h.Active = true;
            h.Save(uid);
        }
Example #2
0
        public void Save(string uid)
        {
            try
            {
                if (String.IsNullOrEmpty(uid))
                {
                    throw new ArgumentNullException("UID", "User ID is required.");
                }
                using (PurchasingContext Context = ContextHelper.GetDBContext())
                {
                    Enums.HistoryType ChangeType;
                    ReceiptItem       Original = null;
                    ReceiptItemData   Data;

                    if (ReceiptItemID <= 0)
                    {
                        Data              = new ReceiptItemData();
                        ChangeType        = Enums.HistoryType.ADD;
                        Data.date_created = DateTime.Now;
                        Data.created_by   = uid;
                    }
                    else
                    {
                        Data       = Context.ReceiptItemDatas.FirstOrDefault(x => x.receipt_item_id == ReceiptItemID);
                        Original   = new ReceiptItem(Data);
                        ChangeType = Enums.HistoryType.UPDATE;
                    }

                    Data.receipt_id             = ReceiptID;
                    Data.purchase_order_item_id = POItemID;
                    Data.quantity_received      = QuantityReceived;
                    Data.date_modified          = DateTime.Now;
                    Data.modified_by            = uid;
                    Data.active = Active;

                    if (ReceiptItemID <= 0)
                    {
                        Context.ReceiptItemDatas.InsertOnSubmit(Data);
                    }

                    Context.SubmitChanges();

                    Load(Data);

                    SaveHistory(ChangeType, Original, uid);
                }
            }
            catch (Exception ex)
            {
                throw new RequisitionException("An error has occureed while saving receipt item.", ex);
            }
        }
Example #3
0
        public void ReceivePackage(int receivedByID, int carrierLUID, string dateReceivedStr, Dictionary <int, int> itemsToReceive, string uid)
        {
            Receipt r = new Receipt();

            r.PurchaseOrderID = PurchaseOrderID;
            r.CarrierLUID     = carrierLUID;
            r.ReceivedByID    = receivedByID;
            DateTime tempDateReceived;

            DateTime.TryParse(dateReceivedStr, out tempDateReceived);
            r.DateReceived = tempDateReceived;
            r.Active       = true;

            r.Save(uid);

            foreach (var item in itemsToReceive)
            {
                ReceiptItem ri = new ReceiptItem();
                ri.ReceiptID        = r.ReceiptID;
                ri.POItemID         = item.Key;
                ri.QuantityReceived = item.Value;
                ri.Active           = true;
                ri.Save(uid);
            }

            RefreshReceipts();
            bool isPartiallyReceived = false;
            bool isFullyReceived     = HasBeenReceived(out isPartiallyReceived, uid);

            if (isFullyReceived)
            {
                StatusLUID   = PurchaseOrderStatusReceivedLUID();
                DateReceived = DateTime.Now;
            }
            else if (isPartiallyReceived)
            {
                StatusLUID = PurchaseOrderStatusPartiallyReceivedLUID();
            }

            Save(uid);
        }