Ejemplo n.º 1
0
        /// <summary>
        /// Handles the OnClick event of the lbtnSendShipment control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void lbtnSendShipment_OnClick(object sender, EventArgs e)
        {
            //if (chxForBuyer.Checked && ucSendShipmentBuyerContact.SelectedValue.HasValue)
            //    ShipmentNotificationService.SendToContact(_shipmentId, ucSendShipmentBuyerContact.SelectedValue.Value);

            //if (chxForExecutor.Checked && ucSendShipmentExecutorContact.SelectedValue.HasValue)
            //    ShipmentNotificationService.SendToContact(_shipmentId, ucSendShipmentExecutorContact.SelectedValue.Value);

            Response.Redirect(UrlsData.AP_ShipmentEdit(_shipmentId));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Handles the OnItemDataBound event of the gridInvoices control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Telerik.Web.UI.GridItemEventArgs"/> instance containing the event data.</param>
        protected void gridInvoices_OnItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                if (access == null)
                {
                    access = Access.Check();
                }

                var item = (GridDataItem)e.Item;
                var data = (DataRowView)e.Item.DataItem;

                var hlTitle = (HyperLink)item.FindControl("hlTitle");
                hlTitle.Text = string.Format("Счет №{0} от {1}", data["tbl_Invoice_Number"], DateTime.Parse(data["tbl_Invoice_CreatedAt"].ToString()).ToString("dd/MM/yyyy"));
                ((HyperLink)item.FindControl("hlEdit")).NavigateUrl  = hlTitle.NavigateUrl = UrlsData.AP_InvoiceEdit(Guid.Parse(data["tbl_Invoice_ID"].ToString()));
                ((Literal)item.FindControl("lrlInvoiceAmount")).Text = decimal.Parse(data["tbl_Invoice_InvoiceAmount"].ToString()).ToString("F");
                ((Literal)item.FindControl("lrlNote")).Text          = data["tbl_Invoice_Note"].ToString();
                ((Literal)item.FindControl("lrlInvoiceStatus")).Text = EnumHelper.GetEnumDescription((InvoiceStatus)int.Parse(data["tbl_Invoice_InvoiceStatusID"].ToString()));
                if (!string.IsNullOrEmpty(data["tbl_Invoice_PaymentDateActual"].ToString()))
                {
                    ((Literal)item.FindControl("lrlPaymentDateActual")).Text = DateTime.Parse(data["tbl_Invoice_CreatedAt"].ToString()).ToString("dd/MM/yyyy");
                }
                else
                {
                    ((Literal)item.FindControl("lrlPaymentDateActual")).Text = "---";
                }

                if (!string.IsNullOrEmpty(data["tbl_Company_Name"].ToString()))
                {
                    ((Literal)item.FindControl("lrlCompany")).Text = string.Format("<a href=\"{0}\">{1}</a>", UrlsData.AP_Company(Guid.Parse(data["tbl_Company_ID"].ToString())), data["tbl_Company_Name"]);
                }

                if (!string.IsNullOrEmpty(data["tbl_CompanyLegalAccount_Title"].ToString()))
                {
                    ((Literal)item.FindControl("lrlCompanyLegalAccount")).Text = data["tbl_CompanyLegalAccount_Title"].ToString();
                }

                var lbDelete = (LinkButton)e.Item.FindControl("lbDelete");
                lbDelete.CommandArgument = data["ID"].ToString();
                lbDelete.Command        += lbDelete_OnCommand;

                lbDelete.Visible = access.Delete;

                var invoice = DataManager.Invoice.SelectById(Guid.Parse(data["tbl_Invoice_ID"].ToString()));
                if (invoice.tbl_Shipment.Any())
                {
                    ((Literal)item.FindControl("lrlShipments")).Text =
                        string.Format("<div class=\"span-url\">Отгрузки: {0}</div>",
                                      string.Join(", ", invoice.tbl_Shipment.Select(
                                                      o =>
                                                      string.Format("<a href=\"{0}\">Отгрузка №{1} от {2}</a>", UrlsData.AP_ShipmentEdit(o.ID), o.Number, o.CreatedAt.ToString("dd.MM.yyyy")))));
                }
            }
        }
Ejemplo n.º 3
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));
        }