Numpad User Control and Login Changes

This commit is contained in:
unknown
2011-01-06 12:47:00 +05:30
parent 232a62f8ca
commit e32e9f9e74
47 changed files with 1536 additions and 714 deletions

View File

@ -1,12 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="connection" connectionString="Server=.;Initial Catalog=AccountsBF;User ID=sa;Password=123456" />
<add name="connection" connectionString="Server=.;Initial Catalog=PeithoPOS;User ID=sa;Password=123456" />
</connectionStrings>
<appSettings>
<add key ="Factory" value ="SqlServer"/>
<add key ="LogConnection" value ="connection"/>
<add key ="LogLevel" value ="Warn"/>
<add key="Printer" value="Posiflex" />
</appSettings>
</configuration>

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Tanshu.Accounts.PointOfSale
{
interface ILogin
{
bool LoginUser();
bool LogoutUser();
}
}

View File

@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tanshu.Accounts.BI;
using System.Threading;
namespace Tanshu.Accounts.PointOfSale
{
class KeyboardLogin : ILogin
{
private static readonly Tanshu.Logging.SqlLogger log = new Tanshu.Logging.SqlLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public bool LoginUser()
{
return LoginUser(true);
}
bool LoginUser(bool setThreadPrincipal)
{
using (LoginForm login = new LoginForm())
{
string userName;
login.ShowDialog();
bool authenticated = login.UserName(out userName);
if (authenticated && setThreadPrincipal)
SetThreadPrincipal(userName);
return authenticated;
}
}
public bool LogoutUser()
{
Session.User = null;
return true;
}
static void SetThreadPrincipal(string userName)
{
log.Warn(string.Format("User Login: '{0}'", userName));
if (userName.Contains(":"))
userName = userName.Substring(userName.IndexOf(":") + 1);
Session.User = new MembershipBI().GetUserFromName(userName);
}
}
}

View File

@ -34,6 +34,7 @@
this.Label2 = new System.Windows.Forms.Label();
this.txtUserName = new System.Windows.Forms.TextBox();
this.Label1 = new System.Windows.Forms.Label();
this.numpadControl1 = new Tanshu.Common.KeyboardControl.NumpadControl();
this.SuspendLayout();
//
// btnExit
@ -90,12 +91,21 @@
this.Label1.TabIndex = 4;
this.Label1.Text = "Username";
//
// numpadControl1
//
this.numpadControl1.Location = new System.Drawing.Point(35, 93);
this.numpadControl1.Name = "numpadControl1";
this.numpadControl1.Size = new System.Drawing.Size(224, 224);
this.numpadControl1.TabIndex = 6;
this.numpadControl1.TabStop = false;
//
// LoginForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.btnExit;
this.ClientSize = new System.Drawing.Size(290, 99);
this.ClientSize = new System.Drawing.Size(290, 329);
this.Controls.Add(this.numpadControl1);
this.Controls.Add(this.txtPassword);
this.Controls.Add(this.Label2);
this.Controls.Add(this.txtUserName);
@ -119,5 +129,6 @@
internal System.Windows.Forms.Label Label2;
internal System.Windows.Forms.TextBox txtUserName;
internal System.Windows.Forms.Label Label1;
private Tanshu.Common.KeyboardControl.NumpadControl numpadControl1;
}
}

View File

