Feature: Added a Tax Management form and a beer consumption report.
Chore: Fixed some Form_Load function names as they were copied from old forms and were not neat. Feature: Management BI Improved and should be pretty much solid by now.
This commit is contained in:
81
Tanshu.Accounts.PointOfSale/Masters/TaxEditForm.cs
Normal file
81
Tanshu.Accounts.PointOfSale/Masters/TaxEditForm.cs
Normal file
@ -0,0 +1,81 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using Tanshu.Accounts.Repository;
|
||||
using Tanshu.Accounts.Entities;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Tanshu.Accounts.PointOfSale
|
||||
{
|
||||
public partial class TaxEditForm : Form
|
||||
{
|
||||
private Guid? _taxID;
|
||||
public TaxEditForm(Guid taxID)
|
||||
: this()
|
||||
{
|
||||
_taxID = taxID;
|
||||
}
|
||||
|
||||
public TaxEditForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void TaxEditForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
Tax tax;
|
||||
if (_taxID.HasValue)
|
||||
{
|
||||
using (var bi = new TaxBI())
|
||||
{
|
||||
tax = bi.Get(x => x.TaxID == _taxID.Value);
|
||||
txtName.Text = tax.Name;
|
||||
txtRate.Text = (tax.Rate * 100).ToString();
|
||||
}
|
||||
}
|
||||
txtName.Focus();
|
||||
}
|
||||
|
||||
private void btnCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void btnOk_Click(object sender, EventArgs e)
|
||||
{
|
||||
Tax tax;
|
||||
using (var bi = new TaxBI())
|
||||
{
|
||||
if (_taxID.HasValue)
|
||||
tax = bi.Get(x => x.TaxID == _taxID.Value);
|
||||
else
|
||||
tax = new Tax();
|
||||
|
||||
if (string.IsNullOrEmpty(txtName.Text.Trim()))
|
||||
return;
|
||||
tax.Name = txtName.Text.Trim();
|
||||
|
||||
if (string.IsNullOrEmpty(txtRate.Text.Trim()))
|
||||
txtRate.Text = "0";
|
||||
decimal rate;
|
||||
if (!decimal.TryParse(txtRate.Text, out rate) || (rate < 0 || rate > 100))
|
||||
{
|
||||
MessageBox.Show("Tax Rate is not valid, it must be between 0 to 100 percent.");
|
||||
txtRate.Focus();
|
||||
return;
|
||||
}
|
||||
else
|
||||
tax.Rate = rate / 100;
|
||||
|
||||
if (_taxID.HasValue)
|
||||
bi.Update(tax);
|
||||
else
|
||||
bi.Insert(tax);
|
||||
bi.SaveChanges();
|
||||
}
|
||||
MessageBox.Show("Update / Save Successful");
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user