Management form working with the correct CSV file.
This commit is contained in:
@ -1,8 +1,4 @@
|
|||||||
using System;
|
using Tanshu.Accounts.Contracts;
|
||||||
using System.Collections.Generic;
|
|
||||||
using Tanshu.Accounts.Contracts;
|
|
||||||
using Tanshu.Accounts.Contracts.Attributes;
|
|
||||||
using Tanshu.Accounts.Entities.Auth;
|
|
||||||
|
|
||||||
namespace Tanshu.Accounts.Entities
|
namespace Tanshu.Accounts.Entities
|
||||||
{
|
{
|
||||||
|
|||||||
@ -180,13 +180,9 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
|
|
||||||
btnChangePassword.Visible = Session.IsAuthenticated;
|
btnChangePassword.Visible = Session.IsAuthenticated;
|
||||||
#if (DEBUG)
|
#if (DEBUG)
|
||||||
btnMgtBeer.Visible = true;
|
btnManagement.Visible = true;
|
||||||
btnMgtFood.Visible = true;
|
|
||||||
btnMgtLiq.Visible = true;
|
|
||||||
#else
|
#else
|
||||||
btnMgtBeer.Visible = false;
|
btnManagement.Visible = false;
|
||||||
btnMgtFood.Visible = false;
|
|
||||||
btnMgtLiq.Visible = false;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,21 +275,9 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnMgtBeer_Click(object sender, EventArgs e)
|
private void btnManagement_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
using (var frm = new MoveForm())
|
using (var frm = new ManagementForm())
|
||||||
frm.ShowDialog();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void btnMgtFood_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
using (var frm = new FoodForm())
|
|
||||||
frm.ShowDialog();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void btnMgtLiq_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
using (var frm = new AmountForm())
|
|
||||||
frm.ShowDialog();
|
frm.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
54
Tanshu.Accounts.PointOfSale/MainForm.designer.cs
generated
54
Tanshu.Accounts.PointOfSale/MainForm.designer.cs
generated
@ -49,9 +49,7 @@
|
|||||||
this.btnDiscountReport = new System.Windows.Forms.Button();
|
this.btnDiscountReport = new System.Windows.Forms.Button();
|
||||||
this.btnChangePassword = new System.Windows.Forms.Button();
|
this.btnChangePassword = new System.Windows.Forms.Button();
|
||||||
this.btnExit = new System.Windows.Forms.Button();
|
this.btnExit = new System.Windows.Forms.Button();
|
||||||
this.btnMgtBeer = new System.Windows.Forms.Button();
|
this.btnManagement = new System.Windows.Forms.Button();
|
||||||
this.btnMgtFood = new System.Windows.Forms.Button();
|
|
||||||
this.btnMgtLiq = new System.Windows.Forms.Button();
|
|
||||||
this.flowLayoutPanel1.SuspendLayout();
|
this.flowLayoutPanel1.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
@ -99,9 +97,7 @@
|
|||||||
this.flowLayoutPanel1.Controls.Add(this.btnDiscountReport);
|
this.flowLayoutPanel1.Controls.Add(this.btnDiscountReport);
|
||||||
this.flowLayoutPanel1.Controls.Add(this.btnChangePassword);
|
this.flowLayoutPanel1.Controls.Add(this.btnChangePassword);
|
||||||
this.flowLayoutPanel1.Controls.Add(this.btnExit);
|
this.flowLayoutPanel1.Controls.Add(this.btnExit);
|
||||||
this.flowLayoutPanel1.Controls.Add(this.btnMgtBeer);
|
this.flowLayoutPanel1.Controls.Add(this.btnManagement);
|
||||||
this.flowLayoutPanel1.Controls.Add(this.btnMgtFood);
|
|
||||||
this.flowLayoutPanel1.Controls.Add(this.btnMgtLiq);
|
|
||||||
this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 0);
|
this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 0);
|
||||||
this.flowLayoutPanel1.Margin = new System.Windows.Forms.Padding(4);
|
this.flowLayoutPanel1.Margin = new System.Windows.Forms.Padding(4);
|
||||||
@ -307,38 +303,16 @@
|
|||||||
this.btnExit.UseVisualStyleBackColor = true;
|
this.btnExit.UseVisualStyleBackColor = true;
|
||||||
this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
|
this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
|
||||||
//
|
//
|
||||||
// btnMgtBeer
|
// btnManagement
|
||||||
//
|
//
|
||||||
this.btnMgtBeer.Location = new System.Drawing.Point(4, 528);
|
this.btnManagement.Location = new System.Drawing.Point(4, 528);
|
||||||
this.btnMgtBeer.Margin = new System.Windows.Forms.Padding(4);
|
this.btnManagement.Margin = new System.Windows.Forms.Padding(4);
|
||||||
this.btnMgtBeer.Name = "btnMgtBeer";
|
this.btnManagement.Name = "btnManagement";
|
||||||
this.btnMgtBeer.Size = new System.Drawing.Size(200, 123);
|
this.btnManagement.Size = new System.Drawing.Size(200, 123);
|
||||||
this.btnMgtBeer.TabIndex = 20;
|
this.btnManagement.TabIndex = 20;
|
||||||
this.btnMgtBeer.Text = "Beer Quantity";
|
this.btnManagement.Text = "Management";
|
||||||
this.btnMgtBeer.UseVisualStyleBackColor = true;
|
this.btnManagement.UseVisualStyleBackColor = true;
|
||||||
this.btnMgtBeer.Click += new System.EventHandler(this.btnMgtBeer_Click);
|
this.btnManagement.Click += new System.EventHandler(this.btnManagement_Click);
|
||||||
//
|
|
||||||
// btnMgtFood
|
|
||||||
//
|
|
||||||
this.btnMgtFood.Location = new System.Drawing.Point(212, 528);
|
|
||||||
this.btnMgtFood.Margin = new System.Windows.Forms.Padding(4);
|
|
||||||
this.btnMgtFood.Name = "btnMgtFood";
|
|
||||||
this.btnMgtFood.Size = new System.Drawing.Size(200, 123);
|
|
||||||
this.btnMgtFood.TabIndex = 22;
|
|
||||||
this.btnMgtFood.Text = "Food Amount";
|
|
||||||
this.btnMgtFood.UseVisualStyleBackColor = true;
|
|
||||||
this.btnMgtFood.Click += new System.EventHandler(this.btnMgtFood_Click);
|
|
||||||
//
|
|
||||||
// btnMgtLiq
|
|
||||||
//
|
|
||||||
this.btnMgtLiq.Location = new System.Drawing.Point(420, 528);
|
|
||||||
this.btnMgtLiq.Margin = new System.Windows.Forms.Padding(4);
|
|
||||||
this.btnMgtLiq.Name = "btnMgtLiq";
|
|
||||||
this.btnMgtLiq.Size = new System.Drawing.Size(200, 123);
|
|
||||||
this.btnMgtLiq.TabIndex = 23;
|
|
||||||
this.btnMgtLiq.Text = "Liq Amount";
|
|
||||||
this.btnMgtLiq.UseVisualStyleBackColor = true;
|
|
||||||
this.btnMgtLiq.Click += new System.EventHandler(this.btnMgtLiq_Click);
|
|
||||||
//
|
//
|
||||||
// MainForm
|
// MainForm
|
||||||
//
|
//
|
||||||
@ -346,7 +320,7 @@
|
|||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(1056, 661);
|
this.ClientSize = new System.Drawing.Size(1056, 661);
|
||||||
this.Controls.Add(this.flowLayoutPanel1);
|
this.Controls.Add(this.flowLayoutPanel1);
|
||||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
|
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||||
this.Margin = new System.Windows.Forms.Padding(4);
|
this.Margin = new System.Windows.Forms.Padding(4);
|
||||||
this.Name = "MainForm";
|
this.Name = "MainForm";
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||||
@ -380,9 +354,7 @@
|
|||||||
private System.Windows.Forms.Button btnOpenBill;
|
private System.Windows.Forms.Button btnOpenBill;
|
||||||
private System.Windows.Forms.Button btnBillDetails;
|
private System.Windows.Forms.Button btnBillDetails;
|
||||||
private System.Windows.Forms.Button btnVoidOrReprints;
|
private System.Windows.Forms.Button btnVoidOrReprints;
|
||||||
private System.Windows.Forms.Button btnMgtBeer;
|
private System.Windows.Forms.Button btnManagement;
|
||||||
private System.Windows.Forms.Button btnDiscountReport;
|
private System.Windows.Forms.Button btnDiscountReport;
|
||||||
private System.Windows.Forms.Button btnMgtFood;
|
|
||||||
private System.Windows.Forms.Button btnMgtLiq;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,49 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
using Tanshu.Accounts.Repository;
|
|
||||||
|
|
||||||
namespace Tanshu.Accounts.Management
|
|
||||||
{
|
|
||||||
public partial class AmountForm : Form
|
|
||||||
{
|
|
||||||
public AmountForm()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Sale_Analysis_Form_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
dtpStart.Value = DateTime.Today;
|
|
||||||
dtpFinish.Value = DateTime.Today;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void btnGo_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
dtpStart.Value = dtpStart.Value.Date.AddHours(7);
|
|
||||||
dtpFinish.Value = dtpFinish.Value.Date.AddDays(1).AddHours(7);
|
|
||||||
var amount = GetAmount();
|
|
||||||
var newAmount = TryConvert(txtQuantity.Text);
|
|
||||||
if (MessageBox.Show(amount.ToString(), "Amounts", MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2) == DialogResult.Yes && amount > newAmount)
|
|
||||||
{
|
|
||||||
MessageBox.Show(SetAmount(newAmount).ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private decimal TryConvert(string amount)
|
|
||||||
{
|
|
||||||
decimal result = 0;
|
|
||||||
decimal.TryParse(amount, out result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
private decimal GetAmount()
|
|
||||||
{
|
|
||||||
using (var bi = new ManagementBI())
|
|
||||||
return bi.GetFood(2, dtpStart.Value, dtpFinish.Value);
|
|
||||||
}
|
|
||||||
private decimal SetAmount(decimal quantity)
|
|
||||||
{
|
|
||||||
using (var bi = new ManagementBI())
|
|
||||||
return bi.SetAmount(2, quantity, dtpStart.Value, dtpFinish.Value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,46 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Globalization;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
using Tanshu.Accounts.Repository;
|
|
||||||
using Tanshu.Accounts.Contracts;
|
|
||||||
|
|
||||||
namespace Tanshu.Accounts.Management
|
|
||||||
{
|
|
||||||
public partial class FoodForm : Form
|
|
||||||
{
|
|
||||||
public FoodForm()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Sale_Analysis_Form_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
dtpStart.Value = DateTime.Today;
|
|
||||||
dtpFinish.Value = DateTime.Today;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void btnGo_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
dtpStart.Value = dtpStart.Value.Date.AddHours(7);
|
|
||||||
dtpFinish.Value = dtpFinish.Value.Date.AddDays(1).AddHours(7);
|
|
||||||
var amount = GetFood();
|
|
||||||
var newAmount = Convert.ToDecimal(txtQuantity.Text);
|
|
||||||
if (MessageBox.Show(amount.ToString(), "Food Sales", MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2) == DialogResult.Yes && amount > newAmount)
|
|
||||||
{
|
|
||||||
MessageBox.Show(SetFood(newAmount).ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private decimal GetFood()
|
|
||||||
{
|
|
||||||
using (var bi = new ManagementBI())
|
|
||||||
return bi.GetFood(1, dtpStart.Value, dtpFinish.Value);
|
|
||||||
}
|
|
||||||
private decimal SetFood(decimal quantity)
|
|
||||||
{
|
|
||||||
using (var bi = new ManagementBI())
|
|
||||||
return bi.SetFood(1, quantity, dtpStart.Value, dtpFinish.Value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,116 +0,0 @@
|
|||||||
namespace Tanshu.Accounts.Management
|
|
||||||
{
|
|
||||||
partial class FoodForm
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.dtpFinish = new System.Windows.Forms.DateTimePicker();
|
|
||||||
this.dtpStart = new System.Windows.Forms.DateTimePicker();
|
|
||||||
this.label10 = new System.Windows.Forms.Label();
|
|
||||||
this.txtQuantity = new System.Windows.Forms.TextBox();
|
|
||||||
this.btnGo = new System.Windows.Forms.Button();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// dtpFinish
|
|
||||||
//
|
|
||||||
this.dtpFinish.CustomFormat = "dd-MMM-yyyy";
|
|
||||||
this.dtpFinish.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
|
|
||||||
this.dtpFinish.Location = new System.Drawing.Point(224, 15);
|
|
||||||
this.dtpFinish.Margin = new System.Windows.Forms.Padding(4);
|
|
||||||
this.dtpFinish.Name = "dtpFinish";
|
|
||||||
this.dtpFinish.Size = new System.Drawing.Size(119, 22);
|
|
||||||
this.dtpFinish.TabIndex = 21;
|
|
||||||
//
|
|
||||||
// dtpStart
|
|
||||||
//
|
|
||||||
this.dtpStart.CustomFormat = "dd-MMM-yyyy";
|
|
||||||
this.dtpStart.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
|
|
||||||
this.dtpStart.Location = new System.Drawing.Point(16, 15);
|
|
||||||
this.dtpStart.Margin = new System.Windows.Forms.Padding(4);
|
|
||||||
this.dtpStart.Name = "dtpStart";
|
|
||||||
this.dtpStart.Size = new System.Drawing.Size(119, 22);
|
|
||||||
this.dtpStart.TabIndex = 20;
|
|
||||||
//
|
|
||||||
// label10
|
|
||||||
//
|
|
||||||
this.label10.AutoSize = true;
|
|
||||||
this.label10.Location = new System.Drawing.Point(144, 20);
|
|
||||||
this.label10.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
|
||||||
this.label10.Name = "label10";
|
|
||||||
this.label10.Size = new System.Drawing.Size(72, 17);
|
|
||||||
this.label10.TabIndex = 22;
|
|
||||||
this.label10.Text = "<- Date ->";
|
|
||||||
//
|
|
||||||
// txtQuantity
|
|
||||||
//
|
|
||||||
this.txtQuantity.Location = new System.Drawing.Point(16, 223);
|
|
||||||
this.txtQuantity.Margin = new System.Windows.Forms.Padding(4);
|
|
||||||
this.txtQuantity.Name = "txtQuantity";
|
|
||||||
this.txtQuantity.Size = new System.Drawing.Size(445, 22);
|
|
||||||
this.txtQuantity.TabIndex = 5;
|
|
||||||
//
|
|
||||||
// btnGo
|
|
||||||
//
|
|
||||||
this.btnGo.Location = new System.Drawing.Point(16, 255);
|
|
||||||
this.btnGo.Margin = new System.Windows.Forms.Padding(4);
|
|
||||||
this.btnGo.Name = "btnGo";
|
|
||||||
this.btnGo.Size = new System.Drawing.Size(200, 28);
|
|
||||||
this.btnGo.TabIndex = 24;
|
|
||||||
this.btnGo.Text = "Go";
|
|
||||||
this.btnGo.UseVisualStyleBackColor = true;
|
|
||||||
this.btnGo.Click += new System.EventHandler(this.btnGo_Click);
|
|
||||||
//
|
|
||||||
// FoodForm
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(479, 298);
|
|
||||||
this.Controls.Add(this.btnGo);
|
|
||||||
this.Controls.Add(this.dtpFinish);
|
|
||||||
this.Controls.Add(this.dtpStart);
|
|
||||||
this.Controls.Add(this.label10);
|
|
||||||
this.Controls.Add(this.txtQuantity);
|
|
||||||
this.Margin = new System.Windows.Forms.Padding(4);
|
|
||||||
this.MaximizeBox = false;
|
|
||||||
this.Name = "FoodForm";
|
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
|
||||||
this.Text = "Sale Analysis Form";
|
|
||||||
this.Load += new System.EventHandler(this.Sale_Analysis_Form_Load);
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private System.Windows.Forms.DateTimePicker dtpFinish;
|
|
||||||
private System.Windows.Forms.DateTimePicker dtpStart;
|
|
||||||
private System.Windows.Forms.Label label10;
|
|
||||||
private System.Windows.Forms.TextBox txtQuantity;
|
|
||||||
private System.Windows.Forms.Button btnGo;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,120 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
||||||
538
Tanshu.Accounts.PointOfSale/Management/ManagementForm.cs
Normal file
538
Tanshu.Accounts.PointOfSale/Management/ManagementForm.cs
Normal file
@ -0,0 +1,538 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using Tanshu.Accounts.Repository;
|
||||||
|
|
||||||
|
namespace Tanshu.Accounts.Management
|
||||||
|
{
|
||||||
|
public partial class ManagementForm : Form
|
||||||
|
{
|
||||||
|
public ManagementForm()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Sale_Analysis_Form_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
dtpStart.Value = DateTime.Today;
|
||||||
|
dtpFinish.Value = DateTime.Today;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnGo_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var currentDirectory = AppDomain.CurrentDomain.BaseDirectory;
|
||||||
|
var beer = Path.Combine(currentDirectory, "beer.csv");
|
||||||
|
var sale = Path.Combine(currentDirectory, "sale.csv");
|
||||||
|
var credit = Path.Combine(currentDirectory, "credit.csv");
|
||||||
|
var error = string.Empty;
|
||||||
|
if (!File.Exists(beer))
|
||||||
|
error += "Beer not found! ";
|
||||||
|
if (!File.Exists(sale))
|
||||||
|
error += "Sale not found! ";
|
||||||
|
if (!File.Exists(credit))
|
||||||
|
error += "Credit not found";
|
||||||
|
if (!string.IsNullOrEmpty(error))
|
||||||
|
{
|
||||||
|
MessageBox.Show(error);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
btnGo.Enabled = false;
|
||||||
|
var beerDates = GetBeer(beer);
|
||||||
|
var saleDates = GetSale(sale);
|
||||||
|
var creditDates = GetCredit(credit);
|
||||||
|
|
||||||
|
var info = string.Empty;
|
||||||
|
foreach (var item in saleDates)
|
||||||
|
{
|
||||||
|
var startDate = item.StartDate;
|
||||||
|
var finishDate = item.FinishDate;
|
||||||
|
Debug.WriteLine("Starting on " + startDate.ToShortDateString() + " to " + finishDate.ToShortDateString());
|
||||||
|
ProcessData(true, startDate, finishDate, item.Sale15 + item.Sale25);
|
||||||
|
Debug.WriteLine("Starting beer");
|
||||||
|
ProcessBeer(beerDates, startDate, finishDate);
|
||||||
|
Debug.WriteLine("Starting sale");
|
||||||
|
info += ProcessSale(item, creditDates);
|
||||||
|
Debug.WriteLine("Starting cleanup");
|
||||||
|
ProcessData(false, startDate, finishDate, item.Sale15 + item.Sale25);
|
||||||
|
Debug.WriteLine("Cleanup done");
|
||||||
|
}
|
||||||
|
MessageBox.Show(info);
|
||||||
|
btnGo.Enabled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Get Data
|
||||||
|
protected class SaleData
|
||||||
|
{
|
||||||
|
public DateTime StartDate { get; set; }
|
||||||
|
public DateTime FinishDate { get; set; }
|
||||||
|
public decimal Sale125 { get; set; }
|
||||||
|
public decimal Sale25 { get; set; }
|
||||||
|
public decimal Sale15 { get; set; }
|
||||||
|
public decimal Sale0 { get; set; }
|
||||||
|
}
|
||||||
|
private IEnumerable<SaleData> GetSale(string sale)
|
||||||
|
{
|
||||||
|
IFormatProvider culture = new CultureInfo("en-US", true);
|
||||||
|
var startDate = dtpStart.Value.Date;
|
||||||
|
var finishDate = dtpFinish.Value.Date;
|
||||||
|
|
||||||
|
var dates = new List<SaleData>();
|
||||||
|
using (var reader = new StreamReader(File.OpenRead(sale)))
|
||||||
|
{
|
||||||
|
while (!reader.EndOfStream)
|
||||||
|
{
|
||||||
|
var line = reader.ReadLine();
|
||||||
|
var values = line.Split(',');
|
||||||
|
if (values.Length != 6)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Error reading line: " + line);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
DateTime dateStart;
|
||||||
|
DateTime dateFinish;
|
||||||
|
if (!DateTime.TryParseExact(values[0], "dd-MM-yyyy", culture, DateTimeStyles.NoCurrentDateDefault, out dateStart))
|
||||||
|
continue;
|
||||||
|
if (!DateTime.TryParseExact(values[1], "dd-MM-yyyy", culture, DateTimeStyles.NoCurrentDateDefault, out dateFinish))
|
||||||
|
continue;
|
||||||
|
if (dateFinish.Date < startDate.Date || dateStart.Date > finishDate.Date)
|
||||||
|
continue;
|
||||||
|
dates.Add(new SaleData
|
||||||
|
{
|
||||||
|
StartDate = dateStart,
|
||||||
|
FinishDate = dateFinish,
|
||||||
|
Sale125 = TryConvert(values[2]),
|
||||||
|
Sale25 = TryConvert(values[3]),
|
||||||
|
Sale15 = TryConvert(values[4]),
|
||||||
|
Sale0 = TryConvert(values[5])
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dates;
|
||||||
|
}
|
||||||
|
private Dictionary<DateTime, decimal> GetCredit(string credit)
|
||||||
|
{
|
||||||
|
IFormatProvider culture = new CultureInfo("en-US", true);
|
||||||
|
var startDate = dtpStart.Value.Date.AddHours(7);
|
||||||
|
var finishDate = dtpFinish.Value.Date.AddDays(1).AddHours(7);
|
||||||
|
|
||||||
|
var dates = new Dictionary<DateTime, decimal>();
|
||||||
|
using (var reader = new StreamReader(File.OpenRead(credit)))
|
||||||
|
{
|
||||||
|
while (!reader.EndOfStream)
|
||||||
|
{
|
||||||
|
var line = reader.ReadLine();
|
||||||
|
var values = line.Split(',');
|
||||||
|
if (values.Length != 2)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Error reading line: " + line);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
DateTime dateOut;
|
||||||
|
if (!DateTime.TryParseExact(values[0], "dd/MM/yyyy", culture, DateTimeStyles.NoCurrentDateDefault, out dateOut))
|
||||||
|
continue;
|
||||||
|
if (dateOut.Date < startDate.Date || dateOut.Date >= finishDate.Date)
|
||||||
|
continue;
|
||||||
|
var amount = TryConvert(values[1]);
|
||||||
|
if (!dates.ContainsKey(dateOut))
|
||||||
|
dates.Add(dateOut, amount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dates;
|
||||||
|
}
|
||||||
|
private Dictionary<DateTime, decimal> GetBeer(string beer)
|
||||||
|
{
|
||||||
|
IFormatProvider culture = new CultureInfo("en-US", true);
|
||||||
|
var startDate = dtpStart.Value.Date.AddHours(7);
|
||||||
|
var finishDate = dtpFinish.Value.Date.AddDays(1).AddHours(7);
|
||||||
|
|
||||||
|
var dates = new Dictionary<DateTime, decimal>();
|
||||||
|
using (var reader = new StreamReader(File.OpenRead(beer)))
|
||||||
|
{
|
||||||
|
while (!reader.EndOfStream)
|
||||||
|
{
|
||||||
|
var line = reader.ReadLine();
|
||||||
|
var values = line.Split(',');
|
||||||
|
DateTime dateOut;
|
||||||
|
if (!DateTime.TryParseExact(values[0], "dd-MMM-yy", culture, DateTimeStyles.NoCurrentDateDefault, out dateOut))
|
||||||
|
continue;
|
||||||
|
if (dateOut.Date < startDate.Date || dateOut.Date >= finishDate.Date)
|
||||||
|
continue;
|
||||||
|
decimal amount = 0;
|
||||||
|
if (values.Length > 1) // Dark - Location 1, Basecode 1
|
||||||
|
amount += TryConvert(values[1]);
|
||||||
|
if (values.Length > 2) // Wheat - Location 2, Basecode 2
|
||||||
|
amount += TryConvert(values[2]);
|
||||||
|
if (values.Length > 3) // Light - Location 3, Basecode 4
|
||||||
|
amount += TryConvert(values[3]);
|
||||||
|
if (values.Length > 4) // Premium - Location 4, Basecode 3
|
||||||
|
amount += TryConvert(values[4]);
|
||||||
|
dates.Add(dateOut, amount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dates;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
private static void ProcessData(bool opening, DateTime startIn, DateTime finishIn, decimal liqTarget)
|
||||||
|
{
|
||||||
|
var startDate = startIn.AddHours(7);
|
||||||
|
var finishDate = finishIn.AddDays(1).AddHours(7);
|
||||||
|
if (opening)
|
||||||
|
{
|
||||||
|
using (var bi = new ManagementBI())
|
||||||
|
{
|
||||||
|
bi.DeleteVoid(startDate, finishDate);
|
||||||
|
}
|
||||||
|
using (var bi = new ManagementBI())
|
||||||
|
{
|
||||||
|
bi.DeleteStaff(startDate, finishDate);
|
||||||
|
}
|
||||||
|
using (var bi = new ManagementBI())
|
||||||
|
{
|
||||||
|
bi.ClearModifiers(startDate, finishDate);
|
||||||
|
}
|
||||||
|
using (var bi = new ManagementBI())
|
||||||
|
{
|
||||||
|
bi.CombineKots(startDate, finishDate);
|
||||||
|
}
|
||||||
|
using (var bi = new ManagementBI())
|
||||||
|
{
|
||||||
|
bi.RemoveBlankKots(startDate, finishDate);
|
||||||
|
}
|
||||||
|
using (var bi = new ManagementBI())
|
||||||
|
{
|
||||||
|
bi.MoveNc(startDate, finishDate, liqTarget);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
using (var bi = new ManagementBI())
|
||||||
|
{
|
||||||
|
bi.SetPayments(startDate, finishDate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ProcessBeer(Dictionary<DateTime, decimal> dates, DateTime startIn, DateTime finishIn)
|
||||||
|
{
|
||||||
|
using (var bi = new ManagementBI())
|
||||||
|
{
|
||||||
|
var info = string.Empty;
|
||||||
|
foreach (var item in dates)
|
||||||
|
{
|
||||||
|
if (item.Key < startIn || item.Key > finishIn)
|
||||||
|
continue;
|
||||||
|
var stDt = item.Key.AddHours(7);
|
||||||
|
var fiDt = stDt.AddDays(1);
|
||||||
|
var original = bi.GetQuantity(stDt, fiDt);
|
||||||
|
if (original < item.Value)
|
||||||
|
{
|
||||||
|
info += "Original for " + item.Key.ToString() + " is " + original.ToString() + " desired is " + item.Value.ToString() + "\r\n";
|
||||||
|
}
|
||||||
|
else if (original == item.Value)
|
||||||
|
{
|
||||||
|
info += item.Key.ToString() + " is " + original.ToString() + " matches!" + "\r\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bi.SetQuantity(stDt, fiDt, item.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string ProcessSale(SaleData item, Dictionary<DateTime, decimal> creditDates)
|
||||||
|
{
|
||||||
|
var info = string.Empty;
|
||||||
|
var startDate = item.StartDate.AddHours(7);
|
||||||
|
var finishDate = item.FinishDate.AddHours(7).AddDays(1);
|
||||||
|
var creditInfo = creditDates.Where(x => x.Key >= item.StartDate && x.Key <= item.FinishDate).ToDictionary(x => x.Key, x => x.Value);
|
||||||
|
|
||||||
|
info += "From " + startDate.ToShortDateString() + " to " + finishDate.ToShortDateString() + "\r\n";
|
||||||
|
|
||||||
|
using (var bi = new ManagementBI())
|
||||||
|
{
|
||||||
|
info += "25%\t" + bi.GetFood(.26250M, startDate, finishDate) + "\t";
|
||||||
|
var ret = bi.SetLiq(.26250M, item.Sale25, startDate, finishDate);
|
||||||
|
info += ret + "\t" + item.Sale25.ToString() + "\r\n";
|
||||||
|
}
|
||||||
|
using (var bi = new ManagementBI())
|
||||||
|
{
|
||||||
|
info += "15%\t" + bi.GetFood(.1575M, startDate, finishDate) + "\t";
|
||||||
|
var ret = bi.SetLiq(.1575M, item.Sale15, startDate, finishDate);
|
||||||
|
info += ret + "\t" + item.Sale15.ToString() + "\r\n";
|
||||||
|
}
|
||||||
|
using (var bi = new ManagementBI())
|
||||||
|
{
|
||||||
|
info += "12.5%\t" + bi.GetFood(.13125M, startDate, finishDate) + "\t";
|
||||||
|
var ret = bi.SetFood(.13125M, item.Sale125, startDate, finishDate);
|
||||||
|
info += ret + "\t" + item.Sale125.ToString() + "\r\n";
|
||||||
|
}
|
||||||
|
using (var bi = new ManagementBI())
|
||||||
|
{
|
||||||
|
info += "0%\t" + bi.GetFood(0M, startDate, finishDate) + "\t";
|
||||||
|
var ret = bi.SetFood(0M, item.Sale0, startDate, finishDate);
|
||||||
|
info += ret + "\t" + item.Sale0.ToString() + "\r\n";
|
||||||
|
}
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static decimal TryConvert(string amount)
|
||||||
|
{
|
||||||
|
decimal result = 0;
|
||||||
|
decimal.TryParse(amount, out result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void button1_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var startDate = dtpStart.Value.Date;
|
||||||
|
var finishDate = dtpFinish.Value.Date;
|
||||||
|
var daybook = @"
|
||||||
|
<ENVELOPE>
|
||||||
|
<HEADER>
|
||||||
|
<TALLYREQUEST>Import Data</TALLYREQUEST>
|
||||||
|
</HEADER>
|
||||||
|
<BODY>
|
||||||
|
<IMPORTDATA>
|
||||||
|
<REQUESTDESC>
|
||||||
|
<REPORTNAME>All Masters</REPORTNAME>
|
||||||
|
<STATICVARIABLES>
|
||||||
|
<SVCURRENTCOMPANY>Peitho Foods Pvt. Ltd.(2012-13)</SVCURRENTCOMPANY>
|
||||||
|
</STATICVARIABLES>
|
||||||
|
</REQUESTDESC>
|
||||||
|
<REQUESTDATA>
|
||||||
|
<TALLYMESSAGE xmlns:UDF=""TallyUDF"">
|
||||||
|
";
|
||||||
|
|
||||||
|
for (var date = startDate; date <= finishDate; date = date.AddDays(1))
|
||||||
|
{
|
||||||
|
daybook += GetVoucher(date);
|
||||||
|
}
|
||||||
|
daybook += @"
|
||||||
|
</TALLYMESSAGE>
|
||||||
|
</REQUESTDATA>
|
||||||
|
</IMPORTDATA>
|
||||||
|
</BODY>
|
||||||
|
</ENVELOPE>
|
||||||
|
";
|
||||||
|
Clipboard.SetText(daybook, TextDataFormat.Text);
|
||||||
|
}
|
||||||
|
private static string GetVoucher(DateTime date)
|
||||||
|
{
|
||||||
|
var currentStart = date.AddHours(7);
|
||||||
|
var currentFinish = date.AddDays(1).AddHours(7);
|
||||||
|
var voucher = string.Empty;
|
||||||
|
var cash = 0M;
|
||||||
|
using (var bi = new ManagementBI())
|
||||||
|
{
|
||||||
|
var sale = Math.Round(bi.GetFood(.26250M, currentStart, currentFinish));
|
||||||
|
var vat = 0M;
|
||||||
|
if (sale != 0)
|
||||||
|
{
|
||||||
|
cash += sale;
|
||||||
|
voucher += GetLedger("Sale @ 25 %", sale.ToString("#0.00"));
|
||||||
|
vat = Math.Round(bi.GetVat(.26250M, currentStart, currentFinish));
|
||||||
|
cash += vat;
|
||||||
|
voucher += GetLedger("Output Vat @ 25%", vat.ToString("#0.00"));
|
||||||
|
}
|
||||||
|
|
||||||
|
sale = Math.Round(bi.GetFood(.1575M, currentStart, currentFinish));
|
||||||
|
if (sale != 0)
|
||||||
|
{
|
||||||
|
cash += sale;
|
||||||
|
voucher += GetLedger("Sale @ 15%", sale.ToString("#0.00"));
|
||||||
|
vat = Math.Round(bi.GetVat(.1575M, currentStart, currentFinish));
|
||||||
|
cash += vat;
|
||||||
|
voucher += GetLedger("Output Vat @ 15%", vat.ToString("#0.00"));
|
||||||
|
}
|
||||||
|
|
||||||
|
sale = Math.Round(bi.GetFood(.13125M, currentStart, currentFinish));
|
||||||
|
if (sale != 0)
|
||||||
|
{
|
||||||
|
cash += sale;
|
||||||
|
voucher += GetLedger("Sale 12.5%", sale.ToString("#0.00"));
|
||||||
|
vat = Math.Round(bi.GetVat(.13125M, currentStart, currentFinish));
|
||||||
|
cash += vat;
|
||||||
|
voucher += GetLedger("Output Vat 12.5%", vat.ToString("#0.00"));
|
||||||
|
}
|
||||||
|
|
||||||
|
sale = Math.Round(bi.GetFood(0M, currentStart, currentFinish));
|
||||||
|
if (sale != 0)
|
||||||
|
{
|
||||||
|
cash += sale;
|
||||||
|
voucher += GetLedger("Sale Tax Free", sale.ToString("#0.00"));
|
||||||
|
}
|
||||||
|
|
||||||
|
vat = Math.Round(bi.GetServiceTax(currentStart, currentFinish));
|
||||||
|
if (vat != 0)
|
||||||
|
{
|
||||||
|
cash += vat;
|
||||||
|
voucher += GetLedger("Central Service Tax@3.708%", vat.ToString("#0.00"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cash != 0)
|
||||||
|
{
|
||||||
|
voucher = GetLedger("Cash", cash.ToString("#0.00")) + voucher;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return voucher != "" ? GetVoucher(date.ToString("yyyyMMdd"), voucher) : "";
|
||||||
|
}
|
||||||
|
private static string GetVoucher(string date, string ledgers)
|
||||||
|
{
|
||||||
|
#region Voucher Template
|
||||||
|
var template = @"
|
||||||
|
<VOUCHER REMOTEID=""{0}"" VCHTYPE=""Journal"" ACTION=""Create"">
|
||||||
|
<DATE>{1}</DATE>
|
||||||
|
<GUID>{0}</GUID>
|
||||||
|
<VOUCHERTYPENAME>Journal</VOUCHERTYPENAME>
|
||||||
|
<VOUCHERNUMBER>349</VOUCHERNUMBER>
|
||||||
|
<PARTYLEDGERNAME>Cash</PARTYLEDGERNAME>
|
||||||
|
<CSTFORMISSUETYPE/>
|
||||||
|
<CSTFORMRECVTYPE/>
|
||||||
|
<FBTPAYMENTTYPE>Default</FBTPAYMENTTYPE>
|
||||||
|
<VCHGSTCLASS/>
|
||||||
|
<ENTEREDBY>Admin</ENTEREDBY>
|
||||||
|
<DIFFACTUALQTY>No</DIFFACTUALQTY>
|
||||||
|
<AUDITED>No</AUDITED>
|
||||||
|
<FORJOBCOSTING>No</FORJOBCOSTING>
|
||||||
|
<ISOPTIONAL>No</ISOPTIONAL>
|
||||||
|
<EFFECTIVEDATE>{1}</EFFECTIVEDATE>
|
||||||
|
<USEFORINTEREST>No</USEFORINTEREST>
|
||||||
|
<USEFORGAINLOSS>No</USEFORGAINLOSS>
|
||||||
|
<USEFORGODOWNTRANSFER>No</USEFORGODOWNTRANSFER>
|
||||||
|
<USEFORCOMPOUND>No</USEFORCOMPOUND>
|
||||||
|
<ALTERID> 3525</ALTERID>
|
||||||
|
<EXCISEOPENING>No</EXCISEOPENING>
|
||||||
|
<ISCANCELLED>No</ISCANCELLED>
|
||||||
|
<HASCASHFLOW>Yes</HASCASHFLOW>
|
||||||
|
<ISPOSTDATED>No</ISPOSTDATED>
|
||||||
|
<USETRACKINGNUMBER>No</USETRACKINGNUMBER>
|
||||||
|
<ISINVOICE>No</ISINVOICE>
|
||||||
|
<MFGJOURNAL>No</MFGJOURNAL>
|
||||||
|
<HASDISCOUNTS>No</HASDISCOUNTS>
|
||||||
|
<ASPAYSLIP>No</ASPAYSLIP>
|
||||||
|
<ISDELETED>No</ISDELETED>
|
||||||
|
<ASORIGINAL>No</ASORIGINAL>
|
||||||
|
{2}
|
||||||
|
</VOUCHER>
|
||||||
|
";
|
||||||
|
var servicetaxtemplate = @"";
|
||||||
|
#endregion
|
||||||
|
return string.Format(template, Guid.NewGuid(), date, ledgers);
|
||||||
|
}
|
||||||
|
private static string GetLedger(string ledgername, string amount)
|
||||||
|
{
|
||||||
|
var isDeemedPositive = string.Empty;
|
||||||
|
var isPartyLedger = string.Empty;
|
||||||
|
switch (ledgername)
|
||||||
|
{
|
||||||
|
case "Cash":
|
||||||
|
isDeemedPositive = "Yes";
|
||||||
|
isPartyLedger = "Yes";
|
||||||
|
amount = "-" + amount;
|
||||||
|
break;
|
||||||
|
case "Sale 12.5%":
|
||||||
|
isDeemedPositive = "No";
|
||||||
|
isPartyLedger = "No";
|
||||||
|
break;
|
||||||
|
case "Sale @ 15%":
|
||||||
|
isDeemedPositive = "No";
|
||||||
|
isPartyLedger = "No";
|
||||||
|
break;
|
||||||
|
case "Sale @ 25 %":
|
||||||
|
isDeemedPositive = "No";
|
||||||
|
isPartyLedger = "No";
|
||||||
|
break;
|
||||||
|
case "Sale Tax Free":
|
||||||
|
isDeemedPositive = "No";
|
||||||
|
isPartyLedger = "No";
|
||||||
|
break;
|
||||||
|
case "Output Vat 12.5%":
|
||||||
|
isDeemedPositive = "No";
|
||||||
|
isPartyLedger = "No";
|
||||||
|
break;
|
||||||
|
case "Output Vat @ 15%":
|
||||||
|
isDeemedPositive = "No";
|
||||||
|
isPartyLedger = "No";
|
||||||
|
break;
|
||||||
|
case "Output Vat @ 25%":
|
||||||
|
isDeemedPositive = "No";
|
||||||
|
isPartyLedger = "No";
|
||||||
|
break;
|
||||||
|
case "Central Service Tax@3.708%":
|
||||||
|
isDeemedPositive = "No";
|
||||||
|
isPartyLedger = "No";
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
#region Voucher Template
|
||||||
|
const string template = @"
|
||||||
|
<ALLLEDGERENTRIES.LIST>
|
||||||
|
<LEDGERNAME>{0}</LEDGERNAME>
|
||||||
|
<GSTCLASS/>
|
||||||
|
<ISDEEMEDPOSITIVE>{1}</ISDEEMEDPOSITIVE>
|
||||||
|
<LEDGERFROMITEM>No</LEDGERFROMITEM>
|
||||||
|
<REMOVEZEROENTRIES>No</REMOVEZEROENTRIES>
|
||||||
|
<ISPARTYLEDGER>{2}</ISPARTYLEDGER>
|
||||||
|
<AMOUNT>{3}</AMOUNT>
|
||||||
|
</ALLLEDGERENTRIES.LIST>
|
||||||
|
";
|
||||||
|
var servicetaxtemplate = @"";
|
||||||
|
#endregion
|
||||||
|
return string.Format(template, ledgername, isDeemedPositive, isPartyLedger, amount);
|
||||||
|
}
|
||||||
|
private void button2_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
using (var bi = new ManagementBI())
|
||||||
|
{
|
||||||
|
bi.FinalSanction(dtpStart.Value.Date.AddHours(7), dtpFinish.Value.Date.AddDays(1).AddHours(7));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void button3_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
button3.Enabled = false;
|
||||||
|
var startDate = dtpStart.Value.Date;
|
||||||
|
var finishDate = dtpFinish.Value.Date;
|
||||||
|
var sheet = "Date\t Bill Start\t Bill Final\t Sale 0%\t Sale 12.5%\t Sale 15%\t Sale 25%\t Vat 12.5%\t Vat 15%\t Vat 25%\t Service Tax\n";
|
||||||
|
|
||||||
|
for (var date = startDate; date <= finishDate; date = date.AddDays(1))
|
||||||
|
{
|
||||||
|
sheet += GetExcel(date);
|
||||||
|
}
|
||||||
|
Clipboard.SetText(sheet, TextDataFormat.Text);
|
||||||
|
button3.Enabled = true;
|
||||||
|
}
|
||||||
|
private static string GetExcel(DateTime date)
|
||||||
|
{
|
||||||
|
using (var bi = new ManagementBI())
|
||||||
|
{
|
||||||
|
var currentStart = date.AddHours(7);
|
||||||
|
var currentFinish = date.AddDays(1).AddHours(7);
|
||||||
|
var cash = bi.GetFirstBill(date);
|
||||||
|
if (cash == "")
|
||||||
|
return "";
|
||||||
|
cash = string.Format("{0:dd-MMM-yyyy}\t'{1}\t'{2}\t", date, cash, bi.GetLastBill(date));
|
||||||
|
cash += string.Format("{0:#0}\t", Math.Round(bi.GetFood(0M, currentStart, currentFinish)));
|
||||||
|
cash += string.Format("{0:#0}\t", Math.Round(bi.GetFood(.13125M, currentStart, currentFinish)));
|
||||||
|
cash += string.Format("{0:#0}\t", Math.Round(bi.GetFood(.1575M, currentStart, currentFinish)));
|
||||||
|
cash += string.Format("{0:#0}\t", Math.Round(bi.GetFood(.2625M, currentStart, currentFinish)));
|
||||||
|
|
||||||
|
cash += string.Format("{0:#0}\t", Math.Round(bi.GetVat(.13125M, currentStart, currentFinish)));
|
||||||
|
cash += string.Format("{0:#0}\t", Math.Round(bi.GetVat(.1575M, currentStart, currentFinish)));
|
||||||
|
cash += string.Format("{0:#0}\t", Math.Round(bi.GetVat(.2625M, currentStart, currentFinish)));
|
||||||
|
|
||||||
|
cash += string.Format("{0:#0}\n", Math.Round(bi.GetServiceTax(currentStart, currentFinish)));
|
||||||
|
return cash;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,6 +1,6 @@
|
|||||||
namespace Tanshu.Accounts.Management
|
namespace Tanshu.Accounts.Management
|
||||||
{
|
{
|
||||||
partial class AmountForm
|
partial class ManagementForm
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required designer variable.
|
/// Required designer variable.
|
||||||
@ -31,8 +31,10 @@
|
|||||||
this.dtpFinish = new System.Windows.Forms.DateTimePicker();
|
this.dtpFinish = new System.Windows.Forms.DateTimePicker();
|
||||||
this.dtpStart = new System.Windows.Forms.DateTimePicker();
|
this.dtpStart = new System.Windows.Forms.DateTimePicker();
|
||||||
this.label10 = new System.Windows.Forms.Label();
|
this.label10 = new System.Windows.Forms.Label();
|
||||||
this.txtQuantity = new System.Windows.Forms.TextBox();
|
|
||||||
this.btnGo = new System.Windows.Forms.Button();
|
this.btnGo = new System.Windows.Forms.Button();
|
||||||
|
this.button1 = new System.Windows.Forms.Button();
|
||||||
|
this.button2 = new System.Windows.Forms.Button();
|
||||||
|
this.button3 = new System.Windows.Forms.Button();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// dtpFinish
|
// dtpFinish
|
||||||
@ -65,16 +67,9 @@
|
|||||||
this.label10.TabIndex = 22;
|
this.label10.TabIndex = 22;
|
||||||
this.label10.Text = "<- Date ->";
|
this.label10.Text = "<- Date ->";
|
||||||
//
|
//
|
||||||
// txtQuantity
|
|
||||||
//
|
|
||||||
this.txtQuantity.Location = new System.Drawing.Point(16, 223);
|
|
||||||
this.txtQuantity.Margin = new System.Windows.Forms.Padding(4);
|
|
||||||
this.txtQuantity.Name = "txtQuantity";
|
|
||||||
this.txtQuantity.Size = new System.Drawing.Size(445, 22);
|
|
||||||
this.txtQuantity.TabIndex = 5;
|
|
||||||
//
|
|
||||||
// btnGo
|
// btnGo
|
||||||
//
|
//
|
||||||
|
this.btnGo.Enabled = false;
|
||||||
this.btnGo.Location = new System.Drawing.Point(16, 255);
|
this.btnGo.Location = new System.Drawing.Point(16, 255);
|
||||||
this.btnGo.Margin = new System.Windows.Forms.Padding(4);
|
this.btnGo.Margin = new System.Windows.Forms.Padding(4);
|
||||||
this.btnGo.Name = "btnGo";
|
this.btnGo.Name = "btnGo";
|
||||||
@ -84,19 +79,54 @@
|
|||||||
this.btnGo.UseVisualStyleBackColor = true;
|
this.btnGo.UseVisualStyleBackColor = true;
|
||||||
this.btnGo.Click += new System.EventHandler(this.btnGo_Click);
|
this.btnGo.Click += new System.EventHandler(this.btnGo_Click);
|
||||||
//
|
//
|
||||||
// FoodForm
|
// button1
|
||||||
|
//
|
||||||
|
this.button1.Location = new System.Drawing.Point(224, 255);
|
||||||
|
this.button1.Margin = new System.Windows.Forms.Padding(4);
|
||||||
|
this.button1.Name = "button1";
|
||||||
|
this.button1.Size = new System.Drawing.Size(200, 28);
|
||||||
|
this.button1.TabIndex = 25;
|
||||||
|
this.button1.Text = "Tally";
|
||||||
|
this.button1.UseVisualStyleBackColor = true;
|
||||||
|
this.button1.Click += new System.EventHandler(this.button1_Click);
|
||||||
|
//
|
||||||
|
// button2
|
||||||
|
//
|
||||||
|
this.button2.Location = new System.Drawing.Point(16, 219);
|
||||||
|
this.button2.Margin = new System.Windows.Forms.Padding(4);
|
||||||
|
this.button2.Name = "button2";
|
||||||
|
this.button2.Size = new System.Drawing.Size(200, 28);
|
||||||
|
this.button2.TabIndex = 26;
|
||||||
|
this.button2.Text = "Final Sanction";
|
||||||
|
this.button2.UseVisualStyleBackColor = true;
|
||||||
|
this.button2.Click += new System.EventHandler(this.button2_Click);
|
||||||
|
//
|
||||||
|
// button3
|
||||||
|
//
|
||||||
|
this.button3.Location = new System.Drawing.Point(224, 219);
|
||||||
|
this.button3.Margin = new System.Windows.Forms.Padding(4);
|
||||||
|
this.button3.Name = "button3";
|
||||||
|
this.button3.Size = new System.Drawing.Size(200, 28);
|
||||||
|
this.button3.TabIndex = 27;
|
||||||
|
this.button3.Text = "Excel";
|
||||||
|
this.button3.UseVisualStyleBackColor = true;
|
||||||
|
this.button3.Click += new System.EventHandler(this.button3_Click);
|
||||||
|
//
|
||||||
|
// ManagementForm
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(479, 298);
|
this.ClientSize = new System.Drawing.Size(479, 298);
|
||||||
|
this.Controls.Add(this.button3);
|
||||||
|
this.Controls.Add(this.button2);
|
||||||
|
this.Controls.Add(this.button1);
|
||||||
this.Controls.Add(this.btnGo);
|
this.Controls.Add(this.btnGo);
|
||||||
this.Controls.Add(this.dtpFinish);
|
this.Controls.Add(this.dtpFinish);
|
||||||
this.Controls.Add(this.dtpStart);
|
this.Controls.Add(this.dtpStart);
|
||||||
this.Controls.Add(this.label10);
|
this.Controls.Add(this.label10);
|
||||||
this.Controls.Add(this.txtQuantity);
|
|
||||||
this.Margin = new System.Windows.Forms.Padding(4);
|
this.Margin = new System.Windows.Forms.Padding(4);
|
||||||
this.MaximizeBox = false;
|
this.MaximizeBox = false;
|
||||||
this.Name = "FoodForm";
|
this.Name = "ManagementForm";
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||||
this.Text = "Sale Analysis Form";
|
this.Text = "Sale Analysis Form";
|
||||||
this.Load += new System.EventHandler(this.Sale_Analysis_Form_Load);
|
this.Load += new System.EventHandler(this.Sale_Analysis_Form_Load);
|
||||||
@ -110,7 +140,9 @@
|
|||||||
private System.Windows.Forms.DateTimePicker dtpFinish;
|
private System.Windows.Forms.DateTimePicker dtpFinish;
|
||||||
private System.Windows.Forms.DateTimePicker dtpStart;
|
private System.Windows.Forms.DateTimePicker dtpStart;
|
||||||
private System.Windows.Forms.Label label10;
|
private System.Windows.Forms.Label label10;
|
||||||
private System.Windows.Forms.TextBox txtQuantity;
|
|
||||||
private System.Windows.Forms.Button btnGo;
|
private System.Windows.Forms.Button btnGo;
|
||||||
|
private System.Windows.Forms.Button button1;
|
||||||
|
private System.Windows.Forms.Button button2;
|
||||||
|
private System.Windows.Forms.Button button3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,162 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Globalization;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
using Tanshu.Accounts.Repository;
|
|
||||||
|
|
||||||
namespace Tanshu.Accounts.Management
|
|
||||||
{
|
|
||||||
public partial class MoveForm : Form
|
|
||||||
{
|
|
||||||
private IList<ComboBox> comboBoxes;
|
|
||||||
private IDictionary<int, string> list;
|
|
||||||
public MoveForm()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
list = new Dictionary<int, string>
|
|
||||||
{
|
|
||||||
{1, "1 - Dark"},
|
|
||||||
{2, "2 - Wheat"},
|
|
||||||
{3, "3 - Premium"},
|
|
||||||
{4, "4 - Light"},
|
|
||||||
{5, "5 - Dragon"},
|
|
||||||
{6, "6 - Festival"},
|
|
||||||
{7, "7 - Vanilla"},
|
|
||||||
{8, "8 - Strong"}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Sale_Analysis_Form_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
dtpStartDate.Value = DateTime.Today;
|
|
||||||
dtpFinishDate.Value = DateTime.Today;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void btnGo_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
comboBoxes = new List<ComboBox>();
|
|
||||||
var startDate = dtpStartDate.Value.Date.AddHours(7);
|
|
||||||
var finishDate = dtpFinishDate.Value.Date.AddDays(1).AddHours(7);
|
|
||||||
var details = GetMove(startDate, finishDate);
|
|
||||||
foreach (var detail in details)
|
|
||||||
{
|
|
||||||
var item = (object[])detail;
|
|
||||||
var text = GetName((int)item[0]) + " ---> " + ((decimal)item[1]).ToString();
|
|
||||||
|
|
||||||
var label = new Label()
|
|
||||||
{
|
|
||||||
Name = "label" + ((int)item[0]).ToString(CultureInfo.InvariantCulture),
|
|
||||||
AutoSize = true,
|
|
||||||
Text = text
|
|
||||||
};
|
|
||||||
flpProducts.Controls.Add(label);
|
|
||||||
var comboBox = GetBox((int)item[0]);
|
|
||||||
comboBoxes.Add(comboBox);
|
|
||||||
flpProducts.Controls.Add(comboBox);
|
|
||||||
|
|
||||||
}
|
|
||||||
//foreach (var comboBox in comboBoxes)
|
|
||||||
//{
|
|
||||||
// var startDate = dtpStartDate.Value.Date.AddHours(7);
|
|
||||||
// var finishDate = startDate.AddDays(1);
|
|
||||||
|
|
||||||
// var baseCode = (int)(((object[])comboBox.Tag)[0]);
|
|
||||||
// var text = (string)(((object[])comboBox.Tag)[1]);
|
|
||||||
// foreach (var item in comboBox.Text.Split(','))
|
|
||||||
// {
|
|
||||||
// var newQuantity = TryConvert(item);
|
|
||||||
// var quantity = GetQuantity(baseCode, startDate, finishDate);
|
|
||||||
|
|
||||||
// if (MessageBox.Show(text + " " + startDate.ToString("dd-MMM-yyyy") + " " + quantity.ToString(), "Quantity of Beer", MessageBoxButtons.YesNo,
|
|
||||||
// MessageBoxIcon.Information, MessageBoxDefaultButton.Button2) == DialogResult.Yes &&
|
|
||||||
// quantity > newQuantity && newQuantity > 0)
|
|
||||||
// {
|
|
||||||
// MessageBox.Show(SetQuantity(baseCode, newQuantity, startDate, finishDate).ToString());
|
|
||||||
// }
|
|
||||||
// startDate = startDate.AddDays(1);
|
|
||||||
// finishDate = finishDate.AddDays(1);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
private ComboBox GetBox(int code)
|
|
||||||
{
|
|
||||||
var comboBox = new ComboBox()
|
|
||||||
{
|
|
||||||
Name = "comboBox" + (code).ToString(CultureInfo.InvariantCulture),
|
|
||||||
Width = 400,
|
|
||||||
Height = 20,
|
|
||||||
Tag = code,
|
|
||||||
DisplayMember = "Value",
|
|
||||||
ValueMember = "Key",
|
|
||||||
DropDownStyle = ComboBoxStyle.DropDownList,
|
|
||||||
DataSource = new BindingSource(list, null)
|
|
||||||
};
|
|
||||||
//foreach (var item in list)
|
|
||||||
// comboBox.Items.Add(new { Code = item.Key, Name = item.Value });
|
|
||||||
//MessageBox.Show(code.ToString());
|
|
||||||
//comboBox.SelectedIndex = code - 1;
|
|
||||||
comboBox.SelectedValue = code;
|
|
||||||
return comboBox;
|
|
||||||
}
|
|
||||||
private static string GetName(int code)
|
|
||||||
{
|
|
||||||
switch (code)
|
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
return "1 - Dark";
|
|
||||||
case 2:
|
|
||||||
return "2 - Wheat";
|
|
||||||
case 3:
|
|
||||||
return "3 - Premium";
|
|
||||||
case 4:
|
|
||||||
return "4 - Light";
|
|
||||||
case 5:
|
|
||||||
return "5 - Dragon";
|
|
||||||
case 6:
|
|
||||||
return "6 - Festival";
|
|
||||||
case 7:
|
|
||||||
return "7 - Vanilla";
|
|
||||||
case 8:
|
|
||||||
return "8 - Strong";
|
|
||||||
default:
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private static decimal TryConvert(string amount)
|
|
||||||
{
|
|
||||||
decimal result = 0;
|
|
||||||
decimal.TryParse(amount, out result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static IList GetMove(DateTime startDate, DateTime finishDate)
|
|
||||||
{
|
|
||||||
using (var bi = new ManagementBI())
|
|
||||||
return bi.GetMove(startDate, finishDate);
|
|
||||||
}
|
|
||||||
private static void SetMove(int fromBaseCode, int toBaseCode, DateTime startDate, DateTime finishDate)
|
|
||||||
{
|
|
||||||
using (var bi = new ManagementBI())
|
|
||||||
bi.SetMove(fromBaseCode, toBaseCode, startDate, finishDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void btnProcess_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
btnProcess.Enabled = false;
|
|
||||||
var startDate = dtpStartDate.Value.Date.AddHours(7);
|
|
||||||
var finishDate = dtpFinishDate.Value.Date.AddDays(1).AddHours(7);
|
|
||||||
foreach (var item in comboBoxes)
|
|
||||||
{
|
|
||||||
var fromBaseCode = (int) item.Tag;
|
|
||||||
var toBaseCode = (int) item.SelectedValue;
|
|
||||||
if (fromBaseCode == toBaseCode)
|
|
||||||
continue;
|
|
||||||
Text = GetName(fromBaseCode) + " to " + GetName(toBaseCode);
|
|
||||||
MessageBox.Show(Text);
|
|
||||||
SetMove(fromBaseCode, toBaseCode, startDate , finishDate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,119 +0,0 @@
|
|||||||
namespace Tanshu.Accounts.Management
|
|
||||||
{
|
|
||||||
partial class MoveForm
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.dtpStartDate = new System.Windows.Forms.DateTimePicker();
|
|
||||||
this.flpProducts = new System.Windows.Forms.FlowLayoutPanel();
|
|
||||||
this.btnGo = new System.Windows.Forms.Button();
|
|
||||||
this.dtpFinishDate = new System.Windows.Forms.DateTimePicker();
|
|
||||||
this.btnProcess = new System.Windows.Forms.Button();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// dtpStartDate
|
|
||||||
//
|
|
||||||
this.dtpStartDate.CustomFormat = "dd-MMM-yyyy";
|
|
||||||
this.dtpStartDate.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
|
|
||||||
this.dtpStartDate.Location = new System.Drawing.Point(16, 15);
|
|
||||||
this.dtpStartDate.Margin = new System.Windows.Forms.Padding(4);
|
|
||||||
this.dtpStartDate.Name = "dtpStartDate";
|
|
||||||
this.dtpStartDate.Size = new System.Drawing.Size(119, 22);
|
|
||||||
this.dtpStartDate.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// flpProducts
|
|
||||||
//
|
|
||||||
this.flpProducts.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
|
||||||
| System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.flpProducts.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
|
|
||||||
this.flpProducts.Location = new System.Drawing.Point(16, 47);
|
|
||||||
this.flpProducts.Margin = new System.Windows.Forms.Padding(4);
|
|
||||||
this.flpProducts.Name = "flpProducts";
|
|
||||||
this.flpProducts.Size = new System.Drawing.Size(447, 390);
|
|
||||||
this.flpProducts.TabIndex = 2;
|
|
||||||
//
|
|
||||||
// btnGo
|
|
||||||
//
|
|
||||||
this.btnGo.Location = new System.Drawing.Point(16, 445);
|
|
||||||
this.btnGo.Margin = new System.Windows.Forms.Padding(4);
|
|
||||||
this.btnGo.Name = "btnGo";
|
|
||||||
this.btnGo.Size = new System.Drawing.Size(200, 28);
|
|
||||||
this.btnGo.TabIndex = 24;
|
|
||||||
this.btnGo.Text = "Load";
|
|
||||||
this.btnGo.UseVisualStyleBackColor = true;
|
|
||||||
this.btnGo.Click += new System.EventHandler(this.btnGo_Click);
|
|
||||||
//
|
|
||||||
// dtpFinishDate
|
|
||||||
//
|
|
||||||
this.dtpFinishDate.CustomFormat = "dd-MMM-yyyy";
|
|
||||||
this.dtpFinishDate.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
|
|
||||||
this.dtpFinishDate.Location = new System.Drawing.Point(143, 15);
|
|
||||||
this.dtpFinishDate.Margin = new System.Windows.Forms.Padding(4);
|
|
||||||
this.dtpFinishDate.Name = "dtpFinishDate";
|
|
||||||
this.dtpFinishDate.Size = new System.Drawing.Size(119, 22);
|
|
||||||
this.dtpFinishDate.TabIndex = 1;
|
|
||||||
//
|
|
||||||
// btnProcess
|
|
||||||
//
|
|
||||||
this.btnProcess.Location = new System.Drawing.Point(263, 445);
|
|
||||||
this.btnProcess.Margin = new System.Windows.Forms.Padding(4);
|
|
||||||
this.btnProcess.Name = "btnProcess";
|
|
||||||
this.btnProcess.Size = new System.Drawing.Size(200, 28);
|
|
||||||
this.btnProcess.TabIndex = 25;
|
|
||||||
this.btnProcess.Text = "Process";
|
|
||||||
this.btnProcess.UseVisualStyleBackColor = true;
|
|
||||||
this.btnProcess.Click += new System.EventHandler(this.btnProcess_Click);
|
|
||||||
//
|
|
||||||
// MoveForm
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(479, 488);
|
|
||||||
this.Controls.Add(this.btnProcess);
|
|
||||||
this.Controls.Add(this.dtpFinishDate);
|
|
||||||
this.Controls.Add(this.btnGo);
|
|
||||||
this.Controls.Add(this.flpProducts);
|
|
||||||
this.Controls.Add(this.dtpStartDate);
|
|
||||||
this.Margin = new System.Windows.Forms.Padding(4);
|
|
||||||
this.MaximizeBox = false;
|
|
||||||
this.Name = "MoveForm";
|
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
|
||||||
this.Text = "Sale Analysis Form";
|
|
||||||
this.Load += new System.EventHandler(this.Sale_Analysis_Form_Load);
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private System.Windows.Forms.DateTimePicker dtpStartDate;
|
|
||||||
private System.Windows.Forms.FlowLayoutPanel flpProducts;
|
|
||||||
private System.Windows.Forms.Button btnGo;
|
|
||||||
private System.Windows.Forms.DateTimePicker dtpFinishDate;
|
|
||||||
private System.Windows.Forms.Button btnProcess;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,120 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
||||||
@ -1,129 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Globalization;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
using Tanshu.Accounts.Repository;
|
|
||||||
|
|
||||||
namespace Tanshu.Accounts.Management
|
|
||||||
{
|
|
||||||
public partial class NcForm : Form
|
|
||||||
{
|
|
||||||
private IList<CheckBox> checkBoxes;
|
|
||||||
private IDictionary<int, string> list;
|
|
||||||
public NcForm()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Sale_Analysis_Form_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
dtpStartDate.Value = DateTime.Today;
|
|
||||||
dtpFinishDate.Value = DateTime.Today;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void btnGo_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
checkBoxes = new List<CheckBox>();
|
|
||||||
var startDate = dtpStartDate.Value.Date.AddHours(7);
|
|
||||||
var finishDate = dtpFinishDate.Value.Date.AddDays(1).AddHours(7);
|
|
||||||
var details = GetNc(startDate, finishDate);
|
|
||||||
foreach (var detail in details)
|
|
||||||
{
|
|
||||||
var item = (object[])detail;
|
|
||||||
var text = GetName((int)item[0]) + " ---> " + ((decimal)item[1]).ToString();
|
|
||||||
|
|
||||||
var label = new Label()
|
|
||||||
{
|
|
||||||
Name = "label" + ((int)item[0]).ToString(CultureInfo.InvariantCulture),
|
|
||||||
AutoSize = true,
|
|
||||||
Text = text
|
|
||||||
};
|
|
||||||
flpProducts.Controls.Add(label);
|
|
||||||
var checkBox = GetBox((int)item[0]);
|
|
||||||
checkBoxes.Add(checkBox);
|
|
||||||
flpProducts.Controls.Add(checkBox);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private ComboBox GetBox(int code)
|
|
||||||
{
|
|
||||||
var checkBox = new CheckBox()
|
|
||||||
{
|
|
||||||
Name = "comboBox" + (code).ToString(CultureInfo.InvariantCulture),
|
|
||||||
Width = 400,
|
|
||||||
Height = 20,
|
|
||||||
Tag = code,
|
|
||||||
DisplayMember = "Value",
|
|
||||||
ValueMember = "Key",
|
|
||||||
DropDownStyle = ComboBoxStyle.DropDownList,
|
|
||||||
DataSource = new BindingSource(list, null)
|
|
||||||
};
|
|
||||||
//foreach (var item in list)
|
|
||||||
// comboBox.Items.Add(new { Code = item.Key, Name = item.Value });
|
|
||||||
//MessageBox.Show(code.ToString());
|
|
||||||
//comboBox.SelectedIndex = code - 1;
|
|
||||||
comboBox.SelectedValue = code;
|
|
||||||
return comboBox;
|
|
||||||
}
|
|
||||||
private static string GetName(int code)
|
|
||||||
{
|
|
||||||
switch (code)
|
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
return "1 - Dark";
|
|
||||||
case 2:
|
|
||||||
return "2 - Wheat";
|
|
||||||
case 3:
|
|
||||||
return "3 - Premium";
|
|
||||||
case 4:
|
|
||||||
return "4 - Light";
|
|
||||||
case 5:
|
|
||||||
return "5 - Dragon";
|
|
||||||
case 6:
|
|
||||||
return "6 - Festival";
|
|
||||||
case 7:
|
|
||||||
return "7 - Vanilla";
|
|
||||||
case 8:
|
|
||||||
return "8 - Strong";
|
|
||||||
default:
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private static decimal TryConvert(string amount)
|
|
||||||
{
|
|
||||||
decimal result = 0;
|
|
||||||
decimal.TryParse(amount, out result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static IList GetNcable(DateTime startDate, DateTime finishDate)
|
|
||||||
{
|
|
||||||
using (var bi = new ManagementBI())
|
|
||||||
return bi.GetNcable(startDate, finishDate);
|
|
||||||
}
|
|
||||||
private static void SetMove(int fromBaseCode, int toBaseCode, DateTime startDate, DateTime finishDate)
|
|
||||||
{
|
|
||||||
using (var bi = new ManagementBI())
|
|
||||||
bi.SetMove(fromBaseCode, toBaseCode, startDate, finishDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void btnProcess_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
btnProcess.Enabled = false;
|
|
||||||
var startDate = dtpStartDate.Value.Date.AddHours(7);
|
|
||||||
var finishDate = dtpFinishDate.Value.Date.AddDays(1).AddHours(7);
|
|
||||||
foreach (var item in comboBoxes)
|
|
||||||
{
|
|
||||||
var fromBaseCode = (int) item.Tag;
|
|
||||||
var toBaseCode = (int) item.SelectedValue;
|
|
||||||
if (fromBaseCode == toBaseCode)
|
|
||||||
continue;
|
|
||||||
Text = GetName(fromBaseCode) + " to " + GetName(toBaseCode);
|
|
||||||
MessageBox.Show(Text);
|
|
||||||
SetMove(fromBaseCode, toBaseCode, startDate , finishDate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,119 +0,0 @@
|
|||||||
namespace Tanshu.Accounts.Management
|
|
||||||
{
|
|
||||||
partial class NcForm
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.dtpStartDate = new System.Windows.Forms.DateTimePicker();
|
|
||||||
this.flpProducts = new System.Windows.Forms.FlowLayoutPanel();
|
|
||||||
this.btnGo = new System.Windows.Forms.Button();
|
|
||||||
this.dtpFinishDate = new System.Windows.Forms.DateTimePicker();
|
|
||||||
this.btnProcess = new System.Windows.Forms.Button();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// dtpStartDate
|
|
||||||
//
|
|
||||||
this.dtpStartDate.CustomFormat = "dd-MMM-yyyy";
|
|
||||||
this.dtpStartDate.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
|
|
||||||
this.dtpStartDate.Location = new System.Drawing.Point(16, 15);
|
|
||||||
this.dtpStartDate.Margin = new System.Windows.Forms.Padding(4);
|
|
||||||
this.dtpStartDate.Name = "dtpStartDate";
|
|
||||||
this.dtpStartDate.Size = new System.Drawing.Size(119, 22);
|
|
||||||
this.dtpStartDate.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// flpProducts
|
|
||||||
//
|
|
||||||
this.flpProducts.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
|
||||||
| System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.flpProducts.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
|
|
||||||
this.flpProducts.Location = new System.Drawing.Point(16, 47);
|
|
||||||
this.flpProducts.Margin = new System.Windows.Forms.Padding(4);
|
|
||||||
this.flpProducts.Name = "flpProducts";
|
|
||||||
this.flpProducts.Size = new System.Drawing.Size(447, 390);
|
|
||||||
this.flpProducts.TabIndex = 2;
|
|
||||||
//
|
|
||||||
// btnGo
|
|
||||||
//
|
|
||||||
this.btnGo.Location = new System.Drawing.Point(16, 445);
|
|
||||||
this.btnGo.Margin = new System.Windows.Forms.Padding(4);
|
|
||||||
this.btnGo.Name = "btnGo";
|
|
||||||
this.btnGo.Size = new System.Drawing.Size(200, 28);
|
|
||||||
this.btnGo.TabIndex = 24;
|
|
||||||
this.btnGo.Text = "Load";
|
|
||||||
this.btnGo.UseVisualStyleBackColor = true;
|
|
||||||
this.btnGo.Click += new System.EventHandler(this.btnGo_Click);
|
|
||||||
//
|
|
||||||
// dtpFinishDate
|
|
||||||
//
|
|
||||||
this.dtpFinishDate.CustomFormat = "dd-MMM-yyyy";
|
|
||||||
this.dtpFinishDate.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
|
|
||||||
this.dtpFinishDate.Location = new System.Drawing.Point(143, 15);
|
|
||||||
this.dtpFinishDate.Margin = new System.Windows.Forms.Padding(4);
|
|
||||||
this.dtpFinishDate.Name = "dtpFinishDate";
|
|
||||||
this.dtpFinishDate.Size = new System.Drawing.Size(119, 22);
|
|
||||||
this.dtpFinishDate.TabIndex = 1;
|
|
||||||
//
|
|
||||||
// btnProcess
|
|
||||||
//
|
|
||||||
this.btnProcess.Location = new System.Drawing.Point(263, 445);
|
|
||||||
this.btnProcess.Margin = new System.Windows.Forms.Padding(4);
|
|
||||||
this.btnProcess.Name = "btnProcess";
|
|
||||||
this.btnProcess.Size = new System.Drawing.Size(200, 28);
|
|
||||||
this.btnProcess.TabIndex = 25;
|
|
||||||
this.btnProcess.Text = "Process";
|
|
||||||
this.btnProcess.UseVisualStyleBackColor = true;
|
|
||||||
this.btnProcess.Click += new System.EventHandler(this.btnProcess_Click);
|
|
||||||
//
|
|
||||||
// MoveForm
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(479, 488);
|
|
||||||
this.Controls.Add(this.btnProcess);
|
|
||||||
this.Controls.Add(this.dtpFinishDate);
|
|
||||||
this.Controls.Add(this.btnGo);
|
|
||||||
this.Controls.Add(this.flpProducts);
|
|
||||||
this.Controls.Add(this.dtpStartDate);
|
|
||||||
this.Margin = new System.Windows.Forms.Padding(4);
|
|
||||||
this.MaximizeBox = false;
|
|
||||||
this.Name = "MoveForm";
|
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
|
||||||
this.Text = "Sale Analysis Form";
|
|
||||||
this.Load += new System.EventHandler(this.Sale_Analysis_Form_Load);
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private System.Windows.Forms.DateTimePicker dtpStartDate;
|
|
||||||
private System.Windows.Forms.FlowLayoutPanel flpProducts;
|
|
||||||
private System.Windows.Forms.Button btnGo;
|
|
||||||
private System.Windows.Forms.DateTimePicker dtpFinishDate;
|
|
||||||
private System.Windows.Forms.Button btnProcess;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,120 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
||||||
@ -1,159 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Globalization;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
using Tanshu.Accounts.Repository;
|
|
||||||
using Tanshu.Accounts.Contracts;
|
|
||||||
|
|
||||||
namespace Tanshu.Accounts.Management
|
|
||||||
{
|
|
||||||
public partial class QuantityForm : Form
|
|
||||||
{
|
|
||||||
private IList<TextBox> textBoxes;
|
|
||||||
public QuantityForm()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Sale_Analysis_Form_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
dtpDate.Value = DateTime.Today;
|
|
||||||
|
|
||||||
textBoxes = new List<TextBox>();
|
|
||||||
for (int i = 0; i < 8; i++)
|
|
||||||
{
|
|
||||||
var text = "";
|
|
||||||
switch (i)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
text = "1 - Dark";
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
text = "2 - Wheat";
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
text = "3 - Premium";
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
text = "4 - Light";
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
text = "5 - Dragon";
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
text = "6 - Festival";
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
text = "7 - Vanilla";
|
|
||||||
break;
|
|
||||||
case 7:
|
|
||||||
text = "8 - Strong";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
var label = new Label()
|
|
||||||
{
|
|
||||||
Name = "label" + (i + 1).ToString(CultureInfo.InvariantCulture),
|
|
||||||
AutoSize = true,
|
|
||||||
Text = text
|
|
||||||
};
|
|
||||||
flpProducts.Controls.Add(label);
|
|
||||||
var textBox = new TextBox()
|
|
||||||
{
|
|
||||||
Name = "textBox" + (i + 1).ToString(CultureInfo.InvariantCulture),
|
|
||||||
Width = 400,
|
|
||||||
Height = 22,
|
|
||||||
Tag = new object[] { (i + 1), text }
|
|
||||||
};
|
|
||||||
textBoxes.Add(textBox);
|
|
||||||
flpProducts.Controls.Add(textBox);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void btnGo_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
foreach (var textBox in textBoxes)
|
|
||||||
{
|
|
||||||
var startDate = dtpDate.Value.Date.AddHours(7);
|
|
||||||
var finishDate = startDate.AddDays(1);
|
|
||||||
|
|
||||||
var baseCode = (int)(((object[])textBox.Tag)[0]);
|
|
||||||
var text = (string)(((object[])textBox.Tag)[1]);
|
|
||||||
foreach (var item in textBox.Text.Split(','))
|
|
||||||
{
|
|
||||||
var newQuantity = TryConvert(item);
|
|
||||||
var quantity = GetQuantity(baseCode, startDate, finishDate);
|
|
||||||
|
|
||||||
if (MessageBox.Show(text + " " + startDate.ToString("dd-MMM-yyyy") + " " + quantity.ToString(), "Quantity of Beer", MessageBoxButtons.YesNo,
|
|
||||||
MessageBoxIcon.Information, MessageBoxDefaultButton.Button2) == DialogResult.Yes &&
|
|
||||||
quantity > newQuantity && newQuantity > 0)
|
|
||||||
{
|
|
||||||
MessageBox.Show(SetQuantity(baseCode, newQuantity, startDate, finishDate).ToString());
|
|
||||||
}
|
|
||||||
startDate = startDate.AddDays(1);
|
|
||||||
finishDate = finishDate.AddDays(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private decimal TryConvert(string amount)
|
|
||||||
{
|
|
||||||
decimal result = 0;
|
|
||||||
decimal.TryParse(amount, out result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
private decimal GetQuantity(int baseCode, DateTime startDate, DateTime finishDate)
|
|
||||||
{
|
|
||||||
using (var bi = new ManagementBI())
|
|
||||||
return bi.GetQuantity(baseCode, startDate, finishDate);
|
|
||||||
}
|
|
||||||
private decimal SetQuantity(int baseCode, decimal quantity, DateTime startDate, DateTime finishDate)
|
|
||||||
{
|
|
||||||
using (var bi = new ManagementBI())
|
|
||||||
return bi.SetQuantity(baseCode, quantity, startDate, finishDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void btnGetClipboard_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
//Clipboard format -- Date,BaseCode,Quantity"
|
|
||||||
var fmtCsv = DataFormats.CommaSeparatedValue;
|
|
||||||
|
|
||||||
// read the CSV
|
|
||||||
var dataobject = Clipboard.GetDataObject();
|
|
||||||
if (dataobject == null)
|
|
||||||
{
|
|
||||||
MessageBox.Show(@"No Data in clipboard");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var stream = (System.IO.Stream)dataobject.GetData(fmtCsv);
|
|
||||||
var enc = new System.Text.UTF8Encoding();
|
|
||||||
|
|
||||||
IFormatProvider culture = new CultureInfo("en-US", true);
|
|
||||||
|
|
||||||
using (var reader = new System.IO.StreamReader(stream, enc))
|
|
||||||
{
|
|
||||||
using (var bi = new ManagementBI())
|
|
||||||
{
|
|
||||||
string line;
|
|
||||||
while ((line = reader.ReadLine()) != null)
|
|
||||||
{
|
|
||||||
DateTime startDate;
|
|
||||||
int baseCode;
|
|
||||||
decimal quantity;
|
|
||||||
var data = line.Split(',');
|
|
||||||
if (!DateTime.TryParseExact(data[0], "dd-MMM-yyyy", culture, DateTimeStyles.NoCurrentDateDefault, out startDate))
|
|
||||||
continue;
|
|
||||||
var finishDate = startDate.AddDays(1).AddHours(7);
|
|
||||||
startDate = startDate.AddHours(7);
|
|
||||||
if (!int.TryParse(data[1], out baseCode))
|
|
||||||
continue;
|
|
||||||
if (baseCode <= 0)
|
|
||||||
continue;
|
|
||||||
if (!decimal.TryParse(data[2], out quantity))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
bi.SetQuantity(baseCode, quantity, startDate, finishDate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,92 +0,0 @@
|
|||||||
namespace Tanshu.Accounts.Management
|
|
||||||
{
|
|
||||||
partial class QuantityForm
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.dtpDate = new System.Windows.Forms.DateTimePicker();
|
|
||||||
this.flpProducts = new System.Windows.Forms.FlowLayoutPanel();
|
|
||||||
this.btnGo = new System.Windows.Forms.Button();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// dtpDate
|
|
||||||
//
|
|
||||||
this.dtpDate.CustomFormat = "dd-MMM-yyyy";
|
|
||||||
this.dtpDate.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
|
|
||||||
this.dtpDate.Location = new System.Drawing.Point(16, 15);
|
|
||||||
this.dtpDate.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
|
||||||
this.dtpDate.Name = "dtpDate";
|
|
||||||
this.dtpDate.Size = new System.Drawing.Size(119, 22);
|
|
||||||
this.dtpDate.TabIndex = 20;
|
|
||||||
//
|
|
||||||
// flpProducts
|
|
||||||
//
|
|
||||||
this.flpProducts.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
|
||||||
| System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.flpProducts.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
|
|
||||||
this.flpProducts.Location = new System.Drawing.Point(16, 47);
|
|
||||||
this.flpProducts.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
|
||||||
this.flpProducts.Name = "flpProducts";
|
|
||||||
this.flpProducts.Size = new System.Drawing.Size(447, 390);
|
|
||||||
this.flpProducts.TabIndex = 23;
|
|
||||||
//
|
|
||||||
// btnGo
|
|
||||||
//
|
|
||||||
this.btnGo.Location = new System.Drawing.Point(16, 445);
|
|
||||||
this.btnGo.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
|
||||||
this.btnGo.Name = "btnGo";
|
|
||||||
this.btnGo.Size = new System.Drawing.Size(200, 28);
|
|
||||||
this.btnGo.TabIndex = 24;
|
|
||||||
this.btnGo.Text = "Go";
|
|
||||||
this.btnGo.UseVisualStyleBackColor = true;
|
|
||||||
this.btnGo.Click += new System.EventHandler(this.btnGo_Click);
|
|
||||||
//
|
|
||||||
// QuantityForm
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(479, 488);
|
|
||||||
this.Controls.Add(this.btnGo);
|
|
||||||
this.Controls.Add(this.flpProducts);
|
|
||||||
this.Controls.Add(this.dtpDate);
|
|
||||||
this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
|
||||||
this.MaximizeBox = false;
|
|
||||||
this.Name = "QuantityForm";
|
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
|
||||||
this.Text = "Sale Analysis Form";
|
|
||||||
this.Load += new System.EventHandler(this.Sale_Analysis_Form_Load);
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private System.Windows.Forms.DateTimePicker dtpDate;
|
|
||||||
private System.Windows.Forms.FlowLayoutPanel flpProducts;
|
|
||||||
private System.Windows.Forms.Button btnGo;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,120 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
||||||
@ -3,8 +3,6 @@ using System.Collections.Generic;
|
|||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using Tanshu.Accounts.Repository;
|
using Tanshu.Accounts.Repository;
|
||||||
using Tanshu.Accounts.Contracts;
|
using Tanshu.Accounts.Contracts;
|
||||||
using Tanshu.Accounts.Helpers;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace Tanshu.Accounts.PointOfSale
|
namespace Tanshu.Accounts.PointOfSale
|
||||||
{
|
{
|
||||||
|
|||||||
@ -126,29 +126,11 @@
|
|||||||
<Compile Include="CurrencyCounter.Designer.cs">
|
<Compile Include="CurrencyCounter.Designer.cs">
|
||||||
<DependentUpon>CurrencyCounter.cs</DependentUpon>
|
<DependentUpon>CurrencyCounter.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Management\AmountForm.cs">
|
<Compile Include="Management\ManagementForm.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Management\AmountForm.designer.cs">
|
<Compile Include="Management\ManagementForm.designer.cs">
|
||||||
<DependentUpon>AmountForm.cs</DependentUpon>
|
<DependentUpon>ManagementForm.cs</DependentUpon>
|
||||||
</Compile>
|
|
||||||
<Compile Include="Management\MoveForm.cs">
|
|
||||||
<SubType>Form</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Management\MoveForm.designer.cs">
|
|
||||||
<DependentUpon>MoveForm.cs</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Management\FoodForm.cs">
|
|
||||||
<SubType>Form</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Management\FoodForm.designer.cs">
|
|
||||||
<DependentUpon>FoodForm.cs</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Management\QuantityForm.cs">
|
|
||||||
<SubType>Form</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Management\QuantityForm.designer.cs">
|
|
||||||
<DependentUpon>QuantityForm.cs</DependentUpon>
|
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Products\ProductListForm.cs">
|
<Compile Include="Products\ProductListForm.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
@ -311,17 +293,8 @@
|
|||||||
<EmbeddedResource Include="CurrencyCounter.resx">
|
<EmbeddedResource Include="CurrencyCounter.resx">
|
||||||
<DependentUpon>CurrencyCounter.cs</DependentUpon>
|
<DependentUpon>CurrencyCounter.cs</DependentUpon>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
<EmbeddedResource Include="Management\AmountForm.resx">
|
<EmbeddedResource Include="Management\ManagementForm.resx">
|
||||||
<DependentUpon>AmountForm.cs</DependentUpon>
|
<DependentUpon>ManagementForm.cs</DependentUpon>
|
||||||
</EmbeddedResource>
|
|
||||||
<EmbeddedResource Include="Management\MoveForm.resx">
|
|
||||||
<DependentUpon>MoveForm.cs</DependentUpon>
|
|
||||||
</EmbeddedResource>
|
|
||||||
<EmbeddedResource Include="Management\FoodForm.resx">
|
|
||||||
<DependentUpon>FoodForm.cs</DependentUpon>
|
|
||||||
</EmbeddedResource>
|
|
||||||
<EmbeddedResource Include="Management\QuantityForm.resx">
|
|
||||||
<DependentUpon>QuantityForm.cs</DependentUpon>
|
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
<EmbeddedResource Include="Products\ProductListForm.resx">
|
<EmbeddedResource Include="Products\ProductListForm.resx">
|
||||||
<DependentUpon>ProductListForm.cs</DependentUpon>
|
<DependentUpon>ProductListForm.cs</DependentUpon>
|
||||||
|
|||||||
@ -1,8 +1,4 @@
|
|||||||
using System;
|
using Tanshu.Accounts.Entities;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq.Expressions;
|
|
||||||
using Tanshu.Accounts.Contracts;
|
|
||||||
using Tanshu.Accounts.Entities;
|
|
||||||
using NHibernate;
|
using NHibernate;
|
||||||
|
|
||||||
namespace Tanshu.Accounts.Repository
|
namespace Tanshu.Accounts.Repository
|
||||||
|
|||||||
@ -4,6 +4,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NHibernate;
|
using NHibernate;
|
||||||
using Tanshu.Accounts.Entities;
|
using Tanshu.Accounts.Entities;
|
||||||
|
using Tanshu.Common.Helpers;
|
||||||
|
|
||||||
namespace Tanshu.Accounts.Repository
|
namespace Tanshu.Accounts.Repository
|
||||||
{
|
{
|
||||||
@ -24,31 +25,418 @@ namespace Tanshu.Accounts.Repository
|
|||||||
public ManagementBI(ISession session, bool beginTransaction)
|
public ManagementBI(ISession session, bool beginTransaction)
|
||||||
: base(session, beginTransaction)
|
: base(session, beginTransaction)
|
||||||
{ }
|
{ }
|
||||||
|
#region Cleanup
|
||||||
|
public void DeleteVoid(DateTime startDate, DateTime finishDate)
|
||||||
|
{
|
||||||
|
IList<Voucher> list;
|
||||||
|
using (var bi = new VoucherBI(Session))
|
||||||
|
{
|
||||||
|
list = bi.List(x => x.Date >= startDate && x.Date <= finishDate && x.Void);
|
||||||
|
}
|
||||||
|
foreach (var item in list)
|
||||||
|
{
|
||||||
|
using (var bi = new VoucherBI())
|
||||||
|
{
|
||||||
|
using (var ri = new ReprintBI())
|
||||||
|
{
|
||||||
|
ri.DeleteList(x => x.Voucher.VoucherID == item.VoucherID);
|
||||||
|
bi.Delete(item.VoucherID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void DeleteStaff(DateTime startDate, DateTime finishDate)
|
||||||
|
{
|
||||||
|
IList<Voucher> list;
|
||||||
|
using (var bi = new VoucherBI(Session))
|
||||||
|
{
|
||||||
|
list = bi.List(x => x.Date >= startDate && x.Date <= finishDate && x.VoucherType == VoucherType.Staff);
|
||||||
|
}
|
||||||
|
foreach (var item in list)
|
||||||
|
{
|
||||||
|
using (var bi = new VoucherBI())
|
||||||
|
{
|
||||||
|
using (var ri = new ReprintBI())
|
||||||
|
{
|
||||||
|
ri.DeleteList(x => x.Voucher.VoucherID == item.VoucherID);
|
||||||
|
bi.Delete(item.VoucherID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void SetPayments(DateTime startDate, DateTime finishDate)
|
||||||
|
{
|
||||||
|
using (var bi = new VoucherBI(Session))
|
||||||
|
{
|
||||||
|
var list = bi.List(x => x.Date >= startDate && x.Date <= finishDate);
|
||||||
|
foreach (var voucher in list)
|
||||||
|
{
|
||||||
|
var settlementType = SettleOption.Cash;
|
||||||
|
switch (voucher.VoucherType)
|
||||||
|
{
|
||||||
|
case VoucherType.NoCharge:
|
||||||
|
settlementType = SettleOption.NoCharge;
|
||||||
|
break;
|
||||||
|
case VoucherType.Staff:
|
||||||
|
settlementType = SettleOption.Staff;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
var amount = -1 * voucher.Kots.Sum(x => x.Inventories.Sum(y => y.Amount));
|
||||||
|
var roundoff = Math.Round(amount) - amount;
|
||||||
|
voucher.Settlements.Clear();
|
||||||
|
voucher.Settlements.Add(new VoucherSettlement() { Amount = amount, Settled = SettleOption.Amount });
|
||||||
|
voucher.Settlements.Add(new VoucherSettlement() { Amount = roundoff, Settled = SettleOption.RoundOff });
|
||||||
|
voucher.Settlements.Add(new VoucherSettlement() { Amount = -1 * (amount + roundoff), Settled = settlementType });
|
||||||
|
Session.Update(voucher);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void ClearModifiers(DateTime startDate, DateTime finishDate)
|
||||||
|
{
|
||||||
|
using (var bi = new VoucherBI(Session))
|
||||||
|
{
|
||||||
|
var list = bi.List(x => x.Date >= startDate && x.Date <= finishDate);
|
||||||
|
foreach (var voucher in list)
|
||||||
|
{
|
||||||
|
foreach (var kot in voucher.Kots)
|
||||||
|
{
|
||||||
|
foreach (var inventory in kot.Inventories)
|
||||||
|
{
|
||||||
|
if (inventory.InventoryModifier.Count > 0)
|
||||||
|
inventory.InventoryModifier.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Session.Update(voucher);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void CombineKots(DateTime startDate, DateTime finishDate)
|
||||||
|
{
|
||||||
|
using (var bi = new VoucherBI(Session))
|
||||||
|
{
|
||||||
|
var list = bi.List(x => x.Date >= startDate && x.Date <= finishDate);
|
||||||
|
foreach (var voucher in list)
|
||||||
|
{
|
||||||
|
if (voucher.Kots.Count == 0)
|
||||||
|
continue;
|
||||||
|
var kots = voucher.Kots.OrderBy(x => x.Date);
|
||||||
|
var kot = kots.First();
|
||||||
|
for (var kotIndex = kots.Count(); kotIndex > 1; kotIndex--)
|
||||||
|
{
|
||||||
|
var otherKot = kots.ElementAt(kotIndex - 1);
|
||||||
|
for (var i = otherKot.Inventories.Count; i > 0; i--)
|
||||||
|
{
|
||||||
|
var inventory = otherKot.Inventories[i - 1];
|
||||||
|
var oldProduct = kot.Inventories.SingleOrDefault(x => x.Product.ProductID == inventory.Product.ProductID);
|
||||||
|
if (oldProduct == null)
|
||||||
|
{
|
||||||
|
inventory.Kot = kot;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
oldProduct.Quantity += inventory.Quantity;
|
||||||
|
otherKot.Inventories.RemoveAt(i - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Session.Update(voucher);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void RemoveBlankKots(DateTime startDate, DateTime finishDate)
|
||||||
|
{
|
||||||
|
using (var bi = new VoucherBI(Session))
|
||||||
|
{
|
||||||
|
var list = bi.List(x => x.Date >= startDate && x.Date <= finishDate);
|
||||||
|
foreach (var voucher in list)
|
||||||
|
{
|
||||||
|
for (var kotIndex = voucher.Kots.Count; kotIndex > 0; kotIndex--)
|
||||||
|
{
|
||||||
|
var kot = voucher.Kots[kotIndex - 1];
|
||||||
|
if (kot.Inventories.Count == 0)
|
||||||
|
voucher.Kots.RemoveAt(kotIndex - 1);
|
||||||
|
}
|
||||||
|
Session.Update(voucher);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public decimal GetFood(int vatID, DateTime startDate, DateTime finishDate)
|
public void FinalSanction(DateTime startDate, DateTime finishDate)
|
||||||
|
{
|
||||||
|
var query = @"
|
||||||
|
select v.BillID
|
||||||
|
from Voucher v
|
||||||
|
where v.Date < :startDate and v.Void = false and v.VoucherType not in (:nc, :staff)
|
||||||
|
order by v.Date desc
|
||||||
|
";
|
||||||
|
var lastBill = Session
|
||||||
|
.CreateQuery(query)
|
||||||
|
.SetParameter("startDate", startDate)
|
||||||
|
.SetParameter("nc", VoucherType.NoCharge)
|
||||||
|
.SetParameter("staff", VoucherType.Staff)
|
||||||
|
.SetMaxResults(1)
|
||||||
|
.UniqueResult();
|
||||||
|
var newID = lastBill == null ? "01-0001" : GetNewID((string)lastBill);
|
||||||
|
var list = Session.QueryOver<Voucher>().Where(x => x.Date >= startDate && x.Date <= finishDate && x.VoucherType != VoucherType.NoCharge && x.VoucherType != VoucherType.Staff && x.Void == false).OrderBy(x => x.Date).Asc.List();
|
||||||
|
foreach (var voucher in list)
|
||||||
|
{
|
||||||
|
if (voucher.BillID != newID)
|
||||||
|
{
|
||||||
|
voucher.SetValue(VoucherFields.BillID, newID);
|
||||||
|
Session.Update(voucher);
|
||||||
|
}
|
||||||
|
newID = GetNewID(newID);
|
||||||
|
}
|
||||||
|
|
||||||
|
query = @"
|
||||||
|
select v.BillID
|
||||||
|
from Voucher v
|
||||||
|
where v.Date < :startDate and v.Void = false and v.VoucherType = :nc
|
||||||
|
order by v.Date desc
|
||||||
|
";
|
||||||
|
lastBill = Session
|
||||||
|
.CreateQuery(query)
|
||||||
|
.SetParameter("startDate", startDate)
|
||||||
|
.SetParameter("nc", VoucherType.NoCharge)
|
||||||
|
.SetMaxResults(1)
|
||||||
|
.UniqueResult();
|
||||||
|
newID = lastBill == null ? "NC-1" : GetNewNc((string)lastBill);
|
||||||
|
list = Session.QueryOver<Voucher>().Where(x => x.Date >= startDate && x.Date <= finishDate && x.VoucherType == VoucherType.NoCharge && x.Void == false).OrderBy(x => x.Date).Asc.List();
|
||||||
|
foreach (var voucher in list)
|
||||||
|
{
|
||||||
|
if (voucher.BillID != newID)
|
||||||
|
{
|
||||||
|
voucher.SetValue(VoucherFields.BillID, newID);
|
||||||
|
Session.Update(voucher);
|
||||||
|
}
|
||||||
|
newID = GetNewNc(newID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetNewNc(string lastBill)
|
||||||
|
{
|
||||||
|
var parts = lastBill.Split('-');
|
||||||
|
if (parts.Length != 2)
|
||||||
|
throw new ArgumentOutOfRangeException();
|
||||||
|
int one;
|
||||||
|
if (parts[0] != "NC")
|
||||||
|
throw new ArgumentOutOfRangeException();
|
||||||
|
if (!int.TryParse(parts[1], out one))
|
||||||
|
throw new ArgumentOutOfRangeException();
|
||||||
|
one += 1;
|
||||||
|
return string.Format("NC-{0}", one);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetNewID(string lastBill)
|
||||||
|
{
|
||||||
|
var parts = lastBill.Split('-');
|
||||||
|
if (parts.Length != 2)
|
||||||
|
throw new ArgumentOutOfRangeException();
|
||||||
|
int one, two;
|
||||||
|
if (!int.TryParse(parts[0], out one))
|
||||||
|
throw new ArgumentOutOfRangeException();
|
||||||
|
if (!int.TryParse(parts[1], out two))
|
||||||
|
throw new ArgumentOutOfRangeException();
|
||||||
|
if (two >= 9999)
|
||||||
|
{
|
||||||
|
one += 1;
|
||||||
|
two = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
two += 1;
|
||||||
|
}
|
||||||
|
return string.Format("{0:00}-{1:0000}", one, two);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
public void MoveNc(DateTime startDate, DateTime finishDate, decimal target)
|
||||||
|
{
|
||||||
|
const string query = @"
|
||||||
|
select v.VoucherID, sum(i.Amount)
|
||||||
|
from Voucher v
|
||||||
|
inner join v.Kots k
|
||||||
|
inner join k.Inventories i
|
||||||
|
where v.Date >= :startDate and v.Date <= :finishDate and i.Vat in (.1575, .2625) and v.Void = false and v.VoucherType not in (:nc, :staff)
|
||||||
|
group by v.VoucherID
|
||||||
|
order by sum(i.Amount) desc
|
||||||
|
";
|
||||||
|
var list = Session
|
||||||
|
.CreateQuery(query)
|
||||||
|
.SetParameter("startDate", startDate.AddHours(7))
|
||||||
|
.SetParameter("finishDate", finishDate.AddDays(1).AddHours(7))
|
||||||
|
.SetParameter("nc", VoucherType.NoCharge)
|
||||||
|
.SetParameter("staff", VoucherType.Staff)
|
||||||
|
.List();
|
||||||
|
var totalAmount = GetFood(.1575M, startDate, finishDate) + GetFood(.2625M, startDate, finishDate);
|
||||||
|
var skip = false;
|
||||||
|
for (int i = 0; i < list.Count / 20; i++)
|
||||||
|
{
|
||||||
|
if (target / totalAmount > .75M)
|
||||||
|
break;
|
||||||
|
skip = !skip;
|
||||||
|
if (skip)
|
||||||
|
continue;
|
||||||
|
var item = (object[])list[i];
|
||||||
|
var voucherID = (int)item[0];
|
||||||
|
var amount = (decimal)item[1];
|
||||||
|
using (var bi = new VoucherBI(Session))
|
||||||
|
{
|
||||||
|
var voucher = bi.Get(x => x.VoucherID == voucherID);
|
||||||
|
voucher.VoucherType = VoucherType.NoCharge;
|
||||||
|
Session.Update(voucher);
|
||||||
|
}
|
||||||
|
totalAmount -= amount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public Dictionary<DateTime, decimal> GetLiq(decimal vat, DateTime startDate, DateTime finishDate)
|
||||||
{
|
{
|
||||||
const string query = @"
|
const string query = @"
|
||||||
select sum(i.Quantity * i.Price * (1 - i.Discount) * (1 + case when i.IsScTaxable then i.ServiceCharge else 0 end)) as Amount
|
select sum(i.Quantity * i.Price * (1 - i.Discount) * (1 + case when i.IsScTaxable then i.ServiceCharge else 0 end)) as Amount
|
||||||
from Voucher v
|
from Voucher v
|
||||||
inner join v.Kots k
|
inner join v.Kots k
|
||||||
inner join k.Inventories i
|
inner join k.Inventories i
|
||||||
inner join i.Product p
|
where v.Date >= :startDate and v.Date <= :finishDate and i.Vat = :vat and v.Void = false and v.VoucherType not in (:nc, :staff)
|
||||||
where v.Date >= :startDate and v.Date <= :finishDate and p.Vat.TaxID = :vatID and v.Void = false and v.VoucherType not in (:nc, :staff)
|
";
|
||||||
|
var dict = new Dictionary<DateTime, decimal>();
|
||||||
|
for (var date = startDate; date <= finishDate; date = date.AddDays(1))
|
||||||
|
{
|
||||||
|
var qty = Session
|
||||||
|
.CreateQuery(query)
|
||||||
|
.SetParameter("startDate", date.AddHours(7))
|
||||||
|
.SetParameter("finishDate", date.AddDays(1).AddHours(7))
|
||||||
|
.SetParameter("vat", vat)
|
||||||
|
.SetParameter("nc", VoucherType.NoCharge)
|
||||||
|
.SetParameter("staff", VoucherType.Staff)
|
||||||
|
.UniqueResult();
|
||||||
|
dict.Add(date, qty == null ? 0 : (decimal)qty);
|
||||||
|
}
|
||||||
|
return dict;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dictionary<DateTime, decimal> GetGrossSale(DateTime startDate, DateTime finishDate)
|
||||||
|
{
|
||||||
|
const string query = @"
|
||||||
|
select sum(i.Quantity * i.Price * (1 - i.Discount) * (1 + case when i.IsScTaxable then i.ServiceCharge else 0 end)) * (1 + i.Vat) as Amount
|
||||||
|
from Voucher v
|
||||||
|
inner join v.Kots k
|
||||||
|
inner join k.Inventories i
|
||||||
|
where v.Date >= :startDate and v.Date <= :finishDate and v.Void = false and v.VoucherType not in (:nc, :staff)
|
||||||
|
";
|
||||||
|
var dict = new Dictionary<DateTime, decimal>();
|
||||||
|
for (var date = startDate; date <= finishDate; date = date.AddDays(1))
|
||||||
|
{
|
||||||
|
var qty = Session
|
||||||
|
.CreateQuery(query)
|
||||||
|
.SetParameter("startDate", date.AddHours(7))
|
||||||
|
.SetParameter("finishDate", date.AddDays(1).AddHours(7))
|
||||||
|
.SetParameter("nc", VoucherType.NoCharge)
|
||||||
|
.SetParameter("staff", VoucherType.Staff)
|
||||||
|
.UniqueResult();
|
||||||
|
dict.Add(date, qty == null ? 0 : (decimal)qty);
|
||||||
|
}
|
||||||
|
return dict;
|
||||||
|
}
|
||||||
|
|
||||||
|
public decimal GetVat(decimal vat, DateTime startDate, DateTime finishDate)
|
||||||
|
{
|
||||||
|
const string query = @"
|
||||||
|
select sum(i.Quantity * i.Price * (1 - i.Discount) * (1 + case when i.IsScTaxable then i.ServiceCharge else 0 end) * i.Vat) as Amount
|
||||||
|
from Voucher v
|
||||||
|
inner join v.Kots k
|
||||||
|
inner join k.Inventories i
|
||||||
|
where v.Date >= :startDate and v.Date <= :finishDate and i.Vat = :vat and v.Void = false and v.VoucherType not in (:nc, :staff)
|
||||||
";
|
";
|
||||||
var qty = Session
|
var qty = Session
|
||||||
.CreateQuery(query)
|
.CreateQuery(query)
|
||||||
.SetParameter("startDate", startDate)
|
.SetParameter("startDate", startDate)
|
||||||
.SetParameter("finishDate", finishDate)
|
.SetParameter("finishDate", finishDate)
|
||||||
.SetParameter("vatID", vatID)
|
.SetParameter("vat", vat)
|
||||||
.SetParameter("nc", VoucherType.NoCharge)
|
.SetParameter("nc", VoucherType.NoCharge)
|
||||||
.SetParameter("staff", VoucherType.Staff)
|
.SetParameter("staff", VoucherType.Staff)
|
||||||
.UniqueResult();
|
.UniqueResult();
|
||||||
return qty == null ? 0 : (decimal)qty;
|
return qty == null ? 0 : (decimal)qty;
|
||||||
}
|
}
|
||||||
public decimal SetFood(int vatID, decimal amount, DateTime startDate, DateTime finishDate)
|
|
||||||
|
public decimal GetServiceTax(DateTime startDate, DateTime finishDate)
|
||||||
|
{
|
||||||
|
const string query = @"
|
||||||
|
select sum(i.Quantity * i.Price * (1 - i.Discount) * (1 + case when i.IsScTaxable then i.ServiceCharge else 0 end) * i.ServiceTax) as Amount
|
||||||
|
from Voucher v
|
||||||
|
inner join v.Kots k
|
||||||
|
inner join k.Inventories i
|
||||||
|
where v.Date >= :startDate and v.Date <= :finishDate and v.Void = false and v.VoucherType not in (:nc, :staff)
|
||||||
|
";
|
||||||
|
var qty = Session
|
||||||
|
.CreateQuery(query)
|
||||||
|
.SetParameter("startDate", startDate)
|
||||||
|
.SetParameter("finishDate", finishDate)
|
||||||
|
.SetParameter("nc", VoucherType.NoCharge)
|
||||||
|
.SetParameter("staff", VoucherType.Staff)
|
||||||
|
.UniqueResult();
|
||||||
|
return qty == null ? 0 : (decimal)qty;
|
||||||
|
}
|
||||||
|
public string GetFirstBill(DateTime date)
|
||||||
|
{
|
||||||
|
const string query = @"
|
||||||
|
select v.BillID
|
||||||
|
from Voucher v
|
||||||
|
where v.Date >= :startDate and v.Date <= :finishDate and v.Void = false and v.VoucherType not in (:nc, :staff)
|
||||||
|
order by v.Date
|
||||||
|
";
|
||||||
|
var qty = Session
|
||||||
|
.CreateQuery(query)
|
||||||
|
.SetParameter("startDate", date.AddHours(7))
|
||||||
|
.SetParameter("finishDate", date.AddDays(1).AddHours(7))
|
||||||
|
.SetParameter("nc", VoucherType.NoCharge)
|
||||||
|
.SetParameter("staff", VoucherType.Staff)
|
||||||
|
.SetMaxResults(1)
|
||||||
|
.UniqueResult();
|
||||||
|
return qty == null ? "" : (string)qty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetLastBill(DateTime date)
|
||||||
|
{
|
||||||
|
const string query = @"
|
||||||
|
select v.BillID
|
||||||
|
from Voucher v
|
||||||
|
where v.Date >= :startDate and v.Date <= :finishDate and v.Void = false and v.VoucherType not in (:nc, :staff)
|
||||||
|
order by v.Date desc
|
||||||
|
";
|
||||||
|
var qty = Session
|
||||||
|
.CreateQuery(query)
|
||||||
|
.SetParameter("startDate", date.AddHours(7))
|
||||||
|
.SetParameter("finishDate", date.AddDays(1).AddHours(7))
|
||||||
|
.SetParameter("nc", VoucherType.NoCharge)
|
||||||
|
.SetParameter("staff", VoucherType.Staff)
|
||||||
|
.SetMaxResults(1)
|
||||||
|
.UniqueResult();
|
||||||
|
return qty == null ? "" : (string)qty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public decimal GetFood(decimal vat, DateTime startDate, DateTime finishDate)
|
||||||
|
{
|
||||||
|
const string query = @"
|
||||||
|
select sum(i.Quantity * i.Price * (1 - i.Discount) * (1 + case when i.IsScTaxable then i.ServiceCharge else 0 end)) as Amount
|
||||||
|
from Voucher v
|
||||||
|
inner join v.Kots k
|
||||||
|
inner join k.Inventories i
|
||||||
|
where v.Date >= :startDate and v.Date <= :finishDate and i.Vat = :vat and v.Void = false and v.VoucherType not in (:nc, :staff)
|
||||||
|
";
|
||||||
|
var qty = Session
|
||||||
|
.CreateQuery(query)
|
||||||
|
.SetParameter("startDate", startDate)
|
||||||
|
.SetParameter("finishDate", finishDate)
|
||||||
|
.SetParameter("vat", vat)
|
||||||
|
.SetParameter("nc", VoucherType.NoCharge)
|
||||||
|
.SetParameter("staff", VoucherType.Staff)
|
||||||
|
.UniqueResult();
|
||||||
|
return qty == null ? 0 : (decimal)qty;
|
||||||
|
}
|
||||||
|
public decimal SetFood(decimal vat, decimal amount, DateTime startDate, DateTime finishDate)
|
||||||
{
|
{
|
||||||
var list = Randomize(new VoucherBI().List(x => x.Date >= startDate && x.Date <= finishDate && x.Void == false && x.VoucherType != VoucherType.NoCharge && x.VoucherType != VoucherType.Staff));
|
var list = Randomize(new VoucherBI().List(x => x.Date >= startDate && x.Date <= finishDate && x.Void == false && x.VoucherType != VoucherType.NoCharge && x.VoucherType != VoucherType.Staff));
|
||||||
var left = GetFood(vatID, startDate, finishDate) - amount;
|
var left = GetFood(vat, startDate, finishDate) - amount;
|
||||||
foreach (var item in list)
|
foreach (var item in list)
|
||||||
{
|
{
|
||||||
if (left <= 0)
|
if (left <= 0)
|
||||||
@ -61,7 +449,7 @@ where v.Date >= :startDate and v.Date <= :finishDate and p.Vat.TaxID = :vatID an
|
|||||||
{
|
{
|
||||||
if (left <= 0)
|
if (left <= 0)
|
||||||
break;
|
break;
|
||||||
if (inventory.Product.Vat.TaxID == vatID)
|
if (inventory.Vat == vat)
|
||||||
{
|
{
|
||||||
using (var bi = new InventoryBI())
|
using (var bi = new InventoryBI())
|
||||||
{
|
{
|
||||||
@ -85,7 +473,63 @@ where v.Date >= :startDate and v.Date <= :finishDate and p.Vat.TaxID = :vatID an
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return GetFood(vatID, startDate, finishDate);
|
return GetFood(vat, startDate, finishDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
public decimal SetLiq(decimal vat, decimal amount, DateTime startDate, DateTime finishDate)
|
||||||
|
{
|
||||||
|
var rand = new Random();
|
||||||
|
var list = Randomize(new VoucherBI().List(x => x.Date >= startDate && x.Date <= finishDate && x.Void == false && x.VoucherType != VoucherType.NoCharge && x.VoucherType != VoucherType.Staff));
|
||||||
|
var left = GetFood(vat, startDate, finishDate) - amount;
|
||||||
|
foreach (var item in list)
|
||||||
|
{
|
||||||
|
if (left <= 0)
|
||||||
|
break;
|
||||||
|
foreach (var kot in item.Kots)
|
||||||
|
{
|
||||||
|
if (left <= 0)
|
||||||
|
break;
|
||||||
|
foreach (var inventory in kot.Inventories)
|
||||||
|
{
|
||||||
|
if (left <= 0)
|
||||||
|
break;
|
||||||
|
if (inventory.Vat == vat)
|
||||||
|
{
|
||||||
|
using (var bi = new InventoryBI())
|
||||||
|
{
|
||||||
|
var minimum = inventory.Discount == 0 ? 10 : Convert.ToInt32(inventory.Discount * 100);
|
||||||
|
if (minimum >= 90)
|
||||||
|
continue;
|
||||||
|
var discount = Convert.ToDecimal(rand.Next(minimum, 90)) / 100;
|
||||||
|
if (discount == inventory.Discount)
|
||||||
|
continue;
|
||||||
|
var reduction = inventory.Quantity * inventory.Price *
|
||||||
|
(1 + (inventory.IsScTaxable ? inventory.ServiceCharge : 0)) *
|
||||||
|
(discount - inventory.Discount);
|
||||||
|
|
||||||
|
if (reduction > left)
|
||||||
|
{
|
||||||
|
discount = inventory.Quantity * inventory.Price *
|
||||||
|
(1 + (inventory.IsScTaxable ? inventory.ServiceCharge : 0));
|
||||||
|
discount = left / discount;
|
||||||
|
var i = bi.Get(x => x.InventoryID == inventory.InventoryID);
|
||||||
|
i.Discount = discount;
|
||||||
|
bi.Update(i);
|
||||||
|
left = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var i = bi.Get(x => x.InventoryID == inventory.InventoryID);
|
||||||
|
i.Discount = discount;
|
||||||
|
bi.Update(i);
|
||||||
|
left -= reduction;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return GetFood(vat, startDate, finishDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public decimal SetAmount(int vatID, decimal amount, DateTime startDate, DateTime finishDate)
|
public decimal SetAmount(int vatID, decimal amount, DateTime startDate, DateTime finishDate)
|
||||||
@ -181,7 +625,9 @@ order by p.BaseCode
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public decimal GetQuantity(int baseCode, DateTime startDate, DateTime finishDate)
|
|
||||||
|
#region Beer
|
||||||
|
public decimal GetQuantity(DateTime startDate, DateTime finishDate)
|
||||||
{
|
{
|
||||||
const string query = @"
|
const string query = @"
|
||||||
select sum(i.Quantity * p.Quantity) as Quantity
|
select sum(i.Quantity * p.Quantity) as Quantity
|
||||||
@ -189,20 +635,19 @@ from Voucher v
|
|||||||
inner join v.Kots k
|
inner join v.Kots k
|
||||||
inner join k.Inventories i
|
inner join k.Inventories i
|
||||||
inner join i.Product p
|
inner join i.Product p
|
||||||
where v.Date >= :startDate and v.Date <= :finishDate and v.Void = false and p.BaseCode = :baseCode
|
where v.Date >= :startDate and v.Date <= :finishDate and v.Void = false and p.Quantity != 0
|
||||||
";
|
";
|
||||||
var qty = Session
|
var qty = Session
|
||||||
.CreateQuery(query)
|
.CreateQuery(query)
|
||||||
.SetParameter("startDate", startDate)
|
.SetParameter("startDate", startDate)
|
||||||
.SetParameter("finishDate", finishDate)
|
.SetParameter("finishDate", finishDate)
|
||||||
.SetParameter("baseCode", baseCode)
|
|
||||||
.UniqueResult();
|
.UniqueResult();
|
||||||
return qty == null ? 0 : (decimal)qty;
|
return qty == null ? 0 : (decimal)qty;
|
||||||
}
|
}
|
||||||
public decimal SetQuantity(int baseCode, decimal quantity, DateTime startDate, DateTime finishDate)
|
public decimal SetQuantity(DateTime startDate, DateTime finishDate, decimal quantity)
|
||||||
{
|
{
|
||||||
var list = Randomize(new VoucherBI().List(x => x.Date >= startDate && x.Date <= finishDate && x.Void == false));
|
var list = Randomize(new VoucherBI().List(x => x.Date >= startDate && x.Date <= finishDate && x.Void == false));
|
||||||
var left = GetQuantity(baseCode, startDate, finishDate) - quantity;
|
var left = GetQuantity(startDate, finishDate) - quantity;
|
||||||
foreach (var item in list)
|
foreach (var item in list)
|
||||||
{
|
{
|
||||||
if (left <= 0)
|
if (left <= 0)
|
||||||
@ -215,7 +660,7 @@ where v.Date >= :startDate and v.Date <= :finishDate and v.Void = false and p.Ba
|
|||||||
{
|
{
|
||||||
if (left <= 0)
|
if (left <= 0)
|
||||||
break;
|
break;
|
||||||
if (inventory.Product.BaseCode == baseCode)
|
if (inventory.Product.Quantity != 0)
|
||||||
{
|
{
|
||||||
using (var bi = new InventoryBI())
|
using (var bi = new InventoryBI())
|
||||||
{
|
{
|
||||||
@ -239,105 +684,10 @@ where v.Date >= :startDate and v.Date <= :finishDate and v.Void = false and p.Ba
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return GetQuantity(baseCode, startDate, finishDate);
|
return GetQuantity(startDate, finishDate);
|
||||||
}
|
|
||||||
public void SetMove(int fromBaseCode, int toBaseCode, DateTime startDate, DateTime finishDate)
|
|
||||||
{
|
|
||||||
var list = Randomize(new VoucherBI().List(x => x.Date >= startDate && x.Date <= finishDate));
|
|
||||||
using (var bi = new InventoryBI())
|
|
||||||
{
|
|
||||||
using (var pbi = new ProductBI())
|
|
||||||
{
|
|
||||||
foreach (var item in list)
|
|
||||||
{
|
|
||||||
foreach (var kot in item.Kots)
|
|
||||||
{
|
|
||||||
foreach (var inventory in kot.Inventories)
|
|
||||||
{
|
|
||||||
if (inventory.Product.BaseCode == fromBaseCode)
|
|
||||||
{
|
|
||||||
var i = bi.Get(x => x.InventoryID == inventory.InventoryID);
|
|
||||||
i.Product = pbi.Get(x => x.ProductID == GetNewID(i.Product.ProductID, toBaseCode));
|
|
||||||
GetNewID(i.InventoryID, toBaseCode);
|
|
||||||
bi.Update(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private static int GetNewID(int code, int toBaseCode)
|
|
||||||
{
|
|
||||||
// Name Mug, Pit, H H
|
|
||||||
// Dark 301, 305, 384 // BaseCode = 1
|
|
||||||
// Wheat 300, 304, 383 // BaseCode = 2
|
|
||||||
// Premium 299, 303, 382 // BaseCode = 3
|
|
||||||
// Light 297, 302, 363 // BaseCode = 4
|
|
||||||
// Dragon 677, 679, 678 // BaseCode = 5
|
|
||||||
// Festival 409 // BaseCode = 6
|
|
||||||
// Vanilla 408, 587 // BaseCode = 7
|
|
||||||
// Strong 697, 708, 707 // BaseCode = 8
|
|
||||||
if (code == 301 || code == 300 || code == 299 || code == 297 || code == 677 || code == 408 || code == 697)
|
|
||||||
{
|
|
||||||
if (toBaseCode == 1)
|
|
||||||
return 301;
|
|
||||||
if (toBaseCode == 2)
|
|
||||||
return 300;
|
|
||||||
if (toBaseCode == 3)
|
|
||||||
return 299;
|
|
||||||
if (toBaseCode == 4)
|
|
||||||
return 297;
|
|
||||||
if (toBaseCode == 5)
|
|
||||||
return 677;
|
|
||||||
if (toBaseCode == 6)
|
|
||||||
return code;
|
|
||||||
if (toBaseCode == 7)
|
|
||||||
return 408;
|
|
||||||
if (toBaseCode == 8)
|
|
||||||
return 697;
|
|
||||||
}
|
|
||||||
if (code == 305 || code == 304 || code == 303 || code == 302 || code == 679 || code == 409 || code == 708)
|
|
||||||
{
|
|
||||||
if (toBaseCode == 1)
|
|
||||||
return 305;
|
|
||||||
if (toBaseCode == 2)
|
|
||||||
return 304;
|
|
||||||
if (toBaseCode == 3)
|
|
||||||
return 303;
|
|
||||||
if (toBaseCode == 4)
|
|
||||||
return 302;
|
|
||||||
if (toBaseCode == 5)
|
|
||||||
return 679;
|
|
||||||
if (toBaseCode == 6)
|
|
||||||
return 409;
|
|
||||||
if (toBaseCode == 7)
|
|
||||||
return code;
|
|
||||||
if (toBaseCode == 8)
|
|
||||||
return 708;
|
|
||||||
}
|
|
||||||
if (code == 384 || code == 383 || code == 382 || code == 363 || code == 678 || code == 587 || code == 707)
|
|
||||||
{
|
|
||||||
if (toBaseCode == 1)
|
|
||||||
return 384;
|
|
||||||
if (toBaseCode == 2)
|
|
||||||
return 383;
|
|
||||||
if (toBaseCode == 3)
|
|
||||||
return 382;
|
|
||||||
if (toBaseCode == 4)
|
|
||||||
return 363;
|
|
||||||
if (toBaseCode == 5)
|
|
||||||
return 678;
|
|
||||||
if (toBaseCode == 6)
|
|
||||||
return code;
|
|
||||||
if (toBaseCode == 7)
|
|
||||||
return 587;
|
|
||||||
if (toBaseCode == 8)
|
|
||||||
return 707;
|
|
||||||
}
|
|
||||||
|
|
||||||
return code;
|
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
#region Helper and Comments
|
||||||
private static IList<T> Randomize<T>(IEnumerable<T> list)
|
private static IList<T> Randomize<T>(IEnumerable<T> list)
|
||||||
{
|
{
|
||||||
var tList = list.ToArray();
|
var tList = list.ToArray();
|
||||||
@ -351,5 +701,162 @@ where v.Date >= :startDate and v.Date <= :finishDate and v.Void = false and p.Ba
|
|||||||
}
|
}
|
||||||
return tList.ToList();
|
return tList.ToList();
|
||||||
}
|
}
|
||||||
|
// public decimal GetQuantity(int baseCode, DateTime startDate, DateTime finishDate)
|
||||||
|
// {
|
||||||
|
// const string query = @"
|
||||||
|
//select sum(i.Quantity * p.Quantity) as Quantity
|
||||||
|
//from Voucher v
|
||||||
|
//inner join v.Kots k
|
||||||
|
//inner join k.Inventories i
|
||||||
|
//inner join i.Product p
|
||||||
|
//where v.Date >= :startDate and v.Date <= :finishDate and v.Void = false and p.BaseCode = :baseCode
|
||||||
|
// ";
|
||||||
|
// var qty = Session
|
||||||
|
// .CreateQuery(query)
|
||||||
|
// .SetParameter("startDate", startDate)
|
||||||
|
// .SetParameter("finishDate", finishDate)
|
||||||
|
// .SetParameter("baseCode", baseCode)
|
||||||
|
// .UniqueResult();
|
||||||
|
// return qty == null ? 0 : (decimal)qty;
|
||||||
|
// }
|
||||||
|
// public decimal SetQuantity(int baseCode, decimal quantity, DateTime startDate, DateTime finishDate)
|
||||||
|
// {
|
||||||
|
// var list = Randomize(new VoucherBI().List(x => x.Date >= startDate && x.Date <= finishDate && x.Void == false));
|
||||||
|
// var left = GetQuantity(baseCode, startDate, finishDate) - quantity;
|
||||||
|
// foreach (var item in list)
|
||||||
|
// {
|
||||||
|
// if (left <= 0)
|
||||||
|
// break;
|
||||||
|
// foreach (var kot in item.Kots)
|
||||||
|
// {
|
||||||
|
// if (left <= 0)
|
||||||
|
// break;
|
||||||
|
// foreach (var inventory in kot.Inventories)
|
||||||
|
// {
|
||||||
|
// if (left <= 0)
|
||||||
|
// break;
|
||||||
|
// if (inventory.Product.BaseCode == baseCode)
|
||||||
|
// {
|
||||||
|
// using (var bi = new InventoryBI())
|
||||||
|
// {
|
||||||
|
// var inventoryQuantity = inventory.Quantity * inventory.Product.Quantity;
|
||||||
|
|
||||||
|
// if (inventoryQuantity > left)
|
||||||
|
// {
|
||||||
|
// var newQuantity = inventory.Quantity * (inventoryQuantity - left) / inventoryQuantity;
|
||||||
|
// var i = bi.Get(x => x.InventoryID == inventory.InventoryID);
|
||||||
|
// i.Quantity = newQuantity;
|
||||||
|
// bi.Update(i);
|
||||||
|
// left = 0;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// left -= inventoryQuantity;
|
||||||
|
// bi.Delete(x => x.InventoryID == inventory.InventoryID);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return GetQuantity(baseCode, startDate, finishDate);
|
||||||
|
// }
|
||||||
|
//private static int GetNewID(int code, int toBaseCode)
|
||||||
|
//{
|
||||||
|
// // Name Mug, Pit, H H
|
||||||
|
// // Dark 301, 305, 384 // BaseCode = 1
|
||||||
|
// // Wheat 300, 304, 383 // BaseCode = 2
|
||||||
|
// // Premium 299, 303, 382 // BaseCode = 3
|
||||||
|
// // Light 297, 302, 363 // BaseCode = 4
|
||||||
|
// // Dragon 677, 679, 678 // BaseCode = 5
|
||||||
|
// // Festivals 762 764, 752 // BaseCode = 6
|
||||||
|
// // Festivals 751, 753, 763 // BaseCode = 6
|
||||||
|
// // Festivals 734, 736, 587 // BaseCode = 6
|
||||||
|
// // Festivals 408, 409, 735 // BaseCode = 6
|
||||||
|
// // Strong 697, 708, 707 // BaseCode = 7
|
||||||
|
// var list = new List<int> { 301, 300, 299, 297, 677, 762, 751, 734, 408, 697 };
|
||||||
|
// if (list.Contains(code))
|
||||||
|
// {
|
||||||
|
// if (toBaseCode == 1)
|
||||||
|
// return 301;
|
||||||
|
// if (toBaseCode == 2)
|
||||||
|
// return 300;
|
||||||
|
// if (toBaseCode == 3)
|
||||||
|
// return 299;
|
||||||
|
// if (toBaseCode == 4)
|
||||||
|
// return 297;
|
||||||
|
// if (toBaseCode == 5)
|
||||||
|
// return 677;
|
||||||
|
// if (toBaseCode == 6)
|
||||||
|
// return code;
|
||||||
|
// if (toBaseCode == 7)
|
||||||
|
// return 697;
|
||||||
|
// }
|
||||||
|
// list = new List<int> { 305, 304, 303, 302, 679, 764, 753, 736, 409, 708 };
|
||||||
|
// if (list.Contains(code))
|
||||||
|
// {
|
||||||
|
// if (toBaseCode == 1)
|
||||||
|
// return 305;
|
||||||
|
// if (toBaseCode == 2)
|
||||||
|
// return 304;
|
||||||
|
// if (toBaseCode == 3)
|
||||||
|
// return 303;
|
||||||
|
// if (toBaseCode == 4)
|
||||||
|
// return 302;
|
||||||
|
// if (toBaseCode == 5)
|
||||||
|
// return 679;
|
||||||
|
// if (toBaseCode == 6)
|
||||||
|
// return code;
|
||||||
|
// if (toBaseCode == 7)
|
||||||
|
// return 708;
|
||||||
|
// }
|
||||||
|
// list = new List<int> { 384, 383, 382, 363, 678, 752, 763, 587, 735, 707 };
|
||||||
|
// if (list.Contains(code))
|
||||||
|
// {
|
||||||
|
// if (toBaseCode == 1)
|
||||||
|
// return 384;
|
||||||
|
// if (toBaseCode == 2)
|
||||||
|
// return 383;
|
||||||
|
// if (toBaseCode == 3)
|
||||||
|
// return 382;
|
||||||
|
// if (toBaseCode == 4)
|
||||||
|
// return 363;
|
||||||
|
// if (toBaseCode == 5)
|
||||||
|
// return 678;
|
||||||
|
// if (toBaseCode == 6)
|
||||||
|
// return code;
|
||||||
|
// if (toBaseCode == 7)
|
||||||
|
// return 707;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return code;
|
||||||
|
//}
|
||||||
|
//public void SetMove(int fromBaseCode, int toBaseCode, DateTime startDate, DateTime finishDate)
|
||||||
|
//{
|
||||||
|
// var list = new VoucherBI().List(x => x.Date >= startDate && x.Date <= finishDate);
|
||||||
|
// using (var bi = new InventoryBI())
|
||||||
|
// {
|
||||||
|
// using (var pbi = new ProductBI())
|
||||||
|
// {
|
||||||
|
// foreach (var item in list)
|
||||||
|
// {
|
||||||
|
// foreach (var kot in item.Kots)
|
||||||
|
// {
|
||||||
|
// foreach (var inventory in kot.Inventories)
|
||||||
|
// {
|
||||||
|
// if (inventory.Product.BaseCode == fromBaseCode)
|
||||||
|
// {
|
||||||
|
// var i = bi.Get(x => x.InventoryID == inventory.InventoryID);
|
||||||
|
// i.Product = pbi.Get(x => x.ProductID == GetNewID(i.Product.ProductID, toBaseCode));
|
||||||
|
// GetNewID(i.InventoryID, toBaseCode);
|
||||||
|
// bi.Update(i);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -71,7 +71,7 @@ order by p.ProductGroup, concat(p.Name, ' ', p.Units)
|
|||||||
else
|
else
|
||||||
outList.Add((string)item[0], new SalesAnalysisDetail() { Product = (string)item[0], NC = (decimal)item[1] });
|
outList.Add((string)item[0], new SalesAnalysisDetail() { Product = (string)item[0], NC = (decimal)item[1] });
|
||||||
#endregion
|
#endregion
|
||||||
#region NC
|
#region Staff
|
||||||
query = @"
|
query = @"
|
||||||
select concat(p.Name, ' ', p.Units) as Product, Sum(i.Quantity) as Amount
|
select concat(p.Name, ' ', p.Units) as Product, Sum(i.Quantity) as Amount
|
||||||
from Voucher v
|
from Voucher v
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using FluentNHibernate.Automapping;
|
using System;
|
||||||
|
using FluentNHibernate.Automapping;
|
||||||
using FluentNHibernate.Cfg;
|
using FluentNHibernate.Cfg;
|
||||||
using FluentNHibernate.Cfg.Db;
|
using FluentNHibernate.Cfg.Db;
|
||||||
using NHibernate;
|
using NHibernate;
|
||||||
@ -60,14 +61,20 @@ namespace Tanshu.Accounts.Repository
|
|||||||
c.Add<FormulaConvention>();
|
c.Add<FormulaConvention>();
|
||||||
c.Add<InverseConvention>();
|
c.Add<InverseConvention>();
|
||||||
c.Add<PropertyAccessConvention>();
|
c.Add<PropertyAccessConvention>();
|
||||||
c.Add<EnumConvention>();
|
c.Add<EnumConvention>();
|
||||||
});
|
});
|
||||||
|
|
||||||
return Fluently.Configure()
|
return Fluently.Configure()
|
||||||
.Database(MsSqlConfiguration.MsSql2005.ConnectionString(p => p.FromConnectionStringWithKey("FluentCon")))
|
.Database(MsSqlConfiguration.MsSql2005.ConnectionString(p => p.FromConnectionStringWithKey("FluentCon")))
|
||||||
.Mappings(m => m.AutoMappings.Add(persistenceModel))
|
.Mappings(m => m.AutoMappings.Add(persistenceModel))
|
||||||
.BuildConfiguration()
|
.ExposeConfiguration(cfg => ApplyAdditionalConfiguration(cfg))
|
||||||
.SetInterceptor(new NHSQLInterceptor());
|
.BuildConfiguration();
|
||||||
|
//.SetInterceptor(new NHSQLInterceptor());
|
||||||
|
}
|
||||||
|
private static void ApplyAdditionalConfiguration(Configuration cfg)
|
||||||
|
{
|
||||||
|
var timeout = TimeSpan.FromMinutes(10).TotalSeconds;
|
||||||
|
cfg.SetProperty("command_timeout", timeout.ToString());
|
||||||
}
|
}
|
||||||
private void Init()
|
private void Init()
|
||||||
{ }
|
{ }
|
||||||
|
|||||||
Reference in New Issue
Block a user