@ -8,14 +8,17 @@ namespace Tanshu.Accounts.PointOfSale
{
public partial class LoginForm : Form
{
//size: 296, 123
private static readonly Tanshu.Logging.SqlLogger log = new Tanshu.Logging.SqlLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private bool isAuthenticated;
private string userName;
private bool cancelled;
public LoginForm()
{
InitializeComponent();
isAuthenticated = false;
userName = null;
cancelled = true;
}
private void txtUserName_KeyDown(object sender, KeyEventArgs e)
@ -36,7 +39,9 @@ namespace Tanshu.Accounts.PointOfSale
isAuthenticated = new MembershipBI().ValidateUser(userName, Tanshu.Common.Md5.Hash(txtPassword.Text, "Salt"));
if (isAuthenticated)
{
this.Close();
}
else
MessageBox.Show("Username or password is not valid");

View File

@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tanshu.Accounts.Contracts;
namespace Tanshu.Accounts.PointOfSale
{
static class Session
{
private static UserBO currentUser;
public static bool IsAuthenticated { get; private set; }
public static UserBO User
{
get
{
return currentUser;
}
set
{
if (value != null)
{
currentUser = value;
IsAuthenticated = true;
}
else
{
currentUser = null;
IsAuthenticated = false;
}
}
}
static public string printer()
{
return "";
}
}
}

View File

@ -0,0 +1,291 @@
namespace Tanshu.Accounts.PointOfSale
{
partial class CurrencyCounter
{
/// <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.txtTotal = new System.Windows.Forms.TextBox();
this.txt1 = new System.Windows.Forms.TextBox();
this.txt2 = new System.Windows.Forms.TextBox();
this.txt5 = new System.Windows.Forms.TextBox();
this.txt10 = new System.Windows.Forms.TextBox();
this.txt20 = new System.Windows.Forms.TextBox();
this.txt50 = new System.Windows.Forms.TextBox();
this.txt100 = new System.Windows.Forms.TextBox();
this.txt500 = new System.Windows.Forms.TextBox();
this.txt1000 = new System.Windows.Forms.TextBox();
this.btnPrint = new System.Windows.Forms.Button();
this.lblTotal = new System.Windows.Forms.Label();
this.label10 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// txtTotal
//
this.txtTotal.Location = new System.Drawing.Point(54, 282);
this.txtTotal.Name = "txtTotal";
this.txtTotal.ReadOnly = true;
this.txtTotal.Size = new System.Drawing.Size(100, 20);
this.txtTotal.TabIndex = 42;
//
// txt1
//
this.txt1.Location = new System.Drawing.Point(54, 252);
this.txt1.Name = "txt1";
this.txt1.Size = new System.Drawing.Size(100, 20);
this.txt1.TabIndex = 41;
this.txt1.TextChanged += new System.EventHandler(this.txt1000_TextChanged);
//
// txt2
//
this.txt2.Location = new System.Drawing.Point(54, 222);
this.txt2.Name = "txt2";
this.txt2.Size = new System.Drawing.Size(100, 20);
this.txt2.TabIndex = 40;
this.txt2.TextChanged += new System.EventHandler(this.txt1000_TextChanged);
//
// txt5
//
this.txt5.Location = new System.Drawing.Point(54, 192);
this.txt5.Name = "txt5";
this.txt5.Size = new System.Drawing.Size(100, 20);
this.txt5.TabIndex = 39;
this.txt5.TextChanged += new System.EventHandler(this.txt1000_TextChanged);
//
// txt10
//
this.txt10.Location = new System.Drawing.Point(54, 162);
this.txt10.Name = "txt10";
this.txt10.Size = new System.Drawing.Size(100, 20);
this.txt10.TabIndex = 38;
this.txt10.TextChanged += new System.EventHandler(this.txt1000_TextChanged);
//
// txt20
//
this.txt20.Location = new System.Drawing.Point(54, 132);
this.txt20.Name = "txt20";
this.txt20.Size = new System.Drawing.Size(100, 20);
this.txt20.TabIndex = 37;
this.txt20.TextChanged += new System.EventHandler(this.txt1000_TextChanged);
//
// txt50
//
this.txt50.Location = new System.Drawing.Point(54, 102);
this.txt50.Name = "txt50";
this.txt50.Size = new System.Drawing.Size(100, 20);
this.txt50.TabIndex = 36;
this.txt50.TextChanged += new System.EventHandler(this.txt1000_TextChanged);
//
// txt100
//
this.txt100.Location = new System.Drawing.Point(54, 72);
this.txt100.Name = "txt100";
this.txt100.Size = new System.Drawing.Size(100, 20);
this.txt100.TabIndex = 35;
this.txt100.TextChanged += new System.EventHandler(this.txt1000_TextChanged);
//
// txt500
//
this.txt500.Location = new System.Drawing.Point(54, 42);
this.txt500.Name = "txt500";
this.txt500.Size = new System.Drawing.Size(100, 20);
this.txt500.TabIndex = 34;
this.txt500.TextChanged += new System.EventHandler(this.txt1000_TextChanged);
//
// txt1000
//
this.txt1000.Location = new System.Drawing.Point(54, 12);
this.txt1000.Name = "txt1000";
this.txt1000.Size = new System.Drawing.Size(100, 20);
this.txt1000.TabIndex = 33;
this.txt1000.TextChanged += new System.EventHandler(this.txt1000_TextChanged);
//
// btnPrint
//
this.btnPrint.Location = new System.Drawing.Point(54, 313);
this.btnPrint.Name = "btnPrint";
this.btnPrint.Size = new System.Drawing.Size(100, 20);
this.btnPrint.TabIndex = 32;
this.btnPrint.Text = "Print";
this.btnPrint.UseVisualStyleBackColor = true;
this.btnPrint.Click += new System.EventHandler(this.btnPrint_Click);
//
// lblTotal
//
this.lblTotal.AutoSize = true;
this.lblTotal.Location = new System.Drawing.Point(16, 285);
this.lblTotal.Name = "lblTotal";
this.lblTotal.Size = new System.Drawing.Size(31, 13);
this.lblTotal.TabIndex = 31;
this.lblTotal.Text = "Total";
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(29, 258);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(18, 13);
this.label10.TabIndex = 30;
this.label10.Text = "1x";
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(28, 227);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(18, 13);
this.label9.TabIndex = 29;
this.label9.Text = "2x";
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(28, 197);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(18, 13);
this.label8.TabIndex = 28;
this.label8.Text = "5x";
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(22, 167);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(24, 13);
this.label7.TabIndex = 27;
this.label7.Text = "10x";
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(22, 137);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(24, 13);
this.label6.TabIndex = 26;
this.label6.Text = "20x";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(21, 108);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(24, 13);
this.label5.TabIndex = 25;
this.label5.Text = "50x";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(17, 75);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(30, 13);
this.label3.TabIndex = 24;
this.label3.Text = "100x";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(18, 46);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(30, 13);
this.label2.TabIndex = 23;
this.label2.Text = "500x";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 17);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(36, 13);
this.label1.TabIndex = 22;
this.label1.Text = "1000x";
//
// CurrencyCounter
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(173, 354);
this.Controls.Add(this.txtTotal);
this.Controls.Add(this.txt1);
this.Controls.Add(this.txt2);
this.Controls.Add(this.txt5);
this.Controls.Add(this.txt10);
this.Controls.Add(this.txt20);
this.Controls.Add(this.txt50);
this.Controls.Add(this.txt100);
this.Controls.Add(this.txt500);
this.Controls.Add(this.txt1000);
this.Controls.Add(this.btnPrint);
this.Controls.Add(this.lblTotal);
this.Controls.Add(this.label10);
this.Controls.Add(this.label9);
this.Controls.Add(this.label8);
this.Controls.Add(this.label7);
this.Controls.Add(this.label6);
this.Controls.Add(this.label5);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Name = "CurrencyCounter";
this.Text = "CurrencyCounter";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox txtTotal;
private System.Windows.Forms.TextBox txt1;
private System.Windows.Forms.TextBox txt2;
private System.Windows.Forms.TextBox txt5;
private System.Windows.Forms.TextBox txt10;
private System.Windows.Forms.TextBox txt20;
private System.Windows.Forms.TextBox txt50;
private System.Windows.Forms.TextBox txt100;
private System.Windows.Forms.TextBox txt500;
private System.Windows.Forms.TextBox txt1000;
private System.Windows.Forms.Button btnPrint;
private System.Windows.Forms.Label lblTotal;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
}
}

View File

@ -0,0 +1,57 @@
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;
namespace Tanshu.Accounts.PointOfSale
{
public partial class CurrencyCounter : Form
{
public CurrencyCounter()
{
InitializeComponent();
}
private void btnPrint_Click(object sender, EventArgs e)
{
Dictionary<int, int> amounts = new Dictionary<int, int>();
if (txt1000.Text != "") amounts.Add(1000, Convert.ToInt32(txt1000.Text));
if (txt500.Text != "") amounts.Add(500, Convert.ToInt32(txt500.Text));
if (txt100.Text != "") amounts.Add(100, Convert.ToInt32(txt100.Text));
if (txt50.Text != "") amounts.Add(50, Convert.ToInt32(txt50.Text));
if (txt20.Text != "") amounts.Add(20, Convert.ToInt32(txt20.Text));
if (txt10.Text != "") amounts.Add(10, Convert.ToInt32(txt10.Text));
if (txt5.Text != "") amounts.Add(5, Convert.ToInt32(txt5.Text));
if (txt2.Text != "") amounts.Add(2, Convert.ToInt32(txt2.Text));
if (txt1.Text != "") amounts.Add(1, Convert.ToInt32(txt1.Text));
Accounts.Print.Thermal.PrintCash(Session.printer(), amounts, Session.User.Name);
}
private void txt1000_TextChanged(object sender, EventArgs e)
{
try
{
int Amount = 0;
Amount += 1000 * (txt1000.Text == "" ? 0 : Convert.ToInt16(txt1000.Text));
Amount += 500 * (txt500.Text == "" ? 0 : Convert.ToInt16(txt500.Text));
Amount += 100 * (txt100.Text == "" ? 0 : Convert.ToInt16(txt100.Text));
Amount += 50 * (txt50.Text == "" ? 0 : Convert.ToInt16(txt50.Text));
Amount += 20 * (txt20.Text == "" ? 0 : Convert.ToInt16(txt20.Text));
Amount += 10 * (txt10.Text == "" ? 0 : Convert.ToInt16(txt10.Text));
Amount += 5 * (txt5.Text == "" ? 0 : Convert.ToInt16(txt5.Text));
Amount += 2 * (txt2.Text == "" ? 0 : Convert.ToInt16(txt2.Text));
Amount += 1 * (txt1.Text == "" ? 0 : Convert.ToInt16(txt1.Text));
txtTotal.Text = Amount.ToString();
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show("Error Number " + ex.Source + "\n\r" + ex.Message);
}
}
}
}

View File

@ -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>

View File

@ -16,86 +16,28 @@ namespace Tanshu.Accounts.PointOfSale
InitializeComponent();
}
private void btnPrint_Click(object sender, EventArgs e)
{
MessageBox.Show(CurrentUser.user.Name);
using (RoleBI roleBI = RoleFactoryBI.GetRoleBI("Sales/Checkout"))
{
if (roleBI.IsAllowed)
using (Cashier_Checkout_Form frmChashierCheckOut = new Cashier_Checkout_Form())
{
frmChashierCheckOut.ShowDialog();
}
}
//Dictionary<int, int> amounts = new Dictionary<int, int>();
//if (txt1000.Text != "") amounts.Add(1000, Convert.ToInt32(txt1000.Text));
//if (txt500.Text != "") amounts.Add(500, Convert.ToInt32(txt500.Text));
//if (txt100.Text != "") amounts.Add(100, Convert.ToInt32(txt100.Text));
//if (txt50.Text != "") amounts.Add(50, Convert.ToInt32(txt50.Text));
//if (txt20.Text != "") amounts.Add(20, Convert.ToInt32(txt20.Text));
//if (txt10.Text != "") amounts.Add(10, Convert.ToInt32(txt10.Text));
//if (txt5.Text != "") amounts.Add(5, Convert.ToInt32(txt5.Text));
//if (txt2.Text != "") amounts.Add(2, Convert.ToInt32(txt2.Text));
//if (txt1.Text != "") amounts.Add(1, Convert.ToInt32(txt1.Text));
//Accounts.Print.Thermal.PrintCash(amounts);
}
private void saleToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!Thread.CurrentPrincipal.IsInRole("Sales/SalesBill"))
{
MessageBox.Show("You are not authorized to access");
}
else
{
new ProductBI().UpdateShortName();
using (SalesForm frmSale = new SalesForm())
frmSale.ShowDialog();
}
}
private void txt1000_TextChanged(object sender, EventArgs e)
{
try
{
int Amount = 0;
Amount += 1000 * Convert.ToInt16(txt1000.Text);
Amount += 500 * (txt500.Text == "" ? 0 : Convert.ToInt16(txt500.Text));
Amount += 100 * (txt100.Text == "" ? 0 : Convert.ToInt16(txt100.Text));
Amount += 50 * (txt50.Text == "" ? 0 : Convert.ToInt16(txt50.Text));
Amount += 20 * (txt20.Text == "" ? 0 : Convert.ToInt16(txt20.Text));
Amount += 10 * (txt10.Text == "" ? 0 : Convert.ToInt16(txt10.Text));
Amount += 5 * (txt5.Text == "" ? 0 : Convert.ToInt16(txt5.Text));
Amount += 2 * (txt2.Text == "" ? 0 : Convert.ToInt16(txt2.Text));
Amount += 1 * (txt1.Text == "" ? 0 : Convert.ToInt16(txt1.Text));
txtTotal.Text = Amount.ToString();
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show("Error Number " + ex.Source + "\n\r" + ex.Message);
}
}
private void advancesToolStripMenuItem_Click(object sender, EventArgs e)
{
RecieveAdvanceForm frmReceivedAdvance = new RecieveAdvanceForm();
frmReceivedAdvance.ShowDialog();
frmReceivedAdvance.Dispose();
using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(Roles.SALES_SALES_BILL))
{
if (roleBI.IsAllowed)
{
using (RecieveAdvanceForm frm = new RecieveAdvanceForm())
frm.ShowDialog();
}
}
}
private void paymentsToolStripMenuItem_Click(object sender, EventArgs e)
{
AdjustAdvanceForm frmAdjustAdvancesForm = new AdjustAdvanceForm();
frmAdjustAdvancesForm.ShowDialog();
frmAdjustAdvancesForm.Dispose();
}
private void paymentsToolStripMenuItem1_Click(object sender, EventArgs e)
{
LogViewerForm frmPayments = new LogViewerForm();
frmPayments.ShowDialog();
frmPayments.Dispose();
using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(Roles.SALES_SALES_BILL))
{
if (roleBI.IsAllowed)
{
using (AdjustAdvanceForm frm = new AdjustAdvanceForm())
frm.ShowDialog();
}
}
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
@ -105,15 +47,14 @@ namespace Tanshu.Accounts.PointOfSale
private void createNewUserToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!Thread.CurrentPrincipal.IsInRole("Security/ManageRoles"))
MessageBox.Show("You are not authorized to access");
else
using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(Roles.SECURITY_MANAGE_ROLES))
{
using (SelectUser form = new SelectUser(new UserBI().GetFilteredUsers, true))
{
form.userEvent += new UserEventHandler(form_userEvent);
form.ShowDialog();
}
if (roleBI.IsAllowed)
using (SelectUser form = new SelectUser(new UserBI().GetFilteredUsers, true))
{
form.userEvent += new UserEventHandler(form_userEvent);
form.ShowDialog();
}
}
}
@ -141,20 +82,18 @@ namespace Tanshu.Accounts.PointOfSale
private void changePasswordToolStripMenuItem_Click(object sender, EventArgs e)
{
ChangePassword frm = new ChangePassword();
frm.ShowDialog();
frm.Dispose();
using (ChangePassword frm = new ChangePassword())
frm.ShowDialog();
}
private void assignRolesToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!Thread.CurrentPrincipal.IsInRole("Security/ManageRoles"))
MessageBox.Show("You are not authorized to access");
else
using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(Roles.SECURITY_MANAGE_ROLES))
{
AssignRoles frm = new AssignRoles();
frm.ShowDialog();
frm.Dispose();
if (roleBI.IsAllowed)
using (AssignRoles frm = new AssignRoles())
frm.ShowDialog();
}
}
@ -166,34 +105,24 @@ namespace Tanshu.Accounts.PointOfSale
}
}
private void MainForm_Load(object sender, EventArgs e)
{
this.Text = "Main Menu - User: " + CurrentUser.user.Name;
}
private void salesAnalysisToolStripMenuItem1_Click(object sender, EventArgs e)
{
if (!Thread.CurrentPrincipal.IsInRole("Sales/SaleDetail"))
MessageBox.Show("You are not authorized to access");
else
using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(Roles.SALES_SALE_DETAIL))
{
frmSaleAnalysisForm frmSalesAnalysis = new frmSaleAnalysisForm();
frmSalesAnalysis.ShowDialog();
frmSalesAnalysis.Dispose();
if (roleBI.IsAllowed)
using (frmSaleAnalysisForm frm = new frmSaleAnalysisForm())
frm.ShowDialog();
}
}
private void cashierCheckoutToolStripMenuItem1_Click(object sender, EventArgs e)
{
if (!Thread.CurrentPrincipal.IsInRole("Sales/Checkout"))
MessageBox.Show("You are not authorized to access");
else
using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(Roles.SALES_CHECKOUT))
{
Cashier_Checkout_Form frmChashierCheckOut = new Cashier_Checkout_Form();
frmChashierCheckOut.ShowDialog();
frmChashierCheckOut.Dispose();
if (roleBI.IsAllowed)
using (Cashier_Checkout_Form frm = new Cashier_Checkout_Form())
frm.ShowDialog();
}
}
private void customersToolStripMenuItem_Click(object sender, EventArgs e)
@ -207,15 +136,11 @@ namespace Tanshu.Accounts.PointOfSale
private void productsToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!Thread.CurrentPrincipal.IsInRole("Master/Products"))
using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(Roles.MASTER_PRODUCTS))
{
MessageBox.Show("You are not authorized to access");
}
else
{
ProductsForm form = new ProductsForm();
form.ShowDialog();
form.Dispose();
if (roleBI.IsAllowed)
using (ProductsForm frm = new ProductsForm())
frm.ShowDialog();
}
}
@ -226,100 +151,86 @@ namespace Tanshu.Accounts.PointOfSale
ProductType.Dispose();
}
private void toolStripMenuItem1_Click(object sender, EventArgs e)
{
//ProductNewRates ProductRates = new ProductNewRates();
//ProductRates.ShowDialog();
//ProductRates.Dispose();
}
private void applyNewRatesToolStripMenuItem_Click(object sender, EventArgs e)
{
//ApplyRates ApplyRate = new ApplyRates();
//ApplyRate.ShowDialog();
//ApplyRate.Dispose();
}
private void masterToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void complexProductsToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!Thread.CurrentPrincipal.IsInRole("Master/Products"))
{
MessageBox.Show("You are not authorized to access");
}
else
{
//ComplexProductForm form = new ComplexProductForm();
//form.ShowDialog();
//form.Dispose();
}
}
private void viewLogToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!Thread.CurrentPrincipal.IsInRole("Log/View"))
MessageBox.Show("You are not authorized to access");
else
using (LogViewerForm form = new LogViewerForm())
form.ShowDialog();
using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(Roles.LOG_VIEW))
{
if (roleBI.IsAllowed)
using (LogViewerForm frm = new LogViewerForm())
frm.ShowDialog();
}
}
private void updateToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!Thread.CurrentPrincipal.IsInRole("Master/Products"))
using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(Roles.MASTER_OWNER))
{
MessageBox.Show("You are not authorized to access");
}
else
{
using (UpdateForm form = new UpdateForm())
{
form.ShowDialog();
}
if (roleBI.IsAllowed)
using (UpdateForm frm = new UpdateForm())
frm.ShowDialog();
}
}
private void reportToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!Thread.CurrentPrincipal.IsInRole("Master/Products"))
using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(Roles.MASTER_OWNER))
{
MessageBox.Show("You are not authorized to access");
}
else
{
using (SaleTaxReportForm form = new SaleTaxReportForm())
{
form.ShowDialog();
}
if (roleBI.IsAllowed)
using (SaleTaxReportForm frm = new SaleTaxReportForm())
frm.ShowDialog();
}
}
private void updateBillsToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!Thread.CurrentPrincipal.IsInRole("Master/Products"))
using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(Roles.MASTER_OWNER))
{
MessageBox.Show("You are not authorized to access");
}
else
{
using (UpdateSales form = new UpdateSales())
{
form.ShowDialog();
}
if (roleBI.IsAllowed)
using (UpdateSales frm = new UpdateSales())
frm.ShowDialog();
}
}
private void autoToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!Thread.CurrentPrincipal.IsInRole("Master/Products"))
MessageBox.Show("You are not authorized to access");
using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(Roles.MASTER_OWNER))
{
if (roleBI.IsAllowed)
using (ReplaceForm frm = new ReplaceForm())
frm.ShowDialog();
}
}
private void btnLogin_Click(object sender, EventArgs e)
{
ILogin login = new KeyboardLogin();
if (!Session.IsAuthenticated)
{
if (login.LoginUser())
{
this.Text = "Main Menu - User: " + Session.User.Name;
btnLogin.Text = "Logout";
}
}
else
using (ReplaceForm form = new ReplaceForm())
form.ShowDialog();
{
login.LogoutUser();
this.Text = "Main Menu - Login";
btnLogin.Text = "Login";
}
}
private void btnSale_Click(object sender, EventArgs e)
{
using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(Roles.SALES_SALES_BILL))
{
if (roleBI.IsAllowed)
{
new ProductBI().UpdateShortName();
using (SalesForm frmSale = new SalesForm())
frmSale.ShowDialog();
}
}
}
}
}

