Explorar el Código

Обновление для тестового проекта

MeseryGG hace 5 meses
padre
commit
87df9682bf

+ 2 - 2
DemoExam/DemoExam/DataBaseModel.Context.cs

@@ -13,9 +13,9 @@ namespace DemoExam
     using System.Data.Entity;
     using System.Data.Entity.Infrastructure;
     
-    public partial class DemoExamenPrepareTestEntities : DbContext
+    public partial class Entities : DbContext
     {
-        public DemoExamenPrepareTestEntities()
+        public Entities()
             : base("name=DemoExamenPrepareTestEntities")
         {
         }

+ 4 - 4
DemoExam/DemoExam/DataBaseModel.edmx

@@ -40,7 +40,7 @@
           </Key>
           <Property Name="RequestId" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
           <Property Name="RequestOpenDate" Type="datetime" Nullable="false" />
-          <Property Name="RequestCloseDate" Type="datetime" Nullable="false" />
+          <Property Name="RequestCloseDate" Type="datetime" />
           <Property Name="EquipmentId" Type="int" Nullable="false" />
           <Property Name="DefectId" Type="int" Nullable="false" />
           <Property Name="Description" Type="text" />
@@ -255,7 +255,7 @@
           </Key>
           <Property Name="RequestId" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
           <Property Name="RequestOpenDate" Type="DateTime" Nullable="false" Precision="3" />
-          <Property Name="RequestCloseDate" Type="DateTime" Nullable="false" Precision="3" />
+          <Property Name="RequestCloseDate" Type="DateTime" Precision="3" />
           <Property Name="EquipmentId" Type="Int32" Nullable="false" />
           <Property Name="DefectId" Type="Int32" Nullable="false" />
           <Property Name="Description" Type="String" MaxLength="Max" FixedLength="false" Unicode="false" />
@@ -394,7 +394,7 @@
             </Dependent>
           </ReferentialConstraint>
         </Association>
-        <EntityContainer Name="DemoExamenPrepareTestEntities" annotation:LazyLoadingEnabled="true">
+        <EntityContainer Name="Entities" annotation:LazyLoadingEnabled="true">
           <EntitySet Name="DefectTypes" EntityType="Self.DefectTypes" />
           <EntitySet Name="Equipments" EntityType="Self.Equipments" />
           <EntitySet Name="Executions" EntityType="Self.Executions" />
@@ -441,7 +441,7 @@
     <!-- C-S mapping content -->
     <edmx:Mappings>
       <Mapping Space="C-S" xmlns="http://schemas.microsoft.com/ado/2009/11/mapping/cs">
-        <EntityContainerMapping StorageEntityContainer="Хранилище DemoExamenPrepareTestModelContainer" CdmEntityContainer="DemoExamenPrepareTestEntities">
+        <EntityContainerMapping StorageEntityContainer="Хранилище DemoExamenPrepareTestModelContainer" CdmEntityContainer="Entities">
           <EntitySetMapping Name="DefectTypes">
             <EntityTypeMapping TypeName="DemoExamenPrepareTestModel.DefectTypes">
               <MappingFragment StoreEntitySet="DefectTypes">

+ 1 - 1
DemoExam/DemoExam/DataBaseModel.edmx.diagram

@@ -4,7 +4,7 @@
   <edmx:Designer xmlns="http://schemas.microsoft.com/ado/2009/11/edmx">
     <!-- Diagram content (shape and connector positions) -->
     <edmx:Diagrams>
-      <Diagram DiagramId="a9328322c10c487e8852042e2fe3d296" Name="Diagram1">
+      <Diagram DiagramId="43c984a8d54049d9bd5b88b7b0f75c56" Name="Diagram1">
         <EntityTypeShape EntityType="DemoExamenPrepareTestModel.DefectTypes" Width="1.5" PointX="6" PointY="6.875" IsExpanded="true" />
         <EntityTypeShape EntityType="DemoExamenPrepareTestModel.Equipments" Width="1.5" PointX="6" PointY="9.125" IsExpanded="true" />
         <EntityTypeShape EntityType="DemoExamenPrepareTestModel.Executions" Width="1.5" PointX="5.25" PointY="3.5" IsExpanded="true" />

+ 15 - 14
DemoExam/DemoExam/DemoExam.csproj

@@ -68,11 +68,21 @@
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </ApplicationDefinition>
+    <Compile Include="DataBaseModel.Context.cs">
+      <AutoGen>True</AutoGen>
+      <DesignTime>True</DesignTime>
+      <DependentUpon>DataBaseModel.Context.tt</DependentUpon>
+    </Compile>
     <Compile Include="DataBaseModel.cs">
       <AutoGen>True</AutoGen>
       <DesignTime>True</DesignTime>
       <DependentUpon>DataBaseModel.tt</DependentUpon>
     </Compile>
+    <Compile Include="DataBaseModel.Designer.cs">
+      <AutoGen>True</AutoGen>
+      <DesignTime>True</DesignTime>
+      <DependentUpon>DataBaseModel.edmx</DependentUpon>
+    </Compile>
     <Compile Include="DefectTypes.cs">
       <DependentUpon>DataBaseModel.tt</DependentUpon>
     </Compile>
@@ -97,6 +107,7 @@
     <Compile Include="Users.cs">
       <DependentUpon>DataBaseModel.tt</DependentUpon>
     </Compile>
+    <Compile Include="UsersPartialClass.cs" />
     <Page Include="MainWindow.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
@@ -105,16 +116,6 @@
       <DependentUpon>App.xaml</DependentUpon>
       <SubType>Code</SubType>
     </Compile>
-    <Compile Include="DataBaseModel.Context.cs">
-      <AutoGen>True</AutoGen>
-      <DesignTime>True</DesignTime>
-      <DependentUpon>DataBaseModel.Context.tt</DependentUpon>
-    </Compile>
-    <Compile Include="DataBaseModel.Designer.cs">
-      <AutoGen>True</AutoGen>
-      <DesignTime>True</DesignTime>
-      <DependentUpon>DataBaseModel.edmx</DependentUpon>
-    </Compile>
     <Compile Include="MainWindow.xaml.cs">
       <DependentUpon>MainWindow.xaml</DependentUpon>
       <SubType>Code</SubType>
@@ -206,11 +207,14 @@
   <ItemGroup>
     <Resource Include="Resources\qrcode_chrome.png" />
   </ItemGroup>
+  <ItemGroup>
+    <Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
+  </ItemGroup>
   <ItemGroup>
     <Content Include="DataBaseModel.Context.tt">
       <Generator>TextTemplatingFileGenerator</Generator>
-      <LastGenOutput>DataBaseModel.Context.cs</LastGenOutput>
       <DependentUpon>DataBaseModel.edmx</DependentUpon>
+      <LastGenOutput>DataBaseModel.Context.cs</LastGenOutput>
     </Content>
     <Content Include="DataBaseModel.tt">
       <Generator>TextTemplatingFileGenerator</Generator>
@@ -218,8 +222,5 @@
       <LastGenOutput>DataBaseModel.cs</LastGenOutput>
     </Content>
   </ItemGroup>
-  <ItemGroup>
-    <Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
-  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
 </Project>

+ 17 - 1
DemoExam/DemoExam/MainWindow.xaml.cs

@@ -1,6 +1,9 @@
 using DemoExam.Pages;
 using System;
 using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.IO.Pipes;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
@@ -34,10 +37,23 @@ namespace DemoExam
         {
             InitializeComponent();
 
+            SetUpDebuggerFile();
+            Trace.WriteLine($"Trace - Новый запуск программы: {DateTime.Now}");
+            Debug.WriteLine($"Debug - Новый запуск программы: {DateTime.Now}");
+            Trace.Flush();
+
             _mainWindow = this;
             ShowingPage = new AuthorizationUserControl();
+        }
 
-            ShowingPage = new ManagersPage();
+
+        private void SetUpDebuggerFile()
+        {
+            //System.IO.Stream fileStream = File.Open("TraceFile.txt", FileMode.Append); 
+            System.IO.Stream fileStream = File.Open("TraceFile.txt", FileMode.OpenOrCreate);
+            fileStream.Seek(0, SeekOrigin.End);
+            Trace.Listeners.Add(new TextWriterTraceListener(fileStream));
+            Trace.AutoFlush = true;
         }
     }
 }

