narsil/Tanshu.Accounts.PointOfSale/Management/AmountForm.cs
Tanshu a984b1f527 Switched to management branch to develop management module.
Initial commit dunno what has changed.
2012-12-01 15:18:02 +05:30

50 lines
1.6 KiB
C#

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);
}
}
}