User management fixed. Reports working now. Deployed

This commit is contained in:
unknown
2011-02-09 17:33:22 +05:30
parent 1400f42989
commit d4cfa92848
51 changed files with 1990 additions and 1358 deletions

View File

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="FluentCon" connectionString="Server=.;Initial Catalog=Pets;User ID=sa;Password=123456" />
<add name="FluentCon" connectionString="Server=Frodo;Initial Catalog=Pets;User ID=sa;Password=123456" />
</connectionStrings>
<appSettings>
<add key ="Location" value ="Ground"/>
<add key ="Location" value ="Office"/>
<add key ="Factory" value ="SqlServer"/>
<add key ="LogConnection" value ="connection"/>
<add key ="LogLevel" value ="Warn"/>

View File

@ -4,6 +4,8 @@ using System.Linq;
using System.Text;
using Tanshu.Accounts.Repository;
using System.Threading;
using Tanshu.Accounts.Contracts;
using Tanshu.Common.KeyboardControl;
namespace Tanshu.Accounts.PointOfSale
{
@ -16,7 +18,7 @@ namespace Tanshu.Accounts.PointOfSale
}
bool LoginUser(bool setThreadPrincipal)
{
using (LoginForm login = new LoginForm())
using (LoginForm login = new LoginForm(new KeyboardControl()))
{
string userName;
login.ShowDialog();

View File

@ -34,7 +34,6 @@
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
@ -91,21 +90,12 @@
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, 329);
this.Controls.Add(this.numpadControl1);
this.ClientSize = new System.Drawing.Size(290, 97);
this.Controls.Add(this.txtPassword);
this.Controls.Add(this.Label2);
this.Controls.Add(this.txtUserName);
@ -129,6 +119,5 @@
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

@ -3,6 +3,7 @@ using System.Threading;
using System.Windows.Forms;
using Tanshu.Accounts.Repository;
using Tanshu.Accounts.Helpers;
using Tanshu.Common.KeyboardControl;
namespace Tanshu.Accounts.PointOfSale
{
@ -12,11 +13,24 @@ namespace Tanshu.Accounts.PointOfSale
//private static readonly Tanshu.Logging.SqlLogger log = new Tanshu.Logging.SqlLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private bool isAuthenticated;
private string userName;
public LoginForm()
private IKeyboardControl keyboardControl;
public LoginForm(IKeyboardControl keyboardControl)
{
InitializeComponent();
isAuthenticated = false;
userName = null;
this.keyboardControl = keyboardControl;
var control = keyboardControl as UserControl;
if (control != null)
{
control.Location = new System.Drawing.Point(6, 87);
var border = (this.Width - this.ClientSize.Width) / 2;
var titlebarHeight = this.Height - this.ClientSize.Height - (2 * border);
this.Controls.Add(control);
this.Width = 6 + control.Width + 6 + (border * 2);
this.Height = titlebarHeight + 87 + control.Height + 6 + (border * 2);
}
}
private void txtUserName_KeyDown(object sender, KeyEventArgs e)

View File

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

View File

@ -18,13 +18,15 @@ namespace Tanshu.Accounts.PointOfSale
public class BillController
{
private SaleVoucher billInfo;
// private KeyedCollection<BillItemKey, BillInventory> b1 = new KeyedCollection<BillItemKey, BillInventory>();
private OrderedDictionary<BillItemKey, BillInventory> bill = new OrderedDictionary<BillItemKey, BillInventory>();
int? newBillID;
int? editVoucherID;
ISaleForm saleForm;
private Customer customer = new CustomerBI().GetCustomer(1);
public BillController(int? editVoucherID)
{
this.editVoucherID = editVoucherID;
}
public void InitGui(ISaleForm saleForm)
{
this.saleForm = saleForm;
@ -49,7 +51,7 @@ namespace Tanshu.Accounts.PointOfSale
}
public void AddProductToGrid(int productID)
{
BillHelperFunctions.AddProductToGrid(productID, saleForm.BindingSource, bill);
new BillHelperFunctions(saleForm.BindingSource, bill, productID).AddProduct();
Product product = ProductBI.GetProduct(productID);
if (ProductGroupModifierBI.HasCompulsoryModifier(product.ProductGroup.ProductGroupID))
{
@ -74,6 +76,9 @@ namespace Tanshu.Accounts.PointOfSale
public void ShowDiscount()
{
if (!Session.IsAllowed(RoleConstants.DISCOUNT))
return;
var list = new ProductGroupBI().GetProductGroups();
using (var frm = new DiscountForm(list))
{
@ -86,7 +91,8 @@ namespace Tanshu.Accounts.PointOfSale
{
var pg = new ProductGroupBI().GetProductGroupOfProduct(item.Value.ProductID);
if (outList.Contains(pg.ProductGroupID))
item.Value.Discount = discount;
new BillHelperFunctions(saleForm.BindingSource, bill, item.Value.ProductID).SetDiscount(item.Value.Name, discount);
}
}
}
@ -125,35 +131,34 @@ namespace Tanshu.Accounts.PointOfSale
public void Save(bool print, int waiterID, string tableID)
{
using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(RolesConstants.SALES_EDIT_BILL))
if (print && !Session.IsAllowed(RoleConstants.PRINT_BILL))
return;
if (!print && !Session.IsAllowed(RoleConstants.PRINT_KOT))
return;
if ((billInfo != null) && (SaleVoucherBI.IsBillPrinted(billInfo.VoucherID)) && (!Session.IsAllowed(RoleConstants.EDIT_PRINTED_BILL)))
return;
if (bill.Count == 0)
return;
int? saved;
if (billInfo == null)
saved = InsertVoucher(print, waiterID, tableID);
else
saved = UpdateSale(print, waiterID, tableID);
if (saved.HasValue)
{
if ((billInfo != null) && (SaleVoucherBI.IsBillPrinted(billInfo.VoucherID)) && (!roleBI.IsAllowed))
{
throw new PermissionException("You do not have the permission to reprint a bill.");
}
}
if (bill.Count != 0)
{
int? saved;
if (billInfo == null)
saved = AddNewSale(print, waiterID, tableID);
if (editVoucherID.HasValue)
saleForm.CloseWindow();
else
saved = UpdateSale(print, waiterID, tableID);
if (saved.HasValue)
{
if (newBillID.HasValue)
saleForm.CloseWindow();
else
PrintBill(print, saved.Value);
}
ClearBill();
PrintBill(print, saved.Value);
}
ClearBill();
}
private int? AddNewSale(bool finalBill, int waiterID, string tableID)
private int? InsertVoucher(bool finalBill, int waiterID, string tableID)
{
if (billInfo != null)
{
MessageBox.Show("Error in AddNewSale, there is a previous sale in memory", "Error");
MessageBox.Show("Error in InsertVoucher, there is a previous sale in memory", "Error");
return null;
}
@ -205,41 +210,46 @@ namespace Tanshu.Accounts.PointOfSale
private IList<Inventory> GetInventoryForBill(ICollection<BillInventory> list)
{
Dictionary<int, Inventory> localList = new Dictionary<int, Inventory>();
HashSet<int> keys = new HashSet<int>();
foreach (BillInventory item in list)
{
Inventory temp = new Inventory();
if (localList.ContainsKey(item.ProductID))
{
if (temp.Quantity <= 0)
keys.Remove(item.ProductID);
temp = localList[item.ProductID];
temp.Quantity += item.Quantity;
temp.Amount += item.Value;
foreach (var mod in item.Modifiers)
temp.InventoryModifier.Add(new InventoryModifier() { Modifier = mod });
if (temp.Quantity <= 0)
keys.Add(item.ProductID);
}
else
{
temp.Discount = item.Discount;
temp.Product = ProductBI.GetProduct(item.ProductID);
temp.Quantity = item.Quantity;
temp.Rate = item.Price;
temp.Discount = item.Discount;
temp.ServiceCharge = item.ServiceCharge;
temp.Tax = item.Tax;
temp.Amount = item.Value;
foreach (var mod in item.Modifiers)
temp.InventoryModifier.Add(new InventoryModifier() { Modifier = mod });
localList.Add(item.ProductID, temp);
if (item.Quantity <= 0)
keys.Add(item.ProductID);
}
}
return localList.Values.ToList();
}
public decimal GetInput(string type, decimal basic)
{
decimal value;
InputBoxResult result = InputBox.Show(type, basic.ToString(), InputBox_Validating);
if (result.OK)
foreach (var item in keys)
{
if (!decimal.TryParse(result.Text, out value))
return 0;
return value;
localList.Remove(item);
}
return 0;
return localList.Values.ToList();
}
#endregion
public void VoidBill()
@ -248,27 +258,22 @@ namespace Tanshu.Accounts.PointOfSale
return;
if (!billInfo.Printed)
return;
using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(RolesConstants.SALES_VOID_BILL))
if (Session.IsAllowed(RoleConstants.VOID_BILL))
{
if (roleBI.IsAllowed)
if (MessageBox.Show("Are you sure you want to void this bill?", "Void Bill", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
{
if (MessageBox.Show("Are you sure you want to void this bill?", "Void Bill", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
SelectVoidReason voidReason = new SelectVoidReason(GetVoidReason, true);
voidReason.ShowDialog();
if (voidReason.SelectedItem != null)
{
SelectVoidReason voidReason = new SelectVoidReason(GetVoidReason, true);
voidReason.ShowDialog();
if (voidReason.SelectedItem != null)
{
SaleVoucherBI.VoidBill(billInfo.VoucherID, voidReason.SelectedItem.Description);
ClearBill();
}
else
{
MessageBox.Show("Please Select a reason if you want to void the bill", "Bill NOT Voided", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
SaleVoucherBI.VoidBill(billInfo.VoucherID, voidReason.SelectedItem.Description);
ClearBill();
}
else
{
MessageBox.Show("Please Select a reason if you want to void the bill", "Bill NOT Voided", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
}
else
throw new PermissionException("You do not have the permission to void a bill.");
}
}
Customer selectCustomer_customerEvent(object sender, CustomerEventArgs e)
@ -281,25 +286,10 @@ namespace Tanshu.Accounts.PointOfSale
}
private void PrintBill(bool finalBill, int voucherID)
{
using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(RolesConstants.SALES_PRINT_KOT))
if (!roleBI.IsAllowed)
throw new PermissionException("You are not allowed to print KOT");
if (!finalBill)
Accounts.Print.Thermal.PrintKot(voucherID, bill.Values.ToList());
else
{
using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(RolesConstants.SALES_PRINT_BILL))
{
if (roleBI.IsAllowed)
{
Accounts.Print.Thermal.PrintBill(true, voucherID, bill.Values.ToList());
}
else
throw new PermissionException("You are not allowed to print KOT");
}
}
Accounts.Print.Thermal.PrintBill(voucherID, bill.Values.ToList());
}
private List<StringType> GetVoidReason(Dictionary<string, string> filter)
@ -315,15 +305,14 @@ namespace Tanshu.Accounts.PointOfSale
list.Add(new StringType("Other"));
return list.Where(i => i.Description.ToLower().Contains(filter["Name"].ToLower().Trim())).ToList();
}
public void SetNewBillID(int voucherID)
{
this.newBillID = voucherID;
}
public BillInventory CurrentProduct
{
get
{
return bill.ElementAt(saleForm.BindingSource.Position).Value;
if (saleForm.BindingSource.Position == -1)
return null;
else
return bill.ElementAt(saleForm.BindingSource.Position).Value;
}
}
private void ShowAmount()
@ -338,64 +327,48 @@ namespace Tanshu.Accounts.PointOfSale
//bill.Values.ToList();
saleForm.ShowAmount(discountAmount, grossAmount, serviceChargeAmount, taxAmount, valueAmount, bill.Values.ToList());
}
public void SetDiscount(BillInventory billInventory, decimal discount)
public void ProductRemove()
{
if (billInventory == null)
var item = CurrentProduct;
if (!Allowed(item))
return;
BillHelperFunctions.SetDiscount(billInventory.ProductID, discount, customer, bill);
ShowAmount();
}
public void SetAmount(BillInventory billInventory, decimal amount)
{
if (billInventory == null)
return;
BillHelperFunctions.SetAmount(billInventory, amount, saleForm.BindingSource, bill);
ShowAmount();
}
public void ProductRemove(BillInventory billInventory)
{
if (billInventory == null)
return;
if (billInventory.Printed > 0)
if (item.Printed > 0)
{
using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(RolesConstants.SALES_EDIT_PRINTED_PRODUCT))
{
if (roleBI.IsAllowed)
{
if (MessageBox.Show(string.Format("Already {0} items have been printed.\n\rAre you sure you want to delete this item?", billInventory.Printed), "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
return;
}
}
if (!Session.IsAllowed(RoleConstants.EDIT_PRINTED_PRODUCT))
return;
else if (MessageBox.Show(string.Format("Already {0} items have been printed.\n\rAre you sure you want to delete this item?", item.Printed), "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
return;
}
bill.Remove(new BillItemKey(billInventory.ProductID, billInventory.Printed == 0));
bill.Remove(new BillItemKey(item.ProductID, item.Printed == 0));
bill.ReCompact();
ShowAmount();
}
public void SetQuantity(BillInventory billInventory, decimal quantity, bool absolute, bool prompt)
public void SetQuantity(decimal quantity, bool prompt)
{
if (billInventory == null)
var item = CurrentProduct;
if (!Allowed(item))
return;
BillHelperFunctions.SetQuantity(billInventory, quantity, absolute, prompt, saleForm.BindingSource, bill);
new BillHelperFunctions(saleForm.BindingSource, bill, CurrentProduct.ProductID).SetQuantity(item, quantity, prompt);
ShowAmount();
}
public void ChangeRate()
{
var item = CurrentProduct;
if (item != null)
{
decimal rate = 0;
InputBoxResult result = InputBox.Show("Rate", item.Price.ToString(), InputBox_Validating);
if (result.OK)
rate = Convert.ToDecimal(result.Text);
if (rate != 0)
{
BillHelperFunctions.SetRate(item.ProductID, rate, bill);
ShowAmount();
}
}
new BillHelperFunctions(saleForm.BindingSource, bill, CurrentProduct.ProductID).SetPrice(CurrentProduct);
ShowAmount();
}
private bool Allowed(BillInventory item, RoleConstants role)
{
if (item == null)
return false;
if (!Session.IsAllowed(role))
return false;
return true;
}
private bool Allowed(BillInventory item)
{ return item != null; }
private void InputBox_Validating(object sender, InputBoxValidatingArgs e)
{
}
@ -463,11 +436,10 @@ namespace Tanshu.Accounts.PointOfSale
public void CancelBillChanges()
{
if (bill.Count != 0)
if (MessageBox.Show("Cancel current bill?", "Cancel bill", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
if (bill.Count != 0 && bill.Values.Any(i => i.Printed != i.Quantity))
if (MessageBox.Show("Abandon Changes?", "Abandon Changes", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
return;
ClearBill();
}
public void ClearBill()
{
@ -478,11 +450,10 @@ namespace Tanshu.Accounts.PointOfSale
}
public void FormLoad()
{
if (newBillID.HasValue)
if (editVoucherID.HasValue)
{
LoadBill(newBillID.Value);
LoadBill(editVoucherID.Value);
}
}
internal void SettleBill()
{
@ -490,6 +461,8 @@ namespace Tanshu.Accounts.PointOfSale
return;
if (!billInfo.Printed)
return;
if (!Session.IsAllowed(RoleConstants.SETTLE_BILL))
return;
int option = SettleOptionFactory.Unsettled;
using (BillSettleForm frm = new BillSettleForm())
{
@ -505,5 +478,5 @@ namespace Tanshu.Accounts.PointOfSale
}
}
// How to load a bill
//LoadBill(((PendingBills)bsPending.Current).voucherID);
//LoadBill(((PendingBills)bsPending.Current).editVoucherID);
// ChangeFormState(SaleFormState.Billing);

View File

@ -6,6 +6,7 @@ using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Tanshu.Accounts.Contracts;
namespace Tanshu.Accounts.PointOfSale
{

View File

@ -5,6 +5,7 @@ using Tanshu.Accounts.Entities.Auth;
using Tanshu.Accounts.Helpers;
using Tanshu.Accounts.Repository;
using System.Collections.Generic;
using Tanshu.Common.KeyboardControl;
namespace Tanshu.Accounts.PointOfSale
{
@ -56,38 +57,26 @@ namespace Tanshu.Accounts.PointOfSale
}
CheckRoles();
}
private void btnSale_Click(object sender, EventArgs e)
{
using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(RolesConstants.SALES_SALES_BILL))
{
if (roleBI.IsAllowed)
{
using (SalesForm frmSale = new SalesForm(new BillController()))
frmSale.ShowDialog();
}
}
if (Session.IsAllowed(RoleConstants.SALES))
using (SalesForm frmSale = new SalesForm(new BillController(null)))
frmSale.ShowDialog();
}
private void btnProduct_Click(object sender, EventArgs e)
{
using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(RolesConstants.MASTER_PRODUCTS))
{
if (roleBI.IsAllowed)
using (ProductsForm frm = new ProductsForm())
frm.ShowDialog();
}
if (Session.IsAllowed(RoleConstants.PRODUCTS))
using (ProductsForm frm = new ProductsForm())
frm.ShowDialog();
}
private void btnProductGroup_Click(object sender, EventArgs e)
{
using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(RolesConstants.MASTER_PRODUCTS))
{
if (roleBI.IsAllowed)
using (var frm = new ProductTypes())
frm.ShowDialog();
}
if (Session.IsAllowed(RoleConstants.PRODUCTS))
using (var frm = new ProductTypes())
frm.ShowDialog();
}
@ -102,40 +91,27 @@ namespace Tanshu.Accounts.PointOfSale
private void btnInitial_Click(object sender, EventArgs e)
{
using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(RolesConstants.MASTER_OWNER))
#if (DEBUG)
if (Session.IsAllowed(RoleConstants.MASTER_OWNER))
{
if (roleBI.IsAllowed)
{
Fixtures.CreateSchema();
MessageBox.Show("Schema Recreated");
}
//Fixtures.CreateSchema();
//MessageBox.Show("Schema Recreated");
}
#endif
}
private void btnAdvanceReceive_Click(object sender, EventArgs e)
{
using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(RolesConstants.SALES_SALES_BILL))
{
if (roleBI.IsAllowed)
{
using (RecieveAdvanceForm frm = new RecieveAdvanceForm())
frm.ShowDialog();
}
}
if (Session.IsAllowed(RoleConstants.SALES))
using (RecieveAdvanceForm frm = new RecieveAdvanceForm())
frm.ShowDialog();
}
private void btnAdvanceAdjust_Click(object sender, EventArgs e)
{
using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(RolesConstants.SALES_SALES_BILL))
{
if (roleBI.IsAllowed)
{
using (AdjustAdvanceForm frm = new AdjustAdvanceForm())
frm.ShowDialog();
}
}
if (Session.IsAllowed(RoleConstants.SALES))
using (AdjustAdvanceForm frm = new AdjustAdvanceForm())
frm.ShowDialog();
}
@ -146,110 +122,87 @@ namespace Tanshu.Accounts.PointOfSale
private void btnCreateUser_Click(object sender, EventArgs e)
{
using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(RolesConstants.SECURITY_MANAGE_ROLES))
{
if (roleBI.IsAllowed)
using (SelectUser form = new SelectUser(UserBI.GetFilteredUsers, true))
{
form.userEvent += new UserEventHandler(form_userEvent);
form.ShowDialog();
}
}
if (Session.IsAllowed(RoleConstants.SECURITY_MANAGE_ROLES))
using (SelectUser form = new SelectUser(UserBI.GetFilteredUsers, true))
{
form.userEvent += new UserEventHandler(form_userEvent);
form.ShowDialog();
}
}
private void btnAssignRoles_Click(object sender, EventArgs e)
private void btnUserRoles_Click(object sender, EventArgs e)
{
using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(RolesConstants.SECURITY_MANAGE_ROLES))
{
if (roleBI.IsAllowed)
using (AssignRoles frm = new AssignRoles())
frm.ShowDialog();
}
if (Session.IsAllowed(RoleConstants.SECURITY_MANAGE_ROLES))
using (var frm = new AssignUserGroups())
frm.ShowDialog();
}
private void btnChangePassword_Click(object sender, EventArgs e)
{
using (ChangePassword frm = new ChangePassword())
using (ChangePassword frm = new ChangePassword(new KeyboardControl()))
frm.ShowDialog();
}
private void btnCashierCheckout_Click(object sender, EventArgs e)
{
using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(RolesConstants.SALES_CHECKOUT))
{
if (roleBI.IsAllowed)
using (Cashier_Checkout_Form frm = new Cashier_Checkout_Form())
frm.ShowDialog();
}
if (Session.IsAllowed(RoleConstants.CASHIER_CHECKOUT))
using (Cashier_Checkout_Form frm = new Cashier_Checkout_Form())
frm.ShowDialog();
}
private void btnSaleAnalysis_Click(object sender, EventArgs e)
{
using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(RolesConstants.SALES_SALE_DETAIL))
{
if (roleBI.IsAllowed)
using (frmSaleAnalysisForm frm = new frmSaleAnalysisForm())
frm.ShowDialog();
}
if (Session.IsAllowed(RoleConstants.SALE_ANALYSIS))
using (frmSaleAnalysisForm frm = new frmSaleAnalysisForm())
frm.ShowDialog();
}
private void btnSaleDetail_Click(object sender, EventArgs e)
{
if (Session.IsAllowed(RoleConstants.SALE_ANALYSIS))
using (var frm = new frmSaleDetail())
frm.ShowDialog();
}
private void MainForm_Load(object sender, EventArgs e)
{
//foreach (Control item in this.flowLayoutPanel1.Controls)
//{
// Button but = item as Button;
// if (but != null)
// {
// }
//}
CheckRoles();
}
private void CheckRoles()
{
using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(RolesConstants.MASTER_OWNER))
{
if (roleBI.IsAllowed)
{
btnInitial.Visible = true;
}
else
{
btnInitial.Visible = false;
}
}
using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(RolesConstants.SALES_SALES_BILL))
{
if (roleBI.IsAllowed)
{
btnSale.Visible = true;
btnCustomer.Visible = true;
}
else
{
btnSale.Visible = false;
btnCustomer.Visible = true;
}
}
using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(RolesConstants.MASTER_PRODUCTS))
{
if (roleBI.IsAllowed)
{
btnProduct.Visible = true;
btnProductGroup.Visible = true;
}
else
{
btnProduct.Visible = false;
btnProductGroup.Visible = false;
}
}
btnInitial.Visible = Session.IsAllowed(RoleConstants.MASTER_OWNER);
btnSale.Visible = Session.IsAllowed(RoleConstants.SALES);
btnProduct.Visible = Session.IsAllowed(RoleConstants.PRODUCTS);
btnProductGroup.Visible = Session.IsAllowed(RoleConstants.PRODUCTS);
btnCustomer.Visible = Session.IsAllowed(RoleConstants.CUSTOMERS);
btnAdvanceReceive.Visible = Session.IsAllowed(RoleConstants.RECEIVE_ADVANCE);
btnAdvanceAdjust.Visible = Session.IsAllowed(RoleConstants.ADJUST_ADVANCE);
btnCreateUser.Visible = Session.IsAllowed(RoleConstants.SECURITY_MANAGE_USERS);
btnUserRoles.Visible = Session.IsAllowed(RoleConstants.SECURITY_MANAGE_USERS);
btnGroupRoles.Visible = Session.IsAllowed(RoleConstants.SECURITY_MANAGE_ROLES);
btnCashierCheckout.Visible = Session.IsAllowed(RoleConstants.SALE_ANALYSIS);
btnSaleAnalysis.Visible = Session.IsAllowed(RoleConstants.SALE_ANALYSIS);
btnSaleDetail.Visible = Session.IsAllowed(RoleConstants.SALE_DETAIL);
btnChangePassword.Visible = Session.IsAuthenticated;
}
private void btnGroupRoles_Click(object sender, EventArgs e)
{
if (Session.IsAllowed(RoleConstants.SECURITY_MANAGE_ROLES))
using (var frm = new AssignGroupRoles())
frm.ShowDialog();
}
}
}

