Feature: Added SortOrder to Inventory.

Chore: Settle Choices form greatly simplified.
Feature: Modifiers are now cached.
This commit is contained in:
tanshu 2014-11-10 16:36:49 +05:30
parent 3706d8eb1e
commit c52f382ec2
12 changed files with 247 additions and 130 deletions

@ -75,6 +75,7 @@ GO
InventoryID UNIQUEIDENTIFIER not null,
KotID UNIQUEIDENTIFIER not null,
ProductID UNIQUEIDENTIFIER not null,
SortOrder int not null,
Quantity DECIMAL(19,5) not null,
Price DECIMAL(19,5) not null,
FullPrice DECIMAL(19,5) not null,

@ -103,11 +103,11 @@ SELECT ID, Code, Name, Units,
ServiceCharge, IsScTaxable, Price, FullPrice, CASE Discontinued WHEN 0 THEN 1 ELSE 0 END, 0, SortOrder, BaseCode, Quantity
from Gets.dbo.Entities_Products AS p;
INSERT INTO Inventories (InventoryID, KotID, ProductID, Quantity, Price, FullPrice, ServiceCharge, IsScTaxable, ServiceTaxRate, VatRate, ServiceTaxID, VatID, Discount)
INSERT INTO Inventories (InventoryID, KotID, ProductID, SortOrder, Quantity, Price, FullPrice, ServiceCharge, IsScTaxable, ServiceTaxRate, VatRate, ServiceTaxID, VatID, Discount)
SELECT ID,
(SELECT k.ID FROM Gets.dbo.Entities_Kots k WHERE k.KotID = i.KotID),
(SELECT p.ID FROM Gets.dbo.Entities_Products p WHERE p.ProductID = i.ProductID),
Quantity, Price, FullPrice, ServiceCharge, IsScTaxable, ServiceTax, Vat,
0, Quantity, Price, FullPrice, ServiceCharge, IsScTaxable, ServiceTax, Vat,
(SELECT s.ID FROM Gets.dbo.Entities_Taxes s WHERE s.Rate = i.ServiceTax),
(SELECT v.ID FROM Gets.dbo.Entities_Taxes v WHERE v.Rate = i.Vat),
Discount

