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:
@ -122,7 +122,7 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
}
|
||||
catch (SqlException)
|
||||
{
|
||||
MessageBox.Show("Unable to connect to the server.\nPlease check that the this computer and the server both are on and connected to the network.", "Server Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
MessageBox.Show("Unable to connect to the server.\nPlease check that the server is on and both this computer and the server both are connected to the network.", "Server Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
throw;
|
||||
}
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@ using System.Web.Script.Serialization;
|
||||
using System.Windows.Forms;
|
||||
using Tanshu.Accounts.Repository;
|
||||
using System.ComponentModel;
|
||||
using Tanshu.Accounts.Entities;
|
||||
|
||||
namespace Tanshu.Accounts.Management
|
||||
{
|
||||
@ -17,6 +18,7 @@ namespace Tanshu.Accounts.Management
|
||||
Stopwatch _totalStopwatch;
|
||||
private BackgroundWorker bwGo = new BackgroundWorker();
|
||||
private BackgroundWorker bwExcel = new BackgroundWorker();
|
||||
private BackgroundWorker bwFinalSanction = new BackgroundWorker();
|
||||
public ManagementForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
@ -32,6 +34,12 @@ namespace Tanshu.Accounts.Management
|
||||
bwExcel.DoWork += new DoWorkEventHandler(DoExcel);
|
||||
bwExcel.ProgressChanged += new ProgressChangedEventHandler(bwGo_ProgressChanged);
|
||||
bwExcel.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwExcel_RunWorkerCompleted);
|
||||
|
||||
bwFinalSanction.WorkerReportsProgress = true;
|
||||
bwFinalSanction.WorkerSupportsCancellation = false;
|
||||
bwFinalSanction.DoWork += new DoWorkEventHandler(DoFinalSanction);
|
||||
bwFinalSanction.ProgressChanged += new ProgressChangedEventHandler(bwFinalSanction_ProgressChanged);
|
||||
bwFinalSanction.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwFinalSanction_RunWorkerCompleted);
|
||||
}
|
||||
|
||||
private void ManagementForm_Load(object sender, EventArgs e)
|
||||
@ -85,50 +93,57 @@ namespace Tanshu.Accounts.Management
|
||||
bwGo.ReportProgress(++count, "Starting on " + startDate.ToShortDateString() + " to " + finishDate.ToShortDateString());
|
||||
using (var bi = new ManagementBI())
|
||||
{
|
||||
bwGo.ReportProgress(++count, "Clearing Modifiers");
|
||||
bi.ClearModifiers(sDate, fDate);
|
||||
bwGo.ReportProgress(++count, "Modifiers Cleared");
|
||||
bwGo.ReportProgress(++count, " -- Modifiers Cleared");
|
||||
if (bwGo.CancellationPending == true)
|
||||
{
|
||||
e.Cancel = true;
|
||||
return;
|
||||
}
|
||||
bwGo.ReportProgress(++count, "Deleting Tobacco");
|
||||
bi.DeleteTobacco(sDate, fDate);
|
||||
bwGo.ReportProgress(++count, "Tobacco Deleted");
|
||||
bwGo.ReportProgress(++count, " -- Tobacco Deleted");
|
||||
if (bwGo.CancellationPending == true)
|
||||
{
|
||||
e.Cancel = true;
|
||||
return;
|
||||
}
|
||||
bwGo.ReportProgress(++count, "Deleting Reprints");
|
||||
bi.DeleteReprints(sDate, fDate);
|
||||
bwGo.ReportProgress(++count, "Reprints Deleted");
|
||||
bwGo.ReportProgress(++count, " -- Reprints Deleted");
|
||||
if (bwGo.CancellationPending == true)
|
||||
{
|
||||
e.Cancel = true;
|
||||
return;
|
||||
}
|
||||
bwGo.ReportProgress(++count, "Deleting Voids");
|
||||
bi.DeleteVoid(sDate, fDate);
|
||||
bwGo.ReportProgress(++count, "Voids Deleted");
|
||||
bwGo.ReportProgress(++count, " -- Voids Deleted");
|
||||
if (bwGo.CancellationPending == true)
|
||||
{
|
||||
e.Cancel = true;
|
||||
return;
|
||||
}
|
||||
bwGo.ReportProgress(++count, "Combining Kots");
|
||||
bi.CombineKots(sDate, fDate);
|
||||
bwGo.ReportProgress(++count, "Kots Combined");
|
||||
bwGo.ReportProgress(++count, " -- Kots Combined");
|
||||
if (bwGo.CancellationPending == true)
|
||||
{
|
||||
e.Cancel = true;
|
||||
return;
|
||||
}
|
||||
bwGo.ReportProgress(++count, "Removing Blank Kots");
|
||||
bi.RemoveBlankKots(sDate, fDate);
|
||||
bwGo.ReportProgress(++count, "Blank Kots Removed");
|
||||
bwGo.ReportProgress(++count, " -- Blank Kots Removed");
|
||||
if (bwGo.CancellationPending == true)
|
||||
{
|
||||
e.Cancel = true;
|
||||
return;
|
||||
}
|
||||
bwGo.ReportProgress(++count, "Moving Staff to NC");
|
||||
bi.MoveStaffToNc(sDate, fDate);
|
||||
bwGo.ReportProgress(++count, "Staff Moved");
|
||||
bwGo.ReportProgress(++count, " -- Staff Moved");
|
||||
if (bwGo.CancellationPending == true)
|
||||
{
|
||||
e.Cancel = true;
|
||||
@ -147,8 +162,9 @@ namespace Tanshu.Accounts.Management
|
||||
return;
|
||||
}
|
||||
}
|
||||
bwGo.ReportProgress(++count, "Removing Blank Kots");
|
||||
bi.RemoveBlankKots(sDate, fDate);
|
||||
bwGo.ReportProgress(++count, "Blank Kots Removed");
|
||||
bwGo.ReportProgress(++count, " -- Blank Kots Removed");
|
||||
if (bwGo.CancellationPending == true)
|
||||
{
|
||||
e.Cancel = true;
|
||||
@ -179,13 +195,16 @@ namespace Tanshu.Accounts.Management
|
||||
e.Cancel = true;
|
||||
return;
|
||||
}
|
||||
bi.IncreaseLiqIfLess(item.Sale.Where(x=>x.IsLiq).ToList(), startDate, finishDate);
|
||||
bi.IncreaseLiqIfLess(item.Sale.Where(x => x.IsLiq).ToList(), startDate, finishDate);
|
||||
bwGo.ReportProgress(++count, "Sale Done");
|
||||
if (bwGo.CancellationPending == true)
|
||||
{
|
||||
e.Cancel = true;
|
||||
return;
|
||||
}
|
||||
bwGo.ReportProgress(++count, "Setting Payments");
|
||||
bi.SetPayments(sDate, fDate);
|
||||
bwGo.ReportProgress(++count, " -- Payments Set");
|
||||
bi.SaveChanges();
|
||||
}
|
||||
bwGo.ReportProgress(++count, "Cleanup done");
|
||||
@ -331,7 +350,8 @@ namespace Tanshu.Accounts.Management
|
||||
var currentDirectory = AppDomain.CurrentDomain.BaseDirectory;
|
||||
var credit = Path.Combine(currentDirectory, "credit.json");
|
||||
if (!File.Exists(credit))
|
||||
throw new ArgumentException("Credit not found!");
|
||||
return new List<CreditJson>();
|
||||
// throw new ArgumentException("Credit not found!");
|
||||
var startDate = dtpStart.Value.Date;
|
||||
var finishDate = dtpFinish.Value.Date;
|
||||
var fileContents = new StreamReader(File.OpenRead(credit)).ReadToEnd();
|
||||
@ -558,15 +578,37 @@ namespace Tanshu.Accounts.Management
|
||||
#endregion
|
||||
|
||||
private void btnFinalSanction_Click(object sender, EventArgs e)
|
||||
{
|
||||
txtStatus.Text = "";
|
||||
_totalStopwatch = Stopwatch.StartNew();
|
||||
bwFinalSanction.RunWorkerAsync();
|
||||
}
|
||||
|
||||
private void DoFinalSanction(object sender, DoWorkEventArgs e)
|
||||
{
|
||||
var startDate = dtpStart.Value.Date.AddHours(7);
|
||||
var finishDate = dtpFinish.Value.Date.AddDays(1).AddHours(7);
|
||||
using (var bi = new ManagementBI())
|
||||
{
|
||||
bi.SetPayments(startDate, finishDate);
|
||||
bi.UpdateBillID(startDate, finishDate);
|
||||
bi.UpdateBillID(startDate, finishDate, bwFinalSanction);
|
||||
bi.UpdateOtherBillID(startDate, finishDate, VoucherType.NoCharge, bwFinalSanction);
|
||||
bi.UpdateOtherBillID(startDate, finishDate, VoucherType.Staff, bwFinalSanction);
|
||||
bi.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
private void bwFinalSanction_ProgressChanged(object sender, System.ComponentModel.ProgressChangedEventArgs e)
|
||||
{
|
||||
var time = (_totalStopwatch.ElapsedMilliseconds / 1000).ToString() + "s";
|
||||
txtStatus.Text = (string)e.UserState + " in " + time;
|
||||
}
|
||||
|
||||
private void bwFinalSanction_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e)
|
||||
{
|
||||
var time = "Done in " + (_totalStopwatch.ElapsedMilliseconds / 1000).ToString() + "s";
|
||||
_totalStopwatch.Stop();
|
||||
txtStatus.Text = time;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
|
||||
foreach (var item in bi.NcQuantity(dtpStart.Value, dtpFinish.Value))
|
||||
{
|
||||
var old = _list.FirstOrDefault(x => x.ProductID == item.ProductID);
|
||||
var old = _list.FirstOrDefault(x => x.ProductID == item.ProductID && x.IsHappyHour == item.IsHappyHour);
|
||||
if (old != null)
|
||||
old.NC = item.NC;
|
||||
else
|
||||
|
||||
@ -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