narsil/Tanshu.Accounts.PointOfSale/Masters/TaxListForm.cs

65 lines
1.8 KiB
C#

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.Entities;
using Tanshu.Accounts.Repository;
namespace Tanshu.Accounts.PointOfSale
{
public partial class TaxListForm : Form
{
private IList<Tax> _list;
public TaxListForm()
{
InitializeComponent();
}
private void btnAdd_Click(object sender, EventArgs e)
{
using (var frm = new TaxEditForm())
frm.ShowDialog();
using (var bi = new TaxBI())
_list = bi.List();
bsList.DataSource = _list;
}
private void TaxListForm_Load(object sender, EventArgs e)
{
using (var bi = new TaxBI())
_list = bi.List();
bsList.DataSource = _list;
}
private void btnEdit_Click(object sender, EventArgs e)
{
var id = ((Tax)bsList.Current).TaxID;
using (var frm = new TaxEditForm(id))
frm.ShowDialog();
using (var bi = new TaxBI())
_list = bi.List();
bsList.DataSource = _list;
}
private void btnExit_Click(object sender, EventArgs e)
{
this.Close();
}
private void dgvTaxes_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
var data = dgvTaxes.Rows[e.RowIndex].DataBoundItem as Tax;
if (data == null)
return;
if (e.ColumnIndex != 1)
return;
var rate = (decimal)e.Value;
e.Value = string.Format("{0:P}", rate);
}
}
}