using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BE_InvoiceSystem
{
public class BEInvoice
{
public int ID { get; set; }
public DateTime Datefrom { get; set; }
public DateTime Dateto { get; set; }
public string Carrier { get; set; }
public decimal Rates { get; set; }
public decimal Minutes { get; set; }
public decimal Cost { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BE_InvoiceSystem;
using System.Data.SqlClient;
using System.Data;
using System.Collections.Specialized;
using System.Collections;
namespace DAL_InvoiceSystem
{
public class DALInvoice
{
private string connnect = MyConnectionString.path;
public List<BEInvoice> show( BEInvoice bes )
{
List<BEInvoice> list = new List<BEInvoice>();
SqlConnection con = new SqlConnection(connnect);
SqlCommand cmd = new SqlCommand(MyProc.name.spBillinginvoiceSummary.ToString(), con);
cmd.Parameters.AddWithValue("@Datefrom", bes.Datefrom);
cmd.Parameters.AddWithValue("@Dateto", bes.Dateto);
cmd.CommandType = CommandType.StoredProcedure;
try
{
con.Open();
SqlDataReader sdr = cmd.ExecuteReader();
if (sdr.HasRows)
{
while (sdr.Read())
{
BEInvoice be = new BEInvoice();
be.ID = Convert.ToInt32(sdr["ID"]);
be.Carrier = Convert.ToString(sdr["Carrier"]);
be.Rates = Convert.ToDecimal(sdr["Rates"]);
be.Minutes = Convert.ToDecimal(sdr["Minutes"]);
be.Cost = Convert.ToDecimal(sdr["Cost"]);
list.Add(be);
}
}
}
catch (Exception)
{
throw;
}
finally
{
con.Close();
}
return list;
}
public void SetParmetersToReportMain(ListDictionary MyListDic, SqlCommand ExecHeadCommand)
{
foreach (DictionaryEntry item in MyListDic)
{
ExecHeadCommand.Parameters.AddWithValue(item.Key.ToString(), item.Value.ToString());
}
}
}
}
--Bl---
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BE_InvoiceSystem;
using DAL_InvoiceSystem;
using System.Collections.Specialized;
using System.Data.SqlClient;
using System.Collections;
namespace BL_InvoiceSystem
{
public class BLInvoice
{
public List<BEInvoice> show(BEInvoice bes)
{
return new DALInvoice().show(bes);
}
public void SetParmetersToReportMain(ListDictionary MyListDic, SqlCommand ExecHeadCommand)
{
new DALInvoice().SetParmetersToReportMain(MyListDic, ExecHeadCommand);
}
}
}
=-------index--------------
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="index.aspx.cs" Inherits="InvoiceSystem.index" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.style1
{
width: 100%;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div style="margin: 0 auto; width: 1080;">
<table class="style1">
<tr>
<td colspan="4" align="center">
<h2>
Invoice System</h2>
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Label ID="lblError" runat="server" Text="" style="color:Red;font-weight:bold"></asp:Label>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
Date From :
</td>
<td>
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<asp:TextBox ID="txtDateFrom" runat="server"></asp:TextBox>
<asp:CalendarExtender ID="CalendarExtender1" TargetControlID="txtDateFrom" runat="server" Format="yyyy-MM-dd"/>
</td>
<td>
Date To :
</td>
<td>
<asp:TextBox ID="txtDateTo" runat="server"></asp:TextBox>
<asp:CalendarExtender ID="CalendarExtender2" TargetControlID="txtDateTo" runat="server" Format="yyyy-MM-dd"/>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
<asp:Button ID="btnSearch" runat="server" Text=" Search "
onclick="btnSearch_Click" />
<asp:Button ID="btnPreview" runat="server" onclick="btnPreview_Click"
Text="Preview" />
</td>
</tr>
</table>
<br />
<br />
<asp:ListView ID="lstinvoice" runat="server">
<LayoutTemplate>
<table border="1">
<tr>
<td style="width: 100px;display:none">
Id
</td>
<td style="width: 300px">
Carrier
</td>
<td style="width: 100px">
Avg Rates
</td>
<td style="width: 200px">
Minutes
</td>
<td style="width: 200px">
Cost
</td>
</tr>
</table>
<div id="ItemPlaceholder" runat="server">
</div>
</table>
</LayoutTemplate>
<ItemTemplate>
<table border="1">
<tr>
<td style="width: 100px ;display:none">
<%#Eval("Id")%>
</td>
<td style="width: 300px">
<%#Eval("Carrier")%>
</td>
<td style="width: 100px">
<%#Eval("Rates")%>
</td>
<td style="width: 200px">
<%#Eval("Minutes")%>
</td>
<td style="width: 200px">
<%#Eval("Cost")%>
</td>
</tr>
</table>
</ItemTemplate>
</asp:ListView>
</div>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BE_InvoiceSystem;
using BL_InvoiceSystem;
using System.Collections.Specialized;
using System.Data.SqlClient;
using DAL_InvoiceSystem;
namespace InvoiceSystem
{
public partial class index : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSearch_Click(object sender, EventArgs e)
{
if ((string.IsNullOrEmpty(txtDateFrom.Text)) && (string.IsNullOrEmpty(txtDateFrom.Text)) )
{
lblError.Text="Kindly Select Date ... ";
return;
}
BEInvoice be = new BEInvoice();
be.Datefrom =Convert.ToDateTime(txtDateFrom.Text);
be.Dateto = Convert.ToDateTime(txtDateTo.Text);
lstinvoice.DataSource = new BLInvoice().show(be);
lstinvoice.DataBind();
}
protected void btnPreview_Click(object sender, EventArgs e)
{
if ((string.IsNullOrEmpty(txtDateFrom.Text)) && (string.IsNullOrEmpty(txtDateFrom.Text)))
{
lblError.Text = "Kindly Select Date ... ";
return;
}
BEInvoice be = new BEInvoice();
be.Datefrom = Convert.ToDateTime(txtDateFrom.Text);
be.Dateto = Convert.ToDateTime(txtDateTo.Text);
lstinvoice.DataSource = new BLInvoice().show(be);
lstinvoice.DataBind();
ListDictionary MyListDic = new ListDictionary();
SqlCommand ExecHeadCommand = new SqlCommand();
string ReportFilePath = "";
MyListDic.Add("@Datefrom1", Convert.ToDateTime(txtDateFrom.Text).ToString("dd/MM/yyyy"));
MyListDic.Add("@Dateto1", Convert.ToDateTime(txtDateTo.Text).ToString("dd/MM/yyyy"));
ReportFilePath = "CrystalReport1.rpt";
ReportFilePath = Server.MapPath(ReportFilePath);
Session["mDataTable"] = new BLInvoice().show(be);
//MyListDic.Add("@DateFrom", Convert.ToDateTime(txtDateFrom.Text).ToString("dd/MM/yyyy"));
//MyListDic.Add("@DateTo", Convert.ToDateTime(txtDateTo.Text).ToString("dd/MM/yyyy"));
new BLInvoice().SetParmetersToReportMain(MyListDic, ExecHeadCommand);
Session["ReportFile"] = ReportFilePath;
Session["MyListDic"] = MyListDic;
Response.Write("<script language = \"Javascript\">var win=window.open('ShowReport.aspx',null,'width=1020,height=700,top=0,left=0,scrollbars=yes,resizable=yes','true');</script>");
}
}
}
=-------Preview Report--------------
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ShowReport.aspx.cs" Inherits="InvoiceSystem.ShowReport" %>
<%@ Register Assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"
Namespace="CrystalDecisions.Web" TagPrefix="CR" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="true" Height="1055px" ReportSourceID="ReportFilePath" Width="100%" EnableDatabaseLogonPrompt="False"
EnableParameterPrompt="False" HasCrystalLogo="False"
ToolPanelView="None" />
</div>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CrystalDecisions.CrystalReports.Engine;
using System.Collections.Specialized;
using System.Collections;
namespace InvoiceSystem
{
public partial class ShowReport : System.Web.UI.Page
{
ReportDocument myReport = new ReportDocument();
ListDictionary MyListDic = new ListDictionary();
protected void Page_Load(object sender, EventArgs e)
{
myReport.Load((string)Session["ReportFile"]);
myReport.SetDataSource(Session["mDataTable"]);
MyListDic = (ListDictionary)Session["MyListDic"];
SetParmetersToReportMain();
CrystalReportViewer1.ReportSource = myReport;
}
private void SetParmetersToReportMain()
{
foreach (DictionaryEntry item in MyListDic)
{
myReport.SetParameterValue(item.Key.ToString(), item.Value.ToString());
}
}
}
}
No comments :
Post a Comment