View File

@ -28,29 +28,6 @@
/// </summary>
private void InitializeComponent()
{
this.CashCalculator = new System.Windows.Forms.GroupBox();
this.txtTotal = new System.Windows.Forms.TextBox();
this.txt1 = new System.Windows.Forms.TextBox();
this.txt2 = new System.Windows.Forms.TextBox();
this.txt5 = new System.Windows.Forms.TextBox();
this.txt10 = new System.Windows.Forms.TextBox();
this.txt20 = new System.Windows.Forms.TextBox();
this.txt50 = new System.Windows.Forms.TextBox();
this.txt100 = new System.Windows.Forms.TextBox();
this.txt500 = new System.Windows.Forms.TextBox();
this.txt1000 = new System.Windows.Forms.TextBox();
this.btnPrint = new System.Windows.Forms.Button();
this.lblTotal = new System.Windows.Forms.Label();
this.label10 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.masterToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.prToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@ -62,7 +39,6 @@
this.autoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.updateBillsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.transactionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.advancesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.paymentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.paymentsToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
@ -75,228 +51,11 @@
this.salesAnalysisToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.viewLogToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.CashCalculator.SuspendLayout();
this.btnLogin = new System.Windows.Forms.Button();
this.btnSale = new System.Windows.Forms.Button();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
//
// CashCalculator
//
this.CashCalculator.Controls.Add(this.txtTotal);
this.CashCalculator.Controls.Add(this.txt1);
this.CashCalculator.Controls.Add(this.txt2);
this.CashCalculator.Controls.Add(this.txt5);
this.CashCalculator.Controls.Add(this.txt10);
this.CashCalculator.Controls.Add(this.txt20);
this.CashCalculator.Controls.Add(this.txt50);
this.CashCalculator.Controls.Add(this.txt100);
this.CashCalculator.Controls.Add(this.txt500);
this.CashCalculator.Controls.Add(this.txt1000);
this.CashCalculator.Controls.Add(this.btnPrint);
this.CashCalculator.Controls.Add(this.lblTotal);
this.CashCalculator.Controls.Add(this.label10);
this.CashCalculator.Controls.Add(this.label9);
this.CashCalculator.Controls.Add(this.label8);
this.CashCalculator.Controls.Add(this.label7);
this.CashCalculator.Controls.Add(this.label6);
this.CashCalculator.Controls.Add(this.label5);
this.CashCalculator.Controls.Add(this.label4);
this.CashCalculator.Controls.Add(this.label3);
this.CashCalculator.Controls.Add(this.label2);
this.CashCalculator.Controls.Add(this.label1);
this.CashCalculator.Location = new System.Drawing.Point(13, 33);
this.CashCalculator.Name = "CashCalculator";
this.CashCalculator.Size = new System.Drawing.Size(174, 346);
this.CashCalculator.TabIndex = 25;
this.CashCalculator.TabStop = false;
//
// txtTotal
//
this.txtTotal.Location = new System.Drawing.Point(51, 286);
this.txtTotal.Name = "txtTotal";
this.txtTotal.ReadOnly = true;
this.txtTotal.Size = new System.Drawing.Size(100, 20);
this.txtTotal.TabIndex = 21;
//
// txt1
//
this.txt1.Location = new System.Drawing.Point(51, 256);
this.txt1.Name = "txt1";
this.txt1.Size = new System.Drawing.Size(100, 20);
this.txt1.TabIndex = 20;
this.txt1.TextChanged += new System.EventHandler(this.txt1000_TextChanged);
//
// txt2
//
this.txt2.Location = new System.Drawing.Point(51, 226);
this.txt2.Name = "txt2";
this.txt2.Size = new System.Drawing.Size(100, 20);
this.txt2.TabIndex = 19;
this.txt2.TextChanged += new System.EventHandler(this.txt1000_TextChanged);
//
// txt5
//
this.txt5.Location = new System.Drawing.Point(51, 196);
this.txt5.Name = "txt5";
this.txt5.Size = new System.Drawing.Size(100, 20);
this.txt5.TabIndex = 18;
this.txt5.TextChanged += new System.EventHandler(this.txt1000_TextChanged);
//
// txt10
//
this.txt10.Location = new System.Drawing.Point(51, 166);
this.txt10.Name = "txt10";
this.txt10.Size = new System.Drawing.Size(100, 20);
this.txt10.TabIndex = 17;
this.txt10.TextChanged += new System.EventHandler(this.txt1000_TextChanged);
//
// txt20
//
this.txt20.Location = new System.Drawing.Point(51, 136);
this.txt20.Name = "txt20";
this.txt20.Size = new System.Drawing.Size(100, 20);
this.txt20.TabIndex = 16;
this.txt20.TextChanged += new System.EventHandler(this.txt1000_TextChanged);
//
// txt50
//
this.txt50.Location = new System.Drawing.Point(51, 106);
this.txt50.Name = "txt50";
this.txt50.Size = new System.Drawing.Size(100, 20);
this.txt50.TabIndex = 15;
this.txt50.TextChanged += new System.EventHandler(this.txt1000_TextChanged);
//
// txt100
//
this.txt100.Location = new System.Drawing.Point(51, 76);
this.txt100.Name = "txt100";
this.txt100.Size = new System.Drawing.Size(100, 20);
this.txt100.TabIndex = 14;
this.txt100.TextChanged += new System.EventHandler(this.txt1000_TextChanged);
//
// txt500
//
this.txt500.Location = new System.Drawing.Point(51, 46);
this.txt500.Name = "txt500";
this.txt500.Size = new System.Drawing.Size(100, 20);
this.txt500.TabIndex = 13;
this.txt500.TextChanged += new System.EventHandler(this.txt1000_TextChanged);
//
// txt1000
//
this.txt1000.Location = new System.Drawing.Point(51, 16);
this.txt1000.Name = "txt1000";
this.txt1000.Size = new System.Drawing.Size(100, 20);
this.txt1000.TabIndex = 12;
this.txt1000.TextChanged += new System.EventHandler(this.txt1000_TextChanged);
//
// btnPrint
//
this.btnPrint.Location = new System.Drawing.Point(51, 317);
this.btnPrint.Name = "btnPrint";
this.btnPrint.Size = new System.Drawing.Size(100, 20);
this.btnPrint.TabIndex = 11;
this.btnPrint.Text = "Print";
this.btnPrint.UseVisualStyleBackColor = true;
this.btnPrint.Click += new System.EventHandler(this.btnPrint_Click);
//
// lblTotal
//
this.lblTotal.AutoSize = true;
this.lblTotal.Location = new System.Drawing.Point(13, 289);
this.lblTotal.Name = "lblTotal";
this.lblTotal.Size = new System.Drawing.Size(31, 13);
this.lblTotal.TabIndex = 10;
this.lblTotal.Text = "Total";
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(26, 262);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(18, 13);
this.label10.TabIndex = 9;
this.label10.Text = "1x";
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(25, 231);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(18, 13);
this.label9.TabIndex = 8;
this.label9.Text = "2x";
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(25, 201);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(18, 13);
this.label8.TabIndex = 7;
this.label8.Text = "5x";
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(19, 171);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(24, 13);
this.label7.TabIndex = 6;
this.label7.Text = "10x";
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(19, 141);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(24, 13);
this.label6.TabIndex = 5;
this.label6.Text = "20x";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(18, 112);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(24, 13);
this.label5.TabIndex = 4;
this.label5.Text = "50x";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(6, 93);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(0, 13);
this.label4.TabIndex = 3;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(14, 79);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(30, 13);
this.label3.TabIndex = 2;
this.label3.Text = "100x";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(15, 50);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(30, 13);
this.label2.TabIndex = 1;
this.label2.Text = "500x";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(9, 21);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(36, 13);
this.label1.TabIndex = 0;
this.label1.Text = "1000x";
//
// menuStrip1
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
@ -325,7 +84,6 @@
this.masterToolStripMenuItem.Name = "masterToolStripMenuItem";
this.masterToolStripMenuItem.Size = new System.Drawing.Size(55, 20);
this.masterToolStripMenuItem.Text = "Master";
this.masterToolStripMenuItem.Click += new System.EventHandler(this.masterToolStripMenuItem_Click);
//
// prToolStripMenuItem
//
@ -346,7 +104,6 @@
this.complexProductsToolStripMenuItem.Name = "complexProductsToolStripMenuItem";
this.complexProductsToolStripMenuItem.Size = new System.Drawing.Size(171, 22);
this.complexProductsToolStripMenuItem.Text = "Complex Products";
this.complexProductsToolStripMenuItem.Click += new System.EventHandler(this.complexProductsToolStripMenuItem_Click);
//
// customersToolStripMenuItem
//
@ -386,7 +143,6 @@
// transactionsToolStripMenuItem
//
this.transactionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.saleToolStripMenuItem,
this.advancesToolStripMenuItem,
this.paymentsToolStripMenuItem,
this.paymentsToolStripMenuItem1});
@ -394,13 +150,6 @@
this.transactionsToolStripMenuItem.Size = new System.Drawing.Size(86, 20);
this.transactionsToolStripMenuItem.Text = "Transactions";
//
// saleToolStripMenuItem
//
this.saleToolStripMenuItem.Name = "saleToolStripMenuItem";
this.saleToolStripMenuItem.Size = new System.Drawing.Size(170, 22);
this.saleToolStripMenuItem.Text = "Sale";
this.saleToolStripMenuItem.Click += new System.EventHandler(this.saleToolStripMenuItem_Click);
//
// advancesToolStripMenuItem
//
this.advancesToolStripMenuItem.Name = "advancesToolStripMenuItem";
@ -491,21 +240,39 @@
this.exitToolStripMenuItem.Text = "Exit";
this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
//
// btnLogin
//
this.btnLogin.Location = new System.Drawing.Point(12, 27);
this.btnLogin.Name = "btnLogin";
this.btnLogin.Size = new System.Drawing.Size(170, 85);
this.btnLogin.TabIndex = 27;
this.btnLogin.Text = "&Login";
this.btnLogin.UseVisualStyleBackColor = true;
this.btnLogin.Click += new System.EventHandler(this.btnLogin_Click);
//
// btnSale
//
this.btnSale.Location = new System.Drawing.Point(188, 27);
this.btnSale.Name = "btnSale";
this.btnSale.Size = new System.Drawing.Size(170, 85);
this.btnSale.TabIndex = 28;
this.btnSale.Text = "&Sale";
this.btnSale.UseVisualStyleBackColor = true;
this.btnSale.Click += new System.EventHandler(this.btnSale_Click);
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(792, 537);
this.Controls.Add(this.CashCalculator);
this.Controls.Add(this.btnSale);
this.Controls.Add(this.btnLogin);
this.Controls.Add(this.menuStrip1);
this.MainMenuStrip = this.menuStrip1;
this.Name = "MainForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "MainForm";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.Load += new System.EventHandler(this.MainForm_Load);
this.CashCalculator.ResumeLayout(false);
this.CashCalculator.PerformLayout();
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.ResumeLayout(false);
@ -515,35 +282,11 @@
#endregion
private System.Windows.Forms.GroupBox CashCalculator;
private System.Windows.Forms.Label lblTotal;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox txtTotal;
private System.Windows.Forms.TextBox txt1;
private System.Windows.Forms.TextBox txt2;
private System.Windows.Forms.TextBox txt5;
private System.Windows.Forms.TextBox txt10;
private System.Windows.Forms.TextBox txt20;
private System.Windows.Forms.TextBox txt50;
private System.Windows.Forms.TextBox txt100;
private System.Windows.Forms.TextBox txt500;
private System.Windows.Forms.TextBox txt1000;
private System.Windows.Forms.Button btnPrint;
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem masterToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem transactionsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem permissionsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem saleToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem advancesToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem paymentsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem createNewUserToolStripMenuItem;
@ -562,5 +305,7 @@
private System.Windows.Forms.ToolStripMenuItem autoToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem viewLogToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem updateBillsToolStripMenuItem;
private System.Windows.Forms.Button btnLogin;
private System.Windows.Forms.Button btnSale;
}
}

