winforms users crud
This commit is contained in:
@@ -45,5 +45,9 @@ namespace StudentHouseDashboard.Models
|
|||||||
get => role;
|
get => role;
|
||||||
set => role = value;
|
set => role = value;
|
||||||
}
|
}
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return $"{ID}: {Name} ({Role})";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -141,7 +141,7 @@ namespace StudentHouseDashboard.Repositories
|
|||||||
using (SqlConnection conn = CreateConnection())
|
using (SqlConnection conn = CreateConnection())
|
||||||
{
|
{
|
||||||
string sql = "UPDATE Users " +
|
string sql = "UPDATE Users " +
|
||||||
"SET Name = 'Deleted User @id', Password = '0', Role = @role " +
|
"SET Name = 'Deleted User @id', Password = '0'" +
|
||||||
"WHERE ID = @id;";
|
"WHERE ID = @id;";
|
||||||
SqlCommand cmd = new SqlCommand(sql, conn);
|
SqlCommand cmd = new SqlCommand(sql, conn);
|
||||||
cmd.Parameters.AddWithValue("@id", id);
|
cmd.Parameters.AddWithValue("@id", id);
|
||||||
|
124
StudentHouseDashboard/WinForms/Dashboard.Designer.cs
generated
Normal file
124
StudentHouseDashboard/WinForms/Dashboard.Designer.cs
generated
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
namespace WinForms
|
||||||
|
{
|
||||||
|
partial class Dashboard
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
lblUserStatus = new Label();
|
||||||
|
lbUsers = new ListBox();
|
||||||
|
btnCreateUser = new Button();
|
||||||
|
btnDeleteUser = new Button();
|
||||||
|
btnUpdateUser = new Button();
|
||||||
|
btnViewUser = new Button();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// lblUserStatus
|
||||||
|
//
|
||||||
|
lblUserStatus.AutoSize = true;
|
||||||
|
lblUserStatus.Location = new Point(13, 18);
|
||||||
|
lblUserStatus.Name = "lblUserStatus";
|
||||||
|
lblUserStatus.Size = new Size(80, 15);
|
||||||
|
lblUserStatus.TabIndex = 0;
|
||||||
|
lblUserStatus.Text = "Logged in as: ";
|
||||||
|
//
|
||||||
|
// lbUsers
|
||||||
|
//
|
||||||
|
lbUsers.FormattingEnabled = true;
|
||||||
|
lbUsers.ItemHeight = 15;
|
||||||
|
lbUsers.Location = new Point(13, 86);
|
||||||
|
lbUsers.Name = "lbUsers";
|
||||||
|
lbUsers.Size = new Size(318, 154);
|
||||||
|
lbUsers.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// btnCreateUser
|
||||||
|
//
|
||||||
|
btnCreateUser.Location = new Point(13, 257);
|
||||||
|
btnCreateUser.Name = "btnCreateUser";
|
||||||
|
btnCreateUser.Size = new Size(75, 23);
|
||||||
|
btnCreateUser.TabIndex = 2;
|
||||||
|
btnCreateUser.Text = "New User";
|
||||||
|
btnCreateUser.UseVisualStyleBackColor = true;
|
||||||
|
btnCreateUser.Click += btnCreateUser_Click;
|
||||||
|
//
|
||||||
|
// btnDeleteUser
|
||||||
|
//
|
||||||
|
btnDeleteUser.Location = new Point(94, 257);
|
||||||
|
btnDeleteUser.Name = "btnDeleteUser";
|
||||||
|
btnDeleteUser.Size = new Size(75, 23);
|
||||||
|
btnDeleteUser.TabIndex = 3;
|
||||||
|
btnDeleteUser.Text = "Delete User";
|
||||||
|
btnDeleteUser.UseVisualStyleBackColor = true;
|
||||||
|
btnDeleteUser.Click += btnDeleteUser_Click;
|
||||||
|
//
|
||||||
|
// btnUpdateUser
|
||||||
|
//
|
||||||
|
btnUpdateUser.Location = new Point(175, 257);
|
||||||
|
btnUpdateUser.Name = "btnUpdateUser";
|
||||||
|
btnUpdateUser.Size = new Size(75, 23);
|
||||||
|
btnUpdateUser.TabIndex = 4;
|
||||||
|
btnUpdateUser.Text = "Edit User";
|
||||||
|
btnUpdateUser.UseVisualStyleBackColor = true;
|
||||||
|
btnUpdateUser.Click += btnUpdateUser_Click;
|
||||||
|
//
|
||||||
|
// btnViewUser
|
||||||
|
//
|
||||||
|
btnViewUser.Location = new Point(256, 257);
|
||||||
|
btnViewUser.Name = "btnViewUser";
|
||||||
|
btnViewUser.Size = new Size(75, 23);
|
||||||
|
btnViewUser.TabIndex = 5;
|
||||||
|
btnViewUser.Text = "View User";
|
||||||
|
btnViewUser.UseVisualStyleBackColor = true;
|
||||||
|
btnViewUser.Click += btnViewUser_Click;
|
||||||
|
//
|
||||||
|
// Dashboard
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(359, 302);
|
||||||
|
Controls.Add(btnViewUser);
|
||||||
|
Controls.Add(btnUpdateUser);
|
||||||
|
Controls.Add(btnDeleteUser);
|
||||||
|
Controls.Add(btnCreateUser);
|
||||||
|
Controls.Add(lbUsers);
|
||||||
|
Controls.Add(lblUserStatus);
|
||||||
|
Name = "Dashboard";
|
||||||
|
Text = "Dashboard";
|
||||||
|
FormClosed += Dashboard_FormClosed;
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label lblUserStatus;
|
||||||
|
private ListBox lbUsers;
|
||||||
|
private Button btnCreateUser;
|
||||||
|
private Button btnDeleteUser;
|
||||||
|
private Button btnUpdateUser;
|
||||||
|
private Button btnViewUser;
|
||||||
|
}
|
||||||
|
}
|
85
StudentHouseDashboard/WinForms/Dashboard.cs
Normal file
85
StudentHouseDashboard/WinForms/Dashboard.cs
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
using StudentHouseDashboard.Managers;
|
||||||
|
using StudentHouseDashboard.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace WinForms
|
||||||
|
{
|
||||||
|
public partial class Dashboard : Form
|
||||||
|
{
|
||||||
|
Login loginForm;
|
||||||
|
public Dashboard(Login loginForm, User user)
|
||||||
|
{
|
||||||
|
this.loginForm = loginForm;
|
||||||
|
InitializeComponent();
|
||||||
|
lblUserStatus.Text = $"Logged in as: {user.Role} {user.Name}";
|
||||||
|
if (user.Role == UserRole.ADMIN || user.Role == UserRole.MANAGER)
|
||||||
|
{
|
||||||
|
btnCreateUser.Enabled = true;
|
||||||
|
btnDeleteUser.Enabled = true;
|
||||||
|
btnUpdateUser.Enabled = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
btnCreateUser.Enabled = false;
|
||||||
|
btnDeleteUser.Enabled = false;
|
||||||
|
btnUpdateUser.Enabled = false;
|
||||||
|
}
|
||||||
|
RefreshLists();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnCreateUser_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
UserForm userForm = new UserForm(null, false);
|
||||||
|
userForm.ShowDialog();
|
||||||
|
RefreshLists();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnDeleteUser_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
User currentUser = (User)lbUsers.SelectedItem;
|
||||||
|
if (MessageBox.Show($"Are you sure you want to delete\n{currentUser.Name}\n{currentUser.Role}", "Delete user", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
UserManager userManager = new UserManager();
|
||||||
|
userManager.DisableUser(currentUser.ID);
|
||||||
|
}
|
||||||
|
RefreshLists();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnUpdateUser_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
UserForm userForm = new UserForm((User)lbUsers.SelectedItem, false);
|
||||||
|
userForm.ShowDialog();
|
||||||
|
RefreshLists();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnViewUser_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
UserForm userForm = new UserForm((User)lbUsers.SelectedItem, true);
|
||||||
|
userForm.ShowDialog();
|
||||||
|
RefreshLists();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RefreshLists()
|
||||||
|
{
|
||||||
|
UserManager userManager = new UserManager();
|
||||||
|
lbUsers.Items.Clear();
|
||||||
|
foreach (User _user in userManager.GetAllUsers())
|
||||||
|
{
|
||||||
|
lbUsers.Items.Add(_user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Dashboard_FormClosed(object sender, FormClosedEventArgs e)
|
||||||
|
{
|
||||||
|
loginForm.Show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
StudentHouseDashboard/WinForms/Dashboard.resx
Normal file
60
StudentHouseDashboard/WinForms/Dashboard.resx
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
@@ -20,8 +20,12 @@ namespace WinForms
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MessageBox.Show($"Welcome, {user.Name}", "Login successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
Dashboard dashboard = new Dashboard(this, user);
|
||||||
|
this.Hide();
|
||||||
|
dashboard.Show();
|
||||||
}
|
}
|
||||||
|
tbUsername.Text = "";
|
||||||
|
tbPassword.Text = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
128
StudentHouseDashboard/WinForms/UserForm.Designer.cs
generated
Normal file
128
StudentHouseDashboard/WinForms/UserForm.Designer.cs
generated
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
namespace WinForms
|
||||||
|
{
|
||||||
|
partial class UserForm
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
lblUsername = new Label();
|
||||||
|
tbUsername = new TextBox();
|
||||||
|
lblPassword = new Label();
|
||||||
|
tbPassword = new TextBox();
|
||||||
|
lblUserRole = new Label();
|
||||||
|
cbUserRole = new ComboBox();
|
||||||
|
btnSave = new Button();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// lblUsername
|
||||||
|
//
|
||||||
|
lblUsername.AutoSize = true;
|
||||||
|
lblUsername.Location = new Point(12, 9);
|
||||||
|
lblUsername.Name = "lblUsername";
|
||||||
|
lblUsername.Size = new Size(63, 15);
|
||||||
|
lblUsername.TabIndex = 0;
|
||||||
|
lblUsername.Text = "Username:";
|
||||||
|
//
|
||||||
|
// tbUsername
|
||||||
|
//
|
||||||
|
tbUsername.Location = new Point(84, 6);
|
||||||
|
tbUsername.Name = "tbUsername";
|
||||||
|
tbUsername.Size = new Size(121, 23);
|
||||||
|
tbUsername.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// lblPassword
|
||||||
|
//
|
||||||
|
lblPassword.AutoSize = true;
|
||||||
|
lblPassword.Location = new Point(12, 38);
|
||||||
|
lblPassword.Name = "lblPassword";
|
||||||
|
lblPassword.Size = new Size(60, 15);
|
||||||
|
lblPassword.TabIndex = 2;
|
||||||
|
lblPassword.Text = "Password:";
|
||||||
|
//
|
||||||
|
// tbPassword
|
||||||
|
//
|
||||||
|
tbPassword.Location = new Point(84, 35);
|
||||||
|
tbPassword.Name = "tbPassword";
|
||||||
|
tbPassword.Size = new Size(121, 23);
|
||||||
|
tbPassword.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// lblUserRole
|
||||||
|
//
|
||||||
|
lblUserRole.AutoSize = true;
|
||||||
|
lblUserRole.Location = new Point(12, 67);
|
||||||
|
lblUserRole.Name = "lblUserRole";
|
||||||
|
lblUserRole.Size = new Size(33, 15);
|
||||||
|
lblUserRole.TabIndex = 4;
|
||||||
|
lblUserRole.Text = "Role:";
|
||||||
|
//
|
||||||
|
// cbUserRole
|
||||||
|
//
|
||||||
|
cbUserRole.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
|
cbUserRole.FormattingEnabled = true;
|
||||||
|
cbUserRole.Location = new Point(84, 64);
|
||||||
|
cbUserRole.Name = "cbUserRole";
|
||||||
|
cbUserRole.Size = new Size(121, 23);
|
||||||
|
cbUserRole.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// btnSave
|
||||||
|
//
|
||||||
|
btnSave.Location = new Point(130, 93);
|
||||||
|
btnSave.Name = "btnSave";
|
||||||
|
btnSave.Size = new Size(75, 23);
|
||||||
|
btnSave.TabIndex = 6;
|
||||||
|
btnSave.Text = "Save changes";
|
||||||
|
btnSave.UseVisualStyleBackColor = true;
|
||||||
|
btnSave.Click += btnSave_Click;
|
||||||
|
//
|
||||||
|
// UserForm
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(230, 135);
|
||||||
|
Controls.Add(btnSave);
|
||||||
|
Controls.Add(cbUserRole);
|
||||||
|
Controls.Add(lblUserRole);
|
||||||
|
Controls.Add(tbPassword);
|
||||||
|
Controls.Add(lblPassword);
|
||||||
|
Controls.Add(tbUsername);
|
||||||
|
Controls.Add(lblUsername);
|
||||||
|
Name = "UserForm";
|
||||||
|
Text = "UserForm";
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label lblUsername;
|
||||||
|
private TextBox tbUsername;
|
||||||
|
private Label lblPassword;
|
||||||
|
private TextBox tbPassword;
|
||||||
|
private Label lblUserRole;
|
||||||
|
private ComboBox cbUserRole;
|
||||||
|
private Button btnSave;
|
||||||
|
}
|
||||||
|
}
|
63
StudentHouseDashboard/WinForms/UserForm.cs
Normal file
63
StudentHouseDashboard/WinForms/UserForm.cs
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
using StudentHouseDashboard.Managers;
|
||||||
|
using StudentHouseDashboard.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace WinForms
|
||||||
|
{
|
||||||
|
public partial class UserForm : Form
|
||||||
|
{
|
||||||
|
User user;
|
||||||
|
public UserForm(User? user, bool readOnly)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
this.user = user;
|
||||||
|
if (readOnly)
|
||||||
|
{
|
||||||
|
btnSave.Enabled = false;
|
||||||
|
tbUsername.Enabled = false;
|
||||||
|
tbPassword.Enabled = false;
|
||||||
|
cbUserRole.Enabled = false;
|
||||||
|
}
|
||||||
|
cbUserRole.Items.Clear();
|
||||||
|
foreach (var item in Enum.GetValues(typeof(UserRole)))
|
||||||
|
{
|
||||||
|
cbUserRole.Items.Add(item);
|
||||||
|
}
|
||||||
|
if (user != null)
|
||||||
|
{
|
||||||
|
tbUsername.Text = user.Name;
|
||||||
|
tbPassword.Text = user.Password;
|
||||||
|
cbUserRole.SelectedIndex = (int)user.Role;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
UserManager userManager = new UserManager();
|
||||||
|
if (string.IsNullOrEmpty(tbUsername.Text) || string.IsNullOrEmpty(tbPassword.Text) || cbUserRole.SelectedIndex == -1)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Please enter data in all fields");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.user == null)
|
||||||
|
{
|
||||||
|
userManager.CreateUser(tbUsername.Text, BCrypt.Net.BCrypt.HashPassword(tbPassword.Text), (UserRole)cbUserRole.SelectedItem);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
userManager.UpdateUser(this.user.ID, tbUsername.Text, BCrypt.Net.BCrypt.HashPassword(tbPassword.Text), (UserRole)cbUserRole.SelectedItem);
|
||||||
|
}
|
||||||
|
this.DialogResult = DialogResult.OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
StudentHouseDashboard/WinForms/UserForm.resx
Normal file
60
StudentHouseDashboard/WinForms/UserForm.resx
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
Reference in New Issue
Block a user