Initial Json commit from 2 years ago

This commit is contained in:
Amritanshu
2018-08-24 16:11:33 +05:30
parent 9301d8d07e
commit d3be8d8481
146 changed files with 3709 additions and 7402 deletions

View File

@ -1,114 +0,0 @@
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.cmbGroup = new System.Windows.Forms.ComboBox();
this.label1 = new System.Windows.Forms.Label();
this.clbRoles = new System.Windows.Forms.CheckedListBox();
this.btnCancel = new System.Windows.Forms.Button();
this.btnOk = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// 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.cmbGroup_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";
//
// clbRoles
//
this.clbRoles.FormattingEnabled = true;
this.clbRoles.Location = new System.Drawing.Point(12, 39);
this.clbRoles.Name = "clbRoles";
this.clbRoles.Size = new System.Drawing.Size(445, 184);
this.clbRoles.TabIndex = 21;
this.clbRoles.Format += new System.Windows.Forms.ListControlConvertEventHandler(this.clbRoles_Format);
//
// btnCancel
//
this.btnCancel.Location = new System.Drawing.Point(382, 236);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(75, 75);
this.btnCancel.TabIndex = 23;
this.btnCancel.Text = "&Cancel";
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// btnOk
//
this.btnOk.Location = new System.Drawing.Point(301, 236);
this.btnOk.Name = "btnOk";
this.btnOk.Size = new System.Drawing.Size(75, 75);
this.btnOk.TabIndex = 22;
this.btnOk.Text = "&Ok";
this.btnOk.UseVisualStyleBackColor = true;
this.btnOk.Click += new System.EventHandler(this.btnOk_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.btnCancel);
this.Controls.Add(this.btnOk);
this.Controls.Add(this.clbRoles);
this.Controls.Add(this.label1);
this.Controls.Add(this.cmbGroup);
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.ComboBox cmbGroup;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.CheckedListBox clbRoles;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.Button btnOk;
}
}

View File