View File

@ -139,7 +139,7 @@ namespace Tanshu.Accounts.PointOfSale
private bool Save(bool addNew)
{
#region Setup Products
UserBO user = CurrentUser.user;
UserBO user = Session.User;
ProductBO product = new ProductBO();
if (!addNew)
product = new ProductBI().GetProduct(productList.ElementAt(bsProducts.Position).ProductID);

View File

@ -18,37 +18,9 @@ namespace Tanshu.Accounts.PointOfSale
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
string userName;
bool isAuthenticated;
using (LoginForm login = new LoginForm())
{
login.ShowDialog();
isAuthenticated = login.UserName(out userName);
}
if (isAuthenticated)
{
SetThreadPrincipal(userName);
Application.Run(new MainForm());
log.Warn(string.Format("User Logout: {0}", CurrentUser.user.Name));
}
else
{
log.Warn(string.Format("User Login Failed: '{0}'", userName));
}
}
static void SetThreadPrincipal(string userName)
{
log.Warn(string.Format("User Login: '{0}'", userName));
if (userName.Contains(":"))
userName = userName.Substring(userName.IndexOf(":") + 1);
AccountsPrincipal principal = AccountsPrincipal.CreateAccountsPrincipal(new Tanshu.Accounts.BI.MembershipBI().GetRolesForUser(userName),
new MembershipBI().GetUserFromName(userName));
// bind the generic principal to the thread
Thread.CurrentPrincipal = principal;
log.Warn("Application Started");
Application.Run(new MainForm());
log.Warn("Application Closed");
}
}
}

