Exemple #1
0
        private void SaveHistory(Enums.HistoryType ht, CapitalRequestBid original, string userID)
        {
            History h = new History();

            h.ObjectTypeName = this.GetType().ToString();
            h.Identifier     = BidID;
            h.ChangeType     = ht;
            h.Active         = true;

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

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

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

            h.Save(userID);
        }
Exemple #2
0
        public void Save(string userID)
        {
            try
            {
                Dictionary <string, string> valErrors = new Dictionary <string, string>();
                if (!Validate(out valErrors))
                {
                    throw new RequisitionNotValidException("Capital Request Bid is not valid", valErrors);
                }

                Enums.HistoryType ht;
                CapitalRequestBid originalBid = null;

                using (PurchasingContext context = ContextHelper.GetDBContext())
                {
                    CapitalRequestBidData data = null;



                    if (BidID > 0)
                    {
                        ht          = Enums.HistoryType.UPDATE;
                        data        = context.CapitalRequestBidDatas.FirstOrDefault(b => b.bid_id == BidID);
                        originalBid = new CapitalRequestBid(data);
                    }
                    else
                    {
                        ht   = Enums.HistoryType.ADD;
                        data = new CapitalRequestBidData();
                    }

                    data.capital_request_id = CapitalRequestID;

                    if (VendorID > 0)
                    {
                        data.vendor_id   = VendorID;
                        data.vendor_name = null;
                    }
                    else
                    {
                        data.vendor_id   = null;
                        data.vendor_name = VendorName;
                    }

                    if (String.IsNullOrWhiteSpace(VendorContactName))
                    {
                        data.vendor_contact_name = null;
                    }
                    else
                    {
                        data.vendor_contact_name = VendorContactName;
                    }

                    if (VendorContactPhone == null || String.IsNullOrWhiteSpace(VendorContactPhone.Number))
                    {
                        data.vendor_contact_phone = null;
                    }
                    else
                    {
                        data.vendor_contact_phone = VendorContactPhone.ToArenaFormat();
                    }


                    if (String.IsNullOrWhiteSpace(VendorContactEmail))
                    {
                        data.vendor_contact_email = null;
                    }
                    else
                    {
                        data.vendor_contact_email = VendorContactEmail;
                    }

                    data.quote_blob_id   = QuoteBlobID;
                    data.bid_amount      = BidAmount;
                    data.active          = Active;
                    data.organization_id = 1;
                    data.modified_by     = userID;
                    data.date_modified   = DateTime.Now;

                    if (BidID == 0)
                    {
                        data.created_by   = userID;
                        data.date_created = DateTime.Now;

                        context.CapitalRequestBidDatas.InsertOnSubmit(data);
                    }

                    context.SubmitChanges();
                    Load(data);
                    SaveHistory(ht, originalBid, userID);
                }
            }
            catch (Exception ex)
            {
                throw new RequisitionException("An error occurred while saving a bid.", ex);
            }
        }