narsil/Tanshu.Accounts.PointOfSale/Advances/frmAdjustAdvance.cs

59 lines
1.8 KiB
C#

using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Tanshu.Accounts.Helpers;
using System.Data.SqlClient;
using System.Configuration;
using Tanshu.Accounts.Repository;
using Tanshu.Accounts.Contracts;
using Tanshu.Accounts.Entities;
namespace Tanshu.Accounts.PointOfSale
{
public partial class frmAdjustAdvance : Form
{
bool loading = true;
public frmAdjustAdvance()
{
InitializeComponent();
}
private void frmAdjustAdvance_Load(object sender, EventArgs e)
{
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()
{
using (var bi = new AdvanceBI(false))
dgExpenses.DataSource = bi.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)
{
var item = (Advance)dgExpenses.SelectedRows[0].DataBoundItem;
txtCashier.Text = item.CashierIn.Name;
txtNarration.Tag = item.AdvanceID;
txtNarration.Text = item.Narration;
txtAmount.Text = item.Amount.ToString();
}
private void btnAdjust_Click(object sender, EventArgs e)
{
using (var bi = new AdvanceBI())
bi.Adjust((int)txtNarration.Tag, Session.User.UserID);
FillDataGrid();
}
}
}