2010-03-02 17:56:21 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using Tanshu.Accounts.BI;
|
|
|
|
|
using Tanshu.Accounts.Contracts;
|
|
|
|
|
using Tanshu.Accounts.Helpers;
|
|
|
|
|
using Tanshu.Common;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace Tanshu.Accounts.PointOfSale
|
|
|
|
|
{
|
2011-01-10 19:49:11 +00:00
|
|
|
|
public partial class SalesForm : Form, ISaleForm
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-01-10 19:49:11 +00:00
|
|
|
|
BillController billController;
|
2011-01-09 23:36:24 +00:00
|
|
|
|
List<Button> buttonList = new List<Button>();
|
|
|
|
|
List<Button> buttonHeads = new List<Button>();
|
|
|
|
|
int page = 0;
|
|
|
|
|
int pageSize = 6;
|
2011-01-13 20:21:02 +00:00
|
|
|
|
|
2011-01-10 19:49:11 +00:00
|
|
|
|
public SalesForm(BillController billController)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2011-01-10 19:49:11 +00:00
|
|
|
|
this.billController = billController;
|
|
|
|
|
billController.InitGui(this);
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-01-10 19:49:11 +00:00
|
|
|
|
public SalesForm(Guid voucherID, BillController billController)
|
|
|
|
|
: this(billController)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-01-10 19:49:11 +00:00
|
|
|
|
billController.SetNewBillID(voucherID);
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-01-10 19:49:11 +00:00
|
|
|
|
public void SetUserName(string name)
|
|
|
|
|
{
|
|
|
|
|
this.Text = name;
|
|
|
|
|
}
|
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:
|
|
|
|
|
{
|
|
|
|
|
if (dgvProducts.Rows.Count > 0)
|
2011-01-10 19:49:11 +00:00
|
|
|
|
billController.SetQuantity(billController.CurrentProduct(dgvProducts.CurrentRow.Index), bindingSource, 0, false, true);
|
2011-01-09 23:36:24 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case Keys.F3:
|
|
|
|
|
{
|
|
|
|
|
btnDiscount_Click(sender, new EventArgs());
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case Keys.F4:
|
|
|
|
|
{
|
|
|
|
|
if (!e.Alt)
|
2011-01-10 19:49:11 +00:00
|
|
|
|
billController.ShowCustomerList(false);
|
2011-01-09 23:36:24 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case Keys.F5:
|
|
|
|
|
{
|
|
|
|
|
btnWaiter_Click(sender, new EventArgs());
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case Keys.F7:
|
|
|
|
|
{
|
2011-01-22 12:38:30 +00:00
|
|
|
|
using (SelectProduct selectProduct = new SelectProduct(ProductBI.GetFilteredProducts, true))
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-01-09 23:36:24 +00:00
|
|
|
|
selectProduct.ShowDialog();
|
|
|
|
|
if (selectProduct.SelectedItem != null)
|
2011-01-10 19:49:11 +00:00
|
|
|
|
billController.AddProductToGrid(selectProduct.SelectedItem.ProductID, bindingSource);
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
2011-01-09 23:36:24 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case Keys.F8:
|
|
|
|
|
{
|
2011-01-13 20:21:02 +00:00
|
|
|
|
billController.LoadBillFromTable(null);
|
2011-01-09 23:36:24 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case Keys.F9:
|
|
|
|
|
{
|
|
|
|
|
if (dgvProducts.Rows.Count > 0)
|
2011-01-10 19:49:11 +00:00
|
|
|
|
billController.SetAmount(billController.CurrentProduct(dgvProducts.CurrentRow.Index), bindingSource, -1);
|
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:
|
|
|
|
|
{
|
|
|
|
|
if (dgvProducts.Rows.Count > 0)
|
2011-01-10 19:49:11 +00:00
|
|
|
|
billController.ProductRemove(billController.CurrentProduct(dgvProducts.CurrentRow.Index));
|
2011-01-09 23:36:24 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case Keys.Add:
|
|
|
|
|
{
|
|
|
|
|
if (dgvProducts.Rows.Count > 0)
|
2011-01-10 19:49:11 +00:00
|
|
|
|
billController.SetQuantity(billController.CurrentProduct(dgvProducts.CurrentRow.Index), bindingSource, 1, false, false);
|
2011-01-09 23:36:24 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case Keys.Subtract:
|
|
|
|
|
{
|
|
|
|
|
if (dgvProducts.Rows.Count > 0)
|
2011-01-10 19:49:11 +00:00
|
|
|
|
billController.SetQuantity(billController.CurrentProduct(dgvProducts.CurrentRow.Index), bindingSource, -1, false, false);
|
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:
|
|
|
|
|
{
|
2011-01-10 19:49:11 +00:00
|
|
|
|
billController.CancelBillChanges();
|
2011-01-09 23:36:24 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region Helper Functions
|
2011-01-10 19:49:11 +00:00
|
|
|
|
public void ClearBill(Dictionary<BillItemKey, SalesBillItemBO> bill)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
|
|
|
|
this.txtBillID.Text = "";
|
|
|
|
|
this.txtKotID.Text = "";
|
|
|
|
|
this.txtCreationDate.Text = "";
|
|
|
|
|
this.txtDate.Text = "";
|
|
|
|
|
this.txtLastEditDate.Text = "";
|
|
|
|
|
this.txtTableID.Text = "";
|
|
|
|
|
this.btnWaiter.Text = "Waiter - F5";
|
|
|
|
|
this.btnWaiter.Tag = null;
|
|
|
|
|
txtGrossTax.Text = "0.00";
|
|
|
|
|
txtDiscount.Text = "0.00";
|
2011-01-17 14:55:43 +00:00
|
|
|
|
txtServiceCharge.Text = "0.00";
|
2010-03-02 17:56:21 +00:00
|
|
|
|
txtGrossAmount.Text = "0.00";
|
|
|
|
|
txtAmount.Text = "0.00";
|
|
|
|
|
bindingSource.DataSource = bill.Values;
|
2011-01-13 20:21:02 +00:00
|
|
|
|
ChangeFormState(SaleFormState.Waiting);
|
|
|
|
|
}
|
|
|
|
|
private void ChangeFormState(SaleFormState state)
|
|
|
|
|
{
|
|
|
|
|
foreach (var button in buttonList)
|
|
|
|
|
button.Dispose();
|
|
|
|
|
foreach (var button in buttonHeads)
|
|
|
|
|
button.Dispose();
|
|
|
|
|
buttonList = new List<Button>();
|
|
|
|
|
buttonHeads = new List<Button>();
|
|
|
|
|
if (state == SaleFormState.Billing)
|
|
|
|
|
{
|
|
|
|
|
btnPrevious.Visible = true;
|
|
|
|
|
btnNext.Visible = true;
|
|
|
|
|
page = 0;
|
2011-01-22 12:38:30 +00:00
|
|
|
|
var list = new ProductGroupBI().GetProductGroups();
|
2011-01-13 20:21:02 +00:00
|
|
|
|
ControlFactory.GenerateButtons(ref pnlBilling, ref buttonHeads, new Rectangle(889, 90, 85, 498), 1, pageSize, 2, page, list, new ButtonClickDelegate(productTypeButton_Click));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
btnPrevious.Visible = false;
|
|
|
|
|
btnNext.Visible = false;
|
|
|
|
|
ControlFactory.GenerateTables(ref pnlBilling, ref buttonHeads, new Rectangle(390, 94, 499, 385), 6, 10, 2, new FoodTableBI().GetFoodTables(), new ButtonClickDelegate(tableButton_Click));
|
|
|
|
|
}
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
2011-01-22 12:38:30 +00:00
|
|
|
|
public void ShowModifiers(Guid productGroupID)
|
|
|
|
|
{
|
|
|
|
|
ControlFactory.GenerateModifiers(ref pnlBilling, ref buttonList, new Rectangle(390, 94, 499, 385), 5, 6, 2, ProductGroupModifierBI.GetProductGroupModifiers(productGroupID), new ButtonClickDelegate(modifierButton_Click));
|
|
|
|
|
}
|
|
|
|
|
private void modifierButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Button button = sender as Button;
|
|
|
|
|
if (button == null)
|
|
|
|
|
return;
|
|
|
|
|
string tag = (string)button.Tag;
|
|
|
|
|
billController.AddModifier(tag);
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-09 23:36:24 +00:00
|
|
|
|
private void productTypeButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Button button = sender as Button;
|
|
|
|
|
if (button == null)
|
|
|
|
|
return;
|
|
|
|
|
Guid tag = (Guid)button.Tag;
|
2011-01-22 12:38:30 +00:00
|
|
|
|
ControlFactory.GenerateButtons(ref pnlBilling, ref buttonList, new Rectangle(390, 94, 499, 385), 5, 6, 2, ProductBI.GetProducts(tag), new ButtonClickDelegate(productButton_Click));
|
2011-01-09 23:36:24 +00:00
|
|
|
|
}
|
|
|
|
|
private void productButton_Click(object sender, EventArgs e)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
|
|
|
|
Button button = sender as Button;
|
|
|
|
|
if (button == null)
|
|
|
|
|
return;
|
|
|
|
|
Guid tag = (Guid)button.Tag;
|
2011-01-10 19:49:11 +00:00
|
|
|
|
billController.AddProductToGrid(tag, bindingSource);
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
2011-01-09 23:36:24 +00:00
|
|
|
|
private void tableButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Button button = sender as Button;
|
|
|
|
|
if (button == null)
|
|
|
|
|
return;
|
2011-01-13 20:21:02 +00:00
|
|
|
|
string tableName = button.Text;
|
|
|
|
|
billController.LoadBillFromTable(tableName);
|
|
|
|
|
txtTableID.Text = tableName;
|
|
|
|
|
ChangeFormState(SaleFormState.Billing);
|
2011-01-09 23:36:24 +00:00
|
|
|
|
}
|
2011-01-17 14:55:43 +00:00
|
|
|
|
public void ShowAmount(decimal discountAmount, decimal grossAmount, decimal serviceChargeAmount, decimal taxAmount, decimal valueAmount, List<SalesBillItemBO> bill)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-01-17 14:55:43 +00:00
|
|
|
|
txtGrossTax.Text = string.Format("{0:#0.00}", taxAmount);
|
|
|
|
|
txtDiscount.Text = string.Format("{0:#0.00}", discountAmount);
|
|
|
|
|
txtServiceCharge.Text = string.Format("{0:#0.00}", serviceChargeAmount);
|
2011-01-10 19:49:11 +00:00
|
|
|
|
txtGrossAmount.Text = string.Format("{0:#0.00}", grossAmount);
|
2011-01-17 14:55:43 +00:00
|
|
|
|
txtAmount.Text = string.Format("{0:#0.00}", Math.Round(valueAmount));
|
2011-01-10 19:49:11 +00:00
|
|
|
|
bindingSource.DataSource = bill;
|
2010-03-02 17:56:21 +00:00
|
|
|
|
dgvProducts.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnPrintBill_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2011-01-10 19:49:11 +00:00
|
|
|
|
if (btnWaiter.Tag == null)
|
|
|
|
|
btnWaiter.Tag = new WaiterBI().GetWaiters()[0].WaiterID;
|
|
|
|
|
billController.Save(true, (Guid)btnWaiter.Tag, txtTableID.Text);
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
private void btnPrintKot_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2011-01-10 19:49:11 +00:00
|
|
|
|
if (btnWaiter.Tag == null)
|
|
|
|
|
btnWaiter.Tag = new WaiterBI().GetWaiters()[0].WaiterID;
|
|
|
|
|
billController.Save(false, (Guid)btnWaiter.Tag, txtTableID.Text);
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
private void btnMultiPrint_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2011-01-10 19:49:11 +00:00
|
|
|
|
if (btnWaiter.Tag == null)
|
|
|
|
|
btnWaiter.Tag = new WaiterBI().GetWaiters()[0].WaiterID;
|
|
|
|
|
billController.Save(true, (Guid)btnWaiter.Tag, txtTableID.Text);
|
|
|
|
|
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
private void btnCancel_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2011-01-10 19:49:11 +00:00
|
|
|
|
billController.CancelBillChanges();
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnQuantity_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (dgvProducts.Rows.Count > 0)
|
2011-01-10 19:49:11 +00:00
|
|
|
|
billController.SetQuantity(billController.CurrentProduct(dgvProducts.CurrentRow.Index), bindingSource, 0, false, true);
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
private void btnDiscount_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (dgvProducts.Rows.Count > 0)
|
2011-01-10 19:49:11 +00:00
|
|
|
|
billController.SetDiscount(billController.CurrentProduct(dgvProducts.CurrentRow.Index), -1);
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
private void SalesForm_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
2011-01-10 19:49:11 +00:00
|
|
|
|
billController.FormLoad();
|
2011-01-13 20:21:02 +00:00
|
|
|
|
ChangeFormState(SaleFormState.Waiting);
|
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
|
|
|
|
{
|
2011-01-10 19:49:11 +00:00
|
|
|
|
billController.ShowCustomerList(false);
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-01-10 19:49:11 +00:00
|
|
|
|
public void SetCustomerDisplay(string name)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-01-10 19:49:11 +00:00
|
|
|
|
btnCustomer.Text = name;
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
2011-01-10 19:49:11 +00:00
|
|
|
|
public void ShowInfo(string billID, string kotID, DateTime creationDate, DateTime date, DateTime lastEditDate, string customer, string tableID, Guid waiterID, string waiter)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-01-10 19:49:11 +00:00
|
|
|
|
this.txtBillID.Text = billID;
|
|
|
|
|
this.txtKotID.Text = kotID;
|
|
|
|
|
this.txtCreationDate.Text = creationDate.ToString("HH:mm dd-MMM-yyyy");
|
|
|
|
|
this.txtDate.Text = date.ToString("HH:mm dd-MMM-yyyy");
|
|
|
|
|
this.txtLastEditDate.Text = lastEditDate.ToString("HH:mm dd-MMM-yyyy");
|
|
|
|
|
this.btnCustomer.Text = customer;
|
|
|
|
|
this.txtTableID.Text = tableID;
|
|
|
|
|
this.btnWaiter.Tag = waiterID;
|
|
|
|
|
this.btnWaiter.Text = string.Format("{0} - F5", waiter);
|
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
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2011-01-10 19:49:11 +00:00
|
|
|
|
billController.VoidBill();
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
2011-01-10 19:49:11 +00:00
|
|
|
|
catch (PermissionException ex)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-01-10 19:49:11 +00:00
|
|
|
|
MessageBox.Show(ex.Message);
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void btnRate_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2011-01-10 19:49:11 +00:00
|
|
|
|
if (dgvProducts.Rows.Count > 0)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-01-10 19:49:11 +00:00
|
|
|
|
billController.ChangeRate(dgvProducts.CurrentRow.Index);
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void btnClear_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2011-01-10 19:49:11 +00:00
|
|
|
|
billController.ClearBill();
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void dgvProducts_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
DataGridView dgv = sender as DataGridView;
|
|
|
|
|
SalesBillItemBO data = dgv.Rows[e.RowIndex].DataBoundItem as SalesBillItemBO;
|
|
|
|
|
|
|
|
|
|
if (data.Printed > 0)
|
|
|
|
|
{
|
|
|
|
|
e.CellStyle.SelectionBackColor = Color.HotPink;
|
|
|
|
|
e.CellStyle.BackColor = Color.LightPink;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
e.CellStyle.SelectionBackColor = Color.Green;
|
|
|
|
|
e.CellStyle.BackColor = Color.LightGreen;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnWaiter_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
using (SelectWaiter selectWaiter = new SelectWaiter(new WaiterBI().GetFilteredWaiters, true))
|
|
|
|
|
{
|
|
|
|
|
selectWaiter.waiterEvent += new WaiterEventHandler(selectWaiter_waiterEvent);
|
|
|
|
|
selectWaiter.ShowDialog();
|
|
|
|
|
if (selectWaiter.SelectedItem != null)
|
|
|
|
|
{
|
|
|
|
|
btnWaiter.Text = string.Format("{0} - F5", selectWaiter.SelectedItem.Name);
|
|
|
|
|
btnWaiter.Tag = selectWaiter.SelectedItem.WaiterID;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
btnWaiter.Text = "Select Waiter - F5";
|
|
|
|
|
btnWaiter.Tag = new WaiterBI().GetWaiters()[0].WaiterID;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
WaiterBO selectWaiter_waiterEvent(object sender, WaiterEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
WaiterBO waiter = e.Waiter;
|
|
|
|
|
if (!Thread.CurrentPrincipal.IsInRole("Waiter/Master"))
|
|
|
|
|
return waiter;
|
|
|
|
|
|
|
|
|
|
switch (e.Action)
|
|
|
|
|
{
|
|
|
|
|
case 1: // Add
|
|
|
|
|
new WaiterBI().Insert(waiter);
|
|
|
|
|
e.Handled = true;
|
|
|
|
|
return waiter;
|
|
|
|
|
case 2: // Edit
|
|
|
|
|
new WaiterBI().Update(waiter);
|
|
|
|
|
e.Handled = true;
|
|
|
|
|
return waiter;
|
|
|
|
|
case 3: // Delete
|
|
|
|
|
e.Handled = new WaiterBI().Delete(waiter.WaiterID);
|
|
|
|
|
return new WaiterBI().GetWaiter(1);
|
|
|
|
|
default:
|
|
|
|
|
throw new ArgumentException();
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-01-10 19:49:11 +00:00
|
|
|
|
public void CloseWindow()
|
|
|
|
|
{
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
2011-01-09 23:36:24 +00:00
|
|
|
|
#region Dynamic Buttons
|
|
|
|
|
private void btnPrevious_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
page--;
|
2011-01-22 12:38:30 +00:00
|
|
|
|
var list = new ProductGroupBI().GetProductGroups();
|
2011-01-09 23:36:24 +00:00
|
|
|
|
if (page == -1)
|
|
|
|
|
page = 0;
|
|
|
|
|
|
|
|
|
|
ControlFactory.GenerateButtons(ref pnlBilling, ref buttonHeads, new Rectangle(889, 90, 85, 498), 1, pageSize, 2, page, list, new ButtonClickDelegate(productTypeButton_Click));
|
|
|
|
|
}
|
|
|
|
|
private void btnNext_Click(object sender, EventArgs e)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-01-09 23:36:24 +00:00
|
|
|
|
page++;
|
2011-01-22 12:38:30 +00:00
|
|
|
|
var list = new ProductGroupBI().GetProductGroups();
|
2011-01-09 23:36:24 +00:00
|
|
|
|
int pages = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(list.Count) / Convert.ToDouble(pageSize)));
|
|
|
|
|
if (page == pages)
|
|
|
|
|
page--;
|
2010-03-02 17:56:21 +00:00
|
|
|
|
|
2011-01-09 23:36:24 +00:00
|
|
|
|
ControlFactory.GenerateButtons(ref pnlBilling, ref buttonHeads, new Rectangle(889, 90, 85, 498), 1, pageSize, 2, page, list, new ButtonClickDelegate(productTypeButton_Click));
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
2011-01-09 23:36:24 +00:00
|
|
|
|
#endregion
|
2011-01-17 14:55:43 +00:00
|
|
|
|
|
|
|
|
|
private void btnSettle_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
billController.SettleBill();
|
|
|
|
|
}
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|