Переглянути джерело

Дигарамма бом бом

Almir Myxametszanov 1 рік тому
батько
коміт
154a60cde8

+ 1 - 1
ROGOZ/App.config

@@ -8,7 +8,7 @@
     <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
   </startup>
   <connectionStrings>
-    <add name="user1Entities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=VPMT.RU\IS4;initial catalog=user1;user id=user1;password = ScladniyParol;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
+    <add name="user1Entities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=SRV-WSR\IS4;initial catalog=user1;user id=user1;password = ScladniyParol;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
   </connectionStrings>
   <entityFramework>
     <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">

+ 3 - 1
ROGOZ/MainWindow.xaml.cs

@@ -80,7 +80,9 @@ namespace ROGOZ
 
         private void Chart_Click(object sender, RoutedEventArgs e)
         {
-            MainFrame.Navigate(new Pages.Chart());
+            //MainFrame.Navigate(new Pages.Chart());
+            Pages.Diagram diagram = new Pages.Diagram();
+            diagram.Show();
         }
     }
 }

+ 2 - 2
ROGOZ/Pages/Chart.xaml

@@ -33,8 +33,8 @@
             </StackPanel>
             
         </StackPanel>
-        <WindowsFormsHost Grid.Row="1"  Margin="20">
-            <charts:Chart x:Name="ChartTasks">
+        <WindowsFormsHost Grid.Row="1"  Margin="20" >
+            <charts:Chart x:Name="ChartPayments">
                 <charts:Chart.Legends>
                     <charts:Legend/>
                 </charts:Chart.Legends>

+ 12 - 11
ROGOZ/Pages/Chart.xaml.cs

