Вячеслав Терешенко 1 год назад
Родитель
Сommit
5f0cdc1e6e

+ 8 - 1
ImpulseVision/Animator.cs

@@ -48,7 +48,14 @@ namespace ImpulseVision
 
                 Parallel.For(0, Count(), index =>
                 {
-                    AnimationList[index].UpdateFrame();
+                    try
+                    {
+                        AnimationList[index].UpdateFrame();
+                    }
+                    catch
+                    {
+                        
+                    }
                 });
 
                 Thread.Sleep((int)Interval);

Разница между файлами не показана из-за своего большого размера
+ 578 - 266
ImpulseVision/FormMain.Designer.cs


+ 58 - 0
ImpulseVision/FormMain.cs

@@ -23,6 +23,7 @@ using System.Runtime.CompilerServices;
 using Timer = System.Windows.Forms.Timer;
 using ZedGraph;
 using static System.Windows.Forms.VisualStyles.VisualStyleElement.StartPanel;
+using Excel = Microsoft.Office.Interop.Excel;
 
 namespace ImpulseVision
 {
@@ -1296,5 +1297,62 @@ where [Login] = '{login}'";
         {
 
         }
+
+        private void BtnExport_Click(object sender, EventArgs e)
+        {
+            ExportToExcel();
+        }
+        /// <summary>
+        /// экспорт информации о посещениях в Excel
+        /// </summary>
+        private void ExportToExcel()
+        {
+            Excel.Application App = new Excel.Application();
+            App.Visible = true;
+            App.Workbooks.Open(Application.StartupPath + "\\Source\\Report.xlsx", Type.Missing, true);
+            Excel.Worksheet List1 = App.Worksheets.get_Item(1);
+            bool NoDetected = false;
+            try
+            {
+                for (int i = 0; i < TabJournal.Controls.Count; i++)
+                {
+                    NoDetected = false;
+                    TileOvals Tile = TabJournal.Controls[i] as TileOvals;
+                    List1.get_Range($"A{i + 4}").Value = i + 1;
+                    List1.get_Range($"B{i + 4}").Value = Tile.LblNameUser.Text.Trim();
+                    List1.get_Range($"C{i + 4}").Value = Tile.LblTimeEntrance.Text.Trim();
+                    if (Tile.LblTimeExit.Text.Trim() == string.Empty)
+                    {
+                        List1.get_Range($"D{i + 4}").Value = "";
+                        NoDetected = true;
+                    }
+                    else
+                    {
+                        List1.get_Range($"D{i + 4}").Value = Tile.LblTimeExit.Text.Trim();
+                    }
+
+                    List1.get_Range($"E{i + 4}").Value = Tile.LblDate.Text.Trim();
+                    if (!NoDetected)
+                    {
+                        DateTime Tm1 = DateTime.Parse(Tile.LblTimeEntrance.Text.Trim());
+                        DateTime Tm2 = DateTime.Parse(Tile.LblTimeExit.Text.Trim());
+
+                        TimeSpan Dif = Tm2 - Tm1;
+                        DateTime TimeOnPlace = DateTime.Parse(Dif.ToString()); ;
+                        List1.get_Range($"F{i + 4}").Value = TimeOnPlace.ToString("HH часов mm минут").ToString();
+                    }
+                    if (NoDetected)
+                    {
+                        List1.get_Range($"A{i + 4}:F{i + 4}").Interior.Color = Color.Red;
+                    }
+                    List1.get_Range($"A{i + 4}:F{i + 4}").Borders.LineStyle = Excel.XlLineStyle.xlContinuous;
+                }
+            }
+            catch (Exception ex)
+            {
+                MessageBox.Show(ex.Message + "  При создании отчёта в Microsoft Excel произошла неизвестная ошибка!", "ImpulseVision", MessageBoxButtons.OK, MessageBoxIcon.Error);
+                return;
+            }
+        }
     }
 }

+ 29 - 0
ImpulseVision/ImpulseVision.csproj

@@ -323,6 +323,35 @@
     <Content Include="ImpulseVision_Icons.ico" />
     <None Include="Resources\ImpulseVision_Icon.png" />
   </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" />
   <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
     <PropertyGroup>

BIN
ImpulseVision/bin/Debug/ImpulseVision.exe


BIN
ImpulseVision/bin/Debug/Source/ImpulseVision.exe


BIN
ImpulseVision/bin/Debug/Source/Report.xlsx


Некоторые файлы не были показаны из-за большого количества измененных файлов