View File

@ -32,17 +32,19 @@
this.btnSale = new System.Windows.Forms.Button();
this.btnInitial = new System.Windows.Forms.Button();
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.btnCustomer = new System.Windows.Forms.Button();
this.btnProduct = new System.Windows.Forms.Button();
this.btnProductGroup = new System.Windows.Forms.Button();
this.btnCustomer = new System.Windows.Forms.Button();
this.btnAdvanceReceive = new System.Windows.Forms.Button();
this.btnAdvanceAdjust = new System.Windows.Forms.Button();
this.btnExit = new System.Windows.Forms.Button();
this.btnCreateUser = new System.Windows.Forms.Button();
this.btnAssignRoles = new System.Windows.Forms.Button();
this.btnChangePassword = 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.btnChangePassword = new System.Windows.Forms.Button();
this.btnExit = new System.Windows.Forms.Button();
this.btnSaleDetail = new System.Windows.Forms.Button();
this.flowLayoutPanel1.SuspendLayout();
this.SuspendLayout();
//
@ -51,7 +53,7 @@
this.btnLogin.Location = new System.Drawing.Point(159, 3);
this.btnLogin.Name = "btnLogin";
this.btnLogin.Size = new System.Drawing.Size(150, 100);
this.btnLogin.TabIndex = 27;
this.btnLogin.TabIndex = 1;
this.btnLogin.Text = "&Login";
this.btnLogin.UseVisualStyleBackColor = true;
this.btnLogin.Click += new System.EventHandler(this.btnLogin_Click);
@ -61,7 +63,7 @@
this.btnSale.Location = new System.Drawing.Point(315, 3);
this.btnSale.Name = "btnSale";
this.btnSale.Size = new System.Drawing.Size(150, 100);
this.btnSale.TabIndex = 28;
this.btnSale.TabIndex = 2;
this.btnSale.Text = "&Sale";
this.btnSale.UseVisualStyleBackColor = true;
this.btnSale.Click += new System.EventHandler(this.btnSale_Click);
@ -71,7 +73,7 @@
this.btnInitial.Location = new System.Drawing.Point(3, 3);
this.btnInitial.Name = "btnInitial";
this.btnInitial.Size = new System.Drawing.Size(150, 100);
this.btnInitial.TabIndex = 29;
this.btnInitial.TabIndex = 0;
this.btnInitial.Text = "Initial Data";
this.btnInitial.UseVisualStyleBackColor = true;
this.btnInitial.Click += new System.EventHandler(this.btnInitial_Click);
@ -81,59 +83,61 @@
this.flowLayoutPanel1.Controls.Add(this.btnInitial);
this.flowLayoutPanel1.Controls.Add(this.btnLogin);
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.btnCustomer);
this.flowLayoutPanel1.Controls.Add(this.btnAdvanceReceive);
this.flowLayoutPanel1.Controls.Add(this.btnAdvanceAdjust);
this.flowLayoutPanel1.Controls.Add(this.btnExit);
this.flowLayoutPanel1.Controls.Add(this.btnCreateUser);
this.flowLayoutPanel1.Controls.Add(this.btnAssignRoles);
this.flowLayoutPanel1.Controls.Add(this.btnChangePassword);
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.btnSaleDetail);
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);
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Size = new System.Drawing.Size(792, 537);
this.flowLayoutPanel1.TabIndex = 30;
this.flowLayoutPanel1.TabIndex = 0;
//
// btnCustomer
//
this.btnCustomer.Location = new System.Drawing.Point(471, 3);
this.btnCustomer.Name = "btnCustomer";
this.btnCustomer.Size = new System.Drawing.Size(150, 100);
this.btnCustomer.TabIndex = 3;
this.btnCustomer.Text = "Customers";
this.btnCustomer.UseVisualStyleBackColor = true;
this.btnCustomer.Click += new System.EventHandler(this.btnCustomer_Click);
//
// btnProduct
//
this.btnProduct.Location = new System.Drawing.Point(471, 3);
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 = 30;
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(627, 3);
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 = 31;
this.btnProductGroup.TabIndex = 5;
this.btnProductGroup.Text = "Product Groups";
this.btnProductGroup.UseVisualStyleBackColor = true;
this.btnProductGroup.Click += new System.EventHandler(this.btnProductGroup_Click);
//
// btnCustomer
//
this.btnCustomer.Location = new System.Drawing.Point(3, 109);
this.btnCustomer.Name = "btnCustomer";
this.btnCustomer.Size = new System.Drawing.Size(150, 100);
this.btnCustomer.TabIndex = 32;
this.btnCustomer.Text = "Customers";
this.btnCustomer.UseVisualStyleBackColor = true;
this.btnCustomer.Click += new System.EventHandler(this.btnCustomer_Click);
//
// btnAdvanceReceive
//
this.btnAdvanceReceive.Location = new System.Drawing.Point(159, 109);
this.btnAdvanceReceive.Name = "btnAdvanceReceive";
this.btnAdvanceReceive.Size = new System.Drawing.Size(150, 100);
this.btnAdvanceReceive.TabIndex = 33;
this.btnAdvanceReceive.TabIndex = 6;
this.btnAdvanceReceive.Text = "Receive Advance";
this.btnAdvanceReceive.UseVisualStyleBackColor = true;
this.btnAdvanceReceive.Click += new System.EventHandler(this.btnAdvanceReceive_Click);
@ -143,71 +147,91 @@
this.btnAdvanceAdjust.Location = new System.Drawing.Point(315, 109);
this.btnAdvanceAdjust.Name = "btnAdvanceAdjust";
this.btnAdvanceAdjust.Size = new System.Drawing.Size(150, 100);
this.btnAdvanceAdjust.TabIndex = 34;
this.btnAdvanceAdjust.TabIndex = 7;
this.btnAdvanceAdjust.Text = "Adjust Advance";
this.btnAdvanceAdjust.UseVisualStyleBackColor = true;
this.btnAdvanceAdjust.Click += new System.EventHandler(this.btnAdvanceAdjust_Click);
//
// btnExit
//
this.btnExit.Location = new System.Drawing.Point(471, 109);
this.btnExit.Name = "btnExit";
this.btnExit.Size = new System.Drawing.Size(150, 100);
this.btnExit.TabIndex = 35;
this.btnExit.Text = "Exit";
this.btnExit.UseVisualStyleBackColor = true;
this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
//
// btnCreateUser
//
this.btnCreateUser.Location = new System.Drawing.Point(627, 109);
this.btnCreateUser.Location = new System.Drawing.Point(471, 109);
this.btnCreateUser.Name = "btnCreateUser";
this.btnCreateUser.Size = new System.Drawing.Size(150, 100);
this.btnCreateUser.TabIndex = 36;
this.btnCreateUser.TabIndex = 8;
this.btnCreateUser.Text = "Create User";
this.btnCreateUser.UseVisualStyleBackColor = true;
this.btnCreateUser.Click += new System.EventHandler(this.btnCreateUser_Click);
//
// btnAssignRoles
// btnUserRoles
//
this.btnAssignRoles.Location = new System.Drawing.Point(3, 215);
this.btnAssignRoles.Name = "btnAssignRoles";
this.btnAssignRoles.Size = new System.Drawing.Size(150, 100);
this.btnAssignRoles.TabIndex = 37;
this.btnAssignRoles.Text = "Assign Roles";
this.btnAssignRoles.UseVisualStyleBackColor = true;
this.btnAssignRoles.Click += new System.EventHandler(this.btnAssignRoles_Click);
this.btnUserRoles.Location = new System.Drawing.Point(627, 109);
this.btnUserRoles.Name = "btnUserRoles";
this.btnUserRoles.Size = new System.Drawing.Size(150, 100);
this.btnUserRoles.TabIndex = 9;
this.btnUserRoles.Text = "Manage User Roles";
this.btnUserRoles.UseVisualStyleBackColor = true;
this.btnUserRoles.Click += new System.EventHandler(this.btnUserRoles_Click);
//
// btnChangePassword
// btnGroupRoles
//
this.btnChangePassword.Location = new System.Drawing.Point(159, 215);
this.btnChangePassword.Name = "btnChangePassword";
this.btnChangePassword.Size = new System.Drawing.Size(150, 100);
this.btnChangePassword.TabIndex = 38;
this.btnChangePassword.Text = "Change Password";
this.btnChangePassword.UseVisualStyleBackColor = true;
this.btnChangePassword.Click += new System.EventHandler(this.btnChangePassword_Click);
this.btnGroupRoles.Location = new System.Drawing.Point(3, 215);
this.btnGroupRoles.Name = "btnGroupRoles";
this.btnGroupRoles.Size = new System.Drawing.Size(150, 100);
this.btnGroupRoles.TabIndex = 10;
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(315, 215);
this.btnCashierCheckout.Location = new System.Drawing.Point(159, 215);
this.btnCashierCheckout.Name = "btnCashierCheckout";
this.btnCashierCheckout.Size = new System.Drawing.Size(150, 100);
this.btnCashierCheckout.TabIndex = 39;
this.btnCashierCheckout.TabIndex = 11;
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(471, 215);
this.btnSaleAnalysis.Location = new System.Drawing.Point(315, 215);
this.btnSaleAnalysis.Name = "btnSaleAnalysis";
this.btnSaleAnalysis.Size = new System.Drawing.Size(150, 100);
this.btnSaleAnalysis.TabIndex = 40;
this.btnSaleAnalysis.TabIndex = 12;
this.btnSaleAnalysis.Text = "Sale Analysis";
this.btnSaleAnalysis.UseVisualStyleBackColor = true;
this.btnSaleAnalysis.Click += new System.EventHandler(this.btnSaleAnalysis_Click);
//
// btnChangePassword
//
this.btnChangePassword.Location = new System.Drawing.Point(627, 215);
this.btnChangePassword.Name = "btnChangePassword";
this.btnChangePassword.Size = new System.Drawing.Size(150, 100);
this.btnChangePassword.TabIndex = 13;
this.btnChangePassword.Text = "Change Password";
this.btnChangePassword.UseVisualStyleBackColor = true;
this.btnChangePassword.Click += new System.EventHandler(this.btnChangePassword_Click);
//
// btnExit
//
this.btnExit.Location = new System.Drawing.Point(3, 321);
this.btnExit.Name = "btnExit";
this.btnExit.Size = new System.Drawing.Size(150, 100);
this.btnExit.TabIndex = 14;
this.btnExit.Text = "Exit";
this.btnExit.UseVisualStyleBackColor = true;
this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
//
// btnSaleDetail
//
this.btnSaleDetail.Location = new System.Drawing.Point(471, 215);
this.btnSaleDetail.Name = "btnSaleDetail";
this.btnSaleDetail.Size = new System.Drawing.Size(150, 100);
this.btnSaleDetail.TabIndex = 15;
this.btnSaleDetail.Text = "Sale Detail";
this.btnSaleDetail.UseVisualStyleBackColor = true;
this.btnSaleDetail.Click += new System.EventHandler(this.btnSaleDetail_Click);
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -237,9 +261,11 @@
private System.Windows.Forms.Button btnAdvanceAdjust;
private System.Windows.Forms.Button btnExit;
private System.Windows.Forms.Button btnCreateUser;
private System.Windows.Forms.Button btnAssignRoles;
private System.Windows.Forms.Button btnUserRoles;
private System.Windows.Forms.Button btnChangePassword;
private System.Windows.Forms.Button btnCashierCheckout;
private System.Windows.Forms.Button btnSaleAnalysis;
private System.Windows.Forms.Button btnGroupRoles;
private System.Windows.Forms.Button btnSaleDetail;
}
}

