예제 #1
0
        protected void ArticleRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            var ee = new ArticleRepeaterItemEventArgs(e);

            String detailsUrl = PageUrlAttribute.Get <Articles.Details>(new Articles.Details.Query()
            {
                Article = ee.Data, SearchTerm = this.RequestAddOn.Query.SearchTerm
            });

            ee.DetailsLink1.NavigateUrl = detailsUrl;

            String ebayUrl = PageUrlAttribute.Get <Articles.Ebay>(new Articles.Ebay.Query()
            {
                Article = ee.Data, SearchTerm = this.RequestAddOn.Query.SearchTerm
            });

            ee.EbayLink1.NavigateUrl = ebayUrl;

            String editUrl = PageUrlAttribute.Get <Articles.Edit>(new Articles.Edit.Query()
            {
                Article = ee.Data, SearchTerm = this.RequestAddOn.Query.SearchTerm
            });

            ee.EditLink1.NavigateUrl = editUrl;

            ee.MaterialGroupLabel.Text              = ee.Data.MaterialGroup.Name;
            ee.ArticleNumberLabel.Text              = ee.Data.ArticleNumber;
            ee.EANLabel.Text                        = ee.Data.EAN;
            ee.NameInternLabel.Text                 = ee.Data.NameIntern;
            ee.Image1Picture.ImageUrl               = ee.Data.GetPictureUrl(0);
            ee.PurchasePriceLabel.Text              = ee.Data.GetPurchasePriceInEuro().ToString("C");
            ee.SellingPriceGrossLabel.Text          = ee.Data.SellingPriceGross.ToString("C");
            ee.SellingPriceWholesaleGrossLabel.Text = ee.Data.SellingPriceWholesaleGross.ToString("C");
            ee.SupplierLabel.Text                   = ee.Data.Supplier.Name;
            ee.SupplierArticleNumberLabel.Text      = ee.Data.SupplierArticleNumber;
            ee.AmountOnStockLabel.Text              = ArticleFormatter.ToStringStockAmount(ee.Data);
            ee.AmountOnStockEbayLabel.Text          = ArticleFormatter.ToStringEbayStockAmount(ee.Data);
            ee.AmountOnStockMagentoLabel.Text       = ee.Data.SyncMagento.ToString("0");
            ee.IsInEbayCheckBox.Checked             = ee.Data.IsInEbay;
            ee.IsInMagentoCheckBox.Checked          = ee.Data.IsInMagento;

            ee.DeleteButton.CommandArgument = ee.Data.Id.ToString();
            ee.DeleteButton.Text            = ee.Data.IsDeleted ? StringTable.Reactivate : StringTable.Delete;

            if (ee.Data.IsDeleted)
            {
                for (int index = 1; index < e.Item.Controls.Count - 1; index++)
                {
                    if (e.Item.Controls[index] is WebControl && !(e.Item.Controls[index] is LinkButton) && !(e.Item.Controls[index] is HyperLink))
                    {
                        (e.Item.Controls[index] as WebControl).Font.Strikeout = true;
                    }
                }
            }
        }
        //Methods
        #region Page_PreRender
        protected void Page_PreRender(object sender, EventArgs e)
        {
            this.BackToListLink.NavigateUrl = PageUrlAttribute.Get <Articles.Default>(new Articles.Default.Query()
            {
                SearchTerm = this.RequestAddOn.Query.SearchTerm
            });
            this.EditLink1.NavigateUrl = PageUrlAttribute.Get <Articles.Edit>(new Articles.Edit.Query()
            {
                Article = this.RequestAddOn.Query.Article, SearchTerm = this.RequestAddOn.Query.SearchTerm
            });
            this.EditLink2.NavigateUrl = PageUrlAttribute.Get <Articles.Edit>(new Articles.Edit.Query()
            {
                Article = this.RequestAddOn.Query.Article, SearchTerm = this.RequestAddOn.Query.SearchTerm
            });

            Article current = this.RequestAddOn.Query.Article;

            //Data
            this.ArticleNumberLabel.Text         = current.ArticleNumber;
            this.EANLabel.Text                   = current.EAN;
            this.MaterialGroupLabel.Text         = current.MaterialGroup.Name;
            this.NameInternLabel.Text            = current.NameIntern;
            this.NameGermanLabel.Text            = current.NameGerman;
            this.NameEnglishLabel.Text           = current.NameEnglish;
            this.DescriptionGermanLabel.Text     = current.DescriptionGerman;
            this.DescriptionEnglishLabel.Text    = current.DescriptionEnglish;
            this.Image1Image.ImageUrl            = current.GetPictureUrl(0);
            this.Image2Image.ImageUrl            = current.GetPictureUrl(1);
            this.Image3Image.ImageUrl            = current.GetPictureUrl(2);
            this.Picture1Panel.Visible           = current.PictureName1.Length > 0;
            this.Picture2Panel.Visible           = current.PictureName2.Length > 0;
            this.Picture3Panel.Visible           = current.PictureName3.Length > 0;
            this.HeightLabel.Text                = current.Height.ToString("0.0");
            this.WidthLabel.Text                 = current.Width.ToString("0.0");
            this.DepthLabel.Text                 = current.Depth.ToString("0.0");
            this.WeightLabel.Text                = current.Weight.ToString("0.0");
            this.UnitLabel.Text                  = current.UnitAsString;
            this.PurchasePriceLabel.Text         = current.GetPurchasePriceInEuro().ToString("C");
            this.SellingPriceGross.Text          = current.SellingPriceGross.ToString("C");
            this.SellingPriceWholesaleGross.Text = current.SellingPriceWholesaleGross.ToString("C");
            this.SupplierNameLabel.Text          = current.Supplier.Name;
            this.SupplierArticleNumberLabel.Text = current.SupplierArticleNumber;
            this.AmountOrderedLabel.Text         = current.GetAmountOrdered().ToString("0.0");
            this.AmountOnStockLabel.Text         = ArticleFormatter.ToStringStockAmount(current);
            this.EbayArticleNumberLabel.Text     = String.IsNullOrWhiteSpace(current.EbayArticleNumber) ? "???" : current.EbayArticleNumber;
            this.AmountEbayLabel.Text            = ArticleFormatter.ToStringEbayStockAmount(current);
            this.AmountMagentoLabel.Text         = current.SyncMagento.ToString();

            //Stock
            var   allStockMovements = current.StockMovements.OrderByDescending(runner => runner.Timestamp);
            Int32 itemsPerPage      = 10;
            var   pagedMovements    = allStockMovements.Skip((this.RequestAddOn.Query.StockMovementPage ?? 0) * itemsPerPage).Take(itemsPerPage);
            var   paginationList    = this.CreateStockMovementPagenationList(allStockMovements, itemsPerPage);

            this.StockMovementHeaderRepeater.DataSource = paginationList;
            this.StockMovementHeaderRepeater.DataBind();
            this.StockMovementRepeater.DataSource = pagedMovements;
            this.StockMovementRepeater.DataBind();
            this.StockMovementFooterRepeater.DataSource = paginationList;
            this.StockMovementFooterRepeater.DataBind();

            //Order
            this.OrderRepeater.DataSource = current.Orders.OrderBy(c => c.OrderDate);
            this.OrderRepeater.DataBind();

            DateTime last4Years = new DateTime(DateTime.Now.Year - 3, 1, 1);
            var      allSales   = MyDataContext.Default.SaleItems
                                  .Include(runner => runner.Article)
                                  .Include(runner => runner.Sale)
                                  .Where(runner => runner.InternalArticleNumber == current.ArticleNumber)
                                  .Where(runner => runner.Sale.DateOfSale >= last4Years)
                                  .Where(runner => !runner.CancelDate.HasValue)
                                  .Where(runner => !runner.Sale.Canceled.HasValue)
                                  .OrderByDescending(runner => runner.Sale.DateOfSale)
                                  .ToList();

            this.ShowYearlyStatistics(allSales);
            this.ShowQuarterlyStatistics(allSales);

            //Vehicles
            this.VehicleRepeater.DataSource = current.ArticleVehicleAssignments.OrderBy(runner => runner.Vehicle.Series).ThenBy(runner => runner.Vehicle.ModelName).ToList();
            this.VehicleRepeater.DataBind();

            // Q&A
            //this.ArticlesQARepeater.DataSource = current.ArticleQAs;
            //this.ArticlesQARepeater.DataBind();

            //this.CreateArticklQAButton2.NavigateUrl = PageUrlAttribute.Get<Articles.EditQA>(
            //	new Articles.EditQA.Query() { Article = current, SearchTerm = this.RequestAddOn.Query.SearchTerm });
        }
예제 #3
0
 public void Setup()
 {
     _blog      = BloggerInitializer.GetBlogs().First();
     _article   = BloggerInitializer.GetChsakellsArticles().First();
     _formatter = new ArticleFormatter();
 }