0172fc4e01
Added Nc Option in settlement Merged Vouchers and SaleVoucher table. Need to update the Sql Schema
88 lines
2.8 KiB
C#
88 lines
2.8 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()
|
|
{
|
|
var fromDate = Convert.ToDateTime(string.Format("{0:dd-MMM-yyyy} 00:00:00", dtpFrom.Value));
|
|
var toDate = Convert.ToDateTime(string.Format("{0:dd-MMM-yyyy} 23:59:59", dtpTo.Value));
|
|
using (var connection = new SqlDAO.SqlConnectionDAO())
|
|
{
|
|
using (var dao = new SqlDAO.AdvanceDAO(connection))
|
|
{
|
|
dgExpenses.DataSource = dao.GetAdvances(fromDate, toDate, 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
|
|
{
|
|
using (var connection = new SqlDAO.SqlConnectionDAO())
|
|
{
|
|
using (var dao = new SqlDAO.AdvanceDAO(connection))
|
|
{
|
|
dao.Adjust((Guid)txtNarration.Tag, CurrentUser.user.UserID);
|
|
}
|
|
}
|
|
FillDataGrid();
|
|
}
|
|
}
|
|
public Guid? AdvanceID
|
|
{
|
|
get { return _advanceID; }
|
|
}
|
|
}
|
|
}
|