2011-01-31 20:33:22 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using Tanshu.Accounts.Helpers;
|
|
|
|
|
|
|
|
|
|
namespace Tanshu.Accounts.PointOfSale
|
|
|
|
|
{
|
|
|
|
|
public partial class DiscountForm : Form
|
|
|
|
|
{
|
2011-12-05 09:41:02 +00:00
|
|
|
|
private readonly IList<string> _source;
|
|
|
|
|
private readonly HashSet<string> _selection;
|
|
|
|
|
decimal _discount;
|
2011-02-18 16:54:48 +00:00
|
|
|
|
public DiscountForm(IList<string> source)
|
2011-01-31 20:33:22 +00:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2011-12-05 09:41:02 +00:00
|
|
|
|
this._source = source;
|
|
|
|
|
_selection = new HashSet<string>();
|
2011-01-31 20:33:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void button_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2011-12-05 09:41:02 +00:00
|
|
|
|
var button = sender as CheckBox;
|
2011-01-31 20:33:22 +00:00
|
|
|
|
if (button == null)
|
|
|
|
|
return;
|
2011-02-18 16:54:48 +00:00
|
|
|
|
var item = (string)button.Tag;
|
2011-01-31 20:33:22 +00:00
|
|
|
|
if (button.CheckState == CheckState.Checked)
|
2011-12-05 09:41:02 +00:00
|
|
|
|
_selection.Add(item);
|
2011-01-31 20:33:22 +00:00
|
|
|
|
else
|
2011-12-05 09:41:02 +00:00
|
|
|
|
_selection.Remove(item);
|
2011-01-31 20:33:22 +00:00
|
|
|
|
}
|
2011-02-18 16:54:48 +00:00
|
|
|
|
public decimal Selection(out HashSet<string> list)
|
2011-01-31 20:33:22 +00:00
|
|
|
|
{
|
2011-12-05 09:41:02 +00:00
|
|
|
|
list = _selection;
|
|
|
|
|
return _discount;
|
2011-01-31 20:33:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnClose_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DiscountForm_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
2011-12-05 09:41:02 +00:00
|
|
|
|
ControlFactory.GenerateGroups(ref flpModifier, new Point(75, 75), _source, new ButtonClickDelegate(button_Click));
|
2011-01-31 20:33:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void txtAmount_KeyDown(object sender, KeyEventArgs e)
|
|
|
|
|
{
|
2011-12-05 09:41:02 +00:00
|
|
|
|
if (e.KeyCode == Keys.Return && decimal.TryParse(txtAmount.Text, out _discount) && _discount >= 0 && _discount <= 100)
|
2011-01-31 20:33:22 +00:00
|
|
|
|
{
|
|
|
|
|
this.DialogResult = DialogResult.OK;
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
else if (e.KeyCode == Keys.Escape)
|
|
|
|
|
{
|
|
|
|
|
this.DialogResult = DialogResult.Cancel;
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|