+ 15 - 9
DemoExam/DemoExam/Pages/RepairListUserControl.xaml

@@ -25,18 +25,24 @@
                Grid.ColumnSpan="2"/>
 
         <GroupBox Grid.Row="1" Header="Поиск (Номер заявки)" Margin="0 0 0 20">
-            <TextBox BorderThickness="0" Height="30"/>
+            <TextBox BorderThickness="0" Height="30" Name="SearchTextBox" TextChanged="SearchTextBoxTextChangedHandler" VerticalContentAlignment="Center"/>
         </GroupBox>
 
-        <DataGrid IsReadOnly="True" x:Name="RepairRequestListDataGrid" Grid.Row="2" Grid.ColumnSpan="2">
+        <DataGrid IsReadOnly="True" x:Name="RepairRequestListDataGrid" Grid.Row="2" Grid.ColumnSpan="2" AutoGenerateColumns="False">
+            <DataGrid.ContextMenu>
+                <ContextMenu>
+                    <MenuItem Header="Тест 1"/>
+                    <MenuItem Header="Тест 2"/>
+                </ContextMenu>
+            </DataGrid.ContextMenu>
             <DataGrid.Columns>
-                <DataGridTextColumn Header="Номер заявки" Binding="{Binding }" Width="*"/>
-                <DataGridTextColumn Header="Оборудование на ремонт" Binding="{Binding }" Width="*"/>
-                <DataGridTextColumn Header="Тип неисправности" Binding="{Binding }" Width="*"/>
-                <DataGridTextColumn Header="Дата добавления" Binding="{Binding }" Width="*"/>
-                <DataGridTextColumn Header="Клиент" Binding="{Binding }" Width="*"/>
-                <DataGridTextColumn Header="Мастер" Binding="{Binding }" Width="*"/>
-                <DataGridTextColumn Header="Статус заявки" Binding="{Binding }" Width="*"/>
+                <DataGridTextColumn Header="Номер заявки" Binding="{Binding RequestId}" Width="*"/>
+                <DataGridTextColumn Header="Оборудование на ремонт" Binding="{Binding Equipments.EquipmentStatus}" Width="*"/>
+                <DataGridTextColumn Header="Тип неисправности" Binding="{Binding DefectTypes.DefectTitle}" Width="*"/>
+                <DataGridTextColumn Header="Дата открытия" Binding="{Binding RequestOpenDate}" Width="*"/>
+                <DataGridTextColumn Header="Дата закрытия" Binding="{Binding RequestCloseDate}" Width="*"/>
+                <DataGridTextColumn Header="Клиент" Binding="{Binding Users.UserName}" Width="*"/>
+                <DataGridTextColumn Header="Статус заявки" Binding="{Binding Statuses.StatusTitle}" Width="*"/>
             </DataGrid.Columns>
         </DataGrid>
 