@ -0,0 +1,101 @@
BEGIN TRANSACTION
ALTER TABLE dbo.Inventories DROP CONSTRAINT FK8C0CFB221DECC269;
GO
ALTER TABLE dbo.Inventories DROP CONSTRAINT FK8C0CFB22EB4DE5BC;
GO
ALTER TABLE dbo.Inventories DROP CONSTRAINT FK8C0CFB223F88CAB6;
GO
ALTER TABLE dbo.Inventories DROP CONSTRAINT FK8C0CFB22DB70F42;
GO
CREATE TABLE dbo.Tmp_Inventories
(
InventoryID uniqueidentifier NOT NULL,
KotID uniqueidentifier NOT NULL,
ProductID uniqueidentifier NOT NULL,
SortOrder int NOT NULL,
Quantity decimal(19, 5) NOT NULL,
Price decimal(19, 5) NOT NULL,
FullPrice decimal(19, 5) NOT NULL,
ServiceCharge decimal(19, 5) NOT NULL,
IsScTaxable bit NOT NULL,
ServiceTaxRate decimal(19, 5) NOT NULL,
VatRate decimal(19, 5) NOT NULL,
ServiceTaxID uniqueidentifier NOT NULL,
VatID uniqueidentifier NOT NULL,
Discount decimal(19, 5) NOT NULL,
Amount AS (case when [IsScTaxable]=(1) then ((([Quantity]*[Price])*((1)-[Discount]))*((1)+[ServiceCharge]))*(((1)+[ServiceTaxRate])+[VatRate]) else (([Quantity]*[Price])*((1)-[Discount]))*((((1)+[ServiceCharge])+[ServiceTaxRate])+[VatRate]) end)
) ON [PRIMARY]
GO
IF EXISTS(SELECT * FROM dbo.Inventories)
EXEC('INSERT INTO dbo.Tmp_Inventories (InventoryID, KotID, ProductID, SortOrder, Quantity, Price, FullPrice, ServiceCharge, IsScTaxable, ServiceTaxRate, VatRate, ServiceTaxID, VatID, Discount)
SELECT InventoryID, KotID, ProductID, 0, Quantity, Price, FullPrice, ServiceCharge, IsScTaxable, ServiceTaxRate, VatRate, ServiceTaxID, VatID, Discount FROM dbo.Inventories WITH (HOLDLOCK TABLOCKX)')
GO
ALTER TABLE dbo.InventoryModifiers DROP CONSTRAINT FK80820FB4BA29671A
GO
DROP TABLE dbo.Inventories
GO
EXECUTE sp_rename N'dbo.Tmp_Inventories', N'Inventories', 'OBJECT'
GO
ALTER TABLE dbo.Inventories ADD CONSTRAINT
PK__Inventories__0DAF0CB0 PRIMARY KEY CLUSTERED
(
InventoryID
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
ALTER TABLE dbo.Inventories ADD CONSTRAINT
FK8C0CFB22DB70F42 FOREIGN KEY
(
KotID
) REFERENCES dbo.Kots
(
KotID
) ON UPDATE NO ACTION
ON DELETE NO ACTION
GO
ALTER TABLE dbo.Inventories ADD CONSTRAINT
FK8C0CFB223F88CAB6 FOREIGN KEY
(
ProductID
) REFERENCES dbo.Products
(
ProductID
) ON UPDATE NO ACTION
ON DELETE NO ACTION
GO
ALTER TABLE dbo.Inventories ADD CONSTRAINT
FK8C0CFB221DECC269 FOREIGN KEY
(
ServiceTaxID
) REFERENCES dbo.Taxes
(
TaxID
) ON UPDATE NO ACTION
ON DELETE NO ACTION
GO
ALTER TABLE dbo.Inventories ADD CONSTRAINT
FK8C0CFB22EB4DE5BC FOREIGN KEY
(
VatID
) REFERENCES dbo.Taxes
(
TaxID
) ON UPDATE NO ACTION
ON DELETE NO ACTION
GO
ALTER TABLE dbo.InventoryModifiers ADD CONSTRAINT
FK80820FB4BA29671A FOREIGN KEY
(
InventoryID
) REFERENCES dbo.Inventories
(
InventoryID
) ON UPDATE NO ACTION
ON DELETE NO ACTION
GO
COMMIT

@ -16,6 +16,7 @@ namespace Tanshu.Accounts.Entities
public virtual Guid InventoryID { get; set; }
public virtual Kot Kot { get; set; }
public virtual int SortOrder { get; set; }
public virtual Product Product { get; set; }
public virtual decimal Quantity { get; set; }
public virtual decimal Price { get; set; }
@ -49,6 +50,7 @@ namespace Tanshu.Accounts.Entities
Schema("dbo");
Lazy(true);
Id(x => x.InventoryID, m => m.Generator(Generators.GuidComb));
Property(x => x.SortOrder, map => map.NotNullable(true));
Property(x => x.Quantity, map => map.NotNullable(true));
Property(x => x.Price, map => map.NotNullable(true));
Property(x => x.FullPrice, map => map.NotNullable(true));

@ -69,7 +69,12 @@ namespace Tanshu.Accounts.Entities
map.Cascade(Cascade.None);
});
Bag(x => x.Inventories, colmap => { colmap.Key(x => x.Column("KotID")); colmap.Inverse(true); }, map => { map.OneToMany(); });
Bag(x => x.Inventories, colmap =>
{
colmap.Key(x => x.Column("KotID"));
colmap.Inverse(true);
colmap.OrderBy(x => x.SortOrder);
}, map => { map.OneToMany(); });
}
}
}

