User management fixed. Reports working now. Deployed
This commit is contained in:
180
Tanshu.Accounts.PointOfSale/User Management/AssignRoleGroups.Designer.cs
generated
Normal file
180
Tanshu.Accounts.PointOfSale/User Management/AssignRoleGroups.Designer.cs
generated
Normal file
@ -0,0 +1,180 @@
|
||||
namespace Tanshu.Accounts.PointOfSale
|
||||
{
|
||||
partial class AssignGroupRoles
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
this.lstRoles = new System.Windows.Forms.ListBox();
|
||||
this.lstGroupRoles = new System.Windows.Forms.ListBox();
|
||||
this.cmbGroup = new System.Windows.Forms.ComboBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.btnAddSelected = new System.Windows.Forms.Button();
|
||||
this.btnAddAll = new System.Windows.Forms.Button();
|
||||
this.btnRemoveSelected = new System.Windows.Forms.Button();
|
||||
this.btnRemoveAll = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// lstGroups
|
||||
//
|
||||
this.lstRoles.FormattingEnabled = true;
|
||||
this.lstRoles.Location = new System.Drawing.Point(12, 59);
|
||||
this.lstRoles.Name = "lstGroups";
|
||||
this.lstRoles.ScrollAlwaysVisible = true;
|
||||
this.lstRoles.Size = new System.Drawing.Size(183, 225);
|
||||
this.lstRoles.TabIndex = 0;
|
||||
//
|
||||
// lstUserGroups
|
||||
//
|
||||
this.lstGroupRoles.FormattingEnabled = true;
|
||||
this.lstGroupRoles.Location = new System.Drawing.Point(274, 59);
|
||||
this.lstGroupRoles.Name = "lstUserGroups";
|
||||
this.lstGroupRoles.ScrollAlwaysVisible = true;
|
||||
this.lstGroupRoles.Size = new System.Drawing.Size(183, 225);
|
||||
this.lstGroupRoles.TabIndex = 1;
|
||||
//
|
||||
// cmbGroup
|
||||
//
|
||||
this.cmbGroup.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbGroup.FormattingEnabled = true;
|
||||
this.cmbGroup.Location = new System.Drawing.Point(82, 12);
|
||||
this.cmbGroup.Name = "cmbGroup";
|
||||
this.cmbGroup.Size = new System.Drawing.Size(375, 21);
|
||||
this.cmbGroup.TabIndex = 2;
|
||||
this.cmbGroup.SelectedIndexChanged += new System.EventHandler(this.cmbUsers_SelectedIndexChanged);
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(9, 12);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(67, 13);
|
||||
this.label1.TabIndex = 4;
|
||||
this.label1.Text = "Group Name";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(12, 43);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(76, 13);
|
||||
this.label2.TabIndex = 5;
|
||||
this.label2.Text = "Pending Roles";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(271, 43);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(80, 13);
|
||||
this.label3.TabIndex = 6;
|
||||
this.label3.Text = "Assigned Roles";
|
||||
//
|
||||
// btnAddSelected
|
||||
//
|
||||
this.btnAddSelected.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.btnAddSelected.Location = new System.Drawing.Point(201, 105);
|
||||
this.btnAddSelected.Name = "btnAddSelected";
|
||||
this.btnAddSelected.Size = new System.Drawing.Size(67, 25);
|
||||
this.btnAddSelected.TabIndex = 7;
|
||||
this.btnAddSelected.Text = ">";
|
||||
this.btnAddSelected.UseVisualStyleBackColor = true;
|
||||
this.btnAddSelected.Click += new System.EventHandler(this.btnAddSelected_Click);
|
||||
//
|
||||
// btnAddAll
|
||||
//
|
||||
this.btnAddAll.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.btnAddAll.Location = new System.Drawing.Point(201, 136);
|
||||
this.btnAddAll.Name = "btnAddAll";
|
||||
this.btnAddAll.Size = new System.Drawing.Size(67, 25);
|
||||
this.btnAddAll.TabIndex = 8;
|
||||
this.btnAddAll.Text = ">>";
|
||||
this.btnAddAll.UseVisualStyleBackColor = true;
|
||||
this.btnAddAll.Click += new System.EventHandler(this.btnAddAll_Click);
|
||||
//
|
||||
// btnRemoveSelected
|
||||
//
|
||||
this.btnRemoveSelected.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.btnRemoveSelected.Location = new System.Drawing.Point(201, 167);
|
||||
this.btnRemoveSelected.Name = "btnRemoveSelected";
|
||||
this.btnRemoveSelected.Size = new System.Drawing.Size(67, 25);
|
||||
this.btnRemoveSelected.TabIndex = 9;
|
||||
this.btnRemoveSelected.Text = "<";
|
||||
this.btnRemoveSelected.UseVisualStyleBackColor = true;
|
||||
this.btnRemoveSelected.Click += new System.EventHandler(this.btnRemoveSelected_Click);
|
||||
//
|
||||
// btnRemoveAll
|
||||
//
|
||||
this.btnRemoveAll.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.btnRemoveAll.Location = new System.Drawing.Point(201, 198);
|
||||
this.btnRemoveAll.Name = "btnRemoveAll";
|
||||
this.btnRemoveAll.Size = new System.Drawing.Size(67, 25);
|
||||
this.btnRemoveAll.TabIndex = 10;
|
||||
this.btnRemoveAll.Text = "<<";
|
||||
this.btnRemoveAll.UseVisualStyleBackColor = true;
|
||||
this.btnRemoveAll.Click += new System.EventHandler(this.btnRemoveAll_Click);
|
||||
//
|
||||
// AssignGroupRoles
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(469, 323);
|
||||
this.Controls.Add(this.btnRemoveAll);
|
||||
this.Controls.Add(this.btnRemoveSelected);
|
||||
this.Controls.Add(this.btnAddAll);
|
||||
this.Controls.Add(this.btnAddSelected);
|
||||
this.Controls.Add(this.label3);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.cmbGroup);
|
||||
this.Controls.Add(this.lstGroupRoles);
|
||||
this.Controls.Add(this.lstRoles);
|
||||
this.MaximizeBox = false;
|
||||
this.Name = "AssignGroupRoles";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "Assign Role Groups";
|
||||
this.Load += new System.EventHandler(this.AssignGroupRoles_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.ListBox lstRoles;
|
||||
private System.Windows.Forms.ListBox lstGroupRoles;
|
||||
private System.Windows.Forms.ComboBox cmbGroup;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.Button btnAddSelected;
|
||||
private System.Windows.Forms.Button btnAddAll;
|
||||
private System.Windows.Forms.Button btnRemoveSelected;
|
||||
private System.Windows.Forms.Button btnRemoveAll;
|
||||
}
|
||||
}
|
||||
119
Tanshu.Accounts.PointOfSale/User Management/AssignRoleGroups.cs
Normal file
119
Tanshu.Accounts.PointOfSale/User Management/AssignRoleGroups.cs
Normal file
@ -0,0 +1,119 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using Tanshu.Accounts.Helpers;
|
||||
using System.Threading;
|
||||
using Tanshu.Accounts.Repository;
|
||||
using Tanshu.Accounts.Entities.Auth;
|
||||
|
||||
namespace Tanshu.Accounts.PointOfSale
|
||||
{
|
||||
public partial class AssignGroupRoles : Form
|
||||
{
|
||||
public AssignGroupRoles()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void AssignGroupRoles_Load(object sender, EventArgs e)
|
||||
{
|
||||
FillUsers();
|
||||
}
|
||||
|
||||
private void FillUsers()
|
||||
{
|
||||
cmbGroup.DisplayMember = "Name";
|
||||
cmbGroup.ValueMember = "GroupID";
|
||||
cmbGroup.DataSource = MembershipBI.GetGroups();
|
||||
}
|
||||
|
||||
private void cmbUsers_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
GetLists();
|
||||
}
|
||||
|
||||
private void GetLists()
|
||||
{
|
||||
IList<Role> roles;
|
||||
IList<Role> roleGroups;
|
||||
if (cmbGroup.SelectedValue == null)
|
||||
{
|
||||
roles = MembershipBI.GetRoles();
|
||||
roleGroups = new List<Role>();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
int groupID = (int)cmbGroup.SelectedValue;
|
||||
roles = MembershipBI.GetRolesNotOfGroup(groupID);
|
||||
roleGroups = MembershipBI.GetRolesOfGroup(groupID);
|
||||
}
|
||||
|
||||
RefreshRoles(roles, roleGroups);
|
||||
}
|
||||
private void RefreshRoles(IList<Role> roles, IList<Role> roleGroups)
|
||||
{
|
||||
lstRoles.DisplayMember = "Name";
|
||||
lstRoles.ValueMember = "RoleID";
|
||||
lstRoles.DataSource = roles;
|
||||
|
||||
lstGroupRoles.DisplayMember = "Name";
|
||||
lstGroupRoles.ValueMember = "RoleID";
|
||||
lstGroupRoles.DataSource = roleGroups;
|
||||
|
||||
btnAddAll.Enabled = btnAddSelected.Enabled = roles.Count > 0;
|
||||
btnRemoveAll.Enabled = btnRemoveSelected.Enabled = roleGroups.Count > 0;
|
||||
}
|
||||
|
||||
private void btnAddSelected_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (lstRoles.SelectedItem != null)
|
||||
{
|
||||
int groupID = (int)cmbGroup.SelectedValue;
|
||||
int roleID = (int)lstRoles.SelectedValue;
|
||||
MembershipBI.AddRoleToGroup(roleID, groupID);
|
||||
GetLists();
|
||||
}
|
||||
}
|
||||
|
||||
private void btnRemoveSelected_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (lstGroupRoles.SelectedItem != null)
|
||||
{
|
||||
int groupID = (int)cmbGroup.SelectedValue;
|
||||
int roleID = (int)lstGroupRoles.SelectedValue;
|
||||
MembershipBI.RemoveRoleFromGroup(roleID, groupID);
|
||||
GetLists();
|
||||
}
|
||||
}
|
||||
|
||||
private void btnAddAll_Click(object sender, EventArgs e)
|
||||
{
|
||||
int groupID = (int)cmbGroup.SelectedValue;
|
||||
int roleID;
|
||||
for (int i = 0; i <= lstRoles.Items.Count - 1; i++)
|
||||
{
|
||||
roleID = ((Role)lstRoles.Items[i]).RoleID;
|
||||
MembershipBI.AddRoleToGroup(roleID, groupID);
|
||||
}
|
||||
GetLists();
|
||||
}
|
||||
|
||||
private void btnRemoveAll_Click(object sender, EventArgs e)
|
||||
{
|
||||
int groupID = (int)cmbGroup.SelectedValue;
|
||||
int roleID;
|
||||
for (int i = 0; i <= lstGroupRoles.Items.Count - 1; i++)
|
||||
{
|
||||
roleID = ((Role)lstGroupRoles.Items[i]).RoleID;
|
||||
MembershipBI.RemoveRoleFromGroup(roleID, groupID);
|
||||
}
|
||||
GetLists();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,120 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using Tanshu.Accounts.Helpers;
|
||||
using System.Threading;
|
||||
using Tanshu.Accounts.Repository;
|
||||
|
||||
namespace Tanshu.Accounts.PointOfSale
|
||||
{
|
||||
public partial class AssignRoles : Form
|
||||
{
|
||||
public AssignRoles()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void AssignRoles_Load(object sender, EventArgs e)
|
||||
{
|
||||
FillUsers();
|
||||
}
|
||||
|
||||
private void FillUsers()
|
||||
{
|
||||
cmbUsers.DisplayMember = "Name";
|
||||
cmbUsers.ValueMember = "UserID";
|
||||
cmbUsers.DataSource = UserBI.GetUsers();
|
||||
}
|
||||
|
||||
private void cmbUsers_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
RefreshRoles();
|
||||
}
|
||||
|
||||
private void RefreshRoles()
|
||||
{
|
||||
if (cmbUsers.SelectedValue == null)
|
||||
{
|
||||
string[] roles = new MembershipBI().GetAllRoles();
|
||||
lstRoles.DataSource = roles;
|
||||
// lstRoles.DataBind();
|
||||
string[] userRoles = new string[0];
|
||||
lstUserRoles.DataSource = userRoles;
|
||||
// lstUserRoles.DataBind();
|
||||
|
||||
btnAddAll.Enabled = false;
|
||||
btnAddSelected.Enabled = false;
|
||||
btnRemoveAll.Enabled = false;
|
||||
btnRemoveSelected.Enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
string[] roles = new MembershipBI().GetAllRoles();
|
||||
string[] userRoles = new MembershipBI().GetRolesForUser(cmbUsers.Text.Trim());
|
||||
roles = roles.Where(r => !userRoles.Contains(r)).ToArray();
|
||||
lstRoles.DataSource = roles;
|
||||
// lstRoles.DataBind();
|
||||
|
||||
lstUserRoles.DataSource = userRoles;
|
||||
// lstUserRoles.DataBind();
|
||||
|
||||
btnAddAll.Enabled = true;
|
||||
btnAddSelected.Enabled = true;
|
||||
btnRemoveAll.Enabled = true;
|
||||
btnRemoveSelected.Enabled = true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void btnAddSelected_Click(object sender, EventArgs e)
|
||||
{
|
||||
//if (lstRoles.SelectedItem != null)
|
||||
//{
|
||||
// new MembershipBI().AddUsersToRoles(new string[] { cmbUsers.Text.Trim() }, new string[] { lstRoles.SelectedItem.ToString() });
|
||||
// RefreshRoles();
|
||||
//}
|
||||
}
|
||||
|
||||
private void btnRemoveSelected_Click(object sender, EventArgs e)
|
||||
{
|
||||
//if (lstUserRoles.SelectedItem != null)
|
||||
//{
|
||||
// new MembershipBI().RemoveUsersFromRoles(new string[] { cmbUsers.Text.Trim() }, new string[] { lstUserRoles.SelectedItem.ToString() });
|
||||
// RefreshRoles();
|
||||
//}
|
||||
}
|
||||
|
||||
private void btnAddAll_Click(object sender, EventArgs e)
|
||||
{
|
||||
//for (int i = 0; i <= lstRoles.Items.Count - 1; i++)
|
||||
//{
|
||||
// new MembershipBI().AddUsersToRoles(new string[] { cmbUsers.Text.Trim() }, new string[] { lstRoles.Items[i].ToString() });
|
||||
//}
|
||||
//RefreshRoles();
|
||||
|
||||
}
|
||||
|
||||
private void btnRemoveAll_Click(object sender, EventArgs e)
|
||||
{
|
||||
//for (int i = 0; i <= lstUserRoles.Items.Count - 1; i++)
|
||||
//{
|
||||
// new MembershipBI().RemoveUsersFromRoles(new string[] { cmbUsers.Text.Trim() }, new string[] { lstUserRoles.Items[i].ToString() });
|
||||
//}
|
||||
//RefreshRoles();
|
||||
}
|
||||
|
||||
private void AssignRoles_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
//string userName = Thread.CurrentPrincipal.Identity.Name;
|
||||
//AccountsPrincipal principal = AccountsPrincipal.CreateAccountsPrincipal(new MembershipBI().GetRolesForUser(userName), new MembershipBI().GetUserFromName(userName));
|
||||
|
||||
//// bind the generic principal to the thread
|
||||
//Thread.CurrentPrincipal = principal;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
namespace Tanshu.Accounts.PointOfSale
|
||||
{
|
||||
partial class AssignRoles
|
||||
partial class AssignUserGroups
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@ -28,8 +28,8 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.lstRoles = new System.Windows.Forms.ListBox();
|
||||
this.lstUserRoles = new System.Windows.Forms.ListBox();
|
||||
this.lstGroups = new System.Windows.Forms.ListBox();
|
||||
this.lstUserGroups = new System.Windows.Forms.ListBox();
|
||||
this.cmbUsers = new System.Windows.Forms.ComboBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
@ -40,28 +40,30 @@
|
||||
this.btnRemoveAll = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// lstRoles
|
||||
// lstGroups
|
||||
//
|
||||
this.lstRoles.FormattingEnabled = true;
|
||||
this.lstRoles.Location = new System.Drawing.Point(12, 59);
|
||||
this.lstRoles.Name = "lstRoles";
|
||||
this.lstRoles.Size = new System.Drawing.Size(183, 225);
|
||||
this.lstRoles.TabIndex = 0;
|
||||
this.lstGroups.FormattingEnabled = true;
|
||||
this.lstGroups.Location = new System.Drawing.Point(12, 59);
|
||||
this.lstGroups.Name = "lstGroups";
|
||||
this.lstGroups.ScrollAlwaysVisible = true;
|
||||
this.lstGroups.Size = new System.Drawing.Size(183, 225);
|
||||
this.lstGroups.TabIndex = 0;
|
||||
//
|
||||
// lstUserRoles
|
||||
// lstUserGroups
|
||||
//
|
||||
this.lstUserRoles.FormattingEnabled = true;
|
||||
this.lstUserRoles.Location = new System.Drawing.Point(274, 59);
|
||||
this.lstUserRoles.Name = "lstUserRoles";
|
||||
this.lstUserRoles.Size = new System.Drawing.Size(183, 225);
|
||||
this.lstUserRoles.TabIndex = 1;
|
||||
this.lstUserGroups.FormattingEnabled = true;
|
||||
this.lstUserGroups.Location = new System.Drawing.Point(274, 59);
|
||||
this.lstUserGroups.Name = "lstUserGroups";
|
||||
this.lstUserGroups.ScrollAlwaysVisible = true;
|
||||
this.lstUserGroups.Size = new System.Drawing.Size(183, 225);
|
||||
this.lstUserGroups.TabIndex = 1;
|
||||
//
|
||||
// cmbUsers
|
||||
// cmbGroup
|
||||
//
|
||||
this.cmbUsers.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbUsers.FormattingEnabled = true;
|
||||
this.cmbUsers.Location = new System.Drawing.Point(72, 12);
|
||||
this.cmbUsers.Name = "cmbUsers";
|
||||
this.cmbUsers.Name = "cmbGroup";
|
||||
this.cmbUsers.Size = new System.Drawing.Size(276, 21);
|
||||
this.cmbUsers.TabIndex = 2;
|
||||
this.cmbUsers.SelectedIndexChanged += new System.EventHandler(this.cmbUsers_SelectedIndexChanged);
|
||||
@ -80,18 +82,18 @@
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(12, 43);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(76, 13);
|
||||
this.label2.Size = new System.Drawing.Size(83, 13);
|
||||
this.label2.TabIndex = 5;
|
||||
this.label2.Text = "Pending Roles";
|
||||
this.label2.Text = "Pending Groups";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(271, 43);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(80, 13);
|
||||
this.label3.Size = new System.Drawing.Size(87, 13);
|
||||
this.label3.TabIndex = 6;
|
||||
this.label3.Text = "Assigned Roles";
|
||||
this.label3.Text = "Assigned Groups";
|
||||
//
|
||||
// btnAddSelected
|
||||
//
|
||||
@ -137,7 +139,7 @@
|
||||
this.btnRemoveAll.UseVisualStyleBackColor = true;
|
||||
this.btnRemoveAll.Click += new System.EventHandler(this.btnRemoveAll_Click);
|
||||
//
|
||||
// AssignRoles
|
||||
// AssignUserGroups
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
@ -150,14 +152,13 @@
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.cmbUsers);
|
||||
this.Controls.Add(this.lstUserRoles);
|
||||
this.Controls.Add(this.lstRoles);
|
||||
this.Controls.Add(this.lstUserGroups);
|
||||
this.Controls.Add(this.lstGroups);
|
||||
this.MaximizeBox = false;
|
||||
this.Name = "AssignRoles";
|
||||
this.Name = "AssignUserGroups";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "AssignRoles";
|
||||
this.Text = "Assign User Groups";
|
||||
this.Load += new System.EventHandler(this.AssignRoles_Load);
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.AssignRoles_FormClosing);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
@ -165,8 +166,8 @@
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.ListBox lstRoles;
|
||||
private System.Windows.Forms.ListBox lstUserRoles;
|
||||
private System.Windows.Forms.ListBox lstGroups;
|
||||
private System.Windows.Forms.ListBox lstUserGroups;
|
||||
private System.Windows.Forms.ComboBox cmbUsers;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Label label2;
|
||||
119
Tanshu.Accounts.PointOfSale/User Management/AssignUserGroups.cs
Normal file
119
Tanshu.Accounts.PointOfSale/User Management/AssignUserGroups.cs
Normal file
@ -0,0 +1,119 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using Tanshu.Accounts.Helpers;
|
||||
using System.Threading;
|
||||
using Tanshu.Accounts.Repository;
|
||||
using Tanshu.Accounts.Entities.Auth;
|
||||
|
||||
namespace Tanshu.Accounts.PointOfSale
|
||||
{
|
||||
public partial class AssignUserGroups : Form
|
||||
{
|
||||
public AssignUserGroups()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void AssignRoles_Load(object sender, EventArgs e)
|
||||
{
|
||||
FillUsers();
|
||||
}
|
||||
|
||||
private void FillUsers()
|
||||
{
|
||||
cmbUsers.DisplayMember = "Name";
|
||||
cmbUsers.ValueMember = "UserID";
|
||||
cmbUsers.DataSource = UserBI.GetUsers();
|
||||
}
|
||||
|
||||
private void cmbUsers_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
GetLists();
|
||||
}
|
||||
|
||||
private void GetLists()
|
||||
{
|
||||
IList<Group> groups;
|
||||
IList<Group> userGroups;
|
||||
if (cmbUsers.SelectedValue == null)
|
||||
{
|
||||
groups = MembershipBI.GetGroups();
|
||||
userGroups = new List<Group>();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
int userid = (int)cmbUsers.SelectedValue;
|
||||
groups = MembershipBI.GetGroupsNotOfUser(userid);
|
||||
userGroups = MembershipBI.GetGroupsOfUser(userid);
|
||||
}
|
||||
|
||||
RefreshRoles(groups, userGroups);
|
||||
}
|
||||
private void RefreshRoles(IList<Group> groups, IList<Group> userGroups)
|
||||
{
|
||||
lstGroups.DisplayMember = "Name";
|
||||
lstGroups.ValueMember = "GroupID";
|
||||
lstGroups.DataSource = groups;
|
||||
|
||||
lstUserGroups.DisplayMember = "Name";
|
||||
lstUserGroups.ValueMember = "GroupID";
|
||||
lstUserGroups.DataSource = userGroups;
|
||||
|
||||
btnAddAll.Enabled = btnAddSelected.Enabled = groups.Count > 0;
|
||||
btnRemoveAll.Enabled = btnRemoveSelected.Enabled = userGroups.Count > 0;
|
||||
}
|
||||
|
||||
private void btnAddSelected_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (lstGroups.SelectedItem != null)
|
||||
{
|
||||
int userID = (int)cmbUsers.SelectedValue;
|
||||
int groupID = (int)lstGroups.SelectedValue;
|
||||
MembershipBI.AddUserToGroup(userID, groupID);
|
||||
GetLists();
|
||||
}
|
||||
}
|
||||
|
||||
private void btnRemoveSelected_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (lstUserGroups.SelectedItem != null)
|
||||
{
|
||||
int userID = (int)cmbUsers.SelectedValue;
|
||||
int groupID = (int)lstUserGroups.SelectedValue;
|
||||
MembershipBI.RemoveUserFromGroup(userID, groupID);
|
||||
GetLists();
|
||||
}
|
||||
}
|
||||
|
||||
private void btnAddAll_Click(object sender, EventArgs e)
|
||||
{
|
||||
int userID = (int)cmbUsers.SelectedValue;
|
||||
int groupID;
|
||||
for (int i = 0; i <= lstGroups.Items.Count - 1; i++)
|
||||
{
|
||||
groupID = ((Group)lstGroups.Items[i]).GroupID;
|
||||
MembershipBI.AddUserToGroup(userID, groupID);
|
||||
}
|
||||
GetLists();
|
||||
}
|
||||
|
||||
private void btnRemoveAll_Click(object sender, EventArgs e)
|
||||
{
|
||||
int userID = (int)cmbUsers.SelectedValue;
|
||||
int groupID;
|
||||
for (int i = 0; i <= lstUserGroups.Items.Count - 1; i++)
|
||||
{
|
||||
groupID = ((Group)lstUserGroups.Items[i]).GroupID;
|
||||
MembershipBI.RemoveUserFromGroup(userID, groupID);
|
||||
}
|
||||
GetLists();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@ -136,7 +136,7 @@
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(287, 145);
|
||||
this.ClientSize = new System.Drawing.Size(287, 185);
|
||||
this.Controls.Add(this.button2);
|
||||
this.Controls.Add(this.btnCreateUSer);
|
||||
this.Controls.Add(this.txtConfirmPassword);
|
||||
|
||||
@ -4,14 +4,29 @@ using Tanshu.Accounts.Repository;
|
||||
using Tanshu.Accounts.Contracts;
|
||||
using Tanshu.Accounts.Helpers;
|
||||
using Tanshu.Accounts.Entities.Auth;
|
||||
using Tanshu.Common.KeyboardControl;
|
||||
|
||||
namespace Tanshu.Accounts.PointOfSale
|
||||
{
|
||||
public partial class ChangePassword : Form
|
||||
{
|
||||
public ChangePassword()
|
||||
IKeyboardControl keyboardControl;
|
||||
public ChangePassword(IKeyboardControl keyboardControl)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.keyboardControl = keyboardControl;
|
||||
|
||||
var control = keyboardControl as UserControl;
|
||||
if (control != null)
|
||||
{
|
||||
control.Location = new System.Drawing.Point(6, 140);
|
||||
var border = (this.Width - this.ClientSize.Width) / 2;
|
||||
var titlebarHeight = this.Height - this.ClientSize.Height - (2 * border);
|
||||
this.Controls.Add(control);
|
||||
this.Width = 6 + control.Width + 6 + (border * 2);
|
||||
this.Height = titlebarHeight + 140 + control.Height + 6 + (border * 2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void ChangePassword_Load(object sender, EventArgs e)
|
||||
|
||||
@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using Tanshu.Accounts.Repository;
|
||||
using Tanshu.Accounts.Contracts;
|
||||
|
||||
namespace Tanshu.Accounts.PointOfSale
|
||||
{
|
||||
@ -11,13 +12,13 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
{
|
||||
private RoleFactoryBI()
|
||||
{ }
|
||||
public static RoleBI GetRoleBI(string roleID)
|
||||
private static RoleBI GetRoleBI(RoleConstants role)
|
||||
{
|
||||
RoleBI roleBI;
|
||||
if (Session.User != null)
|
||||
roleBI = new RoleBI(roleID, Session.User.UserID);
|
||||
roleBI = new RoleBI(role.Role, Session.User.UserID);
|
||||
else
|
||||
roleBI = new RoleBI(roleID, -1);
|
||||
roleBI = new RoleBI(role.Role, -1);
|
||||
return roleBI;
|
||||
//bool repeat = true;
|
||||
//while (!roleBI.IsAllowed && repeat)
|
||||
|
||||
Reference in New Issue
Block a user