View File

@ -195,7 +195,6 @@
this.txtSales.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
this.txtSales.Size = new System.Drawing.Size(200, 20);
this.txtSales.TabIndex = 54;
this.txtSales.TextChanged += new System.EventHandler(this.txtSales_TextChanged);
//
// txtDeposited
//

View File

@ -9,21 +9,24 @@ namespace Tanshu.Accounts.PointOfSale
public partial class Cashier_Checkout_Form : Form
{
CheckoutBI coProxy;
bool loading;
//private static readonly Tanshu.Logging.SqlLogger log = new Tanshu.Logging.SqlLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public Cashier_Checkout_Form()
{
loading = true;
InitializeComponent();
}
private void Cashier_Checkout_Form_Load(object sender, EventArgs e)
{
dtpStart.Format = DateTimePickerFormat.Custom;
dtpStart.CustomFormat = "dd-MMM-yyyy HH:mm:ss";
dtpStart.CustomFormat = "dd-MMM-yyyy";
dtpStart.Value = DateTime.Now;
dtpFinish.Format = DateTimePickerFormat.Custom;
dtpFinish.CustomFormat = "dd-MMM-yyyy HH:mm:ss";
dtpFinish.CustomFormat = "dd-MMM-yyyy";
dtpFinish.Value = DateTime.Now;
FillUsers();
loading = false;
}
private void FillUsers()
@ -41,11 +44,8 @@ namespace Tanshu.Accounts.PointOfSale
private void EmployeeStatus()
{
if (cmbCashier.SelectedValue == null)
if (loading || cmbCashier.SelectedValue == null)
return;
dtpStart.Value = Convert.ToDateTime(String.Format("{0:dd-MMM-yyyy} 00:00:00", dtpStart.Value));
dtpFinish.Value = Convert.ToDateTime(String.Format("{0:dd-MMM-yyyy} 23:59:59", dtpFinish.Value));
coProxy = new CheckoutBI((int)cmbCashier.SelectedValue, dtpStart.Value, dtpFinish.Value);
txtOpening.Text = string.Format("{0:#,##0.00}", coProxy);
txtReceipts.Text = string.Format("{0:#,##0.00}", coProxy.Receipts);
@ -57,10 +57,10 @@ namespace Tanshu.Accounts.PointOfSale
txtPayments.Text = string.Format("{0:#,##0.00}", coProxy.CashPayments);
txtAdditionalVoids.Text = string.Format("{0:#,##0.00}", coProxy.AdditionalVoids);
txtVoidsInSystem.Text = string.Format("{0:#,##0.00}", coProxy.VoidsInSystem);
txtDiscounts.Text = string.Format("{0:#,##0.00}", coProxy.Discount);
txtPending.Text = string.Format("{0:#,##0.00}", coProxy.PendingBills);
txtSales.Text = string.Format("{0:#,##0.00}", coProxy.NetSales);
txtClosingCash.Text = string.Format("{0:#,##0.00}", coProxy.ClosingBalance
);
txtClosingCash.Text = string.Format("{0:#,##0.00}", coProxy.ClosingBalance);
txtStatus.Text = coProxy.Status;
}
@ -88,10 +88,5 @@ namespace Tanshu.Accounts.PointOfSale
{
Thermal.PrintClosing(coProxy);
}
private void txtSales_TextChanged(object sender, EventArgs e)
{
}
}
}