@ -88,22 +88,19 @@ namespace Tanshu.Accounts.PointOfSale
if (bi.HasCompulsoryModifier(product.ProductGroup.ProductGroupID))
{
var item = CurrentProduct;
ShowModifiers(product.ProductGroup.ProductGroupID, item);
ShowModifiers(item);
}
}
ShowAmount();
}
public void ShowModifiers(Guid productGroupID, BillItemValue item)
public void ShowModifiers(BillItemValue item)
{
if (item.Printed)
return;
using (var bi = new ProductGroupModifierBI())
using (var frm = new ModifierForm(Cache.ProductGroupModifiers(item.Product.ProductGroup.ProductGroupID), item.Modifiers))
{
using (var frm = new ModifierForm(bi.List(productGroupID), item.Modifiers))
{
frm.ShowDialog();
item.Modifiers = frm.Selection;
}
frm.ShowDialog();
item.Modifiers = frm.Selection;
}
ShowAmount();
}
@ -425,7 +422,7 @@ namespace Tanshu.Accounts.PointOfSale
{
using (var bi = new FoodTableBI())
{
using (var frm = new MoveTableForm(bi.List(x=>x.IsActive), allowMerge))
using (var frm = new MoveTableForm(bi.List(x => x.IsActive), allowMerge))
{
frm.ShowDialog();
if (frm.Selection != null)

@ -35,6 +35,8 @@
this.btnCustomer = new System.Windows.Forms.Button();
this.btnProduct = new System.Windows.Forms.Button();
this.btnProductGroup = new System.Windows.Forms.Button();
this.btnReorderTables = new System.Windows.Forms.Button();
this.btnModifiers = new System.Windows.Forms.Button();
this.btnOpenBill = new System.Windows.Forms.Button();
this.btnCreateUser = new System.Windows.Forms.Button();
this.btnUserRoles = new System.Windows.Forms.Button();
@ -48,8 +50,6 @@
this.btnChangePassword = new System.Windows.Forms.Button();
this.btnExit = new System.Windows.Forms.Button();
this.btnManagement = new System.Windows.Forms.Button();
this.btnReorderTables = new System.Windows.Forms.Button();
this.btnModifiers = new System.Windows.Forms.Button();
this.flowLayoutPanel1.SuspendLayout();
this.SuspendLayout();
//
@ -58,7 +58,7 @@
this.btnLogin.Location = new System.Drawing.Point(3, 3);
this.btnLogin.Name = "btnLogin";
this.btnLogin.Size = new System.Drawing.Size(150, 100);
this.btnLogin.TabIndex = 1;
this.btnLogin.TabIndex = 0;
this.btnLogin.Text = "&Login";
this.btnLogin.UseVisualStyleBackColor = true;
this.btnLogin.Click += new System.EventHandler(this.btnLogin_Click);
@ -68,7 +68,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 = 3;
this.btnSale.TabIndex = 2;
this.btnSale.Text = "&Sale";
this.btnSale.UseVisualStyleBackColor = true;
this.btnSale.Click += new System.EventHandler(this.btnSale_Click);
@ -107,7 +107,7 @@
this.btnSwipeLogin.Location = new System.Drawing.Point(159, 3);
this.btnSwipeLogin.Name = "btnSwipeLogin";
this.btnSwipeLogin.Size = new System.Drawing.Size(150, 100);
this.btnSwipeLogin.TabIndex = 2;
this.btnSwipeLogin.TabIndex = 1;
this.btnSwipeLogin.Text = "Swipe Login";
this.btnSwipeLogin.UseVisualStyleBackColor = true;
this.btnSwipeLogin.Click += new System.EventHandler(this.btnSwipeLogin_Click);
@ -117,7 +117,7 @@
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 = 4;
this.btnCustomer.TabIndex = 3;
this.btnCustomer.Text = "Customers";
this.btnCustomer.UseVisualStyleBackColor = true;
this.btnCustomer.Click += new System.EventHandler(this.btnCustomer_Click);
@ -127,7 +127,7 @@
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 = 5;
this.btnProduct.TabIndex = 4;
this.btnProduct.Text = "Products";
this.btnProduct.UseVisualStyleBackColor = true;
this.btnProduct.Click += new System.EventHandler(this.btnProduct_Click);
@ -137,17 +137,37 @@
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 = 6;
this.btnProductGroup.TabIndex = 5;
this.btnProductGroup.Text = "Product Groups";
this.btnProductGroup.UseVisualStyleBackColor = true;
this.btnProductGroup.Click += new System.EventHandler(this.btnProductGroup_Click);
//
// btnReorderTables
//
this.btnReorderTables.Location = new System.Drawing.Point(159, 109);
this.btnReorderTables.Name = "btnReorderTables";
this.btnReorderTables.Size = new System.Drawing.Size(150, 100);
this.btnReorderTables.TabIndex = 6;
this.btnReorderTables.Text = "Reorder Tables";
this.btnReorderTables.UseVisualStyleBackColor = true;
this.btnReorderTables.Click += new System.EventHandler(this.btnReorderTables_Click);
//
// btnModifiers
//
this.btnModifiers.Location = new System.Drawing.Point(315, 109);
this.btnModifiers.Name = "btnModifiers";
this.btnModifiers.Size = new System.Drawing.Size(150, 100);
this.btnModifiers.TabIndex = 7;
this.btnModifiers.Text = "Product Modifiers";
this.btnModifiers.UseVisualStyleBackColor = true;
this.btnModifiers.Click += new System.EventHandler(this.btnModifiers_Click);
//
// btnOpenBill
//
this.btnOpenBill.Location = new System.Drawing.Point(471, 109);
this.btnOpenBill.Name = "btnOpenBill";
this.btnOpenBill.Size = new System.Drawing.Size(150, 100);
this.btnOpenBill.TabIndex = 7;
this.btnOpenBill.TabIndex = 8;
this.btnOpenBill.Text = "Open Bill";
this.btnOpenBill.UseVisualStyleBackColor = true;
this.btnOpenBill.Click += new System.EventHandler(this.btnOpenBill_Click);
@ -157,7 +177,7 @@
this.btnCreateUser.Location = new System.Drawing.Point(627, 109);
this.btnCreateUser.Name = "btnCreateUser";
this.btnCreateUser.Size = new System.Drawing.Size(150, 100);
this.btnCreateUser.TabIndex = 10;
this.btnCreateUser.TabIndex = 9;
this.btnCreateUser.Text = "Create User";
this.btnCreateUser.UseVisualStyleBackColor = true;
this.btnCreateUser.Click += new System.EventHandler(this.btnCreateUser_Click);
@ -167,7 +187,7 @@
this.btnUserRoles.Location = new System.Drawing.Point(3, 215);
this.btnUserRoles.Name = "btnUserRoles";
this.btnUserRoles.Size = new System.Drawing.Size(150, 100);
this.btnUserRoles.TabIndex = 11;
this.btnUserRoles.TabIndex = 10;
this.btnUserRoles.Text = "Manage User Roles";
this.btnUserRoles.UseVisualStyleBackColor = true;
this.btnUserRoles.Click += new System.EventHandler(this.btnUserRoles_Click);
@ -177,7 +197,7 @@
this.btnGroupRoles.Location = new System.Drawing.Point(159, 215);
this.btnGroupRoles.Name = "btnGroupRoles";
this.btnGroupRoles.Size = new System.Drawing.Size(150, 100);
this.btnGroupRoles.TabIndex = 12;
this.btnGroupRoles.TabIndex = 11;
this.btnGroupRoles.Text = "Manage Group Roles";
this.btnGroupRoles.UseVisualStyleBackColor = true;
this.btnGroupRoles.Click += new System.EventHandler(this.btnGroupRoles_Click);
@ -187,7 +207,7 @@
this.btnCashierCheckout.Location = new System.Drawing.Point(315, 215);
this.btnCashierCheckout.Name = "btnCashierCheckout";
this.btnCashierCheckout.Size = new System.Drawing.Size(150, 100);
this.btnCashierCheckout.TabIndex = 13;
this.btnCashierCheckout.TabIndex = 12;
this.btnCashierCheckout.Text = "Cashier Checkout";
this.btnCashierCheckout.UseVisualStyleBackColor = true;
this.btnCashierCheckout.Click += new System.EventHandler(this.btnCashierCheckout_Click);
@ -197,7 +217,7 @@
this.btnSaleAnalysis.Location = new System.Drawing.Point(471, 215);
this.btnSaleAnalysis.Name = "btnSaleAnalysis";
this.btnSaleAnalysis.Size = new System.Drawing.Size(150, 100);
this.btnSaleAnalysis.TabIndex = 14;
this.btnSaleAnalysis.TabIndex = 13;
this.btnSaleAnalysis.Text = "Sale Analysis";
this.btnSaleAnalysis.UseVisualStyleBackColor = true;
this.btnSaleAnalysis.Click += new System.EventHandler(this.btnSaleAnalysis_Click);
@ -207,7 +227,7 @@
this.btnSaleDetail.Location = new System.Drawing.Point(627, 215);
this.btnSaleDetail.Name = "btnSaleDetail";
this.btnSaleDetail.Size = new System.Drawing.Size(150, 100);
this.btnSaleDetail.TabIndex = 15;
this.btnSaleDetail.TabIndex = 14;
this.btnSaleDetail.Text = "Sale Detail";
this.btnSaleDetail.UseVisualStyleBackColor = true;
this.btnSaleDetail.Click += new System.EventHandler(this.btnSaleDetail_Click);
@ -217,7 +237,7 @@
this.btnBillDetails.Location = new System.Drawing.Point(3, 321);
this.btnBillDetails.Name = "btnBillDetails";
this.btnBillDetails.Size = new System.Drawing.Size(150, 100);
this.btnBillDetails.TabIndex = 16;
this.btnBillDetails.TabIndex = 15;
this.btnBillDetails.Text = "Bill Details";
this.btnBillDetails.UseVisualStyleBackColor = true;
this.btnBillDetails.Click += new System.EventHandler(this.btnBillDetails_Click);
@ -227,7 +247,7 @@
this.btnVoidOrReprints.Location = new System.Drawing.Point(159, 321);
this.btnVoidOrReprints.Name = "btnVoidOrReprints";
this.btnVoidOrReprints.Size = new System.Drawing.Size(150, 100);
this.btnVoidOrReprints.TabIndex = 19;
this.btnVoidOrReprints.TabIndex = 16;
this.btnVoidOrReprints.Text = "Voids or Reprints";
this.btnVoidOrReprints.UseVisualStyleBackColor = true;
this.btnVoidOrReprints.Click += new System.EventHandler(this.btnVoidOrReprints_Click);
@ -237,7 +257,7 @@
this.btnDiscountReport.Location = new System.Drawing.Point(315, 321);
this.btnDiscountReport.Name = "btnDiscountReport";
this.btnDiscountReport.Size = new System.Drawing.Size(150, 100);
this.btnDiscountReport.TabIndex = 21;
this.btnDiscountReport.TabIndex = 17;
this.btnDiscountReport.Text = "Discount Report";
this.btnDiscountReport.UseVisualStyleBackColor = true;
this.btnDiscountReport.Click += new System.EventHandler(this.btnDiscountReport_Click);
@ -247,7 +267,7 @@
this.btnChangePassword.Location = new System.Drawing.Point(471, 321);
this.btnChangePassword.Name = "btnChangePassword";
this.btnChangePassword.Size = new System.Drawing.Size(150, 100);
this.btnChangePassword.TabIndex = 17;
this.btnChangePassword.TabIndex = 18;
this.btnChangePassword.Text = "Change Password";
this.btnChangePassword.UseVisualStyleBackColor = true;
this.btnChangePassword.Click += new System.EventHandler(this.btnChangePassword_Click);
@ -257,7 +277,7 @@
this.btnExit.Location = new System.Drawing.Point(627, 321);
this.btnExit.Name = "btnExit";
this.btnExit.Size = new System.Drawing.Size(150, 100);
this.btnExit.TabIndex = 18;
this.btnExit.TabIndex = 19;
this.btnExit.Text = "Exit";
this.btnExit.UseVisualStyleBackColor = true;
this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
@ -272,26 +292,6 @@
this.btnManagement.UseVisualStyleBackColor = true;
this.btnManagement.Click += new System.EventHandler(this.btnManagement_Click);
//
// btnReorderTables
//
this.btnReorderTables.Location = new System.Drawing.Point(159, 109);
this.btnReorderTables.Name = "btnReorderTables";
this.btnReorderTables.Size = new System.Drawing.Size(150, 100);
this.btnReorderTables.TabIndex = 22;
this.btnReorderTables.Text = "Reorder Tables";
this.btnReorderTables.UseVisualStyleBackColor = true;
this.btnReorderTables.Click += new System.EventHandler(this.btnReorderTables_Click);
//
// btnModifiers
//
this.btnModifiers.Location = new System.Drawing.Point(315, 109);
this.btnModifiers.Name = "btnModifiers";
this.btnModifiers.Size = new System.Drawing.Size(150, 100);
this.btnModifiers.TabIndex = 23;
this.btnModifiers.Text = "Product Modifiers";
this.btnModifiers.UseVisualStyleBackColor = true;
this.btnModifiers.Click += new System.EventHandler(this.btnModifiers_Click);
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);

@ -234,10 +234,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
if (item == null)
return;
Guid id;
using (var bi = new ProductGroupBI())
id = bi.GetProductGroupOfProduct(item.ProductID).ProductGroupID;
_billController.ShowModifiers(id, item);
_billController.ShowModifiers(item);
}
private void btnDelete_Click(object sender, EventArgs e)

@ -35,7 +35,8 @@
//
// txtAmount
//
this.txtAmount.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.txtAmount.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtAmount.Location = new System.Drawing.Point(3, 3);
this.txtAmount.Name = "txtAmount";
this.txtAmount.ReadOnly = true;

@ -11,74 +11,20 @@ namespace Tanshu.Accounts.PointOfSale
{
public partial class SettleChoicesForm : Form
{
private readonly IDictionary<Button, int> _list;
private decimal _amount;
private decimal _totalAmount;
private readonly VoucherType _voucherType;
public SettleChoicesForm(decimal amount, VoucherType voucherType)
private IDictionary<SettleOption, decimal> _optionsChosen;
public SettleChoicesForm(decimal totalAmount, VoucherType voucherType)
{
InitializeComponent();
_amount = amount;
_totalAmount = totalAmount;
_voucherType = voucherType;
OptionsChosen = new Dictionary<SettleOption, decimal>();
_list = new Dictionary<Button, int>();
}
private void ButtonClick(object sender, EventArgs e)
{
var button = sender as Button;
if (button == null || button.Tag == null)
return;
if (button.Tag is SettleOption)
{
var settleOption = (SettleOption)button.Tag;
using (var frm = new SettleAmountsForm(new NumpadControl(), settleOption, _amount))
{
frm.ShowDialog();
UpdateChoice(settleOption, frm.AmountSettled, _list[button]);
}
}
else
{
if ((string)button.Tag == "Cancel")
_optionsChosen.Clear();
this.Close();
}
}
private void UpdateChoice(SettleOption settleOption, decimal amount, int group)
{
var oldAmount = _optionsChosen.ContainsKey(settleOption) ? _optionsChosen[settleOption] : 0;
if (amount == 0 && _optionsChosen.ContainsKey(settleOption))
_optionsChosen.Remove(settleOption);
else if (_optionsChosen.ContainsKey(settleOption))
_optionsChosen[settleOption] = amount;
else if (amount != 0)
_optionsChosen.Add(settleOption, amount);
_amount += oldAmount - amount;
txtAmount.Text = string.Format("Pending Amount: Rs. {0}", _amount);
if (_optionsChosen.Count == 0)
foreach (var item in _list)
item.Key.Enabled = true;
else
foreach (var item in _list.Where(item => item.Value != group))
item.Key.Enabled = false;
}
private IDictionary<SettleOption, decimal> _optionsChosen;
public IDictionary<SettleOption, decimal> OptionsChosen
{
get
{
return _amount == 0 ? _optionsChosen : new Dictionary<SettleOption, decimal>();
}
private set { _optionsChosen = value; }
_optionsChosen = new Dictionary<SettleOption, decimal>();
}
private void SettleChoicesFormLoad(object sender, EventArgs e)
{
txtAmount.Text = string.Format("Pending Amount: Rs. {0}", _amount);
txtAmount.Text = string.Format("Pending Amount: Rs. {0}", PendingAmount);
var count = 0;
foreach (SettleOption item in Enum.GetValues(typeof(SettleOption)))
{
@ -86,17 +32,16 @@ namespace Tanshu.Accounts.PointOfSale
if (!attribute.ShowInChoices || attribute.Group != _voucherType.Attribute().Group)
continue;
var button = new Button
{
Name = item.ToString(),
Text = attribute.Name,
Size = new Size(75, 75),
TabIndex = count,
UseVisualStyleBackColor = true,
Tag = item
};
{
Name = item.ToString(),
Text = attribute.Name,
Size = new Size(75, 75),
TabIndex = count,
UseVisualStyleBackColor = true,
Tag = item,
};
button.Click += new EventHandler(ButtonClick);
flpSettlement.Controls.Add(button);
_list.Add(button, attribute.Group);
count++;
}
var controlButton = new Button
@ -108,9 +53,8 @@ namespace Tanshu.Accounts.PointOfSale
UseVisualStyleBackColor = true,
Tag = "OK"
};
controlButton.Click += new EventHandler(ButtonClick);
controlButton.Click += new EventHandler(OkClick);
flpSettlement.Controls.Add(controlButton);
// _list.Add(controlButton); --- Do not add to list
count++;
controlButton = new Button
{
@ -121,9 +65,8 @@ namespace Tanshu.Accounts.PointOfSale
UseVisualStyleBackColor = true,
Tag = "Cancel"
};
controlButton.Click += new EventHandler(ButtonClick);
controlButton.Click += new EventHandler(CancelClick);
flpSettlement.Controls.Add(controlButton);
// _list.Add(controlButton); --- Do not add to list
count++;
txtAmount.TabIndex = count;
@ -131,5 +74,55 @@ namespace Tanshu.Accounts.PointOfSale
txtAmount.Width = flpSettlement.Width - 6;
}
private void ButtonClick(object sender, EventArgs e)
{
var settleOption = (SettleOption)((sender as Button).Tag);
using (var frm = new SettleAmountsForm(new NumpadControl(), settleOption, PendingAmount))
{
frm.ShowDialog();
UpdateChoice(settleOption, frm.AmountSettled);
}
}
private void UpdateChoice(SettleOption settleOption, decimal amount)
{
if (amount == 0 && _optionsChosen.ContainsKey(settleOption))
_optionsChosen.Remove(settleOption);
else if (amount != 0 && _optionsChosen.ContainsKey(settleOption))
_optionsChosen[settleOption] = amount;
else if (amount != 0 && !_optionsChosen.ContainsKey(settleOption))
_optionsChosen.Add(settleOption, amount);
else if (_totalAmount == 0 && amount == 0 && !_optionsChosen.ContainsKey(settleOption))
_optionsChosen.Add(settleOption, amount);
txtAmount.Text = string.Format("Pending Amount: Rs. {0}", PendingAmount);
}
private decimal PendingAmount
{
get
{
decimal amount = _totalAmount;
foreach (var item in _optionsChosen)
{
amount -= item.Value;
}
return amount;
}
}
public IDictionary<SettleOption, decimal> OptionsChosen
{
get
{
return PendingAmount == 0 ? _optionsChosen : new Dictionary<SettleOption, decimal>();
}
}
private void OkClick(object sender, EventArgs e)
{
this.Close();
}
private void CancelClick(object sender, EventArgs e)
{
_optionsChosen.Clear();
this.Close();
}
}
}

