gr672_bda 4 tahun lalu
induk
melakukan
343ec0468b

+ 28 - 0
ProjectAnalogParus/AccrualsPage.xaml

@@ -0,0 +1,28 @@
+<Page x:Class="ProjectAnalogParus.AccrualsPage"
+      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+      xmlns:local="clr-namespace:ProjectAnalogParus"
+      mc:Ignorable="d" 
+      d:DesignHeight="450" d:DesignWidth="800"
+      Title="AccrualsPage" Loaded="LoadedWindows">
+
+    <Grid>
+
+        <DataGrid Name="Acctualsgrid" HorizontalAlignment="Left" AutoGenerateColumns="False" Height="188" Margin="10,74,0,0" VerticalAlignment="Top" Width="780" >
+
+            <DataGrid.Columns>
+                <DataGridTextColumn Binding="{Binding IdAccrualsScholarship}" Header="Id" Width="*"/>
+                <DataGridTextColumn Binding="{Binding Student.LastName}" Header="Студент" Width="3*"/>
+                <DataGridTextColumn Binding="{Binding User.FullNameUser}" Header="Ответсвенное лицо" Width="3*" />
+                <DataGridTextColumn Binding="{Binding DateAccruals,StringFormat='yyyy-MM-dd'}" Header="Дата начисления" Width="3*" />
+                <DataGridTextColumn Binding="{Binding Scholarship.NameScholarship}" Header="Стипендия" Width="3*" />
+                <DataGridTextColumn Binding="{Binding Encouragement.NameTypeEncouragement}" Header="Поощрение" Width="3*" />
+                <DataGridTextColumn Binding="{Binding Amount}" Header="Сумма" Width="3*" />
+            </DataGrid.Columns>
+        </DataGrid>
+        <Button Content="Экспорт Excel" HorizontalAlignment="Left" Margin="51,285,0,0" VerticalAlignment="Top" Width="97" Click="ExcelClick"/>
+    </Grid>
+
+</Page>

+ 61 - 0
ProjectAnalogParus/AccrualsPage.xaml.cs

@@ -0,0 +1,61 @@
+using Microsoft.Office.Interop.Excel;
+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 Excel = Microsoft.Office.Interop.Excel;
+using Page = System.Windows.Controls.Page;
+
+namespace ProjectAnalogParus
+{
+    /// <summary>
+    /// Логика взаимодействия для AccrualsPage.xaml
+    /// </summary>
+    public partial class AccrualsPage : Page
+    {
+        gr672_bdaEntities db = new gr672_bdaEntities();
+        public AccrualsPage()
+        {
+            InitializeComponent();
+        }
+
+        private void ExcelClick(object sender, RoutedEventArgs e)
+        {          
+            Excel.Application excel = new Excel.Application();
+            excel.Visible = true;
+            Workbook workbook = excel.Workbooks.Add(System.Reflection.Missing.Value);
+            Worksheet sheet1 = (Worksheet)workbook.Sheets[1];
+            for (int j = 0; j < Acctualsgrid.Columns.Count; j++)
+            {
+                Range myRange = (Range)sheet1.Cells[1, j + 1];
+                sheet1.Cells[1, j + 1].Font.Bold = true;
+                sheet1.Columns[j + 1].ColumnWidth = 15;
+                myRange.Value2 = Acctualsgrid.Columns[j].Header;
+            }
+            for (int i = 0; i < Acctualsgrid.Columns.Count; i++)
+            {
+                for (int j = 0; j < Acctualsgrid.Items.Count; j++)
+                {
+                    TextBlock b = Acctualsgrid.Columns[i].GetCellContent(Acctualsgrid.Items[j]) as TextBlock;
+                    Microsoft.Office.Interop.Excel.Range myRange = (Microsoft.Office.Interop.Excel.Range)sheet1.Cells[j + 2, i + 1];
+                    myRange.Value2 = b.Text;
+                }
+            }
+        }
+        
+        private void LoadedWindows(object sender, RoutedEventArgs e)
+        {           
+            Acctualsgrid.ItemsSource = db.AccrualsScholarship.ToList();
+        }
+    }
+}

+ 16 - 2
ProjectAnalogParus/EncouragementSummaPage.xaml

@@ -30,8 +30,22 @@
         <ComboBox Name="cmbScholarship" HorizontalAlignment="Left" Margin="304,181,0,0" VerticalAlignment="Top" Width="120"/>
         <ComboBox Name="cmbEncoragement" HorizontalAlignment="Left" Margin="304,221,0,0" VerticalAlignment="Top" Width="120"/>
         <TextBlock Name="AmoutSumma" HorizontalAlignment="Left" Margin="304,254,0,0" TextWrapping="Wrap"  VerticalAlignment="Top" Height="24" Width="120"/>
