User number added to EditSelectedUser form.

This commit is contained in:
Milan Hanajik
2017-03-17 09:45:39 +01:00
parent e245ec80c6
commit ccf99a3105
6 changed files with 239 additions and 139 deletions
+22 -3
View File
@@ -29,6 +29,7 @@ namespace Users.Forms
Localize();
txtName.Text = CurrentEditUser.UserName;
txtCode.Text = CurrentEditUser.Number.ToString();
txtDescription.Text = CurrentEditUser.FullName;
txtPassword.Text = "";
txtRepeatPassword.Text = "";
@@ -72,8 +73,7 @@ namespace Users.Forms
public bool Save()
{
{
// todo: check if this name is given to another user
if (IsUserNameAllreadyTaken(txtName.Text))
{
@@ -81,6 +81,12 @@ namespace Users.Forms
return false;
}
int userCode;
if (!int.TryParse (txtCode.Text, out userCode))
{
MessageBox.Show(Strings.Invalid_code);
return false;
}
if (txtPassword.Text != "")
{
@@ -97,6 +103,7 @@ namespace Users.Forms
CurrentEditUser.UserName = txtName.Text;
CurrentEditUser.FullName = txtDescription.Text;
CurrentEditUser.Number = userCode;
// Groups
CurrentEditUser.Groups.Clear();
@@ -156,6 +163,9 @@ namespace Users.Forms
{
btnOk.Enabled = false;
if (txtName.Text == "") return;
int userCode;
if (!int.TryParse(txtCode.Text, out userCode)) return;
if (txtPassword.Text != txtRepeatPassword.Text) return;
btnOk.Enabled = true;
}
@@ -172,7 +182,6 @@ namespace Users.Forms
private void txtName_KeyPress(object sender, KeyPressEventArgs e)
{
CheckIfFormCanBeSubmitted();
}
private void txtName_TextChanged(object sender, EventArgs e)
@@ -185,6 +194,11 @@ namespace Users.Forms
CheckIfFormCanBeSubmitted();
}
private void txtRepeatPassword_TextChanged(object sender, EventArgs e)
{
CheckIfFormCanBeSubmitted();
}
private void txtDescription_TextChanged(object sender, EventArgs e)
{
CheckIfFormCanBeSubmitted();
@@ -199,5 +213,10 @@ namespace Users.Forms
{
CheckIfFormCanBeSubmitted();
}
private void txtCode_TextChanged(object sender, EventArgs e)
{
CheckIfFormCanBeSubmitted();
}
}
}