Inital branch of Bengali Development

This commit is contained in:
unknown
2011-12-05 14:53:02 +05:30
parent 232a62f8ca
commit e2db77ea70
57 changed files with 1721 additions and 1580 deletions

View File

@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Tanshu.Accounts.Helpers;
using System.Data.SqlClient;
using System.Configuration;
using Tanshu.Accounts.BI;
using Tanshu.Accounts.Contracts;
@ -11,20 +7,24 @@ namespace Tanshu.Accounts.PointOfSale
{
public partial class AdjustAdvanceForm : Form
{
bool loading = true;
public AdjustAdvanceForm()
bool _loading = true;
private readonly bool _fromSaleForm;
private Guid? _advanceID;
public AdjustAdvanceForm(bool fromSaleForm)
{
_fromSaleForm = fromSaleForm;
InitializeComponent();
}
private void AdjustAdvancesForm_Load(object sender, EventArgs e)
{
btnAdjust.Enabled = _fromSaleForm;
dtpFrom.Format = DateTimePickerFormat.Custom;
dtpFrom.CustomFormat = "dd-MMM-yyyy";
dtpFrom.Value = DateTime.Now;
dtpTo.Format = DateTimePickerFormat.Custom;
dtpTo.CustomFormat = "dd-MMM-yyyy";
dtpTo.Value = DateTime.Now;
loading = false;
_loading = false;
FillDataGrid();
}
private void FillDataGrid()
@ -33,7 +33,7 @@ namespace Tanshu.Accounts.PointOfSale
}
private void dtpFrom_ValueChanged(object sender, EventArgs e)
{
if (!loading)
if (!_loading)
FillDataGrid();
}
@ -41,7 +41,9 @@ namespace Tanshu.Accounts.PointOfSale
{
try
{
AdvanceDisplayBO item = (AdvanceDisplayBO)dgExpenses.SelectedRows[0].DataBoundItem;
var item = dgExpenses.SelectedRows[0].DataBoundItem as AdvanceDisplayBO;
if (item == null)
return;
txtCashier.Text = item.Cashier;
txtNarration.Tag = item.AdvanceID;
txtNarration.Text = item.Narration;
@ -52,8 +54,20 @@ namespace Tanshu.Accounts.PointOfSale
private void btnAdjust_Click(object sender, EventArgs e)
{
new AdvanceBI().Adjust((Guid)txtNarration.Tag, CurrentUser.user.UserID);
FillDataGrid();
if (_fromSaleForm)
{
_advanceID = (Guid)txtNarration.Tag;
this.Close();
}
else
{
new AdvanceBI().Adjust((Guid)txtNarration.Tag, CurrentUser.user.UserID);
FillDataGrid();
}
}
public Guid? AdvanceID
{
get { return _advanceID; }
}
}
}

View File

@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tanshu.Common;
using Tanshu.Accounts.BI;
using Tanshu.Accounts.Contracts;
@ -31,15 +30,18 @@ namespace Tanshu.Accounts.PointOfSale
#endregion
#region Max Discount
decimal maxDiscount = new SaleVoucherBI().GetProductDiscountLimit(productID);
if ((discount > maxDiscount) && customer.CustomerID != new Guid("F016CBAD-206C-42C0-BB1D-6006CE57BAB5"))
var maxDiscount = new SaleVoucherBI().GetProductDiscountLimit(productID);
if (discount > maxDiscount)
{
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 == new Guid("F016CBAD-206C-42C0-BB1D-6006CE57BAB5"))
{
MessageBox.Show(string.Format("Maximum discount for this product is {0:P} Discount Disallowed", maxDiscount), "Excessive Discount", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
if (Thread.CurrentPrincipal.IsInRole("High Discount Allowed"))
{
MessageBox.Show(string.Format("Maximum discount for this product is {0:P}", maxDiscount), "Excessive Discount", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else
{
MessageBox.Show(string.Format("Maximum discount for this product is {0:P} Discount Disallowed", maxDiscount), "Excessive Discount", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
#endregion
@ -150,7 +152,7 @@ namespace Tanshu.Accounts.PointOfSale
}
else if (bill.ContainsKey(new BillItemKey(product.productID, true)))
{
SalesBillItemBO otherProduct = bill[new BillItemKey(product.productID, true)];
var otherProduct = bill[new BillItemKey(product.productID, true)];
if (absolute)
SetQuantity(otherProduct, quantity - product.Printed, absolute);
else

View File

@ -65,12 +65,16 @@
this.txtAdvanceReceived = new System.Windows.Forms.TextBox();
this.txtReceipts = new System.Windows.Forms.TextBox();
this.txtOpening = new System.Windows.Forms.TextBox();
this.label11 = new System.Windows.Forms.Label();
this.label19 = new System.Windows.Forms.Label();
this.txtCreditReceipts = new System.Windows.Forms.TextBox();
this.txtStaffReceipts = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// label18
//
this.label18.AutoSize = true;
this.label18.Location = new System.Drawing.Point(12, 380);
this.label18.Location = new System.Drawing.Point(12, 432);
this.label18.Name = "label18";
this.label18.Size = new System.Drawing.Size(68, 13);
this.label18.TabIndex = 71;
@ -78,7 +82,7 @@
//
// txtClosingCash
//
this.txtClosingCash.Location = new System.Drawing.Point(99, 377);
this.txtClosingCash.Location = new System.Drawing.Point(99, 429);
this.txtClosingCash.Name = "txtClosingCash";
this.txtClosingCash.ReadOnly = true;
this.txtClosingCash.Size = new System.Drawing.Size(200, 20);
@ -103,7 +107,7 @@
// label17
//
this.label17.AutoSize = true;
this.label17.Location = new System.Drawing.Point(12, 276);
this.label17.Location = new System.Drawing.Point(12, 328);
this.label17.Name = "label17";
this.label17.Size = new System.Drawing.Size(85, 13);
this.label17.TabIndex = 67;
@ -112,7 +116,7 @@
// label16
//
this.label16.AutoSize = true;
this.label16.Location = new System.Drawing.Point(12, 302);
this.label16.Location = new System.Drawing.Point(12, 354);
this.label16.Name = "label16";
this.label16.Size = new System.Drawing.Size(81, 13);
this.label16.TabIndex = 68;
@ -121,7 +125,7 @@
// label15
//
this.label15.AutoSize = true;
this.label15.Location = new System.Drawing.Point(12, 354);
this.label15.Location = new System.Drawing.Point(12, 406);
this.label15.Name = "label15";
this.label15.Size = new System.Drawing.Size(53, 13);
this.label15.TabIndex = 70;
@ -130,7 +134,7 @@
// label14
//
this.label14.AutoSize = true;
this.label14.Location = new System.Drawing.Point(12, 406);
this.label14.Location = new System.Drawing.Point(12, 458);
this.label14.Name = "label14";
this.label14.Size = new System.Drawing.Size(82, 13);
this.label14.TabIndex = 72;
@ -139,7 +143,7 @@
// label13
//
this.label13.AutoSize = true;
this.label13.Location = new System.Drawing.Point(12, 432);
this.label13.Location = new System.Drawing.Point(12, 484);
this.label13.Name = "label13";
this.label13.Size = new System.Drawing.Size(37, 13);
this.label13.TabIndex = 73;
@ -148,7 +152,7 @@
// label12
//
this.label12.AutoSize = true;
this.label12.Location = new System.Drawing.Point(12, 328);
this.label12.Location = new System.Drawing.Point(12, 380);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(62, 13);
this.label12.TabIndex = 69;
@ -156,7 +160,7 @@
//
// btnCalculate
//
this.btnCalculate.Location = new System.Drawing.Point(12, 455);
this.btnCalculate.Location = new System.Drawing.Point(12, 507);
this.btnCalculate.Name = "btnCalculate";
this.btnCalculate.Size = new System.Drawing.Size(287, 23);
this.btnCalculate.TabIndex = 39;
@ -166,7 +170,7 @@
//
// btnPrint
//
this.btnPrint.Location = new System.Drawing.Point(12, 484);
this.btnPrint.Location = new System.Drawing.Point(12, 536);
this.btnPrint.Name = "btnPrint";
this.btnPrint.Size = new System.Drawing.Size(287, 23);
this.btnPrint.TabIndex = 40;
@ -176,7 +180,7 @@
//
// txtStatus
//
this.txtStatus.Location = new System.Drawing.Point(99, 429);
this.txtStatus.Location = new System.Drawing.Point(99, 481);
this.txtStatus.Name = "txtStatus";
this.txtStatus.ReadOnly = true;
this.txtStatus.Size = new System.Drawing.Size(200, 20);
@ -184,23 +188,22 @@
//
// txtSales
//
this.txtSales.Location = new System.Drawing.Point(99, 351);
this.txtSales.Location = new System.Drawing.Point(99, 403);
this.txtSales.Name = "txtSales";
this.txtSales.ReadOnly = true;
this.txtSales.Size = new System.Drawing.Size(200, 20);
this.txtSales.TabIndex = 54;
this.txtSales.TextChanged += new System.EventHandler(this.txtSales_TextChanged);
//
// txtDeposited
//
this.txtDeposited.Location = new System.Drawing.Point(99, 403);
this.txtDeposited.Location = new System.Drawing.Point(99, 455);
this.txtDeposited.Name = "txtDeposited";
this.txtDeposited.Size = new System.Drawing.Size(200, 20);
this.txtDeposited.TabIndex = 38;
//
// txtPending
//
this.txtPending.Location = new System.Drawing.Point(99, 325);
this.txtPending.Location = new System.Drawing.Point(99, 377);
this.txtPending.Name = "txtPending";
this.txtPending.ReadOnly = true;
this.txtPending.Size = new System.Drawing.Size(200, 20);
@ -237,7 +240,7 @@
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(12, 250);
this.label8.Location = new System.Drawing.Point(12, 302);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(81, 13);
this.label8.TabIndex = 66;
@ -246,7 +249,7 @@
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(12, 224);
this.label7.Location = new System.Drawing.Point(12, 276);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(82, 13);
this.label7.TabIndex = 65;
@ -255,7 +258,7 @@
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(12, 198);
this.label6.Location = new System.Drawing.Point(12, 250);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(53, 13);
this.label6.TabIndex = 64;
@ -264,7 +267,7 @@
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(12, 172);
this.label5.Location = new System.Drawing.Point(12, 224);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(73, 13);
this.label5.TabIndex = 63;
@ -308,7 +311,7 @@
//
// txtPayments
//
this.txtPayments.Location = new System.Drawing.Point(99, 195);
this.txtPayments.Location = new System.Drawing.Point(99, 247);
this.txtPayments.Name = "txtPayments";
this.txtPayments.ReadOnly = true;
this.txtPayments.Size = new System.Drawing.Size(200, 20);
@ -316,7 +319,7 @@
//
// txtAdvanceAdjusted
//
this.txtAdvanceAdjusted.Location = new System.Drawing.Point(99, 169);
this.txtAdvanceAdjusted.Location = new System.Drawing.Point(99, 221);
this.txtAdvanceAdjusted.Name = "txtAdvanceAdjusted";
this.txtAdvanceAdjusted.ReadOnly = true;
this.txtAdvanceAdjusted.Size = new System.Drawing.Size(200, 20);
@ -332,7 +335,7 @@
//
// txtAdditionalVoids
//
this.txtAdditionalVoids.Location = new System.Drawing.Point(99, 221);
this.txtAdditionalVoids.Location = new System.Drawing.Point(99, 273);
this.txtAdditionalVoids.Name = "txtAdditionalVoids";
this.txtAdditionalVoids.ReadOnly = true;
this.txtAdditionalVoids.Size = new System.Drawing.Size(200, 20);
@ -340,7 +343,7 @@
//
// txtVoidsInSystem
//
this.txtVoidsInSystem.Location = new System.Drawing.Point(99, 247);
this.txtVoidsInSystem.Location = new System.Drawing.Point(99, 299);
this.txtVoidsInSystem.Name = "txtVoidsInSystem";
this.txtVoidsInSystem.ReadOnly = true;
this.txtVoidsInSystem.Size = new System.Drawing.Size(200, 20);
@ -348,7 +351,7 @@
//
// txtDiscounts
//
this.txtDiscounts.Location = new System.Drawing.Point(99, 273);
this.txtDiscounts.Location = new System.Drawing.Point(99, 325);
this.txtDiscounts.Name = "txtDiscounts";
this.txtDiscounts.ReadOnly = true;
this.txtDiscounts.Size = new System.Drawing.Size(200, 20);
@ -356,7 +359,7 @@
//
// txtRates
//
this.txtRates.Location = new System.Drawing.Point(99, 299);
this.txtRates.Location = new System.Drawing.Point(99, 351);
this.txtRates.Name = "txtRates";
this.txtRates.ReadOnly = true;
this.txtRates.Size = new System.Drawing.Size(200, 20);
@ -386,11 +389,49 @@
this.txtOpening.Size = new System.Drawing.Size(200, 20);
this.txtOpening.TabIndex = 43;
//
// label11
//
this.label11.AutoSize = true;
this.label11.Location = new System.Drawing.Point(12, 198);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(52, 13);
this.label11.TabIndex = 77;
this.label11.Text = "CreditBills";
//
// label19
//
this.label19.AutoSize = true;
this.label19.Location = new System.Drawing.Point(12, 172);
this.label19.Name = "label19";
this.label19.Size = new System.Drawing.Size(50, 13);
this.label19.TabIndex = 76;
this.label19.Text = "Staff Bills";
//
// txtCreditReceipts
//
this.txtCreditReceipts.Location = new System.Drawing.Point(99, 195);
this.txtCreditReceipts.Name = "txtCreditReceipts";
this.txtCreditReceipts.ReadOnly = true;
this.txtCreditReceipts.Size = new System.Drawing.Size(200, 20);
this.txtCreditReceipts.TabIndex = 75;
//
// txtStaffReceipts
//
this.txtStaffReceipts.Location = new System.Drawing.Point(99, 169);
this.txtStaffReceipts.Name = "txtStaffReceipts";
this.txtStaffReceipts.ReadOnly = true;
this.txtStaffReceipts.Size = new System.Drawing.Size(200, 20);
this.txtStaffReceipts.TabIndex = 74;
//
// Cashier_Checkout_Form
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(311, 519);
this.ClientSize = new System.Drawing.Size(311, 571);
this.Controls.Add(this.label11);
this.Controls.Add(this.label19);
this.Controls.Add(this.txtCreditReceipts);
this.Controls.Add(this.txtStaffReceipts);
this.Controls.Add(this.label18);
this.Controls.Add(this.txtClosingCash);
this.Controls.Add(this.dtpFinish);
@ -477,5 +518,9 @@
private System.Windows.Forms.TextBox txtAdvanceReceived;
private System.Windows.Forms.TextBox txtReceipts;
private System.Windows.Forms.TextBox txtOpening;
private System.Windows.Forms.Label label11;
private System.Windows.Forms.Label label19;
private System.Windows.Forms.TextBox txtCreditReceipts;
private System.Windows.Forms.TextBox txtStaffReceipts;
}
}

View File

@ -2,14 +2,13 @@
using System.Windows.Forms;
using Tanshu.Accounts.BI;
using Tanshu.Accounts.Print;
using Tanshu.Accounts.Helpers;
namespace Tanshu.Accounts.PointOfSale
{
public partial class Cashier_Checkout_Form : Form
{
CheckoutBI coProxy;
private static readonly Tanshu.Logging.SqlLogger log = new Tanshu.Logging.SqlLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
CheckoutBI _coProxy;
private static readonly Logging.SqlLogger Log = new Logging.SqlLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public Cashier_Checkout_Form()
{
InitializeComponent();
@ -36,7 +35,7 @@ namespace Tanshu.Accounts.PointOfSale
private void cmbCashier_SelectedIndexChanged(object sender, EventArgs e)
{
EmployeeStatus();
log.Warn(string.Format("User Checkout: {0} by {1}", coProxy.Cashier, CurrentUser.user.Name));
Log.Warn(string.Format("User Checkout: {0} by {1}", _coProxy.Cashier, CurrentUser.user.Name));
}
private void EmployeeStatus()
@ -46,19 +45,21 @@ namespace Tanshu.Accounts.PointOfSale
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((Guid)cmbCashier.SelectedValue, dtpStart.Value, dtpFinish.Value);
txtOpening.Text = coProxy.Opening.ToString();
txtReceipts.Text = coProxy.Receipts.ToString();
txtAdvanceReceived.Text = coProxy.AdvanceReceipts.ToString();
txtCCReceipts.Text = coProxy.CCReceipts.ToString();
txtAdvanceAdjusted.Text = coProxy.AdvanceAdjusted.ToString();
txtPayments.Text = coProxy.CashPayments.ToString();
txtAdditionalVoids.Text = coProxy.AdditionalVoids.ToString();
txtVoidsInSystem.Text = coProxy.VoidsInSystem.ToString();
txtPending.Text = coProxy.PendingBills.ToString();
txtSales.Text = coProxy.NetSales.ToString();
txtClosingCash.Text = coProxy.ClosingBalance.ToString();
txtStatus.Text = coProxy.Status;
_coProxy = new CheckoutBI((Guid)cmbCashier.SelectedValue, dtpStart.Value, dtpFinish.Value);
txtOpening.Text = _coProxy.Opening.ToString();
txtReceipts.Text = _coProxy.Receipts.ToString();
txtAdvanceReceived.Text = _coProxy.AdvanceReceipts.ToString();
txtCCReceipts.Text = _coProxy.CreditCardReceipts.ToString();
txtStaffReceipts.Text = _coProxy.StaffReceipts.ToString();
txtCreditReceipts.Text = _coProxy.CreditReceipts.ToString();
txtAdvanceAdjusted.Text = _coProxy.AdvanceAdjusted.ToString();
txtPayments.Text = _coProxy.CashPayments.ToString();
txtAdditionalVoids.Text = _coProxy.AdditionalVoids.ToString();
txtVoidsInSystem.Text = _coProxy.VoidsInSystem.ToString();
txtPending.Text = _coProxy.PendingBills.ToString();
txtSales.Text = _coProxy.NetSales.ToString();
txtClosingCash.Text = _coProxy.ClosingBalance.ToString();
txtStatus.Text = _coProxy.Status;
}
private void dtpStart_ValueChanged(object sender, EventArgs e)
@ -73,22 +74,17 @@ namespace Tanshu.Accounts.PointOfSale
private void btnCalculate_Click(object sender, EventArgs e)
{
decimal deposited = 0;
decimal deposited;
if (!decimal.TryParse(txtDeposited.Text, out deposited))
deposited = 0;
coProxy.Calculate(deposited, 0);
txtStatus.Text = coProxy.Status;
_coProxy.Calculate(deposited, 0);
txtStatus.Text = _coProxy.Status;
}
private void btnPrint_Click(object sender, EventArgs e)
{
Thermal.PrintClosing(coProxy);
}
private void txtSales_TextChanged(object sender, EventArgs e)
{
Thermal.PrintClosing(_coProxy);
}
}
}

View File

@ -10,7 +10,7 @@ namespace Tanshu.Accounts.PointOfSale
{
public partial class RecieveAdvanceForm : Form
{
bool loading = true;
bool _loading = true;
public RecieveAdvanceForm()
{
InitializeComponent();
@ -18,16 +18,25 @@ namespace Tanshu.Accounts.PointOfSale
private void btnAdd_Click(object sender, EventArgs e)
{
if (Convert.ToDecimal(txtAmount.Text) == 0)
var adv = new AdvanceBO
{
Narration = txtNarration.Text.Trim(),
Amount = Convert.ToDecimal(txtAmount.Text.Trim()),
CashierIn = new Guid(txtCashier.Tag.ToString()),
DateIn = DateTime.Now
};
if (adv.Amount == 0)
return;
AdvanceBO adv = new AdvanceBO();
adv.Narration = txtNarration.Text;
adv.Amount = Convert.ToDecimal(txtAmount.Text.Trim());
adv.CashierIn = new Guid(txtCashier.Tag.ToString());
adv.DateIn = DateTime.Now;
new AdvanceBI().Insert(adv);
GridBind();
PrintAdvances();
if (String.IsNullOrEmpty(adv.Narration))
{
MessageBox.Show("Please fill in party name, product and date of delivery");
}
else
{
new AdvanceBI().Insert(adv);
GridBind();
PrintAdvances();
}
}
@ -41,34 +50,25 @@ namespace Tanshu.Accounts.PointOfSale
dtpTo.Value = DateTime.Now;
txtCashier.Text = CurrentUser.user.Name;
txtCashier.Tag = CurrentUser.user.UserID;
loading = false;
_loading = false;
GridBind();
}
private void GridBind()
{
List<AdvanceDisplayBO> advance = new AdvanceBI().GetAdvances(dtpFrom.Value, dtpTo.Value, true);
var advance = new AdvanceBI().GetAdvances(dtpFrom.Value, dtpTo.Value, true);
dgExpenses.DataSource = advance;
}
private void dtpFrom_ValueChanged(object sender, EventArgs e)
{
if (!loading)
if (!_loading)
GridBind();
}
private void PrintAdvances()
{
Thermal.PrintAdvance(txtAmount.Text.Trim(), txtNarration.Text.Trim());
}
private string AddDate(string SqlStringP, DateTime FromDate, DateTime ToDate)
{
return SqlStringP.Replace("$From$", string.Format(FromDate.ToString(), "dd-MMM-yyyy" + " 05:00:00")).Replace("$To$", string.Format(ToDate.ToString(), "dd-MMM-yyyy" + " 23:59:59"));
}
private void txtAmount_TextChanged(object sender, EventArgs e)
{
}
private void txtAmount_Leave(object sender, EventArgs e)
{

View File

@ -79,7 +79,6 @@
this.txtAmount.Size = new System.Drawing.Size(92, 20);
this.txtAmount.TabIndex = 106;
this.txtAmount.Text = "0";
this.txtAmount.TextChanged += new System.EventHandler(this.txtAmount_TextChanged);
this.txtAmount.Leave += new System.EventHandler(this.txtAmount_Leave);
//
// lblAmount

View File

@ -31,9 +31,6 @@
this.components = new System.ComponentModel.Container();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
this.bindingSource = new System.Windows.Forms.BindingSource(this.components);
this.bsWaiter = new System.Windows.Forms.BindingSource(this.components);
this.bsPending = new System.Windows.Forms.BindingSource(this.components);
this.tmrPending = new System.Windows.Forms.Timer(this.components);
this.label7 = new System.Windows.Forms.Label();
this.txtDiscount = new System.Windows.Forms.TextBox();
@ -48,11 +45,13 @@
this.Display = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.printedDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.additionalDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.bindingSource = new System.Windows.Forms.BindingSource(this.components);
this.pnlBilling = new System.Windows.Forms.Panel();
this.btnAdvance = new System.Windows.Forms.Button();
this.btnResetCustomer = new System.Windows.Forms.Button();
this.btnWaiter = new System.Windows.Forms.Button();
this.txtCode = new System.Windows.Forms.TextBox();
this.btnClear = new System.Windows.Forms.Button();
this.btnMultiPrint = new System.Windows.Forms.Button();
this.btnRate = new System.Windows.Forms.Button();
this.btnPrintKot = new System.Windows.Forms.Button();
this.btnPrintBill = new System.Windows.Forms.Button();
@ -75,7 +74,8 @@
this.txtKotID = new System.Windows.Forms.TextBox();
this.btnCustomer = new System.Windows.Forms.Button();
this.pnlWaiting = new System.Windows.Forms.Panel();
this.btnImportant = new System.Windows.Forms.Button();
this.btnPaidStaff = new System.Windows.Forms.Button();
this.btnPaidCredit = new System.Windows.Forms.Button();
this.dgvPending = new System.Windows.Forms.DataGridView();
this.selectDataGridViewCheckBoxColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn();
this.billNoDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
@ -90,6 +90,7 @@
this.cashierDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.printedDataGridViewCheckBoxColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn();
this.alarmTimeDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.bsPending = new System.Windows.Forms.BindingSource(this.components);
this.btnAlarm = new System.Windows.Forms.Button();
this.chkRefresh = new System.Windows.Forms.CheckBox();
this.btnRefresh = new System.Windows.Forms.Button();
@ -102,31 +103,19 @@
this.tpToday = new System.Windows.Forms.TabPage();
this.tpWeek = new System.Windows.Forms.TabPage();
this.tpAll = new System.Windows.Forms.TabPage();
this.tpImportant = new System.Windows.Forms.TabPage();
this.tpAlarm = new System.Windows.Forms.TabPage();
this.lblUser = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.bindingSource)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.bsWaiter)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.bsPending)).BeginInit();
this.bsWaiter = new System.Windows.Forms.BindingSource(this.components);
((System.ComponentModel.ISupportInitialize)(this.dgvProducts)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.bindingSource)).BeginInit();
this.pnlBilling.SuspendLayout();
this.pnlWaiting.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dgvPending)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.bsPending)).BeginInit();
this.tcPending.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.bsWaiter)).BeginInit();
this.SuspendLayout();
//
// bindingSource
//
this.bindingSource.DataSource = typeof(Tanshu.Accounts.Contracts.SalesBillItemBO);
//
// bsWaiter
//
this.bsWaiter.DataSource = typeof(Tanshu.Accounts.Contracts.WaiterBO);
//
// bsPending
//
this.bsPending.DataSource = typeof(Tanshu.Accounts.Contracts.PendingBillsBO);
//
// tmrPending
//
this.tmrPending.Enabled = true;
@ -288,14 +277,19 @@
this.additionalDataGridViewTextBoxColumn.ReadOnly = true;
this.additionalDataGridViewTextBoxColumn.Width = 5;
//
// bindingSource
//
this.bindingSource.DataSource = typeof(Tanshu.Accounts.Contracts.SalesBillItemBO);
//
// pnlBilling
//
this.pnlBilling.AutoSize = true;
this.pnlBilling.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.pnlBilling.Controls.Add(this.btnAdvance);
this.pnlBilling.Controls.Add(this.btnResetCustomer);
this.pnlBilling.Controls.Add(this.btnWaiter);
this.pnlBilling.Controls.Add(this.txtCode);
this.pnlBilling.Controls.Add(this.btnClear);
this.pnlBilling.Controls.Add(this.btnMultiPrint);
this.pnlBilling.Controls.Add(this.btnRate);
this.pnlBilling.Controls.Add(this.btnPrintKot);
this.pnlBilling.Controls.Add(this.btnPrintBill);
@ -333,11 +327,32 @@
this.pnlBilling.Size = new System.Drawing.Size(982, 662);
this.pnlBilling.TabIndex = 121;
//
// btnAdvance
//
this.btnAdvance.Location = new System.Drawing.Point(341, 543);
this.btnAdvance.Name = "btnAdvance";
this.btnAdvance.Size = new System.Drawing.Size(101, 45);
this.btnAdvance.TabIndex = 152;
this.btnAdvance.Text = "Advance - F10";
this.btnAdvance.UseVisualStyleBackColor = true;
this.btnAdvance.Click += new System.EventHandler(this.btnAdvance_Click);
//
// btnResetCustomer
//
this.btnResetCustomer.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnResetCustomer.ForeColor = System.Drawing.Color.Red;
this.btnResetCustomer.Location = new System.Drawing.Point(489, 54);
this.btnResetCustomer.Name = "btnResetCustomer";
this.btnResetCustomer.Size = new System.Drawing.Size(36, 34);
this.btnResetCustomer.TabIndex = 151;
this.btnResetCustomer.UseVisualStyleBackColor = true;
this.btnResetCustomer.Click += new System.EventHandler(this.btnResetCustomer_Click);
//
// btnWaiter
//
this.btnWaiter.Location = new System.Drawing.Point(341, 482);
this.btnWaiter.Name = "btnWaiter";
this.btnWaiter.Size = new System.Drawing.Size(101, 106);
this.btnWaiter.Size = new System.Drawing.Size(101, 55);
this.btnWaiter.TabIndex = 150;
this.btnWaiter.Text = "Select Waiter - F5";
this.btnWaiter.UseVisualStyleBackColor = true;
@ -345,9 +360,9 @@
//
// txtCode
//
this.txtCode.Location = new System.Drawing.Point(489, 54);
this.txtCode.Location = new System.Drawing.Point(531, 54);
this.txtCode.Name = "txtCode";
this.txtCode.Size = new System.Drawing.Size(481, 20);
this.txtCode.Size = new System.Drawing.Size(439, 20);
this.txtCode.TabIndex = 149;
//
// btnClear
@ -360,16 +375,6 @@
this.btnClear.UseVisualStyleBackColor = true;
this.btnClear.Click += new System.EventHandler(this.btnClear_Click);
//
// btnMultiPrint
//
this.btnMultiPrint.Location = new System.Drawing.Point(773, 485);
this.btnMultiPrint.Name = "btnMultiPrint";
this.btnMultiPrint.Size = new System.Drawing.Size(21, 106);
this.btnMultiPrint.TabIndex = 147;
this.btnMultiPrint.Text = "Multi Print";
this.btnMultiPrint.UseVisualStyleBackColor = true;
this.btnMultiPrint.Click += new System.EventHandler(this.btnMultiPrint_Click);
//
// btnRate
//
this.btnRate.Location = new System.Drawing.Point(663, 566);
@ -564,7 +569,8 @@
//
this.pnlWaiting.AutoSize = true;
this.pnlWaiting.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.pnlWaiting.Controls.Add(this.btnImportant);
this.pnlWaiting.Controls.Add(this.btnPaidStaff);
this.pnlWaiting.Controls.Add(this.btnPaidCredit);
this.pnlWaiting.Controls.Add(this.dgvPending);
this.pnlWaiting.Controls.Add(this.btnAlarm);
this.pnlWaiting.Controls.Add(this.chkRefresh);
@ -581,17 +587,26 @@
this.pnlWaiting.Name = "pnlWaiting";
this.pnlWaiting.Size = new System.Drawing.Size(982, 662);
this.pnlWaiting.TabIndex = 121;
this.pnlWaiting.Paint += new System.Windows.Forms.PaintEventHandler(this.pnlWaiting_Paint);
//
// btnImportant
// btnPaidStaff
//
this.btnImportant.Location = new System.Drawing.Point(850, 459);
this.btnImportant.Name = "btnImportant";
this.btnImportant.Size = new System.Drawing.Size(120, 62);
this.btnImportant.TabIndex = 137;
this.btnImportant.Text = "Mark / UnMark Important";
this.btnImportant.UseVisualStyleBackColor = true;
this.btnImportant.Click += new System.EventHandler(this.btnImportant_Click);
this.btnPaidStaff.Location = new System.Drawing.Point(850, 527);
this.btnPaidStaff.Name = "btnPaidStaff";
this.btnPaidStaff.Size = new System.Drawing.Size(120, 58);
this.btnPaidStaff.TabIndex = 138;
this.btnPaidStaff.Text = "Paid Staff";
this.btnPaidStaff.UseVisualStyleBackColor = true;
this.btnPaidStaff.Click += new System.EventHandler(this.btnPaidStaff_Click);
//
// btnPaidCredit
//
this.btnPaidCredit.Location = new System.Drawing.Point(850, 591);
this.btnPaidCredit.Name = "btnPaidCredit";
this.btnPaidCredit.Size = new System.Drawing.Size(120, 53);
this.btnPaidCredit.TabIndex = 137;
this.btnPaidCredit.Text = "Paid Credit";
this.btnPaidCredit.UseVisualStyleBackColor = true;
this.btnPaidCredit.Click += new System.EventHandler(this.btnPaidCredit_Click);
//
// dgvPending
//
@ -723,6 +738,10 @@
this.alarmTimeDataGridViewTextBoxColumn.Name = "alarmTimeDataGridViewTextBoxColumn";
this.alarmTimeDataGridViewTextBoxColumn.Width = 81;
//
// bsPending
//
this.bsPending.DataSource = typeof(Tanshu.Accounts.Contracts.PendingBillsBO);
//
// btnAlarm
//
this.btnAlarm.Location = new System.Drawing.Point(850, 393);
@ -757,9 +776,9 @@
//
// btnPaidCC
//
this.btnPaidCC.Location = new System.Drawing.Point(850, 527);
this.btnPaidCC.Location = new System.Drawing.Point(850, 466);
this.btnPaidCC.Name = "btnPaidCC";
this.btnPaidCC.Size = new System.Drawing.Size(120, 117);
this.btnPaidCC.Size = new System.Drawing.Size(120, 55);
this.btnPaidCC.TabIndex = 6;
this.btnPaidCC.Text = "Paid By CC";
this.btnPaidCC.UseVisualStyleBackColor = true;
@ -810,7 +829,6 @@
this.tcPending.Controls.Add(this.tpToday);
this.tcPending.Controls.Add(this.tpWeek);
this.tcPending.Controls.Add(this.tpAll);
this.tcPending.Controls.Add(this.tpImportant);
this.tcPending.Controls.Add(this.tpAlarm);
this.tcPending.Location = new System.Drawing.Point(192, 12);
this.tcPending.Name = "tcPending";
@ -849,16 +867,6 @@
this.tpAll.Text = "All";
this.tpAll.UseVisualStyleBackColor = true;
//
// tpImportant
//
this.tpImportant.Location = new System.Drawing.Point(4, 22);
this.tpImportant.Name = "tpImportant";
this.tpImportant.Padding = new System.Windows.Forms.Padding(3);
this.tpImportant.Size = new System.Drawing.Size(263, 0);
this.tpImportant.TabIndex = 4;
this.tpImportant.Text = "Important";
this.tpImportant.UseVisualStyleBackColor = true;
//
// tpAlarm
//
this.tpAlarm.Location = new System.Drawing.Point(4, 22);
@ -879,13 +887,17 @@
this.lblUser.TabIndex = 135;
this.lblUser.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// bsWaiter
//
this.bsWaiter.DataSource = typeof(Tanshu.Accounts.Contracts.WaiterBO);
//
// SalesForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(982, 662);
this.Controls.Add(this.pnlWaiting);
this.Controls.Add(this.pnlBilling);
this.Controls.Add(this.pnlWaiting);
this.KeyPreview = true;
this.MaximizeBox = false;
this.Name = "SalesForm";
@ -894,16 +906,16 @@
"unt, F11-Print Bill, F12-Print KOT, ESC-Cancel";
this.Load += new System.EventHandler(this.SalesForm_Load);
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.SalesForm_KeyDown);
((System.ComponentModel.ISupportInitialize)(this.bindingSource)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.bsWaiter)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.bsPending)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dgvProducts)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.bindingSource)).EndInit();
this.pnlBilling.ResumeLayout(false);
this.pnlBilling.PerformLayout();
this.pnlWaiting.ResumeLayout(false);
this.pnlWaiting.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.dgvPending)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.bsPending)).EndInit();
this.tcPending.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.bsWaiter)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@ -937,7 +949,6 @@
private System.Windows.Forms.TabPage tpToday;
private System.Windows.Forms.TabPage tpWeek;
private System.Windows.Forms.TabPage tpAll;
private System.Windows.Forms.TabPage tpImportant;
private System.Windows.Forms.TabPage tpAlarm;
private System.Windows.Forms.DataGridView dgvPending;
private System.Windows.Forms.Button btnCustomer;
@ -961,7 +972,6 @@
private System.Windows.Forms.Button btnPrintKot;
private System.Windows.Forms.Button btnPrintBill;
private System.Windows.Forms.Button btnVoid;
private System.Windows.Forms.Button btnMultiPrint;
private System.Windows.Forms.Button btnRate;
private System.Windows.Forms.Button btnClear;
private System.Windows.Forms.Label lblUser;
@ -979,12 +989,15 @@
private System.Windows.Forms.DataGridViewTextBoxColumn cashierDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewCheckBoxColumn printedDataGridViewCheckBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn alarmTimeDataGridViewTextBoxColumn;
private System.Windows.Forms.Button btnImportant;
private System.Windows.Forms.TextBox txtCode;
private System.Windows.Forms.DataGridViewTextBoxColumn Display;
private System.Windows.Forms.DataGridViewTextBoxColumn printedDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn additionalDataGridViewTextBoxColumn;
private System.Windows.Forms.Button btnWaiter;
private System.Windows.Forms.Button btnResetCustomer;
private System.Windows.Forms.TextBox txtCode;
private System.Windows.Forms.Button btnPaidStaff;
private System.Windows.Forms.Button btnPaidCredit;
private System.Windows.Forms.Button btnAdvance;
}
}

