Skip to content

Commit

Permalink
Выполненно задание №1
Browse files Browse the repository at this point in the history
  • Loading branch information
TotKtoSmog committed Dec 13, 2023
1 parent dfae1be commit 9663e27
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 18 deletions.
13 changes: 13 additions & 0 deletions JsonClass/Content.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.Runtime.Serialization;

namespace laba4.JsonClass
{
[DataContract]
public class Content
{
[DataMember]
public string orderNumber { get; set; }
[DataMember]
public Section4 section4 { get; set; }
}
}
4 changes: 3 additions & 1 deletion JsonProfStandart.cs → JsonClass/JsonProfStandart.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Runtime.Serialization;

namespace laba4
namespace laba4.JsonClass
{
[DataContract]
public class JsonProfStandart
Expand All @@ -21,5 +21,7 @@ public class JsonProfStandart
public string title { get; set; }
[DataMember]
public string fgosOrderDate { get; set; }
[DataMember]
public Content content { get; set; }
}
}
9 changes: 9 additions & 0 deletions JsonClass/ProfessionalCompetenceTaskTable.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Runtime.Serialization;

namespace laba4.JsonClass
{
[DataContract]
public class ProfessionalCompetenceTaskTable
{
}
}
13 changes: 13 additions & 0 deletions JsonClass/ProfessionalStandards.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.Runtime.Serialization;

namespace laba4.JsonClass
{
[DataContract]
public class ProfessionalStandards
{
[DataMember]
public string id { get; set; }
[DataMember]
public string content { get; set; }
}
}
12 changes: 12 additions & 0 deletions JsonClass/Section4.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System.Runtime.Serialization;

namespace laba4.JsonClass
{
[DataContract]
public class Section4
{
[DataMember]
public ProfessionalStandards[] professionalStandards { get; set; }
public ProfessionalCompetenceTaskTable[] professionalCompetenceTaskTable { get; set; }
}
}
11 changes: 9 additions & 2 deletions MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,15 @@
</GroupBox>
</StackPanel>
</TabItem>
<TabItem Header="TabItem">
<Grid Background="#FFE5E5E5"/>
<TabItem Header="Задание №1">
<StackPanel>
<DataGrid ItemsSource="{Binding standart}" x:Name="EmployeesTable" AutoGenerateColumns="False" IsReadOnly="True" Margin="0,5,0,0">
<DataGrid.Columns >
<DataGridTextColumn Header="Код" Binding="{Binding Id}"/>
<DataGridTextColumn Header="Назваание" Binding="{Binding Name}"/>
</DataGrid.Columns>
</DataGrid>
</StackPanel>
</TabItem>
</TabControl>

Expand Down
37 changes: 23 additions & 14 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
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.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows;
using System.IO;
using System.Runtime.Serialization.Json;
using System.Collections.Generic;
using System.Linq;
using laba4.JsonClass;

namespace laba4
{
Expand All @@ -22,11 +12,13 @@ public partial class MainWindow : Window
{
public string PathJsonFile = @"C:\Users\Totkt\source\repos\laba4\data\file.json";
public JsonProfStandart jsonProfStandart { get; set; }
public List<Standart> standart { get; set; }

public MainWindow()
{
InitializeComponent();
jsonProfStandart = LoadJsonFile(PathJsonFile);
standart = getStandartInData(jsonProfStandart);
this.DataContext = this;
}
public JsonProfStandart LoadJsonFile(string PathJsonFile)
Expand All @@ -39,5 +31,22 @@ public JsonProfStandart LoadJsonFile(string PathJsonFile)
}
return returnResult;
}

private List<Standart> getStandartInData(JsonProfStandart jsonProfStandart)
{
List<Standart> returnResult = new List<Standart>();
foreach(ProfessionalStandards PS in jsonProfStandart.content.section4.professionalStandards)
{
string id = PS.content.Split(' ').First();
string name = PS.content.Replace(id + " ", "");
if (!id.Contains("06."))
{
id = "";
name = PS.content;
}
returnResult.Add(new Standart(id, name));
}
return returnResult;
}
}
}
14 changes: 14 additions & 0 deletions Standart.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace laba4
{
public class Standart
{
public string Id { get; set; }
public string Name { get; set; }
public Standart() { }
public Standart(string Id, string Name)
{
this.Id = Id;
this.Name = Name;
}
}
}
7 changes: 6 additions & 1 deletion laba4.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="JsonClass\ProfessionalCompetenceTaskTable.cs" />
<Compile Include="JsonClass\Section4.cs" />
<Compile Include="Standart.cs" />
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand All @@ -64,13 +67,15 @@
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="JsonProfStandart.cs" />
<Compile Include="JsonClass\Content.cs" />
<Compile Include="JsonClass\JsonProfStandart.cs" />
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="JsonClass\ProfessionalStandards.cs" />
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
Expand Down

0 comments on commit 9663e27

Please sign in to comment.