2010-03-02 17:56:21 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Drawing;
|
2018-08-24 10:41:33 +00:00
|
|
|
|
using System.Linq;
|
2010-03-02 17:56:21 +00:00
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using Tanshu.Accounts.Contracts;
|
2011-03-11 18:49:48 +00:00
|
|
|
|
using Tanshu.Accounts.Entities;
|
2010-03-02 17:56:21 +00:00
|
|
|
|
using Tanshu.Accounts.Helpers;
|
2018-08-24 10:41:33 +00:00
|
|
|
|
using Tanshu.Accounts.Print;
|
2011-03-11 18:49:48 +00:00
|
|
|
|
using Tanshu.Accounts.Repository;
|
2010-03-02 17:56:21 +00:00
|
|
|
|
|
2011-03-11 18:49:48 +00:00
|
|
|
|
namespace Tanshu.Accounts.PointOfSale.Sales
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2016-03-31 08:43:26 +00:00
|
|
|
|
public partial class SalesForm : Form
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-06-23 12:47:48 +00:00
|
|
|
|
private ProductGroup _currentProductGroup;
|
2011-01-10 19:49:11 +00:00
|
|
|
|
public SalesForm(BillController billController)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2016-03-31 08:43:26 +00:00
|
|
|
|
_controller = billController;
|
|
|
|
|
this.Text = Session.User.Name;
|
2011-03-11 18:49:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-05-12 09:11:02 +00:00
|
|
|
|
private void ShowInfo()
|
2011-12-05 09:41:02 +00:00
|
|
|
|
{
|
2016-05-12 09:11:02 +00:00
|
|
|
|
Voucher voucher = _controller._voucher;
|
|
|
|
|
BillDict bill = _controller._bill;
|
2014-10-12 09:41:45 +00:00
|
|
|
|
if (voucher.VoucherID == Guid.Empty)
|
2011-12-05 09:41:02 +00:00
|
|
|
|
{
|
2016-03-31 06:57:39 +00:00
|
|
|
|
txtBillID.Text = "";
|
|
|
|
|
txtKotID.Text = "";
|
|
|
|
|
txtCreationDate.Text = "";
|
|
|
|
|
txtDate.Text = "";
|
|
|
|
|
txtLastEditDate.Text = "";
|
2011-12-05 09:41:02 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-11-06 10:39:11 +00:00
|
|
|
|
txtBillID.Text = voucher.FullBillID;
|
2014-11-02 08:03:31 +00:00
|
|
|
|
txtKotID.Text = "K-" + voucher.KotID.ToString();
|
2011-12-05 09:41:02 +00:00
|
|
|
|
txtCreationDate.Text = voucher.CreationDate.ToString("HH:mm dd-MMM-yyyy");
|
2014-11-06 10:39:11 +00:00
|
|
|
|
txtDate.Text = voucher.Date.ToString("HH:mm dd-MMM-yyyy");
|
2011-12-05 09:41:02 +00:00
|
|
|
|
txtLastEditDate.Text = voucher.LastEditDate.ToString("HH:mm dd-MMM-yyyy");
|
|
|
|
|
}
|
2016-03-31 06:57:39 +00:00
|
|
|
|
btnCustomer.Text = voucher.Customer.Name;
|
|
|
|
|
txtTableID.Text = voucher.Table == null ? "" : voucher.Table.Name;
|
|
|
|
|
txtPax.Text = voucher.Pax.ToString();
|
|
|
|
|
bindingSource.CurrencyManager.Position = Math.Min(bindingSource.CurrencyManager.Position, bill.Count - 1);
|
|
|
|
|
txtGrossTax.Text = string.Format("{0:#0.00}", bill.Tax);
|
|
|
|
|
txtDiscount.Text = string.Format("{0:#0.00}", bill.Discount);
|
|
|
|
|
txtServiceCharge.Text = string.Format("{0:#0.00}", bill.ServiceCharge);
|
|
|
|
|
txtGrossAmount.Text = string.Format("{0:#0.00}", bill.NetAmount);
|
|
|
|
|
txtAmount.Text = string.Format("{0:#0.00}", bill.Amount);
|
|
|
|
|
bindingSource.DataSource = bill.ToList();
|
|
|
|
|
dgvProducts.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells);
|
|
|
|
|
MoreButton(false);
|
2011-03-11 18:49:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-31 06:57:39 +00:00
|
|
|
|
public BillItemValue CurrentProduct
|
2011-03-11 18:49:48 +00:00
|
|
|
|
{
|
2016-03-31 06:57:39 +00:00
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (bindingSource.Position == -1)
|
|
|
|
|
return null;
|
2016-03-31 08:43:26 +00:00
|
|
|
|
var item = _controller._bill.ElementAt(bindingSource.Position);
|
2016-03-31 06:57:39 +00:00
|
|
|
|
return item.Key.BillItemType != BillItemType.Kot ? item.Value : null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public BillItemKey CurrentKey
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (bindingSource.Position == -1)
|
|
|
|
|
return null;
|
2016-03-31 08:43:26 +00:00
|
|
|
|
var item = _controller._bill.ElementAt(bindingSource.Position);
|
2016-03-31 06:57:39 +00:00
|
|
|
|
return item.Key;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public BillItemKey CurrentKot
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (bindingSource.Position == -1)
|
|
|
|
|
return null;
|
2016-03-31 08:43:26 +00:00
|
|
|
|
var item = _controller._bill.ElementAt(bindingSource.Position);
|
2016-03-31 06:57:39 +00:00
|
|
|
|
return item.Key.BillItemType == BillItemType.Kot ? item.Key : null;
|
|
|
|
|
}
|
2011-03-11 18:49:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-03-02 17:56:21 +00:00
|
|
|
|
private void SalesForm_KeyDown(object sender, KeyEventArgs e)
|
|
|
|
|
{
|
2011-01-09 23:36:24 +00:00
|
|
|
|
switch (e.KeyCode)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-01-09 23:36:24 +00:00
|
|
|
|
case Keys.F2:
|
|
|
|
|
{
|
2011-02-09 12:03:22 +00:00
|
|
|
|
btnQuantity_Click(sender, new EventArgs());
|
2011-01-09 23:36:24 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case Keys.F3:
|
|
|
|
|
{
|
|
|
|
|
btnDiscount_Click(sender, new EventArgs());
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case Keys.F4:
|
|
|
|
|
{
|
|
|
|
|
if (!e.Alt)
|
2016-03-31 06:57:39 +00:00
|
|
|
|
{
|
2016-03-31 08:43:26 +00:00
|
|
|
|
_controller.ShowCustomers();
|
2016-05-12 09:11:02 +00:00
|
|
|
|
ShowInfo();
|
2016-03-31 06:57:39 +00:00
|
|
|
|
}
|
2011-01-09 23:36:24 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case Keys.F8:
|
|
|
|
|
{
|
2016-03-31 08:43:26 +00:00
|
|
|
|
_controller.LoadBill(null);
|
2016-05-12 09:11:02 +00:00
|
|
|
|
ShowInfo();
|
2016-03-31 06:57:39 +00:00
|
|
|
|
FormState = SaleFormState.Billing;
|
2011-01-09 23:36:24 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case Keys.F11:
|
|
|
|
|
{
|
|
|
|
|
btnPrintBill_Click(sender, e);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case Keys.F12:
|
|
|
|
|
{
|
|
|
|
|
btnPrintKot_Click(sender, e);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case Keys.Delete:
|
|
|
|
|
{
|
2016-03-31 08:43:26 +00:00
|
|
|
|
_controller.SetQuantity(CurrentKey, CurrentProduct, -1, false);
|
2016-05-12 09:11:02 +00:00
|
|
|
|
ShowInfo();
|
2011-01-09 23:36:24 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case Keys.Add:
|
|
|
|
|
{
|
2016-03-31 08:43:26 +00:00
|
|
|
|
_controller.SetQuantity(CurrentKey, CurrentProduct, 1, false);
|
2016-05-12 09:11:02 +00:00
|
|
|
|
ShowInfo();
|
2011-01-09 23:36:24 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case Keys.Subtract:
|
|
|
|
|
{
|
2016-03-31 08:43:26 +00:00
|
|
|
|
_controller.SetQuantity(CurrentKey, CurrentProduct, -1, false);
|
2016-05-12 09:11:02 +00:00
|
|
|
|
ShowInfo();
|
2011-01-09 23:36:24 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case Keys.Up:
|
|
|
|
|
{
|
|
|
|
|
if ((bindingSource.Position >= 1) && (!dgvProducts.Focused))
|
|
|
|
|
bindingSource.Position -= 1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case Keys.Down:
|
|
|
|
|
{
|
|
|
|
|
if ((bindingSource.Position < bindingSource.Count - 1) && (!dgvProducts.Focused))
|
|
|
|
|
bindingSource.Position += 1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case Keys.Escape:
|
|
|
|
|
{
|
2016-03-31 08:43:26 +00:00
|
|
|
|
var canceled = _controller.CancelBillChanges();
|
2016-05-12 09:11:02 +00:00
|
|
|
|
ShowInfo();
|
2016-03-31 06:57:39 +00:00
|
|
|
|
if (canceled)
|
|
|
|
|
FormState = SaleFormState.Waiting;
|
2011-01-09 23:36:24 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SalesForm_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
2018-08-24 10:41:33 +00:00
|
|
|
|
var showSC = (bool)SettingBI.Get("Service Charge").Details["Enabled"];
|
|
|
|
|
txtServiceCharge.Visible = showSC;
|
|
|
|
|
lblServiceCharge.Visible = showSC;
|
2016-03-31 08:43:26 +00:00
|
|
|
|
var state = _controller.FormLoad();
|
2016-05-12 09:11:02 +00:00
|
|
|
|
ShowInfo();
|
2016-03-31 06:57:39 +00:00
|
|
|
|
FormState = state;
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-01-10 19:49:11 +00:00
|
|
|
|
private void btnCustomer_Click(object sender, EventArgs e)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2016-03-31 08:43:26 +00:00
|
|
|
|
_controller.ShowCustomers();
|
2016-05-12 09:11:02 +00:00
|
|
|
|
ShowInfo();
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-01-10 19:49:11 +00:00
|
|
|
|
private void btnVoid_Click(object sender, EventArgs e)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2016-03-31 08:43:26 +00:00
|
|
|
|
var voided = _controller.VoidBill();
|
2016-05-12 09:11:02 +00:00
|
|
|
|
ShowInfo();
|
2016-03-31 06:57:39 +00:00
|
|
|
|
if (voided)
|
|
|
|
|
FormState = SaleFormState.Waiting;
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
2011-03-11 18:49:48 +00:00
|
|
|
|
|
2016-03-29 09:36:46 +00:00
|
|
|
|
private void btnPrice_Click(object sender, EventArgs e)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2016-03-31 06:57:39 +00:00
|
|
|
|
var item = CurrentProduct;
|
|
|
|
|
if (item == null)
|
|
|
|
|
return;
|
2016-03-31 08:43:26 +00:00
|
|
|
|
_controller.SetPrice(CurrentProduct);
|
2016-05-12 09:11:02 +00:00
|
|
|
|
ShowInfo();
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
2011-03-11 18:49:48 +00:00
|
|
|
|
|
2010-03-02 17:56:21 +00:00
|
|
|
|
private void btnClear_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2016-03-31 08:43:26 +00:00
|
|
|
|
var canceled = _controller.CancelBillChanges();
|
2016-05-12 09:11:02 +00:00
|
|
|
|
ShowInfo();
|
2016-03-31 06:57:39 +00:00
|
|
|
|
if (canceled)
|
|
|
|
|
FormState = SaleFormState.Waiting;
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void dgvProducts_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
|
|
|
|
|
{
|
2011-03-11 18:49:48 +00:00
|
|
|
|
var dgv = sender as DataGridView;
|
2016-03-29 09:36:46 +00:00
|
|
|
|
var data = (KeyValuePair<BillItemKey, BillItemValue>)dgv.Rows[e.RowIndex].DataBoundItem;
|
2010-03-02 17:56:21 +00:00
|
|
|
|
|
2016-03-29 09:36:46 +00:00
|
|
|
|
if (data.Key.BillItemType == BillItemType.Kot)
|
2011-02-18 16:54:48 +00:00
|
|
|
|
{
|
|
|
|
|
e.CellStyle.SelectionBackColor = Color.Blue;
|
|
|
|
|
e.CellStyle.BackColor = Color.LightBlue;
|
|
|
|
|
}
|
2016-03-29 09:36:46 +00:00
|
|
|
|
else if (data.Value.inventory.Kot != null)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
|
|
|
|
e.CellStyle.SelectionBackColor = Color.HotPink;
|
|
|
|
|
e.CellStyle.BackColor = Color.LightPink;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
e.CellStyle.SelectionBackColor = Color.Green;
|
|
|
|
|
e.CellStyle.BackColor = Color.LightGreen;
|
|
|
|
|
}
|
2016-03-29 09:36:46 +00:00
|
|
|
|
if (dgv.Columns[e.ColumnIndex].Name.Equals("DisplayColumn"))
|
|
|
|
|
e.Value = data.Value.Display;
|
|
|
|
|
else if (dgv.Columns[e.ColumnIndex].Name.Equals("QuantityColumn"))
|
|
|
|
|
{
|
|
|
|
|
if (data.Key.BillItemType != BillItemType.Kot)
|
|
|
|
|
e.Value = data.Value.inventory.Quantity;
|
|
|
|
|
else
|
|
|
|
|
e.Value = "";
|
|
|
|
|
}
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-01-30 07:14:05 +00:00
|
|
|
|
private void btnSettle_Click(object sender, EventArgs e)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2016-03-31 08:43:26 +00:00
|
|
|
|
var settled = _controller.SettleBill();
|
2016-05-12 09:11:02 +00:00
|
|
|
|
ShowInfo();
|
2016-03-31 06:57:39 +00:00
|
|
|
|
if (settled)
|
|
|
|
|
FormState = SaleFormState.Waiting;
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
2011-01-17 14:55:43 +00:00
|
|
|
|
|
2011-01-30 07:14:05 +00:00
|
|
|
|
private void btnModifier_Click(object sender, EventArgs e)
|
2011-01-17 14:55:43 +00:00
|
|
|
|
{
|
2016-03-31 06:57:39 +00:00
|
|
|
|
var item = CurrentProduct;
|
|
|
|
|
if (item == null || CurrentKey.KotID != Guid.Empty)
|
|
|
|
|
return; // No Product or Old Product
|
|
|
|
|
|
2016-03-31 08:43:26 +00:00
|
|
|
|
_controller.ShowModifiers(item);
|
2016-05-12 09:11:02 +00:00
|
|
|
|
ShowInfo();
|
2011-01-17 14:55:43 +00:00
|
|
|
|
}
|
2011-01-31 20:33:22 +00:00
|
|
|
|
|
|
|
|
|
private void btnDelete_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2016-03-31 08:43:26 +00:00
|
|
|
|
_controller.SetQuantity(CurrentKey, CurrentProduct, -1, false);
|
2016-05-12 09:11:02 +00:00
|
|
|
|
ShowInfo();
|
2011-02-18 16:54:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnMoveTable_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2016-03-31 08:43:26 +00:00
|
|
|
|
_controller.MoveTable();
|
2016-05-12 09:11:02 +00:00
|
|
|
|
ShowInfo();
|
2011-02-18 16:54:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnMore_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var button = sender as Button;
|
2011-12-05 09:41:02 +00:00
|
|
|
|
if (button == null)
|
|
|
|
|
return;
|
2011-02-18 16:54:48 +00:00
|
|
|
|
if (button.Text == "More")
|
|
|
|
|
MoreButton(true);
|
|
|
|
|
else if (button.Text == "Less")
|
|
|
|
|
MoreButton(false);
|
2011-02-09 12:03:22 +00:00
|
|
|
|
else
|
2011-02-18 16:54:48 +00:00
|
|
|
|
throw new InvalidOperationException("Button State incorrect");
|
|
|
|
|
}
|
2011-03-11 18:49:48 +00:00
|
|
|
|
|
2011-02-18 16:54:48 +00:00
|
|
|
|
private void MoreButton(bool more)
|
|
|
|
|
{
|
|
|
|
|
btnMore.Text = more ? "Less" : "More";
|
|
|
|
|
btnQuantity.Visible = !more;
|
2016-03-29 09:36:46 +00:00
|
|
|
|
btnPrice.Visible = more;
|
2011-02-18 16:54:48 +00:00
|
|
|
|
btnDelete.Visible = !more;
|
|
|
|
|
btnDiscount.Visible = !more;
|
|
|
|
|
btnModifier.Visible = !more;
|
|
|
|
|
btnMoveTable.Visible = more;
|
|
|
|
|
btnMoveKot.Visible = more;
|
|
|
|
|
btnVoid.Visible = more;
|
2011-08-23 07:10:05 +00:00
|
|
|
|
btnSplitBill.Visible = more;
|
2011-01-31 20:33:22 +00:00
|
|
|
|
}
|
2011-02-18 16:54:48 +00:00
|
|
|
|
|
|
|
|
|
private void btnMoveKot_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2016-03-31 08:43:26 +00:00
|
|
|
|
_controller.MoveKot(CurrentKot);
|
2016-05-12 09:11:02 +00:00
|
|
|
|
ShowInfo();
|
2011-02-18 16:54:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-03-11 18:49:48 +00:00
|
|
|
|
#region Helper Functions
|
|
|
|
|
|
2016-03-31 06:57:39 +00:00
|
|
|
|
private SaleFormState FormState
|
2011-03-11 18:49:48 +00:00
|
|
|
|
{
|
2011-08-23 07:10:05 +00:00
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
flpGroup.Controls.Clear();
|
|
|
|
|
flpMain.Controls.Clear();
|
|
|
|
|
if (value == SaleFormState.Billing)
|
2014-11-02 08:03:31 +00:00
|
|
|
|
ControlFactory.GenerateGroups(ref flpGroup, new Point(75, 75), 0, Cache.ProductGroups(), productTypeButton_Click, productTypePage_Click);
|
2011-08-23 07:10:05 +00:00
|
|
|
|
else
|
2018-08-24 10:41:33 +00:00
|
|
|
|
ControlFactory.GenerateTables(ref flpMain, new Point(75, 75), 0, FoodTableBI.List(true), tableButton_Click, tablePage_Click);
|
2011-08-23 07:10:05 +00:00
|
|
|
|
|
|
|
|
|
}
|
2011-03-11 18:49:48 +00:00
|
|
|
|
}
|
|
|
|
|
private void productTypeButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var button = sender as Button;
|
|
|
|
|
if (button == null)
|
|
|
|
|
return;
|
|
|
|
|
var item = button.Tag as ProductGroup;
|
2011-12-05 09:41:02 +00:00
|
|
|
|
if (item == null)
|
|
|
|
|
return;
|
2014-10-12 09:41:45 +00:00
|
|
|
|
_currentProductGroup = item;
|
|
|
|
|
ControlFactory.GenerateProducts(ref flpMain, new Point(75, 75), 0,
|
2014-11-02 08:03:31 +00:00
|
|
|
|
item.Products, productButton_Click, productPage_Click);
|
2014-10-12 09:41:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void productTypePage_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var button = sender as Button;
|
|
|
|
|
if (button == null)
|
|
|
|
|
return;
|
|
|
|
|
var start = (int)button.Tag;
|
|
|
|
|
if (start < 0)
|
|
|
|
|
start = 0;
|
2014-11-02 08:03:31 +00:00
|
|
|
|
ControlFactory.GenerateGroups(ref flpGroup, new Point(75, 75), start, Cache.ProductGroups(), productTypeButton_Click, productTypePage_Click);
|
2011-03-11 18:49:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void productButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var button = sender as Button;
|
|
|
|
|
if (button == null)
|
|
|
|
|
return;
|
|
|
|
|
var item = button.Tag as Product;
|
2014-10-16 11:11:55 +00:00
|
|
|
|
if (item.IsNotAvailable)
|
|
|
|
|
return;
|
2016-03-31 08:43:26 +00:00
|
|
|
|
_controller.AddProduct(item);
|
|
|
|
|
bindingSource.DataSource = _controller._bill.ToList();
|
2016-04-11 07:01:52 +00:00
|
|
|
|
bindingSource.CurrencyManager.Position = _controller._bill.IndexOfKey(new BillItemKey(item.ProductID, Guid.Empty, item.HasHappyHour));
|
2018-08-24 10:41:33 +00:00
|
|
|
|
// TODO: Refactor this so that this is loaded in the cache with the products
|
|
|
|
|
if (CurrentProduct.inventory.Product.ProductGroup.IsModifierCompulsory)
|
2016-03-31 08:43:26 +00:00
|
|
|
|
_controller.ShowModifiers(CurrentProduct);
|
2016-05-12 09:11:02 +00:00
|
|
|
|
ShowInfo();
|
2014-10-12 09:41:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void productPage_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var button = sender as Button;
|
|
|
|
|
if (button == null)
|
|
|
|
|
return;
|
|
|
|
|
var item = button.Tag as Product;
|
|
|
|
|
var start = (int)button.Tag;
|
|
|
|
|
if (start < 0)
|
|
|
|
|
start = 0;
|
2014-11-02 08:03:31 +00:00
|
|
|
|
ControlFactory.GenerateProducts(ref flpMain, new Point(75, 75), start, _currentProductGroup.Products, productButton_Click, productPage_Click);
|
2011-03-11 18:49:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tableButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var button = sender as Button;
|
|
|
|
|
if (button == null)
|
|
|
|
|
return;
|
|
|
|
|
var item = button.Tag as FoodTable;
|
2014-10-12 09:41:45 +00:00
|
|
|
|
var tableName = item.Name;
|
2016-03-31 08:43:26 +00:00
|
|
|
|
_controller.LoadBill(tableName);
|
2016-05-12 09:11:02 +00:00
|
|
|
|
ShowInfo();
|
2014-10-12 09:41:45 +00:00
|
|
|
|
FormState = SaleFormState.Billing;
|
2011-03-11 18:49:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-10-12 09:41:45 +00:00
|
|
|
|
private void tablePage_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var button = sender as Button;
|
|
|
|
|
if (button == null)
|
|
|
|
|
return;
|
|
|
|
|
var start = (int)button.Tag;
|
|
|
|
|
if (start < 0)
|
|
|
|
|
start = 0;
|
2018-08-24 10:41:33 +00:00
|
|
|
|
ControlFactory.GenerateTables(ref flpMain, new Point(75, 75), start, FoodTableBI.List(true), tableButton_Click, tablePage_Click);
|
2014-10-12 09:41:45 +00:00
|
|
|
|
}
|
2011-03-11 18:49:48 +00:00
|
|
|
|
private void btnPrintBill_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2017-01-12 07:15:21 +00:00
|
|
|
|
btnPrintBill.Enabled = false;
|
2016-05-12 09:11:02 +00:00
|
|
|
|
bool isPrinted = false, isVoid = false;
|
|
|
|
|
if (_controller._voucher.VoucherID != Guid.Empty)
|
2018-08-24 10:41:33 +00:00
|
|
|
|
{
|
|
|
|
|
var dbVoucher = VoucherBI.Get(_controller._voucher.VoucherID);
|
|
|
|
|
isPrinted = dbVoucher.Printed;
|
|
|
|
|
isVoid = dbVoucher.Void;
|
|
|
|
|
}
|
2016-05-12 09:11:02 +00:00
|
|
|
|
|
2017-01-12 07:15:21 +00:00
|
|
|
|
if (_controller.CanSaveBill(isPrinted, isVoid))
|
2016-03-31 08:43:26 +00:00
|
|
|
|
{
|
2017-01-12 07:15:21 +00:00
|
|
|
|
var amount = _controller._bill.NetAmount;
|
|
|
|
|
_controller.SetDiscount();
|
2016-05-12 09:11:02 +00:00
|
|
|
|
ShowInfo();
|
2017-01-12 07:15:21 +00:00
|
|
|
|
var printed = _controller.SaveAndPrintBill(isPrinted, amount);
|
|
|
|
|
if (printed)
|
|
|
|
|
{
|
|
|
|
|
if (_controller._editVoucherID.HasValue)
|
|
|
|
|
this.Close();
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ShowInfo();
|
|
|
|
|
FormState = SaleFormState.Waiting;
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-03-31 08:43:26 +00:00
|
|
|
|
}
|
2017-01-12 07:15:21 +00:00
|
|
|
|
btnPrintBill.Enabled = true;
|
|
|
|
|
|
2011-03-11 18:49:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnPrintKot_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2017-01-12 07:15:21 +00:00
|
|
|
|
btnPrintKot.Enabled = false;
|
2016-03-31 08:43:26 +00:00
|
|
|
|
var printed = _controller.SaveAndPrintKot();
|
2017-01-12 07:15:21 +00:00
|
|
|
|
if (printed)
|
2016-03-31 08:43:26 +00:00
|
|
|
|
{
|
2017-01-12 07:15:21 +00:00
|
|
|
|
if (_controller._editVoucherID.HasValue)
|
|
|
|
|
this.Close();
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ShowInfo();
|
|
|
|
|
FormState = SaleFormState.Waiting;
|
|
|
|
|
}
|
2016-03-31 08:43:26 +00:00
|
|
|
|
}
|
2017-01-12 07:15:21 +00:00
|
|
|
|
btnPrintKot.Enabled = true;
|
2011-03-11 18:49:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnQuantity_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2016-03-31 08:43:26 +00:00
|
|
|
|
_controller.SetQuantity(CurrentKey, CurrentProduct, 0, true);
|
2016-05-12 09:11:02 +00:00
|
|
|
|
ShowInfo();
|
2011-03-11 18:49:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnDiscount_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2016-03-31 08:43:26 +00:00
|
|
|
|
_controller.SetDiscount();
|
2016-05-12 09:11:02 +00:00
|
|
|
|
ShowInfo();
|
2011-03-11 18:49:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
2011-08-23 07:10:05 +00:00
|
|
|
|
|
|
|
|
|
private void btnSplitBill_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2016-03-31 08:43:26 +00:00
|
|
|
|
_controller.SplitBill();
|
2016-05-12 09:11:02 +00:00
|
|
|
|
ShowInfo();
|
2011-08-23 07:10:05 +00:00
|
|
|
|
}
|
2011-03-11 18:49:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|