2011-01-30 07:14:05 +00:00
|
|
|
|
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.Helpers;
|
|
|
|
|
|
|
|
|
|
namespace Tanshu.Accounts.PointOfSale
|
|
|
|
|
{
|
|
|
|
|
public partial class ModifierForm : Form
|
|
|
|
|
{
|
2016-03-29 09:36:46 +00:00
|
|
|
|
private IList<InventoryModifier> selection;
|
2011-01-30 07:14:05 +00:00
|
|
|
|
private IList<Modifier> source;
|
|
|
|
|
private IList<CheckBox> list;
|
2016-03-29 09:36:46 +00:00
|
|
|
|
public ModifierForm(IList<Modifier> source, IList<InventoryModifier> selection)
|
2011-01-30 07:14:05 +00:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
this.selection = selection;
|
|
|
|
|
this.source = source;
|
|
|
|
|
list = new List<CheckBox>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void button_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CheckBox button = sender as CheckBox;
|
2016-04-11 07:01:52 +00:00
|
|
|
|
if (button == null)
|
|
|
|
|
return;
|
2011-01-30 07:14:05 +00:00
|
|
|
|
if (button.CheckState == CheckState.Checked)
|
2016-03-29 09:36:46 +00:00
|
|
|
|
selection.Add(new InventoryModifier() { Modifier = (Modifier)button.Tag });
|
2011-01-30 07:14:05 +00:00
|
|
|
|
else
|
2016-03-29 09:36:46 +00:00
|
|
|
|
selection.Remove(selection.First(x => x.Modifier.ModifierID == ((Modifier)button.Tag).ModifierID));
|
2011-01-30 07:14:05 +00:00
|
|
|
|
}
|
2016-04-11 07:01:52 +00:00
|
|
|
|
|
2016-03-29 09:36:46 +00:00
|
|
|
|
private void ModifierForm_Load(object sender, EventArgs e)
|
2011-01-30 07:14:05 +00:00
|
|
|
|
{
|
2016-03-29 09:36:46 +00:00
|
|
|
|
var size = new Point(75, 75);
|
|
|
|
|
int count = 30;
|
|
|
|
|
ButtonClickDelegate bcDelegate = new ButtonClickDelegate(button_Click);
|
|
|
|
|
if (list.Count != 0)
|
|
|
|
|
{
|
|
|
|
|
for (int i = list.Count - 1; i >= 0; i--)
|
|
|
|
|
{
|
|
|
|
|
list[i].Dispose();
|
|
|
|
|
}
|
|
|
|
|
list = new List<CheckBox>();
|
|
|
|
|
}
|
|
|
|
|
if (count > source.Count)
|
|
|
|
|
count = source.Count;
|
|
|
|
|
for (int i = 0; i < count; i++)
|
2011-01-30 07:14:05 +00:00
|
|
|
|
{
|
2016-03-29 09:36:46 +00:00
|
|
|
|
var control = new CheckBox()
|
|
|
|
|
{
|
|
|
|
|
Name = i.ToString(),
|
|
|
|
|
Text = source[i].Name,
|
|
|
|
|
Width = size.X,
|
|
|
|
|
Height = size.Y,
|
|
|
|
|
Tag = source[i],
|
|
|
|
|
Appearance = Appearance.Button,
|
|
|
|
|
Checked = selection.Count(x => x.Modifier.ModifierID == source[i].ModifierID) > 0
|
|
|
|
|
};
|
|
|
|
|
control.Click += new EventHandler(bcDelegate);
|
|
|
|
|
flpModifier.Controls.Add(control);
|
|
|
|
|
list.Add(control);
|
2011-01-30 07:14:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnClose_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|