@ -1,89 +0,0 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Linq;
using Tanshu.Accounts.Entities.Auth;
using Tanshu.Accounts.Repository;
namespace Tanshu.Accounts.PointOfSale
{
public partial class AssignGroupRoles : Form
{
public AssignGroupRoles()
{
InitializeComponent();
}
private void AssignGroupRoles_Load(object sender, EventArgs e)
{
FillGroups();
}
private void FillGroups()
{
cmbGroup.DisplayMember = "Name";
cmbGroup.ValueMember = "GroupID";
using (var bi = new GroupBI())
cmbGroup.DataSource = bi.List();
}
private void cmbGroup_SelectedIndexChanged(object sender, EventArgs e)
{
if (cmbGroup.SelectedValue == null)
GetRoles(null);
else
GetRoles((Guid)cmbGroup.SelectedValue);
}
private void GetRoles(Guid? groupID)
{
using (var bi = new GroupBI())
{
var roles = bi.RoleList();
clbRoles.DataSource = roles;
for (int i = 0; i < clbRoles.Items.Count; i++)
{
clbRoles.SetItemChecked(i, false);
}
if (groupID.HasValue)
{
var group = bi.Get(x => x.GroupID == groupID.Value);
for (int i = 0; i < clbRoles.Items.Count; i++)
{
var item = (Role)clbRoles.Items[i];
if (item.Groups.Any(x => x.Group == group))
{
clbRoles.SetItemChecked(i, true);
}
}
}
}
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnOk_Click(object sender, EventArgs e)
{
if (cmbGroup.SelectedValue != null)
Save((Guid)cmbGroup.SelectedValue);
}
private void Save(Guid groupID)
{
using (var bi = new GroupBI())
{
var group = bi.Get(x => x.GroupID == groupID);
bi.Update(group, clbRoles.CheckedItems.OfType<Role>());
bi.SaveChanges();
}
MessageBox.Show("Update / Save Successful");
}
private void clbRoles_Format(object sender, ListControlConvertEventArgs e)
{
e.Value = ((Role)e.ListItem).Name;
}
}
}

View File

@ -1,120 +0,0 @@
<?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>

View File

@ -1,114 +0,0 @@
namespace Tanshu.Accounts.PointOfSale
{
partial class AssignUserGroups
{
/// <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.cmbUser = new System.Windows.Forms.ComboBox();
this.label1 = new System.Windows.Forms.Label();
this.clbGroups = new System.Windows.Forms.CheckedListBox();
this.btnCancel = new System.Windows.Forms.Button();
this.btnOk = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// cmbUser
//
this.cmbUser.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbUser.FormattingEnabled = true;
this.cmbUser.Location = new System.Drawing.Point(72, 12);
this.cmbUser.Name = "cmbUser";
this.cmbUser.Size = new System.Drawing.Size(385, 21);
this.cmbUser.TabIndex = 2;
this.cmbUser.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(60, 13);
this.label1.TabIndex = 4;
this.label1.Text = "User Name";
//
// clbGroups
//
this.clbGroups.FormattingEnabled = true;
this.clbGroups.Location = new System.Drawing.Point(12, 39);
this.clbGroups.Name = "clbGroups";
this.clbGroups.Size = new System.Drawing.Size(445, 184);
this.clbGroups.TabIndex = 22;
this.clbGroups.Format += new System.Windows.Forms.ListControlConvertEventHandler(this.clbGroups_Format);
//
// btnCancel
//
this.btnCancel.Location = new System.Drawing.Point(382, 236);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(75, 75);
this.btnCancel.TabIndex = 25;
this.btnCancel.Text = "&Cancel";
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// btnOk
//
this.btnOk.Location = new System.Drawing.Point(301, 236);
this.btnOk.Name = "btnOk";
this.btnOk.Size = new System.Drawing.Size(75, 75);
this.btnOk.TabIndex = 24;
this.btnOk.Text = "&Ok";
this.btnOk.UseVisualStyleBackColor = true;
this.btnOk.Click += new System.EventHandler(this.btnOk_Click);
//
// AssignUserGroups
//
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.btnCancel);
this.Controls.Add(this.btnOk);
this.Controls.Add(this.clbGroups);
this.Controls.Add(this.label1);
this.Controls.Add(this.cmbUser);
this.MaximizeBox = false;
this.Name = "AssignUserGroups";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Assign User Groups";
this.Load += new System.EventHandler(this.AssignUserGroups_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.ComboBox cmbUser;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.CheckedListBox clbGroups;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.Button btnOk;
}
}

View File

@ -1,95 +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;
using Tanshu.Accounts.Entities.Auth;
namespace Tanshu.Accounts.PointOfSale
{
public partial class AssignUserGroups : Form
{
public AssignUserGroups()
{
InitializeComponent();
}
private void AssignUserGroups_Load(object sender, EventArgs e)
{
FillUsers();
}
private void FillUsers()
{
cmbUser.DisplayMember = "Name";
cmbUser.ValueMember = "UserID";
using (var bi = new UserBI())
cmbUser.DataSource = bi.List();
}
private void cmbUsers_SelectedIndexChanged(object sender, EventArgs e)
{
if (cmbUser.SelectedValue == null)
GetGroups(null);
else
GetGroups((Guid)cmbUser.SelectedValue);
}
private void GetGroups(Guid? userID)
{
using (var bi = new UserBI())
{
var groups = bi.GroupList();
clbGroups.DataSource = groups;
for (int i = 0; i < clbGroups.Items.Count; i++)
{
clbGroups.SetItemChecked(i, false);
}
if (userID.HasValue)
{
var user = bi.Get(x => x.UserID == userID.Value);
for (int i = 0; i < clbGroups.Items.Count; i++)
{
var item = (Group)clbGroups.Items[i];
if (item.UserGroups.Any(x => x.User == user))
{
clbGroups.SetItemChecked(i, true);
}
}
}
}
}
private void btnOk_Click(object sender, EventArgs e)
{
if (cmbUser.SelectedValue != null)
Save((Guid)cmbUser.SelectedValue);
}
private void Save(Guid userID)
{
using (var bi = new UserBI())
{
var user = bi.Get(x => x.UserID == userID);
bi.Update(user, clbGroups.CheckedItems.OfType<Group>());
bi.SaveChanges();
}
MessageBox.Show("Update / Save Successful");
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
private void clbGroups_Format(object sender, ListControlConvertEventArgs e)
{
e.Value = ((Group)e.ListItem).Name;
}
}
}

View File

@ -1,10 +1,8 @@
using System;
using System.Drawing;
using System.Windows.Forms;
using Tanshu.Accounts.Repository;
using Tanshu.Accounts.Contracts;
using Tanshu.Accounts.Helpers;
using Tanshu.Accounts.Entities.Auth;
using Tanshu.Accounts.Repository;
using Tanshu.Common.KeyboardControl;
namespace Tanshu.Accounts.PointOfSale
@ -51,9 +49,11 @@ namespace Tanshu.Accounts.PointOfSale
MessageBox.Show("New password not matched to confirm password", "Password not matched");
else
{
if (ChangeUserPassword())
var changed = UserBI.ChangePassword(Session.User.Name, txtPassword.Text.Trim(), txtnewPassword.Text.Trim());
if (changed)
{
this.Close();
MessageBox.Show("Password changed", "Confirm");
this.Close();
}
else
MessageBox.Show("old Password not matched for user", "Wrong Password");
@ -62,40 +62,22 @@ namespace Tanshu.Accounts.PointOfSale
}
}
private bool ChangeUserPassword()
{
using (var bi = new UserBI())
{
var user = bi.ValidateUser(Session.User.Name, txtPassword.Text.Trim());
if (user == null)
return false;
bi.ChangePassword(user, txtnewPassword.Text.Trim());
bi.SaveChanges();
MessageBox.Show("Password changed", "Confirm");
return true;
}
}
private void btnMsr_Click(object sender, EventArgs e)
{
using (var bi = new UserBI())
var user = UserBI.ValidateUser(Session.User.Name, txtPassword.Text.Trim());
if (user == null)
return;
using (var frm = new MsrLoginForm(true))
{
var user = bi.ValidateUser(Session.User.Name, txtPassword.Text.Trim());
if (user == null)
frm.ShowDialog();
var msrString = frm.User().MsrString;
if (MessageBox.Show("Update Msr Card", "Update", MessageBoxButtons.YesNo, MessageBoxIcon.Question) !=
DialogResult.Yes)
return;
using (var frm = new MsrLoginForm(true))
{
frm.ShowDialog();
var msrString = frm.User().MsrString;
if (MessageBox.Show("Update Msr Card", "Update", MessageBoxButtons.YesNo, MessageBoxIcon.Question) !=
DialogResult.Yes)
return;
user.MsrString = msrString;
bi.Update(user);
bi.SaveChanges();
MessageBox.Show("Msr Card Updated");
this.Close();
}
UserBI.ChangeMsr(user.Name, txtPassword.Text.Trim(), msrString);
MessageBox.Show("Msr Card Updated");
this.Close();
}
}
}

