Switched to management branch to develop management module.

Initial commit dunno what has changed.
This commit is contained in:
Tanshu
2012-12-01 15:18:02 +05:30
parent 2d1030abf6
commit a984b1f527
19 changed files with 1868 additions and 328 deletions

View File

@ -0,0 +1,49 @@
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);
}
}
}

View File

@ -0,0 +1,116 @@
namespace Tanshu.Accounts.Management
{
partial class AmountForm
{
/// <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;
}
}

View File

@ -0,0 +1,120 @@
<?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>

View File

@ -0,0 +1,46 @@
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);
}
}
}

View File

@ -0,0 +1,116 @@
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;
}
}

View File

@ -0,0 +1,120 @@
<?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>

View File

@ -0,0 +1,162 @@
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);
}
}
}
}

View File

@ -0,0 +1,119 @@
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;
}
}

View File

@ -0,0 +1,120 @@
<?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>

View File

@ -0,0 +1,129 @@
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);
}
}
}
}

View File

@ -0,0 +1,119 @@
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;
}
}

View File

@ -0,0 +1,120 @@
<?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>

View File

@ -9,63 +9,106 @@ namespace Tanshu.Accounts.Management
{
public partial class QuantityForm : Form
{
private IList<TextBox> textBoxes;
public QuantityForm()
{
InitializeComponent();
}
private void ShowStatement()
{
}
private void Sale_Analysis_Form_Load(object sender, EventArgs e)
{
dtpStart.Value = DateTime.Today;
dtpFinish.Value = DateTime.Today;
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)
{
int baseCode = 0;
if (rbLight.Checked)
foreach (var textBox in textBoxes)
{
baseCode = 1;
}
else if (rbPremium.Checked)
{
baseCode = 2;
}
else if (rbWheat.Checked)
{
baseCode = 3;
}
else if (rbDark.Checked)
{
baseCode = 4;
}
else if (rbFestival.Checked)
{
baseCode = 5;
}
dtpStart.Value = dtpStart.Value.Date.AddHours(7);
dtpFinish.Value = dtpFinish.Value.Date.AddDays(1).AddHours(7);
var quantity = GetQuantity(baseCode);
var newQuantity = Convert.ToDecimal(txtQuantity.Text);
if (MessageBox.Show(quantity.ToString(), "Quantity of Beer", MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2) == DialogResult.Yes && quantity > newQuantity)
{
MessageBox.Show(SetQuantity(baseCode, newQuantity).ToString());
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 GetQuantity(int baseCode)
private decimal TryConvert(string amount)
{
using (var bi = new ManagementBI())
return bi.GetQuantity(baseCode, dtpStart.Value, dtpFinish.Value);
decimal result = 0;
decimal.TryParse(amount, out result);
return result;
}
private decimal SetQuantity(int baseCode, decimal quantity)
private decimal GetQuantity(int baseCode, DateTime startDate, DateTime finishDate)
{
using (var bi = new ManagementBI())
return bi.SetQuantity(baseCode, quantity, dtpStart.Value, dtpFinish.Value);
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)
@ -102,7 +145,7 @@ namespace Tanshu.Accounts.Management
startDate = startDate.AddHours(7);
if (!int.TryParse(data[1], out baseCode))
continue;
if (baseCode <=0)
if (baseCode <= 0)
continue;
if (!decimal.TryParse(data[2], out quantity))
continue;

View File

@ -28,182 +28,65 @@
/// </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.dtpDate = new System.Windows.Forms.DateTimePicker();
this.flpProducts = new System.Windows.Forms.FlowLayoutPanel();
this.rbLight = new System.Windows.Forms.RadioButton();
this.rbPremium = new System.Windows.Forms.RadioButton();
this.rbWheat = new System.Windows.Forms.RadioButton();
this.rbDark = new System.Windows.Forms.RadioButton();
this.rbFestival = new System.Windows.Forms.RadioButton();
this.txtQuantity = new System.Windows.Forms.TextBox();
this.btnGo = new System.Windows.Forms.Button();
this.btnGetClipboard = new System.Windows.Forms.Button();
this.flpProducts.SuspendLayout();
this.SuspendLayout();
//
// dtpFinish
// dtpDate
//
this.dtpFinish.CustomFormat = "dd-MMM-yyyy";
this.dtpFinish.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.dtpFinish.Location = new System.Drawing.Point(168, 12);
this.dtpFinish.Name = "dtpFinish";
this.dtpFinish.Size = new System.Drawing.Size(90, 20);
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(12, 12);
this.dtpStart.Name = "dtpStart";
this.dtpStart.Size = new System.Drawing.Size(90, 20);
this.dtpStart.TabIndex = 20;
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(108, 16);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(54, 13);
this.label10.TabIndex = 22;
this.label10.Text = "<- Date ->";
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.Controls.Add(this.rbLight);
this.flpProducts.Controls.Add(this.rbPremium);
this.flpProducts.Controls.Add(this.rbWheat);
this.flpProducts.Controls.Add(this.rbDark);
this.flpProducts.Controls.Add(this.rbFestival);
this.flpProducts.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
this.flpProducts.Location = new System.Drawing.Point(12, 38);
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(335, 137);
this.flpProducts.Size = new System.Drawing.Size(447, 390);
this.flpProducts.TabIndex = 23;
//
// rbLight
//
this.rbLight.AutoSize = true;
this.rbLight.Location = new System.Drawing.Point(3, 3);
this.rbLight.Name = "rbLight";
this.rbLight.Size = new System.Drawing.Size(48, 17);
this.rbLight.TabIndex = 0;
this.rbLight.TabStop = true;
this.rbLight.Text = "Light";
this.rbLight.UseVisualStyleBackColor = true;
//
// rbPremium
//
this.rbPremium.AutoSize = true;
this.rbPremium.Location = new System.Drawing.Point(3, 26);
this.rbPremium.Name = "rbPremium";
this.rbPremium.Size = new System.Drawing.Size(65, 17);
this.rbPremium.TabIndex = 1;
this.rbPremium.TabStop = true;
this.rbPremium.Text = "Premium";
this.rbPremium.UseVisualStyleBackColor = true;
//
// rbWheat
//
this.rbWheat.AutoSize = true;
this.rbWheat.Location = new System.Drawing.Point(3, 49);
this.rbWheat.Name = "rbWheat";
this.rbWheat.Size = new System.Drawing.Size(57, 17);
this.rbWheat.TabIndex = 2;
this.rbWheat.TabStop = true;
this.rbWheat.Text = "Wheat";
this.rbWheat.UseVisualStyleBackColor = true;
//
// rbDark
//
this.rbDark.AutoSize = true;
this.rbDark.Location = new System.Drawing.Point(3, 72);
this.rbDark.Name = "rbDark";
this.rbDark.Size = new System.Drawing.Size(48, 17);
this.rbDark.TabIndex = 3;
this.rbDark.TabStop = true;
this.rbDark.Text = "Dark";
this.rbDark.UseVisualStyleBackColor = true;
//
// rbFestival
//
this.rbFestival.AutoSize = true;
this.rbFestival.Location = new System.Drawing.Point(3, 95);
this.rbFestival.Name = "rbFestival";
this.rbFestival.Size = new System.Drawing.Size(61, 17);
this.rbFestival.TabIndex = 4;
this.rbFestival.TabStop = true;
this.rbFestival.Text = "Festival";
this.rbFestival.UseVisualStyleBackColor = true;
//
// txtQuantity
//
this.txtQuantity.Location = new System.Drawing.Point(12, 181);
this.txtQuantity.Name = "txtQuantity";
this.txtQuantity.Size = new System.Drawing.Size(335, 20);
this.txtQuantity.TabIndex = 5;
//
// btnGo
//
this.btnGo.Location = new System.Drawing.Point(12, 207);
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(150, 23);
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);
//
// btnGetClipboard
//
this.btnGetClipboard.Location = new System.Drawing.Point(168, 207);
this.btnGetClipboard.Name = "btnGetClipboard";
this.btnGetClipboard.Size = new System.Drawing.Size(179, 23);
this.btnGetClipboard.TabIndex = 25;
this.btnGetClipboard.Text = "Go Clipboard";
this.btnGetClipboard.UseVisualStyleBackColor = true;
this.btnGetClipboard.Click += new System.EventHandler(this.btnGetClipboard_Click);
//
// QuantityForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(359, 242);
this.Controls.Add(this.btnGetClipboard);
this.ClientSize = new System.Drawing.Size(479, 488);
this.Controls.Add(this.btnGo);
this.Controls.Add(this.flpProducts);
this.Controls.Add(this.dtpFinish);
this.Controls.Add(this.dtpStart);
this.Controls.Add(this.label10);
this.Controls.Add(this.txtQuantity);
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.flpProducts.ResumeLayout(false);
this.flpProducts.PerformLayout();
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.DateTimePicker dtpDate;
private System.Windows.Forms.FlowLayoutPanel flpProducts;
private System.Windows.Forms.RadioButton rbLight;
private System.Windows.Forms.RadioButton rbPremium;
private System.Windows.Forms.RadioButton rbWheat;
private System.Windows.Forms.RadioButton rbDark;
private System.Windows.Forms.RadioButton rbFestival;
private System.Windows.Forms.TextBox txtQuantity;
private System.Windows.Forms.Button btnGo;
private System.Windows.Forms.Button btnGetClipboard;
}
}