View File

@ -9,8 +9,7 @@ namespace Tanshu.Accounts.PointOfSale
{
public partial class frmSaleAnalysisForm : Form
{
int? details = null;
IList<SalesAnalysis> det;
IList<SalesAnalysis> list;
//private static readonly Tanshu.Logging.SqlLogger log = new Tanshu.Logging.SqlLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public frmSaleAnalysisForm()
{
@ -25,38 +24,12 @@ namespace Tanshu.Accounts.PointOfSale
private void ShowStatement()
{
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));
if (details.HasValue)
{
var list = new SalesAnalysisBI().GetSaleDetail(startDate, finishDate, details.Value);
dgvSale.AutoGenerateColumns = true;
dgvSale.DataSource = list;
dgvSale.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
dgvSale.Columns[2].DefaultCellStyle.Format = "#,##0.00;(#,##0.00);0";
dgvSale.Columns[3].DefaultCellStyle.Format = "#,##0.00;(#,##0.00);0";
}
else
{
det = new SalesAnalysisBI().GetSale(startDate, finishDate);
dgvSale.AutoGenerateColumns = true;
dgvSale.DataSource = det;
dgvSale.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
dgvSale.Columns[0].Visible = false;
dgvSale.Columns[2].DefaultCellStyle.Format = "#,##0.00;(#,##0.00);0";
dgvSale.Columns[3].DefaultCellStyle.Format = "#,##0.00;(#,##0.00);0";
}
decimal freeSale = 0, voids = 0, pending = 0, net = 0, tax = 0;
new SalesAnalysisBI().GetAdditionalInfo(ref freeSale, ref voids, ref pending, ref net, ref tax, startDate, finishDate);
txtVoid.Text = String.Format("{0:#,##0.00;(#,##0.00);0}", voids);
txtPending.Text = String.Format("{0:#,##0.00;(#,##0.00);0}", pending);
txtNet.Text = String.Format("{0:#,##0.00;(#,##0.00);0}", net);
txtTax.Text = String.Format("{0:#,##0.00;(#,##0.00);0}", tax);
txtGross.Text = String.Format("{0:#,##0.00;(#,##0.00);0}", net + tax);
list = new SalesAnalysisBI().GetSale(dtpStart.Value, dtpFinish.Value);
dgvSale.AutoGenerateColumns = true;
dgvSale.DataSource = list;
dgvSale.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
dgvSale.Columns[1].DefaultCellStyle.Format = "#,##0.00;(#,##0.00);0";
dgvSale.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
}
private void dtpFinish_ValueChanged(object sender, EventArgs e)
@ -71,27 +44,13 @@ namespace Tanshu.Accounts.PointOfSale
ShowStatement();
}
private void dgvSale_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
try
{
if (!details.HasValue)
details = ((SalesAnalysis)dgvSale.SelectedRows[0].DataBoundItem).TypeID;
else
details = null;
ShowStatement();
}
catch (Exception ex)
{ throw ex; }
}
private void btnPrint_Click(object sender, EventArgs e)
{
if (det != null)
if (list != null)
{
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(Session.User.Name, det, startDate, finishDate);
var startDate = dtpStart.Value.Date.AddHours(6);
var finishDate = dtpFinish.Value.Date.AddDays(1).AddHours(5);
Accounts.Print.Thermal.PrintSale(Session.User.Name, list, startDate, finishDate);
}
}
}

View File

@ -28,16 +28,6 @@
/// </summary>
private void InitializeComponent()
{
this.txtNet = new System.Windows.Forms.TextBox();
this.txtTax = new System.Windows.Forms.TextBox();
this.txtGross = new System.Windows.Forms.TextBox();
this.txtPending = new System.Windows.Forms.TextBox();
this.txtVoid = new System.Windows.Forms.TextBox();
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.dgvSale = new System.Windows.Forms.DataGridView();
this.dtpFinish = new System.Windows.Forms.DateTimePicker();
this.dtpStart = new System.Windows.Forms.DateTimePicker();
@ -46,96 +36,14 @@
((System.ComponentModel.ISupportInitialize)(this.dgvSale)).BeginInit();
this.SuspendLayout();
//
// txtNet
//
this.txtNet.Location = new System.Drawing.Point(224, 487);
this.txtNet.Name = "txtNet";
this.txtNet.ReadOnly = true;
this.txtNet.Size = new System.Drawing.Size(100, 20);
this.txtNet.TabIndex = 17;
//
// txtTax
//
this.txtTax.Location = new System.Drawing.Point(330, 487);
this.txtTax.Name = "txtTax";
this.txtTax.ReadOnly = true;
this.txtTax.Size = new System.Drawing.Size(100, 20);
this.txtTax.TabIndex = 18;
//
// txtGross
//
this.txtGross.Location = new System.Drawing.Point(436, 487);
this.txtGross.Name = "txtGross";
this.txtGross.ReadOnly = true;
this.txtGross.Size = new System.Drawing.Size(100, 20);
this.txtGross.TabIndex = 19;
//
// txtPending
//
this.txtPending.Location = new System.Drawing.Point(118, 487);
this.txtPending.Name = "txtPending";
this.txtPending.ReadOnly = true;
this.txtPending.Size = new System.Drawing.Size(100, 20);
this.txtPending.TabIndex = 16;
//
// txtVoid
//
this.txtVoid.Location = new System.Drawing.Point(12, 487);
this.txtVoid.Name = "txtVoid";
this.txtVoid.ReadOnly = true;
this.txtVoid.Size = new System.Drawing.Size(100, 20);
this.txtVoid.TabIndex = 15;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(115, 471);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(70, 13);
this.label5.TabIndex = 24;
this.label5.Text = "Pending Sale";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(12, 471);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(52, 13);
this.label4.TabIndex = 23;
this.label4.Text = "Void Sale";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(327, 471);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(25, 13);
this.label3.TabIndex = 26;
this.label3.Text = "Tax";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(433, 471);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(58, 13);
this.label2.TabIndex = 27;
this.label2.Text = "Gross Sale";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(221, 471);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(48, 13);
this.label1.TabIndex = 25;
this.label1.Text = "Net Sale";
//
// dgvSale
//
this.dgvSale.AllowUserToAddRows = false;
this.dgvSale.AllowUserToDeleteRows = false;
this.dgvSale.AllowUserToResizeRows = false;
this.dgvSale.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.dgvSale.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgvSale.Location = new System.Drawing.Point(12, 41);
this.dgvSale.MultiSelect = false;
@ -145,9 +53,8 @@
this.dgvSale.RowTemplate.Height = 19;
this.dgvSale.RowTemplate.ReadOnly = true;
this.dgvSale.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.dgvSale.Size = new System.Drawing.Size(524, 427);
this.dgvSale.Size = new System.Drawing.Size(335, 466);
this.dgvSale.TabIndex = 14;
this.dgvSale.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvSale_CellDoubleClick);
//
// dtpFinish
//
@ -180,7 +87,8 @@
//
// btnPrint
//
this.btnPrint.Location = new System.Drawing.Point(461, 12);
this.btnPrint.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnPrint.Location = new System.Drawing.Point(272, 12);
this.btnPrint.Name = "btnPrint";
this.btnPrint.Size = new System.Drawing.Size(75, 23);
this.btnPrint.TabIndex = 28;
@ -192,18 +100,8 @@
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(548, 519);
this.ClientSize = new System.Drawing.Size(359, 519);
this.Controls.Add(this.btnPrint);
this.Controls.Add(this.txtNet);
this.Controls.Add(this.txtTax);
this.Controls.Add(this.txtGross);
this.Controls.Add(this.txtPending);
this.Controls.Add(this.txtVoid);
this.Controls.Add(this.label5);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.dgvSale);
this.Controls.Add(this.dtpFinish);
this.Controls.Add(this.dtpStart);
@ -221,16 +119,6 @@
#endregion
private System.Windows.Forms.TextBox txtNet;
private System.Windows.Forms.TextBox txtTax;
private System.Windows.Forms.TextBox txtGross;
private System.Windows.Forms.TextBox txtPending;
private System.Windows.Forms.TextBox txtVoid;
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.DataGridView dgvSale;
private System.Windows.Forms.DateTimePicker dtpFinish;
private System.Windows.Forms.DateTimePicker dtpStart;

