2011-03-11 18:49:48 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using Tanshu.Accounts.Entities;
|
|
|
|
|
using Tanshu.Accounts.Contracts;
|
|
|
|
|
using Tanshu.Common.KeyboardControl;
|
|
|
|
|
|
|
|
|
|
namespace Tanshu.Accounts.PointOfSale
|
|
|
|
|
{
|
2011-08-23 07:10:05 +00:00
|
|
|
|
public partial class SettleAmountsForm : Form
|
2011-03-11 18:49:48 +00:00
|
|
|
|
{
|
|
|
|
|
private IKeyboardControl _keyboardControl;
|
|
|
|
|
private readonly decimal _amount;
|
|
|
|
|
private readonly SettleOption _settleOption;
|
|
|
|
|
private decimal _settleAmount;
|
2011-08-23 07:10:05 +00:00
|
|
|
|
public SettleAmountsForm(IKeyboardControl keyboardControl, SettleOption settleOption, decimal amount)
|
2011-03-11 18:49:48 +00:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
|
|
_keyboardControl = keyboardControl;
|
|
|
|
|
_amount = amount;
|
|
|
|
|
_settleOption = settleOption;
|
|
|
|
|
_settleAmount = 0;
|
|
|
|
|
var control = keyboardControl as UserControl;
|
|
|
|
|
if (control != null)
|
|
|
|
|
{
|
|
|
|
|
control.Location = new System.Drawing.Point(3, 49);
|
|
|
|
|
this.Controls.Add(control);
|
|
|
|
|
this.Size = this.SizeFromClientSize(new Size(3 + control.Width + 3, 49 + control.Height + 3));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public decimal AmountSettled
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _settleAmount;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SettleChoicesFormLoad(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var attribute = (DisplayAttribute)_settleOption.GetType().GetField(_settleOption.ToString()).GetCustomAttributes(typeof(DisplayAttribute), false)[0];
|
|
|
|
|
this.Text = attribute.Name;
|
|
|
|
|
txtAmount.Text = string.Format("Pending Amount: Rs. {0}", _amount);
|
|
|
|
|
txtCurrentAmount.Text = string.Format("{0:#,#00}", _amount);
|
|
|
|
|
txtCurrentAmount.Focus();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void TxtCurrentAmountKeyDown(object sender, KeyEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
switch (e.KeyCode)
|
|
|
|
|
{
|
|
|
|
|
case Keys.Escape:
|
|
|
|
|
_settleAmount = 0;
|
|
|
|
|
this.Close();
|
|
|
|
|
break;
|
|
|
|
|
case Keys.Return:
|
|
|
|
|
{
|
|
|
|
|
decimal settleAmount;
|
|
|
|
|
if (!Decimal.TryParse(txtCurrentAmount.Text, out settleAmount))
|
|
|
|
|
return;
|
|
|
|
|
if (settleAmount > _amount)
|
|
|
|
|
settleAmount = _amount;
|
|
|
|
|
_settleAmount = settleAmount;
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|