@@ -23,37 +23,38 @@ namespace ROGOZ.Pages
     /// </summary>
     public partial class Chart : Page
     {
-        List<string> ExecutorGrades = new List<string>()
+        private user1Entities _context = new user1Entities();
+        List<string> listStatus = new List<string>()
         {
-            "junior", "middle", "senior"
+            "запланирована", "выполнена", "отменена", "исполняется"
         };
-        private user1Entities _context = new user1Entities();
+        
         public Chart()
         {
             InitializeComponent();
-            ChartTasks.ChartAreas.Add(new ChartArea("Main"));
+            ChartPayments.ChartAreas.Add(new ChartArea("Main"));
 
-            var currentSeries = new Series("Исполнители")
+            var currentSeries = new Series("Количество")
             {
                 IsValueShownAsLabel = true
             };
-            ChartTasks.Series.Add(currentSeries);
+            ChartPayments.Series.Add(currentSeries);
 
-            ComboExecutor.ItemsSource = ExecutorGrades;
+            ComboExecutor.ItemsSource = listStatus;
             ComboChartTypes.ItemsSource = Enum.GetValues(typeof(SeriesChartType));
         }
 
         private void UpdateChart(object sender, SelectionChangedEventArgs e)
         {
-            if (ComboExecutor.SelectedItem is string grade &&
+            if (ComboExecutor.SelectedItem is string value &&
                 ComboChartTypes.SelectedItem is SeriesChartType chartType)
             {
-                Series currentSeries = ChartTasks.Series.FirstOrDefault();
+                Series currentSeries = ChartPayments.Series.FirstOrDefault();
                 currentSeries.ChartType = chartType;
                 currentSeries.Points.Clear();
 
-                var categoriesList = _context.Executor.ToArray();
-                currentSeries.Points.AddXY(grade, categoriesList.Where(x=>x.Grade == grade).Count());
+                var categoriesList = _context.Task.ToList();
+                currentSeries.Points.AddXY(value, categoriesList.Where(x=>x.Status == value).Count());
             }
         }
     }

+ 42 - 0
ROGOZ/Pages/Diagram.xaml

@@ -0,0 +1,42 @@
+<Window x:Class="ROGOZ.Pages.Diagram"
+        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+        xmlns:charts ="clr-namespace:System.Windows.Forms.DataVisualization.Charting;assembly=System.Windows.Forms.DataVisualization"
+        xmlns:local="clr-namespace:ROGOZ.Pages"
+        mc:Ignorable="d"
+        Title="Diagram" Height="630" Width="820">
+    <Grid>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="auto"/>
+            <RowDefinition Height="*"/>
+        </Grid.RowDefinitions>
+        <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Width="800">
+            <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
+                <TextBlock Text="Пользователь: " FontSize="23" FontFamily="Comic Sans Ms" 
+                       Foreground="#52a8ff" VerticalAlignment="Center"
+                       TextAlignment="Left" Margin="10"/>
+                <ComboBox Name="ComboExecutor" SelectionChanged="UpdateChart" Style="{DynamicResource ComboBoxStyle1}"
+                      Width="180" Height="35"/>
+            </StackPanel>
+            <Separator Width="20" Background="Transparent"/>
+
+            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" >
+                <TextBlock Text="Тип диаграммы: " FontSize="23" FontFamily="Comic Sans Ms" 
+                       Foreground="#52a8ff" VerticalAlignment="Center"
+                       TextAlignment="Left" Margin="10"/>
+                <ComboBox Name="ComboChartTypes" SelectionChanged="UpdateChart" Style="{DynamicResource ComboBoxStyle1}"
+                      Width="180" Height="35"/>
+            </StackPanel>
+
+        </StackPanel>
+        <WindowsFormsHost Grid.Row="1"  Margin="20" >
+            <charts:Chart x:Name="ChartPayments">
+                <charts:Chart.Legends>
+                    <charts:Legend/>
+                </charts:Chart.Legends>
+            </charts:Chart>
+        </WindowsFormsHost>
+    </Grid>
+</Window>

+ 56 - 0
ROGOZ/Pages/Diagram.xaml.cs

@@ -0,0 +1,56 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Forms.DataVisualization.Charting;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace ROGOZ.Pages
+{
+    /// <summary>
+    /// Логика взаимодействия для Diagram.xaml
+    /// </summary>
+    public partial class Diagram : Window
+    {
+        private user1Entities _context = new user1Entities();
+        List<string> listStatus = new List<string>()
+        {
+            "запланирована", "выполнена", "отменена", "исполняется"
+        };
+        public Diagram()
+        {
+            InitializeComponent();
+            ChartPayments.ChartAreas.Add(new ChartArea("Main"));
+
+            var currentSeries = new Series("Количество")
+            {
+                IsValueShownAsLabel = true
+            };
+            ChartPayments.Series.Add(currentSeries);
+
+            ComboExecutor.ItemsSource = listStatus;
+            ComboChartTypes.ItemsSource = Enum.GetValues(typeof(SeriesChartType));
+        }
+        private void UpdateChart(object sender, SelectionChangedEventArgs e)
+        {
+            if (ComboExecutor.SelectedItem is string value &&
+                ComboChartTypes.SelectedItem is SeriesChartType chartType)
+            {
+                Series currentSeries = ChartPayments.Series.FirstOrDefault();
+                currentSeries.ChartType = chartType;
+                currentSeries.Points.Clear();
+
+                var categoriesList = _context.Task.ToList();
+                currentSeries.Points.AddXY(value, categoriesList.Where(x => x.Status == value).Count());
+            }
+        }
+    }
+}

+ 7 - 0
ROGOZ/ROGOZ.csproj

@@ -109,6 +109,9 @@
     <Compile Include="Pages\Chart.xaml.cs">
       <DependentUpon>Chart.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Pages\Diagram.xaml.cs">
+      <DependentUpon>Diagram.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Pages\General.xaml.cs">
       <DependentUpon>General.xaml</DependentUpon>
     </Compile>
@@ -155,6 +158,10 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="Pages\Diagram.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="Pages\General.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>