View File

@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Tanshu.Accounts.Repository;
using Tanshu.Accounts.Contracts;
using Tanshu.Accounts.Helpers;
using System.Linq;
namespace Tanshu.Accounts.PointOfSale
{
public partial class frmSaleDetail : Form
{
IList<SalesAnalysisDetail> list;
//private static readonly Tanshu.Logging.SqlLogger log = new Tanshu.Logging.SqlLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public frmSaleDetail()
{
InitializeComponent();
//log.Warn(string.Format("Sales Analysis by: {0}", Session.User.Name));
}
private void dtpStart_ValueChanged(object sender, EventArgs e)
{
ShowStatement();
}
private void ShowStatement()
{
list = new SalesAnalysisBI().GetSaleDetail(dtpStart.Value, dtpFinish.Value).ToList();
dgvSale.AutoGenerateColumns = true;
dgvSale.DataSource = list;
dgvSale.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
dgvSale.Columns[1].DefaultCellStyle.Format = "#,##0.00;(#,##0.00);0";
dgvSale.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
dgvSale.Columns[2].DefaultCellStyle.Format = "#,##0.00;(#,##0.00);0";
dgvSale.Columns[2].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
}
private void dtpFinish_ValueChanged(object sender, EventArgs e)
{
ShowStatement();
}
private void Sale_Analysis_Form_Load(object sender, EventArgs e)
{
dtpStart.Value = DateTime.Today;
dtpFinish.Value = DateTime.Today;
ShowStatement();
}
private void btnPrint_Click(object sender, EventArgs e)
{
if (list != null)
{
var startDate = dtpStart.Value.Date.AddHours(6);
var finishDate = dtpFinish.Value.Date.AddDays(1).AddHours(5);
Accounts.Print.Thermal.PrintSale(Session.User.Name, list, startDate, finishDate);
}
}
}
}

View File

@ -0,0 +1,128 @@
namespace Tanshu.Accounts.PointOfSale
{
partial class frmSaleDetail
{
/// <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.dgvSale = new System.Windows.Forms.DataGridView();
this.dtpFinish = new System.Windows.Forms.DateTimePicker();
this.dtpStart = new System.Windows.Forms.DateTimePicker();
this.label10 = new System.Windows.Forms.Label();
this.btnPrint = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dgvSale)).BeginInit();
this.SuspendLayout();
//
// dgvSale
//
this.dgvSale.AllowUserToAddRows = false;
this.dgvSale.AllowUserToDeleteRows = false;
this.dgvSale.AllowUserToResizeRows = false;
this.dgvSale.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.dgvSale.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgvSale.Location = new System.Drawing.Point(12, 41);
this.dgvSale.MultiSelect = false;
this.dgvSale.Name = "dgvSale";
this.dgvSale.ReadOnly = true;
this.dgvSale.RowHeadersVisible = false;
this.dgvSale.RowTemplate.Height = 19;
this.dgvSale.RowTemplate.ReadOnly = true;
this.dgvSale.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.dgvSale.Size = new System.Drawing.Size(335, 466);
this.dgvSale.TabIndex = 14;
//
// dtpFinish
//
this.dtpFinish.CustomFormat = "dd-MMM-yyyy";
this.dtpFinish.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.dtpFinish.Location = new System.Drawing.Point(168, 12);
this.dtpFinish.Name = "dtpFinish";
this.dtpFinish.Size = new System.Drawing.Size(90, 20);
this.dtpFinish.TabIndex = 21;
this.dtpFinish.ValueChanged += new System.EventHandler(this.dtpFinish_ValueChanged);
//
// dtpStart
//
this.dtpStart.CustomFormat = "dd-MMM-yyyy";
this.dtpStart.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.dtpStart.Location = new System.Drawing.Point(12, 12);
this.dtpStart.Name = "dtpStart";
this.dtpStart.Size = new System.Drawing.Size(90, 20);
this.dtpStart.TabIndex = 20;
this.dtpStart.ValueChanged += new System.EventHandler(this.dtpStart_ValueChanged);
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(108, 16);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(54, 13);
this.label10.TabIndex = 22;
this.label10.Text = "<- Date ->";
//
// btnPrint
//
this.btnPrint.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnPrint.Location = new System.Drawing.Point(272, 12);
this.btnPrint.Name = "btnPrint";
this.btnPrint.Size = new System.Drawing.Size(75, 23);
this.btnPrint.TabIndex = 28;
this.btnPrint.Text = "Print";
this.btnPrint.UseVisualStyleBackColor = true;
this.btnPrint.Click += new System.EventHandler(this.btnPrint_Click);
//
// frmSaleDetail
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(359, 519);
this.Controls.Add(this.btnPrint);
this.Controls.Add(this.dgvSale);
this.Controls.Add(this.dtpFinish);
this.Controls.Add(this.dtpStart);
this.Controls.Add(this.label10);
this.MaximizeBox = false;
this.Name = "frmSaleDetail";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Sale Detail";
this.Load += new System.EventHandler(this.Sale_Analysis_Form_Load);
((System.ComponentModel.ISupportInitialize)(this.dgvSale)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.DataGridView dgvSale;
private System.Windows.Forms.DateTimePicker dtpFinish;
private System.Windows.Forms.DateTimePicker dtpStart;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.Button btnPrint;
}
}

View File

