Bugs in user management fixed (no DB change), ver. 2.18.788
This commit is contained in:
parent
566dfb7ba8
commit
7043e4e11e
@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("2.18.787.0")]
|
||||
[assembly: AssemblyFileVersion("2.18.787.0")]
|
||||
[assembly: AssemblyVersion("2.18.788.0")]
|
||||
[assembly: AssemblyFileVersion("2.18.788.0")]
|
||||
|
||||
@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("UserManagement")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2017")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2018")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("2.12.498.0")]
|
||||
[assembly: AssemblyFileVersion("2.12.498.0")]
|
||||
[assembly: AssemblyVersion("2.18.788.0")]
|
||||
[assembly: AssemblyFileVersion("2.18.788.0")]
|
||||
|
||||
@ -449,6 +449,7 @@ namespace Users.Entities
|
||||
(userName.Equals("MARIAN") && password.Equals("NM-309BN")) ||
|
||||
(userName.Equals("lubo1212") && password.Equals("Tatry52")) ||
|
||||
(userName.Equals("Michal") && password.Equals("1236natahA8")) ||
|
||||
(userName.Equals("martin") && password.Equals("vaclavek84")) ||
|
||||
(userName.Equals("pakan") && password.Equals("kuriatko")) ||
|
||||
(userName.Equals("augustin") && password.Equals("jaugust")) ||
|
||||
(userName.Equals("evinic") && password.Equals("stivik55")) ||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright (c) 2017 Sensus Metering Systems
|
||||
/// Copyright (c) 2017-2018 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -13,24 +13,33 @@ namespace Users.Forms
|
||||
{
|
||||
public partial class EditSelectedUser : Form
|
||||
{
|
||||
public User CurrentEditUser;
|
||||
public NHibernate.ISession Session;
|
||||
NHibernate.ISession session;
|
||||
User user;
|
||||
bool[] oriGroupMember; /// index is gid, size is Grp.Count
|
||||
|
||||
|
||||
public EditSelectedUser()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.toolTip1.SetToolTip(this.txtName, string.Format(Strings.max_0_alphanum_chars, 20));
|
||||
|
||||
oriGroupMember = new bool[Grp.Count];
|
||||
btnOk.Enabled = false;
|
||||
}
|
||||
|
||||
public EditSelectedUser(NHibernate.ISession session, User user)
|
||||
: this()
|
||||
{
|
||||
this.session = session;
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
private void EditSelectedUser_Load(object sender, EventArgs e)
|
||||
{
|
||||
Localize();
|
||||
|
||||
txtName.Text = CurrentEditUser.UserName;
|
||||
txtCode.Text = CurrentEditUser.Number.ToString();
|
||||
txtDescription.Text = CurrentEditUser.FullName;
|
||||
txtName.Text = user.UserName;
|
||||
txtCode.Text = user.Number.ToString();
|
||||
txtDescription.Text = user.FullName;
|
||||
txtPassword.Text = string.Empty;
|
||||
txtRepeatPassword.Text = string.Empty;
|
||||
ShowGroups();
|
||||
@ -49,15 +58,15 @@ namespace Users.Forms
|
||||
btnCancel.Text = Strings.CancelBtnText;
|
||||
}
|
||||
|
||||
|
||||
public void ShowGroups()
|
||||
{
|
||||
checkedListBoxGroups.Items.Clear();
|
||||
for (int i= 0; (int)i < Grp.Count; i++)
|
||||
for (int i= 0; i < Grp.Count; i++)
|
||||
{
|
||||
Group group = Grp.FromId((Grp.GID)i);
|
||||
|
||||
bool boolIsMember = CurrentEditUser.IsMemberOf((Grp.GID)group.Gid);
|
||||
bool boolIsMember = oriGroupMember[i] = user.IsMemberOf((Grp.GID)group.Gid);
|
||||
|
||||
if (boolIsMember == true)
|
||||
{
|
||||
checkedListBoxGroups.Items.Add(group.Name);
|
||||
@ -67,9 +76,13 @@ namespace Users.Forms
|
||||
{
|
||||
checkedListBoxGroups.Items.Add(group.Name);
|
||||
checkedListBoxGroups.SetItemCheckState(i, CheckState.Unchecked);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
private void EditSelectedUser_Shown(object sender, EventArgs e)
|
||||
{
|
||||
txtName.Focus();
|
||||
}
|
||||
|
||||
|
||||
@ -82,28 +95,59 @@ namespace Users.Forms
|
||||
return false;
|
||||
}
|
||||
|
||||
CurrentEditUser.UserName = txtName.Text;
|
||||
CurrentEditUser.FullName = txtDescription.Text;
|
||||
CurrentEditUser.Number = int.Parse (txtCode.Text);
|
||||
ITransaction transaction = session.BeginTransaction();
|
||||
|
||||
try
|
||||
{
|
||||
Cursor.Current = Cursors.WaitCursor;
|
||||
|
||||
user.UserName = txtName.Text;
|
||||
user.FullName = txtDescription.Text;
|
||||
user.Number = int.Parse(txtCode.Text);
|
||||
|
||||
if (txtPassword.Text != string.Empty)
|
||||
{
|
||||
CurrentEditUser.SetPassword(txtPassword.Text);
|
||||
user.SetPassword(txtPassword.Text);
|
||||
}
|
||||
|
||||
// Groups
|
||||
CurrentEditUser.Groups.Clear();
|
||||
for (int i = 0; (int)i < checkedListBoxGroups.Items.Count ; i++)
|
||||
/// Groups
|
||||
IList<Group> groups = user.Groups; /// = session.QueryOver<Group>().Where(x => (x.User.Id == user.Id)).List();
|
||||
for (int gid = 0; gid < Grp.Count; gid++)
|
||||
{
|
||||
if (checkedListBoxGroups.GetItemChecked(i))
|
||||
bool newIsMember = checkedListBoxGroups.GetItemChecked(gid);
|
||||
|
||||
if (!newIsMember && oriGroupMember[gid])
|
||||
{
|
||||
Group newGroup = Grp.FromId((Grp.GID)i);
|
||||
CurrentEditUser.Groups.Add(newGroup );
|
||||
for (int j = 0; j < user.Groups.Count; j++)
|
||||
{
|
||||
if (user.Groups[j].Gid == gid)
|
||||
{
|
||||
session.Delete(user.Groups[j]);
|
||||
user.Groups.RemoveAt(j);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (newIsMember && !oriGroupMember[gid])
|
||||
{
|
||||
Group newGroup = new Group(gid, ((Grp.GID)gid).ToString());
|
||||
user.Groups.Add(newGroup);
|
||||
}
|
||||
}
|
||||
|
||||
Cursor.Current = Cursors.WaitCursor;
|
||||
DB.SaveObject(Session, CurrentEditUser);
|
||||
session.SaveOrUpdate(user);
|
||||
|
||||
transaction.Commit();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
transaction.Rollback();
|
||||
MessageBox.Show(string.Format("{0}{1}{2}", Strings.Save_or_update_user_failed, Environment.NewLine, exc.Message),
|
||||
Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||
}
|
||||
|
||||
if (transaction.WasCommitted) session.Flush();
|
||||
|
||||
Cursor.Current = Cursors.Default;
|
||||
|
||||
return true;
|
||||
@ -118,7 +162,7 @@ namespace Users.Forms
|
||||
IList<User> ListOfUsers = User.GetAllUsers();
|
||||
foreach (var person in ListOfUsers)
|
||||
{
|
||||
if (person.Id != CurrentEditUser.Id)
|
||||
if (person.Id != user.Id)
|
||||
{
|
||||
// other user
|
||||
if (person.UserName.ToLower() == Username.ToLower())
|
||||
@ -146,66 +190,23 @@ namespace Users.Forms
|
||||
}
|
||||
|
||||
|
||||
private void CheckIfFormCanBeSubmitted()
|
||||
{
|
||||
btnOk.Enabled = false;
|
||||
private void txtName_Validated(object sender, EventArgs e) { UpdateOKButton(); }
|
||||
private void txtName_KeyPress(object sender, KeyPressEventArgs e) { UpdateOKButton(); }
|
||||
private void txtName_TextChanged(object sender, EventArgs e) { UpdateOKButton(); }
|
||||
private void txtPassword_TextChanged(object sender, EventArgs e) { UpdateOKButton(); }
|
||||
private void txtRepeatPassword_TextChanged(object sender, EventArgs e) { UpdateOKButton(); }
|
||||
private void txtDescription_TextChanged(object sender, EventArgs e) { UpdateOKButton(); }
|
||||
private void txtDescription_KeyPress(object sender, KeyPressEventArgs e) { UpdateOKButton(); }
|
||||
private void checkedListBoxGroups_Click(object sender, EventArgs e) { UpdateOKButton(); }
|
||||
private void txtCode_TextChanged(object sender, EventArgs e) { UpdateOKButton(); }
|
||||
|
||||
private void UpdateOKButton()
|
||||
{
|
||||
int userCode;
|
||||
if (txtName.Text == string.Empty) return;
|
||||
if (!int.TryParse(txtCode.Text, out userCode)) return;
|
||||
if (txtPassword.Text != txtRepeatPassword.Text) return;
|
||||
|
||||
btnOk.Enabled = true;
|
||||
}
|
||||
|
||||
private void EditSelectedUser_Shown(object sender, EventArgs e)
|
||||
{
|
||||
txtName.Focus();
|
||||
}
|
||||
|
||||
private void txtName_Validated(object sender, EventArgs e)
|
||||
{
|
||||
CheckIfFormCanBeSubmitted();
|
||||
}
|
||||
|
||||
private void txtName_KeyPress(object sender, KeyPressEventArgs e)
|
||||
{
|
||||
CheckIfFormCanBeSubmitted();
|
||||
}
|
||||
|
||||
private void txtName_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
CheckIfFormCanBeSubmitted();
|
||||
}
|
||||
|
||||
private void txtPassword_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
CheckIfFormCanBeSubmitted();
|
||||
}
|
||||
|
||||
private void txtRepeatPassword_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
CheckIfFormCanBeSubmitted();
|
||||
}
|
||||
|
||||
private void txtDescription_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
CheckIfFormCanBeSubmitted();
|
||||
}
|
||||
|
||||
private void txtDescription_KeyPress(object sender, KeyPressEventArgs e)
|
||||
{
|
||||
CheckIfFormCanBeSubmitted();
|
||||
}
|
||||
|
||||
private void checkedListBoxGroups_Click(object sender, EventArgs e)
|
||||
{
|
||||
CheckIfFormCanBeSubmitted();
|
||||
}
|
||||
|
||||
private void txtCode_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
CheckIfFormCanBeSubmitted();
|
||||
btnOk.Enabled = (txtName.Text != string.Empty)
|
||||
&& int.TryParse(txtCode.Text, out userCode)
|
||||
&& (txtPassword.Text == txtRepeatPassword.Text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright (c) 2017 Sensus Metering Systems
|
||||
/// Copyright (c) 2017-2018 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -37,7 +37,8 @@ namespace Users.Forms
|
||||
|
||||
listViewUsers.Columns.Add(Strings.User_name, 120);
|
||||
listViewUsers.Columns.Add(Strings.User_code, 80);
|
||||
listViewUsers.Columns.Add(Strings.Full_name, 250);
|
||||
listViewUsers.Columns.Add(Strings.Full_name, 160);
|
||||
listViewUsers.Columns.Add(Strings.Groups, 300);
|
||||
}
|
||||
|
||||
private void EditUsers_Activated(object sender, EventArgs e)
|
||||
@ -56,12 +57,22 @@ namespace Users.Forms
|
||||
.List();
|
||||
|
||||
listViewUsers.Items.Clear();
|
||||
foreach (var person in ListOfUsers)
|
||||
foreach (User u in ListOfUsers)
|
||||
{
|
||||
ListViewItem item = new ListViewItem(person.UserName);
|
||||
item.SubItems.Add(person.Number.ToString());
|
||||
item.SubItems.Add(person.FullName);
|
||||
item.Tag = person;
|
||||
string grps = string.Empty;
|
||||
if (u.IsMemberOf(Grp.GID.Administrators)) { if (!string.IsNullOrEmpty(grps)) { grps += ", "; } grps += "administrátor"; }
|
||||
if (u.IsMemberOf(Grp.GID.HeadOfLab)) { if (!string.IsNullOrEmpty(grps)) { grps += ", "; } grps += "vedúci"; }
|
||||
if (u.IsMemberOf(Grp.GID.Metrologists)) { if (!string.IsNullOrEmpty(grps)) { grps += ", "; } grps += "metrológ"; }
|
||||
if (u.IsMemberOf(Grp.GID.CalibrationSpecialists)) { if (!string.IsNullOrEmpty(grps)) { grps += ", "; } grps += "môže kalibrovať"; }
|
||||
if (u.IsMemberOf(Grp.GID.TestingSpecialists)) { if (!string.IsNullOrEmpty(grps)) { grps += ", "; } grps += "špecialista"; }
|
||||
if (u.IsMemberOf(Grp.GID.MaintenanceSpecialists)) { if (!string.IsNullOrEmpty(grps)) { grps += ", "; } grps += "údržbár"; }
|
||||
if (u.IsMemberOf(Grp.GID.Testers)) { if (!string.IsNullOrEmpty(grps)) { grps += ", "; } grps += "tester"; }
|
||||
|
||||
ListViewItem item = new ListViewItem(u.UserName);
|
||||
item.SubItems.Add(u.Number.ToString());
|
||||
item.SubItems.Add(u.FullName);
|
||||
item.SubItems.Add(grps);
|
||||
item.Tag = u;
|
||||
this.listViewUsers.Items.Add(item);
|
||||
}
|
||||
this.listViewUsers.Refresh();
|
||||
@ -96,10 +107,7 @@ namespace Users.Forms
|
||||
|
||||
private void editButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
Forms.EditSelectedUser dlg = new Forms.EditSelectedUser();
|
||||
dlg.CurrentEditUser = (User)listViewUsers.SelectedItems[0].Tag;
|
||||
dlg.Session = session;
|
||||
dlg.ShowDialog();
|
||||
new Forms.EditSelectedUser(session, (User)listViewUsers.SelectedItems[0].Tag).ShowDialog();
|
||||
ListUsers();
|
||||
}
|
||||
|
||||
@ -110,11 +118,7 @@ namespace Users.Forms
|
||||
|
||||
private void addButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
Forms.EditSelectedUser dlg;
|
||||
dlg = new Forms.EditSelectedUser();
|
||||
dlg.Session = session;
|
||||
dlg.CurrentEditUser = new User();
|
||||
dlg.ShowDialog();
|
||||
new Forms.EditSelectedUser(session, new User()).ShowDialog();
|
||||
ListUsers();
|
||||
}
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Users")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2016")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2018")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("2.16.667.0")]
|
||||
[assembly: AssemblyFileVersion("2.16.667.0")]
|
||||
[assembly: AssemblyVersion("2.18.788.0")]
|
||||
[assembly: AssemblyFileVersion("2.18.788.0")]
|
||||
|
||||
9
Users/Resources/Strings.Designer.cs
generated
9
Users/Resources/Strings.Designer.cs
generated
@ -258,6 +258,15 @@ namespace Users.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Save or update user failed.
|
||||
/// </summary>
|
||||
internal static string Save_or_update_user_failed {
|
||||
get {
|
||||
return ResourceManager.GetString("Save_or_update_user_failed", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to User code.
|
||||
/// </summary>
|
||||
|
||||
@ -201,4 +201,7 @@
|
||||
<data name="Copying_remote_users_failed" xml:space="preserve">
|
||||
<value>Copying remote users failed</value>
|
||||
</data>
|
||||
<data name="Save_or_update_user_failed" xml:space="preserve">
|
||||
<value>Save or update user failed</value>
|
||||
</data>
|
||||
</root>
|
||||
Loading…
Reference in New Issue
Block a user