User management fixed. Reports working now. Deployed
This commit is contained in:
1 parent
1400f42989
commit
d4cfa92848
51 files changed
+1990
-1358
No files matched your search
Binary file not shown.
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Tanshu.Accounts.Contracts
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Method)]
|
||||
public class PermissionAttribute : Attribute
|
||||
{
|
||||
public PermissionAttribute(RoleConstants role)
|
||||
{
|
||||
Role = role;
|
||||
}
|
||||
public RoleConstants Role { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -8,13 +8,9 @@ namespace Tanshu.Accounts.Contracts
|
||||
public class BillInventory
|
||||
{
|
||||
public int ProductID { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public decimal Price { get; set; }
|
||||
|
||||
public decimal Quantity { get; set; }
|
||||
|
||||
private decimal discount = 0;
|
||||
public decimal Discount
|
||||
{
|
||||
@@ -88,10 +84,9 @@ namespace Tanshu.Accounts.Contracts
|
||||
{
|
||||
get
|
||||
{
|
||||
return Quantity - printed;
|
||||
return Quantity - Printed;
|
||||
}
|
||||
}
|
||||
|
||||
public bool isNew;
|
||||
|
||||
public string Display
|
||||
|
||||
@@ -6,18 +6,14 @@ namespace Tanshu.Accounts.Contracts
|
||||
{
|
||||
public class SalesAnalysis
|
||||
{
|
||||
public virtual int TypeID { get; set; }
|
||||
public virtual string Section { get; set; }
|
||||
public virtual decimal Quantity { get; set; }
|
||||
public virtual decimal Gross { get; set; }
|
||||
public virtual decimal Net { get; set; }
|
||||
public virtual string GroupType { get; set; }
|
||||
public virtual decimal Amount { get; set; }
|
||||
}
|
||||
|
||||
public class SalesAnalysisDetail
|
||||
{
|
||||
public virtual string Section { get; set; }
|
||||
public virtual string Product { get; set; }
|
||||
public virtual decimal Quantity { get; set; }
|
||||
public virtual decimal Amount { get; set; }
|
||||
public virtual decimal Sale { get; set; }
|
||||
public virtual decimal NC { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -11,10 +11,10 @@ namespace Tanshu.Accounts.Entities.Auth
|
||||
public virtual string Name { get; set; }
|
||||
public virtual string Password { get; set; }
|
||||
public virtual bool LockedOut { get; set; }
|
||||
public virtual IList<Group> Groups { get; set; }
|
||||
public virtual IList<UserGroup> UserGroups { get; set; }
|
||||
public User()
|
||||
{
|
||||
Groups = new List<Group>();
|
||||
UserGroups = new List<UserGroup>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,78 +12,24 @@ namespace Tanshu.Accounts.Entities
|
||||
public virtual Voucher Voucher { get; set; }
|
||||
public virtual Product Product { get; set; }
|
||||
|
||||
private decimal quantity;
|
||||
public virtual decimal Quantity
|
||||
{
|
||||
get { return quantity; }
|
||||
set
|
||||
{
|
||||
quantity = value;
|
||||
if (amount != null)
|
||||
CalculateAmount();
|
||||
}
|
||||
}
|
||||
public virtual decimal Quantity { get; set; }
|
||||
|
||||
private decimal rate;
|
||||
public virtual decimal Rate
|
||||
{
|
||||
get { return rate; }
|
||||
set
|
||||
{
|
||||
rate = value;
|
||||
if (amount != null)
|
||||
CalculateAmount();
|
||||
}
|
||||
}
|
||||
public virtual decimal Rate { get; set; }
|
||||
|
||||
decimal tax;
|
||||
public virtual decimal Tax
|
||||
{
|
||||
get { return tax; }
|
||||
set
|
||||
{
|
||||
tax = value;
|
||||
if (amount != null)
|
||||
CalculateAmount();
|
||||
}
|
||||
}
|
||||
public virtual decimal Tax { get; set; }
|
||||
|
||||
decimal discount;
|
||||
public virtual decimal Discount
|
||||
{
|
||||
get { return discount; }
|
||||
set
|
||||
{
|
||||
discount = value;
|
||||
if (amount != null)
|
||||
CalculateAmount();
|
||||
}
|
||||
}
|
||||
public virtual decimal Discount { get; set; }
|
||||
|
||||
private decimal serviceCharge;
|
||||
public virtual decimal ServiceCharge
|
||||
{
|
||||
get { return serviceCharge; }
|
||||
set
|
||||
{
|
||||
discount = value;
|
||||
if (amount != null)
|
||||
CalculateAmount();
|
||||
}
|
||||
|
||||
}
|
||||
public virtual decimal ServiceCharge { get; set;}
|
||||
|
||||
[Cascade]
|
||||
public virtual IList<InventoryModifier> InventoryModifier { get; set; }
|
||||
|
||||
decimal? amount;
|
||||
public virtual decimal Amount
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!amount.HasValue)
|
||||
CalculateAmount();
|
||||
return amount.Value;
|
||||
return Quantity * Rate * (1 + Tax) * (1 + ServiceCharge) * (1 - Discount);
|
||||
}
|
||||
set
|
||||
{ }
|
||||
@@ -96,10 +42,6 @@ namespace Tanshu.Accounts.Entities
|
||||
// return quantity * rate * (1 + tax) * (1 + serviceCharge) * discount;
|
||||
// }
|
||||
//}
|
||||
protected void CalculateAmount()
|
||||
{
|
||||
amount = quantity * rate * (1 + tax) * (1 + serviceCharge) * (1 - discount);
|
||||
}
|
||||
public Inventory()
|
||||
{
|
||||
InventoryModifier = new List<InventoryModifier>();
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace Tanshu.Accounts.Entities
|
||||
public virtual string Name { get; set; }
|
||||
public virtual decimal DiscountLimit { get; set; }
|
||||
public virtual bool IsModifierCompulsory { get; set; }
|
||||
public virtual string GroupType { get; set; }
|
||||
public virtual IList<Product> Products { get; set; }
|
||||
public ProductGroup()
|
||||
{
|
||||
|
||||
@@ -5,23 +5,44 @@ using System.Text;
|
||||
|
||||
namespace Tanshu.Accounts.Contracts
|
||||
{
|
||||
public static class RolesConstants
|
||||
public sealed class RoleConstants
|
||||
{
|
||||
public const string SALES_CHECKOUT = "Sales/Checkout";
|
||||
public const string SALES_SALES_BILL = "Sales/SalesBill";
|
||||
public const string SALES_SALE_DETAIL = "Sales/SaleDetail";
|
||||
public const string SALES_VOID_BILL = "Sales/VoidPrintedBill";
|
||||
public const string SALES_EDIT_BILL = "Sales/EditBill";
|
||||
public const string SALES_PRINT_KOT = "Sales/PrintKOT";
|
||||
public const string SALES_PRINT_BILL = "Sales/PrintBill";
|
||||
public const string SALES_CHANGE_RATE = "Sales/ChangeRate";
|
||||
public const string SALES_EDIT_PRINTED_PRODUCT = "Sales/EditPrintedProduct";
|
||||
private readonly string role;
|
||||
private RoleConstants(string role)
|
||||
{
|
||||
this.role = role;
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
return role;
|
||||
}
|
||||
public string Role
|
||||
{
|
||||
get { return role; }
|
||||
}
|
||||
public static RoleConstants ADJUST_ADVANCE = new RoleConstants("Sales/AdjustAdvance");
|
||||
public static RoleConstants RECEIVE_ADVANCE = new RoleConstants("Sales/ReceiveAdvance");
|
||||
public static RoleConstants CHANGE_RATE = new RoleConstants("Sales/ChangeRate");
|
||||
public static RoleConstants CASHIER_CHECKOUT = new RoleConstants("Sales/CashierCheckout");
|
||||
public static RoleConstants CUSTOMERS = new RoleConstants("Sales/Customers");
|
||||
public static RoleConstants DISCOUNT = new RoleConstants("Sales/Discount");
|
||||
public static RoleConstants EDIT_PRINTED_BILL = new RoleConstants("Sales/EditBill");
|
||||
public static RoleConstants EDIT_PRINTED_PRODUCT = new RoleConstants("Sales/EditPrintedProduct");
|
||||
public static RoleConstants PRINT_BILL = new RoleConstants("Sales/PrintBill");
|
||||
public static RoleConstants PRINT_KOT = new RoleConstants("Sales/PrintKOT");
|
||||
public static RoleConstants SALES = new RoleConstants("Sales/SalesBill");
|
||||
public static RoleConstants SALE_ANALYSIS = new RoleConstants("Sales/SaleAnalysis");
|
||||
public static RoleConstants SALE_DETAIL = new RoleConstants("Sales/SaleDetail");
|
||||
public static RoleConstants VOID_BILL = new RoleConstants("Sales/VoidPrintedBill");
|
||||
public static RoleConstants ZERO_RATE = new RoleConstants("Sales/ZeroRate");
|
||||
public static RoleConstants SETTLE_BILL = new RoleConstants("Sales/SettleBill");
|
||||
|
||||
public const string MASTER_PRODUCTS = "Master/Products";
|
||||
public static RoleConstants PRODUCTS = new RoleConstants("Master/Products");
|
||||
|
||||
public const string SECURITY_MANAGE_ROLES = "Security/ManageRoles";
|
||||
public const string LOG_VIEW = "Log/View";
|
||||
public const string MASTER_OWNER = "Master/Owner";
|
||||
public static RoleConstants SECURITY_MANAGE_USERS = new RoleConstants("Security/ManageUsers");
|
||||
public static RoleConstants SECURITY_MANAGE_ROLES = new RoleConstants("Security/ManageRoles");
|
||||
public static RoleConstants LOG_VIEW = new RoleConstants("Log/View");
|
||||
public static RoleConstants MASTER_OWNER = new RoleConstants("Master/Owner");
|
||||
|
||||
}
|
||||
}
|
||||
@@ -41,10 +41,6 @@
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Include\Fluent\Castle.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Castle.DynamicProxy2, Version=2.1.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Include\Fluent\Castle.DynamicProxy2.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="FluentNHibernate, Version=1.1.0.685, Culture=neutral, PublicKeyToken=8aa435e3cb308880, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Include\Fluent\FluentNHibernate.dll</HintPath>
|
||||
@@ -53,10 +49,6 @@
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Include\Fluent\Iesi.Collections.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Include\Fluent\log4net.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NHibernate, Version=2.1.2.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Include\Fluent\NHibernate.dll</HintPath>
|
||||
@@ -86,6 +78,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Attributes\CascadeAttribute.cs" />
|
||||
<Compile Include="Attributes\PermissionAttribute.cs" />
|
||||
<Compile Include="Attributes\SecutiryAttribute.cs" />
|
||||
<Compile Include="Attributes\NotNullAttribute.cs" />
|
||||
<Compile Include="Data Contracts Display\BillItemKey.cs">
|
||||
|
||||
@@ -22,7 +22,6 @@ namespace Tanshu.Accounts.Helpers
|
||||
filters.Add("Universal");
|
||||
SetFilterColumns(filters);
|
||||
grid.Columns["CustomerID"].Visible = false;
|
||||
grid.Columns["LedgerID"].Visible = false;
|
||||
}
|
||||
|
||||
protected override void FilterChanged(Dictionary<string, string> filter)
|
||||
|
||||
@@ -21,7 +21,6 @@ namespace Tanshu.Accounts.Helpers
|
||||
filters.Add("Name");
|
||||
SetFilterColumns(filters);
|
||||
grid.Columns["UserID"].Visible = false;
|
||||
grid.Columns["timestamp"].Visible = false;
|
||||
}
|
||||
|
||||
protected override void FilterChanged(Dictionary<string, string> filter)
|
||||
|
||||
@@ -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"/>
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+87
-61
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
//
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+7
-119
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
File renamed without changes.
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
+30
-29
@@ -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;
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -221,10 +221,31 @@ namespace Tanshu.Accounts.Print
|
||||
printText += DrawLine;
|
||||
foreach (SalesAnalysis d in det)
|
||||
{
|
||||
if (d.Section.Length > 30)
|
||||
d.Section = d.Section.Substring(0, 30);
|
||||
printText += string.Format("\n\r{0,-22} {1,9:#,##0} {2,9:#,##0}", d.Section, d.Net, d.Gross);
|
||||
printText += DrawLine;
|
||||
printText += string.Format("\n\r {0,-22} {1,9:#,##0}", d.GroupType, d.Amount);
|
||||
}
|
||||
printText += DrawEqual;
|
||||
return PrintRAW(PrintLocationBI.BasePrinter, printText, "Sale Detail " + user);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static Boolean PrintSale(string user, IList<SalesAnalysisDetail> list, DateTime startDate, DateTime endDate)
|
||||
{
|
||||
string printText;
|
||||
try
|
||||
{
|
||||
printText = FormatText(user, 42, false, Align.Centre);
|
||||
printText += DrawLine;
|
||||
printText += "\n\r" + FormatText(string.Format("{0:dd-MMM-yyyy HH:mm:ss}", DateTime.Now), 42, false, Align.Centre);
|
||||
printText += "\n\r" + FormatText(string.Format("{0:dd-MMM-yyyy} to {1:dd-MMM-yyyy}", startDate, endDate), 42, false, Align.Centre);
|
||||
printText += DrawLine;
|
||||
foreach (var item in list)
|
||||
{
|
||||
printText += string.Format("\n\r{0,-22} {1,9:#,##0.00} {1,9:#,##0.00}", item.Product, item.Sale, item.NC);
|
||||
}
|
||||
printText += DrawEqual;
|
||||
return PrintRAW(PrintLocationBI.BasePrinter, printText, "Sale Detail " + user);
|
||||
@@ -284,16 +305,19 @@ namespace Tanshu.Accounts.Print
|
||||
try
|
||||
{
|
||||
BillText = FormatText(string.Format("{0} Checkout By {1}", details.Cashier.Name, details.Manager), 42, false, Align.Centre);
|
||||
BillText += string.Format("{0:dd-MMM-yy} To {1:dd-MMM-yy} @ {2:dd-MMM-yyyy HH:mm}", details.StartDate, details.FinishDate, DateTime.Now);
|
||||
BillText += string.Format("\n\r{0:dd-MMM-yy} To {1:dd-MMM-yy} @ {2:dd-MMM-yyyy HH:mm}", details.StartDate, details.FinishDate, DateTime.Now);
|
||||
BillText += DrawLine;
|
||||
BillText += string.Format("\n\rOpening : {0,26:#,##0.00}", details.Opening);
|
||||
BillText += string.Format("\n\rReceipts : {0,26:#,##0.00}", details.Receipts);
|
||||
//BillText += string.Format("\n\rOpening : {0,26:#,##0.00}", details.Opening);
|
||||
//BillText += string.Format("\n\rReceipts : {0,26:#,##0.00}", details.Receipts);
|
||||
BillText += string.Format("\n\rAdvance Rcv. : {0,26:#,##0.00}", details.AdvanceReceipts);
|
||||
BillText += string.Format("\n\rCC Receipts : {0,26:#,##0.00}", details.CCReceipts);
|
||||
BillText += string.Format("\n\rNC Amount : {0,26:#,##0.00}", details.NCReceipts);
|
||||
BillText += string.Format("\n\rBTC Amount : {0,26:#,##0.00}", details.BTCReceipts);
|
||||
BillText += string.Format("\n\rAdvance Adj. : {0,26:#,##0.00}", details.AdvanceAdjusted);
|
||||
BillText += string.Format("\n\rPayments : {0,26:#,##0.00}", details.CashPayments);
|
||||
BillText += string.Format("\n\rAddl. Voids : {0,26:#,##0.00}", details.AdditionalVoids);
|
||||
//BillText += string.Format("\n\rPayments : {0,26:#,##0.00}", details.CashPayments);
|
||||
//BillText += string.Format("\n\rAddl. Voids : {0,26:#,##0.00}", details.AdditionalVoids);
|
||||
BillText += string.Format("\n\rVoids in Sys. : {0,26:#,##0.00}", details.VoidsInSystem);
|
||||
BillText += string.Format("\n\rDiscounts : {0,26:#,##0.00}", details.Discount);
|
||||
BillText += string.Format("\n\rPending Bills : {0,26:#,##0.00}", details.PendingBills);
|
||||
BillText += string.Format("\n\rNet Sales : {0,26:#,##0.00}", details.NetSales);
|
||||
BillText += string.Format("\n\rClosing Bal. : {0,26:#,##0.00}", details.ClosingBalance);
|
||||
@@ -313,6 +337,15 @@ namespace Tanshu.Accounts.Print
|
||||
if (details.CCString.Length > 0)
|
||||
BillText += details.CCString;
|
||||
|
||||
if (details.NCString.Length > 0)
|
||||
BillText += details.NCString;
|
||||
|
||||
if (details.BTCString.Length > 0)
|
||||
BillText += details.BTCString;
|
||||
|
||||
if (details.StaffString.Length > 0)
|
||||
BillText += details.StaffString;
|
||||
|
||||
if (details.VoidsString.Length > 0)
|
||||
BillText += details.VoidsString;
|
||||
|
||||
@@ -336,7 +369,7 @@ namespace Tanshu.Accounts.Print
|
||||
return FormatText(InputString, 24, false, Align.Right);
|
||||
}
|
||||
|
||||
public static void PrintBill(bool bill, int voucherID, List<BillInventory> list)
|
||||
public static void PrintBill(int voucherID, List<BillInventory> list)
|
||||
{
|
||||
SaleVoucher trans = new SaleVoucher();
|
||||
IList<Inventory> iList = new List<Inventory>();
|
||||
|
||||
@@ -9,6 +9,7 @@ using Tanshu.Accounts.SqlDAO;
|
||||
using Tanshu.Accounts.Entities;
|
||||
using Tanshu.Accounts.Entities.Auth;
|
||||
using NHibernate.Criterion;
|
||||
using Tanshu.Accounts.Contracts;
|
||||
|
||||
namespace Tanshu.Accounts.Repository
|
||||
{
|
||||
@@ -21,10 +22,12 @@ namespace Tanshu.Accounts.Repository
|
||||
public decimal CCReceipts { get; private set; }
|
||||
public decimal NCReceipts { get; private set; }
|
||||
public decimal BTCReceipts { get; private set; }
|
||||
public decimal StaffReceipts { get; private set; }
|
||||
public decimal AdvanceAdjusted { get; private set; }
|
||||
public decimal CashPayments { get; private set; }
|
||||
public decimal AdditionalVoids { get; private set; }
|
||||
public decimal VoidsInSystem { get; private set; }
|
||||
public decimal Discount { get; private set; }
|
||||
public decimal PendingBills { get; private set; }
|
||||
public decimal NetSales { get; private set; }
|
||||
public decimal ClosingBalance { get; private set; }
|
||||
@@ -46,18 +49,14 @@ namespace Tanshu.Accounts.Repository
|
||||
public string CCString { get; private set; }
|
||||
public string NCString { get; private set; }
|
||||
public string BTCString { get; private set; }
|
||||
public string StaffString { get; private set; }
|
||||
public string VoidsString { get; private set; }
|
||||
public string DiscountString { get; private set; }
|
||||
|
||||
//public string PendingString { get; private set; } //
|
||||
//public string CCString { get; private set; } //
|
||||
//public string VoidsString { get; private set; }
|
||||
//public string DiscountString { get; private set; }
|
||||
|
||||
public string PaymentString { get; private set; } //
|
||||
public string PaymentString { get; private set; }
|
||||
public string Manager
|
||||
{
|
||||
get { return Thread.CurrentPrincipal.Identity.Name; }
|
||||
get { return Session.User.Name; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -65,10 +64,9 @@ namespace Tanshu.Accounts.Repository
|
||||
{
|
||||
using (var session = SessionManager.Session)
|
||||
{
|
||||
//Actual Closing
|
||||
this.Cashier = UserBI.GetUser(cashier);
|
||||
this.StartDate = Convert.ToDateTime(string.Format("{0:dd-MMM-yyyy} 00:00:00", startDate));
|
||||
this.FinishDate = Convert.ToDateTime(string.Format("{0:dd-MMM-yyyy} 23:59:59", finishDate));
|
||||
this.StartDate = startDate.Date.AddHours(6);
|
||||
this.FinishDate = finishDate.Date.AddDays(1).AddHours(5);
|
||||
|
||||
string info;
|
||||
PendingBills = GetPending(out info);
|
||||
@@ -79,10 +77,13 @@ namespace Tanshu.Accounts.Repository
|
||||
NCString = info;
|
||||
BTCReceipts = GetBillToCompany(out info);
|
||||
BTCString = info;
|
||||
StaffReceipts = GetStaffBills(out info);
|
||||
StaffString = info;
|
||||
VoidsInSystem = GetVoids(out info);
|
||||
VoidsString = info;
|
||||
// Opening = dao.GetOpenings();
|
||||
// Receipts = GetReceipts();
|
||||
PaymentString = "";
|
||||
// CashPayments = dao.GetPayments();
|
||||
// AdditionalVoids = dao.GetAdditionalVoids();
|
||||
// RetainedOvernight = dao.GetRetainedOvernight();
|
||||
@@ -96,14 +97,15 @@ namespace Tanshu.Accounts.Repository
|
||||
// OldVoided = dao.GetOldVoided();
|
||||
|
||||
|
||||
//Cashiers = GetActiveCashiers();
|
||||
Cashiers = GetActiveCashiers();
|
||||
NetSales = GetNetSales();
|
||||
GetDiscountBills(.1M, out info);
|
||||
Discount = GetDiscountBills(.1M, out info);
|
||||
DiscountString = info;
|
||||
ClosingBalance = Opening
|
||||
+ Receipts
|
||||
+ AdvanceReceipts
|
||||
- CCReceipts
|
||||
- BTCReceipts
|
||||
- AdvanceAdjusted
|
||||
- CashPayments
|
||||
- AdditionalVoids
|
||||
@@ -147,6 +149,7 @@ namespace Tanshu.Accounts.Repository
|
||||
using (var session = SessionManager.Session)
|
||||
{
|
||||
decimal amount;
|
||||
decimal discount;
|
||||
info = "\n\r--- Pending Bills ------------------------";
|
||||
var list = (from i in session.QueryOver<SaleVoucher>()
|
||||
where i.LastEditDate >= StartDate &&
|
||||
@@ -155,7 +158,7 @@ namespace Tanshu.Accounts.Repository
|
||||
i.Void == false &&
|
||||
i.Settled == SettleOptionFactory.OUnsettled
|
||||
select i).List();
|
||||
GetInfo(list, out amount, ref info);
|
||||
GetInfo(list, out amount, out discount, ref info);
|
||||
return amount;
|
||||
}
|
||||
}
|
||||
@@ -164,6 +167,7 @@ namespace Tanshu.Accounts.Repository
|
||||
using (var session = SessionManager.Session)
|
||||
{
|
||||
decimal amount;
|
||||
decimal discount;
|
||||
info = "\n\r--- No Charge ----------------------------";
|
||||
var list = (from i in session.QueryOver<SaleVoucher>()
|
||||
where i.LastEditDate >= StartDate &&
|
||||
@@ -172,7 +176,7 @@ namespace Tanshu.Accounts.Repository
|
||||
i.Void == false &&
|
||||
i.Settled == SettleOptionFactory.ONoCharge
|
||||
select i).List();
|
||||
GetInfo(list, out amount, ref info);
|
||||
GetInfo(list, out amount, out discount, ref info);
|
||||
return amount;
|
||||
}
|
||||
}
|
||||
@@ -181,6 +185,7 @@ namespace Tanshu.Accounts.Repository
|
||||
using (var session = SessionManager.Session)
|
||||
{
|
||||
decimal amount;
|
||||
decimal discount;
|
||||
info = "\n\r--- Bill To Company ----------------------";
|
||||
var list = (from i in session.QueryOver<SaleVoucher>()
|
||||
where i.LastEditDate >= StartDate &&
|
||||
@@ -189,7 +194,25 @@ namespace Tanshu.Accounts.Repository
|
||||
i.Void == false &&
|
||||
i.Settled == SettleOptionFactory.OBillToCompany
|
||||
select i).List();
|
||||
GetInfo(list, out amount, ref info);
|
||||
GetInfo(list, out amount, out discount, ref info);
|
||||
return amount;
|
||||
}
|
||||
}
|
||||
private decimal GetStaffBills(out string info)
|
||||
{
|
||||
using (var session = SessionManager.Session)
|
||||
{
|
||||
decimal amount;
|
||||
decimal discount;
|
||||
info = "\n\r--- Staff Bills --------------------------";
|
||||
var list = (from i in session.QueryOver<SaleVoucher>()
|
||||
where i.LastEditDate >= StartDate &&
|
||||
i.LastEditDate <= FinishDate &&
|
||||
i.User == Cashier &&
|
||||
i.Void == false &&
|
||||
i.Settled == SettleOptionFactory.OStaff
|
||||
select i).List();
|
||||
GetInfo(list, out amount, out discount, ref info);
|
||||
return amount;
|
||||
}
|
||||
}
|
||||
@@ -198,6 +221,7 @@ namespace Tanshu.Accounts.Repository
|
||||
using (var session = SessionManager.Session)
|
||||
{
|
||||
decimal amount;
|
||||
decimal discount;
|
||||
info = "\n\r--- Credit Card Bills --------------------";
|
||||
var list = (from i in session.QueryOver<SaleVoucher>()
|
||||
where i.LastEditDate >= StartDate &&
|
||||
@@ -206,7 +230,7 @@ namespace Tanshu.Accounts.Repository
|
||||
i.Void == false &&
|
||||
i.Settled == SettleOptionFactory.OCreditCard
|
||||
select i).List();
|
||||
GetInfo(list, out amount, ref info);
|
||||
GetInfo(list, out amount, out discount, ref info);
|
||||
return amount;
|
||||
}
|
||||
}
|
||||
@@ -215,6 +239,7 @@ namespace Tanshu.Accounts.Repository
|
||||
using (var session = SessionManager.Session)
|
||||
{
|
||||
decimal amount;
|
||||
decimal discount;
|
||||
info = "\n\r--- Void Bills ---------------------------";
|
||||
var list = (from i in session.QueryOver<SaleVoucher>()
|
||||
where i.LastEditDate >= StartDate &&
|
||||
@@ -222,7 +247,7 @@ namespace Tanshu.Accounts.Repository
|
||||
i.User == Cashier &&
|
||||
i.Void == true
|
||||
select i).List();
|
||||
GetInfo(list, out amount, ref info);
|
||||
GetInfo(list, out amount, out discount, ref info);
|
||||
return amount;
|
||||
}
|
||||
}
|
||||
@@ -231,10 +256,11 @@ namespace Tanshu.Accounts.Repository
|
||||
using (var session = SessionManager.Session)
|
||||
{
|
||||
decimal amount;
|
||||
decimal discount;
|
||||
info = "\n\r--- High Discount Bills ------------------";
|
||||
string query = @"
|
||||
select v from SaleVoucher v
|
||||
inner join v.Inventories i
|
||||
select distinct(v) from SaleVoucher v
|
||||
inner join v.Inventories i
|
||||
where v.Date >= :startDate and v.Date <= :finishDate and v.User = :cashierID and v.Void = false and v.Settled != :unSettled and v.Settled != :noCharge
|
||||
and i.Discount >= :discount";
|
||||
var list = session.CreateQuery(query)
|
||||
@@ -246,8 +272,8 @@ and i.Discount >= :discount";
|
||||
.SetParameter("discount", disount)
|
||||
.List<SaleVoucher>();
|
||||
|
||||
GetInfo(list, out amount, ref info);
|
||||
return amount;
|
||||
GetInfo(list, out amount, out discount, ref info);
|
||||
return discount;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,9 +297,10 @@ where v.Date >= :startDate and v.Date <= :finishDate and v.User = :cashierID and
|
||||
}
|
||||
}
|
||||
|
||||
private void GetInfo(IList<SaleVoucher> list, out decimal amount, ref string info)
|
||||
private void GetInfo(IList<SaleVoucher> list, out decimal amount, out decimal discount, ref string info)
|
||||
{
|
||||
amount = 0;
|
||||
discount = 0;
|
||||
if (list.Count == 0)
|
||||
{
|
||||
info = string.Empty;
|
||||
@@ -284,11 +311,31 @@ where v.Date >= :startDate and v.Date <= :finishDate and v.User = :cashierID and
|
||||
{
|
||||
decimal amt, disc;
|
||||
amt = item.Inventories.Sum(x => x.Amount);
|
||||
disc = item.Inventories.Sum(x => x.Quantity * x.Rate * (1 + x.Tax) * (1 + x.ServiceCharge) * x.Discount);
|
||||
disc = item.Inventories.Sum(x => x.Quantity * x.Rate * x.Discount);
|
||||
info += string.Format("\n\r{0:dd-MMM-yyyy HH:mm:ss} {1} {2}", item.Date, item.BillID, item.Customer.Name);
|
||||
info += string.Format("\n\rAmount: {0:#0.00} :: Discount: {1:#0.00}", amt, disc);
|
||||
info += "\n\r------------------------------------------";
|
||||
amount += amt;
|
||||
discount += disc;
|
||||
}
|
||||
}
|
||||
|
||||
private string GetActiveCashiers()
|
||||
{
|
||||
string cashiers = "";
|
||||
using (var session = SessionManager.Session)
|
||||
{
|
||||
string query = @"
|
||||
select distinct(u.Name) from SaleVoucher v
|
||||
inner join v.User u
|
||||
where v.Date >= :startDate and v.Date <= :finishDate";
|
||||
var list = session.CreateQuery(query)
|
||||
.SetParameter("startDate", StartDate)
|
||||
.SetParameter("finishDate", FinishDate)
|
||||
.List<string>();
|
||||
foreach (var item in list)
|
||||
cashiers += item + ", ";
|
||||
return cashiers;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,9 +60,16 @@ namespace Tanshu.Accounts.Repository
|
||||
}
|
||||
}
|
||||
|
||||
public List<Customer> GetFilteredCustomers(Dictionary<string, string> filter)
|
||||
public IList<Customer> GetFilteredCustomers(Dictionary<string, string> filter)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
using (var session = SessionManager.Session)
|
||||
{
|
||||
string name = string.Format("%{0}%", filter["Universal"]);
|
||||
return session.CreateCriteria<Customer>()
|
||||
.Add(Restrictions.Like("Name", name))
|
||||
.List<Customer>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,75 +14,55 @@ using NHibernate;
|
||||
|
||||
namespace Tanshu.Accounts.Repository
|
||||
{
|
||||
public class MembershipBI
|
||||
public static class MembershipBI
|
||||
{
|
||||
public void AddUserToGroup(int userID, int groupID)
|
||||
{
|
||||
using (var session = SessionManager.Session)
|
||||
{
|
||||
var user = session.Get<User>(userID);
|
||||
var group = session.Get<Group>(groupID);
|
||||
var userGroup = session.CreateCriteria<UserGroup>()
|
||||
.Add(Restrictions.Eq("UserID", userID))
|
||||
.Add(Restrictions.Eq("GroupID", groupID))
|
||||
.UniqueResult<UserGroup>();
|
||||
if (userGroup == null)
|
||||
session.Save(
|
||||
new UserGroup()
|
||||
{
|
||||
User = user,
|
||||
Group = group
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public string[] GetAllRoles()
|
||||
{
|
||||
using (var session = SessionManager.Session)
|
||||
{
|
||||
var roleList = session.CreateCriteria<Role>().List<Role>();
|
||||
string[] list = new string[roleList.Count];
|
||||
for (int i = 0; i < list.Length; i++)
|
||||
{
|
||||
list[i] = roleList[i].Name;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
//public string[] GetAllRoles()
|
||||
//{
|
||||
// using (var session = SessionManager.Session)
|
||||
// {
|
||||
// var roleList = session.CreateCriteria<Role>().List<Role>();
|
||||
// string[] list = new string[roleList.Count];
|
||||
// for (int i = 0; i < list.Length; i++)
|
||||
// {
|
||||
// list[i] = roleList[i].Name;
|
||||
// }
|
||||
// return list;
|
||||
// }
|
||||
//}
|
||||
|
||||
public string[] GetRolesForUser(string username)
|
||||
{
|
||||
using (var session = SessionManager.Session)
|
||||
{
|
||||
var user = session.CreateCriteria<User>()
|
||||
.Add(Restrictions.Eq("Name", username))
|
||||
.UniqueResult<User>();
|
||||
//public string[] GetRolesForUser(string username)
|
||||
//{
|
||||
// using (var session = SessionManager.Session)
|
||||
// {
|
||||
// var user = session.CreateCriteria<User>()
|
||||
// .Add(Restrictions.Eq("Name", username))
|
||||
// .UniqueResult<User>();
|
||||
|
||||
List<string> roles = new List<string>();
|
||||
foreach (var group in user.Groups)
|
||||
{
|
||||
foreach (var item in group.RoleGroups)
|
||||
{
|
||||
roles.Add(item.Role.Name);
|
||||
}
|
||||
}
|
||||
return roles.ToArray();
|
||||
}
|
||||
}
|
||||
// List<string> roles = new List<string>();
|
||||
// foreach (var group in user.Groups)
|
||||
// {
|
||||
// foreach (var item in group.RoleGroups)
|
||||
// {
|
||||
// roles.Add(item.Role.Name);
|
||||
// }
|
||||
// }
|
||||
// return roles.ToArray();
|
||||
// }
|
||||
//}
|
||||
|
||||
public bool IsUserInRole(string username, string roleName)
|
||||
{
|
||||
using (var session = SessionManager.Session)
|
||||
{
|
||||
var user = session.CreateCriteria<User>()
|
||||
.Add(Restrictions.Eq("Name", username))
|
||||
.UniqueResult<User>();
|
||||
return IsUserInRole(user.UserID, roleName);
|
||||
}
|
||||
}
|
||||
//public bool IsUserInRole(string username, string roleName)
|
||||
//{
|
||||
// using (var session = SessionManager.Session)
|
||||
// {
|
||||
// var user = session.CreateCriteria<User>()
|
||||
// .Add(Restrictions.Eq("Name", username))
|
||||
// .UniqueResult<User>();
|
||||
// return IsUserInRole(user.UserID, roleName);
|
||||
// }
|
||||
//}
|
||||
|
||||
public bool IsUserInRole(int userID, string roleName)
|
||||
public static bool IsUserInRole(int userID, string roleName)
|
||||
{
|
||||
string query = @"
|
||||
SELECT COUNT(*) AS Role_Count FROM
|
||||
@@ -93,24 +73,139 @@ WHERE ug.UserID = :UserID AND r.Name = :Role;";
|
||||
{
|
||||
return session
|
||||
.CreateSQLQuery(query)
|
||||
.AddScalar("Role_Count",NHibernateUtil.Int32)
|
||||
.AddScalar("Role_Count", NHibernateUtil.Int32)
|
||||
.SetInt32("UserID", userID)
|
||||
.SetString("Role", roleName)
|
||||
.UniqueResult<int>() > 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveUserFromGroup(int userID, int groupID)
|
||||
#region UserGroup
|
||||
public static IList<Group> GetGroups()
|
||||
{
|
||||
using (var session = SessionManager.Session)
|
||||
{
|
||||
var userGroup = session.CreateCriteria<UserGroup>()
|
||||
.Add(Restrictions.Eq("UserID", userID))
|
||||
.Add(Restrictions.Eq("GroupID", groupID))
|
||||
.UniqueResult<UserGroup>();
|
||||
if (userGroup != null)
|
||||
session.Delete(userGroup);
|
||||
return session.CreateCriteria<Group>()
|
||||
.List<Group>();
|
||||
}
|
||||
}
|
||||
public static IList<Group> GetGroupsOfUser(int userID)
|
||||
{
|
||||
using (var session = SessionManager.Session)
|
||||
{
|
||||
string query = "select ug.Group from UserGroup ug where ug.User.UserID = :userID";
|
||||
var list = session.CreateQuery(query)
|
||||
.SetParameter("userID", userID)
|
||||
.List<Group>();
|
||||
foreach (var item in list)
|
||||
NHibernateUtil.Initialize(item);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
public static IList<Group> GetGroupsNotOfUser(int userID)
|
||||
{
|
||||
using (var session = SessionManager.Session)
|
||||
{
|
||||
string query = "select g from Group g where g not in (select ug.Group from UserGroup ug where ug.User.UserID = :userID)";
|
||||
var list = session.CreateQuery(query)
|
||||
.SetParameter("userID", userID)
|
||||
.List<Group>();
|
||||
foreach (var item in list)
|
||||
NHibernateUtil.Initialize(item);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
public static void AddUserToGroup(int userID, int groupID)
|
||||
{
|
||||
using (var session = SessionManager.Session)
|
||||
{
|
||||
var userGroup = session.CreateQuery("select count(*) from UserGroup ug where ug.User.UserID = :userID and ug.Group.GroupID = :groupID")
|
||||
.SetParameter("userID", userID)
|
||||
.SetParameter("groupID", groupID)
|
||||
.UniqueResult<long>();
|
||||
if (userGroup == 0)
|
||||
{
|
||||
var user = session.Get<User>(userID);
|
||||
var group = session.Get<Group>(groupID);
|
||||
session.Save(new UserGroup() { User = user, Group = group });
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void RemoveUserFromGroup(int userID, int groupID)
|
||||
{
|
||||
using (var session = SessionManager.Session)
|
||||
{
|
||||
string query = "delete UserGroup ug where ug.User.UserID = :userID and ug.Group.GroupID = :groupID";
|
||||
session.CreateQuery(query)
|
||||
.SetParameter("userID", userID)
|
||||
.SetParameter("groupID", groupID)
|
||||
.ExecuteUpdate();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region RoleGroup
|
||||
public static IList<Role> GetRoles()
|
||||
{
|
||||
using (var session = SessionManager.Session)
|
||||
{
|
||||
return session.CreateCriteria<Role>()
|
||||
.List<Role>();
|
||||
}
|
||||
}
|
||||
public static IList<Role> GetRolesOfGroup(int groupID)
|
||||
{
|
||||
using (var session = SessionManager.Session)
|
||||
{
|
||||
string query = "select rg.Role from RoleGroup rg where rg.Group.GroupID = :groupID";
|
||||
var list = session.CreateQuery(query)
|
||||
.SetParameter("groupID", groupID)
|
||||
.List<Role>();
|
||||
foreach (var item in list)
|
||||
NHibernateUtil.Initialize(item);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
public static IList<Role> GetRolesNotOfGroup(int groupID)
|
||||
{
|
||||
using (var session = SessionManager.Session)
|
||||
{
|
||||
string query = "select r from Role r where r not in (select rg.Role from RoleGroup rg where rg.Group.GroupID = :groupID)";
|
||||
var list = session.CreateQuery(query)
|
||||
.SetParameter("groupID", groupID)
|
||||
.List<Role>();
|
||||
foreach (var item in list)
|
||||
NHibernateUtil.Initialize(item);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
public static void AddRoleToGroup(int roleID, int groupID)
|
||||
{
|
||||
using (var session = SessionManager.Session)
|
||||
{
|
||||
var roleGroup = session.CreateQuery("select count(*) from RoleGroup rg where rg.Role.RoleID = :roleID and rg.Group.GroupID = :groupID")
|
||||
.SetParameter("roleID", roleID)
|
||||
.SetParameter("groupID", groupID)
|
||||
.UniqueResult<long>();
|
||||
if (roleGroup == 0)
|
||||
{
|
||||
var role = session.Get<Role>(roleID);
|
||||
var group = session.Get<Group>(groupID);
|
||||
session.Save(new RoleGroup() { Role = role, Group = group });
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void RemoveRoleFromGroup(int roleID, int groupID)
|
||||
{
|
||||
using (var session = SessionManager.Session)
|
||||
{
|
||||
string query = "delete RoleGroup rg where rg.Role.RoleID = :roleID and rg.Group.GroupID = :groupID";
|
||||
session.CreateQuery(query)
|
||||
.SetParameter("roleID", roleID)
|
||||
.SetParameter("groupID", groupID)
|
||||
.ExecuteUpdate();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -48,6 +48,7 @@ namespace Tanshu.Accounts.Repository
|
||||
using (var session = SessionManager.Session)
|
||||
{
|
||||
return session.CreateCriteria<ProductGroup>()
|
||||
.AddOrder(Order.Asc("Name"))
|
||||
.List<ProductGroup>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,30 +9,25 @@ namespace Tanshu.Accounts.Repository
|
||||
public delegate bool AuthenticateUser(out string userName);
|
||||
public class RoleBI : IDisposable
|
||||
{
|
||||
string roleID;
|
||||
string roleName;
|
||||
int userID;
|
||||
bool isAllowed;
|
||||
//bool elevated;
|
||||
//AccountsPrincipal originalUser;
|
||||
//AuthenticateUser authenticateUser;
|
||||
public RoleBI(string roleID, int userID)
|
||||
public RoleBI(string roleName, int userID)
|
||||
{
|
||||
this.roleID = roleID;
|
||||
this.roleName = roleName;
|
||||
this.userID = userID;
|
||||
//elevated = false;
|
||||
//originalUser = null;
|
||||
//authenticateUser = null;
|
||||
if (userID == 0)
|
||||
isAllowed = false;
|
||||
else
|
||||
isAllowed = MembershipBI.IsUserInRole(userID, this.roleName);
|
||||
disposed = false;
|
||||
}
|
||||
|
||||
|
||||
public bool IsAllowed
|
||||
{
|
||||
get
|
||||
{
|
||||
if (userID == 0)
|
||||
return false;
|
||||
return new MembershipBI().IsUserInRole(userID, roleID);
|
||||
}
|
||||
}
|
||||
{ get { return isAllowed; } }
|
||||
|
||||
//public bool IsElevated
|
||||
//{
|
||||
@@ -57,7 +52,7 @@ namespace Tanshu.Accounts.Repository
|
||||
// if (userName.Contains(":"))
|
||||
// userName = userName.Substring(userName.IndexOf(":") + 1);
|
||||
|
||||
// Session.User = new MembershipBI().GetUserFromName(userName));
|
||||
// Session.User = MembershipBI.GetUserFromName(userName));
|
||||
|
||||
// // bind the generic principal to the thread
|
||||
// Thread.CurrentPrincipal = principal;
|
||||
|
||||
@@ -7,169 +7,163 @@ using Tanshu.Data.DAO;
|
||||
using Tanshu.Accounts.SqlDAO;
|
||||
using Tanshu.Accounts.Entities;
|
||||
using NHibernate.Criterion;
|
||||
using Tanshu.Common;
|
||||
|
||||
namespace Tanshu.Accounts.Repository
|
||||
{
|
||||
public class SalesAnalysisBI
|
||||
{
|
||||
public IList<SalesAnalysisDetail> GetSaleDetail(DateTime startDate, DateTime finishDate, int costCenterID)
|
||||
public ICollection<SalesAnalysisDetail> GetSaleDetail(DateTime startDate, DateTime finishDate)
|
||||
{
|
||||
string query = @"
|
||||
SELECT p.Name AS Product, pt.Name AS Section, SUM(i.Quantity) AS Quantity, SUM(Amount) AS Amount
|
||||
FROM Vouchers t INNER JOIN SaleVoucher s ON t.VoucherID = s.VoucherID
|
||||
INNER JOIN Inventory i ON t.VoucherID = i.VoucherID
|
||||
INNER JOIN Products p ON i.ProductID = p.ProductID
|
||||
INNER JOIN ProductTypes pt ON p.ProductTypeID = pt.ProductTypeID
|
||||
INNER JOIN Ledgers l ON p.SaleLedgerID = l.LedgerID
|
||||
WHERE t.Type = 'S' AND s.Paid = 1 AND s.Void = 0
|
||||
AND t.LastEditDate BETWEEN :StartDate AND :FinishDate AND l.CostCenterID = :CostCenterID
|
||||
GROUP BY p.Name, pt.Name
|
||||
ORDER BY Amount DESC;";
|
||||
|
||||
startDate = startDate.Date.AddHours(6);
|
||||
finishDate = finishDate.Date.AddDays(1).AddHours(5);
|
||||
if (finishDate <= startDate)
|
||||
return new List<SalesAnalysisDetail>();
|
||||
|
||||
using (var session = SessionManager.Session)
|
||||
{
|
||||
return session
|
||||
.CreateSQLQuery(query)
|
||||
.AddEntity(typeof(SalesAnalysisDetail))
|
||||
.SetDateTime("StartDate", startDate)
|
||||
.SetDateTime("FinishDate", finishDate)
|
||||
.SetInt32("CostCenterID", costCenterID)
|
||||
.List<SalesAnalysisDetail>();
|
||||
var query = @"
|
||||
select concat(p.Name, ' ', p.Units) as Product, Sum(i.Quantity) as Amount
|
||||
from SaleVoucher v
|
||||
inner join v.Inventories i
|
||||
inner join i.Product p
|
||||
where v.Date >= :startDate and v.Date <= :finishDate and v.Void = false and v.Settled != :noCharge
|
||||
group by concat(p.Name, ' ', p.Units), p.ProductGroup
|
||||
order by p.ProductGroup, concat(p.Name, ' ', p.Units)
|
||||
";
|
||||
var list = session
|
||||
.CreateQuery(query)
|
||||
.SetParameter("startDate", startDate)
|
||||
.SetParameter("finishDate", finishDate)
|
||||
.SetParameter("noCharge", SettleOptionFactory.NoCharge)
|
||||
.List<object[]>();
|
||||
var outList = new OrderedDictionary<string, SalesAnalysisDetail>();
|
||||
foreach (var item in list)
|
||||
outList.Add((string)item[0], new SalesAnalysisDetail() { Product = (string)item[0], Sale = (decimal)item[1] });
|
||||
|
||||
query = @"
|
||||
select concat(p.Name, ' ', p.Units) as Product, Sum(i.Quantity) as Amount
|
||||
from SaleVoucher v
|
||||
inner join v.Inventories i
|
||||
inner join i.Product p
|
||||
where v.Date >= :startDate and v.Date <= :finishDate and v.Void = false and v.Settled = :noCharge
|
||||
group by concat(p.Name, ' ', p.Units), p.ProductGroup
|
||||
order by p.ProductGroup, concat(p.Name, ' ', p.Units)
|
||||
";
|
||||
list = session
|
||||
.CreateQuery(query)
|
||||
.SetParameter("startDate", startDate)
|
||||
.SetParameter("finishDate", finishDate)
|
||||
.SetParameter("noCharge", SettleOptionFactory.NoCharge)
|
||||
.List<object[]>();
|
||||
foreach (var item in list)
|
||||
if (outList.ContainsKey((string)item[0]))
|
||||
outList[(string)item[0]].NC = (decimal)item[1];
|
||||
else
|
||||
outList.Add((string)item[0], new SalesAnalysisDetail() { Product = (string)item[0], NC = (decimal)item[1] });
|
||||
|
||||
return outList.Values;
|
||||
}
|
||||
}
|
||||
public IList<SalesAnalysis> GetSale(DateTime startDate, DateTime finishDate)
|
||||
{
|
||||
startDate = startDate.Date.AddHours(6);
|
||||
finishDate = finishDate.Date.AddDays(1).AddHours(5);
|
||||
if (finishDate <= startDate)
|
||||
return new List<SalesAnalysis>();
|
||||
using (var session = SessionManager.Session)
|
||||
{
|
||||
var temp = from sal in session.QueryOver<SaleVoucher>()
|
||||
where sal.Date >= startDate && sal.Date <= finishDate
|
||||
&& sal.Settled != SettleOptionFactory.ONoCharge && sal.Void == false
|
||||
select sal.Inventories;
|
||||
|
||||
string query = @"
|
||||
SELECT c.CostCenterID AS TypeID, c.Name AS Section, SUM(i.Quantity) AS Quantity, SUM(Amount) AS Gross, SUM(i.Quantity * i.Rate * (1 - Discount)) AS Net
|
||||
FROM Vouchers t INNER JOIN SaleVoucher s ON t.VoucherID = s.VoucherID
|
||||
INNER JOIN Inventory i ON t.VoucherID = i.VoucherID
|
||||
INNER JOIN Products p ON i.ProductID = p.ProductID
|
||||
INNER JOIN Ledgers l ON p.SaleLedgerID = l.LedgerID
|
||||
INNER JOIN CostCenters c ON l.CostCenterID = c.CostCenterID
|
||||
WHERE t.Type = 's' AND s.Paid = 1 AND s.Void = 0
|
||||
AND t.LastEditDate BETWEEN @StartDate AND @FinishDate
|
||||
GROUP BY c.CostCenterID, c.Name
|
||||
ORDER BY Net DESC;";
|
||||
return session
|
||||
.CreateSQLQuery(query)
|
||||
.AddEntity(typeof(SalesAnalysis))
|
||||
.SetDateTime("StartDate", startDate)
|
||||
.SetDateTime("FinishDate", finishDate)
|
||||
.List<SalesAnalysis>();
|
||||
var query = @"
|
||||
select g.GroupType as GroupType, Sum(i.Quantity * i.Rate * (1 - i.Discount)) as Amount
|
||||
from SaleVoucher v
|
||||
inner join v.Inventories i
|
||||
inner join i.Product p
|
||||
inner join p.ProductGroup g
|
||||
where v.Date >= :startDate and v.Date <= :finishDate and v.Void = false and v.Settled != :noCharge
|
||||
group by g.GroupType
|
||||
order by g.GroupType
|
||||
";
|
||||
var list = session
|
||||
.CreateQuery(query)
|
||||
.SetParameter("startDate", startDate)
|
||||
.SetParameter("finishDate", finishDate)
|
||||
.SetParameter("noCharge", SettleOptionFactory.NoCharge)
|
||||
.List<object[]>();
|
||||
var outList = new List<SalesAnalysis>();
|
||||
foreach (var item in list)
|
||||
outList.Add(new SalesAnalysis() { GroupType = (string)item[0], Amount = (decimal)item[1] });
|
||||
return GetSettlement(outList, startDate, finishDate);
|
||||
}
|
||||
}
|
||||
public void GetAdditionalInfo(ref decimal freeSale, ref decimal voids, ref decimal pending, ref decimal net, ref decimal tax, DateTime startDate, DateTime finishDate)
|
||||
private IList<SalesAnalysis> GetSettlement(IList<SalesAnalysis> outList, DateTime startDate, DateTime finishDate)
|
||||
{
|
||||
string query;
|
||||
outList.Add(new SalesAnalysis() { GroupType = " -- ", Amount = 0 });
|
||||
if (finishDate <= startDate)
|
||||
return new List<SalesAnalysis>();
|
||||
using (var session = SessionManager.Session)
|
||||
{
|
||||
query = @"
|
||||
SELECT ISNULL(SUM(Quantity * Rate), 0) AS Amount
|
||||
FROM Vouchers t INNER JOIN SaleVoucher s ON t.VoucherID = s.VoucherID
|
||||
INNER JOIN Inventory i ON t.VoucherID = i.VoucherID
|
||||
WHERE t.Type = 's' AND s.Paid = 1 AND s.Void = 0
|
||||
AND t.LastEditDate BETWEEN @StartDate AND @FinishDate
|
||||
AND i.Amount = 0";
|
||||
freeSale = session
|
||||
.CreateSQLQuery(query)
|
||||
.AddEntity(typeof(decimal))
|
||||
.SetDateTime("StartDate", startDate)
|
||||
.SetDateTime("FinishDate", finishDate)
|
||||
.UniqueResult<decimal>();
|
||||
freeSale = Math.Round(freeSale);
|
||||
|
||||
query = @"
|
||||
SELECT ISNULL(SUM(Amount), 0) AS Amount
|
||||
FROM Vouchers t INNER JOIN SaleVoucher s ON t.VoucherID = s.VoucherID
|
||||
INNER JOIN Inventory i ON t.VoucherID = i.VoucherID
|
||||
WHERE t.Type = 's'
|
||||
AND t.LastEditDate BETWEEN @StartDate AND @FinishDate
|
||||
AND s.Void = 1";
|
||||
voids = session
|
||||
.CreateSQLQuery(query)
|
||||
.AddEntity(typeof(decimal))
|
||||
.SetDateTime("StartDate", startDate)
|
||||
.SetDateTime("FinishDate", finishDate)
|
||||
.UniqueResult<decimal>();
|
||||
voids = Math.Round(voids);
|
||||
|
||||
query = @"
|
||||
SELECT ISNULL(SUM(Amount), 0) AS Amount
|
||||
FROM Vouchers t INNER JOIN SaleVoucher s ON t.VoucherID = s.VoucherID
|
||||
INNER JOIN Inventory i ON t.VoucherID = i.VoucherID
|
||||
WHERE t.Type = 's' AND s.Paid = 0 AND s.Void = 0
|
||||
AND t.LastEditDate BETWEEN @StartDate AND @FinishDate
|
||||
ORDER BY Amount DESC;";
|
||||
pending = session
|
||||
.CreateSQLQuery(query)
|
||||
.AddEntity(typeof(decimal))
|
||||
.SetDateTime("StartDate", startDate)
|
||||
.SetDateTime("FinishDate", finishDate)
|
||||
.UniqueResult<decimal>();
|
||||
pending = Math.Round(pending);
|
||||
|
||||
query = @"
|
||||
SELECT ISNULL(SUM(Quantity * Rate * (1 - Discount )), 0) AS Amount
|
||||
FROM Vouchers t INNER JOIN SaleVoucher s ON t.VoucherID = s.VoucherID
|
||||
INNER JOIN Inventory i ON t.VoucherID = i.VoucherID
|
||||
WHERE t.Type = 's' AND s.Paid = 1 AND s.Void = 0
|
||||
AND t.LastEditDate BETWEEN @StartDate AND @FinishDate";
|
||||
net = session
|
||||
.CreateSQLQuery(query)
|
||||
.AddEntity(typeof(decimal))
|
||||
.SetDateTime("StartDate", startDate)
|
||||
.SetDateTime("FinishDate", finishDate)
|
||||
.UniqueResult<decimal>();
|
||||
net = Math.Round(net);
|
||||
|
||||
query = @"
|
||||
SELECT ISNULL(SUM(Amount), 0) AS Amount
|
||||
FROM Vouchers t INNER JOIN SaleVoucher s ON t.VoucherID = s.VoucherID
|
||||
INNER JOIN Inventory i ON t.VoucherID = i.VoucherID
|
||||
WHERE t.Type = 's' AND s.Paid = 1 AND s.Void = 0
|
||||
AND t.LastEditDate BETWEEN @StartDate AND @FinishDate";
|
||||
tax = session
|
||||
.CreateSQLQuery(query)
|
||||
.AddEntity(typeof(decimal))
|
||||
.SetDateTime("StartDate", startDate)
|
||||
.SetDateTime("FinishDate", finishDate)
|
||||
.UniqueResult<decimal>();
|
||||
tax = Math.Round(tax);
|
||||
var query = @"
|
||||
select s.Name, Sum(i.Quantity * i.Rate * (1 - i.Discount) * (1 + i.ServiceCharge) * (1 + i.Tax)) as Amount
|
||||
from SaleVoucher v
|
||||
inner join v.Inventories i
|
||||
inner join v.Settled s
|
||||
where v.Date >= :startDate and v.Date <= :finishDate and v.Void = false and v.Settled != :noCharge
|
||||
group by s.Name
|
||||
order by s.Name
|
||||
";
|
||||
var list = session
|
||||
.CreateQuery(query)
|
||||
.SetParameter("startDate", startDate)
|
||||
.SetParameter("finishDate", finishDate)
|
||||
.SetParameter("noCharge", SettleOptionFactory.NoCharge)
|
||||
.List<object[]>();
|
||||
foreach (var item in list)
|
||||
outList.Add(new SalesAnalysis() { GroupType = (string)item[0], Amount = (decimal)item[1] });
|
||||
return GetOtherDetails(outList, startDate, finishDate);
|
||||
}
|
||||
}
|
||||
public IList<SalesAnalysis> GetSalesTaxReturn(DateTime startDate, DateTime finishDate, ref decimal freeSale, ref decimal voids, ref decimal pending, ref decimal net, ref decimal tax)
|
||||
private IList<SalesAnalysis> GetOtherDetails(IList<SalesAnalysis> outList, DateTime startDate, DateTime finishDate)
|
||||
{
|
||||
IList<SalesAnalysis> list = new List<SalesAnalysis>();
|
||||
|
||||
string query;
|
||||
outList.Add(new SalesAnalysis() { GroupType = " -- ", Amount = 0 });
|
||||
if (finishDate <= startDate)
|
||||
return new List<SalesAnalysis>();
|
||||
using (var session = SessionManager.Session)
|
||||
{
|
||||
#region Service Charge
|
||||
var query = @"
|
||||
select Sum(i.Quantity * i.Rate * (1 - i.Discount) * i.ServiceCharge)
|
||||
from SaleVoucher v
|
||||
inner join v.Inventories i
|
||||
where v.Date >= :startDate and v.Date <= :finishDate and v.Void = false and v.Settled != :noCharge
|
||||
";
|
||||
var amt = session
|
||||
.CreateQuery(query)
|
||||
.SetParameter("startDate", startDate)
|
||||
.SetParameter("finishDate", finishDate)
|
||||
.SetParameter("noCharge", SettleOptionFactory.NoCharge)
|
||||
.UniqueResult();
|
||||
outList.Add(new SalesAnalysis() { GroupType = "Service Charge", Amount = (decimal)amt });
|
||||
#endregion
|
||||
#region Tax
|
||||
query = @"
|
||||
SELECT p.Name AS Product, pt.Name AS Section, SUM(i.Quantity) AS Quantity, SUM(Amount) AS Amount
|
||||
FROM Vouchers t INNER JOIN SaleVoucher s ON t.VoucherID = s.VoucherID
|
||||
INNER JOIN Inventory i ON t.VoucherID = i.VoucherID
|
||||
INNER JOIN Products p ON i.ProductID = p.ProductID
|
||||
INNER JOIN ProductTypes pt ON p.ProductTypeID = pt.ProductTypeID
|
||||
INNER JOIN Ledgers l ON p.SaleLedgerID = l.LedgerID
|
||||
WHERE t.Type = 'S' AND s.Paid = 1 AND s.Void = 0
|
||||
AND t.LastEditDate BETWEEN :StartDate AND :FinishDate AND l.CostCenterID = :CostCenterID
|
||||
GROUP BY p.Name, pt.Name
|
||||
ORDER BY Amount DESC;";
|
||||
list = session
|
||||
.CreateSQLQuery(query)
|
||||
.AddEntity(typeof(SalesAnalysis))
|
||||
.SetDateTime("StartDate", startDate)
|
||||
.SetDateTime("FinishDate", finishDate)
|
||||
.List<SalesAnalysis>();
|
||||
select i.Tax, Sum(i.Quantity * i.Rate * (1 - i.Discount) * (1 + i.ServiceCharge) * i.Tax)
|
||||
from SaleVoucher v
|
||||
inner join v.Inventories i
|
||||
where v.Date >= :startDate and v.Date <= :finishDate and v.Void = false and v.Settled != :noCharge
|
||||
group by i.Tax
|
||||
";
|
||||
var list = session
|
||||
.CreateQuery(query)
|
||||
.SetParameter("startDate", startDate)
|
||||
.SetParameter("finishDate", finishDate)
|
||||
.SetParameter("noCharge", SettleOptionFactory.NoCharge)
|
||||
.List<object[]>();
|
||||
foreach (var item in list)
|
||||
outList.Add(new SalesAnalysis() { GroupType = string.Format("Tax {0:P}", (decimal)item[0]), Amount = (decimal)item[1] });
|
||||
#endregion
|
||||
return outList;
|
||||
}
|
||||
GetAdditionalInfo(ref freeSale, ref voids, ref pending, ref net, ref tax, startDate, finishDate);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -64,20 +64,29 @@ namespace Tanshu.Accounts.Repository
|
||||
}
|
||||
public static IList<User> GetFilteredUsers(Dictionary<string, string> filter)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
using (var session = SessionManager.Session)
|
||||
{
|
||||
return session.CreateCriteria<User>()
|
||||
.Add(Restrictions.Like("Name", string.Format("%{0}%", filter["Name"])))
|
||||
.List<User>();
|
||||
}
|
||||
}
|
||||
public static bool ChangePassword(User userData, string newPassword)
|
||||
{
|
||||
using (var session = SessionManager.Session)
|
||||
{
|
||||
var dbUser = session.CreateCriteria<User>()
|
||||
.Add(Restrictions.Eq("Name", userData.Name))
|
||||
.Add(Restrictions.Eq("Password", userData.Password))
|
||||
.UniqueResult<User>();
|
||||
if (dbUser == null)
|
||||
return false;
|
||||
dbUser.Password = newPassword;
|
||||
session.Update(dbUser);
|
||||
using (var trans = session.BeginTransaction())
|
||||
{
|
||||
var dbUser = session.CreateCriteria<User>()
|
||||
.Add(Restrictions.Eq("Name", userData.Name))
|
||||
.Add(Restrictions.Eq("Password", userData.Password))
|
||||
.UniqueResult<User>();
|
||||
if (dbUser == null)
|
||||
return false;
|
||||
dbUser.Password = newPassword;
|
||||
session.Update(dbUser);
|
||||
trans.Commit();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ using NHibernate.Tool.hbm2ddl;
|
||||
using Tanshu.Accounts.Entities;
|
||||
using Tanshu.Accounts.Entities.Auth;
|
||||
using Tanshu.Accounts.SqlDAO;
|
||||
using System.Reflection;
|
||||
using Tanshu.Accounts.Contracts;
|
||||
|
||||
namespace Tanshu.Accounts.Repository
|
||||
{
|
||||
@@ -41,29 +43,16 @@ namespace Tanshu.Accounts.Repository
|
||||
{
|
||||
using (var session = SessionManager.StatelessSession)
|
||||
{
|
||||
session.Insert(GetRole(1, "Sales/Checkout"));
|
||||
session.Insert(GetRole(2, "Sales/SalesBill"));
|
||||
session.Insert(GetRole(3, "Sales/SaleDetail"));
|
||||
session.Insert(GetRole(4, "Sales/VoidPrintedBill"));
|
||||
session.Insert(GetRole(5, "Sales/EditBill"));
|
||||
session.Insert(GetRole(6, "Sales/PrintKOT"));
|
||||
session.Insert(GetRole(7, "Sales/PrintBill"));
|
||||
session.Insert(GetRole(8, "Sales/EditPrintedProduct"));
|
||||
session.Insert(GetRole(9, "Sales/ChangeRate"));
|
||||
session.Insert(GetRole(10, "Master/Products"));
|
||||
session.Insert(GetRole(11, "Security/ManageRoles"));
|
||||
session.Insert(GetRole(12, "Log/View"));
|
||||
session.Insert(GetRole(13, "Master/Owner"));
|
||||
|
||||
FieldInfo[] list = typeof(RoleConstants).GetFields(BindingFlags.Public | BindingFlags.Static);
|
||||
// write method names
|
||||
foreach (var item in list)
|
||||
{
|
||||
var role = (RoleConstants)item.GetValue(null);
|
||||
session.Insert(new Role() { Name = role.Role });
|
||||
}
|
||||
}
|
||||
}
|
||||
private static Role GetRole(int roleID, string name)
|
||||
{
|
||||
return new Role()
|
||||
{
|
||||
RoleID = roleID,
|
||||
Name = name
|
||||
};
|
||||
}
|
||||
#endregion
|
||||
#region user
|
||||
public static void InsertUser()
|
||||
@@ -91,10 +80,12 @@ namespace Tanshu.Accounts.Repository
|
||||
{
|
||||
session.Insert(GetGroup(1, "owner"));
|
||||
session.Insert(GetGroup(2, "waiter"));
|
||||
session.Insert(GetGroup(3, "captain"));
|
||||
session.Insert(GetGroup(4, "manager"));
|
||||
session.Insert(GetGroup(5, "controller"));
|
||||
session.Insert(GetGroup(6, "accountant"));
|
||||
session.Insert(GetGroup(3, "cashier"));
|
||||
session.Insert(GetGroup(4, "captain"));
|
||||
session.Insert(GetGroup(5, "senior captain"));
|
||||
session.Insert(GetGroup(6, "manager"));
|
||||
session.Insert(GetGroup(7, "controller"));
|
||||
session.Insert(GetGroup(8, "accountant"));
|
||||
}
|
||||
}
|
||||
private static Group GetGroup(int groupID, string name)
|
||||
@@ -130,7 +121,8 @@ namespace Tanshu.Accounts.Repository
|
||||
{
|
||||
using (var session = SessionManager.StatelessSession)
|
||||
{
|
||||
var owner = session.Get<Group>(1);
|
||||
#region owner
|
||||
var group = session.Get<Group>(1);
|
||||
var list = session.CreateCriteria<Role>()
|
||||
.List<Role>();
|
||||
foreach (var item in list)
|
||||
@@ -138,9 +130,74 @@ namespace Tanshu.Accounts.Repository
|
||||
session.Insert(new RoleGroup()
|
||||
{
|
||||
Role = item,
|
||||
Group = owner
|
||||
Group = group
|
||||
});
|
||||
}
|
||||
#endregion
|
||||
#region waiter
|
||||
group = session.Get<Group>(2);
|
||||
var role = session.CreateCriteria<Role>()
|
||||
.Add(Restrictions.Eq("Name", RoleConstants.PRINT_KOT.Role))
|
||||
.UniqueResult<Role>();
|
||||
session.Insert(new RoleGroup()
|
||||
{
|
||||
Role = role,
|
||||
Group = group
|
||||
});
|
||||
role = session.CreateCriteria<Role>()
|
||||
.Add(Restrictions.Eq("Name", RoleConstants.SALES.Role))
|
||||
.UniqueResult<Role>();
|
||||
session.Insert(new RoleGroup()
|
||||
{
|
||||
Role = role,
|
||||
Group = group
|
||||
});
|
||||
#endregion
|
||||
#region cashier
|
||||
group = session.Get<Group>(3);
|
||||
role = session.CreateCriteria<Role>()
|
||||
.Add(Restrictions.Eq("Name", RoleConstants.PRINT_BILL.Role))
|
||||
.UniqueResult<Role>();
|
||||
session.Insert(new RoleGroup() { Role = role, Group = group });
|
||||
role = session.CreateCriteria<Role>()
|
||||
.Add(Restrictions.Eq("Name", RoleConstants.SALES.Role))
|
||||
.UniqueResult<Role>();
|
||||
session.Insert(new RoleGroup() { Role = role, Group = group });
|
||||
role = session.CreateCriteria<Role>()
|
||||
.Add(Restrictions.Eq("Name", RoleConstants.SETTLE_BILL.Role))
|
||||
.UniqueResult<Role>();
|
||||
session.Insert(new RoleGroup() { Role = role, Group = group });
|
||||
role = session.CreateCriteria<Role>()
|
||||
.Add(Restrictions.Eq("Name", RoleConstants.DISCOUNT.Role))
|
||||
.UniqueResult<Role>();
|
||||
session.Insert(new RoleGroup() { Role = role, Group = group });
|
||||
#endregion
|
||||
#region senior captain
|
||||
group = session.Get<Group>(5);
|
||||
role = session.CreateCriteria<Role>()
|
||||
.Add(Restrictions.Eq("Name", RoleConstants.EDIT_PRINTED_PRODUCT.Role))
|
||||
.UniqueResult<Role>();
|
||||
session.Insert(new RoleGroup() { Role = role, Group = group });
|
||||
#endregion
|
||||
#region manager
|
||||
group = session.Get<Group>(6);
|
||||
role = session.CreateCriteria<Role>()
|
||||
.Add(Restrictions.Eq("Name", RoleConstants.CHANGE_RATE.Role))
|
||||
.UniqueResult<Role>();
|
||||
session.Insert(new RoleGroup() { Role = role, Group = group });
|
||||
role = session.CreateCriteria<Role>()
|
||||
.Add(Restrictions.Eq("Name", RoleConstants.VOID_BILL.Role))
|
||||
.UniqueResult<Role>();
|
||||
session.Insert(new RoleGroup() { Role = role, Group = group });
|
||||
role = session.CreateCriteria<Role>()
|
||||
.Add(Restrictions.Eq("Name", RoleConstants.EDIT_PRINTED_BILL.Role))
|
||||
.UniqueResult<Role>();
|
||||
session.Insert(new RoleGroup() { Role = role, Group = group });
|
||||
role = session.CreateCriteria<Role>()
|
||||
.Add(Restrictions.Eq("Name", RoleConstants.PRODUCTS.Role))
|
||||
.UniqueResult<Role>();
|
||||
session.Insert(new RoleGroup() { Role = role, Group = group });
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
@@ -360,66 +417,34 @@ namespace Tanshu.Accounts.Repository
|
||||
{
|
||||
using (var session = SessionManager.StatelessSession)
|
||||
{
|
||||
session.Insert(new FoodTable() { Location = "", Name = "1" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "2" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "3" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "4" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "5" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "6" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "7" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "8" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "9" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "10" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "11" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "12" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "13" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "14" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "15" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "16" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "17" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "18" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "19" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "20" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "21" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "22" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "23" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "24" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "25" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "26" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "27" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "28" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "29" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "30" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "31" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "32" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "33" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "34" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "35" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "36" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "37" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "38" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "39" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "40" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "41" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "42" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "43" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "44" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "45" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "46" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "47" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "48" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "49" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "50" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "51" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "52" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "53" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "54" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "55" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "56" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "57" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "58" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "59" });
|
||||
session.Insert(new FoodTable() { Location = "", Name = "60" });
|
||||
for (int i = 1; i < 34; i++)
|
||||
{
|
||||
session.Insert(new FoodTable() { Location = "", Name = i.ToString() });
|
||||
}
|
||||
for (int i = 40; i < 43; i++)
|
||||
{
|
||||
session.Insert(new FoodTable() { Location = "", Name = i.ToString() });
|
||||
}
|
||||
for (int i = 50; i < 52; i++)
|
||||
{
|
||||
session.Insert(new FoodTable() { Location = "", Name = i.ToString() });
|
||||
}
|
||||
for (int i = 60; i < 62; i++)
|
||||
{
|
||||
session.Insert(new FoodTable() { Location = "", Name = i.ToString() });
|
||||
}
|
||||
for (int i = 70; i < 91; i++)
|
||||
{
|
||||
session.Insert(new FoodTable() { Location = "", Name = i.ToString() });
|
||||
}
|
||||
for (int i = 1; i < 21; i++)
|
||||
{
|
||||
session.Insert(new FoodTable() { Location = "", Name = "B" + i.ToString() });
|
||||
}
|
||||
for (int i = 1; i < 11; i++)
|
||||
{
|
||||
session.Insert(new FoodTable() { Location = "", Name = "D" + i.ToString() });
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
+17
-3
@@ -3,14 +3,15 @@ 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;
|
||||
using Tanshu.Accounts.Repository;
|
||||
|
||||
namespace Tanshu.Accounts.PointOfSale
|
||||
namespace Tanshu.Accounts.Contracts
|
||||
{
|
||||
static class Session
|
||||
public static class Session
|
||||
{
|
||||
private static Dictionary<string, bool> roles;
|
||||
private static User currentUser;
|
||||
public static bool IsAuthenticated { get; private set; }
|
||||
public static User User
|
||||
@@ -30,8 +31,21 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
{
|
||||
currentUser = null;
|
||||
IsAuthenticated = false;
|
||||
roles = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static bool IsAllowed(RoleConstants role)
|
||||
{
|
||||
if (currentUser == null)
|
||||
return false;
|
||||
if (roles == null)
|
||||
roles = new Dictionary<string, bool>();
|
||||
if (!roles.ContainsKey(role.Role))
|
||||
roles.Add(role.Role, MembershipBI.IsUserInRole(currentUser.UserID, role.Role));
|
||||
return roles[role.Role];
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,10 +40,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.1.0.685, Culture=neutral, PublicKeyToken=8aa435e3cb308880, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Include\Fluent\FluentNHibernate.dll</HintPath>
|
||||
@@ -96,6 +92,7 @@
|
||||
<Compile Include="BusinessLayer\ManagementBI.cs" />
|
||||
<Compile Include="Fluent\CascadeConvention.cs" />
|
||||
<Compile Include="Fluent\NotNullConvention.cs" />
|
||||
<Compile Include="Lifetime\Session.cs" />
|
||||
<Compile Include="Ninject\SessionRepository.cs" />
|
||||
<Compile Include="Fluent\AllowNullConvention.cs" />
|
||||
<Compile Include="Fluent\SettleOptionFactory.cs" />
|
||||
|
||||
Reference in new issue
Block a user