View File

@ -0,0 +1,127 @@
namespace Tanshu.Accounts.PointOfSale
{
partial class RolesForm
{
/// <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.cmbRole = new System.Windows.Forms.ComboBox();
this.label1 = new System.Windows.Forms.Label();
this.clbPermissions = new System.Windows.Forms.CheckedListBox();
this.btnCancel = new System.Windows.Forms.Button();
this.btnOk = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// cmbRole
//
this.cmbRole.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.cmbRole.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbRole.FormattingEnabled = true;
this.cmbRole.Location = new System.Drawing.Point(109, 15);
this.cmbRole.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.cmbRole.Name = "cmbRole";
this.cmbRole.Size = new System.Drawing.Size(499, 24);
this.cmbRole.TabIndex = 2;
this.cmbRole.SelectedIndexChanged += new System.EventHandler(this.cmbGroup_SelectedIndexChanged);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 15);
this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(78, 17);
this.label1.TabIndex = 4;
this.label1.Text = "Role Name";
//
// clbPermissions
//
this.clbPermissions.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.clbPermissions.FormattingEnabled = true;
this.clbPermissions.Location = new System.Drawing.Point(16, 48);
this.clbPermissions.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.clbPermissions.Name = "clbPermissions";
this.clbPermissions.Size = new System.Drawing.Size(592, 225);
this.clbPermissions.TabIndex = 21;
this.clbPermissions.Format += new System.Windows.Forms.ListControlConvertEventHandler(this.clbRoles_Format);
//
// btnCancel
//
this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnCancel.Location = new System.Drawing.Point(509, 290);
this.btnCancel.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(100, 92);
this.btnCancel.TabIndex = 23;
this.btnCancel.Text = "&Cancel";
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// btnOk
//
this.btnOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnOk.Location = new System.Drawing.Point(401, 290);
this.btnOk.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.btnOk.Name = "btnOk";
this.btnOk.Size = new System.Drawing.Size(100, 92);
this.btnOk.TabIndex = 22;
this.btnOk.Text = "&Ok";
this.btnOk.UseVisualStyleBackColor = true;
this.btnOk.Click += new System.EventHandler(this.btnOk_Click);
//
// RolesForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(625, 398);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnOk);
this.Controls.Add(this.clbPermissions);
this.Controls.Add(this.label1);
this.Controls.Add(this.cmbRole);
this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.MaximizeBox = false;
this.Name = "RolesForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Assign Permission Groups";
this.Load += new System.EventHandler(this.RolesForm_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.ComboBox cmbRole;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.CheckedListBox clbPermissions;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.Button btnOk;
}
}

