Feature: Log sql can be turned on or off from the Config file

This commit is contained in:
tanshu 2016-08-31 13:33:04 +05:30
parent 5e64209b76
commit 68388705f1
5 changed files with 185 additions and 195 deletions

View File

@ -4,18 +4,9 @@
<add name="Con" connectionString="Server=sovereign;Initial Catalog=Sales;User ID=sa;Password=123456" /> <add name="Con" connectionString="Server=sovereign;Initial Catalog=Sales;User ID=sa;Password=123456" />
</connectionStrings> </connectionStrings>
<appSettings> <appSettings>
<add key ="Location" value ="Office"/> <add key ="log-sql" value ="false"/>
<add key ="Factory" value ="SqlServer"/> <add key ="Factory" value ="SqlServer"/>
<add key ="LogConnection" value ="connection"/> <add key ="LogConnection" value ="connection"/>
<add key ="LogLevel" value ="Warn"/> <add key ="LogLevel" value ="Warn"/>
</appSettings> </appSettings>
<system.diagnostics>
<trace autoflush="true" indentsize="4">
<listeners>
<add name="myListener" type="System.Diagnostics.TextWriterTraceListener"
initializeData="TraceOutput.log" />
<remove name="Default" />
</listeners>
</trace>
</system.diagnostics>
</configuration> </configuration>

View File

