Fix: Sale Detail Report would not show the proper NC as it did not check of the product was Happy Hour and at times would overwrite the wrong value
Feature: Modifier form now resizes the buttons so that if there are more modifiers than can fit on the screen, the button size will reduce to a degree Feature: The Final Sanction is also a background worker and reports progress.
This commit is contained in:
@ -28,20 +28,10 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.flpModifier = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.btnClose = new System.Windows.Forms.Button();
|
||||
this.flpModifier.SuspendLayout();
|
||||
this.flpModifier = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// flpModifier
|
||||
//
|
||||
this.flpModifier.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.flpModifier.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.flpModifier.Location = new System.Drawing.Point(0, 84);
|
||||
this.flpModifier.Name = "flpModifier";
|
||||
this.flpModifier.Size = new System.Drawing.Size(486, 324);
|
||||
this.flpModifier.TabIndex = 6;
|
||||
//
|
||||
// btnClose
|
||||
//
|
||||
this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
@ -54,28 +44,37 @@
|
||||
this.btnClose.UseVisualStyleBackColor = true;
|
||||
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
|
||||
//
|
||||
// flpModifier
|
||||
//
|
||||
this.flpModifier.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.flpModifier.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.flpModifier.Location = new System.Drawing.Point(0, 84);
|
||||
this.flpModifier.Name = "flpModifier";
|
||||
this.flpModifier.Size = new System.Drawing.Size(486, 324);
|
||||
this.flpModifier.TabIndex = 6;
|
||||
this.flpModifier.Resize += new System.EventHandler(this.flpModifier_Resize);
|
||||
//
|
||||
// ModifierForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(486, 408);
|
||||
this.ControlBox = false;
|
||||
this.Controls.Add(this.btnClose);
|
||||
this.Controls.Add(this.flpModifier);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
|
||||
this.MaximizeBox = false;
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
|
||||
this.Name = "ModifierForm";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Modifier";
|
||||
this.Load += new System.EventHandler(this.ModifierForm_Load);
|
||||
this.flpModifier.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.FlowLayoutPanel flpModifier;
|
||||
private System.Windows.Forms.Button btnClose;
|
||||
private System.Windows.Forms.FlowLayoutPanel flpModifier;
|
||||
}
|
||||
}
|
||||
@ -15,13 +15,13 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
public partial class ModifierForm : Form
|
||||
{
|
||||
private IList<InventoryModifier> selection;
|
||||
private IList<Modifier> source;
|
||||
private IList<Modifier> modifiersList;
|
||||
private IList<CheckBox> list;
|
||||
public ModifierForm(IList<Modifier> source, IList<InventoryModifier> selection)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.selection = selection;
|
||||
this.source = source;
|
||||
this.modifiersList = source;
|
||||
list = new List<CheckBox>();
|
||||
}
|
||||
|
||||
@ -35,33 +35,61 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
else
|
||||
selection.Remove(selection.First(x => x.Modifier.ModifierID == ((Modifier)button.Tag).ModifierID));
|
||||
}
|
||||
private static Point GetSize(FlowLayoutPanel panel, int count)
|
||||
{
|
||||
Point min = new Point(20, 50);
|
||||
Point max = new Point(75, 75);
|
||||
|
||||
var marginWidth = panel.Margin.Right + panel.Margin.Left;
|
||||
var marginHeight = panel.Margin.Top + panel.Margin.Bottom;
|
||||
|
||||
var rows = panel.ClientSize.Height / (max.Y + marginHeight);
|
||||
var cols = panel.ClientSize.Width / (max.X + marginWidth);
|
||||
|
||||
var num = rows * cols;
|
||||
|
||||
if (num >= count)
|
||||
return max;
|
||||
|
||||
var w = max.X;
|
||||
var h = max.Y;
|
||||
while (w > min.X && h > min.Y)
|
||||
{
|
||||
h = (panel.ClientSize.Height / (rows + 1)) - marginHeight;
|
||||
if (h >= min.Y)
|
||||
{
|
||||
++rows;
|
||||
}
|
||||
if (rows * cols >= count)
|
||||
break;
|
||||
w = (panel.ClientSize.Width / (cols + 1)) - marginWidth;
|
||||
if (w >= min.X)
|
||||
{
|
||||
++cols;
|
||||
}
|
||||
if (rows * cols >= count)
|
||||
break;
|
||||
}
|
||||
max.X = (panel.ClientSize.Width / cols) - marginWidth;
|
||||
max.Y = (panel.ClientSize.Height / rows) - marginHeight;
|
||||
|
||||
return max;
|
||||
}
|
||||
private void ModifierForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
var size = new Point(75, 75);
|
||||
int count = 30;
|
||||
var size = GetSize(flpModifier, modifiersList.Count);
|
||||
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++)
|
||||
for (int i = 0; i < modifiersList.Count; i++)
|
||||
{
|
||||
var control = new CheckBox()
|
||||
{
|
||||
Name = i.ToString(),
|
||||
Text = source[i].Name,
|
||||
Text = modifiersList[i].Name,
|
||||
Width = size.X,
|
||||
Height = size.Y,
|
||||
Tag = source[i],
|
||||
Tag = modifiersList[i],
|
||||
Appearance = Appearance.Button,
|
||||
Checked = selection.Count(x => x.Modifier.ModifierID == source[i].ModifierID) > 0
|
||||
Checked = selection.Count(x => x.Modifier.ModifierID == modifiersList[i].ModifierID) > 0
|
||||
};
|
||||
control.Click += new EventHandler(bcDelegate);
|
||||
flpModifier.Controls.Add(control);
|
||||
@ -73,5 +101,15 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void flpModifier_Resize(object sender, EventArgs e)
|
||||
{
|
||||
var size = GetSize(flpModifier, modifiersList.Count);
|
||||
foreach (var item in list)
|
||||
{
|
||||
item.Width = size.X;
|
||||
item.Height = size.Y;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user