74 lines
2.2 KiB
C#
74 lines
2.2 KiB
C#
using System;
|
|
using System.Windows.Forms;
|
|
using Tanshu.Accounts.BI;
|
|
using Tanshu.Accounts.Contracts;
|
|
|
|
namespace Tanshu.Accounts.PointOfSale
|
|
{
|
|
public partial class AdjustAdvanceForm : Form
|
|
{
|
|
bool _loading = true;
|
|
private readonly bool _fromSaleForm;
|
|
private Guid? _advanceID;
|
|
public AdjustAdvanceForm(bool fromSaleForm)
|
|
{
|
|
_fromSaleForm = fromSaleForm;
|
|
InitializeComponent();
|
|
}
|
|
private void AdjustAdvancesForm_Load(object sender, EventArgs e)
|
|
{
|
|
btnAdjust.Enabled = _fromSaleForm;
|
|
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;
|
|
_loading = false;
|
|
FillDataGrid();
|
|
}
|
|
private void FillDataGrid()
|
|
{
|
|
dgExpenses.DataSource = new AdvanceBI().GetAdvances(dtpFrom.Value, dtpTo.Value, false);
|
|
}
|
|
private void dtpFrom_ValueChanged(object sender, EventArgs e)
|
|
{
|
|
if (!_loading)
|
|
FillDataGrid();
|
|
}
|
|
|
|
private void btnSelect_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
var item = dgExpenses.SelectedRows[0].DataBoundItem as AdvanceDisplayBO;
|
|
if (item == null)
|
|
return;
|
|
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)
|
|
{
|
|
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; }
|
|
}
|
|
}
|
|
}
|