Skip to content

Commit f2a1a24

Browse files
Merge pull request #1 from SyncfusionExamples/demosample
Sales report demo sample committed.
2 parents e89cf41 + 185d2ca commit f2a1a24

19 files changed

+791
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>WinExe</OutputType>
5+
<TargetFramework>net8.0-windows</TargetFramework>
6+
<Nullable>enable</Nullable>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<UseWPF>true</UseWPF>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<None Remove="Images\down-arrow-28.png" />
13+
<None Remove="Images\estimate.png" />
14+
<None Remove="Images\export.png" />
15+
<None Remove="Images\products.png" />
16+
<None Remove="Images\sales_decrease.png" />
17+
<None Remove="Images\sales_increased.png" />
18+
<None Remove="Images\total-sales.png" />
19+
<None Remove="Images\total_sales.png" />
20+
<None Remove="Images\up-2-24.png" />
21+
</ItemGroup>
22+
23+
<ItemGroup>
24+
<PackageReference Include="Syncfusion.DataGridExcelExport.Wpf" Version="29.1.33" />
25+
<PackageReference Include="Syncfusion.SfGrid.WPF" Version="29.1.33" />
26+
<PackageReference Include="Syncfusion.SfProgressBar.WPF" Version="29.1.33" />
27+
<PackageReference Include="Syncfusion.SfSkinManager.WPF" Version="29.1.33" />
28+
<PackageReference Include="Syncfusion.Themes.Windows11Light.WPF" Version="29.1.33" />
29+
</ItemGroup>
30+
31+
<ItemGroup>
32+
<Resource Include="Images\down-arrow-28.png" />
33+
<Resource Include="Images\estimate.png" />
34+
<Resource Include="Images\export.png" />
35+
<Resource Include="Images\products.png" />
36+
<Resource Include="Images\sales_decrease.png" />
37+
<Resource Include="Images\sales_increased.png" />
38+
<Resource Include="Images\total_sales.png" />
39+
<Resource Include="Images\up-2-24.png" />
40+
</ItemGroup>
41+
42+
</Project>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.13.35825.156 d17.13
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AnnualSalesReportDemoUsingGrid", "AnnualSalesReportDemoUsingGrid.csproj", "{ABB042E9-24B0-48FC-BA3F-B9B42CF216BF}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{ABB042E9-24B0-48FC-BA3F-B9B42CF216BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{ABB042E9-24B0-48FC-BA3F-B9B42CF216BF}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{ABB042E9-24B0-48FC-BA3F-B9B42CF216BF}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{ABB042E9-24B0-48FC-BA3F-B9B42CF216BF}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {724B7E6E-A60C-4FC0-BDDC-1C16B3D675E0}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<Application x:Class="AnnualSalesReportDemoUsingGrid.App"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:local="clr-namespace:AnnualSalesReportDemoUsingGrid"
5+
StartupUri="MainWindow.xaml">
6+
7+
<Application.Resources>
8+
9+
</Application.Resources>
10+
</Application>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System.Configuration;
2+
using System.Data;
3+
using System.Windows;
4+
5+
namespace AnnualSalesReportDemoUsingGrid;
6+
7+
/// <summary>
8+
/// Interaction logic for App.xaml
9+
/// </summary>
10+
public partial class App : Application
11+
{
12+
}
13+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System.Windows;
2+
3+
[assembly:ThemeInfo(
4+
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
5+
//(used if a resource is not found in the page,
6+
// or application resource dictionaries)
7+
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
8+
//(used if a resource is not found in the page,
9+
// app, or any theme specific resource dictionaries)
10+
)]
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using Syncfusion.Windows.Shared;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using System.Windows.Input;
8+
using System.Windows;
9+
10+
namespace AnnualSalesReportDemoUsingGrid
11+
{
12+
using System;
13+
using System.Windows.Input;
14+
15+
namespace YourNamespace
16+
{
17+
public class RelayCommand : ICommand
18+
{
19+
private readonly Action<object> _execute;
20+
private readonly Predicate<object> _canExecute;
21+
22+
public RelayCommand(Action<object> execute, Predicate<object> canExecute = null)
23+
{
24+
_execute = execute ?? throw new ArgumentNullException(nameof(execute));
25+
_canExecute = canExecute;
26+
}
27+
28+
public bool CanExecute(object parameter)
29+
{
30+
return _canExecute == null || _canExecute(parameter);
31+
}
32+
33+
public void Execute(object parameter)
34+
{
35+
_execute(parameter);
36+
}
37+
38+
public event EventHandler CanExecuteChanged
39+
{
40+
add => CommandManager.RequerySuggested += value;
41+
remove => CommandManager.RequerySuggested -= value;
42+
}
43+
}
44+
}
45+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Globalization;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using System.Windows;
8+
using System.Windows.Data;
9+
using System.Windows.Media;
10+
using System.Windows.Media.Imaging;
11+
using static System.Runtime.InteropServices.JavaScript.JSType;
12+
13+
namespace AnnualSalesReportDemoUsingGrid
14+
{
15+
public class PercentageConverter : IValueConverter
16+
{
17+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
18+
{
19+
20+
return System.String.Format("{0}%", value); ;
21+
}
22+
23+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
24+
{
25+
throw new NotImplementedException();
26+
}
27+
}
28+
29+
public class BoolToImageConverter : IValueConverter
30+
{
31+
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
32+
{
33+
if((bool)value)
34+
{
35+
if(parameter?.ToString() == "AnnualReport")
36+
return new BitmapImage(new Uri(string.Format(@"..\..\Images\{0}", "sales_increased.png"), UriKind.Relative));
37+
else
38+
return new BitmapImage(new Uri(string.Format(@"..\..\Images\{0}", "up-2-24.png"), UriKind.Relative));
39+
}
40+
else
41+
{
42+
if (parameter?.ToString() == "AnnualReport")
43+
return new BitmapImage(new Uri(string.Format(@"..\..\Images\{0}", "sales_decrease.png"), UriKind.Relative));
44+
else
45+
return new BitmapImage(new Uri(string.Format(@"..\..\Images\{0}", "down-arrow-28.png"), UriKind.Relative));
46+
}
47+
48+
}
49+
50+
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
51+
{
52+
return null;
53+
}
54+
}
55+
56+
public class ColorConverter : IValueConverter
57+
{
58+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
59+
{
60+
var increased = (value as MonthlySalesReport).IsSalesIncreased;
61+
62+
//custom condition is checked based on data.
63+
64+
if (increased)
65+
return new SolidColorBrush(Colors.PaleGreen);
66+
else
67+
return new SolidColorBrush(Colors.OrangeRed);
68+
69+
70+
}
71+
72+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
73+
{
74+
throw new NotImplementedException();
75+
}
76+
}
77+
}
Loading
718 Bytes
Loading
311 Bytes
Loading
689 Bytes
Loading
Loading
Loading
Loading
399 Bytes
Loading
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
<Window x:Class="AnnualSalesReportDemoUsingGrid.MainWindow"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6+
xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
7+
xmlns:local="clr-namespace:AnnualSalesReportDemoUsingGrid"
8+
xmlns:syncfusionskin="clr-namespace:Syncfusion.SfSkinManager;assembly=Syncfusion.SfSkinManager.WPF"
9+
syncfusionskin:SfSkinManager.Theme="{syncfusionskin:SkinManagerExtension ThemeName=Windows11Light}"
10+
mc:Ignorable="d"
11+
Title="SalesReportApp" Height="670" Width="1000">
12+
<Window.DataContext>
13+
<local:SalesReportViewModel/>
14+
</Window.DataContext>
15+
<Window.Resources>
16+
<Style TargetType="syncfusion:GridHeaderCellControl">
17+
<Setter Property="FontWeight" Value="DemiBold"/>
18+
</Style>
19+
<local:ColorConverter x:Key="colorConverter"/>
20+
<local:PercentageConverter x:Key="converter"/>
21+
<local:BoolToImageConverter x:Key="boolToImageConverter"/>
22+
<Style x:Key="rowStyle1" TargetType="syncfusion:VirtualizingCellsControl">
23+
<Setter Property="Background" Value="{Binding Converter={StaticResource colorConverter}}" />
24+
</Style>
25+
</Window.Resources>
26+
<Grid>
27+
<Grid.RowDefinitions>
28+
<RowDefinition Height="130"/>
29+
<RowDefinition/>
30+
</Grid.RowDefinitions>
31+
<Grid.ColumnDefinitions>
32+
<ColumnDefinition/>
33+
<ColumnDefinition Width="300"/>
34+
</Grid.ColumnDefinitions>
35+
<StackPanel Grid.Row="0" Orientation="Vertical">
36+
<Grid>
37+
<Grid.ColumnDefinitions>
38+
<ColumnDefinition/>
39+
<ColumnDefinition Width="200"/>
40+
</Grid.ColumnDefinitions>
41+
<TextBlock x:Name="label" Text="Sales Report 2025" FontSize="28" FontWeight="Bold"/>
42+
<syncfusion:SplitButtonAdv x:Name="splitbutton" Label="Export" Grid.Column="1" FontSize="16" Height="30" Width="150" SizeMode="Normal" SmallIcon="/Images/export.png" HorizontalAlignment="Right" VerticalAlignment="Top">
43+
<syncfusion:DropDownMenuGroup>
44+
<syncfusion:DropDownMenuItem HorizontalAlignment="Left" Header="Annual Report" Command="{Binding AnnualReportCommand}" CommandParameter="{Binding ElementName=dataGrid}"/>
45+
<syncfusion:DropDownMenuItem HorizontalAlignment="Left" Header="Quarterly Report" Command="{Binding QuarterlyReportCommand}" CommandParameter="{Binding ElementName=quarterlyReportsGrid}"/>
46+
<syncfusion:DropDownMenuItem HorizontalAlignment="Left" Header="Monthly Report" Command="{Binding MonthlyReportCommand}" CommandParameter="{Binding ElementName=monthlyReportsGrid}"/>
47+
</syncfusion:DropDownMenuGroup>
48+
</syncfusion:SplitButtonAdv>
49+
</Grid>
50+
<Grid Margin="10,10,0,0">
51+
<Grid.ColumnDefinitions>
52+
<ColumnDefinition Width="30"/>
53+
<ColumnDefinition Width="150"/>
54+
<ColumnDefinition Width="20"/>
55+
<ColumnDefinition />
56+
</Grid.ColumnDefinitions>
57+
<Image Grid.Column="0" Source="/Images/products.png"/>
58+
<TextBlock Grid.Column="1" Text="Total No of Prducts : " FontSize="16" FontWeight="DemiBold" VerticalAlignment="Center"/>
59+
<TextBlock Grid.Column="2" Text="15" FontSize="16" FontWeight="DemiBold" VerticalAlignment="Center" />
60+
</Grid>
61+
<Grid Margin="10,10,0,0">
62+
<Grid.ColumnDefinitions>
63+
<ColumnDefinition Width="30"/>
64+
<ColumnDefinition Width="150"/>
65+
<ColumnDefinition Width="120"/>
66+
<ColumnDefinition Width="30"/>
67+
<ColumnDefinition Width="170"/>
68+
<ColumnDefinition Width="120"/>
69+
<ColumnDefinition />
70+
</Grid.ColumnDefinitions>
71+
<Image Grid.Column="0" Source="/Images/estimate.png"/>
72+
<TextBlock Grid.Column="1" Text="Esitimated Sales : " FontSize="16" FontWeight="DemiBold" VerticalAlignment="Center"/>
73+
<TextBlock Grid.Column="2" Text="{Binding EstimatedSales, StringFormat=C}" FontSize="16" FontWeight="DemiBold" VerticalAlignment="Center"/>
74+
<Image Grid.Column="3" Source="/Images/total_sales.png"/>
75+
<TextBlock Grid.Column="4" Text="Total Sales Achieved : " FontSize="16" FontWeight="DemiBold" VerticalAlignment="Center"/>
76+
<TextBlock Grid.Column="5" Text="{Binding TotalSales, StringFormat=C}" FontSize="16" FontWeight="DemiBold" VerticalAlignment="Center" HorizontalAlignment="Left"/>
77+
</Grid>
78+
</StackPanel>
79+
<GroupBox x:Name="groupbox" Header="Annual Product Sales Report" Margin="10" FontSize="16" FontWeight="DemiBold" Grid.RowSpan="2" Grid.Row="1">
80+
<syncfusion:SfDataGrid x:Name="dataGrid"
81+
AutoGenerateColumns="False"
82+
ColumnSizer="Star"
83+
RowHeight="30"
84+
GridLinesVisibility="Horizontal"
85+
HeaderLinesVisibility="Horizontal"
86+
ItemsSource="{Binding Reports}">
87+
<syncfusion:SfDataGrid.Columns>
88+
<syncfusion:GridTextColumn MappingName="ProductName" HeaderText="Product Name"/>
89+
<syncfusion:GridCurrencyColumn MappingName="EstimatedSales" HeaderText="Estimated Sales"/>
90+
<syncfusion:GridCurrencyColumn MappingName="SalesAchieved" HeaderText="Sales Achieved" Width="150">
91+
<syncfusion:GridCurrencyColumn.CellTemplate>
92+
<DataTemplate>
93+
<Grid>
94+
<Grid.ColumnDefinitions>
95+
<ColumnDefinition Width="50"/>
96+
<ColumnDefinition/>
97+
</Grid.ColumnDefinitions>
98+
<Image Source="{Binding IsSalesIncreased, Converter={StaticResource boolToImageConverter}, ConverterParameter='AnnualReport'}"/>
99+
<TextBlock Grid.Column="1" Text="{Binding SalesAchieved, StringFormat=C}" VerticalAlignment="Center"/>
100+
</Grid>
101+
</DataTemplate>
102+
</syncfusion:GridCurrencyColumn.CellTemplate>
103+
</syncfusion:GridCurrencyColumn>
104+
<syncfusion:GridTemplateColumn MappingName="SalesPercent" HeaderText="Sales Percent" Width="250">
105+
<syncfusion:GridTemplateColumn.CellTemplate>
106+
<DataTemplate>
107+
<Grid>
108+
<Grid.ColumnDefinitions>
109+
<ColumnDefinition/>
110+
<ColumnDefinition Width="40"/>
111+
</Grid.ColumnDefinitions>
112+
<syncfusion:SfLinearProgressBar Grid.Column="0" Progress="{Binding SalesPercent}" Width="180" Height="10" Padding="2" Minimum="0" Maximum="150" IndicatorCornerRadius="4">
113+
114+
</syncfusion:SfLinearProgressBar>
115+
<TextBlock Grid.Column="1" Text="{Binding SalesPercent, Converter={StaticResource converter}}" VerticalAlignment="Center"/>
116+
</Grid>
117+
</DataTemplate>
118+
</syncfusion:GridTemplateColumn.CellTemplate>
119+
</syncfusion:GridTemplateColumn>
120+
121+
</syncfusion:SfDataGrid.Columns>
122+
</syncfusion:SfDataGrid>
123+
</GroupBox>
124+
<StackPanel Grid.Column="1" Grid.ColumnSpan="2" Grid.RowSpan="2">
125+
<GroupBox Header="Quarterly Report" Margin="10" FontSize="16" FontWeight="DemiBold" >
126+
<syncfusion:SfDataGrid x:Name="quarterlyReportsGrid"
127+
AutoGenerateColumns="False"
128+
RowHeight="30"
129+
GridLinesVisibility="Horizontal"
130+
HeaderLinesVisibility="Horizontal"
131+
ColumnSizer="Star"
132+
ItemsSource="{Binding QuarterlyReports}">
133+
<syncfusion:SfDataGrid.Columns>
134+
<syncfusion:GridTextColumn MappingName="QuarterName" HeaderText="Quarter Name"/>
135+
<syncfusion:GridTextColumn MappingName="SalesAchieved" HeaderText="Sales Achieved">
136+
<syncfusion:GridTextColumn.CellTemplate>
137+
<DataTemplate>
138+
<Grid>
139+
<Grid.ColumnDefinitions>
140+
<ColumnDefinition />
141+
<ColumnDefinition Width="50"/>
142+
</Grid.ColumnDefinitions>
143+
<TextBlock Text="{Binding SalesAchieved, StringFormat=C}" VerticalAlignment="Center"/>
144+
<Image Grid.Column="1" Source="{Binding IsSalesIncreased, Converter={StaticResource boolToImageConverter}}"/>
145+
</Grid>
146+
</DataTemplate>
147+
</syncfusion:GridTextColumn.CellTemplate>
148+
</syncfusion:GridTextColumn>
149+
</syncfusion:SfDataGrid.Columns>
150+
</syncfusion:SfDataGrid>
151+
</GroupBox>
152+
<GroupBox Header="Monthly Report" FontSize="16" Margin="10,0,10,10" FontWeight="DemiBold" >
153+
<syncfusion:SfDataGrid x:Name="monthlyReportsGrid"
154+
AutoGenerateColumns="False"
155+
ColumnSizer="Star"
156+
RowHeight="30"
157+
RowStyle="{StaticResource rowStyle1}"
158+
GridLinesVisibility="Horizontal"
159+
HeaderLinesVisibility="Horizontal"
160+
ItemsSource="{Binding MonthlyReports}">
161+
<syncfusion:SfDataGrid.Columns>
162+
<syncfusion:GridTextColumn MappingName="MonthName" HeaderText="Month"/>
163+
<syncfusion:GridTextColumn MappingName="SalesAchieved" HeaderText="Sales Achieved"/>
164+
</syncfusion:SfDataGrid.Columns>
165+
</syncfusion:SfDataGrid>
166+
</GroupBox>
167+
</StackPanel>
168+
169+
</Grid>
170+
</Window>

0 commit comments

Comments
 (0)