Skip to content

Commit

Permalink
Student Records DataGridView
Browse files Browse the repository at this point in the history
  • Loading branch information
PP-Namias committed May 25, 2024
1 parent 79d6212 commit c835621
Show file tree
Hide file tree
Showing 27 changed files with 402 additions and 223 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion StudentAttendanceManagementSystem/ArchiveLoginLogs.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,8 @@
FontFamily="Century Gothic"
FontWeight="Bold"
Margin="700,-75,0,0"
Click="btnOpenArchive_Click" Padding="0" >
Click="btnOpenArchive_Click"
Padding="0" >
<WrapPanel HorizontalAlignment="Center" >
<materialDesign:PackIcon
Kind="Show"
Expand Down
6 changes: 5 additions & 1 deletion StudentAttendanceManagementSystem/ArchiveLoginLogs.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ private void LoadData()
.Select(log => new LoginLogViewModel(log))
.ToList();
tblArchivedLogs.ItemsSource = loginLogViewModels;
NumberOfLogs.Text = $"Number of archived logs: {archivedLoginLogs.Count}";
}
}

Expand Down Expand Up @@ -57,11 +58,14 @@ private void btnUnarchive_Click(object sender, RoutedEventArgs e)

private void btnOpenArchive_Click(object sender, RoutedEventArgs e)
{

LoginLogsViewer x = new LoginLogsViewer();
UserPages.Children.Clear();
UserPages.Children.Add(x);
}

private void btnRefresh_Click(object sender, RoutedEventArgs e)
{
LoadData();

}
}
Expand Down
57 changes: 49 additions & 8 deletions StudentAttendanceManagementSystem/DbContexts/AppDbContext.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using StudentAttendanceManagementSystem.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using StudentAttendanceManagementSystem.Models;
using System;
using System.Linq;

Expand All @@ -17,12 +17,23 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
string connectionString = "Host=localhost; port=5432; Database=SAMS; User Id=postgres; Password=Namias99;";
optionsBuilder.UseNpgsql(connectionString);
}


protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
// Additional configuration and model customization can be added here
}

public IQueryable<LoginUser> GetNonArchivedLoginLogs()
{
return LoginLogs.Where(log => !log.Archived);
}


public IQueryable<Students> GetNonArchivedStudents()
{
return Students.Where(student => !student.Archived);
}

public void SaveUser(User user)
{
try
Expand Down Expand Up @@ -78,11 +89,41 @@ public void SaveStudentAttendance(Students_Attendance studentAttendance)
throw;
}
}
/*
public IQueryable<LoginLog> GetNonArchivedLoginLogs()

public void ArchiveStudent(int studentId)
{
return LoginLogs.Where(log => !log.Archived);
try
{
var student = Students.Find(studentId);
if (student != null)
{
student.Archived = true;
SaveChanges();
}
}
catch (DbUpdateException ex)
{
Console.WriteLine($"Error archiving student: {ex.Message}");
throw;
}
}

public void ArchiveLoginLog(int loginLogId)
{
try
{
var loginLog = LoginLogs.Find(loginLogId);
if (loginLog != null)
{
loginLog.Archived = true;
SaveChanges();
}
}
catch (DbUpdateException ex)
{
Console.WriteLine($"Error archiving login log: {ex.Message}");
throw;
}
}
*/
}
}
1 change: 1 addition & 0 deletions StudentAttendanceManagementSystem/LoginLogsViewer.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ private void LoadData()
.Select(log => new LoginLogViewModel(log))
.ToList();
tblLoginLogs.ItemsSource = loginLogViewModels;
NumberOfLogs.Text = $"Number of logs: {nonArchivedLoginLogs.Count}";
}
}

Expand Down
2 changes: 2 additions & 0 deletions StudentAttendanceManagementSystem/Models/Students.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public class Students
public string Section { get; set; } = string.Empty;
[Required]
public string StudentId { get; set; } = string.Empty;
[Required]
public bool Archived { get; set; } = false;
}
}

119 changes: 54 additions & 65 deletions StudentAttendanceManagementSystem/StudentRecord.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:src="http://metro.mahapps.com/winfx/xaml/controls"

