128 lines
5.1 KiB
C#
128 lines
5.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using Payroll.BO;
|
|
using Ease.CoreV35.Model;
|
|
using Payroll.Report;
|
|
|
|
|
|
namespace Payroll.UI
|
|
{
|
|
public partial class fJVReport : BaseFormTest
|
|
{
|
|
ObjectsTemplate<JVType> _JVTypes = new ObjectsTemplate<JVType>();
|
|
private EnumReportType _reportType = EnumReportType.None;
|
|
private EnumReportType _Type = EnumReportType.None;
|
|
|
|
public fJVReport()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public EnumReportType Type
|
|
{
|
|
set
|
|
{
|
|
_Type = value;
|
|
}
|
|
}
|
|
|
|
private void btnPreview_Click(object sender, EventArgs e)
|
|
{
|
|
fReportViewer oForm = new fReportViewer();
|
|
DataTable oDFTable = null;
|
|
rptJV ob = new rptJV();
|
|
|
|
switch(_reportType)
|
|
{
|
|
case EnumReportType.JVReport:
|
|
oDFTable = ob.JVReport(_JVTypes[cboJVType.SelectedIndex].ID,GlobalExtensions.LastDateOfMonth(dtpJVDate.Value));
|
|
oForm.ShowDlgForJVReport(null, oDFTable);
|
|
break;
|
|
case EnumReportType.EmployeeWiseJVReport:
|
|
oDFTable = ob.JVSalaryDetail(_JVTypes[cboJVType.SelectedIndex].ID, dtpJVDate.Value);
|
|
oForm.ShowDlgForJVsalaryDetail(null, oDFTable);
|
|
break;
|
|
case EnumReportType.CCWiseJVReport:
|
|
oDFTable = ob.JVLoactionWReport(_JVTypes[cboJVType.SelectedIndex].ID, dtpJVDate.Value);
|
|
oForm.ShowDlgForJVLocationWReport(null, oDFTable);
|
|
break;
|
|
case EnumReportType.JVSummaryReport:
|
|
oDFTable = ob.JVSummaryReport(_JVTypes[cboJVType.SelectedIndex].ID, dtpJVDate.Value);
|
|
oForm.ShowDlgForJVSummaryReport(null, oDFTable);
|
|
break;
|
|
}
|
|
}
|
|
|
|
private void btnPrint_Click(object sender, EventArgs e)
|
|
{
|
|
DataTable oDFTable = null;
|
|
DataTable dt = new DataTable();
|
|
rptJV ob = new rptJV();
|
|
oDFTable = ob.JVReport(_JVTypes[cboJVType.SelectedIndex].ID, GlobalExtensions.LastDateOfMonth(dtpJVDate.Value));
|
|
dt.Columns.Add("GroupCode");
|
|
dt.Columns.Add("GL Code");
|
|
dt.Columns.Add("GL Name");
|
|
dt.Columns.Add("Cheque Number");
|
|
dt.Columns.Add("Amount");
|
|
dt.Columns.Add("Side");
|
|
dt.Columns.Add("Date");
|
|
SaveFileDialog savefile = new SaveFileDialog();
|
|
savefile.Filter = "Excel files (*.csv)|*.csv";
|
|
// savefile.Filter = "Excel files (*.csv)|*.csv";
|
|
savefile.FileName = "JV Report " + dtpJVDate.Value.ToString("MMM yyyy");
|
|
double nDebit = 0;
|
|
double nCredit = 0;
|
|
if (savefile.ShowDialog() == DialogResult.OK)
|
|
{
|
|
int nCount = 1;
|
|
foreach (DataRow dr in oDFTable.Rows)
|
|
{
|
|
nDebit = Convert.ToDouble(dr[2].ToString());
|
|
if(nDebit >0)
|
|
dt.Rows.Add(dr[oDFTable.Columns.Count -1].ToString(), dr[0].ToString(), dr[1].ToString(),
|
|
dr[6].ToString(), dr[2].ToString(),"D", DateTime.Today.ToString("dd-MM-yyyy"));
|
|
nCredit = Convert.ToDouble(dr[3].ToString());
|
|
if (nCredit > 0)
|
|
dt.Rows.Add(dr[oDFTable.Columns.Count - 1].ToString(), dr[0].ToString(),
|
|
dr[1].ToString(), dr[6].ToString(), dr[3].ToString(),"C", DateTime.Today.ToString("dd-MM-yyyy"));
|
|
// dt.Rows.Add(dr[oDFTable.Columns.Count -1].ToString(), dr[0].ToString(), dr[1].ToString(), dr[6].ToString(), dr[2].ToString(), dr[3].ToString());
|
|
}
|
|
// dt.Rows.Add("", "", "", "Total", nDebit.ToString(), nCredit.ToString());
|
|
// GlobalFunctions.ExportToExcel(dt, savefile.FileName, "Sheet1");
|
|
// ToCSV walks dt.Rows, so the sorted view has to be materialized into a table.
|
|
dt.DefaultView.Sort = "[GL Name] ASC";
|
|
dt = dt.DefaultView.ToTable();
|
|
GlobalFunctions.ToCSV(dt, savefile.FileName);
|
|
MessageBox.Show("Excel created at " + savefile.FileName,"Exported",MessageBoxButtons.OK,MessageBoxIcon.Information);
|
|
}
|
|
}
|
|
private void RefreshCbo()
|
|
{
|
|
cboJVType.Items.Clear();
|
|
|
|
_JVTypes = JVType.Get();
|
|
foreach (JVType oJVType in _JVTypes)
|
|
{
|
|
cboJVType.Items.Add(oJVType);
|
|
}
|
|
cboJVType.DisplayMember = "Name";
|
|
if (_JVTypes.Count > 0)
|
|
cboJVType.SelectedIndex = 0;
|
|
|
|
}
|
|
|
|
private void fJVReport_Load(object sender, EventArgs e)
|
|
{
|
|
dtpJVDate.Value = Payroll.BO.SystemInformation.CurrentSysInfo.NextPayProcessDate;
|
|
this._reportType = _Type;
|
|
RefreshCbo();
|
|
}
|
|
}
|
|
}
|