using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using Tanshu.Accounts.Entities; using Tanshu.Accounts.Contracts; using Tanshu.Accounts.SqlDAO; using Tanshu.Accounts.Helpers; using Tanshu.Common.KeyboardControl; namespace Tanshu.Accounts.PointOfSale { public partial class DiscountForm : Form { private IList source; private IList list; private IList selection; decimal discount; public DiscountForm(IList source) { InitializeComponent(); this.source = source; list = new List(); selection = new List(); } private void button_Click(object sender, EventArgs e) { CheckBox button = sender as CheckBox; if (button == null) return; var pg = (ProductGroup)button.Tag; if (button.CheckState == CheckState.Checked) selection.Add(pg.ProductGroupID); else selection.Remove(pg.ProductGroupID); } public decimal Selection(out IList list) { list = selection; return discount; } private void btnClose_Click(object sender, EventArgs e) { this.Close(); } private void DiscountForm_Load(object sender, EventArgs e) { ControlFactory.GenerateGroups(ref flpModifier, ref list, new Point(75, 75), source, new ButtonClickDelegate(button_Click)); } private void txtAmount_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Return && decimal.TryParse(txtAmount.Text, out discount) && discount >= 0 && discount <= 100) { this.DialogResult = DialogResult.OK; this.Close(); } else if (e.KeyCode == Keys.Escape) { this.DialogResult = DialogResult.Cancel; this.Close(); } } } }