Background="#111315"
Background="#070F2B"
FontFamily="pack://application:,,,/MaterialDesignThemes.Wpf;component/Resources/Roboto/#Roboto"
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
TextElement.FontWeight="Regular"
Expand Down Expand Up @@ -63,7 +63,7 @@
</ResourceDictionary>
</UserControl.Resources>

<Grid Background="#111315">
<Grid Background="#070F2B">
<Border Canvas.Left="55"
Canvas.Top="30"
Height="700"
Expand Down Expand Up @@ -98,33 +98,22 @@
BorderThickness="1"
CornerRadius="18"
Margin="50,0,50,0">

<DataGrid Grid.Row="1"
ScrollViewer.CanContentScroll="True"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
AutoGenerateColumns="True"
Height="263"
HorizontalAlignment="Center"
Name="DataGrid" Width="885"
AlternatingRowBackground="#111315"
CanUserAddRows="False"
IsReadOnly="True"
Panel.ZIndex="3"
SelectionMode="Single"
SelectionUnit="Cell">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Remark}" Header="Remark" Width="Auto"/>
<DataGridTextColumn Binding="{Binding Name}" Header="Name" Width="Auto"/>
<DataGridTextColumn Binding="{Binding Stud_Id}" Header="Student ID" Width="Auto"/>
<DataGridTextColumn Binding="{Binding Course}" Header="Course" Width="Auto"/>
<DataGridTextColumn Binding="{Binding Year}" Header="Year" Width="Auto"/>
<DataGridTextColumn Binding="{Binding Section}" Header="Section" Width="Auto"/>
<DataGridTextColumn Binding="{Binding Status}" Header="Status" Width="Auto"/>
<DataGridTextColumn Binding="{Binding Archived}" Header="Archived" Width="Auto"/>
<DataGridTextColumn Binding="{Binding Date, StringFormat=d,ConverterCulture=en-NZ}" Header="Date" Width="Auto" MinWidth="20"/>
<DataGridTextColumn Binding="{Binding Time, StringFormat=d,ConverterCulture=en-NZ}" Header="Time" Width="Auto" MinWidth="20"/>
</DataGrid.Columns>

<DataGrid x:Name="tblStudentRecords"
Grid.Row="1"
ScrollViewer.CanContentScroll="True"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
AutoGenerateColumns="True"
Height="263"
HorizontalAlignment="Center"
Width="885"
AlternatingRowBackground="LightGray"
CanUserAddRows="False"
IsReadOnly="False"
Panel.ZIndex="3"
SelectionMode="Single"
SelectionUnit="Cell">
</DataGrid>
</Border>
<TextBlock Name="Filter"
Expand All @@ -138,8 +127,8 @@
Select Filters
</TextBlock>

<ComboBox
Background="#111315"
<ComboBox x:Name="cmbFilter"
Background="#070F2B"
Foreground="White"
Grid.Row="0"
Margin="50,5,0,0"
Expand All @@ -156,43 +145,43 @@


materialDesign:HintAssist.IsFloating = "True"
materialDesign:HintAssist.Background="#111315"
materialDesign:HintAssist.Foreground="White">
materialDesign:HintAssist.Background="#070F2B"
materialDesign:HintAssist.Foreground="White" ContextMenuClosing="cmbFilter_ContextMenuClosing">

<ComboBoxItem
Background="#111315"
Background="#070F2B"
Foreground="White"
Content="Remark" />
<ComboBoxItem
Background="#111315"
Background="#070F2B"
Foreground="White"
Content="Name" />
<ComboBoxItem
Background="#111315"
Background="#070F2B"
Foreground="White"
Content="Student ID" />
<ComboBoxItem
Background="#111315"
Background="#070F2B"
Foreground="White"
Content="Course" />
<ComboBoxItem
Background="#111315"
Background="#070F2B"
Foreground="White"
Content="Year" />
<ComboBoxItem
Background="#111315"
Background="#070F2B"
Foreground="White"
Content="Section" />
<ComboBoxItem
Background="#111315"
Background="#070F2B"
Foreground="White"
Content="Status" />
<ComboBoxItem
Background="#111315"
Background="#070F2B"
Foreground="White"
Content="Archived" />
<ComboBoxItem
Background="#111315"
Background="#070F2B"
Foreground="White"
Content="Date" />