@ -11,6 +11,8 @@ using Tanshu.Accounts.PointOfSale.Sales;
using Tanshu.Accounts.Repository; using Tanshu.Accounts.Repository;
using Tanshu.Common; using Tanshu.Common;
using Tanshu.Common.KeyboardControl; using Tanshu.Common.KeyboardControl;
using System.Configuration;
using System.Data.SqlClient;
namespace Tanshu.Accounts.PointOfSale namespace Tanshu.Accounts.PointOfSale
{ {
@ -18,11 +20,18 @@ namespace Tanshu.Accounts.PointOfSale
{ {
public MainForm() public MainForm()
{ {
SessionManager.Initialize();
//new SchemaExport(SessionManager.Configuration).Create(false, true); //new SchemaExport(SessionManager.Configuration).Create(false, true);
InitializeComponent(); InitializeComponent();
Text = "Point of Sale: Login (" + Environment.MachineName + ")"; Text = "Point of Sale: Login (" + Environment.MachineName + ")";
} }
private bool logSql
{
get
{
var settingValue = ConfigurationManager.AppSettings["log-sql"];
return settingValue == "true";
}
}
private void btnLogin_Click(object sender, EventArgs e) private void btnLogin_Click(object sender, EventArgs e)
{ {
@ -107,6 +116,16 @@ namespace Tanshu.Accounts.PointOfSale
private void MainForm_Load(object sender, EventArgs e) private void MainForm_Load(object sender, EventArgs e)
{ {
try
{
SessionManager.Initialize(logSql);
}
catch (SqlException)
{
MessageBox.Show("Unable to connect to the server.\nPlease check that the this computer and the server both are on and connected to the network.", "Server Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
throw;
}
#if (DEBUG) #if (DEBUG)
MessageBox.Show("This software does not print kots!!!", "Debug Mode", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); MessageBox.Show("This software does not print kots!!!", "Debug Mode", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
#endif #endif
@ -131,39 +150,39 @@ namespace Tanshu.Accounts.PointOfSale
private void CheckRoles() private void CheckRoles()
{ {
btnSale.Visible = Session.IsAllowed("Sales"); btnSale.Visible = Session.IsAllowed("Sales");
btnProduct.Visible = Session.IsAllowed("Products");
btnProductGroup.Visible = Session.IsAllowed("Products");
btnModifiers.Visible = Session.IsAllowed("Modifiers");
btnReorderTables.Visible = Session.IsAllowed("Tables");
btnMachines.Visible = Session.IsAllowed("Machines");
btnOpenBill.Visible = Session.IsAllowed("Open Bill");
btnCustomer.Visible = Session.IsAllowed("Customers"); btnCustomer.Visible = Session.IsAllowed("Customers");
btnUsers.Visible = Session.IsAllowed("Users"); btnOpenBill.Visible = Session.IsAllowed("Open Bill");
btnUserRoles.Visible = Session.IsAllowed("Users");
btnGroupRoles.Visible = Session.IsAllowed("Roles");
btnCashierCheckout.Visible = Session.IsAllowed("Cashier Checkout"); btnCashierCheckout.Visible = Session.IsAllowed("Cashier Checkout");
btnSaleAnalysis.Visible = Session.IsAllowed("Sales Analysis"); btnSaleAnalysis.Visible = Session.IsAllowed("Sales Analysis");
btnTaxAnalysis.Visible = Session.IsAllowed("Tax Analysis"); btnTaxAnalysis.Visible = Session.IsAllowed("Tax Analysis");
btnSaleDetail.Visible = Session.IsAllowed("Sales Detail"); btnSaleDetail.Visible = Session.IsAllowed("Sales Detail");
btnBillDetails.Visible = Session.IsAllowed("Bill Details"); btnBillDetails.Visible = Session.IsAllowed("Bill Details");
btnBeerConsumption.Visible = Session.IsAllowed("Beer Consumption"); btnBeerConsumption.Visible = Session.IsAllowed("Beer Consumption");
btnVoidOrReprints.Visible = Session.IsAllowed("Void or Reprinted Bill Report"); btnVoidOrReprints.Visible = Session.IsAllowed("Void or Reprinted Bill Report");
btnDiscountReport.Visible = Session.IsAllowed("Discount Report"); btnDiscountReport.Visible = Session.IsAllowed("Discount Report");
btnProduct.Visible = Session.IsAllowed("Products");
btnProductGroup.Visible = Session.IsAllowed("Products");
btnReorderTables.Visible = Session.IsAllowed("Tables");
btnMachines.Visible = Session.IsAllowed("Machines");
btnModifiers.Visible = Session.IsAllowed("Modifiers");
btnTaxes.Visible = Session.IsAllowed("Discount Report"); btnTaxes.Visible = Session.IsAllowed("Discount Report");
btnChangePassword.Visible = Session.IsAuthenticated; btnUsers.Visible = Session.IsAllowed("Users");
btnUserRoles.Visible = Session.IsAllowed("Users");
btnGroupRoles.Visible = Session.IsAllowed("Roles");
#if (DEBUG) #if (DEBUG)
btnManagement.Visible = true; btnManagement.Visible = true;
#else #else
btnManagement.Visible = false; btnManagement.Visible = false;
#endif #endif
btnChangePassword.Visible = Session.IsAuthenticated;
} }
private void btnGroupRoles_Click(object sender, EventArgs e) private void btnGroupRoles_Click(object sender, EventArgs e)

View File

@ -33,15 +33,7 @@
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.btnSwipeLogin = new System.Windows.Forms.Button(); this.btnSwipeLogin = new System.Windows.Forms.Button();
this.btnCustomer = new System.Windows.Forms.Button(); this.btnCustomer = new System.Windows.Forms.Button();
this.btnProduct = new System.Windows.Forms.Button();
this.btnProductGroup = new System.Windows.Forms.Button();
this.btnReorderTables = new System.Windows.Forms.Button();
this.btnMachines = new System.Windows.Forms.Button();
this.btnModifiers = new System.Windows.Forms.Button();
this.btnOpenBill = new System.Windows.Forms.Button(); this.btnOpenBill = new System.Windows.Forms.Button();
this.btnUsers = new System.Windows.Forms.Button();
this.btnUserRoles = new System.Windows.Forms.Button();
this.btnGroupRoles = new System.Windows.Forms.Button();
this.btnCashierCheckout = new System.Windows.Forms.Button(); this.btnCashierCheckout = new System.Windows.Forms.Button();
this.btnSaleAnalysis = new System.Windows.Forms.Button(); this.btnSaleAnalysis = new System.Windows.Forms.Button();
this.btnTaxAnalysis = new System.Windows.Forms.Button(); this.btnTaxAnalysis = new System.Windows.Forms.Button();
@ -50,9 +42,17 @@
this.btnBeerConsumption = new System.Windows.Forms.Button(); this.btnBeerConsumption = new System.Windows.Forms.Button();
this.btnVoidOrReprints = new System.Windows.Forms.Button(); this.btnVoidOrReprints = new System.Windows.Forms.Button();
this.btnDiscountReport = new System.Windows.Forms.Button(); this.btnDiscountReport = new System.Windows.Forms.Button();
this.btnChangePassword = new System.Windows.Forms.Button(); this.btnProduct = new System.Windows.Forms.Button();
this.btnManagement = new System.Windows.Forms.Button(); this.btnProductGroup = new System.Windows.Forms.Button();
this.btnReorderTables = new System.Windows.Forms.Button();
this.btnMachines = new System.Windows.Forms.Button();
this.btnModifiers = new System.Windows.Forms.Button();
this.btnTaxes = new System.Windows.Forms.Button(); this.btnTaxes = new System.Windows.Forms.Button();
this.btnUsers = new System.Windows.Forms.Button();
this.btnUserRoles = new System.Windows.Forms.Button();
this.btnGroupRoles = new System.Windows.Forms.Button();
this.btnManagement = new System.Windows.Forms.Button();
this.btnChangePassword = new System.Windows.Forms.Button();
this.btnExit = new System.Windows.Forms.Button(); this.btnExit = new System.Windows.Forms.Button();
this.flowLayoutPanel1.SuspendLayout(); this.flowLayoutPanel1.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
@ -83,15 +83,7 @@
this.flowLayoutPanel1.Controls.Add(this.btnSwipeLogin); this.flowLayoutPanel1.Controls.Add(this.btnSwipeLogin);
this.flowLayoutPanel1.Controls.Add(this.btnSale); this.flowLayoutPanel1.Controls.Add(this.btnSale);
this.flowLayoutPanel1.Controls.Add(this.btnCustomer); this.flowLayoutPanel1.Controls.Add(this.btnCustomer);
this.flowLayoutPanel1.Controls.Add(this.btnProduct);
this.flowLayoutPanel1.Controls.Add(this.btnProductGroup);
this.flowLayoutPanel1.Controls.Add(this.btnReorderTables);
this.flowLayoutPanel1.Controls.Add(this.btnMachines);
this.flowLayoutPanel1.Controls.Add(this.btnModifiers);
this.flowLayoutPanel1.Controls.Add(this.btnOpenBill); this.flowLayoutPanel1.Controls.Add(this.btnOpenBill);
this.flowLayoutPanel1.Controls.Add(this.btnUsers);
this.flowLayoutPanel1.Controls.Add(this.btnUserRoles);
this.flowLayoutPanel1.Controls.Add(this.btnGroupRoles);
this.flowLayoutPanel1.Controls.Add(this.btnCashierCheckout); this.flowLayoutPanel1.Controls.Add(this.btnCashierCheckout);
this.flowLayoutPanel1.Controls.Add(this.btnSaleAnalysis); this.flowLayoutPanel1.Controls.Add(this.btnSaleAnalysis);
this.flowLayoutPanel1.Controls.Add(this.btnTaxAnalysis); this.flowLayoutPanel1.Controls.Add(this.btnTaxAnalysis);
@ -100,9 +92,17 @@
this.flowLayoutPanel1.Controls.Add(this.btnBeerConsumption); this.flowLayoutPanel1.Controls.Add(this.btnBeerConsumption);
this.flowLayoutPanel1.Controls.Add(this.btnVoidOrReprints); this.flowLayoutPanel1.Controls.Add(this.btnVoidOrReprints);
this.flowLayoutPanel1.Controls.Add(this.btnDiscountReport); this.flowLayoutPanel1.Controls.Add(this.btnDiscountReport);
this.flowLayoutPanel1.Controls.Add(this.btnChangePassword); this.flowLayoutPanel1.Controls.Add(this.btnProduct);
this.flowLayoutPanel1.Controls.Add(this.btnManagement); this.flowLayoutPanel1.Controls.Add(this.btnProductGroup);
this.flowLayoutPanel1.Controls.Add(this.btnReorderTables);
this.flowLayoutPanel1.Controls.Add(this.btnMachines);
this.flowLayoutPanel1.Controls.Add(this.btnModifiers);
this.flowLayoutPanel1.Controls.Add(this.btnTaxes); this.flowLayoutPanel1.Controls.Add(this.btnTaxes);
this.flowLayoutPanel1.Controls.Add(this.btnUsers);
this.flowLayoutPanel1.Controls.Add(this.btnUserRoles);
this.flowLayoutPanel1.Controls.Add(this.btnGroupRoles);
this.flowLayoutPanel1.Controls.Add(this.btnManagement);
this.flowLayoutPanel1.Controls.Add(this.btnChangePassword);
this.flowLayoutPanel1.Controls.Add(this.btnExit); this.flowLayoutPanel1.Controls.Add(this.btnExit);
this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 0); this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 0);
@ -130,185 +130,185 @@
this.btnCustomer.UseVisualStyleBackColor = true; this.btnCustomer.UseVisualStyleBackColor = true;
this.btnCustomer.Click += new System.EventHandler(this.btnCustomer_Click); this.btnCustomer.Click += new System.EventHandler(this.btnCustomer_Click);
// //
// btnProduct
//
this.btnProduct.Location = new System.Drawing.Point(627, 3);
this.btnProduct.Name = "btnProduct";
this.btnProduct.Size = new System.Drawing.Size(150, 100);
this.btnProduct.TabIndex = 4;
this.btnProduct.Text = "Products";
this.btnProduct.UseVisualStyleBackColor = true;
this.btnProduct.Click += new System.EventHandler(this.btnProduct_Click);
//
// btnProductGroup
//
this.btnProductGroup.Location = new System.Drawing.Point(3, 109);
this.btnProductGroup.Name = "btnProductGroup";
this.btnProductGroup.Size = new System.Drawing.Size(150, 100);
this.btnProductGroup.TabIndex = 5;
this.btnProductGroup.Text = "Product Groups";
this.btnProductGroup.UseVisualStyleBackColor = true;
this.btnProductGroup.Click += new System.EventHandler(this.btnProductGroup_Click);
//
// btnReorderTables
//
this.btnReorderTables.Location = new System.Drawing.Point(159, 109);
this.btnReorderTables.Name = "btnReorderTables";
this.btnReorderTables.Size = new System.Drawing.Size(150, 100);
this.btnReorderTables.TabIndex = 6;
this.btnReorderTables.Text = "Reorder Tables";
this.btnReorderTables.UseVisualStyleBackColor = true;
this.btnReorderTables.Click += new System.EventHandler(this.btnReorderTables_Click);
//
// btnMachines
//
this.btnMachines.Location = new System.Drawing.Point(315, 109);
this.btnMachines.Name = "btnMachines";
this.btnMachines.Size = new System.Drawing.Size(150, 100);
this.btnMachines.TabIndex = 7;
this.btnMachines.Text = "Manage Machines";
this.btnMachines.UseVisualStyleBackColor = true;
this.btnMachines.Click += new System.EventHandler(this.btnMachines_Click);
//
// btnModifiers
//
this.btnModifiers.Location = new System.Drawing.Point(471, 109);
this.btnModifiers.Name = "btnModifiers";
this.btnModifiers.Size = new System.Drawing.Size(150, 100);
this.btnModifiers.TabIndex = 8;
this.btnModifiers.Text = "Product Modifiers";
this.btnModifiers.UseVisualStyleBackColor = true;
this.btnModifiers.Click += new System.EventHandler(this.btnModifiers_Click);
//
// btnOpenBill // btnOpenBill
// //
this.btnOpenBill.Location = new System.Drawing.Point(627, 109); this.btnOpenBill.Location = new System.Drawing.Point(627, 3);
this.btnOpenBill.Name = "btnOpenBill"; this.btnOpenBill.Name = "btnOpenBill";
this.btnOpenBill.Size = new System.Drawing.Size(150, 100); this.btnOpenBill.Size = new System.Drawing.Size(150, 100);
this.btnOpenBill.TabIndex = 9; this.btnOpenBill.TabIndex = 4;
this.btnOpenBill.Text = "Open Bill"; this.btnOpenBill.Text = "Open Bill";
this.btnOpenBill.UseVisualStyleBackColor = true; this.btnOpenBill.UseVisualStyleBackColor = true;
this.btnOpenBill.Click += new System.EventHandler(this.btnOpenBill_Click); this.btnOpenBill.Click += new System.EventHandler(this.btnOpenBill_Click);
// //
// btnUsers
//
this.btnUsers.Location = new System.Drawing.Point(3, 215);
this.btnUsers.Name = "btnUsers";
this.btnUsers.Size = new System.Drawing.Size(150, 100);
this.btnUsers.TabIndex = 10;
this.btnUsers.Text = "Users";
this.btnUsers.UseVisualStyleBackColor = true;
this.btnUsers.Click += new System.EventHandler(this.btnUsers_Click);
//
// btnUserRoles
//
this.btnUserRoles.Location = new System.Drawing.Point(159, 215);
this.btnUserRoles.Name = "btnUserRoles";
this.btnUserRoles.Size = new System.Drawing.Size(150, 100);
this.btnUserRoles.TabIndex = 11;
this.btnUserRoles.Text = "Manage User Roles";
this.btnUserRoles.UseVisualStyleBackColor = true;
this.btnUserRoles.Click += new System.EventHandler(this.btnUserRoles_Click);
//
// btnGroupRoles
//
this.btnGroupRoles.Location = new System.Drawing.Point(315, 215);
this.btnGroupRoles.Name = "btnGroupRoles";
this.btnGroupRoles.Size = new System.Drawing.Size(150, 100);
this.btnGroupRoles.TabIndex = 12;
this.btnGroupRoles.Text = "Manage Group Roles";
this.btnGroupRoles.UseVisualStyleBackColor = true;
this.btnGroupRoles.Click += new System.EventHandler(this.btnGroupRoles_Click);
//
// btnCashierCheckout // btnCashierCheckout
// //
this.btnCashierCheckout.Location = new System.Drawing.Point(471, 215); this.btnCashierCheckout.Location = new System.Drawing.Point(3, 109);
this.btnCashierCheckout.Name = "btnCashierCheckout"; this.btnCashierCheckout.Name = "btnCashierCheckout";
this.btnCashierCheckout.Size = new System.Drawing.Size(150, 100); this.btnCashierCheckout.Size = new System.Drawing.Size(150, 100);
this.btnCashierCheckout.TabIndex = 13; this.btnCashierCheckout.TabIndex = 5;
this.btnCashierCheckout.Text = "Cashier Checkout"; this.btnCashierCheckout.Text = "Cashier Checkout";
this.btnCashierCheckout.UseVisualStyleBackColor = true; this.btnCashierCheckout.UseVisualStyleBackColor = true;
this.btnCashierCheckout.Click += new System.EventHandler(this.btnCashierCheckout_Click); this.btnCashierCheckout.Click += new System.EventHandler(this.btnCashierCheckout_Click);
// //
// btnSaleAnalysis // btnSaleAnalysis
// //
this.btnSaleAnalysis.Location = new System.Drawing.Point(627, 215); this.btnSaleAnalysis.Location = new System.Drawing.Point(159, 109);
this.btnSaleAnalysis.Name = "btnSaleAnalysis"; this.btnSaleAnalysis.Name = "btnSaleAnalysis";
this.btnSaleAnalysis.Size = new System.Drawing.Size(150, 100); this.btnSaleAnalysis.Size = new System.Drawing.Size(150, 100);
this.btnSaleAnalysis.TabIndex = 14; this.btnSaleAnalysis.TabIndex = 6;
this.btnSaleAnalysis.Text = "Sale Analysis"; this.btnSaleAnalysis.Text = "Sale Analysis";
this.btnSaleAnalysis.UseVisualStyleBackColor = true; this.btnSaleAnalysis.UseVisualStyleBackColor = true;
this.btnSaleAnalysis.Click += new System.EventHandler(this.btnSaleAnalysis_Click); this.btnSaleAnalysis.Click += new System.EventHandler(this.btnSaleAnalysis_Click);
// //
// btnTaxAnalysis // btnTaxAnalysis
// //
this.btnTaxAnalysis.Location = new System.Drawing.Point(3, 321); this.btnTaxAnalysis.Location = new System.Drawing.Point(315, 109);
this.btnTaxAnalysis.Name = "btnTaxAnalysis"; this.btnTaxAnalysis.Name = "btnTaxAnalysis";
this.btnTaxAnalysis.Size = new System.Drawing.Size(150, 100); this.btnTaxAnalysis.Size = new System.Drawing.Size(150, 100);
this.btnTaxAnalysis.TabIndex = 15; this.btnTaxAnalysis.TabIndex = 7;
this.btnTaxAnalysis.Text = "Tax Analysis"; this.btnTaxAnalysis.Text = "Tax Analysis";
this.btnTaxAnalysis.UseVisualStyleBackColor = true; this.btnTaxAnalysis.UseVisualStyleBackColor = true;
this.btnTaxAnalysis.Click += new System.EventHandler(this.btnTaxAnalysis_Click); this.btnTaxAnalysis.Click += new System.EventHandler(this.btnTaxAnalysis_Click);
// //
// btnSaleDetail // btnSaleDetail
// //
this.btnSaleDetail.Location = new System.Drawing.Point(159, 321); this.btnSaleDetail.Location = new System.Drawing.Point(471, 109);
this.btnSaleDetail.Name = "btnSaleDetail"; this.btnSaleDetail.Name = "btnSaleDetail";
this.btnSaleDetail.Size = new System.Drawing.Size(150, 100); this.btnSaleDetail.Size = new System.Drawing.Size(150, 100);
this.btnSaleDetail.TabIndex = 16; this.btnSaleDetail.TabIndex = 8;
this.btnSaleDetail.Text = "Sale Detail"; this.btnSaleDetail.Text = "Sale Detail";
this.btnSaleDetail.UseVisualStyleBackColor = true; this.btnSaleDetail.UseVisualStyleBackColor = true;
this.btnSaleDetail.Click += new System.EventHandler(this.btnSaleDetail_Click); this.btnSaleDetail.Click += new System.EventHandler(this.btnSaleDetail_Click);
// //
// btnBillDetails // btnBillDetails
// //
this.btnBillDetails.Location = new System.Drawing.Point(315, 321); this.btnBillDetails.Location = new System.Drawing.Point(627, 109);
this.btnBillDetails.Name = "btnBillDetails"; this.btnBillDetails.Name = "btnBillDetails";
this.btnBillDetails.Size = new System.Drawing.Size(150, 100); this.btnBillDetails.Size = new System.Drawing.Size(150, 100);
this.btnBillDetails.TabIndex = 17; this.btnBillDetails.TabIndex = 9;
this.btnBillDetails.Text = "Bill Details"; this.btnBillDetails.Text = "Bill Details";
this.btnBillDetails.UseVisualStyleBackColor = true; this.btnBillDetails.UseVisualStyleBackColor = true;
this.btnBillDetails.Click += new System.EventHandler(this.btnBillDetails_Click); this.btnBillDetails.Click += new System.EventHandler(this.btnBillDetails_Click);
// //
// btnBeerConsumption // btnBeerConsumption
// //
this.btnBeerConsumption.Location = new System.Drawing.Point(471, 321); this.btnBeerConsumption.Location = new System.Drawing.Point(3, 215);
this.btnBeerConsumption.Name = "btnBeerConsumption"; this.btnBeerConsumption.Name = "btnBeerConsumption";
this.btnBeerConsumption.Size = new System.Drawing.Size(150, 100); this.btnBeerConsumption.Size = new System.Drawing.Size(150, 100);
this.btnBeerConsumption.TabIndex = 18; this.btnBeerConsumption.TabIndex = 10;
this.btnBeerConsumption.Text = "Beer Consumption"; this.btnBeerConsumption.Text = "Beer Consumption";
this.btnBeerConsumption.UseVisualStyleBackColor = true; this.btnBeerConsumption.UseVisualStyleBackColor = true;
this.btnBeerConsumption.Click += new System.EventHandler(this.btnBeerConsumption_Click); this.btnBeerConsumption.Click += new System.EventHandler(this.btnBeerConsumption_Click);
// //
// btnVoidOrReprints // btnVoidOrReprints
// //
this.btnVoidOrReprints.Location = new System.Drawing.Point(627, 321); this.btnVoidOrReprints.Location = new System.Drawing.Point(159, 215);
this.btnVoidOrReprints.Name = "btnVoidOrReprints"; this.btnVoidOrReprints.Name = "btnVoidOrReprints";
this.btnVoidOrReprints.Size = new System.Drawing.Size(150, 100); this.btnVoidOrReprints.Size = new System.Drawing.Size(150, 100);
this.btnVoidOrReprints.TabIndex = 19; this.btnVoidOrReprints.TabIndex = 11;
this.btnVoidOrReprints.Text = "Voids or Reprints"; this.btnVoidOrReprints.Text = "Voids or Reprints";
this.btnVoidOrReprints.UseVisualStyleBackColor = true; this.btnVoidOrReprints.UseVisualStyleBackColor = true;
this.btnVoidOrReprints.Click += new System.EventHandler(this.btnVoidOrReprints_Click); this.btnVoidOrReprints.Click += new System.EventHandler(this.btnVoidOrReprints_Click);
// //
// btnDiscountReport // btnDiscountReport
// //
this.btnDiscountReport.Location = new System.Drawing.Point(3, 427); this.btnDiscountReport.Location = new System.Drawing.Point(315, 215);
this.btnDiscountReport.Name = "btnDiscountReport"; this.btnDiscountReport.Name = "btnDiscountReport";
this.btnDiscountReport.Size = new System.Drawing.Size(150, 100); this.btnDiscountReport.Size = new System.Drawing.Size(150, 100);
this.btnDiscountReport.TabIndex = 20; this.btnDiscountReport.TabIndex = 12;
this.btnDiscountReport.Text = "Discount Report"; this.btnDiscountReport.Text = "Discount Report";
this.btnDiscountReport.UseVisualStyleBackColor = true; this.btnDiscountReport.UseVisualStyleBackColor = true;
this.btnDiscountReport.Click += new System.EventHandler(this.btnDiscountReport_Click); this.btnDiscountReport.Click += new System.EventHandler(this.btnDiscountReport_Click);
// //
// btnChangePassword // btnProduct
// //
this.btnChangePassword.Location = new System.Drawing.Point(159, 427); this.btnProduct.Location = new System.Drawing.Point(471, 215);
this.btnChangePassword.Name = "btnChangePassword"; this.btnProduct.Name = "btnProduct";
this.btnChangePassword.Size = new System.Drawing.Size(150, 100); this.btnProduct.Size = new System.Drawing.Size(150, 100);
this.btnChangePassword.TabIndex = 21; this.btnProduct.TabIndex = 13;
this.btnChangePassword.Text = "Change Password"; this.btnProduct.Text = "Products";
this.btnChangePassword.UseVisualStyleBackColor = true; this.btnProduct.UseVisualStyleBackColor = true;
this.btnChangePassword.Click += new System.EventHandler(this.btnChangePassword_Click); this.btnProduct.Click += new System.EventHandler(this.btnProduct_Click);
//
// btnProductGroup
//
this.btnProductGroup.Location = new System.Drawing.Point(627, 215);
this.btnProductGroup.Name = "btnProductGroup";
this.btnProductGroup.Size = new System.Drawing.Size(150, 100);
this.btnProductGroup.TabIndex = 14;
this.btnProductGroup.Text = "Product Groups";
this.btnProductGroup.UseVisualStyleBackColor = true;
this.btnProductGroup.Click += new System.EventHandler(this.btnProductGroup_Click);
//
// btnReorderTables
//
this.btnReorderTables.Location = new System.Drawing.Point(3, 321);
this.btnReorderTables.Name = "btnReorderTables";
this.btnReorderTables.Size = new System.Drawing.Size(150, 100);
this.btnReorderTables.TabIndex = 15;
this.btnReorderTables.Text = "Reorder Tables";
this.btnReorderTables.UseVisualStyleBackColor = true;
this.btnReorderTables.Click += new System.EventHandler(this.btnReorderTables_Click);
//
// btnMachines
//
this.btnMachines.Location = new System.Drawing.Point(159, 321);
this.btnMachines.Name = "btnMachines";
this.btnMachines.Size = new System.Drawing.Size(150, 100);
this.btnMachines.TabIndex = 16;
this.btnMachines.Text = "Manage Machines";
this.btnMachines.UseVisualStyleBackColor = true;
this.btnMachines.Click += new System.EventHandler(this.btnMachines_Click);
//
// btnModifiers
//
this.btnModifiers.Location = new System.Drawing.Point(315, 321);
this.btnModifiers.Name = "btnModifiers";
this.btnModifiers.Size = new System.Drawing.Size(150, 100);
this.btnModifiers.TabIndex = 17;
this.btnModifiers.Text = "Product Modifiers";
this.btnModifiers.UseVisualStyleBackColor = true;
this.btnModifiers.Click += new System.EventHandler(this.btnModifiers_Click);
//
// btnTaxes
//
this.btnTaxes.Location = new System.Drawing.Point(471, 321);
this.btnTaxes.Name = "btnTaxes";
this.btnTaxes.Size = new System.Drawing.Size(150, 100);
this.btnTaxes.TabIndex = 18;
this.btnTaxes.Text = "Taxes";
this.btnTaxes.UseVisualStyleBackColor = true;
this.btnTaxes.Click += new System.EventHandler(this.btnTaxes_Click);
//
// btnUsers
//
this.btnUsers.Location = new System.Drawing.Point(627, 321);
this.btnUsers.Name = "btnUsers";
this.btnUsers.Size = new System.Drawing.Size(150, 100);
this.btnUsers.TabIndex = 19;
this.btnUsers.Text = "Users";
this.btnUsers.UseVisualStyleBackColor = true;
this.btnUsers.Click += new System.EventHandler(this.btnUsers_Click);
//
// btnUserRoles
//
this.btnUserRoles.Location = new System.Drawing.Point(3, 427);
this.btnUserRoles.Name = "btnUserRoles";
this.btnUserRoles.Size = new System.Drawing.Size(150, 100);
this.btnUserRoles.TabIndex = 20;
this.btnUserRoles.Text = "Manage User Roles";
this.btnUserRoles.UseVisualStyleBackColor = true;
this.btnUserRoles.Click += new System.EventHandler(this.btnUserRoles_Click);
//
// btnGroupRoles
//
this.btnGroupRoles.Location = new System.Drawing.Point(159, 427);
this.btnGroupRoles.Name = "btnGroupRoles";
this.btnGroupRoles.Size = new System.Drawing.Size(150, 100);
this.btnGroupRoles.TabIndex = 21;
this.btnGroupRoles.Text = "Manage Group Roles";
this.btnGroupRoles.UseVisualStyleBackColor = true;
this.btnGroupRoles.Click += new System.EventHandler(this.btnGroupRoles_Click);
// //
// btnManagement // btnManagement
// //
@ -320,15 +320,15 @@
this.btnManagement.UseVisualStyleBackColor = true; this.btnManagement.UseVisualStyleBackColor = true;
this.btnManagement.Click += new System.EventHandler(this.btnManagement_Click); this.btnManagement.Click += new System.EventHandler(this.btnManagement_Click);
// //
// btnTaxes // btnChangePassword
// //
this.btnTaxes.Location = new System.Drawing.Point(471, 427); this.btnChangePassword.Location = new System.Drawing.Point(471, 427);
this.btnTaxes.Name = "btnTaxes"; this.btnChangePassword.Name = "btnChangePassword";
this.btnTaxes.Size = new System.Drawing.Size(150, 100); this.btnChangePassword.Size = new System.Drawing.Size(150, 100);
this.btnTaxes.TabIndex = 23; this.btnChangePassword.TabIndex = 23;
this.btnTaxes.Text = "Taxes"; this.btnChangePassword.Text = "Change Password";
this.btnTaxes.UseVisualStyleBackColor = true; this.btnChangePassword.UseVisualStyleBackColor = true;
this.btnTaxes.Click += new System.EventHandler(this.btnTaxes_Click); this.btnChangePassword.Click += new System.EventHandler(this.btnChangePassword_Click);
// //
// btnExit // btnExit
// //

View File

@ -11,16 +11,12 @@ namespace Tanshu.Accounts.PointOfSale
{ {
static class Program static class Program
{ {
//private static readonly Tanshu.Logging.SqlLogger log = new Tanshu.Logging.SqlLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
[STAThread] [STAThread]
static void Main() static void Main()
{ {
Application.EnableVisualStyles(); Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false); Application.SetCompatibleTextRenderingDefault(false);
//log.Warn("Application Started");
Application.Run(new MainForm()); Application.Run(new MainForm());
//log.Warn("Application Closed");
} }
} }
} }

View File

@ -17,17 +17,17 @@ namespace Tanshu.Accounts.Repository
private readonly ISessionFactory factory; private readonly ISessionFactory factory;
private static SessionManager instance; private static SessionManager instance;
private SessionManager() private SessionManager(bool forTesting)
{ {
cfg = ConfigureNHibernate(); cfg = ConfigureNHibernate(forTesting);
factory = cfg.BuildSessionFactory(); factory = cfg.BuildSessionFactory();
} }
public static void Initialize() public static void Initialize(bool forTesting)
{ {
if (instance == null) if (instance == null)
{ {
instance = new SessionManager(); instance = new SessionManager(forTesting);
} }
} }
public static ISession Session public static ISession Session
@ -35,9 +35,7 @@ namespace Tanshu.Accounts.Repository
get get
{ {
if (instance == null) if (instance == null)
{ throw new ApplicationException("Session factory not initalized. Cannot get Session");
instance = new SessionManager();
}
return instance.GetSession(); return instance.GetSession();
} }
} }
@ -46,29 +44,11 @@ namespace Tanshu.Accounts.Repository
get get
{ {
if (instance == null) if (instance == null)
{ throw new ApplicationException("Session factory not initalized. Cannot get Session");
instance = new SessionManager();
}
return instance.GetStatelessSession(); return instance.GetStatelessSession();
} }
} }
public static Configuration Configuration private Configuration ConfigureNHibernate(bool forTesting)
{
get
{
if (instance == null)
{
instance = new SessionManager();
}
return instance.GetConfiguration();
}
}
private Configuration GetConfiguration()
{
return cfg;
}
private Configuration ConfigureNHibernate()
{ {
var configure = new Configuration(); var configure = new Configuration();
configure.SessionFactoryName("BuildIt"); configure.SessionFactoryName("BuildIt");
@ -81,10 +61,14 @@ namespace Tanshu.Accounts.Repository
db.IsolationLevel = IsolationLevel.ReadCommitted; db.IsolationLevel = IsolationLevel.ReadCommitted;
db.ConnectionStringName = "Con"; db.ConnectionStringName = "Con";
db.Timeout = 10; db.Timeout = 10;
// enabled for testing
//db.LogFormattedSql = true; if (forTesting)
//db.LogSqlInConsole = true; {
//db.AutoCommentSql = true; // enabled for testing
db.LogFormattedSql = true;
db.LogSqlInConsole = true;
db.AutoCommentSql = true;
}
}); });
var mapping = GetMappings(); var mapping = GetMappings();