narsil/Tanshu.Accounts.PointOfSale/Sales/RecieveAdvanceForm.cs
unknown 0172fc4e01 Added Service Tax and CIN Information to the bill printout
Added Nc Option in settlement
Merged Vouchers and SaleVoucher table. Need to update the Sql Schema
2014-08-08 17:35:38 +05:30

96 lines
3.0 KiB
C#

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
{
bool _loading = true;
public RecieveAdvanceForm()
{
InitializeComponent();
}
private void btnAdd_Click(object sender, EventArgs e)
{
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)
return;
if (String.IsNullOrEmpty(adv.Narration))
{
MessageBox.Show("Please fill in party name, product and date of delivery");
}
else
{
using (var connection = new SqlDAO.SqlConnectionDAO())
{
using (var dao = new SqlDAO.AdvanceDAO(connection))
{
dao.Insert(adv);
}
}
GridBind();
PrintAdvances();
}
}
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;
_loading = false;
GridBind();
}
private void GridBind()
{
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, true);
}
}
}
private void dtpFrom_ValueChanged(object sender, EventArgs e)
{
if (!_loading)
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();
}
}
}
}