-        <DatePicker Name="datetime" HorizontalAlignment="Left" Margin="302,143,0,0" VerticalAlignment="Top" Height="29" Width="120"/>
-        <Button Content="Начисление стипендии" HorizontalAlignment="Left" Margin="265,355,0,0" VerticalAlignment="Top" Width="147" Height="20" Click="ReqisitesScholarshipsClick"/>
+        <DatePicker SelectedDate="{Binding Path = SellStartDate, StringFormat = {}{0:yyyy-MM-dd}}" SelectedDateFormat="Short" Name="datetime" HorizontalAlignment="Left" Margin="302,143,0,0" VerticalAlignment="Top" Height="29" Width="120"  IsTodayHighlighted="True">
+            <DatePicker.Resources>
+                <Style TargetType="DatePickerTextBox">
+                    <Setter Property="Control.Template">
+                        <Setter.Value>
+                            <ControlTemplate>
+                                <TextBox x:Name="PART_TextBox"
+                                    Text="{Binding Path=SelectedDate, StringFormat = {}{0:yyyy-MM-dd}, 
+                                    RelativeSource={RelativeSource AncestorType={x:Type DatePicker}}}" />
+                            </ControlTemplate>
+                        </Setter.Value>
+                    </Setter>
+                </Style>
+            </DatePicker.Resources>
+        </DatePicker>
+        <Button Content="Начислить" HorizontalAlignment="Left" Margin="265,355,0,0" VerticalAlignment="Top" Width="94" Height="20" Click="ReqisitesScholarshipsClick"/>
 
     </Grid>
 </Page>

+ 31 - 8
ProjectAnalogParus/EncouragementSummaPage.xaml.cs

@@ -2,6 +2,7 @@
 using System.Collections.Generic;
 using System.Data;
 using System.Data.SqlClient;
+using System.Globalization;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
@@ -33,7 +34,6 @@ namespace ProjectAnalogParus
 
             cmbScholarship.ItemsSource = db.Scholarship.ToList();
             cmbScholarship.DisplayMemberPath = "NameScholarship";
-            cmbScholarship.SelectedValuePath = "Amount";
 
             cmbUser.ItemsSource = db.User.ToList();
             cmbUser.DisplayMemberPath = "FullNameUser";
@@ -42,17 +42,20 @@ namespace ProjectAnalogParus
             cmbEncoragement.ItemsSource = db.Encouragement.ToList();           
 
             cmbEncoragement.DisplayMemberPath = "NameTypeEncouragement";
+
+
+            cmbScholarship.SelectedValuePath = "Amount";
             cmbEncoragement.SelectedValuePath = "Amount";
 
-           
         }        
 
         private void SummaClick(object sender, RoutedEventArgs e)
         {
 
-
-            if (/*cmbStudent != null && cmbUser != null && datetime != null ||*/ cmbScholarship != null || cmbEncoragement != null)
+           
+            if (cmbStudent != null && cmbUser != null && datetime != null || cmbScholarship != null || cmbEncoragement != null)
             {
+               
                 double ship = Convert.ToDouble(cmbScholarship.SelectedValue);
                 double enco = Convert.ToDouble(cmbEncoragement.SelectedValue);
 
@@ -62,13 +65,33 @@ namespace ProjectAnalogParus
             else
             {
                 MessageBox.Show("Не все поля заполнены");
-            }
-          
+            }            
+
         }
 
         private void ReqisitesScholarshipsClick(object sender, RoutedEventArgs e)
         {
-            FramePage.MainFrame.Navigate(new ReqisitesSholarshipsPage());
-        }
+            if (cmbStudent != null && cmbUser != null && datetime != null || cmbScholarship != null || cmbEncoragement != null && AmoutSumma.Text != "")
+            {               
+                AccrualsScholarship accruals = new AccrualsScholarship();
+                accruals.StudentId = Convert.ToInt32(cmbStudent.SelectedValue.ToString());
+                accruals.UserId = Convert.ToInt32(cmbUser.SelectedValue.ToString());
+                accruals.DateAccruals = Convert.ToDateTime(datetime.SelectedDate.ToString());
+                accruals.ScholarshipId = Convert.ToInt32((cmbScholarship.SelectedItem as Scholarship).IdScholarship);
+                accruals.EncouragementId = Convert.ToInt32((cmbEncoragement.SelectedItem as Encouragement).IdEncouragement);
+                accruals.Amount = Convert.ToDecimal(AmoutSumma.Text);
+                db.AccrualsScholarship.Add(accruals);
+                db.SaveChanges();
+                MessageBox.Show("Стипендия начислена студенту!");
+
+            }
+            else
+            {
+                MessageBox.Show("Не все поля заполнены!");
+            }
+
+        }   
+
+
     }
 }