@ -11,227 +11,148 @@ using Tanshu.Accounts.Entities;
namespace Tanshu.Accounts.PointOfSale
{
public static class BillHelperFunctions
public class BillHelperFunctions
{
#region Discount
public static void SetDiscount(int productID, decimal discount, Customer customer, OrderedDictionary<BillItemKey, BillInventory> bill)
BindingSource bindingSource;
OrderedDictionary<BillItemKey, BillInventory> bill;
BillItemKey oldKey;
BillItemKey newKey;
public BillHelperFunctions(BindingSource bindingSource, OrderedDictionary<BillItemKey, BillInventory> bill, int productID)
{
#region InputBox
if (discount == -1)
{
InputBoxResult result = InputBox.Show("Discount", "0", InputBox_Validating);
if (result.OK)
{
if (!decimal.TryParse(result.Text, out discount))
return;
discount /= 100;
}
}
if (discount == -1)
this.bindingSource = bindingSource;
this.bill = bill;
this.oldKey = new BillItemKey(productID, false);
this.newKey = new BillItemKey(productID, true);
}
public void SetDiscount(string name, decimal discount)
{
if (discount > 1 || discount < 0)
return;
#endregion
#region Max Discount
decimal maxDiscount = SaleVoucherBI.GetProductDiscountLimit(productID);
if ((discount > maxDiscount) && customer.CustomerID != 1)
{
MessageBox.Show(string.Format("Maximum discount for this product is {0:P}", maxDiscount), "Excessive Discount", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else if ((discount > maxDiscount) && customer.CustomerID == 1)
{
MessageBox.Show(string.Format("Maximum discount for this product is {0:P} Discount Disallowed", maxDiscount), "Excessive Discount", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
#endregion
if (bill.ContainsKey(new BillItemKey(productID, true)))
SetDiscount(bill[new BillItemKey(productID, true)], discount);
if (bill.ContainsKey(new BillItemKey(productID, false)))
SetDiscount(bill[new BillItemKey(productID, false)], discount);
decimal maxDiscount = SaleVoucherBI.GetProductDiscountLimit(newKey.ProductID);
if (discount > maxDiscount)
MessageBox.Show(string.Format("Maximum discount for {0} is {1:P}", name, maxDiscount), "Excessive Discount", MessageBoxButtons.OK, MessageBoxIcon.Warning);
if (bill.ContainsKey(oldKey))
bill[oldKey].Discount = discount;
if (bill.ContainsKey(newKey))
bill[newKey].Discount = discount;
return;
}
private static void SetDiscount(BillInventory product, decimal discount)
{
product.Discount = discount;
}
#endregion
#region Add Product
public static BillInventory AddProductToGrid(int productID, BindingSource bindingSource, OrderedDictionary<BillItemKey, BillInventory> bill)
public BillInventory AddProduct()
{
BillInventory product;
if ((!bill.ContainsKey(new BillItemKey(productID, false))) && (!bill.ContainsKey(new BillItemKey(productID, true))))
if ((!bill.ContainsKey(oldKey)) && (!bill.ContainsKey(newKey)))
{
//No new or old
product = AddNewProduct(productID, bindingSource, bill);
product = SaleVoucherBI.GetDefaultSaleBillItem(newKey.ProductID);
product = AddProduct(product);
}
else if (bill.ContainsKey(new BillItemKey(productID, true)))
else if (bill.ContainsKey(newKey))
{
//Has new or both
BillItemKey key = new BillItemKey(productID, true);
bindingSource.CurrencyManager.Position = ProductPosition(key, bill);
product = bill[key];
SetQuantity(product, 1, false);
bindingSource.CurrencyManager.Position = bill.IndexOfKey(newKey);
product = bill[newKey];
product.Quantity += 1;
}
else
{
//Has only old
product = bill[new BillItemKey(productID, false)];
if (product.Additional <= -1)
SetQuantity(product, 1, false);
else if (product.Additional < 0)
{
decimal quantity = 1 + product.Additional;
SetQuantity(product, 1, false);
decimal rate = bill[new BillItemKey(productID, false)].Discount;
decimal discount = bill[new BillItemKey(productID, false)].Price;
product = AddNewProduct(productID, bindingSource, bill);
SetDiscount(product, discount);
SetRate(productID, rate, bill);
SetQuantity(product, quantity, true);
}
else
{
decimal discount = bill[new BillItemKey(productID, false)].Discount;
decimal rate = bill[new BillItemKey(productID, false)].Price;
product = AddNewProduct(productID, bindingSource, bill);
SetDiscount(product, discount);
SetRate(productID, rate, bill);
}
product = SaleVoucherBI.GetDefaultSaleBillItem(oldKey.ProductID);
product.Discount = bill[oldKey].Discount;
product.Price = bill[oldKey].Price;
product = AddProduct(product);
}
return product;
}
private static BillInventory AddNewProduct(int productID, BindingSource bindingSource, OrderedDictionary<BillItemKey, BillInventory> bill)
private BillInventory AddProduct(BillInventory product)
{
BillItemKey key = new BillItemKey(productID, true);
BillInventory product = SaleVoucherBI.GetDefaultSaleBillItem(productID);
product.Quantity = 1;
bill.Add(key, product);
bill.Add(new BillItemKey(product.ProductID, true), product);
bindingSource.DataSource = bill.Values;
bindingSource.CurrencyManager.Position = bindingSource.CurrencyManager.Count + 1;
return product;
}
private static int ProductPosition(BillItemKey key, OrderedDictionary<BillItemKey, BillInventory> bill)
{
for (int i = 0; i < bill.Count; i++)
{
if (bill.Keys.ElementAt(i) == key)
return i;
}
return 0;
}
#endregion
#region Quantity
public static void SetQuantity(BillInventory product, decimal quantity, bool absolute, bool prompt, BindingSource bindingSource, OrderedDictionary<BillItemKey, BillInventory> bill)
public void SetQuantity(BillInventory product, decimal quantity, bool prompt)
{
#region Prompt
if (prompt)
{
InputBoxResult result = InputBox.Show("Quantity", (product.Quantity + 1).ToString(), InputBox_Validating);
if (result.OK)
{
if (!decimal.TryParse(result.Text, out quantity))
return;
absolute = true;
}
}
if (quantity == 0)
if (prompt && !GetInput("Price", ref quantity))
return;
#endregion
CheckQuantity(product, quantity, absolute);
if (product.Printed == 0)
{
SetQuantity(product, quantity, absolute);
{ // new
if (!prompt)
quantity += product.Quantity;
SetQuantity(product, quantity);
}
else if (bill.ContainsKey(new BillItemKey(product.ProductID, true)))
else if (bill.ContainsKey(newKey))
{
BillInventory otherProduct = bill[new BillItemKey(product.ProductID, true)];
if (absolute)
SetQuantity(otherProduct, quantity - product.Printed, absolute);
BillInventory newProduct = bill[newKey];
if (prompt)
SetQuantity(newProduct, quantity - product.Printed);
else
SetQuantity(otherProduct, quantity, absolute);
SetQuantity(newProduct, newProduct.Quantity + quantity);
}
else
{
if (product.Additional < 0)
////Has only old
if (prompt)
quantity -= product.Printed;
if (quantity > 0 || Session.IsAllowed(RoleConstants.EDIT_PRINTED_PRODUCT))
{
if (!absolute)
quantity += product.Additional;
product.Quantity = product.Printed;
}
if (absolute)
quantity -= product.Quantity;
if (quantity > 0)
{
BillInventory otherProduct = AddProductToGrid(product.ProductID, bindingSource, bill);
SetQuantity(otherProduct, quantity, true);
}
else if ((quantity < 0) && (Thread.CurrentPrincipal.IsInRole("Sales/EditPrintedProduct")))
{
SetQuantity(product, quantity, false);
var newProduct = SaleVoucherBI.GetDefaultSaleBillItem(product.ProductID);
newProduct.Price = product.Price;
newProduct.Discount = product.Discount;
newProduct = AddProduct(newProduct);
SetQuantity(newProduct, quantity);
}
}
}
private static bool CheckQuantity(BillInventory product, decimal quantity, bool absolute)
private void SetQuantity(BillInventory product, decimal quantity)
{
if (!absolute)
quantity = product.Quantity + quantity;
if (quantity < 0)
return false;
else if ((quantity < product.Printed) && (!Thread.CurrentPrincipal.IsInRole("Sales/EditPrintedProduct")))
return false;
else
return true;
}
private static void SetQuantity(BillInventory product, decimal quantity, bool absolute)
{
if (!absolute)
{
quantity = product.Quantity + quantity;
}
if (quantity <= 0)
if (quantity < 0 && !Session.IsAllowed(RoleConstants.EDIT_PRINTED_PRODUCT))
return;
if (bill.ContainsKey(oldKey))
{
var totalQuantity = bill[oldKey].Quantity + quantity;
if (totalQuantity < 0)
quantity += 0 - totalQuantity;
}
product.Quantity = quantity;
}
#endregion
#region Amount
public static void SetAmount(BillInventory product, decimal amount, BindingSource bindingSource, OrderedDictionary<BillItemKey, BillInventory> bill)
public void SetPrice(BillInventory product)
{
if (amount == -1)
{
InputBoxResult result = InputBox.Show("Amount", (product.Value).ToString(), InputBox_Validating);
if (result.OK)
{
amount = Convert.ToDecimal(result.Text);
}
}
if (amount == -1)
if (!Allowed(product, RoleConstants.CHANGE_RATE))
return;
else
{
SetQuantity(product, amount / (product.Price * (1 + product.Tax) * (1 - product.Discount)), true, false, bindingSource, bill);
}
decimal rate = product.Price;
if (!GetInput("Price", ref rate))
return;
if (rate == 0 && !Session.IsAllowed(RoleConstants.ZERO_RATE))
return;
if (bill.ContainsKey(new BillItemKey(product.ProductID, true)))
bill[new BillItemKey(product.ProductID, true)].Price = rate;
if (bill.ContainsKey(new BillItemKey(product.ProductID, false)))
bill[new BillItemKey(product.ProductID, false)].Price = rate;
}
#endregion
#region Rate
public static void SetRate(int productID, decimal rate, OrderedDictionary<BillItemKey, BillInventory> bill)
{
if (bill.ContainsKey(new BillItemKey(productID, true)))
bill[new BillItemKey(productID, true)].Price = rate;
if (bill.ContainsKey(new BillItemKey(productID, false)))
bill[new BillItemKey(productID, false)].Price = rate;
}
#endregion
private static void InputBox_Validating(object sender, InputBoxValidatingArgs e)
private void InputBox_Validating(object sender, InputBoxValidatingArgs e)
{
}
private bool Allowed(BillInventory item, RoleConstants role)
{
if (item == null)
return false;
if (!Session.IsAllowed(role))
return false;
return true;
}
private bool GetInput(string prompt, ref decimal amount)
{
InputBoxResult result = InputBox.Show(prompt, amount.ToString(), InputBox_Validating);
if (!result.OK)
return false;
if (!decimal.TryParse(result.Text, out amount))
return false;
return true;
}
}
}

View File

@ -51,8 +51,8 @@
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.flpModifier);
this.splitContainer1.Size = new System.Drawing.Size(619, 492);
this.splitContainer1.SplitterDistance = 230;
this.splitContainer1.Size = new System.Drawing.Size(847, 492);
this.splitContainer1.SplitterDistance = 232;
this.splitContainer1.TabIndex = 2;
//
// numpadControl1
@ -76,14 +76,14 @@
this.flpModifier.Dock = System.Windows.Forms.DockStyle.Fill;
this.flpModifier.Location = new System.Drawing.Point(0, 0);
this.flpModifier.Name = "flpModifier";
this.flpModifier.Size = new System.Drawing.Size(385, 492);
this.flpModifier.Size = new System.Drawing.Size(611, 492);
this.flpModifier.TabIndex = 6;
//
// DiscountForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(619, 492);
this.ClientSize = new System.Drawing.Size(847, 492);
this.ControlBox = false;
this.Controls.Add(this.splitContainer1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;

View File

@ -27,12 +27,6 @@ namespace Tanshu.Accounts.PointOfSale
billController.InitGui(this);
}
public SalesForm(int voucherID, BillController billController)
: this(billController)
{
billController.SetNewBillID(voucherID);
}
public void SetUserName(string name)
{
this.Text = name;
@ -43,10 +37,7 @@ namespace Tanshu.Accounts.PointOfSale
{
case Keys.F2:
{
if (dgvProducts.Rows.Count > 0)
{
billController.SetQuantity(billController.CurrentProduct, 0, false, true);
}
btnQuantity_Click(sender, new EventArgs());
break;
}
case Keys.F3:
@ -80,14 +71,6 @@ namespace Tanshu.Accounts.PointOfSale
billController.LoadBillFromTable(null);
break;
}
case Keys.F9:
{
if (dgvProducts.Rows.Count > 0)
{
billController.SetAmount(billController.CurrentProduct, -1);
}
break;
}
case Keys.F11:
{
btnPrintBill_Click(sender, e);
@ -100,20 +83,17 @@ namespace Tanshu.Accounts.PointOfSale
}
case Keys.Delete:
{
if (dgvProducts.Rows.Count > 0)
billController.ProductRemove(billController.CurrentProduct);
billController.ProductRemove();
break;
}
case Keys.Add:
{
if (dgvProducts.Rows.Count > 0)
billController.SetQuantity(billController.CurrentProduct, 1, false, false);
billController.SetQuantity(1, false);
break;
}
case Keys.Subtract:
{
if (dgvProducts.Rows.Count > 0)
billController.SetQuantity(billController.CurrentProduct, -1, false, false);
billController.SetQuantity(-1, false);
break;
}
case Keys.Up:
@ -257,13 +237,6 @@ namespace Tanshu.Accounts.PointOfSale
btnWaiter.Tag = WaiterBI.GetWaiters()[0].WaiterID;
billController.Save(false, (int)btnWaiter.Tag, txtTableID.Text);
}
private void btnMultiPrint_Click(object sender, EventArgs e)
{
if (btnWaiter.Tag == null)
btnWaiter.Tag = WaiterBI.GetWaiters()[0].WaiterID;
billController.Save(true, (int)btnWaiter.Tag, txtTableID.Text);
}
private void btnCancel_Click(object sender, EventArgs e)
{
billController.CancelBillChanges();
@ -271,10 +244,7 @@ namespace Tanshu.Accounts.PointOfSale
private void btnQuantity_Click(object sender, EventArgs e)
{
if (dgvProducts.Rows.Count > 0)
{
billController.SetQuantity(billController.CurrentProduct, 0, false, true);
}
billController.SetQuantity(0, true);
}
private void btnDiscount_Click(object sender, EventArgs e)
{
@ -333,14 +303,11 @@ namespace Tanshu.Accounts.PointOfSale
}
private void btnRate_Click(object sender, EventArgs e)
{
if (dgvProducts.Rows.Count > 0)
{
billController.ChangeRate();
}
billController.ChangeRate();
}
private void btnClear_Click(object sender, EventArgs e)
{
billController.ClearBill();
billController.CancelBillChanges();
}
private void dgvProducts_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
@ -414,14 +381,21 @@ namespace Tanshu.Accounts.PointOfSale
private void btnModifier_Click(object sender, EventArgs e)
{
var item = billController.CurrentProduct;
if (item == null)
return;
var id = new ProductGroupBI().GetProductGroupOfProduct(item.ProductID).ProductGroupID;
billController.ShowModifiers(id, item);
}
private void btnDelete_Click(object sender, EventArgs e)
{
if (dgvProducts.Rows.Count > 0)
billController.ProductRemove(billController.CurrentProduct);
if (dgvProducts.Rows.Count <= 0)
return;
var p = billController.CurrentProduct;
if (p.Quantity > 1)
billController.SetQuantity(-1, false);
else
billController.ProductRemove();
}
}
}

View File

@ -55,10 +55,6 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Include\Fluent\Castle.Core.dll</HintPath>
</Reference>
<Reference Include="Castle.Windsor, Version=2.5.1.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Include\Windsor\Castle.Windsor.dll</HintPath>
</Reference>
<Reference Include="FluentNHibernate, Version=1.2.0.694, Culture=neutral, PublicKeyToken=8aa435e3cb308880, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Include\Fluent\FluentNHibernate.dll</HintPath>
@ -112,7 +108,6 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Authentication\PermissionException.cs" />
<Compile Include="Authentication\Session.cs" />
<Compile Include="Authentication\KeyboardLogin.cs" />
<Compile Include="Authentication\ILogin.cs" />
<Compile Include="Controllers\BillController.cs" />
@ -123,6 +118,12 @@
<Compile Include="CurrencyCounter.Designer.cs">
<DependentUpon>CurrencyCounter.cs</DependentUpon>
</Compile>
<Compile Include="Reports\SaleDetail.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Reports\SaleDetail.designer.cs">
<DependentUpon>SaleDetail.cs</DependentUpon>
</Compile>
<Compile Include="Sales\BillHelperFunctions.cs" />
<Compile Include="Sales\BillSettleForm.cs">
<SubType>Form</SubType>
@ -148,11 +149,11 @@
<Compile Include="Sales\ModifierForm.Designer.cs">
<DependentUpon>ModifierForm.cs</DependentUpon>
</Compile>
<Compile Include="User Management\AssignRoles.cs">
<Compile Include="User Management\AssignUserGroups.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="User Management\AssignRoles.Designer.cs">
<DependentUpon>AssignRoles.cs</DependentUpon>
<Compile Include="User Management\AssignUserGroups.Designer.cs">
<DependentUpon>AssignUserGroups.cs</DependentUpon>
</Compile>
<Compile Include="User Management\ChangePassword.cs">
<SubType>Form</SubType>
@ -185,6 +186,12 @@
<Compile Include="MainForm.designer.cs">
<DependentUpon>MainForm.cs</DependentUpon>
</Compile>
<Compile Include="User Management\AssignRoleGroups.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="User Management\AssignRoleGroups.Designer.cs">
<DependentUpon>AssignRoleGroups.cs</DependentUpon>
</Compile>
<Compile Include="User Management\RoleFactoryBI.cs" />
<Compile Include="User Management\UserForm.cs">
<SubType>Form</SubType>
@ -209,6 +216,10 @@
<EmbeddedResource Include="CurrencyCounter.resx">
<DependentUpon>CurrencyCounter.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Reports\SaleDetail.resx">
<DependentUpon>SaleDetail.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Sales\BillSettleForm.resx">
<DependentUpon>BillSettleForm.cs</DependentUpon>
</EmbeddedResource>
@ -222,8 +233,8 @@
<EmbeddedResource Include="Sales\ModifierForm.resx">
<DependentUpon>ModifierForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="User Management\AssignRoles.resx">
<DependentUpon>AssignRoles.cs</DependentUpon>
<EmbeddedResource Include="User Management\AssignUserGroups.resx">
<DependentUpon>AssignUserGroups.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="User Management\ChangePassword.resx">
@ -246,6 +257,10 @@
<DependentUpon>MainForm.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="User Management\AssignRoleGroups.resx">
<DependentUpon>AssignRoleGroups.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="User Management\UserForm.resx">
<DependentUpon>UserForm.cs</DependentUpon>
<SubType>Designer</SubType>

View File

@ -0,0 +1,180 @@
namespace Tanshu.Accounts.PointOfSale
{
partial class AssignGroupRoles
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.lstRoles = new System.Windows.Forms.ListBox();
this.lstGroupRoles = new System.Windows.Forms.ListBox();
this.cmbGroup = new System.Windows.Forms.ComboBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.btnAddSelected = new System.Windows.Forms.Button();
this.btnAddAll = new System.Windows.Forms.Button();
this.btnRemoveSelected = new System.Windows.Forms.Button();
this.btnRemoveAll = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// lstGroups
//
this.lstRoles.FormattingEnabled = true;
this.lstRoles.Location = new System.Drawing.Point(12, 59);
this.lstRoles.Name = "lstGroups";
this.lstRoles.ScrollAlwaysVisible = true;
this.lstRoles.Size = new System.Drawing.Size(183, 225);
this.lstRoles.TabIndex = 0;
//
// lstUserGroups
//
this.lstGroupRoles.FormattingEnabled = true;
this.lstGroupRoles.Location = new System.Drawing.Point(274, 59);
this.lstGroupRoles.Name = "lstUserGroups";
this.lstGroupRoles.ScrollAlwaysVisible = true;
this.lstGroupRoles.Size = new System.Drawing.Size(183, 225);
this.lstGroupRoles.TabIndex = 1;
//
// cmbGroup
//
this.cmbGroup.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbGroup.FormattingEnabled = true;
this.cmbGroup.Location = new System.Drawing.Point(82, 12);
this.cmbGroup.Name = "cmbGroup";
this.cmbGroup.Size = new System.Drawing.Size(375, 21);
this.cmbGroup.TabIndex = 2;
this.cmbGroup.SelectedIndexChanged += new System.EventHandler(this.cmbUsers_SelectedIndexChanged);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(9, 12);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(67, 13);
this.label1.TabIndex = 4;
this.label1.Text = "Group Name";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 43);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(76, 13);
this.label2.TabIndex = 5;
this.label2.Text = "Pending Roles";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(271, 43);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(80, 13);
this.label3.TabIndex = 6;
this.label3.Text = "Assigned Roles";
//
// btnAddSelected
//
this.btnAddSelected.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnAddSelected.Location = new System.Drawing.Point(201, 105);
this.btnAddSelected.Name = "btnAddSelected";
this.btnAddSelected.Size = new System.Drawing.Size(67, 25);
this.btnAddSelected.TabIndex = 7;
this.btnAddSelected.Text = ">";
this.btnAddSelected.UseVisualStyleBackColor = true;
this.btnAddSelected.Click += new System.EventHandler(this.btnAddSelected_Click);
//
// btnAddAll
//
this.btnAddAll.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnAddAll.Location = new System.Drawing.Point(201, 136);
this.btnAddAll.Name = "btnAddAll";
this.btnAddAll.Size = new System.Drawing.Size(67, 25);
this.btnAddAll.TabIndex = 8;
this.btnAddAll.Text = ">>";
this.btnAddAll.UseVisualStyleBackColor = true;
this.btnAddAll.Click += new System.EventHandler(this.btnAddAll_Click);
//
// btnRemoveSelected
//
this.btnRemoveSelected.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnRemoveSelected.Location = new System.Drawing.Point(201, 167);
this.btnRemoveSelected.Name = "btnRemoveSelected";
this.btnRemoveSelected.Size = new System.Drawing.Size(67, 25);
this.btnRemoveSelected.TabIndex = 9;
this.btnRemoveSelected.Text = "<";
this.btnRemoveSelected.UseVisualStyleBackColor = true;
this.btnRemoveSelected.Click += new System.EventHandler(this.btnRemoveSelected_Click);
//
// btnRemoveAll
//
this.btnRemoveAll.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnRemoveAll.Location = new System.Drawing.Point(201, 198);
this.btnRemoveAll.Name = "btnRemoveAll";
this.btnRemoveAll.Size = new System.Drawing.Size(67, 25);
this.btnRemoveAll.TabIndex = 10;
this.btnRemoveAll.Text = "<<";
this.btnRemoveAll.UseVisualStyleBackColor = true;
this.btnRemoveAll.Click += new System.EventHandler(this.btnRemoveAll_Click);
//
// AssignGroupRoles
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(469, 323);
this.Controls.Add(this.btnRemoveAll);
this.Controls.Add(this.btnRemoveSelected);
this.Controls.Add(this.btnAddAll);
this.Controls.Add(this.btnAddSelected);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.cmbGroup);
this.Controls.Add(this.lstGroupRoles);
this.Controls.Add(this.lstRoles);
this.MaximizeBox = false;
this.Name = "AssignGroupRoles";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Assign Role Groups";
this.Load += new System.EventHandler(this.AssignGroupRoles_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.ListBox lstRoles;
private System.Windows.Forms.ListBox lstGroupRoles;
private System.Windows.Forms.ComboBox cmbGroup;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Button btnAddSelected;
private System.Windows.Forms.Button btnAddAll;
private System.Windows.Forms.Button btnRemoveSelected;
private System.Windows.Forms.Button btnRemoveAll;
}
}

View File

@ -0,0 +1,119 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Tanshu.Accounts.Helpers;
using System.Threading;
using Tanshu.Accounts.Repository;
using Tanshu.Accounts.Entities.Auth;
namespace Tanshu.Accounts.PointOfSale
{
public partial class AssignGroupRoles : Form
{
public AssignGroupRoles()
{
InitializeComponent();
}
private void AssignGroupRoles_Load(object sender, EventArgs e)
{
FillUsers();
}
private void FillUsers()
{
cmbGroup.DisplayMember = "Name";
cmbGroup.ValueMember = "GroupID";
cmbGroup.DataSource = MembershipBI.GetGroups();
}
private void cmbUsers_SelectedIndexChanged(object sender, EventArgs e)
{
GetLists();
}
private void GetLists()
{
IList<Role> roles;
IList<Role> roleGroups;
if (cmbGroup.SelectedValue == null)
{
roles = MembershipBI.GetRoles();
roleGroups = new List<Role>();
}
else
{
int groupID = (int)cmbGroup.SelectedValue;
roles = MembershipBI.GetRolesNotOfGroup(groupID);
roleGroups = MembershipBI.GetRolesOfGroup(groupID);
}
RefreshRoles(roles, roleGroups);
}
private void RefreshRoles(IList<Role> roles, IList<Role> roleGroups)
{
lstRoles.DisplayMember = "Name";
lstRoles.ValueMember = "RoleID";
lstRoles.DataSource = roles;
lstGroupRoles.DisplayMember = "Name";
lstGroupRoles.ValueMember = "RoleID";
lstGroupRoles.DataSource = roleGroups;
btnAddAll.Enabled = btnAddSelected.Enabled = roles.Count > 0;
btnRemoveAll.Enabled = btnRemoveSelected.Enabled = roleGroups.Count > 0;
}
private void btnAddSelected_Click(object sender, EventArgs e)
{
if (lstRoles.SelectedItem != null)
{
int groupID = (int)cmbGroup.SelectedValue;
int roleID = (int)lstRoles.SelectedValue;
MembershipBI.AddRoleToGroup(roleID, groupID);
GetLists();
}
}
private void btnRemoveSelected_Click(object sender, EventArgs e)
{
if (lstGroupRoles.SelectedItem != null)
{
int groupID = (int)cmbGroup.SelectedValue;
int roleID = (int)lstGroupRoles.SelectedValue;
MembershipBI.RemoveRoleFromGroup(roleID, groupID);
GetLists();
}
}
private void btnAddAll_Click(object sender, EventArgs e)
{
int groupID = (int)cmbGroup.SelectedValue;
int roleID;
for (int i = 0; i <= lstRoles.Items.Count - 1; i++)
{
roleID = ((Role)lstRoles.Items[i]).RoleID;
MembershipBI.AddRoleToGroup(roleID, groupID);
}
GetLists();
}
private void btnRemoveAll_Click(object sender, EventArgs e)
{
int groupID = (int)cmbGroup.SelectedValue;
int roleID;
for (int i = 0; i <= lstGroupRoles.Items.Count - 1; i++)
{
roleID = ((Role)lstGroupRoles.Items[i]).RoleID;
MembershipBI.RemoveRoleFromGroup(roleID, groupID);
}
GetLists();
}
}
}

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

@ -1,120 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Tanshu.Accounts.Helpers;
using System.Threading;
using Tanshu.Accounts.Repository;
namespace Tanshu.Accounts.PointOfSale
{
public partial class AssignRoles : Form
{
public AssignRoles()
{
InitializeComponent();
}
private void AssignRoles_Load(object sender, EventArgs e)
{
FillUsers();
}
private void FillUsers()
{
cmbUsers.DisplayMember = "Name";
cmbUsers.ValueMember = "UserID";
cmbUsers.DataSource = UserBI.GetUsers();
}
private void cmbUsers_SelectedIndexChanged(object sender, EventArgs e)
{
RefreshRoles();
}
private void RefreshRoles()
{
if (cmbUsers.SelectedValue == null)
{
string[] roles = new MembershipBI().GetAllRoles();
lstRoles.DataSource = roles;
// lstRoles.DataBind();
string[] userRoles = new string[0];
lstUserRoles.DataSource = userRoles;
// lstUserRoles.DataBind();
btnAddAll.Enabled = false;
btnAddSelected.Enabled = false;
btnRemoveAll.Enabled = false;
btnRemoveSelected.Enabled = false;
}
else
{
string[] roles = new MembershipBI().GetAllRoles();
string[] userRoles = new MembershipBI().GetRolesForUser(cmbUsers.Text.Trim());
roles = roles.Where(r => !userRoles.Contains(r)).ToArray();
lstRoles.DataSource = roles;
// lstRoles.DataBind();
lstUserRoles.DataSource = userRoles;
// lstUserRoles.DataBind();
btnAddAll.Enabled = true;
btnAddSelected.Enabled = true;
btnRemoveAll.Enabled = true;
btnRemoveSelected.Enabled = true;
}
}
private void btnAddSelected_Click(object sender, EventArgs e)
{
//if (lstRoles.SelectedItem != null)
//{
// new MembershipBI().AddUsersToRoles(new string[] { cmbUsers.Text.Trim() }, new string[] { lstRoles.SelectedItem.ToString() });
// RefreshRoles();
//}
}
private void btnRemoveSelected_Click(object sender, EventArgs e)
{
//if (lstUserRoles.SelectedItem != null)
//{
// new MembershipBI().RemoveUsersFromRoles(new string[] { cmbUsers.Text.Trim() }, new string[] { lstUserRoles.SelectedItem.ToString() });
// RefreshRoles();
//}
}
private void btnAddAll_Click(object sender, EventArgs e)
{
//for (int i = 0; i <= lstRoles.Items.Count - 1; i++)
//{
// new MembershipBI().AddUsersToRoles(new string[] { cmbUsers.Text.Trim() }, new string[] { lstRoles.Items[i].ToString() });
//}
//RefreshRoles();
}
private void btnRemoveAll_Click(object sender, EventArgs e)
{
//for (int i = 0; i <= lstUserRoles.Items.Count - 1; i++)
//{
// new MembershipBI().RemoveUsersFromRoles(new string[] { cmbUsers.Text.Trim() }, new string[] { lstUserRoles.Items[i].ToString() });
//}
//RefreshRoles();
}
private void AssignRoles_FormClosing(object sender, FormClosingEventArgs e)
{
//string userName = Thread.CurrentPrincipal.Identity.Name;
//AccountsPrincipal principal = AccountsPrincipal.CreateAccountsPrincipal(new MembershipBI().GetRolesForUser(userName), new MembershipBI().GetUserFromName(userName));
//// bind the generic principal to the thread
//Thread.CurrentPrincipal = principal;
}
}
}

View File

@ -1,6 +1,6 @@
namespace Tanshu.Accounts.PointOfSale
{
partial class AssignRoles
partial class AssignUserGroups
{
/// <summary>
/// Required designer variable.
@ -28,8 +28,8 @@
/// </summary>
private void InitializeComponent()
{
this.lstRoles = new System.Windows.Forms.ListBox();
this.lstUserRoles = new System.Windows.Forms.ListBox();
this.lstGroups = new System.Windows.Forms.ListBox();
this.lstUserGroups = new System.Windows.Forms.ListBox();
this.cmbUsers = new System.Windows.Forms.ComboBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
@ -40,28 +40,30 @@
this.btnRemoveAll = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// lstRoles
// lstGroups
//
this.lstRoles.FormattingEnabled = true;
this.lstRoles.Location = new System.Drawing.Point(12, 59);
this.lstRoles.Name = "lstRoles";
this.lstRoles.Size = new System.Drawing.Size(183, 225);
this.lstRoles.TabIndex = 0;
this.lstGroups.FormattingEnabled = true;
this.lstGroups.Location = new System.Drawing.Point(12, 59);
this.lstGroups.Name = "lstGroups";
this.lstGroups.ScrollAlwaysVisible = true;
this.lstGroups.Size = new System.Drawing.Size(183, 225);
this.lstGroups.TabIndex = 0;
//
// lstUserRoles
// lstUserGroups
//
this.lstUserRoles.FormattingEnabled = true;
this.lstUserRoles.Location = new System.Drawing.Point(274, 59);
this.lstUserRoles.Name = "lstUserRoles";
this.lstUserRoles.Size = new System.Drawing.Size(183, 225);
this.lstUserRoles.TabIndex = 1;
this.lstUserGroups.FormattingEnabled = true;
this.lstUserGroups.Location = new System.Drawing.Point(274, 59);
this.lstUserGroups.Name = "lstUserGroups";
this.lstUserGroups.ScrollAlwaysVisible = true;
this.lstUserGroups.Size = new System.Drawing.Size(183, 225);
this.lstUserGroups.TabIndex = 1;
//
// cmbUsers
// cmbGroup
//
this.cmbUsers.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbUsers.FormattingEnabled = true;
this.cmbUsers.Location = new System.Drawing.Point(72, 12);
this.cmbUsers.Name = "cmbUsers";
this.cmbUsers.Name = "cmbGroup";
this.cmbUsers.Size = new System.Drawing.Size(276, 21);
this.cmbUsers.TabIndex = 2;
this.cmbUsers.SelectedIndexChanged += new System.EventHandler(this.cmbUsers_SelectedIndexChanged);
@ -80,18 +82,18 @@
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 43);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(76, 13);
this.label2.Size = new System.Drawing.Size(83, 13);
this.label2.TabIndex = 5;
this.label2.Text = "Pending Roles";
this.label2.Text = "Pending Groups";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(271, 43);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(80, 13);
this.label3.Size = new System.Drawing.Size(87, 13);
this.label3.TabIndex = 6;
this.label3.Text = "Assigned Roles";
this.label3.Text = "Assigned Groups";
//
// btnAddSelected
//
@ -137,7 +139,7 @@
this.btnRemoveAll.UseVisualStyleBackColor = true;
this.btnRemoveAll.Click += new System.EventHandler(this.btnRemoveAll_Click);
//
// AssignRoles
// AssignUserGroups
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
@ -150,14 +152,13 @@
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.cmbUsers);
this.Controls.Add(this.lstUserRoles);
this.Controls.Add(this.lstRoles);
this.Controls.Add(this.lstUserGroups);
this.Controls.Add(this.lstGroups);
this.MaximizeBox = false;
this.Name = "AssignRoles";
this.Name = "AssignUserGroups";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "AssignRoles";
this.Text = "Assign User Groups";
this.Load += new System.EventHandler(this.AssignRoles_Load);
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.AssignRoles_FormClosing);
this.ResumeLayout(false);
this.PerformLayout();
@ -165,8 +166,8 @@
#endregion
private System.Windows.Forms.ListBox lstRoles;
private System.Windows.Forms.ListBox lstUserRoles;
private System.Windows.Forms.ListBox lstGroups;
private System.Windows.Forms.ListBox lstUserGroups;
private System.Windows.Forms.ComboBox cmbUsers;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;

View File

@ -0,0 +1,119 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Tanshu.Accounts.Helpers;
using System.Threading;
using Tanshu.Accounts.Repository;
using Tanshu.Accounts.Entities.Auth;
namespace Tanshu.Accounts.PointOfSale
{
public partial class AssignUserGroups : Form
{
public AssignUserGroups()
{
InitializeComponent();
}
private void AssignRoles_Load(object sender, EventArgs e)
{
FillUsers();
}
private void FillUsers()
{
cmbUsers.DisplayMember = "Name";
cmbUsers.ValueMember = "UserID";
cmbUsers.DataSource = UserBI.GetUsers();
}
private void cmbUsers_SelectedIndexChanged(object sender, EventArgs e)
{
GetLists();
}
private void GetLists()
{
IList<Group> groups;
IList<Group> userGroups;
if (cmbUsers.SelectedValue == null)
{
groups = MembershipBI.GetGroups();
userGroups = new List<Group>();
}
else
{
int userid = (int)cmbUsers.SelectedValue;
groups = MembershipBI.GetGroupsNotOfUser(userid);
userGroups = MembershipBI.GetGroupsOfUser(userid);
}
RefreshRoles(groups, userGroups);
}
private void RefreshRoles(IList<Group> groups, IList<Group> userGroups)
{
lstGroups.DisplayMember = "Name";
lstGroups.ValueMember = "GroupID";
lstGroups.DataSource = groups;
lstUserGroups.DisplayMember = "Name";
lstUserGroups.ValueMember = "GroupID";
lstUserGroups.DataSource = userGroups;
btnAddAll.Enabled = btnAddSelected.Enabled = groups.Count > 0;
btnRemoveAll.Enabled = btnRemoveSelected.Enabled = userGroups.Count > 0;
}
private void btnAddSelected_Click(object sender, EventArgs e)
{
if (lstGroups.SelectedItem != null)
{
int userID = (int)cmbUsers.SelectedValue;
int groupID = (int)lstGroups.SelectedValue;
MembershipBI.AddUserToGroup(userID, groupID);
GetLists();
}
}
private void btnRemoveSelected_Click(object sender, EventArgs e)
{
if (lstUserGroups.SelectedItem != null)
{
int userID = (int)cmbUsers.SelectedValue;
int groupID = (int)lstUserGroups.SelectedValue;
MembershipBI.RemoveUserFromGroup(userID, groupID);
GetLists();
}
}
private void btnAddAll_Click(object sender, EventArgs e)
{
int userID = (int)cmbUsers.SelectedValue;
int groupID;
for (int i = 0; i <= lstGroups.Items.Count - 1; i++)
{
groupID = ((Group)lstGroups.Items[i]).GroupID;
MembershipBI.AddUserToGroup(userID, groupID);
}
GetLists();
}
private void btnRemoveAll_Click(object sender, EventArgs e)
{
int userID = (int)cmbUsers.SelectedValue;
int groupID;
for (int i = 0; i <= lstUserGroups.Items.Count - 1; i++)
{
groupID = ((Group)lstUserGroups.Items[i]).GroupID;
MembershipBI.RemoveUserFromGroup(userID, groupID);
}
GetLists();
}
}
}

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

@ -136,7 +136,7 @@
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(287, 145);
this.ClientSize = new System.Drawing.Size(287, 185);
this.Controls.Add(this.button2);
this.Controls.Add(this.btnCreateUSer);
this.Controls.Add(this.txtConfirmPassword);

View File

@ -4,14 +4,29 @@ using Tanshu.Accounts.Repository;
using Tanshu.Accounts.Contracts;
using Tanshu.Accounts.Helpers;
using Tanshu.Accounts.Entities.Auth;
using Tanshu.Common.KeyboardControl;
namespace Tanshu.Accounts.PointOfSale
{
public partial class ChangePassword : Form
{
public ChangePassword()
IKeyboardControl keyboardControl;
public ChangePassword(IKeyboardControl keyboardControl)
{
InitializeComponent();
this.keyboardControl = keyboardControl;
var control = keyboardControl as UserControl;
if (control != null)
{
control.Location = new System.Drawing.Point(6, 140);
var border = (this.Width - this.ClientSize.Width) / 2;
var titlebarHeight = this.Height - this.ClientSize.Height - (2 * border);
this.Controls.Add(control);
this.Width = 6 + control.Width + 6 + (border * 2);
this.Height = titlebarHeight + 140 + control.Height + 6 + (border * 2);
}
}
private void ChangePassword_Load(object sender, EventArgs e)

View File

@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading;
using Tanshu.Accounts.Repository;
using Tanshu.Accounts.Contracts;
namespace Tanshu.Accounts.PointOfSale
{
@ -11,13 +12,13 @@ namespace Tanshu.Accounts.PointOfSale
{
private RoleFactoryBI()
{ }
public static RoleBI GetRoleBI(string roleID)
private static RoleBI GetRoleBI(RoleConstants role)
{
RoleBI roleBI;
if (Session.User != null)
roleBI = new RoleBI(roleID, Session.User.UserID);
roleBI = new RoleBI(role.Role, Session.User.UserID);
else
roleBI = new RoleBI(roleID, -1);
roleBI = new RoleBI(role.Role, -1);
return roleBI;
//bool repeat = true;
//while (!roleBI.IsAllowed && repeat)