diff --git a/Tanshu.Accounts.PointOfSale/App.config b/Tanshu.Accounts.PointOfSale/App.config index a704c9a..8504181 100644 --- a/Tanshu.Accounts.PointOfSale/App.config +++ b/Tanshu.Accounts.PointOfSale/App.config @@ -4,18 +4,9 @@ - + - - - - - - - - \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/MainForm.cs b/Tanshu.Accounts.PointOfSale/MainForm.cs index dc73852..d44db04 100644 --- a/Tanshu.Accounts.PointOfSale/MainForm.cs +++ b/Tanshu.Accounts.PointOfSale/MainForm.cs @@ -11,6 +11,8 @@ using Tanshu.Accounts.PointOfSale.Sales; using Tanshu.Accounts.Repository; using Tanshu.Common; using Tanshu.Common.KeyboardControl; +using System.Configuration; +using System.Data.SqlClient; namespace Tanshu.Accounts.PointOfSale { @@ -18,11 +20,18 @@ namespace Tanshu.Accounts.PointOfSale { public MainForm() { - SessionManager.Initialize(); //new SchemaExport(SessionManager.Configuration).Create(false, true); InitializeComponent(); 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) { @@ -107,6 +116,16 @@ namespace Tanshu.Accounts.PointOfSale 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) MessageBox.Show("This software does not print kots!!!", "Debug Mode", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); #endif @@ -131,39 +150,39 @@ namespace Tanshu.Accounts.PointOfSale private void CheckRoles() { 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"); - btnUsers.Visible = Session.IsAllowed("Users"); - btnUserRoles.Visible = Session.IsAllowed("Users"); - - btnGroupRoles.Visible = Session.IsAllowed("Roles"); + btnOpenBill.Visible = Session.IsAllowed("Open Bill"); btnCashierCheckout.Visible = Session.IsAllowed("Cashier Checkout"); btnSaleAnalysis.Visible = Session.IsAllowed("Sales Analysis"); btnTaxAnalysis.Visible = Session.IsAllowed("Tax Analysis"); btnSaleDetail.Visible = Session.IsAllowed("Sales Detail"); - btnBillDetails.Visible = Session.IsAllowed("Bill Details"); btnBeerConsumption.Visible = Session.IsAllowed("Beer Consumption"); btnVoidOrReprints.Visible = Session.IsAllowed("Void or Reprinted Bill 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"); - btnChangePassword.Visible = Session.IsAuthenticated; + btnUsers.Visible = Session.IsAllowed("Users"); + btnUserRoles.Visible = Session.IsAllowed("Users"); + btnGroupRoles.Visible = Session.IsAllowed("Roles"); + #if (DEBUG) btnManagement.Visible = true; #else btnManagement.Visible = false; #endif + + btnChangePassword.Visible = Session.IsAuthenticated; } private void btnGroupRoles_Click(object sender, EventArgs e) diff --git a/Tanshu.Accounts.PointOfSale/MainForm.designer.cs b/Tanshu.Accounts.PointOfSale/MainForm.designer.cs index d38f0ac..8a7ce05 100644 --- a/Tanshu.Accounts.PointOfSale/MainForm.designer.cs +++ b/Tanshu.Accounts.PointOfSale/MainForm.designer.cs @@ -33,15 +33,7 @@ this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); this.btnSwipeLogin = 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.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.btnSaleAnalysis = new System.Windows.Forms.Button(); this.btnTaxAnalysis = new System.Windows.Forms.Button(); @@ -50,9 +42,17 @@ this.btnBeerConsumption = new System.Windows.Forms.Button(); this.btnVoidOrReprints = new System.Windows.Forms.Button(); this.btnDiscountReport = new System.Windows.Forms.Button(); - this.btnChangePassword = new System.Windows.Forms.Button(); - this.btnManagement = 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.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.flowLayoutPanel1.SuspendLayout(); this.SuspendLayout(); @@ -83,15 +83,7 @@ this.flowLayoutPanel1.Controls.Add(this.btnSwipeLogin); this.flowLayoutPanel1.Controls.Add(this.btnSale); 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.btnUsers); - this.flowLayoutPanel1.Controls.Add(this.btnUserRoles); - this.flowLayoutPanel1.Controls.Add(this.btnGroupRoles); this.flowLayoutPanel1.Controls.Add(this.btnCashierCheckout); this.flowLayoutPanel1.Controls.Add(this.btnSaleAnalysis); this.flowLayoutPanel1.Controls.Add(this.btnTaxAnalysis); @@ -100,9 +92,17 @@ this.flowLayoutPanel1.Controls.Add(this.btnBeerConsumption); this.flowLayoutPanel1.Controls.Add(this.btnVoidOrReprints); this.flowLayoutPanel1.Controls.Add(this.btnDiscountReport); - this.flowLayoutPanel1.Controls.Add(this.btnChangePassword); - this.flowLayoutPanel1.Controls.Add(this.btnManagement); + 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.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.Dock = System.Windows.Forms.DockStyle.Fill; this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 0); @@ -130,185 +130,185 @@ this.btnCustomer.UseVisualStyleBackColor = true; 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 // - this.btnOpenBill.Location = new System.Drawing.Point(627, 109); + this.btnOpenBill.Location = new System.Drawing.Point(627, 3); this.btnOpenBill.Name = "btnOpenBill"; this.btnOpenBill.Size = new System.Drawing.Size(150, 100); - this.btnOpenBill.TabIndex = 9; + this.btnOpenBill.TabIndex = 4; this.btnOpenBill.Text = "Open Bill"; this.btnOpenBill.UseVisualStyleBackColor = true; 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 // - this.btnCashierCheckout.Location = new System.Drawing.Point(471, 215); + this.btnCashierCheckout.Location = new System.Drawing.Point(3, 109); this.btnCashierCheckout.Name = "btnCashierCheckout"; this.btnCashierCheckout.Size = new System.Drawing.Size(150, 100); - this.btnCashierCheckout.TabIndex = 13; + this.btnCashierCheckout.TabIndex = 5; this.btnCashierCheckout.Text = "Cashier Checkout"; this.btnCashierCheckout.UseVisualStyleBackColor = true; this.btnCashierCheckout.Click += new System.EventHandler(this.btnCashierCheckout_Click); // // 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.Size = new System.Drawing.Size(150, 100); - this.btnSaleAnalysis.TabIndex = 14; + this.btnSaleAnalysis.TabIndex = 6; this.btnSaleAnalysis.Text = "Sale Analysis"; this.btnSaleAnalysis.UseVisualStyleBackColor = true; this.btnSaleAnalysis.Click += new System.EventHandler(this.btnSaleAnalysis_Click); // // 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.Size = new System.Drawing.Size(150, 100); - this.btnTaxAnalysis.TabIndex = 15; + this.btnTaxAnalysis.TabIndex = 7; this.btnTaxAnalysis.Text = "Tax Analysis"; this.btnTaxAnalysis.UseVisualStyleBackColor = true; this.btnTaxAnalysis.Click += new System.EventHandler(this.btnTaxAnalysis_Click); // // 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.Size = new System.Drawing.Size(150, 100); - this.btnSaleDetail.TabIndex = 16; + this.btnSaleDetail.TabIndex = 8; this.btnSaleDetail.Text = "Sale Detail"; this.btnSaleDetail.UseVisualStyleBackColor = true; this.btnSaleDetail.Click += new System.EventHandler(this.btnSaleDetail_Click); // // 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.Size = new System.Drawing.Size(150, 100); - this.btnBillDetails.TabIndex = 17; + this.btnBillDetails.TabIndex = 9; this.btnBillDetails.Text = "Bill Details"; this.btnBillDetails.UseVisualStyleBackColor = true; this.btnBillDetails.Click += new System.EventHandler(this.btnBillDetails_Click); // // 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.Size = new System.Drawing.Size(150, 100); - this.btnBeerConsumption.TabIndex = 18; + this.btnBeerConsumption.TabIndex = 10; this.btnBeerConsumption.Text = "Beer Consumption"; this.btnBeerConsumption.UseVisualStyleBackColor = true; this.btnBeerConsumption.Click += new System.EventHandler(this.btnBeerConsumption_Click); // // 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.Size = new System.Drawing.Size(150, 100); - this.btnVoidOrReprints.TabIndex = 19; + this.btnVoidOrReprints.TabIndex = 11; this.btnVoidOrReprints.Text = "Voids or Reprints"; this.btnVoidOrReprints.UseVisualStyleBackColor = true; this.btnVoidOrReprints.Click += new System.EventHandler(this.btnVoidOrReprints_Click); // // 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.Size = new System.Drawing.Size(150, 100); - this.btnDiscountReport.TabIndex = 20; + this.btnDiscountReport.TabIndex = 12; this.btnDiscountReport.Text = "Discount Report"; this.btnDiscountReport.UseVisualStyleBackColor = true; this.btnDiscountReport.Click += new System.EventHandler(this.btnDiscountReport_Click); // - // btnChangePassword + // btnProduct // - this.btnChangePassword.Location = new System.Drawing.Point(159, 427); - this.btnChangePassword.Name = "btnChangePassword"; - this.btnChangePassword.Size = new System.Drawing.Size(150, 100); - this.btnChangePassword.TabIndex = 21; - this.btnChangePassword.Text = "Change Password"; - this.btnChangePassword.UseVisualStyleBackColor = true; - this.btnChangePassword.Click += new System.EventHandler(this.btnChangePassword_Click); + this.btnProduct.Location = new System.Drawing.Point(471, 215); + this.btnProduct.Name = "btnProduct"; + this.btnProduct.Size = new System.Drawing.Size(150, 100); + this.btnProduct.TabIndex = 13; + 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(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 // @@ -320,15 +320,15 @@ this.btnManagement.UseVisualStyleBackColor = true; this.btnManagement.Click += new System.EventHandler(this.btnManagement_Click); // - // btnTaxes + // btnChangePassword // - this.btnTaxes.Location = new System.Drawing.Point(471, 427); - this.btnTaxes.Name = "btnTaxes"; - this.btnTaxes.Size = new System.Drawing.Size(150, 100); - this.btnTaxes.TabIndex = 23; - this.btnTaxes.Text = "Taxes"; - this.btnTaxes.UseVisualStyleBackColor = true; - this.btnTaxes.Click += new System.EventHandler(this.btnTaxes_Click); + this.btnChangePassword.Location = new System.Drawing.Point(471, 427); + this.btnChangePassword.Name = "btnChangePassword"; + this.btnChangePassword.Size = new System.Drawing.Size(150, 100); + this.btnChangePassword.TabIndex = 23; + this.btnChangePassword.Text = "Change Password"; + this.btnChangePassword.UseVisualStyleBackColor = true; + this.btnChangePassword.Click += new System.EventHandler(this.btnChangePassword_Click); // // btnExit // diff --git a/Tanshu.Accounts.PointOfSale/Program.cs b/Tanshu.Accounts.PointOfSale/Program.cs index c248b8b..a091cb4 100644 --- a/Tanshu.Accounts.PointOfSale/Program.cs +++ b/Tanshu.Accounts.PointOfSale/Program.cs @@ -11,16 +11,12 @@ namespace Tanshu.Accounts.PointOfSale { static class Program { - //private static readonly Tanshu.Logging.SqlLogger log = new Tanshu.Logging.SqlLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - //log.Warn("Application Started"); Application.Run(new MainForm()); - //log.Warn("Application Closed"); } } } diff --git a/Tanshu.Accounts.Repository/SetupStore.cs b/Tanshu.Accounts.Repository/SetupStore.cs index 8ae3718..f66d9f2 100644 --- a/Tanshu.Accounts.Repository/SetupStore.cs +++ b/Tanshu.Accounts.Repository/SetupStore.cs @@ -17,17 +17,17 @@ namespace Tanshu.Accounts.Repository private readonly ISessionFactory factory; private static SessionManager instance; - private SessionManager() + private SessionManager(bool forTesting) { - cfg = ConfigureNHibernate(); + cfg = ConfigureNHibernate(forTesting); factory = cfg.BuildSessionFactory(); } - public static void Initialize() + public static void Initialize(bool forTesting) { if (instance == null) { - instance = new SessionManager(); + instance = new SessionManager(forTesting); } } public static ISession Session @@ -35,9 +35,7 @@ namespace Tanshu.Accounts.Repository get { if (instance == null) - { - instance = new SessionManager(); - } + throw new ApplicationException("Session factory not initalized. Cannot get Session"); return instance.GetSession(); } } @@ -46,29 +44,11 @@ namespace Tanshu.Accounts.Repository get { if (instance == null) - { - instance = new SessionManager(); - } + throw new ApplicationException("Session factory not initalized. Cannot get Session"); return instance.GetStatelessSession(); } } - public static Configuration Configuration - { - get - { - if (instance == null) - { - instance = new SessionManager(); - } - return instance.GetConfiguration(); - } - - } - private Configuration GetConfiguration() - { - return cfg; - } - private Configuration ConfigureNHibernate() + private Configuration ConfigureNHibernate(bool forTesting) { var configure = new Configuration(); configure.SessionFactoryName("BuildIt"); @@ -81,10 +61,14 @@ namespace Tanshu.Accounts.Repository db.IsolationLevel = IsolationLevel.ReadCommitted; db.ConnectionStringName = "Con"; db.Timeout = 10; - // enabled for testing - //db.LogFormattedSql = true; - //db.LogSqlInConsole = true; - //db.AutoCommentSql = true; + + if (forTesting) + { + // enabled for testing + db.LogFormattedSql = true; + db.LogSqlInConsole = true; + db.AutoCommentSql = true; + } }); var mapping = GetMappings();