+ 52 - 7
ProjectAnalogParus/ProjectAnalogParus.csproj

@@ -50,17 +50,33 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="Castle.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
+      <HintPath>..\packages\Castle.Core.4.4.0\lib\net45\Castle.Core.dll</HintPath>
+    </Reference>
+    <Reference Include="DocumentFormat.OpenXml, Version=2.12.3.0, Culture=neutral, PublicKeyToken=8fb06cb64d019a17, processorArchitecture=MSIL">
+      <HintPath>..\packages\DocumentFormat.OpenXml.2.12.3\lib\net46\DocumentFormat.OpenXml.dll</HintPath>
+    </Reference>
     <Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
       <HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll</HintPath>
     </Reference>
     <Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
       <HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
     </Reference>
+    <Reference Include="Moq, Version=4.16.0.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
+      <HintPath>..\packages\Moq.4.16.1\lib\net45\Moq.dll</HintPath>
+    </Reference>
     <Reference Include="System" />
     <Reference Include="System.ComponentModel.DataAnnotations" />
+    <Reference Include="System.Configuration" />
     <Reference Include="System.Data" />
+    <Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+      <HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
+    </Reference>
     <Reference Include="System.Runtime.Serialization" />
     <Reference Include="System.Security" />
+    <Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
+      <HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
+    </Reference>
     <Reference Include="System.Xml" />
     <Reference Include="Microsoft.CSharp" />
     <Reference Include="System.Core" />
@@ -82,6 +98,9 @@
     <Compile Include="Access.cs">
       <DependentUpon>Model.tt</DependentUpon>
     </Compile>
+    <Compile Include="AccrualsPage.xaml.cs">
+      <DependentUpon>AccrualsPage.xaml</DependentUpon>
+    </Compile>
     <Compile Include="AccrualsScholarship.cs">
       <DependentUpon>Model.tt</DependentUpon>
     </Compile>
@@ -177,9 +196,6 @@
     <Compile Include="Position.cs">
       <DependentUpon>Model.tt</DependentUpon>
     </Compile>
-    <Compile Include="ReqisitesSholarshipsPage.xaml.cs">
-      <DependentUpon>ReqisitesSholarshipsPage.xaml</DependentUpon>
-    </Compile>
     <Compile Include="Requisites.cs">
       <DependentUpon>Model.tt</DependentUpon>
     </Compile>
@@ -228,6 +244,10 @@
     <Compile Include="WageFund.cs">
       <DependentUpon>Model.tt</DependentUpon>
     </Compile>
+    <Page Include="AccrualsPage.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="AdminPage.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
@@ -292,10 +312,6 @@
       <DependentUpon>MainWindow.xaml</DependentUpon>
       <SubType>Code</SubType>
     </Compile>
-    <Page Include="ReqisitesSholarshipsPage.xaml">
-      <SubType>Designer</SubType>
-      <Generator>MSBuild:Compile</Generator>
-    </Page>
     <Page Include="ScholarshipsPage.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
@@ -376,5 +392,34 @@
       <Install>false</Install>
     </BootstrapperPackage>
   </ItemGroup>
+  <ItemGroup>
+    <COMReference Include="Microsoft.Office.Core">
+      <Guid>{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}</Guid>
+      <VersionMajor>2</VersionMajor>
+      <VersionMinor>8</VersionMinor>
+      <Lcid>0</Lcid>
+      <WrapperTool>primary</WrapperTool>
+      <Isolated>False</Isolated>
+      <EmbedInteropTypes>True</EmbedInteropTypes>
+    </COMReference>
+    <COMReference Include="Microsoft.Office.Interop.Excel">
+      <Guid>{00020813-0000-0000-C000-000000000046}</Guid>
+      <VersionMajor>1</VersionMajor>
+      <VersionMinor>9</VersionMinor>
+      <Lcid>0</Lcid>
+      <WrapperTool>primary</WrapperTool>
+      <Isolated>False</Isolated>
+      <EmbedInteropTypes>True</EmbedInteropTypes>
+    </COMReference>
+    <COMReference Include="VBIDE">
+      <Guid>{0002E157-0000-0000-C000-000000000046}</Guid>
+      <VersionMajor>5</VersionMajor>
+      <VersionMinor>3</VersionMinor>
+      <Lcid>0</Lcid>
+      <WrapperTool>primary</WrapperTool>
+      <Isolated>False</Isolated>
+      <EmbedInteropTypes>True</EmbedInteropTypes>
+    </COMReference>
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
 </Project>

