Initial commit
This commit is contained in:
2
.gitattributes
vendored
Normal file
2
.gitattributes
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# Auto detect text files and perform LF normalization
|
||||||
|
* text=auto
|
||||||
401
.gitignore
vendored
Normal file
401
.gitignore
vendored
Normal file
@@ -0,0 +1,401 @@
|
|||||||
|
## Ignore Visual Studio temporary files, build results, and
|
||||||
|
## files generated by popular Visual Studio add-ons.
|
||||||
|
##
|
||||||
|
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
|
||||||
|
|
||||||
|
# User-specific files
|
||||||
|
*.rsuser
|
||||||
|
*.suo
|
||||||
|
*.user
|
||||||
|
*.userosscache
|
||||||
|
*.sln.docstates
|
||||||
|
|
||||||
|
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||||
|
*.userprefs
|
||||||
|
|
||||||
|
# Mono auto generated files
|
||||||
|
mono_crash.*
|
||||||
|
|
||||||
|
# Build results
|
||||||
|
[Dd]ebug/
|
||||||
|
[Dd]ebugPublic/
|
||||||
|
[Rr]elease/
|
||||||
|
[Rr]eleases/
|
||||||
|
x64/
|
||||||
|
x86/
|
||||||
|
[Ww][Ii][Nn]32/
|
||||||
|
[Aa][Rr][Mm]/
|
||||||
|
[Aa][Rr][Mm]64/
|
||||||
|
bld/
|
||||||
|
[Bb]in/
|
||||||
|
[Oo]bj/
|
||||||
|
[Ll]og/
|
||||||
|
[Ll]ogs/
|
||||||
|
|
||||||
|
# Visual Studio 2015/2017 cache/options directory
|
||||||
|
.vs/
|
||||||
|
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||||
|
#wwwroot/
|
||||||
|
|
||||||
|
# Visual Studio 2017 auto generated files
|
||||||
|
Generated\ Files/
|
||||||
|
|
||||||
|
# MSTest test Results
|
||||||
|
[Tt]est[Rr]esult*/
|
||||||
|
[Bb]uild[Ll]og.*
|
||||||
|
|
||||||
|
# NUnit
|
||||||
|
*.VisualState.xml
|
||||||
|
TestResult.xml
|
||||||
|
nunit-*.xml
|
||||||
|
|
||||||
|
# Build Results of an ATL Project
|
||||||
|
[Dd]ebugPS/
|
||||||
|
[Rr]eleasePS/
|
||||||
|
dlldata.c
|
||||||
|
|
||||||
|
# Benchmark Results
|
||||||
|
BenchmarkDotNet.Artifacts/
|
||||||
|
|
||||||
|
# .NET Core
|
||||||
|
project.lock.json
|
||||||
|
project.fragment.lock.json
|
||||||
|
artifacts/
|
||||||
|
|
||||||
|
# ASP.NET Scaffolding
|
||||||
|
ScaffoldingReadMe.txt
|
||||||
|
|
||||||
|
# StyleCop
|
||||||
|
StyleCopReport.xml
|
||||||
|
|
||||||
|
# Files built by Visual Studio
|
||||||
|
*_i.c
|
||||||
|
*_p.c
|
||||||
|
*_h.h
|
||||||
|
*.ilk
|
||||||
|
*.meta
|
||||||
|
*.obj
|
||||||
|
*.iobj
|
||||||
|
*.pch
|
||||||
|
*.pdb
|
||||||
|
*.ipdb
|
||||||
|
*.pgc
|
||||||
|
*.pgd
|
||||||
|
*.rsp
|
||||||
|
# but not Directory.Build.rsp, as it configures directory-level build defaults
|
||||||
|
!Directory.Build.rsp
|
||||||
|
*.sbr
|
||||||
|
*.tlb
|
||||||
|
*.tli
|
||||||
|
*.tlh
|
||||||
|
*.tmp
|
||||||
|
*.tmp_proj
|
||||||
|
*_wpftmp.csproj
|
||||||
|
*.log
|
||||||
|
*.tlog
|
||||||
|
*.vspscc
|
||||||
|
*.vssscc
|
||||||
|
.builds
|
||||||
|
*.pidb
|
||||||
|
*.svclog
|
||||||
|
*.scc
|
||||||
|
|
||||||
|
# Chutzpah Test files
|
||||||
|
_Chutzpah*
|
||||||
|
|
||||||
|
# Visual C++ cache files
|
||||||
|
ipch/
|
||||||
|
*.aps
|
||||||
|
*.ncb
|
||||||
|
*.opendb
|
||||||
|
*.opensdf
|
||||||
|
*.sdf
|
||||||
|
*.cachefile
|
||||||
|
*.VC.db
|
||||||
|
*.VC.VC.opendb
|
||||||
|
|
||||||
|
# Visual Studio profiler
|
||||||
|
*.psess
|
||||||
|
*.vsp
|
||||||
|
*.vspx
|
||||||
|
*.sap
|
||||||
|
|
||||||
|
# Visual Studio Trace Files
|
||||||
|
*.e2e
|
||||||
|
|
||||||
|
# TFS 2012 Local Workspace
|
||||||
|
$tf/
|
||||||
|
|
||||||
|
# Guidance Automation Toolkit
|
||||||
|
*.gpState
|
||||||
|
|
||||||
|
# ReSharper is a .NET coding add-in
|
||||||
|
_ReSharper*/
|
||||||
|
*.[Rr]e[Ss]harper
|
||||||
|
*.DotSettings.user
|
||||||
|
|
||||||
|
# TeamCity is a build add-in
|
||||||
|
_TeamCity*
|
||||||
|
|
||||||
|
# DotCover is a Code Coverage Tool
|
||||||
|
*.dotCover
|
||||||
|
|
||||||
|
# AxoCover is a Code Coverage Tool
|
||||||
|
.axoCover/*
|
||||||
|
!.axoCover/settings.json
|
||||||
|
|
||||||
|
# Coverlet is a free, cross platform Code Coverage Tool
|
||||||
|
coverage*.json
|
||||||
|
coverage*.xml
|
||||||
|
coverage*.info
|
||||||
|
|
||||||
|
# Visual Studio code coverage results
|
||||||
|
*.coverage
|
||||||
|
*.coveragexml
|
||||||
|
|
||||||
|
# NCrunch
|
||||||
|
_NCrunch_*
|
||||||
|
.NCrunch_*
|
||||||
|
.*crunch*.local.xml
|
||||||
|
nCrunchTemp_*
|
||||||
|
|
||||||
|
# MightyMoose
|
||||||
|
*.mm.*
|
||||||
|
AutoTest.Net/
|
||||||
|
|
||||||
|
# Web workbench (sass)
|
||||||
|
.sass-cache/
|
||||||
|
|
||||||
|
# Installshield output folder
|
||||||
|
[Ee]xpress/
|
||||||
|
|
||||||
|
# DocProject is a documentation generator add-in
|
||||||
|
DocProject/buildhelp/
|
||||||
|
DocProject/Help/*.HxT
|
||||||
|
DocProject/Help/*.HxC
|
||||||
|
DocProject/Help/*.hhc
|
||||||
|
DocProject/Help/*.hhk
|
||||||
|
DocProject/Help/*.hhp
|
||||||
|
DocProject/Help/Html2
|
||||||
|
DocProject/Help/html
|
||||||
|
|
||||||
|
# Click-Once directory
|
||||||
|
publish/
|
||||||
|
|
||||||
|
# Publish Web Output
|
||||||
|
*.[Pp]ublish.xml
|
||||||
|
*.azurePubxml
|
||||||
|
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||||
|
# but database connection strings (with potential passwords) will be unencrypted
|
||||||
|
*.pubxml
|
||||||
|
*.publishproj
|
||||||
|
|
||||||
|
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||||
|
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||||
|
# in these scripts will be unencrypted
|
||||||
|
PublishScripts/
|
||||||
|
|
||||||
|
# NuGet Packages
|
||||||
|
*.nupkg
|
||||||
|
# NuGet Symbol Packages
|
||||||
|
*.snupkg
|
||||||
|
# The packages folder can be ignored because of Package Restore
|
||||||
|
**/[Pp]ackages/*
|
||||||
|
# except build/, which is used as an MSBuild target.
|
||||||
|
!**/[Pp]ackages/build/
|
||||||
|
# Uncomment if necessary however generally it will be regenerated when needed
|
||||||
|
#!**/[Pp]ackages/repositories.config
|
||||||
|
# NuGet v3's project.json files produces more ignorable files
|
||||||
|
*.nuget.props
|
||||||
|
*.nuget.targets
|
||||||
|
|
||||||
|
# Microsoft Azure Build Output
|
||||||
|
csx/
|
||||||
|
*.build.csdef
|
||||||
|
|
||||||
|
# Microsoft Azure Emulator
|
||||||
|
ecf/
|
||||||
|
rcf/
|
||||||
|
|
||||||
|
# Windows Store app package directories and files
|
||||||
|
AppPackages/
|
||||||
|
BundleArtifacts/
|
||||||
|
Package.StoreAssociation.xml
|
||||||
|
_pkginfo.txt
|
||||||
|
*.appx
|
||||||
|
*.appxbundle
|
||||||
|
*.appxupload
|
||||||
|
|
||||||
|
# Visual Studio cache files
|
||||||
|
# files ending in .cache can be ignored
|
||||||
|
*.[Cc]ache
|
||||||
|
# but keep track of directories ending in .cache
|
||||||
|
!?*.[Cc]ache/
|
||||||
|
|
||||||
|
# Others
|
||||||
|
ClientBin/
|
||||||
|
~$*
|
||||||
|
*~
|
||||||
|
*.dbmdl
|
||||||
|
*.dbproj.schemaview
|
||||||
|
*.jfm
|
||||||
|
*.pfx
|
||||||
|
*.publishsettings
|
||||||
|
orleans.codegen.cs
|
||||||
|
|
||||||
|
# Including strong name files can present a security risk
|
||||||
|
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||||
|
#*.snk
|
||||||
|
|
||||||
|
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||||
|
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||||
|
#bower_components/
|
||||||
|
|
||||||
|
# RIA/Silverlight projects
|
||||||
|
Generated_Code/
|
||||||
|
|
||||||
|
# Backup & report files from converting an old project file
|
||||||
|
# to a newer Visual Studio version. Backup files are not needed,
|
||||||
|
# because we have git ;-)
|
||||||
|
_UpgradeReport_Files/
|
||||||
|
Backup*/
|
||||||
|
UpgradeLog*.XML
|
||||||
|
UpgradeLog*.htm
|
||||||
|
ServiceFabricBackup/
|
||||||
|
*.rptproj.bak
|
||||||
|
|
||||||
|
# SQL Server files
|
||||||
|
*.mdf
|
||||||
|
*.ldf
|
||||||
|
*.ndf
|
||||||
|
|
||||||
|
# Business Intelligence projects
|
||||||
|
*.rdl.data
|
||||||
|
*.bim.layout
|
||||||
|
*.bim_*.settings
|
||||||
|
*.rptproj.rsuser
|
||||||
|
*- [Bb]ackup.rdl
|
||||||
|
*- [Bb]ackup ([0-9]).rdl
|
||||||
|
*- [Bb]ackup ([0-9][0-9]).rdl
|
||||||
|
|
||||||
|
# Microsoft Fakes
|
||||||
|
FakesAssemblies/
|
||||||
|
|
||||||
|
# GhostDoc plugin setting file
|
||||||
|
*.GhostDoc.xml
|
||||||
|
|
||||||
|
# Node.js Tools for Visual Studio
|
||||||
|
.ntvs_analysis.dat
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# Visual Studio 6 build log
|
||||||
|
*.plg
|
||||||
|
|
||||||
|
# Visual Studio 6 workspace options file
|
||||||
|
*.opt
|
||||||
|
|
||||||
|
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||||
|
*.vbw
|
||||||
|
|
||||||
|
# Visual Studio 6 auto-generated project file (contains which files were open etc.)
|
||||||
|
*.vbp
|
||||||
|
|
||||||
|
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
|
||||||
|
*.dsw
|
||||||
|
*.dsp
|
||||||
|
|
||||||
|
# Visual Studio 6 technical files
|
||||||
|
*.ncb
|
||||||
|
*.aps
|
||||||
|
|
||||||
|
# Visual Studio LightSwitch build output
|
||||||
|
**/*.HTMLClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/ModelManifest.xml
|
||||||
|
**/*.Server/GeneratedArtifacts
|
||||||
|
**/*.Server/ModelManifest.xml
|
||||||
|
_Pvt_Extensions
|
||||||
|
|
||||||
|
# Paket dependency manager
|
||||||
|
.paket/paket.exe
|
||||||
|
paket-files/
|
||||||
|
|
||||||
|
# FAKE - F# Make
|
||||||
|
.fake/
|
||||||
|
|
||||||
|
# CodeRush personal settings
|
||||||
|
.cr/personal
|
||||||
|
|
||||||
|
# Python Tools for Visual Studio (PTVS)
|
||||||
|
__pycache__/
|
||||||
|
*.pyc
|
||||||
|
|
||||||
|
# Cake - Uncomment if you are using it
|
||||||
|
# tools/**
|
||||||
|
# !tools/packages.config
|
||||||
|
|
||||||
|
# Tabs Studio
|
||||||
|
*.tss
|
||||||
|
|
||||||
|
# Telerik's JustMock configuration file
|
||||||
|
*.jmconfig
|
||||||
|
|
||||||
|
# BizTalk build output
|
||||||
|
*.btp.cs
|
||||||
|
*.btm.cs
|
||||||
|
*.odx.cs
|
||||||
|
*.xsd.cs
|
||||||
|
|
||||||
|
# OpenCover UI analysis results
|
||||||
|
OpenCover/
|
||||||
|
|
||||||
|
# Azure Stream Analytics local run output
|
||||||
|
ASALocalRun/
|
||||||
|
|
||||||
|
# MSBuild Binary and Structured Log
|
||||||
|
*.binlog
|
||||||
|
|
||||||
|
# NVidia Nsight GPU debugger configuration file
|
||||||
|
*.nvuser
|
||||||
|
|
||||||
|
# MFractors (Xamarin productivity tool) working folder
|
||||||
|
.mfractor/
|
||||||
|
|
||||||
|
# Local History for Visual Studio
|
||||||
|
.localhistory/
|
||||||
|
|
||||||
|
# Visual Studio History (VSHistory) files
|
||||||
|
.vshistory/
|
||||||
|
|
||||||
|
# BeatPulse healthcheck temp database
|
||||||
|
healthchecksdb
|
||||||
|
|
||||||
|
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||||
|
MigrationBackup/
|
||||||
|
|
||||||
|
# Ionide (cross platform F# VS Code tools) working folder
|
||||||
|
.ionide/
|
||||||
|
|
||||||
|
# Fody - auto-generated XML schema
|
||||||
|
FodyWeavers.xsd
|
||||||
|
|
||||||
|
# VS Code files for those working on multiple tools
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/settings.json
|
||||||
|
!.vscode/tasks.json
|
||||||
|
!.vscode/launch.json
|
||||||
|
!.vscode/extensions.json
|
||||||
|
*.code-workspace
|
||||||
|
|
||||||
|
# Local History for Visual Studio Code
|
||||||
|
.history/
|
||||||
|
|
||||||
|
# Windows Installer files from build outputs
|
||||||
|
*.cab
|
||||||
|
*.msi
|
||||||
|
*.msix
|
||||||
|
*.msm
|
||||||
|
*.msp
|
||||||
|
|
||||||
|
# JetBrains Rider
|
||||||
|
*.sln.iml
|
||||||
25
HCI_TaskTracker.sln
Normal file
25
HCI_TaskTracker.sln
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.14.36908.2
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HCI_TaskTracker", "HCI_TaskTracker\HCI_TaskTracker.csproj", "{EDA1B770-1AD9-448F-8DBB-C7E99121B678}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{EDA1B770-1AD9-448F-8DBB-C7E99121B678}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{EDA1B770-1AD9-448F-8DBB-C7E99121B678}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{EDA1B770-1AD9-448F-8DBB-C7E99121B678}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{EDA1B770-1AD9-448F-8DBB-C7E99121B678}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {1E8CB369-9EBE-4C00-901F-F33C327D5527}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
16
HCI_TaskTracker/ActivityLog.cs
Normal file
16
HCI_TaskTracker/ActivityLog.cs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace HCI_TaskTracker
|
||||||
|
{
|
||||||
|
public class ActivityLog
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Action { get; set; }
|
||||||
|
public DateTime Timestamp { get; set; }
|
||||||
|
public int UserId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
38
HCI_TaskTracker/AdminView.xaml
Normal file
38
HCI_TaskTracker/AdminView.xaml
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
<UserControl x:Class="HCI_TaskTracker.AdminView"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
|
|
||||||
|
<Grid Margin="10">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="*"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<DataGrid x:Name="GridUsers"
|
||||||
|
AutoGenerateColumns="False"
|
||||||
|
CanUserAddRows="False">
|
||||||
|
|
||||||
|
<DataGrid.Columns>
|
||||||
|
<DataGridTextColumn Header="ID" Binding="{Binding Id}" Width="60"/>
|
||||||
|
<DataGridTextColumn Header="Username" Binding="{Binding Username}" Width="200"/>
|
||||||
|
<DataGridTextColumn Header="Password" Binding="{Binding Password}" Width="150"/>
|
||||||
|
<DataGridTextColumn Header="Role" Binding="{Binding Role}" Width="100"/>
|
||||||
|
|
||||||
|
<DataGridTemplateColumn Header="X" Width="40">
|
||||||
|
<DataGridTemplateColumn.CellTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<Button Content="X" Tag="{Binding}" Click="Delete_Click"/>
|
||||||
|
</DataTemplate>
|
||||||
|
</DataGridTemplateColumn.CellTemplate>
|
||||||
|
</DataGridTemplateColumn>
|
||||||
|
</DataGrid.Columns>
|
||||||
|
</DataGrid>
|
||||||
|
|
||||||
|
<StackPanel Grid.Row="1" Orientation="Horizontal" Margin="0,10,0,0">
|
||||||
|
<TextBox x:Name="NewUsername" Width="150" Margin="0,0,10,0"/>
|
||||||
|
<TextBox x:Name="NewPassword" Width="150" Margin="0,0,10,0"/>
|
||||||
|
<TextBox x:Name="NewRole" Width="100" Margin="0,0,10,0"/>
|
||||||
|
<Button Content="Hinzufügen" Click="Add_Click"/>
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
||||||
111
HCI_TaskTracker/AdminView.xaml.cs
Normal file
111
HCI_TaskTracker/AdminView.xaml.cs
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
using MySql.Data.MySqlClient;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
|
||||||
|
namespace HCI_TaskTracker
|
||||||
|
{
|
||||||
|
public partial class AdminView : UserControl
|
||||||
|
{
|
||||||
|
string ConnStr = "server=mysql.pb.bib.de;uid=pba3h24abd;pwd=a2UJEGJtjrsb;database=pba3h24abd_TaskTracker";
|
||||||
|
|
||||||
|
public AdminView()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
LoadUsers();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoadUsers()
|
||||||
|
{
|
||||||
|
var list = new List<UserRow>();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var conn = new MySqlConnection(ConnStr);
|
||||||
|
conn.Open();
|
||||||
|
|
||||||
|
string sql = "SELECT id, username, password, role FROM users ORDER BY id DESC;";
|
||||||
|
using var cmd = new MySqlCommand(sql, conn);
|
||||||
|
using var r = cmd.ExecuteReader();
|
||||||
|
|
||||||
|
while (r.Read())
|
||||||
|
{
|
||||||
|
list.Add(new UserRow
|
||||||
|
{
|
||||||
|
Id = r.GetInt32("id"),
|
||||||
|
Username = r.GetString("username"),
|
||||||
|
Password = r.GetString("password"),
|
||||||
|
Role = r.GetString("role")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
GridUsers.ItemsSource = list;
|
||||||
|
Console.WriteLine("Users loaded.");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("DB Fehler (Load Users): " + ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Delete_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if ((sender as FrameworkElement)?.Tag is not UserRow u) return;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var conn = new MySqlConnection(ConnStr);
|
||||||
|
conn.Open();
|
||||||
|
|
||||||
|
string sql = "DELETE FROM users WHERE id=@id;";
|
||||||
|
using var cmd = new MySqlCommand(sql, conn);
|
||||||
|
cmd.Parameters.AddWithValue("@id", u.Id);
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
|
||||||
|
Console.WriteLine("User deleted.");
|
||||||
|
LoadUsers();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("DB Fehler (Delete User): " + ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Add_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
string username = NewUsername.Text.Trim();
|
||||||
|
string password = NewPassword.Text.Trim();
|
||||||
|
string role = NewRole.Text.Trim();
|
||||||
|
|
||||||
|
if (username.Length < 3) return;
|
||||||
|
if (password.Length < 3) return;
|
||||||
|
if (role.Length < 3) return;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var conn = new MySqlConnection(ConnStr);
|
||||||
|
conn.Open();
|
||||||
|
|
||||||
|
string sql = "INSERT INTO users (username, password, role) VALUES (@u, @p, @r);";
|
||||||
|
using var cmd = new MySqlCommand(sql, conn);
|
||||||
|
cmd.Parameters.AddWithValue("@u", username);
|
||||||
|
cmd.Parameters.AddWithValue("@p", password);
|
||||||
|
cmd.Parameters.AddWithValue("@r", role);
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
|
||||||
|
Console.WriteLine("User added.");
|
||||||
|
|
||||||
|
NewUsername.Text = "";
|
||||||
|
NewPassword.Text = "";
|
||||||
|
NewRole.Text = "";
|
||||||
|
|
||||||
|
LoadUsers();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("DB Fehler (Add User): " + ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
9
HCI_TaskTracker/App.xaml
Normal file
9
HCI_TaskTracker/App.xaml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<Application x:Class="HCI_TaskTracker.App"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:local="clr-namespace:HCI_TaskTracker"
|
||||||
|
StartupUri="MainWindow.xaml">
|
||||||
|
<Application.Resources>
|
||||||
|
|
||||||
|
</Application.Resources>
|
||||||
|
</Application>
|
||||||
14
HCI_TaskTracker/App.xaml.cs
Normal file
14
HCI_TaskTracker/App.xaml.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using System.Configuration;
|
||||||
|
using System.Data;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
namespace HCI_TaskTracker
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for App.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class App : Application
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
10
HCI_TaskTracker/AssemblyInfo.cs
Normal file
10
HCI_TaskTracker/AssemblyInfo.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
[assembly: ThemeInfo(
|
||||||
|
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||||
|
//(used if a resource is not found in the page,
|
||||||
|
// or application resource dictionaries)
|
||||||
|
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||||
|
//(used if a resource is not found in the page,
|
||||||
|
// app, or any theme specific resource dictionaries)
|
||||||
|
)]
|
||||||
17
HCI_TaskTracker/Aufgabe.cs
Normal file
17
HCI_TaskTracker/Aufgabe.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace HCI_TaskTracker
|
||||||
|
{
|
||||||
|
internal class Aufgabe
|
||||||
|
{
|
||||||
|
public int AufgabeID { get; set; }
|
||||||
|
public List<Task> Tasks { get; set; }
|
||||||
|
public int TeilnechmerId { get; set; }
|
||||||
|
public DateTime ErstellungsDatum { get; set; }
|
||||||
|
public DateTime AbgabefristDatum { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
21
HCI_TaskTracker/DashboardView.xaml
Normal file
21
HCI_TaskTracker/DashboardView.xaml
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<UserControl x:Class="HCI_TaskTracker.DashboardView"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
|
|
||||||
|
<Grid Margin="20">
|
||||||
|
<StackPanel>
|
||||||
|
<TextBlock Text="Dashboard" FontSize="24" FontWeight="Bold" Margin="0,0,0,20"/>
|
||||||
|
|
||||||
|
<TextBlock Text="Tasks:" FontSize="16"/>
|
||||||
|
<TextBlock x:Name="TasksCountText" FontSize="20" Margin="0,0,0,15"/>
|
||||||
|
|
||||||
|
<TextBlock Text="Habits:" FontSize="16"/>
|
||||||
|
<TextBlock x:Name="HabitsCountText" FontSize="20" Margin="0,0,0,15"/>
|
||||||
|
|
||||||
|
<TextBlock Text="Users:" FontSize="16"/>
|
||||||
|
<TextBlock x:Name="UsersCountText" FontSize="20" Margin="0,0,0,15"/>
|
||||||
|
|
||||||
|
<Button Content="Refresh" Width="100" Click="Refresh_Click"/>
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
||||||
54
HCI_TaskTracker/DashboardView.xaml.cs
Normal file
54
HCI_TaskTracker/DashboardView.xaml.cs
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
using MySql.Data.MySqlClient;
|
||||||
|
using System;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
|
||||||
|
namespace HCI_TaskTracker
|
||||||
|
{
|
||||||
|
public partial class DashboardView : UserControl
|
||||||
|
{
|
||||||
|
string ConnStr = "server=mysql.pb.bib.de;uid=pba3h24abd;pwd=a2UJEGJtjrsb;database=pba3h24abd_TaskTracker";
|
||||||
|
|
||||||
|
public DashboardView()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
LoadDashboard();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoadDashboard()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var conn = new MySqlConnection(ConnStr);
|
||||||
|
conn.Open();
|
||||||
|
|
||||||
|
string sqlTasks = "SELECT COUNT(*) FROM tasks;";
|
||||||
|
using var cmdTasks = new MySqlCommand(sqlTasks, conn);
|
||||||
|
int tasksCount = Convert.ToInt32(cmdTasks.ExecuteScalar());
|
||||||
|
|
||||||
|
string sqlHabits = "SELECT COUNT(*) FROM habits;";
|
||||||
|
using var cmdHabits = new MySqlCommand(sqlHabits, conn);
|
||||||
|
int habitsCount = Convert.ToInt32(cmdHabits.ExecuteScalar());
|
||||||
|
|
||||||
|
string sqlUsers = "SELECT COUNT(*) FROM users;";
|
||||||
|
using var cmdUsers = new MySqlCommand(sqlUsers, conn);
|
||||||
|
int usersCount = Convert.ToInt32(cmdUsers.ExecuteScalar());
|
||||||
|
|
||||||
|
TasksCountText.Text = tasksCount.ToString();
|
||||||
|
HabitsCountText.Text = habitsCount.ToString();
|
||||||
|
UsersCountText.Text = usersCount.ToString();
|
||||||
|
|
||||||
|
Console.WriteLine("Dashboard loaded");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("DB Fehler (Dashboard): " + ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Refresh_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
LoadDashboard();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
19
HCI_TaskTracker/HCI_TaskTracker.csproj
Normal file
19
HCI_TaskTracker/HCI_TaskTracker.csproj
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net8.0-windows</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<UseWPF>true</UseWPF>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.0" />
|
||||||
|
<PackageReference Include="MySql.Data" Version="9.6.0" />
|
||||||
|
<PackageReference Include="MySqlConnector" Version="2.5.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
10
HCI_TaskTracker/Habit.cs
Normal file
10
HCI_TaskTracker/Habit.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
namespace HCI_TaskTracker
|
||||||
|
{
|
||||||
|
public class HabitRow
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Name { get; set; } = "";
|
||||||
|
public string Frequency { get; set; } = "";
|
||||||
|
public int UserId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
36
HCI_TaskTracker/HabitsView.xaml
Normal file
36
HCI_TaskTracker/HabitsView.xaml
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<UserControl x:Class="HCI_TaskTracker.HabitsView"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
|
|
||||||
|
<Grid Margin="10">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="*"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<DataGrid x:Name="GridHabits"
|
||||||
|
AutoGenerateColumns="False"
|
||||||
|
CanUserAddRows="False">
|
||||||
|
|
||||||
|
<DataGrid.Columns>
|
||||||
|
<DataGridTextColumn Header="ID" Binding="{Binding Id}" Width="60"/>
|
||||||
|
<DataGridTextColumn Header="Name" Binding="{Binding Name}" Width="200"/>
|
||||||
|
<DataGridTextColumn Header="Frequency" Binding="{Binding Frequency}" Width="*"/>
|
||||||
|
|
||||||
|
<DataGridTemplateColumn Header="X" Width="40">
|
||||||
|
<DataGridTemplateColumn.CellTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<Button Content="X" Tag="{Binding}" Click="Delete_Click"/>
|
||||||
|
</DataTemplate>
|
||||||
|
</DataGridTemplateColumn.CellTemplate>
|
||||||
|
</DataGridTemplateColumn>
|
||||||
|
</DataGrid.Columns>
|
||||||
|
</DataGrid>
|
||||||
|
|
||||||
|
<StackPanel Grid.Row="1" Orientation="Horizontal" Margin="0,10,0,0">
|
||||||
|
<TextBox x:Name="NewName" Width="200" Margin="0,0,10,0"/>
|
||||||
|
<TextBox x:Name="NewFrequency" Width="200" Margin="0,0,10,0"/>
|
||||||
|
<Button Content="Hinzufügen" Click="Add_Click" />
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
||||||
120
HCI_TaskTracker/HabitsView.xaml.cs
Normal file
120
HCI_TaskTracker/HabitsView.xaml.cs
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
using MySql.Data.MySqlClient;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
|
||||||
|
namespace HCI_TaskTracker
|
||||||
|
{
|
||||||
|
public partial class HabitsView : UserControl
|
||||||
|
{
|
||||||
|
string ConnStr = "server=mysql.pb.bib.de;uid=pba3h24abd;pwd=a2UJEGJtjrsb;database=pba3h24abd_TaskTracker";
|
||||||
|
|
||||||
|
int currentUserId = 1;
|
||||||
|
|
||||||
|
public HabitsView()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
LoadHabits();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoadHabits()
|
||||||
|
{
|
||||||
|
var list = new List<HabitRow>();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var conn = new MySqlConnection(ConnStr);
|
||||||
|
conn.Open();
|
||||||
|
|
||||||
|
string sql = "SELECT id, name, frequency, user_id FROM habits WHERE user_id=@uid ORDER BY id DESC;";
|
||||||
|
using var cmd = new MySqlCommand(sql, conn);
|
||||||
|
cmd.Parameters.AddWithValue("@uid", currentUserId);
|
||||||
|
|
||||||
|
using var r = cmd.ExecuteReader();
|
||||||
|
while (r.Read())
|
||||||
|
{
|
||||||
|
list.Add(new HabitRow
|
||||||
|
{
|
||||||
|
Id = r.GetInt32("id"),
|
||||||
|
Name = r.GetString("name"),
|
||||||
|
Frequency = r.GetString("frequency"),
|
||||||
|
UserId = r.GetInt32("user_id")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
GridHabits.ItemsSource = list;
|
||||||
|
Console.WriteLine("Habits loaded");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("DB Fehler (Load Habits): " + ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Delete_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if ((sender as FrameworkElement)?.Tag is not HabitRow h)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var conn = new MySqlConnection(ConnStr);
|
||||||
|
conn.Open();
|
||||||
|
|
||||||
|
string sql = "DELETE FROM habits WHERE id=@id;";
|
||||||
|
using var cmd = new MySqlCommand(sql, conn);
|
||||||
|
cmd.Parameters.AddWithValue("@id", h.Id);
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
|
||||||
|
Console.WriteLine("Habit deleted.");
|
||||||
|
LoadHabits();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("DB Fehler (Delete Habit): " + ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Add_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
string name = NewName.Text.Trim();
|
||||||
|
string frequency = NewFrequency.Text.Trim();
|
||||||
|
|
||||||
|
if (name.Length < 3)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (frequency.Length < 3)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var conn = new MySqlConnection(ConnStr);
|
||||||
|
conn.Open();
|
||||||
|
|
||||||
|
string sql = "INSERT INTO habits (name, frequency, user_id) VALUES (@n, @f, @uid);";
|
||||||
|
using var cmd = new MySqlCommand(sql, conn);
|
||||||
|
cmd.Parameters.AddWithValue("@n", name);
|
||||||
|
cmd.Parameters.AddWithValue("@f", frequency);
|
||||||
|
cmd.Parameters.AddWithValue("@uid", currentUserId);
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
|
||||||
|
Console.WriteLine("Habit added.");
|
||||||
|
|
||||||
|
NewName.Text = "";
|
||||||
|
NewFrequency.Text = "";
|
||||||
|
|
||||||
|
LoadHabits();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("DB Fehler (Add Habit): " + ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
28
HCI_TaskTracker/MainWindow.xaml
Normal file
28
HCI_TaskTracker/MainWindow.xaml
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<Window x:Class="HCI_TaskTracker.MainWindow"
|
||||||
|
xmlns:views="clr-namespace:HCI_TaskTracker"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
Title="MainWindow" Height="600" Width="620">
|
||||||
|
|
||||||
|
<Grid>
|
||||||
|
<TabControl>
|
||||||
|
|
||||||
|
<TabItem Header="Dashboard">
|
||||||
|
<views:DashboardView/>
|
||||||
|
</TabItem>
|
||||||
|
|
||||||
|
<TabItem Header="Tasks">
|
||||||
|
<views:TasksView/>
|
||||||
|
</TabItem>
|
||||||
|
|
||||||
|
<TabItem Header="Habits">
|
||||||
|
<views:HabitsView/>
|
||||||
|
</TabItem>
|
||||||
|
|
||||||
|
<TabItem Header="Admin">
|
||||||
|
<views:AdminView/>
|
||||||
|
</TabItem>
|
||||||
|
|
||||||
|
</TabControl>
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
||||||
37
HCI_TaskTracker/MainWindow.xaml.cs
Normal file
37
HCI_TaskTracker/MainWindow.xaml.cs
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
using System.Text;
|
||||||
|
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 MySqlConnector;
|
||||||
|
|
||||||
|
namespace HCI_TaskTracker
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for MainWindow.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class MainWindow : Window
|
||||||
|
{
|
||||||
|
public MainWindow()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
string ConnStr = "server=mysql.pb.bib.de;uid=pba3h24abd;pwd=a2UJEGJtjrsb;database=pba3h24abd_TaskTracker";
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var conn = new MySqlConnection(ConnStr);
|
||||||
|
conn.Open();
|
||||||
|
Console.WriteLine("Verbindung erfolgreich!");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Fehler: " + ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
14
HCI_TaskTracker/Task.cs
Normal file
14
HCI_TaskTracker/Task.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace HCI_TaskTracker
|
||||||
|
{
|
||||||
|
internal class Task
|
||||||
|
{
|
||||||
|
public int TaskID { get; set; }
|
||||||
|
public string TaskBescreibung { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
17
HCI_TaskTracker/TaskItem.cs
Normal file
17
HCI_TaskTracker/TaskItem.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace HCI_TaskTracker
|
||||||
|
{
|
||||||
|
public class TaskItem
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Title { get; set; }
|
||||||
|
public string Description { get; set; }
|
||||||
|
public bool IsDone { get; set; }
|
||||||
|
public int UserId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
11
HCI_TaskTracker/TaskRow.cs
Normal file
11
HCI_TaskTracker/TaskRow.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
namespace HCI_TaskTracker
|
||||||
|
{
|
||||||
|
public class TaskRow
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Title { get; set; } = "";
|
||||||
|
public string Description { get; set; } = "";
|
||||||
|
public bool IsDone { get; set; }
|
||||||
|
public int UserId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
38
HCI_TaskTracker/TasksView.xaml
Normal file
38
HCI_TaskTracker/TasksView.xaml
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
<UserControl x:Class="HCI_TaskTracker.TasksView"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
|
|
||||||
|
<Grid Margin="10">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="*"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<DataGrid x:Name="GridTasks"
|
||||||
|
AutoGenerateColumns="False"
|
||||||
|
CanUserAddRows="False"
|
||||||
|
CurrentCellChanged="GridTasks_CurrentCellChanged">
|
||||||
|
|
||||||
|
<DataGrid.Columns>
|
||||||
|
<DataGridTextColumn Header="ID" Binding="{Binding Id}" Width="60"/>
|
||||||
|
<DataGridTextColumn Header="Title" Binding="{Binding Title}" Width="200"/>
|
||||||
|
<DataGridTextColumn Header="Description" Binding="{Binding Description}" Width="*"/>
|
||||||
|
<DataGridCheckBoxColumn Header="Done" Binding="{Binding IsDone, Mode=TwoWay}" Width="70"/>
|
||||||
|
|
||||||
|
<DataGridTemplateColumn Header="X" Width="40">
|
||||||
|
<DataGridTemplateColumn.CellTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<Button Content="X" Tag="{Binding}" Click="Delete_Click"/>
|
||||||
|
</DataTemplate>
|
||||||
|
</DataGridTemplateColumn.CellTemplate>
|
||||||
|
</DataGridTemplateColumn>
|
||||||
|
</DataGrid.Columns>
|
||||||
|
</DataGrid>
|
||||||
|
|
||||||
|
<StackPanel Grid.Row="1" Orientation="Horizontal" Margin="0,10,0,0">
|
||||||
|
<TextBox x:Name="NewTitle" Width="200" Margin="0,0,10,0"/>
|
||||||
|
<TextBox x:Name="NewDescription" Width="300" Margin="0,0,10,0"/>
|
||||||
|
<Button Content="Hinzufügen" Click="Add_Click" />
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
||||||
141
HCI_TaskTracker/TasksView.xaml.cs
Normal file
141
HCI_TaskTracker/TasksView.xaml.cs
Normal file
@@ -0,0 +1,141 @@
|
|||||||
|
using MySql.Data.MySqlClient;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
|
||||||
|
namespace HCI_TaskTracker
|
||||||
|
{
|
||||||
|
public partial class TasksView : UserControl
|
||||||
|
{
|
||||||
|
string ConnStr = "server=mysql.pb.bib.de;uid=pba3h24abd;pwd=a2UJEGJtjrsb;database=pba3h24abd_TaskTracker";
|
||||||
|
|
||||||
|
int currentUserId = 1;
|
||||||
|
|
||||||
|
public TasksView()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
LoadTasks();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoadTasks()
|
||||||
|
{
|
||||||
|
var list = new List<TaskRow>();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var conn = new MySqlConnection(ConnStr);
|
||||||
|
conn.Open();
|
||||||
|
|
||||||
|
string sql = "SELECT id, title, description, is_done, user_id FROM tasks WHERE user_id=@uid ORDER BY id DESC;";
|
||||||
|
using var cmd = new MySqlCommand(sql, conn);
|
||||||
|
cmd.Parameters.AddWithValue("@uid", currentUserId);
|
||||||
|
|
||||||
|
using var r = cmd.ExecuteReader();
|
||||||
|
while (r.Read())
|
||||||
|
{
|
||||||
|
list.Add(new TaskRow
|
||||||
|
{
|
||||||
|
Id = r.GetInt32("id"),
|
||||||
|
Title = r.GetString("title"),
|
||||||
|
Description = r.IsDBNull(r.GetOrdinal("description")) ? "" : r.GetString("description"),
|
||||||
|
IsDone = r.GetBoolean("is_done"),
|
||||||
|
UserId = r.GetInt32("user_id")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
GridTasks.ItemsSource = list;
|
||||||
|
Console.WriteLine("Tasks loaded.");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("DB Fehler (Load): " + ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GridTasks_CurrentCellChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (GridTasks.CurrentItem is not TaskRow t)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var conn = new MySqlConnection(ConnStr);
|
||||||
|
conn.Open();
|
||||||
|
|
||||||
|
string sql = "UPDATE tasks SET is_done=@d WHERE id=@id;";
|
||||||
|
using var cmd = new MySqlCommand(sql, conn);
|
||||||
|
cmd.Parameters.AddWithValue("@d", t.IsDone);
|
||||||
|
cmd.Parameters.AddWithValue("@id", t.Id);
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
|
||||||
|
Console.WriteLine("Task updated (done).");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("DB Fehler (Update): " + ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Delete_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if ((sender as FrameworkElement)?.Tag is not TaskRow t)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var conn = new MySqlConnection(ConnStr);
|
||||||
|
conn.Open();
|
||||||
|
|
||||||
|
string sql = "DELETE FROM tasks WHERE id=@id;";
|
||||||
|
using var cmd = new MySqlCommand(sql, conn);
|
||||||
|
cmd.Parameters.AddWithValue("@id", t.Id);
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
|
||||||
|
Console.WriteLine("Task deleted.");
|
||||||
|
LoadTasks();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("DB Fehler (Delete): " + ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Add_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
string title = NewTitle.Text.Trim();
|
||||||
|
string description = NewDescription.Text.Trim();
|
||||||
|
|
||||||
|
if (title.Length < 3)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var conn = new MySqlConnection(ConnStr);
|
||||||
|
conn.Open();
|
||||||
|
|
||||||
|
string sql = "INSERT INTO tasks (title, description, is_done, user_id) VALUES (@t, @d, 0, @uid);";
|
||||||
|
using var cmd = new MySqlCommand(sql, conn);
|
||||||
|
cmd.Parameters.AddWithValue("@t", title);
|
||||||
|
cmd.Parameters.AddWithValue("@d", description);
|
||||||
|
cmd.Parameters.AddWithValue("@uid", currentUserId);
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
|
||||||
|
Console.WriteLine("Task added.");
|
||||||
|
|
||||||
|
NewTitle.Text = "";
|
||||||
|
NewDescription.Text = "";
|
||||||
|
|
||||||
|
LoadTasks();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("DB Fehler (Add): " + ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
16
HCI_TaskTracker/User.cs
Normal file
16
HCI_TaskTracker/User.cs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace HCI_TaskTracker
|
||||||
|
{
|
||||||
|
public class User
|
||||||
|
{
|
||||||
|
public int ID { get; set; }
|
||||||
|
public string Username { get; set; }
|
||||||
|
public string Password { get; set; }
|
||||||
|
public string Role { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
10
HCI_TaskTracker/UserRow.cs
Normal file
10
HCI_TaskTracker/UserRow.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
namespace HCI_TaskTracker
|
||||||
|
{
|
||||||
|
public class UserRow
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Username { get; set; } = "";
|
||||||
|
public string Password { get; set; } = "";
|
||||||
|
public string Role { get; set; } = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user