View File

@ -0,0 +1,72 @@
using System;
using System.Linq;
using System.Windows.Forms;
using Tanshu.Accounts.Entities;
using Tanshu.Accounts.Repository;
namespace Tanshu.Accounts.PointOfSale
{
public partial class RolesForm : Form
{
public RolesForm()
{
InitializeComponent();
}
private void RolesForm_Load(object sender, EventArgs e)
{
FillRoles();
}
private void FillRoles()
{
cmbRole.DisplayMember = "Name";
cmbRole.ValueMember = "RoleID";
cmbRole.DataSource = RoleBI.List();
}
private void cmbGroup_SelectedIndexChanged(object sender, EventArgs e)
{
if (cmbRole.SelectedValue == null)
GetPermissions(null);
else
GetPermissions((Role)cmbRole.SelectedItem);
}
private void GetPermissions(Role role)
{
var permissions = RoleBI.Permissions();
clbPermissions.DataSource = permissions;
if (role != null)
{
for (int i = 0; i < clbPermissions.Items.Count; i++)
{
var item = (Permission)clbPermissions.Items[i];
clbPermissions.SetItemChecked(i, role.Permissions.Any(x => x.PermissionID == item.PermissionID));
}
}
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnOk_Click(object sender, EventArgs e)
{
if (cmbRole.SelectedValue != null)
Save((Role)cmbRole.SelectedItem);
}
private void Save(Role role)
{
role.Permissions = clbPermissions.CheckedItems.OfType<Permission>().ToList();
RoleBI.Update(role);
MessageBox.Show("Update / Save Successful");
}
private void clbRoles_Format(object sender, ListControlConvertEventArgs e)
{
e.Value = ((Permission)e.ListItem).Name;
}
}
}

View File

@ -112,9 +112,9 @@
<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>
<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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -38,56 +38,63 @@
this.btnSave = new System.Windows.Forms.Button();
this.txtRetype = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.clbRoles = new System.Windows.Forms.CheckedListBox();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 12);
this.label1.Location = new System.Drawing.Point(16, 15);
this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(60, 13);
this.label1.Size = new System.Drawing.Size(79, 17);
this.label1.TabIndex = 7;
this.label1.Text = "User Name";
//
// txtUsername
//
this.txtUsername.Location = new System.Drawing.Point(78, 12);
this.txtUsername.Location = new System.Drawing.Point(104, 15);
this.txtUsername.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.txtUsername.Name = "txtUsername";
this.txtUsername.Size = new System.Drawing.Size(188, 20);
this.txtUsername.Size = new System.Drawing.Size(249, 22);
this.txtUsername.TabIndex = 0;
//
// txtPassword
//
this.txtPassword.Location = new System.Drawing.Point(78, 38);
this.txtPassword.Location = new System.Drawing.Point(104, 47);
this.txtPassword.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.txtPassword.Name = "txtPassword";
this.txtPassword.Size = new System.Drawing.Size(188, 20);
this.txtPassword.Size = new System.Drawing.Size(249, 22);
this.txtPassword.TabIndex = 1;
this.txtPassword.UseSystemPasswordChar = true;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(19, 38);
this.label2.Location = new System.Drawing.Point(25, 47);
this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(53, 13);
this.label2.Size = new System.Drawing.Size(69, 17);
this.label2.TabIndex = 8;
this.label2.Text = "Password";
//
// chkLocked
//
this.chkLocked.AutoSize = true;
this.chkLocked.Location = new System.Drawing.Point(78, 90);
this.chkLocked.Location = new System.Drawing.Point(104, 111);
this.chkLocked.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.chkLocked.Name = "chkLocked";
this.chkLocked.Size = new System.Drawing.Size(82, 17);
this.chkLocked.Size = new System.Drawing.Size(103, 21);
this.chkLocked.TabIndex = 3;
this.chkLocked.Text = "Locked Out";
this.chkLocked.UseVisualStyleBackColor = true;
//
// btnDelete
//
this.btnDelete.Location = new System.Drawing.Point(96, 113);
this.btnDelete.Location = new System.Drawing.Point(125, 457);
this.btnDelete.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.btnDelete.Name = "btnDelete";
this.btnDelete.Size = new System.Drawing.Size(78, 23);
this.btnDelete.Size = new System.Drawing.Size(104, 28);
this.btnDelete.TabIndex = 5;
this.btnDelete.Text = "&Delete";
this.btnDelete.UseVisualStyleBackColor = true;
@ -95,9 +102,10 @@
//
// btnCancel
//
this.btnCancel.Location = new System.Drawing.Point(180, 113);
this.btnCancel.Location = new System.Drawing.Point(274, 457);
this.btnCancel.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(85, 23);
this.btnCancel.Size = new System.Drawing.Size(113, 28);
this.btnCancel.TabIndex = 6;
this.btnCancel.Text = "&Cancel";
this.btnCancel.UseVisualStyleBackColor = true;
@ -105,9 +113,10 @@
//
// btnSave
//
this.btnSave.Location = new System.Drawing.Point(12, 113);
this.btnSave.Location = new System.Drawing.Point(13, 457);
this.btnSave.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.btnSave.Name = "btnSave";
this.btnSave.Size = new System.Drawing.Size(78, 23);
this.btnSave.Size = new System.Drawing.Size(104, 28);
this.btnSave.TabIndex = 4;
this.btnSave.Text = "&Save";
this.btnSave.UseVisualStyleBackColor = true;
@ -115,26 +124,39 @@
//
// txtRetype
//
this.txtRetype.Location = new System.Drawing.Point(78, 65);
this.txtRetype.Location = new System.Drawing.Point(104, 80);
this.txtRetype.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.txtRetype.Name = "txtRetype";
this.txtRetype.Size = new System.Drawing.Size(188, 20);
this.txtRetype.Size = new System.Drawing.Size(249, 22);
this.txtRetype.TabIndex = 2;
this.txtRetype.UseSystemPasswordChar = true;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(31, 65);
this.label3.Location = new System.Drawing.Point(41, 80);
this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(41, 13);
this.label3.Size = new System.Drawing.Size(53, 17);
this.label3.TabIndex = 9;
this.label3.Text = "Retype";
//
// clbRoles
//
this.clbRoles.FormattingEnabled = true;
this.clbRoles.Location = new System.Drawing.Point(13, 140);
this.clbRoles.Margin = new System.Windows.Forms.Padding(4);
this.clbRoles.Name = "clbRoles";
this.clbRoles.Size = new System.Drawing.Size(374, 293);
this.clbRoles.TabIndex = 23;
this.clbRoles.Format += new System.Windows.Forms.ListControlConvertEventHandler(this.clbRoles_Format);
//
// UserForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(300, 148);
this.ClientSize = new System.Drawing.Size(400, 498);
this.Controls.Add(this.clbRoles);
this.Controls.Add(this.txtRetype);
this.Controls.Add(this.label3);
this.Controls.Add(this.btnSave);
@ -145,6 +167,7 @@
this.Controls.Add(this.label2);
this.Controls.Add(this.txtUsername);
this.Controls.Add(this.label1);
this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.MaximizeBox = false;
this.Name = "UserForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
@ -167,5 +190,6 @@
private System.Windows.Forms.Button btnSave;
private System.Windows.Forms.TextBox txtRetype;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.CheckedListBox clbRoles;
}
}