+ 0 - 31
ProjectAnalogParus/ReqisitesSholarshipsPage.xaml

@@ -1,31 +0,0 @@
-<Page x:Class="ProjectAnalogParus.ReqisitesSholarshipsPage"
-      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
-      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
-      xmlns:local="clr-namespace:ProjectAnalogParus"
-      mc:Ignorable="d" 
-      d:DesignHeight="450" d:DesignWidth="800"
-      Title="Начисление стипендии">
-
-    <Grid>
-        <ComboBox Name="cmbStudent" HorizontalAlignment="Left" Margin="330,86,0,0" VerticalAlignment="Top" Width="120">
-            <ComboBox.ItemTemplate>
-                <DataTemplate>
-                    <TextBlock DataContext="{Binding}">
-                        <TextBlock.Text>
-                            <MultiBinding StringFormat="{}{0} {1} {2}">
-                                <Binding Path="LastName" />
-                                <Binding Path="FirstName" />
-                                <Binding Path="Middlename" />
-                            </MultiBinding>
-                        </TextBlock.Text>
-                    </TextBlock>
-                </DataTemplate>
-            </ComboBox.ItemTemplate>
-        </ComboBox>
-        <ComboBox Name="cmbUser" HorizontalAlignment="Left" Margin="330,141,0,0" VerticalAlignment="Top" Width="120"/>
-        <Button Content="Начислить стипендию" HorizontalAlignment="Left" Margin="128,343,0,0" VerticalAlignment="Top" Width="136" Height="25" Click="ScholarshipSumma_Click"/>
-
-    </Grid>
-</Page>

+ 0 - 44
ProjectAnalogParus/ReqisitesSholarshipsPage.xaml.cs

@@ -1,44 +0,0 @@
-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;
-
-namespace ProjectAnalogParus
-{
-    /// <summary>
-    /// Логика взаимодействия для ReqisitesSholarshipsPage.xaml
-    /// </summary>
-    public partial class ReqisitesSholarshipsPage : Page
-    {
-        public ReqisitesSholarshipsPage()
-        {
-            InitializeComponent();
-            gr672_bdaEntities db = new gr672_bdaEntities();
-
-            cmbStudent.ItemsSource = db.Student.ToList();
-            cmbStudent.SelectedValuePath = "IdStudent";
-
-            cmbUser.ItemsSource = db.User.ToList();
-            cmbUser.DisplayMemberPath = "FullNameUser";
-            cmbUser.SelectedValuePath = "IdUser";
-
-            
-
-        }
-
-        private void ScholarshipSumma_Click(object sender, RoutedEventArgs e)
-        {
-
-        }
-    }
-}

+ 2 - 1
ProjectAnalogParus/StudentPage.xaml

@@ -14,6 +14,7 @@
         
         <Button Content="Поощрения" HorizontalAlignment="Left" Margin="55,117,0,0" VerticalAlignment="Top" Width="75" Click="OpenEncouragementPage"/>
         <Button Content="Детали" HorizontalAlignment="Left" Margin="587,44,0,0" VerticalAlignment="Top" Width="75" Click="OpenDetailsStudent"/>
-
+        <Button Content="Начисления" HorizontalAlignment="Left" Margin="402,44,0,0" VerticalAlignment="Top" Width="95" Height="22" Click="AccrualsClick"/>
+        
     </Grid>
 </Page>

+ 5 - 1
ProjectAnalogParus/StudentPage.xaml.cs

@@ -45,7 +45,11 @@ namespace ProjectAnalogParus
         {
             FramePage.MainFrame.Navigate(new DetailsStudentPage());
         }
-       
+
+        private void AccrualsClick(object sender, RoutedEventArgs e)
+        {
+            FramePage.MainFrame.Navigate(new AccrualsPage());
+        }
     }
 }
 

+ 5 - 0
ProjectAnalogParus/packages.config

@@ -1,5 +1,10 @@
 <?xml version="1.0" encoding="utf-8"?>
 <packages>
+  <package id="Castle.Core" version="4.4.0" targetFramework="net472" />
+  <package id="DocumentFormat.OpenXml" version="2.12.3" targetFramework="net472" />
   <package id="EntityFramework" version="6.2.0" targetFramework="net472" />
   <package id="EntityFramework.ru" version="6.2.0" targetFramework="net472" />
+  <package id="Moq" version="4.16.1" targetFramework="net472" />
+  <package id="System.Runtime.CompilerServices.Unsafe" version="4.5.3" targetFramework="net472" />
+  <package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net472" />
 </packages>