View File

@ -52,7 +52,7 @@ namespace Tanshu.Accounts.PointOfSale
private void btnAdjust_Click(object sender, EventArgs e)
{
new AdvanceBI().Adjust((Guid)txtNarration.Tag, CurrentUser.user.UserID);
new AdvanceBI().Adjust((Guid)txtNarration.Tag, Session.User.UserID);
FillDataGrid();
}
}

View File

@ -36,7 +36,7 @@ namespace Tanshu.Accounts.PointOfSale
private void cmbCashier_SelectedIndexChanged(object sender, EventArgs e)
{
EmployeeStatus();
log.Warn(string.Format("User Checkout: {0} by {1}", coProxy.Cashier, CurrentUser.user.Name));
log.Warn(string.Format("User Checkout: {0} by {1}", coProxy.Cashier, Session.User.Name));
}
private void EmployeeStatus()
@ -83,7 +83,7 @@ namespace Tanshu.Accounts.PointOfSale
private void btnPrint_Click(object sender, EventArgs e)
{
Thermal.PrintClosing(coProxy);
Thermal.PrintClosing(Session.printer(), coProxy);
}
private void txtSales_TextChanged(object sender, EventArgs e)

View File

@ -84,7 +84,7 @@ namespace Tanshu.Accounts.PointOfSale
{
if (customer == null)
customer = new CustomerBO();
UserBO user = CurrentUser.user;
UserBO user = Session.User;
customer.Name = txtName.Text;
customer.LedgerID = (Guid)cmbLedger.SelectedValue;
customer.Phone = txtPhone.Text;

View File

@ -17,7 +17,7 @@ namespace Tanshu.Accounts.PointOfSale
}
private void btnAdd_Click(object sender, EventArgs e)
{
UserBO user = CurrentUser.user;
UserBO user = Session.User;
if (txtAmount.Text == "0" || cmbType.Text == "")
{
System.Windows.Forms.MessageBox.Show("Amount can't be blank", "Blank not Allowed");
@ -37,7 +37,7 @@ namespace Tanshu.Accounts.PointOfSale
private void PaymentForm_Load(object sender, EventArgs e)
{
UserBO user = CurrentUser.user;
UserBO user = Session.User;
dtpFrom.Value = DateTime.Today;
dtpTo.Value = DateTime.Today;
GridBind();
@ -50,7 +50,7 @@ namespace Tanshu.Accounts.PointOfSale
MessageBox.Show("You are not authorized to access");
else
{
UserBO user = CurrentUser.user;
UserBO user = Session.User;
if (dgvPayments.SelectedRows.Count <= 0)
return;
Guid paymentID = ((PaymentDisplayBO)bindingSource.Current).PaymentID;
@ -65,7 +65,7 @@ namespace Tanshu.Accounts.PointOfSale
userID = null;
else
{
userID = CurrentUser.user.UserID;
userID = Session.User.UserID;
}
paymentList = new PaymentBI().GetPayments(userID, dtpFrom.Value, dtpTo.Value);
bindingSource.DataSource = paymentList;

View File

@ -39,8 +39,8 @@ namespace Tanshu.Accounts.PointOfSale
dtpTo.Format = DateTimePickerFormat.Custom;
dtpTo.CustomFormat = "dd-MMM-yyyy";
dtpTo.Value = DateTime.Now;
txtCashier.Text = CurrentUser.user.Name;
txtCashier.Tag = CurrentUser.user.UserID;
txtCashier.Text = Session.User.Name;
txtCashier.Tag = Session.User.UserID;
loading = false;
GridBind();
}
@ -58,7 +58,7 @@ namespace Tanshu.Accounts.PointOfSale
}
private void PrintAdvances()
{
Thermal.PrintAdvance(txtAmount.Text.Trim(), txtNarration.Text.Trim());
Thermal.PrintAdvance(Session.printer(), Session.User.Name, txtAmount.Text.Trim(), txtNarration.Text.Trim());
}
private string AddDate(string SqlStringP, DateTime FromDate, DateTime ToDate)
{

View File

@ -15,7 +15,7 @@ namespace Tanshu.Accounts.PointOfSale
public frmSaleAnalysisForm()
{
InitializeComponent();
log.Warn(string.Format("Sales Analysis by: {0}", CurrentUser.user.Name));
log.Warn(string.Format("Sales Analysis by: {0}", Session.User.Name));
}
private void dtpStart_ValueChanged(object sender, EventArgs e)
@ -91,7 +91,7 @@ namespace Tanshu.Accounts.PointOfSale
{
DateTime startDate = Convert.ToDateTime(String.Format("{0:dd-MMM-yyyy} 00:00:00", dtpStart.Value));
DateTime finishDate = Convert.ToDateTime(String.Format("{0:dd-MMM-yyyy} 23:59:59", dtpFinish.Value));
Accounts.Print.Thermal.PrintSale(det, startDate, finishDate);
Accounts.Print.Thermal.PrintSale(Session.printer(), Session.User.Name, det, startDate, finishDate);
}
}
}

View File

@ -29,8 +29,8 @@
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
this.bindingSource = new System.Windows.Forms.BindingSource(this.components);
this.bsWaiter = new System.Windows.Forms.BindingSource(this.components);
this.bsPending = new System.Windows.Forms.BindingSource(this.components);
@ -270,8 +270,8 @@
// printedDataGridViewTextBoxColumn
//
this.printedDataGridViewTextBoxColumn.DataPropertyName = "Printed";
dataGridViewCellStyle1.Format = "N2";
this.printedDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle1;
dataGridViewCellStyle3.Format = "N2";
this.printedDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle3;
this.printedDataGridViewTextBoxColumn.HeaderText = "Printed";
this.printedDataGridViewTextBoxColumn.Name = "printedDataGridViewTextBoxColumn";
this.printedDataGridViewTextBoxColumn.ReadOnly = true;
@ -280,9 +280,9 @@
// additionalDataGridViewTextBoxColumn
//
this.additionalDataGridViewTextBoxColumn.DataPropertyName = "Additional";
dataGridViewCellStyle2.Format = "N2";
dataGridViewCellStyle2.NullValue = null;
this.additionalDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle2;
dataGridViewCellStyle4.Format = "N2";
dataGridViewCellStyle4.NullValue = null;
this.additionalDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle4;
this.additionalDataGridViewTextBoxColumn.HeaderText = "Additional";
this.additionalDataGridViewTextBoxColumn.Name = "additionalDataGridViewTextBoxColumn";
this.additionalDataGridViewTextBoxColumn.ReadOnly = true;

View File

@ -33,7 +33,7 @@ namespace Tanshu.Accounts.PointOfSale
{
InitializeComponent();
btnCustomer.Text = customer.Name;
lblUser.Text = CurrentUser.user.Name;
lblUser.Text = Session.User.Name;
}
public SalesForm(Guid voucherID)
@ -369,7 +369,7 @@ namespace Tanshu.Accounts.PointOfSale
}
else
{
Accounts.Print.Thermal.PrintBill(true, voucherID, bill.Values.ToList());
Accounts.Print.Thermal.PrintBill(Session.printer(), true, voucherID, bill.Values.ToList());
Accounts.Print.Thermal.PrintCustomerKot("KOT", voucherID, bill.Values.ToList());
}
}
@ -386,7 +386,7 @@ namespace Tanshu.Accounts.PointOfSale
btnWaiter.Tag = new WaiterBI().GetWaiters()[0].WaiterID;
#region SaleVoucher
UserBO user = CurrentUser.user;
UserBO user = Session.User;
SaleVoucherBO saleVoucher = new SaleVoucherBO
{
CustomerID = customer.CustomerID,
@ -416,7 +416,7 @@ namespace Tanshu.Accounts.PointOfSale
if (btnWaiter.Tag == null)
btnWaiter.Tag = new WaiterBI().GetWaiters()[0].WaiterID;
UserBO user = CurrentUser.user;
UserBO user = Session.User;
#region Voucher and SaleVoucher
SaleVoucherBO saleVoucher = new SaleVoucherBO
{
@ -572,11 +572,11 @@ namespace Tanshu.Accounts.PointOfSale
if (seconds <= 0)
lblUser.Text = string.Format("Alarm {0:hh:MM}", al.AlarmTime);
else
lblUser.Text = CurrentUser.user.Name;
lblUser.Text = Session.User.Name;
}
else
{
lblUser.Text = CurrentUser.user.Name;
lblUser.Text = Session.User.Name;
}
}
}
@ -759,14 +759,14 @@ namespace Tanshu.Accounts.PointOfSale
private void btnPaidCash_Click(object sender, EventArgs e)
{
UserBO user = CurrentUser.user;
UserBO user = Session.User;
new SaleVoucherBI().DeclareBillsPaid(user.UserID, selectedBills, false);
ListUnpaidBills();
}
private void btnPaidCC_Click(object sender, EventArgs e)
{
UserBO user = CurrentUser.user;
UserBO user = Session.User;
new SaleVoucherBI().DeclareBillsPaid(user.UserID, selectedBills, true);
ListUnpaidBills();
}