View File

@ -1,7 +1,8 @@
using System;
using System.Linq;
using System.Windows.Forms;
using Tanshu.Accounts.Entities;
using Tanshu.Accounts.Repository;
using Tanshu.Accounts.Entities.Auth;
namespace Tanshu.Accounts.PointOfSale
{
@ -12,8 +13,7 @@ namespace Tanshu.Accounts.PointOfSale
{
InitializeComponent();
if (userID.HasValue)
using (var bi = new UserBI())
_user = bi.Get(x => x.UserID == userID.Value);
_user = UserBI.Get(userID.Value);
}
private void btnCancel_Click(object sender, EventArgs e)
@ -23,49 +23,50 @@ namespace Tanshu.Accounts.PointOfSale
private void btnDelete_Click(object sender, EventArgs e)
{
using (var bi = new UserBI())
{
bi.Delete(x => x.UserID == _user.UserID);
bi.SaveChanges();
}
UserBI.Delete(_user.UserID);
btnCancel_Click(sender, e);
}
private void UserForm_Load(object sender, EventArgs e)
{
var roles = RoleBI.List();
clbRoles.DataSource = roles;
if (_user == null)
return;
txtUsername.Text = _user.Name;
txtPassword.Text = _user.Password;
txtRetype.Text = _user.Password;
chkLocked.Checked = _user.LockedOut;
for (int i = 0; i < clbRoles.Items.Count; i++)
{
var item = (Role)clbRoles.Items[i];
clbRoles.SetItemChecked(i, _user.Roles.Any(x => x.RoleID == item.RoleID));
}
}
private void Save()
{
using (var bi = new UserBI())
{
if (_user == null)
_user = new User();
else
_user = bi.Get(x => x.UserID == _user.UserID);
if (_user == null)
_user = new User();
else
_user = UserBI.Get(_user.UserID);
_user.Name = txtUsername.Text.Trim();
if (_user.Password != txtPassword.Text.Trim())
_user.Password = Common.Md5.Hash(txtPassword.Text.Trim(), "v2");
_user.LockedOut = (chkLocked.Checked == true ? true : false);
_user.Name = txtUsername.Text.Trim();
if (_user.Password != txtPassword.Text.Trim())
_user.Password = txtPassword.Text.Trim();
_user.LockedOut = (chkLocked.Checked == true ? true : false);
_user.Roles = clbRoles.CheckedItems.OfType<Role>().ToList();
if (_user.UserID == Guid.Empty)
bi.Insert(_user);
else
bi.Update(_user);
bi.SaveChanges();
}
if (_user.UserID == Guid.Empty)
UserBI.Insert(_user);
else
UserBI.Update(_user);
}
private void btnSave_Click(object sender, EventArgs e)
{
if (txtUsername.Text.Trim() == "")
if (string.IsNullOrEmpty(txtUsername.Text.Trim()))
{
MessageBox.Show("Username cannot be blank.");
txtUsername.Focus();
@ -75,7 +76,7 @@ namespace Tanshu.Accounts.PointOfSale
MessageBox.Show("Passwords do not match.");
txtPassword.Focus();
}
else if (string.IsNullOrEmpty(txtPassword.Text.Trim()))
else if (_user == null && string.IsNullOrEmpty(txtPassword.Text.Trim()))
{
MessageBox.Show("Password cannot be empty.");
txtPassword.Focus();
@ -83,8 +84,13 @@ namespace Tanshu.Accounts.PointOfSale
else
{
Save();
btnCancel_Click(sender, e);
this.Close();
}
}
private void clbRoles_Format(object sender, ListControlConvertEventArgs e)
{
e.Value = ((Role)e.ListItem).Name;
}
}
}

