SaveFileDialog
Code
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 System.Collections;
namespace BusinessProgramming
{
public partial class Report : Form
{
#region "Local Variables"
private List<int> clientIds;
#endregion
#region "Constructor"
public Report()
{
InitializeComponent();
}
#endregion
#region "Report_Load"
private void Report_Load(object sender, EventArgs e)
{
clientIds = new List<int>();
cbClients.Items.Clear();
DataTable dt = LogicBroker.GetClients();
foreach (DataRow dr in dt.Rows)
{
clientIds.Add(Convert.ToInt32(dr["client_id"]));
cbClients.Items.Add(dr["name"].ToString());
}
if (cbClients.Items.Count != 0)
{
cbClients.SelectedIndex = 0;
}
if (cbReports.Items.Count != 0)
{
cbReports.SelectedIndex = 0;
}
if (cbMonths.Items.Count != 0)
{
cbMonths.SelectedIndex = 0;
}
if (cbYears.Items.Count != 0)
{
cbYears.SelectedIndex = 0;
}
}
#endregion
#region "btnGenerate_Click"
private void btnGenerate_Click(object sender, EventArgs e)
{
DateTime date = new DateTime(cbYears.SelectedIndex + 2006, cbMonths.SelectedIndex + 1, 1);
int clientID = clientIds[cbClients.SelectedIndex];
Hashtable ht = new Hashtable();
ht.Add("Month", date.ToString("MMMM"));
ht.Add("Year", date.ToString("yyyy"));
ht.Add("Client", LogicBroker.GetClientName(clientID));
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "xls files (*.xls)|*.xls|All files (*.*)|*.*";
sfd.FilterIndex = 1;
sfd.RestoreDirectory = true;
if (sfd.ShowDialog() == DialogResult.OK)
{
string filePath = sfd.FileName;
switch (cbReports.SelectedIndex)
{
case 0:
ht.Add("110", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 110));
ht.Add("120", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 120));
ht.Add("140", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 140));
ht.Add("145", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 145));
ht.Add("150", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 150));
ht.Add("155", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 155));
ht.Add("160", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 160));
ht.Add("161", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 161));
ht.Add("165", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 165));
ht.Add("166", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 166));
ht.Add("220", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 220));
ht.Add("230", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 230));
ht.Add("240", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 240));
ht.Add("300", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 300));
ht.Add("301", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 301));
ht.Add("400", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 400));
ht.Add("620", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 620));
ht.Add("660", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 660));
ht.Add("665", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 665));
ht.Add("682", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 682));
ht.Add("688", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 688));
ht.Add("689", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 689));
ht.Add("690", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 690));
ht.Add("692", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 692));
ht.Add("695", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 695));
ExcelExporter.ExportUnAdjustedTrialBalance(ht, filePath);
break;
case 1:
ht.Add("110", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 110));
ht.Add("120", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 120));
ht.Add("140", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 140));
ht.Add("145", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 145));
ht.Add("150", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 150));
ht.Add("155", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 155));
ht.Add("160", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 160));
ht.Add("161", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 161));
ht.Add("165", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 165));
ht.Add("166", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 166));
ht.Add("220", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 220));
ht.Add("230", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 230));
ht.Add("240", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 240));
ht.Add("300", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 300));
ht.Add("301", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 301));
ht.Add("400", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 400));
ht.Add("620", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 620));
ht.Add("660", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 660));
ht.Add("665", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 665));
ht.Add("682", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 682));
ht.Add("688", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 688));
ht.Add("689", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 689));
ht.Add("690", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 690));
ht.Add("692", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 692));
ht.Add("695", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 695));
ExcelExporter.ExportAdjustedTrialBalance(ht, filePath);
break;
case 2:
ht.Add("400", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 400));
ht.Add("620", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 620));
ht.Add("660", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 660));
ht.Add("665", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 665));
ht.Add("682", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 682));
ht.Add("688", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 688));
ht.Add("689", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 689));
ht.Add("690", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 690));
ht.Add("692", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 692));
ht.Add("695", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 695));
ExcelExporter.ExportIncomeStatement(ht, filePath);
break;
case 3:
ht.Add("300", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 300));
ht.Add("NetIncome", LogicBroker.GetIncomeStatement(date, clientID));
ht.Add("301", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 301));
ExcelExporter.ExportOwnersEquity(ht, filePath);
break;
case 4:
ht.Add("110", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 110));
ht.Add("120", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 120));
ht.Add("140", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 140));
ht.Add("145", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 145));
ht.Add("150", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 150));
ht.Add("155", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 155));
ht.Add("160", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 160));
ht.Add("161", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 161));
ht.Add("165", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 165));
ht.Add("166", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 166));
ht.Add("220", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 220));
ht.Add("230", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 230));
ht.Add("240", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 240));
ht.Add("300", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 300));
ExcelExporter.ExportBalanceSheet(ht, filePath);
break;
default:
break;
}
MessageBox.Show("Report generated");
this.Dispose();
}
}
#endregion
}
}
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 System.Collections;
namespace BusinessProgramming
{
public partial class Report : Form
{
#region "Local Variables"
private List<int> clientIds;
#endregion
#region "Constructor"
public Report()
{
InitializeComponent();
}
#endregion
#region "Report_Load"
private void Report_Load(object sender, EventArgs e)
{
clientIds = new List<int>();
cbClients.Items.Clear();
DataTable dt = LogicBroker.GetClients();
foreach (DataRow dr in dt.Rows)
{
clientIds.Add(Convert.ToInt32(dr["client_id"]));
cbClients.Items.Add(dr["name"].ToString());
}
if (cbClients.Items.Count != 0)
{
cbClients.SelectedIndex = 0;
}
if (cbReports.Items.Count != 0)
{
cbReports.SelectedIndex = 0;
}
if (cbMonths.Items.Count != 0)
{
cbMonths.SelectedIndex = 0;
}
if (cbYears.Items.Count != 0)
{
cbYears.SelectedIndex = 0;
}
}
#endregion
#region "btnGenerate_Click"
private void btnGenerate_Click(object sender, EventArgs e)
{
DateTime date = new DateTime(cbYears.SelectedIndex + 2006, cbMonths.SelectedIndex + 1, 1);
int clientID = clientIds[cbClients.SelectedIndex];
Hashtable ht = new Hashtable();
ht.Add("Month", date.ToString("MMMM"));
ht.Add("Year", date.ToString("yyyy"));
ht.Add("Client", LogicBroker.GetClientName(clientID));
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "xls files (*.xls)|*.xls|All files (*.*)|*.*";
sfd.FilterIndex = 1;
sfd.RestoreDirectory = true;
if (sfd.ShowDialog() == DialogResult.OK)
{
string filePath = sfd.FileName;
switch (cbReports.SelectedIndex)
{
case 0:
ht.Add("110", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 110));
ht.Add("120", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 120));
ht.Add("140", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 140));
ht.Add("145", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 145));
ht.Add("150", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 150));
ht.Add("155", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 155));
ht.Add("160", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 160));
ht.Add("161", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 161));
ht.Add("165", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 165));
ht.Add("166", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 166));
ht.Add("220", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 220));
ht.Add("230", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 230));
ht.Add("240", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 240));
ht.Add("300", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 300));
ht.Add("301", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 301));
ht.Add("400", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 400));
ht.Add("620", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 620));
ht.Add("660", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 660));
ht.Add("665", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 665));
ht.Add("682", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 682));
ht.Add("688", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 688));
ht.Add("689", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 689));
ht.Add("690", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 690));
ht.Add("692", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 692));
ht.Add("695", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 695));
ExcelExporter.ExportUnAdjustedTrialBalance(ht, filePath);
break;
case 1:
ht.Add("110", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 110));
ht.Add("120", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 120));
ht.Add("140", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 140));
ht.Add("145", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 145));
ht.Add("150", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 150));
ht.Add("155", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 155));
ht.Add("160", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 160));
ht.Add("161", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 161));
ht.Add("165", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 165));
ht.Add("166", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 166));
ht.Add("220", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 220));
ht.Add("230", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 230));
ht.Add("240", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 240));
ht.Add("300", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 300));
ht.Add("301", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 301));
ht.Add("400", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 400));
ht.Add("620", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 620));
ht.Add("660", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 660));
ht.Add("665", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 665));
ht.Add("682", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 682));
ht.Add("688", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 688));
ht.Add("689", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 689));
ht.Add("690", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 690));
ht.Add("692", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 692));
ht.Add("695", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 695));
ExcelExporter.ExportAdjustedTrialBalance(ht, filePath);
break;
case 2:
ht.Add("400", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 400));
ht.Add("620", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 620));
ht.Add("660", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 660));
ht.Add("665", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 665));
ht.Add("682", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 682));
ht.Add("688", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 688));
ht.Add("689", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 689));
ht.Add("690", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 690));
ht.Add("692", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 692));
ht.Add("695", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 695));
ExcelExporter.ExportIncomeStatement(ht, filePath);
break;
case 3:
ht.Add("300", LogicBroker.GetPreviousMonthAccountBalance(date, clientID, 300));
ht.Add("NetIncome", LogicBroker.GetIncomeStatement(date, clientID));
ht.Add("301", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 301));
ExcelExporter.ExportOwnersEquity(ht, filePath);
break;
case 4:
ht.Add("110", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 110));
ht.Add("120", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 120));
ht.Add("140", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 140));
ht.Add("145", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 145));
ht.Add("150", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 150));
ht.Add("155", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 155));
ht.Add("160", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 160));
ht.Add("161", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 161));
ht.Add("165", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 165));
ht.Add("166", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 166));
ht.Add("220", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 220));
ht.Add("230", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 230));
ht.Add("240", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 240));
ht.Add("300", LogicBroker.GetCurrentMonthAccountBalance(date, clientID, 300));
ExcelExporter.ExportBalanceSheet(ht, filePath);
break;
default:
break;
}
MessageBox.Show("Report generated");
this.Dispose();
}
}
#endregion
}
}