View File

@ -132,6 +132,15 @@
<metadata name="Display.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Display.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="selectDataGridViewCheckBoxColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="TableID.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="selectDataGridViewCheckBoxColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>

View File

@ -83,6 +83,15 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Authentication\Session.cs" />
<Compile Include="Authentication\KeyboardLogin.cs" />
<Compile Include="Authentication\ILogin.cs" />
<Compile Include="CurrencyCounter.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="CurrencyCounter.Designer.cs">
<DependentUpon>CurrencyCounter.cs</DependentUpon>
</Compile>
<Compile Include="Sales\BillHelperFunctions.cs" />
<Compile Include="Sales\PaymentForm.cs">
<SubType>Form</SubType>
@ -145,10 +154,10 @@
<Compile Include="Sales\CustomersForm.Designer.cs">
<DependentUpon>CustomersForm.cs</DependentUpon>
</Compile>
<Compile Include="LoginForm.cs">
<Compile Include="Authentication\LoginForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="LoginForm.Designer.cs">
<Compile Include="Authentication\LoginForm.Designer.cs">
<DependentUpon>LoginForm.cs</DependentUpon>
</Compile>
<Compile Include="MainForm.cs">
@ -184,6 +193,9 @@
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="CurrencyCounter.resx">
<DependentUpon>CurrencyCounter.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Sales\PaymentForm.resx">
<DependentUpon>PaymentForm.cs</DependentUpon>
<SubType>Designer</SubType>
@ -224,7 +236,7 @@
<DependentUpon>CustomersForm.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="LoginForm.resx">
<EmbeddedResource Include="Authentication\LoginForm.resx">
<DependentUpon>LoginForm.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
@ -322,6 +334,10 @@
<Project>{90C9D02C-91AF-4529-86BE-28320332DDB5}</Project>
<Name>Tanshu.Accounts.Print</Name>
</ProjectReference>
<ProjectReference Include="..\Tanshu.Common.KeyboardControl\Tanshu.Common.KeyboardControl.csproj">
<Project>{4847FEE9-90E1-4795-A644-32867887A653}</Project>
<Name>Tanshu.Common.KeyboardControl</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@ -20,7 +20,7 @@ namespace Tanshu.Accounts.PointOfSale
private void btnGo_Click(object sender, EventArgs e)
{
if (!Thread.CurrentPrincipal.IsInRole("Security/CreateUser"))
if (!Thread.CurrentPrincipal.IsInRole("Master/Owner"))
return;
dtpFrom.Value = Convert.ToDateTime(string.Format("{0:dd-MMM-yyyy} 00:00:00", dtpFrom.Value));
dtpTo.Value = Convert.ToDateTime(string.Format("{0:dd-MMM-yyyy} 23:59:59", dtpTo.Value));

View File

@ -71,7 +71,7 @@ namespace Tanshu.Accounts.PointOfSale
{
DateTime startDate = Convert.ToDateTime(String.Format("{0:dd-MMM-yyyy} 00:00:00", dtpStart.Value));
DateTime finishDate = Convert.ToDateTime(String.Format("{0:dd-MMM-yyyy} 23:59:59", dtpFinish.Value));
Tanshu.Accounts.Print.Thermal.PrintSale(det, startDate, finishDate);
Tanshu.Accounts.Print.Thermal.PrintSale(Session.printer(), Session.User.Name, det, startDate, finishDate);
}
}
}