View File

@ -112,9 +112,9 @@
<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>
<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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -108,7 +108,7 @@
//
// bsList
//
this.bsList.DataSource = typeof(Tanshu.Accounts.Entities.Auth.User);
this.bsList.DataSource = typeof(Tanshu.Accounts.Entities.User);
//
// nameDataGridViewTextBoxColumn
//

View File

@ -1,10 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using Tanshu.Accounts.Entities;
using Tanshu.Accounts.Repository;
using System.Collections.Generic;
using Tanshu.Accounts.Entities.Auth;
namespace Tanshu.Accounts.PointOfSale
{
@ -20,8 +19,7 @@ namespace Tanshu.Accounts.PointOfSale
{
using (var frm = new UserForm(null))
frm.ShowDialog();
using (var bi = new UserBI())
_list = bi.List();
_list = UserBI.List();
bsList.DataSource = _list;
}
@ -31,8 +29,7 @@ namespace Tanshu.Accounts.PointOfSale
}
private void ShowGrid()
{
using (var bi = new UserBI())
_list = bi.List();
_list = UserBI.List();
bsList.DataSource = _list;
}
@ -41,8 +38,7 @@ namespace Tanshu.Accounts.PointOfSale
var id = ((User)bsList.Current).UserID;
using (var frm = new UserForm(id))
frm.ShowDialog();
using (var bi = new UserBI())
_list = bi.List();
_list = UserBI.List();
bsList.DataSource = _list;
}
@ -68,7 +64,7 @@ namespace Tanshu.Accounts.PointOfSale
if (e.ColumnIndex == dgvUsers.Columns["UserGroups"].Index)
{
e.Value = string.Join(", ", data.UserGroups.Select(x => x.Group.Name).ToArray());
e.Value = string.Join(", ", data.Roles.Select(x => x.Name).ToArray());
}
var tax = e.Value as Tax;