narsil/Tanshu.Accounts.PointOfSale/CurrencyCounter.cs

59 lines
2.4 KiB
C#
Raw Normal View History

2011-01-06 07:17:00 +00:00
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Tanshu.Accounts.Contracts;
2011-01-06 07:17:00 +00:00
namespace Tanshu.Accounts.PointOfSale
{
public partial class CurrencyCounter : Form
{
public CurrencyCounter()
{
InitializeComponent();
}
private void btnPrint_Click(object sender, EventArgs e)
{
Dictionary<int, int> amounts = new Dictionary<int, int>();
if (txt1000.Text != "") amounts.Add(1000, Convert.ToInt32(txt1000.Text));
if (txt500.Text != "") amounts.Add(500, Convert.ToInt32(txt500.Text));
if (txt100.Text != "") amounts.Add(100, Convert.ToInt32(txt100.Text));
if (txt50.Text != "") amounts.Add(50, Convert.ToInt32(txt50.Text));
if (txt20.Text != "") amounts.Add(20, Convert.ToInt32(txt20.Text));
if (txt10.Text != "") amounts.Add(10, Convert.ToInt32(txt10.Text));
if (txt5.Text != "") amounts.Add(5, Convert.ToInt32(txt5.Text));
if (txt2.Text != "") amounts.Add(2, Convert.ToInt32(txt2.Text));
if (txt1.Text != "") amounts.Add(1, Convert.ToInt32(txt1.Text));
Accounts.Print.Thermal.PrintCash(amounts, Session.User.Name);
2011-01-06 07:17:00 +00:00
}
private void txt1000_TextChanged(object sender, EventArgs e)
{
try
{
int Amount = 0;
Amount += 1000 * (txt1000.Text == "" ? 0 : Convert.ToInt16(txt1000.Text));
Amount += 500 * (txt500.Text == "" ? 0 : Convert.ToInt16(txt500.Text));
Amount += 100 * (txt100.Text == "" ? 0 : Convert.ToInt16(txt100.Text));
Amount += 50 * (txt50.Text == "" ? 0 : Convert.ToInt16(txt50.Text));
Amount += 20 * (txt20.Text == "" ? 0 : Convert.ToInt16(txt20.Text));
Amount += 10 * (txt10.Text == "" ? 0 : Convert.ToInt16(txt10.Text));
Amount += 5 * (txt5.Text == "" ? 0 : Convert.ToInt16(txt5.Text));
Amount += 2 * (txt2.Text == "" ? 0 : Convert.ToInt16(txt2.Text));
Amount += 1 * (txt1.Text == "" ? 0 : Convert.ToInt16(txt1.Text));
txtTotal.Text = Amount.ToString();
}
catch (Exception ex)
{
MessageBox.Show("Error Number " + ex.Source + "\n\r" + ex.Message);
2011-01-06 07:17:00 +00:00
}
}
}
}