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

83 lines
2.4 KiB
C#
Raw Normal View History

2010-03-02 17:56:21 +00:00
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Tanshu.Accounts.Helpers;
using Tanshu.Accounts.Print;
using Tanshu.Accounts.Contracts;
using Tanshu.Accounts.BI;
namespace Tanshu.Accounts.PointOfSale
{
public partial class RecieveAdvanceForm : Form
{
2011-12-05 09:23:02 +00:00
bool _loading = true;
2010-03-02 17:56:21 +00:00
public RecieveAdvanceForm()
{
InitializeComponent();
}
private void btnAdd_Click(object sender, EventArgs e)
{
2011-12-05 09:23:02 +00:00
var adv = new AdvanceBO
{
Narration = txtNarration.Text.Trim(),
Amount = Convert.ToDecimal(txtAmount.Text.Trim()),
CashierIn = new Guid(txtCashier.Tag.ToString()),
DateIn = DateTime.Now
};
if (adv.Amount == 0)
2010-03-02 17:56:21 +00:00
return;
2011-12-05 09:23:02 +00:00
if (String.IsNullOrEmpty(adv.Narration))
{
MessageBox.Show("Please fill in party name, product and date of delivery");
}
else
{
new AdvanceBI().Insert(adv);
GridBind();
PrintAdvances();
}
2010-03-02 17:56:21 +00:00
}
private void RecieveAdvanceForm_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;
txtCashier.Text = CurrentUser.user.Name;
txtCashier.Tag = CurrentUser.user.UserID;
2011-12-05 09:23:02 +00:00
_loading = false;
2010-03-02 17:56:21 +00:00
GridBind();
}
private void GridBind()
{
2011-12-05 09:23:02 +00:00
var advance = new AdvanceBI().GetAdvances(dtpFrom.Value, dtpTo.Value, true);
2010-03-02 17:56:21 +00:00
dgExpenses.DataSource = advance;
}
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
GridBind();
}
private void PrintAdvances()
{
Thermal.PrintAdvance(txtAmount.Text.Trim(), txtNarration.Text.Trim());
}
private void txtAmount_Leave(object sender, EventArgs e)
{
if (txtAmount.Text.Trim() == "")
{
txtAmount.Focus();
}
}
}
}