View File

@ -15,36 +15,42 @@ namespace Tanshu.Accounts.PointOfSale
{
public partial class SalesForm : Form
{
private static readonly Logging.SqlLogger Log = new Logging.SqlLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#region Waiting
private List<Guid> selectedBills = new List<Guid>();
private List<PendingBillsBO> pendingBills = new List<PendingBillsBO>();
private PendingType pendingList = PendingType.Today;
#endregion
private SaleFormState formState = SaleFormState.Waiting;
private SaleFormState _formState = SaleFormState.Waiting;
#region Billing
private Dictionary<BillItemKey, SalesBillItemBO> bill = new Dictionary<BillItemKey, SalesBillItemBO>();
private CustomerBO customer = new CustomerBI().GetCustomer(new Guid("F016CBAD-206C-42C0-BB1D-6006CE57BAB5"));
private Guid? _advanceID;
#endregion
private SaleVoucherBO billInfo;
private SaleVoucherBO _billInfo;
object lockObject = new object();
Guid? newBillID;
Guid? _newBillID;
readonly int _floor;
public SalesForm()
{
InitializeComponent();
btnCustomer.Text = customer.Name;
lblUser.Text = CurrentUser.user.Name;
var floorString = System.Configuration.ConfigurationManager.AppSettings["floor"];
_floor = !string.IsNullOrEmpty(floorString) ? Convert.ToInt32(floorString.Trim()) : 0;
}
public SalesForm(Guid voucherID)
: this()
{
newBillID = voucherID;
_newBillID = voucherID;
}
private void SalesForm_KeyDown(object sender, KeyEventArgs e)
{
if (formState == SaleFormState.Billing)
if (_formState == SaleFormState.Billing)
{
#region Billing KeyDown
switch (e.KeyCode)
@ -92,6 +98,12 @@ namespace Tanshu.Accounts.PointOfSale
SetAmount(CurrentProduct, -1);
break;
}
case Keys.F10:
{
if (dgvProducts.Rows.Count > 0)
SetAmount(CurrentProduct, -1);
break;
}
case Keys.F11:
{
btnPrintBill_Click(sender, e);
@ -168,7 +180,7 @@ namespace Tanshu.Accounts.PointOfSale
private void ClearBill()
{
ShowCustomerList(true);
this.billInfo = null;
this._billInfo = null;
this.txtBillID.Text = "";
this.txtKotID.Text = "";
this.txtCreationDate.Text = "";
@ -184,13 +196,14 @@ namespace Tanshu.Accounts.PointOfSale
txtGrossAmount.Text = "0.00";
txtAmount.Text = "0.00";
bill.Clear();
_advanceID = null;
bindingSource.DataSource = bill.Values;
ChangeFormState(SaleFormState.Waiting);
}
private void AddProductToGrid(Guid productID)
{
BillHelperFunctions.AddProductToGrid(productID, bindingSource, bill);
calculateAmount();
CalculateAmount();
}
private void SetQuantity(SalesBillItemBO product, decimal quantity, bool absolute, bool prompt)
@ -198,21 +211,21 @@ namespace Tanshu.Accounts.PointOfSale
if (product == null)
return;
BillHelperFunctions.SetQuantity(product, quantity, absolute, prompt, bindingSource, bill);
calculateAmount();
CalculateAmount();
}
private void SetAmount(SalesBillItemBO product, decimal amount)
{
if (product == null)
return;
BillHelperFunctions.SetAmount(product, amount, bindingSource, bill);
calculateAmount();
CalculateAmount();
}
private void SetDiscount(SalesBillItemBO product, decimal discount)
{
if (product == null)
return;
BillHelperFunctions.SetDiscount(product.productID, discount, customer, bill);
calculateAmount();
CalculateAmount();
return;
}
private bool ProductRemove(SalesBillItemBO product)
@ -231,7 +244,7 @@ namespace Tanshu.Accounts.PointOfSale
//If BillList(Location).Printed <> 0 Then ItemsDeleted.Add("Deleted " & BillList(Location).Printed & " " & BillList(Location).Name & " from Bill No " & mBillNo)
}
bill.Remove(new BillItemKey(product.productID, product.Printed == 0));
calculateAmount();
CalculateAmount();
return true;
}
private void InputBox_Validating(object sender, InputBoxValidatingArgs e)
@ -240,13 +253,13 @@ namespace Tanshu.Accounts.PointOfSale
private void button_Click(object sender, EventArgs e)
{
Button button = sender as Button;
var button = sender as Button;
if (button == null)
return;
Guid tag = (Guid)button.Tag;
var tag = (Guid)button.Tag;
AddProductToGrid(tag);
}
private void calculateAmount()
private void CalculateAmount()
{
txtGrossTax.Text = string.Format("{0:#0.00}", bill.Values.Sum(b => b.TaxAmount));
txtDiscount.Text = string.Format("{0:#0.00}", bill.Values.Sum(b => b.DiscountAmount));
@ -258,15 +271,21 @@ namespace Tanshu.Accounts.PointOfSale
private void btnPrintBill_Click(object sender, EventArgs e)
{
Save(true);
Guid? val = Save(true);
if (val.HasValue)
{
PrintBill(val.Value);
ClearBill();
}
}
private void btnPrintKot_Click(object sender, EventArgs e)
{
Save(false);
}
private void btnMultiPrint_Click(object sender, EventArgs e)
{
Save(true);
Guid? val = Save(false);
if (val.HasValue)
{
PrintKOT(val.Value);
ClearBill();
}
}
private void btnCancel_Click(object sender, EventArgs e)
{
@ -301,9 +320,9 @@ namespace Tanshu.Accounts.PointOfSale
private void SalesForm_Load(object sender, EventArgs e)
{
ChangeFormState(SaleFormState.Waiting);
if (newBillID.HasValue)
if (_newBillID.HasValue)
{
LoadBill(newBillID.Value);
LoadBill(_newBillID.Value);
ChangeFormState(SaleFormState.Billing);
}
ControlFactory.GenerateButtons(ref pnlBilling, new Rectangle(489, 94, 481, 385), 6, 6, 2, new ProductBI().GetUnFilteredProducts(), new ButtonClickDelegate(button_Click));
@ -311,7 +330,7 @@ namespace Tanshu.Accounts.PointOfSale
private void ChangeFormState(SaleFormState state)
{
formState = state;
_formState = state;
if (state == SaleFormState.Billing)
{
pnlWaiting.Visible = false;
@ -326,57 +345,66 @@ namespace Tanshu.Accounts.PointOfSale
}
#region Save Bill
private void Save(bool print)
{
if ((billInfo != null) && (new SaleVoucherBI().IsBillPrinted(billInfo.VoucherID)) && (!Thread.CurrentPrincipal.IsInRole("Sales/EditBill")))
MessageBox.Show("You are not authorized to access");
else
{
if (bill.Count != 0)
{
Guid? saved;
if (billInfo == null)
saved = AddNewSale(print);
else
saved = UpdateSale(print);
if (saved.HasValue)
{
if (newBillID.HasValue)
this.Close();
else
PrintBill(print, saved.Value);
}
ClearBill();
}
}
}
private void PrintBill(bool finalBill, Guid voucherID)
private Guid? Save(bool finalBill)
{
if (!Thread.CurrentPrincipal.IsInRole("Sales/PrintKOT"))
decimal? amount = null;
if (_billInfo != null && new SaleVoucherBI().IsBillPrinted(_billInfo.VoucherID))
{
MessageBox.Show("You are not authorized to access");
return;
}
if (!finalBill)
Accounts.Print.Thermal.PrintWaiterKot("KOT", voucherID, bill.Values.ToList());
else
{
if (!Thread.CurrentPrincipal.IsInRole("Sales/PrintBill"))
if (!Thread.CurrentPrincipal.IsInRole("Sales/EditBill"))
{
MessageBox.Show("You are not authorized to access");
return;
return null;
}
else
amount = new SaleVoucherBI().Amount(_billInfo.VoucherID);
}
if (bill.Count == 0)
return null;
//
if (_advanceID.HasValue)
{
var billAmount = Math.Round(bill.Values.Sum(b => b.Value));
var advanceAmount = new AdvanceBI().Get(_advanceID.Value).Amount;
if (advanceAmount > billAmount)
{
Accounts.Print.Thermal.PrintBill(true, voucherID, bill.Values.ToList());
Accounts.Print.Thermal.PrintCustomerKot("KOT", voucherID, bill.Values.ToList());
if (MessageBox.Show("Advance adjusted amount more than bill amount, advance will not be adjusted.\n\rContinue will bill print?", "Advace adjustment error",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
return null;
else
_advanceID = null;
}
}
var saved = _billInfo == null ? AddNewSale(finalBill) : UpdateSale(finalBill);
if (saved.HasValue && _advanceID.HasValue)
new AdvanceBI().Adjust(_advanceID.Value, CurrentUser.user.UserID);
if (amount != null)
Log.Warn(string.Format("{4} modified bill no {0}/{1} from (Rs. {2:#,00}) to (Rs. {3:#,00})", _billInfo.BillID, _billInfo.TableID, amount.Value, new SaleVoucherBI().Amount(saved.Value), Thread.CurrentPrincipal.Identity.Name));
if (_newBillID.HasValue)
this.Close();
return saved;
}
private void PrintBill(Guid voucherID)
{
if (!Thread.CurrentPrincipal.IsInRole("Sales/PrintBill"))
MessageBox.Show("You are not authorized to access");
else
{
Print.Thermal.PrintBill(voucherID);
Print.Thermal.PrintCustomerKot("KOT", voucherID, bill.Values.ToList());
}
}
private void PrintKOT(Guid voucherID)
{
if (!Thread.CurrentPrincipal.IsInRole("Sales/PrintKOT"))
MessageBox.Show("You are not authorized to access");
else
Print.Thermal.PrintWaiterKot("KOT", voucherID, bill.Values.ToList());
}
#region Save / Update
private Guid? AddNewSale(bool finalBill)
{
if (billInfo != null)
if (_billInfo != null)
{
MessageBox.Show("Error in AddNewSale, there is a previous sale in memory", "Error");
return null;
@ -386,21 +414,22 @@ namespace Tanshu.Accounts.PointOfSale
btnWaiter.Tag = new WaiterBI().GetWaiters()[0].WaiterID;
#region SaleVoucher
UserBO user = CurrentUser.user;
SaleVoucherBO saleVoucher = new SaleVoucherBO
var user = CurrentUser.user;
var saleVoucher = new SaleVoucherBO
{
CustomerID = customer.CustomerID,
Paid = false,
PaidStatus = PaidStatus.Pending,
//Paid = finalBill,
TableID = txtTableID.Text,
WaiterID = (Guid)btnWaiter.Tag,
Printed = finalBill,
Void = false,
Date = DateTime.Now,
Narration = txtNarration.Text,
Ref = "",
Type = 'S',
UserID = user.UserID
UserID = user.UserID,
Floor = _floor,
AdvanceID = _advanceID
};
#endregion
#region Inventories
@ -410,47 +439,46 @@ namespace Tanshu.Accounts.PointOfSale
return saleVoucher.VoucherID;
}
#region TransactionUpdate
private Guid? UpdateSale(bool finalBill)
{
if (btnWaiter.Tag == null)
btnWaiter.Tag = new WaiterBI().GetWaiters()[0].WaiterID;
UserBO user = CurrentUser.user;
var user = CurrentUser.user;
#region Voucher and SaleVoucher
SaleVoucherBO saleVoucher = new SaleVoucherBO
var saleVoucher = new SaleVoucherBO
{
VoucherID = billInfo.VoucherID,
timestamp = (byte[])billInfo.timestamp,
UserID = billInfo.UserID,
Date = billInfo.Date,
VoucherID = _billInfo.VoucherID,
timestamp = _billInfo.timestamp,
UserID = _billInfo.UserID,
Date = _billInfo.Date,
CreationDate = DateTime.Now,
LastEditDate = DateTime.Now,
Narration = billInfo.Narration,
Narration = _billInfo.Narration,
Ref = "",
Type = 'S',
Alarm = billInfo.Alarm,
BillID = billInfo.BillID,
Alarm = _billInfo.Alarm,
BillID = _billInfo.BillID,
CustomerID = customer.CustomerID,
KotID = billInfo.KotID,
Paid = billInfo.Paid,
Printed = billInfo.Printed || finalBill,
KotID = _billInfo.KotID,
PaidStatus = _billInfo.PaidStatus,
Printed = _billInfo.Printed || finalBill,
TableID = txtTableID.Text,
Void = billInfo.Void,
VoidReason = billInfo.VoidReason,
VoidReason = _billInfo.VoidReason,
WaiterID = (Guid)btnWaiter.Tag,
SaleTimestamp = (byte[])billInfo.SaleTimestamp
SaleTimestamp = _billInfo.SaleTimestamp,
Floor = _floor,
AdvanceID = _advanceID
};
if ((!billInfo.Printed) && finalBill)
if ((!_billInfo.Printed) && finalBill)
saleVoucher.Date = null;
#endregion
#region Inventory
List<InventoryBO> iList = new SaleVoucherBI().SaleInventory(bill.Values, billInfo.VoucherID);
List<InventoryBO> iList = new SaleVoucherBI().SaleInventory(bill.Values, _billInfo.VoucherID);
#endregion
new SaleVoucherBI().Update(saleVoucher, iList);
return saleVoucher.VoucherID;
}
#endregion
#endregion
@ -463,7 +491,7 @@ namespace Tanshu.Accounts.PointOfSale
txtTableID.Text = result.Text.Trim();
if ((txtTableID.Text != "C") && (txtTableID.Text != "") && (!txtTableID.Text.Contains(".")))
{
Guid? tID = new SaleVoucherBI().GetPendingVoucherID(txtTableID.Text);
Guid? tID = new SaleVoucherBI().GetPendingVoucherID(txtTableID.Text, _floor);
if (tID.HasValue)
{
LoadBill(tID.Value);
@ -478,61 +506,38 @@ namespace Tanshu.Accounts.PointOfSale
private void LoadBill(Guid voucherID)
{
ClearBill();
List<InventoryDisplayBO> iList = new List<InventoryDisplayBO>();
new SaleVoucherBI().GetSaleVoucher(voucherID, ref billInfo, ref iList);
var iList = new List<InventoryDisplayBO>();
new SaleVoucherBI().GetSaleVoucher(voucherID, ref _billInfo, ref iList);
this.txtBillID.Text = billInfo.BillID;
this.txtKotID.Text = billInfo.KotID;
this.txtCreationDate.Text = billInfo.CreationDate.ToString("HH:mm dd-MMM-yyyy");
this.txtDate.Text = billInfo.Date.Value.ToString("HH:mm dd-MMM-yyyy");
this.txtLastEditDate.Text = billInfo.LastEditDate.ToString("HH:mm dd-MMM-yyyy");
this.txtNarration.Text = billInfo.Narration;
this.txtUserID.Text = new UserBI().GetUser(billInfo.UserID).Name;
this.customer = new CustomerBI().GetCustomer(billInfo.CustomerID);
this.txtBillID.Text = _billInfo.BillID;
this.txtKotID.Text = _billInfo.KotID;
this.txtCreationDate.Text = _billInfo.CreationDate.ToString("HH:mm dd-MMM-yyyy");
this.txtDate.Text = _billInfo.Date.Value.ToString("HH:mm dd-MMM-yyyy");
this.txtLastEditDate.Text = _billInfo.LastEditDate.ToString("HH:mm dd-MMM-yyyy");
this.txtNarration.Text = _billInfo.Narration;
this.txtUserID.Text = new UserBI().GetUser(_billInfo.UserID).Name;
this.customer = new CustomerBI().GetCustomer(_billInfo.CustomerID);
this.btnCustomer.Text = this.customer.Name;
this.txtTableID.Text = billInfo.TableID;
this.btnWaiter.Tag = billInfo.WaiterID;
this.btnWaiter.Text = string.Format("{0} - F5", new WaiterBI().GetWaiter(billInfo.WaiterID).Name);
this.txtTableID.Text = _billInfo.TableID;
this.btnWaiter.Tag = _billInfo.WaiterID;
this._advanceID = _billInfo.AdvanceID;
this.btnWaiter.Text = string.Format("{0} - F5", new WaiterBI().GetWaiter(_billInfo.WaiterID).Name);
foreach (InventoryDisplayBO inventory in iList)
foreach (var inventory in iList)
{
if (inventory.ComplexProductID.HasValue)
var key = new BillItemKey(inventory.ProductID, inventory.Quantity == 0);
bill.Add(key, new SalesBillItemBO
{
BillItemKey key = new BillItemKey(inventory.ComplexProductID.Value, inventory.Quantity == 0);
if (!bill.ContainsKey(key))
{
decimal rate = 0, quantity = 0;
string name = "";
new SaleVoucherBI().GetComplexBillInformation(voucherID, inventory.ComplexProductID.Value, ref rate, ref quantity, ref name);
bill.Add(key, new SalesBillItemBO
{
productID = inventory.ComplexProductID.Value,
Discount = inventory.Discount,
Name = name,
Price = rate,
Printed = quantity,
Quantity = quantity,
Tax = inventory.Tax,
});
}
}
else
{
BillItemKey key = new BillItemKey(inventory.ProductID, inventory.Quantity == 0);
bill.Add(key, new SalesBillItemBO
{
productID = inventory.ProductID,
Discount = inventory.Discount,
Name = inventory.ProductName,
Price = inventory.Rate,
Printed = inventory.Quantity,
Quantity = inventory.Quantity,
Tax = inventory.Tax,
});
}
productID = inventory.ProductID,
Discount = inventory.Discount,
Name = inventory.ProductName,
Price = inventory.Rate,
Printed = inventory.Quantity,
Quantity = inventory.Quantity,
Tax = inventory.Tax,
});
}
calculateAmount();
CalculateAmount();
}
@ -562,17 +567,14 @@ namespace Tanshu.Accounts.PointOfSale
{
lock (lockObject)
{
pendingBills = new SaleVoucherBI().GetPendingBills(pendingList);
pendingBills = new SaleVoucherBI().GetPendingBills(pendingList, _floor);
bsPending.DataSource = pendingBills;
List<PendingBillsBO> alarmBills = new SaleVoucherBI().GetPendingBills(PendingType.Alarms).OrderBy(b => b.AlarmTime).ToList();
var alarmBills = new SaleVoucherBI().GetPendingBills(PendingType.Alarms, _floor).OrderBy(b => b.AlarmTime).ToList();
if (alarmBills.Count > 0)
{
PendingBillsBO al = alarmBills.First();
double seconds = al.AlarmTime.Value.Subtract(DateTime.Now).TotalSeconds;
if (seconds <= 0)
lblUser.Text = string.Format("Alarm {0:hh:MM}", al.AlarmTime);
else
lblUser.Text = CurrentUser.user.Name;
var al = alarmBills.First();
var seconds = al.AlarmTime.Value.Subtract(DateTime.Now).TotalSeconds;
lblUser.Text = seconds <= 0 ? string.Format("Alarm {0:hh:MM}", al.AlarmTime) : CurrentUser.user.Name;
}
else
{
@ -609,9 +611,6 @@ namespace Tanshu.Accounts.PointOfSale
case "All":
pendingList = PendingType.All;
break;
case "Important":
pendingList = PendingType.Important;
break;
case "Alarms":
pendingList = PendingType.Alarms;
break;
@ -661,10 +660,18 @@ namespace Tanshu.Accounts.PointOfSale
}
}
}
else if (!reset)
{
using (CustomersForm form = new CustomersForm(customer.CustomerID, customer.Phone))
{
form.ShowDialog();
}
}
else
{
customer = new CustomerBI().GetCustomer(new Guid("F016CBAD-206C-42C0-BB1D-6006CE57BAB5"));
btnCustomer.Text = customer.Name;
}
}
@ -696,9 +703,9 @@ namespace Tanshu.Accounts.PointOfSale
private void btnVoid_Click(object sender, EventArgs e)
{
if (billInfo != null)
if (_billInfo != null)
{
if ((billInfo.Printed) && (!Thread.CurrentPrincipal.IsInRole("Sales/VoidPrintedBill")))
if ((_billInfo.Printed) && (!Thread.CurrentPrincipal.IsInRole("Sales/VoidPrintedBill")))
MessageBox.Show("Cannot void a paid bill");
else if (MessageBox.Show("Are you sure you want to void this bill?", "Void Bill", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
{
@ -706,7 +713,7 @@ namespace Tanshu.Accounts.PointOfSale
voidReason.ShowDialog();
if (voidReason.SelectedItem != null)
{
new SaleVoucherBI().VoidBill(billInfo.VoucherID, voidReason.SelectedItem.Description);
new SaleVoucherBI().VoidBill(_billInfo.VoucherID, voidReason.SelectedItem.Description);
ClearBill();
}
else
@ -746,7 +753,7 @@ namespace Tanshu.Accounts.PointOfSale
if (rate != 0)
{
BillHelperFunctions.SetRate(product.productID, rate, bill);
calculateAmount();
CalculateAmount();
}
}
}
@ -759,15 +766,15 @@ namespace Tanshu.Accounts.PointOfSale
private void btnPaidCash_Click(object sender, EventArgs e)
{
UserBO user = CurrentUser.user;
new SaleVoucherBI().DeclareBillsPaid(user.UserID, selectedBills, false);
var user = CurrentUser.user;
new SaleVoucherBI().DeclareBillsPaid(user.UserID, selectedBills, PaidStatus.Cash);
ListUnpaidBills();
}
private void btnPaidCC_Click(object sender, EventArgs e)
{
UserBO user = CurrentUser.user;
new SaleVoucherBI().DeclareBillsPaid(user.UserID, selectedBills, true);
var user = CurrentUser.user;
new SaleVoucherBI().DeclareBillsPaid(user.UserID, selectedBills, PaidStatus.CreditCard);
ListUnpaidBills();
}
@ -854,17 +861,6 @@ namespace Tanshu.Accounts.PointOfSale
//}
}
private void btnImportant_Click(object sender, EventArgs e)
{
if (bsPending.Current == null)
return;
if (MessageBox.Show("Are you sure?", "Mark / UnMark Important", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
return;
PendingBillsBO billAlarm = (PendingBillsBO)bsPending.Current;
new SaleVoucherBI().ToggleImportant(billAlarm.voucherID);
ListUnpaidBills();
}
private void dgvProducts_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
DataGridView dgv = sender as DataGridView;
@ -924,8 +920,34 @@ namespace Tanshu.Accounts.PointOfSale
}
}
private void pnlWaiting_Paint(object sender, PaintEventArgs e)
private void btnResetCustomer_Click(object sender, EventArgs e)
{
ShowCustomerList(true);
}
private void btnPaidStaff_Click(object sender, EventArgs e)
{
var user = CurrentUser.user;
new SaleVoucherBI().DeclareBillsPaid(user.UserID, selectedBills, PaidStatus.Staff);
ListUnpaidBills();
}
private void btnPaidCredit_Click(object sender, EventArgs e)
{
var user = CurrentUser.user;
new SaleVoucherBI().DeclareBillsPaid(user.UserID, selectedBills, PaidStatus.Credit);
ListUnpaidBills();
}
private void btnAdvance_Click(object sender, EventArgs e)
{
if (_billInfo != null && _billInfo.AdvanceID.HasValue)
return;
using (var frm = new AdjustAdvanceForm(true))
{
frm.ShowDialog();
_advanceID = frm.AdvanceID;
}
}
}

View File

@ -117,27 +117,27 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="bindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="bsWaiter.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>148, 17</value>
</metadata>
<metadata name="bsPending.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>248, 17</value>
</metadata>
<metadata name="tmrPending.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>357, 17</value>
</metadata>
<metadata name="Display.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="bindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="selectDataGridViewCheckBoxColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="TableID.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="bsPending.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>248, 17</value>
</metadata>
<metadata name="bsWaiter.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>148, 17</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>81</value>
</metadata>