+ 26 - 0
DemoExam/DemoExam/Pages/RepairListUserControl.xaml.cs

@@ -2,6 +2,7 @@
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
+using System.Text.RegularExpressions;
 using System.Threading.Tasks;
 using System.Windows;
 using System.Windows.Controls;
@@ -23,6 +24,31 @@ namespace DemoExam.Pages
         public RepairListUserControl()
         {
             InitializeComponent();
+
+            UpdateRequestsFromDB();
+            RepairRequestListDataGrid.ItemsSource = _requestsAfterSearching;
+        }
+
+
+        private List<Requests> _requestsFromDataBase;
+        private List<Requests> _requestsAfterSearching;
+
+        private Entities _db = new Entities();
+
+
+        private void UpdateRequestsFromDB()
+        {
+            _requestsFromDataBase = _db.Requests.ToList();
+            UpdateRequestsWithSearching();
+        }
+
+        private void UpdateRequestsWithSearching() =>
+            _requestsAfterSearching = _requestsFromDataBase.Where(a => Regex.IsMatch(a.RequestId.ToString(), $"{SearchTextBox.Text}")).ToList();
+
+        private void SearchTextBoxTextChangedHandler(object sender, TextChangedEventArgs e)
+        {
+            UpdateRequestsWithSearching();
+            RepairRequestListDataGrid.ItemsSource = _requestsAfterSearching;
         }
     }
 }

+ 1 - 1
DemoExam/DemoExam/Requests.cs

@@ -22,7 +22,7 @@ namespace DemoExam
     
         public int RequestId { get; set; }
         public System.DateTime RequestOpenDate { get; set; }
-        public System.DateTime RequestCloseDate { get; set; }
+        public Nullable<System.DateTime> RequestCloseDate { get; set; }
         public int EquipmentId { get; set; }
         public int DefectId { get; set; }
         public string Description { get; set; }

+ 9 - 0
DemoExam/DemoExam/UsersPartialClass.cs

@@ -0,0 +1,9 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DemoExam
+{
+}

+ 1 - 1
РуководствоСистемногоПрограммиста.docx

@@ -27,7 +27,7 @@
 
    Настройка программы
 
-   Для работы приложения первично необходимо базу данных Microsoft SQL Server приложения. И изменить строку подключения приложения в файле app.config.
+   Для работы приложения первично необходимо развернуть базу данных Microsoft SQL Server приложения. И изменить строку подключения приложения в файле app.config.
    
    Проверка программы