narsil/Tanshu.Accounts.PointOfSale/Sales/AdjustAdvanceForm.cs

74 lines
2.2 KiB
C#
Raw Normal View History

2010-03-02 17:56:21 +00:00
using System;
using System.Windows.Forms;
using Tanshu.Accounts.BI;
using Tanshu.Accounts.Contracts;
namespace Tanshu.Accounts.PointOfSale
{
public partial class AdjustAdvanceForm : Form
{
2011-12-05 09:23:02 +00:00
bool _loading = true;
private readonly bool _fromSaleForm;
private Guid? _advanceID;
public AdjustAdvanceForm(bool fromSaleForm)
2010-03-02 17:56:21 +00:00
{
2011-12-05 09:23:02 +00:00
_fromSaleForm = fromSaleForm;
2010-03-02 17:56:21 +00:00
InitializeComponent();
}
private void AdjustAdvancesForm_Load(object sender, EventArgs e)
{
2011-12-05 09:23:02 +00:00
btnAdjust.Enabled = _fromSaleForm;
2010-03-02 17:56:21 +00:00
dtpFrom.Format = DateTimePickerFormat.Custom;
dtpFrom.CustomFormat = "dd-MMM-yyyy";
dtpFrom.Value = DateTime.Now;
dtpTo.Format = DateTimePickerFormat.Custom;
dtpTo.CustomFormat = "dd-MMM-yyyy";
dtpTo.Value = DateTime.Now;
2011-12-05 09:23:02 +00:00
_loading = false;
2010-03-02 17:56:21 +00:00
FillDataGrid();
}
private void FillDataGrid()
{
dgExpenses.DataSource = new AdvanceBI().GetAdvances(dtpFrom.Value, dtpTo.Value, false);
}
private void dtpFrom_ValueChanged(object sender, EventArgs e)
{
2011-12-05 09:23:02 +00:00
if (!_loading)
2010-03-02 17:56:21 +00:00
FillDataGrid();
}
private void btnSelect_Click(object sender, EventArgs e)
{
try
{
2011-12-05 09:23:02 +00:00
var item = dgExpenses.SelectedRows[0].DataBoundItem as AdvanceDisplayBO;
if (item == null)
return;
2010-03-02 17:56:21 +00:00
txtCashier.Text = item.Cashier;
txtNarration.Tag = item.AdvanceID;
txtNarration.Text = item.Narration;
txtAmount.Text = item.Amount.ToString();
}
catch { }
}
private void btnAdjust_Click(object sender, EventArgs e)
{
2011-12-05 09:23:02 +00:00
if (_fromSaleForm)
{
_advanceID = (Guid)txtNarration.Tag;
this.Close();
}
else
{
new AdvanceBI().Adjust((Guid)txtNarration.Tag, CurrentUser.user.UserID);
FillDataGrid();
}
}
public Guid? AdvanceID
{
get { return _advanceID; }
2010-03-02 17:56:21 +00:00
}
}
}