View File

@ -110,11 +110,11 @@ namespace Tanshu.Accounts.PointOfSale
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));
//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;
//// bind the generic principal to the thread
//Thread.CurrentPrincipal = principal;
}
}
}

View File

@ -15,7 +15,7 @@ namespace Tanshu.Accounts.PointOfSale
private void ChangePassword_Load(object sender, EventArgs e)
{
txtUsername.Text = CurrentUser.user.Name;
txtUsername.Text = Session.User.Name;
}
private void button2_Click(object sender, EventArgs e)

View File

@ -13,16 +13,26 @@ namespace Tanshu.Accounts.PointOfSale
{ }
public static RoleBI GetRoleBI(string roleID)
{
RoleBI roleBI = new RoleBI(roleID, CurrentUser.user.UserID);
if (!roleBI.IsAllowed)
{
using (LoginForm frm = new LoginForm())
{
frm.ShowDialog();
roleBI.Evelvate(frm.UserName);
}
}
RoleBI roleBI;
if (Session.User != null)
roleBI = new RoleBI(roleID, Session.User.UserID);
else
roleBI = new RoleBI(roleID, new Guid());
return roleBI;
//bool repeat = true;
//while (!roleBI.IsAllowed && repeat)
//{
// using (LoginForm frm = new LoginForm())
// {
// frm.ShowDialog();
// string userName;
// if (frm.Cancelled)
// repeat = false;
// else if (frm.UserName(out userName))
// roleBI.Evelvate(frm.UserName);
// }
//}
//return roleBI;
}
}
}