Chore: Rename _billController to _controller as it is shorter

Removed: Unused SelectorEvent Helper
Refactor: Removed references to SaleForm from BillController as it is not needed.
This commit is contained in:
tanshu
2016-03-31 14:13:26 +05:30
parent 51d518d2a0
commit 69cb7d8bce
7 changed files with 75 additions and 151 deletions

View File

@ -672,7 +672,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
private System.Windows.Forms.DataGridViewTextBoxColumn quantityColumn;
private System.Windows.Forms.Button btnMore;
private System.Windows.Forms.Button btnMoveKot;
private readonly BillController _billController;
private readonly BillController _controller;
private System.Windows.Forms.Button btnSplitBill;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.TextBox txtPax;

View File

@ -11,20 +11,14 @@ using Tanshu.Accounts.Repository;
namespace Tanshu.Accounts.PointOfSale.Sales
{
public partial class SalesForm : Form, ISaleForm
public partial class SalesForm : Form
{
private ProductGroup _currentProductGroup;
public SalesForm(BillController billController)
{
InitializeComponent();
_billController = billController;
billController.InitGui(this);
}
#region ISaleForm Members
public void SetUserName(string name)
{
Text = name;
_controller = billController;
this.Text = Session.User.Name;
}
private void ShowInfo(Voucher voucher, BillDict bill)
@ -65,7 +59,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
{
if (bindingSource.Position == -1)
return null;
var item = _billController._bill.ElementAt(bindingSource.Position);
var item = _controller._bill.ElementAt(bindingSource.Position);
return item.Key.BillItemType != BillItemType.Kot ? item.Value : null;
}
}
@ -76,7 +70,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
{
if (bindingSource.Position == -1)
return null;
var item = _billController._bill.ElementAt(bindingSource.Position);
var item = _controller._bill.ElementAt(bindingSource.Position);
return item.Key;
}
}
@ -87,18 +81,11 @@ namespace Tanshu.Accounts.PointOfSale.Sales
{
if (bindingSource.Position == -1)
return null;
var item = _billController._bill.ElementAt(bindingSource.Position);
var item = _controller._bill.ElementAt(bindingSource.Position);
return item.Key.BillItemType == BillItemType.Kot ? item.Key : null;
}
}
public void CloseWindow()
{
Close();
}
#endregion
private void SalesForm_KeyDown(object sender, KeyEventArgs e)
{
switch (e.KeyCode)
@ -117,15 +104,15 @@ namespace Tanshu.Accounts.PointOfSale.Sales
{
if (!e.Alt)
{
_billController.ShowCustomers();
ShowInfo(_billController._voucher, _billController._bill);
_controller.ShowCustomers();
ShowInfo(_controller._voucher, _controller._bill);
}
break;
}
case Keys.F8:
{
_billController.LoadBill(null);
ShowInfo(_billController._voucher, _billController._bill);
_controller.LoadBill(null);
ShowInfo(_controller._voucher, _controller._bill);
FormState = SaleFormState.Billing;
break;
}
@ -141,20 +128,20 @@ namespace Tanshu.Accounts.PointOfSale.Sales
}
case Keys.Delete:
{
_billController.SetQuantity(CurrentKey, CurrentProduct, -1, false);
ShowInfo(_billController._voucher, _billController._bill);
_controller.SetQuantity(CurrentKey, CurrentProduct, -1, false);
ShowInfo(_controller._voucher, _controller._bill);
break;
}
case Keys.Add:
{
_billController.SetQuantity(CurrentKey, CurrentProduct, 1, false);
ShowInfo(_billController._voucher, _billController._bill);
_controller.SetQuantity(CurrentKey, CurrentProduct, 1, false);
ShowInfo(_controller._voucher, _controller._bill);
break;
}
case Keys.Subtract:
{
_billController.SetQuantity(CurrentKey, CurrentProduct, -1, false);
ShowInfo(_billController._voucher, _billController._bill);
_controller.SetQuantity(CurrentKey, CurrentProduct, -1, false);
ShowInfo(_controller._voucher, _controller._bill);
break;
}
case Keys.Up:
@ -171,8 +158,8 @@ namespace Tanshu.Accounts.PointOfSale.Sales
}
case Keys.Escape:
{
var canceled = _billController.CancelBillChanges();
ShowInfo(_billController._voucher, _billController._bill);
var canceled = _controller.CancelBillChanges();
ShowInfo(_controller._voucher, _controller._bill);
if (canceled)
FormState = SaleFormState.Waiting;
break;
@ -188,22 +175,21 @@ namespace Tanshu.Accounts.PointOfSale.Sales
txtServiceCharge.Visible = showSC;
lblServiceCharge.Visible = showSC;
}
_billController.ClearBill();
var state = _billController.FormLoad();
ShowInfo(_billController._voucher, _billController._bill);
var state = _controller.FormLoad();
ShowInfo(_controller._voucher, _controller._bill);
FormState = state;
}
private void btnCustomer_Click(object sender, EventArgs e)
{
_billController.ShowCustomers();
ShowInfo(_billController._voucher, _billController._bill);
_controller.ShowCustomers();
ShowInfo(_controller._voucher, _controller._bill);
}
private void btnVoid_Click(object sender, EventArgs e)
{
var voided = _billController.VoidBill();
ShowInfo(_billController._voucher, _billController._bill);
var voided = _controller.VoidBill();
ShowInfo(_controller._voucher, _controller._bill);
if (voided)
FormState = SaleFormState.Waiting;
}
@ -213,14 +199,14 @@ namespace Tanshu.Accounts.PointOfSale.Sales
var item = CurrentProduct;
if (item == null)
return;
_billController.SetPrice(CurrentProduct);
ShowInfo(_billController._voucher, _billController._bill);
_controller.SetPrice(CurrentProduct);
ShowInfo(_controller._voucher, _controller._bill);
}
private void btnClear_Click(object sender, EventArgs e)
{
var canceled = _billController.CancelBillChanges();
ShowInfo(_billController._voucher, _billController._bill);
var canceled = _controller.CancelBillChanges();
ShowInfo(_controller._voucher, _controller._bill);
if (canceled)
FormState = SaleFormState.Waiting;
}
@ -258,8 +244,8 @@ namespace Tanshu.Accounts.PointOfSale.Sales
private void btnSettle_Click(object sender, EventArgs e)
{
var settled = _billController.SettleBill();
ShowInfo(_billController._voucher, _billController._bill);
var settled = _controller.SettleBill();
ShowInfo(_controller._voucher, _controller._bill);
if (settled)
FormState = SaleFormState.Waiting;
}
@ -270,20 +256,20 @@ namespace Tanshu.Accounts.PointOfSale.Sales
if (item == null || CurrentKey.KotID != Guid.Empty)
return; // No Product or Old Product
_billController.ShowModifiers(item);
ShowInfo(_billController._voucher, _billController._bill);
_controller.ShowModifiers(item);
ShowInfo(_controller._voucher, _controller._bill);
}
private void btnDelete_Click(object sender, EventArgs e)
{
_billController.SetQuantity(CurrentKey, CurrentProduct, -1, false);
ShowInfo(_billController._voucher, _billController._bill);
_controller.SetQuantity(CurrentKey, CurrentProduct, -1, false);
ShowInfo(_controller._voucher, _controller._bill);
}
private void btnMoveTable_Click(object sender, EventArgs e)
{
_billController.MoveTable();
ShowInfo(_billController._voucher, _billController._bill);
_controller.MoveTable();
ShowInfo(_controller._voucher, _controller._bill);
}
private void btnMore_Click(object sender, EventArgs e)
@ -315,8 +301,8 @@ namespace Tanshu.Accounts.PointOfSale.Sales
private void btnMoveKot_Click(object sender, EventArgs e)
{
_billController.MoveKot(CurrentKot);
ShowInfo(_billController._voucher, _billController._bill);
_controller.MoveKot(CurrentKot);
ShowInfo(_controller._voucher, _controller._bill);
}
#region Helper Functions
@ -367,16 +353,16 @@ namespace Tanshu.Accounts.PointOfSale.Sales
var item = button.Tag as Product;
if (item.IsNotAvailable)
return;
_billController.AddProduct(item);
bindingSource.DataSource = _billController._bill.ToList();
bindingSource.CurrencyManager.Position = _billController._bill.IndexOfKey(new BillItemKey(item.ProductID, Guid.Empty));
_controller.AddProduct(item);
bindingSource.DataSource = _controller._bill.ToList();
bindingSource.CurrencyManager.Position = _controller._bill.IndexOfKey(new BillItemKey(item.ProductID, Guid.Empty));
var showModifier = false;
using (var bi = new ProductGroupModifierBI())
showModifier = bi.HasCompulsoryModifier(CurrentProduct.inventory.Product.ProductGroup.ProductGroupID);
if (showModifier)
_billController.ShowModifiers(CurrentProduct);
ShowInfo(_billController._voucher, _billController._bill);
_controller.ShowModifiers(CurrentProduct);
ShowInfo(_controller._voucher, _controller._bill);
}
private void productPage_Click(object sender, EventArgs e)
@ -398,8 +384,8 @@ namespace Tanshu.Accounts.PointOfSale.Sales
return;
var item = button.Tag as FoodTable;
var tableName = item.Name;
_billController.LoadBill(tableName);
ShowInfo(_billController._voucher, _billController._bill);
_controller.LoadBill(tableName);
ShowInfo(_controller._voucher, _controller._bill);
FormState = SaleFormState.Billing;
}
@ -416,38 +402,50 @@ namespace Tanshu.Accounts.PointOfSale.Sales
}
private void btnPrintBill_Click(object sender, EventArgs e)
{
var printed = _billController.SaveAndPrintBill();
ShowInfo(_billController._voucher, _billController._bill);
if (printed)
var printed = _controller.SaveAndPrintBill();
if (!printed)
return;
if (_controller._editVoucherID.HasValue)
this.Close();
else
{
ShowInfo(_controller._voucher, _controller._bill);
FormState = SaleFormState.Waiting;
}
}
private void btnPrintKot_Click(object sender, EventArgs e)
{
var printed = _billController.SaveAndPrintKot();
ShowInfo(_billController._voucher, _billController._bill);
if (printed)
var printed = _controller.SaveAndPrintKot();
if (!printed)
return;
if (_controller._editVoucherID.HasValue)
this.Close();
else
{
ShowInfo(_controller._voucher, _controller._bill);
FormState = SaleFormState.Waiting;
}
}
private void btnQuantity_Click(object sender, EventArgs e)
{
_billController.SetQuantity(CurrentKey, CurrentProduct, 0, true);
ShowInfo(_billController._voucher, _billController._bill);
_controller.SetQuantity(CurrentKey, CurrentProduct, 0, true);
ShowInfo(_controller._voucher, _controller._bill);
}
private void btnDiscount_Click(object sender, EventArgs e)
{
_billController.SetDiscount();
ShowInfo(_billController._voucher, _billController._bill);
_controller.SetDiscount();
ShowInfo(_controller._voucher, _controller._bill);
}
#endregion
private void btnSplitBill_Click(object sender, EventArgs e)
{
_billController.SplitBill();
ShowInfo(_billController._voucher, _billController._bill);
_controller.SplitBill();
ShowInfo(_controller._voucher, _controller._bill);
}
}
}