Пример #1
0
        /// <summary>
        /// Adds the specified shipment.
        /// </summary>
        /// <param name="shipment">The shipment.</param>
        /// <returns></returns>
        public tbl_Shipment Add(tbl_Shipment shipment)
        {
            shipment.ID = Guid.NewGuid();
            shipment.CreatedAt = DateTime.Now;
            _dataContext.tbl_Shipment.AddObject(shipment);
            _dataContext.SaveChanges();

            AddHistory(new DataManager(), shipment);            

            return shipment;
        }
Пример #2
0
        /// <summary>
        /// Adds the history.
        /// </summary>
        /// <param name="dataManager">The data manager.</param>
        /// <param name="shipment">The shipment.</param>
        protected void AddHistory(DataManager dataManager, tbl_Shipment shipment)
        {
            var shipmentHistory = new tbl_ShipmentHistory
            {
                ShipmentID = shipment.ID,
                AuthorID = (Guid)CurrentUser.Instance.ContactID,
                SendDate = shipment.SendDate,                
                ShipmentAmount = shipment.ShipmentAmount,
                ShipmentStatusID = shipment.ShipmentStatusID,
                Note = shipment.Note
            };

            dataManager.ShipmentHistory.Add(shipmentHistory);
        }
Пример #3
0
        /// <summary>
        /// Updates the specified shipment.
        /// </summary>
        /// <param name="shipment">The shipment.</param>
        public void Update(tbl_Shipment shipment)
        {
            var dataManager = new DataManager();
            var shipmentInDataBase = dataManager.Shipment.SelectById(shipment.SiteID, shipment.ID);
            shipment.ModifiedAt = DateTime.Now;
            _dataContext.SaveChanges();

            if (shipment.SendDate != shipmentInDataBase.SendDate ||
                shipment.ShipmentAmount != shipmentInDataBase.ShipmentAmount || shipment.ShipmentStatusID != shipmentInDataBase.ShipmentStatusID || 
                shipment.Note != shipmentInDataBase.Note)
            {
                AddHistory(dataManager, shipment);
            }

        //    if (shipment.ShipmentStatusID != shipmentInDataBase.ShipmentStatusID && shipment.ShipmentStatusID == (int)ShipmentStatus.PendingPayment)
        //        ShipmentNotificationService.PendingPayment(shipment.ID);
        }
Пример #4
0
        protected void rbtnGenerateShipment_OnClick(object sender, EventArgs e)
        {
            var shipmentType = _dataManager.ShipmentType.SelectAll(CurrentUser.Instance.SiteID).SingleOrDefault(o => o.IsDefault);

            if (!InvoiceId.HasValue)
            {
                return;
            }

            if (shipmentType == null)
            {
                ucMessage.Text = "Необходимо указать тип документа по умолчанию";
                return;
            }

            var invoice = _dataManager.Invoice.SelectById(InvoiceId.Value);

            var shipment = new tbl_Shipment
            {
                CreatedAt                     = DateTime.Now,
                ShipmentTypeID                = shipmentType.ID,
                ShipmentStatusID              = (int)ShipmentStatus.Prepared,
                Note                          = invoice.Note,
                ExecutorCompanyID             = invoice.ExecutorCompanyID,
                BuyerCompanyID                = invoice.BuyerCompanyID,
                ExecutorCompanyLegalAccountID = invoice.ExecutorCompanyLegalAccountID,
                BuyerCompanyLegalAccountID    = invoice.BuyerCompanyLegalAccountID,
                BuyerContactID                = invoice.BuyerContactID,
                ExecutorContactID             = invoice.ExecutorContactID,
                SendDate                      = null,
                PriceListID                   = null,
                OrderID                       = invoice.OrderID,
                ShipmentAmount                = invoice.InvoiceAmount
            };



            shipment.tbl_Invoice.Clear();
            shipment.tbl_Invoice.Add(invoice);
            shipment.SiteID  = invoice.SiteID;
            shipment.OwnerID = CurrentUser.Instance.ContactID;
            var documentNumerator = DocumentNumerator.GetNumber((Guid)shipmentType.NumeratorID,
                                                                shipment.CreatedAt,
                                                                shipmentType.tbl_Numerator.Mask, "tbl_Shipment");

            shipment.Number       = documentNumerator.Number;
            shipment.SerialNumber = documentNumerator.SerialNumber;

            foreach (var product in invoice.tbl_InvoiceProducts.ToList())
            {
                var shipmentProduct = new tbl_ShipmentProducts
                {
                    ID                      = Guid.NewGuid(),
                    Amount                  = product.Amount,
                    AnyProductName          = product.AnyProductName,
                    CurrencyAmount          = product.CurrencyAmount,
                    CurrencyDiscountAmount  = product.CurrencyDiscountAmount,
                    CurrencyID              = product.CurrencyID,
                    CurrencyPrice           = product.CurrencyPrice,
                    CurrencyTotalAmount     = product.CurrencyTotalAmount,
                    Discount                = product.Discount,
                    DiscountAmount          = product.DiscountAmount,
                    Price                   = product.Price,
                    PriceListID             = product.PriceListID,
                    ProductID               = product.ProductID,
                    Quantity                = product.Quantity,
                    Rate                    = product.Rate,
                    SerialNumber            = product.SerialNumber,
                    ShipmentID              = shipment.ID,
                    SpecialOfferPriceListID = product.SpecialOfferPriceListID,
                    TaskID                  = product.TaskID,
                    TotalAmount             = product.TotalAmount,
                    UnitID                  = product.UnitID
                };

                shipment.tbl_ShipmentProducts.Add(shipmentProduct);
            }

            _dataManager.Shipment.Add(shipment);

            Response.Redirect(UrlsData.AP_ShipmentEdit(shipment.ID));
        }