Creating a WPF application to implement a lecturer dashboard for submitting claims involves several components, including UI elements for input, file uploads, and status handling. Below, I'll show you a simplified version of how you can structure this application in C# using WPF.
This application will have:
- A form for lecturers to submit claims.
- A view to display the submitted claims with their status.
- A dashboard for managers to accept or reject claims.
This code is a simplified example; you may need to adapt it for a real-world application, ensuring proper error handling, threading, and data persistence (such as saving to a database or file).
MainWindow.xaml (Lecturer Dashboard)
<Window x:Class="ClaimSubmission.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Lecturer Dashboard" Height="400" Width="400">
<Grid>
<Label Content="Hours Worked:" VerticalAlignment="Top" Margin="10,10,0,0"/>
<TextBox Name="HoursWorkedTextBox" VerticalAlignment="Top" Margin="120,10,10,0"/>
<Label Content="Hourly Rate:" VerticalAlignment="Top" Margin="10,50,0,0"/>
<TextBox Name="HourlyRateTextBox" VerticalAlignment="Top" Margin="120,50,10,0"/>
<Label Content="Notes:" VerticalAlignment="Top" Margin="10,90,0,0"/>
<TextBox Name="NotesTextBox" VerticalAlignment="Top" Height="60" Margin="120,90,10,0" TextWrapping="Wrap" AcceptsReturn="True"/>
<Button Content="Upload File" VerticalAlignment="Top" Margin="10,160,0,0" Click="UploadFile_Click"/>
<TextBlock Name="FileNameTextBlock" VerticalAlignment="Top" Margin="120,160,10,0" Height="23"/>
<Button Content="Submit Claim" VerticalAlignment="Top" Margin="10,200,0,0" Click="SubmitClaim_Click"/>
<ListBox Name="ClaimsListBox" Margin="10,240,10,10"/>
</Grid>
</Window>
MainWindow.xaml.cs (Lecturer Dashboard Logic)
using Microsoft.Win32;
using System.Collections.Generic;
using System.Windows;
namespace ClaimSubmission
{
public partial class MainWindow : Window
{
private string uploadedFileName;
private List<Claim> claims = new List<Claim>();
public MainWindow()
{
InitializeComponent();
}
private void UploadFile_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
if (openFileDialog.ShowDialog() == true)
{
uploadedFileName = openFileDialog.FileName;
FileNameTextBlock.Text = System.IO.Path.GetFileName(uploadedFileName);
}
}
private void SubmitClaim_Click(object sender, RoutedEventArgs e)
{
string hoursWorked = HoursWorkedTextBox.Text;
string hourlyRate = HourlyRateTextBox.Text;
string notes = NotesTextBox.Text;
Claim newClaim = new Claim
{
HoursWorked = hoursWorked,
HourlyRate = hourlyRate,
Notes = notes,
FileName = uploadedFileName,
Status = "Pending"
};
claims.Add(newClaim);
ClaimsListBox.Items.Add(newClaim.ToString());
// Clear fields after submission
HoursWorkedTextBox.Text = "";
HourlyRateTextBox.Text = "";
NotesTextBox.Text = "";
FileNameTextBlock.Text = "";
uploadedFileName = null;
}
}
public class Claim
{
public string HoursWorked { get; set; }
public string HourlyRate { get; set; }
public string Notes { get; set; }
public string FileName { get; set; }
public string Status { get; set; }
public override string ToString()
{
return $"Hours: {HoursWorked}, Rate: {HourlyRate}, Notes: {Notes}, File: {FileName}, Status: {Status}";
}
}
}
ManagerDashboard.xaml (Manager Dashboard)
<Window x:Class="ClaimSubmission.ManagerDashboard"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Manager Dashboard" Height="300" Width="400">
<Grid>
<ListBox Name="ClaimsListBox" Margin="10" MouseDoubleClick="ClaimsListBox_MouseDoubleClick"/>
</Grid>
</Window>
ManagerDashboard.xaml.cs (Manager Dashboard Logic)
using System.Windows;
using System.Windows.Controls;
namespace ClaimSubmission
{
public partial class ManagerDashboard : Window
{
public ManagerDashboard()
{
InitializeComponent();
LoadClaims();
}
private void LoadClaims()
{
foreach (var claim in MainWindow.Claims) // Access claims from the MainWindow
{
ClaimsListBox.Items.Add(claim);
}
}
private void ClaimsListBox_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
if (ClaimsListBox.SelectedItem is Claim selectedClaim)
{
// Handle Accept/Reject here
selectedClaim.Status = "Accepted"; // or "Rejected"
ClaimsListBox.Items.Refresh();
}
}
}
}
Notes
- The above code is a basic example. You'll need to adjust the namespaces based on your project structure.
- You need to refactor the way claims are shared between classes (such as storing claims in a static list or database).
- This code does not include real file handling or a persistent storage solution to store claims. You might consider using a local database or web API for a production-quality solution.
- The "Accept" or "Reject" buttons on the manager dashboard are handled with a double-click, but you can modify this to use buttons in the UI if you prefer.
- Ensure you handle UI threading appropriately, especially when interacting with any UI elements from different threads.
This should provide you with a solid foundation to build the lecturer and manager dashboards.