@ -13,6 +13,7 @@ namespace Tanshu.Accounts.Repository
{
private static IList<ProductGroup> cache = null;
private static Dictionary<int, PrintLocation> locations = new Dictionary<int, PrintLocation>();
private static Dictionary<Guid, IList<Modifier>> modifiers = new Dictionary<Guid, IList<Modifier>>();
private static string location = ConfigurationManager.AppSettings["Location"].ToLowerInvariant();
private static IList<Role> roles = null;
@ -62,6 +63,18 @@ namespace Tanshu.Accounts.Repository
}
return locations[location.GetHashCode() ^ productGroupID.GetHashCode()];
}
public static IList<Modifier> ProductGroupModifiers(Guid productGroupID)
{
if (!modifiers.ContainsKey(productGroupID))
{
using (var bi = new ProductGroupModifierBI())
{
var list = bi.List(productGroupID);
modifiers.Add(productGroupID, list);
}
}
return modifiers[productGroupID];
}
public static IList<Role> UserRoles(Guid userID)
{
if (roles == null)
@ -82,6 +95,7 @@ namespace Tanshu.Accounts.Repository
{
cache = null;
locations = new Dictionary<int, PrintLocation>();
modifiers = new Dictionary<Guid, IList<Modifier>>();
}
public static bool Log
{

@ -24,9 +24,12 @@ namespace Tanshu.Accounts.Repository
item.User = voucher.User;
UpdateBillType(voucher);
_session.Save(item);
int index = 0;
foreach (var inv in item.Inventories)
{
inv.Kot = item;
inv.SortOrder = index;
index++;
_session.Save(inv);
foreach (var modifier in inv.InventoryModifier)
{
@ -72,9 +75,12 @@ namespace Tanshu.Accounts.Repository
item.Table = voucher.Table;
item.User = voucher.User;
_session.Save(item);
int index = 0;
foreach (var inv in item.Inventories)
{
inv.Kot = item;
inv.SortOrder = index;
index++;
_session.Save(inv);
foreach (var modifier in inv.InventoryModifier)
{