Expand All @@ -204,7 +193,7 @@


<StackPanel Width="250" HorizontalAlignment="Left" Margin="50,0,0,0">
<TextBox x:Name="TextBoxTextCounter"
<TextBox x:Name="txtFilter"
Height="70"
materialDesign:HintAssist.Hint="Input Name Here"
AcceptsReturn="True"
Expand All @@ -220,8 +209,8 @@
BorderThickness="1"

materialDesign:HintAssist.IsFloating = "True"
materialDesign:HintAssist.Background="#111315"
materialDesign:HintAssist.Foreground="White"/>
materialDesign:HintAssist.Background="#070F2B"
materialDesign:HintAssist.Foreground="White" TextInput="txtFilter_TextInput"/>
</StackPanel>
<Border x:Name="CalendarBorder"
BorderThickness="2"
Expand All @@ -246,10 +235,10 @@
</DrawingBrush>
</Border.BorderBrush>
<Calendar x:Name="cldArchive"
materialDesign:CalendarAssist.HeaderBackground="#111315"
materialDesign:CalendarAssist.HeaderBackground="#070F2B"
materialDesign:CalendarAssist.HeaderForeground="White"
materialDesign:CalendarAssist.Orientation="Horizontal"
Background="#111315"
Background="#070F2B"
Foreground="White"
BorderBrush="DarkGray"
CalendarButtonStyle="{DynamicResource CustomCalendarButton}"
Expand All @@ -260,9 +249,9 @@
</Border>


<Button x:Name="btnScanner"
<Button x:Name="btnArchive"
ToolTip="Archive Student Records"
Background="#0a0a0a"
Background="#1B1A55"
materialDesign:ButtonAssist.CornerRadius="10"
Foreground="White"
FontSize="20"
Expand All @@ -278,20 +267,19 @@
Click="btnArchive_Click" >
<WrapPanel HorizontalAlignment="Center">
<materialDesign:PackIcon
Kind="BarcodeScanner"
Kind="ArchivePlus"
Width="45"
Height="45" />
<TextBlock Text="| Scanner"
<TextBlock Text="| Archive"
VerticalAlignment="Center"
FontWeight="SemiBold"
Margin="10 0" />
</WrapPanel>
</Button>


<Button x:Name="btnArchive"
ToolTip="Archive Student Records"
Background="#0a0a0a"
<Button x:Name="btnScanner"
ToolTip="Scanner Student Records"
Background="#1B1A55"
materialDesign:ButtonAssist.CornerRadius="10"
Foreground="White"
FontSize="20"
Expand All @@ -303,23 +291,24 @@
BorderThickness="1"
FontFamily="Century Gothic"
FontWeight="Bold"
Margin="700,-225,0,0"
Click="btnArchive_Click" >
Margin="700,-75,0,0"
Click="btnScanner_Click" >
<WrapPanel HorizontalAlignment="Center">
<materialDesign:PackIcon
Kind="ArchivePlus"
Kind="BarcodeScanner"
Width="45"
Height="45" />
<TextBlock Text="| Archive"
<TextBlock Text="| Scanner"
VerticalAlignment="Center"
FontWeight="SemiBold"
Margin="10 0" />
</WrapPanel>
</Button>

<Button x:Name="btnEdit"

<Button x:Name="btnRefresh"
ToolTip="Edit Student Records"
Background="#0a0a0a"
Background="#1B1A55"
materialDesign:ButtonAssist.CornerRadius="10"
Foreground="White"
FontSize="20"
Expand All @@ -331,14 +320,14 @@
BorderThickness="1"
FontFamily="Century Gothic"
FontWeight="Bold"
Margin="700,-75,0,0"
Click="btnEdit_Click">
Margin="700,-225,0,0"
Click="btnRefresh_Click">
<WrapPanel HorizontalAlignment="Center">
<materialDesign:PackIcon
Kind="EditBoxOutline"
Kind="RefreshCircle"
Width="45"
Height="45" />
<TextBlock Text="| Edit"
<TextBlock Text="| Refresh"
VerticalAlignment="Center"
FontWeight="SemiBold"
Margin="10 0" />
Expand Down
Loading

0 comments on commit c835621

Please sign in to comment.