Ans:-
Here i have done in 1st page- one Confirmation Box will show while click the Show Button and then while Click OK option of Confirmation Box- then only PopUp(PopUp is the 2nd page) will show which is Redirect to the 2nd page and then in 2nd page one Hyperlink is there in DataGridview Column while click that Hyperlink this page is Redirect to the 3rd page where i have added Crystal Report to show the data in Report format and one Back Button to go back again to 2nd page.
below as some Pics..
1st page..
1st page while clicking the show button..Confirmation Box is Showing..
Redirecting to 2nd page after clicking OK option of Confirmation Box..
Redirecting to 3rd page after clicking the Hyperlink of DataGridView Column(Code)..
Again Redirecting to 2nd page while clicking the Back Button in 3rd page..
1st Normal (.aspx)Page-
ConfirmBoxOrPopup5.aspx:-
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="ConfirmBoxOrPopup5.aspx.vb" Inherits="ConfirmingWhileDelete" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Confirmation Box And Pop Up Show Page</title>
<script language="javascript" type="text/javascript">
function Approve() {
var txtCount = document.getElementById('txtCount');
if (parseInt(txtCount.value) < 1) {
alert("You can not show the premiums for this Policy");
return false;
}
else {
var sConfirm;
sConfirm = confirm("Are you sure you want to Show Data on Pop Up.");
if (sConfirm == true) {
var txtspStr1 = document.getElementById('txtspStr1');
window.open("ForPopupPage5_1.aspx?strParm=" + txtspStr1.value + "", 'Window', 'height=700,width=900,left=150,top=150,resizable=no,scrollbars=yes,toolbar=no,status=no');
}
else
{ return false; }
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<center>
<table>
<tr>
<td>
<asp:Label ID="Label1" Text="Policy : " runat="server" Font-Bold="True" ></asp:Label>
</td>
<td>
<telerik:radcombobox ID="ddlCode" runat="server" AllowCustomText="true" AutoPostBack="true"
BorderColor="#666666" BorderStyle="Solid" BorderWidth="1px" DropDownCssClass="RadComboBox_Sunset"
EmptyMessage="Select Insurance Company"
EnableEmbeddedSkins="False" EnableLoadOnDemand="true"
EnableViewState="false" EnableVirtualScrolling="True"
Font-Names="Verdana" Font-Size="8.5pt"
MarkFirstMatch="true" ShowMoreResultsBox="True" Skin="Sunset"
Width="300px" TabIndex="12">
</telerik:radcombobox>
</td>
</tr>
<tr><td><br /></td><td><br /></td></tr>
<tr><td><br /></td><td><br /></td></tr>
<tr>
<td>
<asp:Label ID="Label2" Text="Policy Code : " runat="server" Font-Bold="True" ></asp:Label>
</td>
<td>
<asp:TextBox runat="server" ID="txtPolicyCode" Width="144" ReadOnly="True" Rows="10"
TabIndex="3"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label3" Text="Policy Name : " runat="server" Font-Bold="True" ></asp:Label>
</td>
<td>
<asp:TextBox runat="server" ID="txtPolicyName" Width="144" ReadOnly="True" Rows="10"
TabIndex="3"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label4" Text="Provider Code : " runat="server" Font-Bold="True" ></asp:Label>
</td>
<td>
<asp:TextBox runat="server" ID="txtProviderCode" Width="144" ReadOnly="True" Rows="10"
TabIndex="3"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label5" Text="Provider Name : " runat="server" Font-Bold="True" ></asp:Label>
</td>
<td>
<asp:TextBox runat="server" ID="txtProviderName" Width="144" ReadOnly="True" Rows="10"
TabIndex="3"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label6" Text="User Id : " runat="server" Font-Bold="True" ></asp:Label>
</td>
<td>
<asp:TextBox runat="server" ID="txtUserid" Width="144" ReadOnly="True" Rows="10"
TabIndex="3"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan='2'>
<asp:Label ID="lblResult" runat="server" Font-Bold="True" Width="542px" ></asp:Label>
<asp:TextBox runat="server" ID="txtRowCount" Height="1" Width="1" ></asp:TextBox>
<asp:TextBox ID="txtCount" runat="server" BorderColor="ActiveCaptionText" BorderStyle="None"
Font-Size="3pt" ForeColor="White" Height="1px" Width="1px"></asp:TextBox>
<asp:TextBox ID="txtspStr1" runat="server" BorderColor="ActiveCaptionText" BorderStyle="None"
Font-Size="3pt" ForeColor="White" Height="1px" Width="1px"></asp:TextBox>
</td>
</tr>
<tr>
<td></td>
<td align="center">
<asp:ImageButton ID="btnShow" runat="server" AccessKey="D" ImageUrl="~/Images/btnshow.gif"
TabIndex="56" ToolTip="Alt+d" Visible="true" />
</td>
</tr>
</table>
</center>
</div>
</form>
</body>
</html>
Here i have done in 1st page- one Confirmation Box will show while click the Show Button and then while Click OK option of Confirmation Box- then only PopUp(PopUp is the 2nd page) will show which is Redirect to the 2nd page and then in 2nd page one Hyperlink is there in DataGridview Column while click that Hyperlink this page is Redirect to the 3rd page where i have added Crystal Report to show the data in Report format and one Back Button to go back again to 2nd page.
below as some Pics..
1st page..
1st page while clicking the show button..Confirmation Box is Showing..
Again Redirecting to 2nd page while clicking the Back Button in 3rd page..
1st Normal (.aspx)Page-
ConfirmBoxOrPopup5.aspx:-
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="ConfirmBoxOrPopup5.aspx.vb" Inherits="ConfirmingWhileDelete" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Confirmation Box And Pop Up Show Page</title>
<script language="javascript" type="text/javascript">
function Approve() {
var txtCount = document.getElementById('txtCount');
if (parseInt(txtCount.value) < 1) {
alert("You can not show the premiums for this Policy");
return false;
}
else {
var sConfirm;
sConfirm = confirm("Are you sure you want to Show Data on Pop Up.");
if (sConfirm == true) {
var txtspStr1 = document.getElementById('txtspStr1');
window.open("ForPopupPage5_1.aspx?strParm=" + txtspStr1.value + "", 'Window', 'height=700,width=900,left=150,top=150,resizable=no,scrollbars=yes,toolbar=no,status=no');
}
else
{ return false; }
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<center>
<table>
<tr>
<td>
<asp:Label ID="Label1" Text="Policy : " runat="server" Font-Bold="True" ></asp:Label>
</td>
<td>
<telerik:radcombobox ID="ddlCode" runat="server" AllowCustomText="true" AutoPostBack="true"
BorderColor="#666666" BorderStyle="Solid" BorderWidth="1px" DropDownCssClass="RadComboBox_Sunset"
EmptyMessage="Select Insurance Company"
EnableEmbeddedSkins="False" EnableLoadOnDemand="true"
EnableViewState="false" EnableVirtualScrolling="True"
Font-Names="Verdana" Font-Size="8.5pt"
MarkFirstMatch="true" ShowMoreResultsBox="True" Skin="Sunset"
Width="300px" TabIndex="12">
</telerik:radcombobox>
</td>
</tr>
<tr><td><br /></td><td><br /></td></tr>
<tr><td><br /></td><td><br /></td></tr>
<tr>
<td>
<asp:Label ID="Label2" Text="Policy Code : " runat="server" Font-Bold="True" ></asp:Label>
</td>
<td>
<asp:TextBox runat="server" ID="txtPolicyCode" Width="144" ReadOnly="True" Rows="10"
TabIndex="3"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label3" Text="Policy Name : " runat="server" Font-Bold="True" ></asp:Label>
</td>
<td>
<asp:TextBox runat="server" ID="txtPolicyName" Width="144" ReadOnly="True" Rows="10"
TabIndex="3"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label4" Text="Provider Code : " runat="server" Font-Bold="True" ></asp:Label>
</td>
<td>
<asp:TextBox runat="server" ID="txtProviderCode" Width="144" ReadOnly="True" Rows="10"
TabIndex="3"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label5" Text="Provider Name : " runat="server" Font-Bold="True" ></asp:Label>
</td>
<td>
<asp:TextBox runat="server" ID="txtProviderName" Width="144" ReadOnly="True" Rows="10"
TabIndex="3"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label6" Text="User Id : " runat="server" Font-Bold="True" ></asp:Label>
</td>
<td>
<asp:TextBox runat="server" ID="txtUserid" Width="144" ReadOnly="True" Rows="10"
TabIndex="3"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan='2'>
<asp:Label ID="lblResult" runat="server" Font-Bold="True" Width="542px" ></asp:Label>
<asp:TextBox runat="server" ID="txtRowCount" Height="1" Width="1" ></asp:TextBox>
<asp:TextBox ID="txtCount" runat="server" BorderColor="ActiveCaptionText" BorderStyle="None"
Font-Size="3pt" ForeColor="White" Height="1px" Width="1px"></asp:TextBox>
<asp:TextBox ID="txtspStr1" runat="server" BorderColor="ActiveCaptionText" BorderStyle="None"
Font-Size="3pt" ForeColor="White" Height="1px" Width="1px"></asp:TextBox>
</td>
</tr>
<tr>
<td></td>
<td align="center">
<asp:ImageButton ID="btnShow" runat="server" AccessKey="D" ImageUrl="~/Images/btnshow.gif"
TabIndex="56" ToolTip="Alt+d" Visible="true" />
</td>
</tr>
</table>
</center>
</div>
</form>
</body>
</html>
ConfirmBoxOrPopup5.aspx.vb:-
Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.UI.WebControls
Imports Telerik.Web.UI
Partial Class ConfirmingWhileDelete
Inherits System.Web.UI.Page
Dim sqlcon As SqlConnection
Dim sqlcmd As SqlCommand
Dim sqlad As SqlDataAdapter
Dim sqldr As SqlDataReader
Dim dt As New DataTable
Dim ds As New DataSet
Dim obj As New Class1
Dim spStr() As String
Dim dsComm As New DataSet
Dim sFlag As Integer = 0
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
sqlcon = New SqlConnection(obj.Connect) : sqlcon.Open()
btnShow.Attributes.Add("onclick", "return Approve()")
End Sub
Protected Sub ddlCode_ItemsRequested(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs) Handles ddlCode.ItemsRequested
Try
If sqlcon.State = ConnectionState.Closed Then sqlcon.Open()
'sqlad = New SqlDataAdapter("select cast(policyid as varchar)+'-'+policyname as Policy from tblpolicy where (policyname Like '" + e.Text + "%' or policyid Like '" + e.Text + "%')", sqlcon)
sqlad = New SqlDataAdapter("select ltrim(rtrim(policyid))+'-'+ltrim(rtrim(policyname)) as Policy from tblpolicy where (policyname Like '" + e.Text + "%' or policyid Like '" + e.Text + "%')", sqlcon)
sqlad.Fill(dt)
Dim itemsPerRequest As Integer = 20
Dim itemOffset As Integer = e.NumberOfItems
Dim endOffset As Integer = itemOffset + itemsPerRequest
If endOffset > dt.Rows.Count Then
endOffset = dt.Rows.Count
End If
Dim i As Integer = itemOffset
While i < endOffset
ddlCode.Items.Add(New RadComboBoxItem(dt.Rows(i)("Policy").ToString()))
i = i + 1
End While
If dt.Rows.Count > 0 Then
e.Message = [String].Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), dt.Rows.Count.ToString())
Else
e.Message = "No matches"
End If
Catch ex As Exception
lblResult.Text = obj.CustomEror(Err.Number)
Finally
sqlcon.Close()
End Try
End Sub
Protected Sub ddlCode_SelectedIndexChanged(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs) Handles ddlCode.SelectedIndexChanged
Try
ddlCode.Attributes.Add("style", "display:''")
If Len(ddlCode.Text) > 0 Then
Dim r As Integer = obj.FetchValue("select COUNT(*) from tblpolicy where ltrim(rtrim(policyid))+'-'+ltrim(rtrim(policyname))='" + ddlCode.Text + "'", sqlcon)
If r = 0 Then
obj.MessageBox(Me, "Code not Found.") : ddlCode.Text = ""
ddlCode.Focus() : obj.PageClear(Me) : sFlag = 1 : Exit Sub
Else
spStr = ddlCode.Text.Split("-")
sqlcmd = New SqlCommand("sp_AutoGenerateGrdVw", sqlcon)
sqlcmd.CommandType = CommandType.StoredProcedure
sqlcmd.Parameters.Add(New SqlParameter("@policyid", spStr(0)))
sqlad = New SqlDataAdapter(sqlcmd)
sqlad.Fill(dsComm, "policytbl")
With dsComm.Tables(0).Rows(0)
txtPolicyCode.Text = .Item("policyid")
txtPolicyName.Text = .Item("policyname")
txtProviderCode.Text = .Item("providerid")
txtProviderName.Text = .Item("providername")
txtUserid.Text = .Item("uid")
End With
ViewState("policytbl") = dsComm
txtRowCount.Text = dsComm.Tables("policytbl").Rows.Count
lblResult.Text = "" : sFlag = 0
End If
End If
Catch ex As Exception
lblResult.Text = obj.CustomEror(Err.Number)
End Try
End Sub
Protected Sub btnShow_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnShow.Click
txtspStr1.Text = "A~" + txtPolicyCode.Text & "~" & txtPolicyName.Text & "~" & txtProviderCode.Text & "~" & txtProviderName.Text & "~" & txtUserid.Text & "~Add"
txtCount.Text = obj.FetchValue("select COUNT(*) from tblpolicy where policyid=" & txtPolicyCode.Text & "", sqlcon)
End Sub
End Class
2nd for generate PopUp (.aspx)Page-
ForPopupPage5_1.aspx:-
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="ForPopupPage5_1.aspx.vb" Inherits="ForPopupPage" %>
<!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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<center>
<p>Show Data on PopUp Show</p>
<table>
<tr>
<td>
<asp:Label ID="Label2" Text="Policy Code : " runat="server" Font-Bold="True" ></asp:Label>
</td>
<td>
<asp:TextBox runat="server" ID="txtPolicyCode" Width="144" ReadOnly="True" Rows="10"
TabIndex="3"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label3" Text="Policy Name : " runat="server" Font-Bold="True" ></asp:Label>
</td>
<td>
<asp:TextBox runat="server" ID="txtPolicyName" Width="144" ReadOnly="True" Rows="10"
TabIndex="3"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblResult" runat="server" Font-Bold="True" Width="542px" ></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:TextBox ID="txtCount" runat="server" BorderColor="ActiveCaptionText" BorderStyle="None"
Font-Size="3pt" ForeColor="White" Height="1px" Width="1px"></asp:TextBox>
</td>
<td>
<asp:TextBox ID="txtspStr1" runat="server" BorderColor="ActiveCaptionText" BorderStyle="None"
Font-Size="3pt" ForeColor="White" Height="1px" Width="1px"></asp:TextBox>
</td>
</tr>
</table>
<br />
<asp:DataGrid ID="dgrPolicy" runat="server" AutoGenerateColumns="False" CellPadding="4"
Font-Bold="False" Font-Names="Verdana" Font-Size="XX-Small" ForeColor="#333333"
GridLines="None" Height="23px" Width="567px" >
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<EditItemStyle BackColor="#2461BF" />
<SelectedItemStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<AlternatingItemStyle BackColor="White" />
<ItemStyle BackColor="#EFF3FB" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<Columns>
<%--<asp:BoundColumn DataField="policyid" HeaderText="PolicyCode">
<ItemStyle HorizontalAlign="Left" Width="20%" />
<HeaderStyle HorizontalAlign="Left" />
</asp:BoundColumn>--%>
<asp:TemplateColumn HeaderText="Code">
<ItemTemplate>
<asp:LinkButton ID="lbllnkBtnCode" runat="server" CausesValidation="false" CommandName="policyid"
Text='<%# Eval("policyid") %>' CommandArgument="Actual"></asp:LinkButton>
</ItemTemplate>
<ItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"
Font-Underline="False" HorizontalAlign="Left" />
<HeaderStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"
Font-Underline="False" HorizontalAlign="Left" />
</asp:TemplateColumn>
<asp:BoundColumn DataField="policyname" HeaderText="PolicyName">
<ItemStyle HorizontalAlign="Left" Width="65%" />
<HeaderStyle HorizontalAlign="Left" />
</asp:BoundColumn>
<asp:BoundColumn DataField="providerid" HeaderText="HospitalCode">
<ItemStyle HorizontalAlign="Left" Width="65%" />
<HeaderStyle HorizontalAlign="Left" />
</asp:BoundColumn>
<asp:BoundColumn DataField="providername" HeaderText="Hospital">
<ItemStyle HorizontalAlign="Left" Width="65%" />
<HeaderStyle HorizontalAlign="Left" />
</asp:BoundColumn>
<asp:BoundColumn DataField="uid" HeaderText="UserId">
<ItemStyle HorizontalAlign="Left" Width="65%" />
<HeaderStyle HorizontalAlign="Left" />
</asp:BoundColumn>
</Columns>
</asp:DataGrid>
</center>
</div>
</form>
</body>
</html>
ForPopupPage5_1.aspx.vb:-
Imports System.Web.UI.WebControls
Imports System
Imports System.Data
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports System.Data.SqlClient
Partial Class ForPopupPage
Inherits System.Web.UI.Page
Dim sqlcon As SqlConnection
Dim sqlcmd As SqlCommand
Dim sqldr As SqlDataReader
Dim Par As SqlParameter
Dim sqlds As New DataSet
Dim sqlda As SqlDataAdapter
Dim obj As New Class1
Dim spStr() As String
Dim spStr1(), spstrmem() As String
Dim POL() As String
Dim ClassCode As Integer
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try
sqlcon = New SqlConnection(obj.Connect) : sqlcon.Open()
ViewState("strParm") = Request.QueryString("strParm")
spStr = Split(ViewState("strParm"), "~")
If Not IsPostBack Then
If spStr(0) = "A" Then
txtPolicyCode.Text = spStr(1)
txtPolicyName.Text = spStr(2)
sqlcmd = New SqlCommand("sp_AutoGenerateGrdVw", sqlcon)
sqlcmd.CommandType = CommandType.StoredProcedure
sqlcmd.Parameters.Add(New SqlParameter("@policyid", txtPolicyCode.Text))
sqlda = New SqlDataAdapter(sqlcmd)
sqlda.Fill(sqlds, "policytbl")
dgrPolicy.DataSource = sqlds
dgrPolicy.DataBind()
End If
End If
Catch ex As Exception
lblResult.Text = obj.CustomEror(Err.Number)
End Try
End Sub
Protected Sub dgrPolicy_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgrPolicy.ItemCommand
'Dim PolicyCode As Integer
Dim PolicyName As String
Dim providerid As Integer
Dim providername As String
Dim uid As Integer
If e.CommandArgument = "Actual" Then
'PolicyCode = e.Item.Cells(0).Text
PolicyName = e.Item.Cells(1).Text
providerid = e.Item.Cells(2).Text
providername = e.Item.Cells(3).Text
uid = e.Item.Cells(4).Text
txtspStr1.Text = "A~" + txtPolicyCode.Text & "~" & PolicyName & "~" & providerid & "~" & providername & "~" & uid & "~Add"
txtCount.Text = obj.FetchValue("select COUNT(*) from tblpolicy where policyid=" & txtPolicyCode.Text & "", sqlcon)
If txtCount.Text < 1 Then
lblResult.Text = "You can not show the premiums for this Policy" 'If Policy is not created then it will not show.
Else
Response.Redirect("ShowReportFromPopUp5_2.aspx?strParm=" + txtspStr1.Text + "") 'On Same Page its redirect to another page.
End If
End If
End Sub
End Class
3rd for generate Report in (.aspx) Page-
ShowReportFromPopUp5_2.aspx:-
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="ShowReportFromPopUp5_2.aspx.vb" Inherits="ShowReportFromPopUp5_2" %>
<%@ Register Assembly="CrystalDecisions.Web, Version=10.5.3700.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>Show Report From PopUp Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table>
<tr>
</tr>
</table>
<table bgcolor="White" width="79%" align="center">
<tr>
<td align="center" colspan="1">
<asp:HyperLink ID="HyperLink1" runat="server" Font-Bold="True">Debit Notes</asp:HyperLink></td>
<td><%--<asp:Button ID="Button1" runat="server" Text="Back" Width="78px" />--%>
<asp:ImageButton ID="Button1" runat="server" ImageUrl="~/Images/btnback.gif"/></td>
</tr>
<tr>
<td align="left" colspan="2">
<asp:Label ID="lblResult" runat="server" Width="798px"></asp:Label></td>
</tr>
<tr>
<td align="left" colspan="2" valign="top" style="width: 600px">
<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server"
AutoDataBind="True" Height="1039px" ReportSourceID="CrystalReportSource1"
Width="901px" />
<CR:CrystalReportSource ID="CrystalReportSource1"
runat="server">
<report filename="ShowReportFromPopUp5_2.rpt">
</report>
</CR:CrystalReportSource>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
ShowReportFromPopUp5_2.aspx.vb:-
Imports System.Web.UI.WebControls
Imports System
Imports System.Data
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports System.Data.SqlClient
Imports System.ComponentModel
Imports CrystalDecisions.Shared
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.ReportAppServer.ClientDoc
Partial Class ShowReportFromPopUp5_2
Inherits System.Web.UI.Page
Dim sqlcon As SqlConnection
Dim sqlcmd As SqlCommand
Dim sqlad As SqlDataAdapter
Dim sqldr As SqlDataReader
Dim ds As New DataSet
Dim obj As New Class1
Dim spStr() As String
Dim spStr1() As String
Dim spStr2() As String
Dim sFlag As Integer = 0
Dim strParm As String
Dim name As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
sqlcon = New SqlConnection(obj.Connect) : sqlcon.Open()
ViewState("strParm") = Request.QueryString.Get("strParm")
spStr = Split(ViewState("strParm"), "~")
'If spStr.Length = 6 Then
' name = spStr(5)
'End If
Call ShowReport()
End Sub
Private Sub ShowReport()
Try
If spStr.Length <= 15 Then
sqlcmd = New SqlCommand("sp_AutoGenerateGrdVw", sqlcon)
sqlcmd.CommandType = CommandType.StoredProcedure
spStr = Split(Request.QueryString.Get("strParm"), "~")
sqlcmd.Parameters.Add(New SqlParameter("@policyid", spStr(1)))
sqlad = New SqlDataAdapter(sqlcmd)
sqlad.Fill(ds, "ShowRpt")
CrystalReportSource1.ReportDocument.SetDataSource(ds.Tables("ShowRpt"))
End If
Catch ex As Exception
lblResult.Text = obj.CustomEror(Err.Number)
End Try
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles Button1.Click
'If name = "Add" Then
Response.Redirect("ForPopupPage5_1.aspx?strParm=" + ViewState("strParm"))
'End If
End Sub
End Class
and then add Crystal Report in this application through our Asp.Net Application as Add New Item /or through Crystal Report 9....and get connection from DB.
Class1.vb:-
Imports Microsoft.VisualBasic
Imports System.Web.UI.WebControls
Imports System
Imports System.Data
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports System.Data.SqlClient
Imports System.Data.Odbc
Imports Telerik.Web.UI
Public Class Class1
Dim sqlcmd As SqlCommand
Dim sqldr As SqlDataReader
Public dsImport As New DataSet
Public Function Connect() As String
Connect = "Data source=192.168.0.200;Database=SubsDB;Uid=sa;Pwd=amtpl@123;Pooling=true;Min Pool Size=2;Max Pool Size=1000"
End Function
Public Sub AddComboTi(ByVal CntName As RadComboBox, ByVal SqlStr As String, ByVal sCon As SqlConnection)
'Which will fill the DropdownList Based on Query
Try
CntName.Items.Clear()
'Dim Str As String = String.Empty
' CntName.Items.Add(New RadComboBoxItem(""))
sqlcmd = New SqlCommand(SqlStr, sCon)
sqldr = sqlcmd.ExecuteReader()
While sqldr.Read
CntName.Items.Add(New RadComboBoxItem(sqldr(0)))
End While
sqldr.Close() : sqlcmd.Dispose()
Catch ex As Exception
'MsgBox(ex.Message)
End Try
End Sub
Public Sub AddCombo(ByVal CntName As DropDownList, ByVal SqlStr As String, ByVal sCon As SqlConnection)
'Which will fill the DropdownList Based on Query
Try
CntName.Items.Clear()
CntName.Items.Add("")
sqlcmd = New SqlCommand(SqlStr, sCon)
sqldr = sqlcmd.ExecuteReader()
While sqldr.Read
CntName.Items.Add(sqldr(0))
End While
sqldr.Close() : sqlcmd.Dispose()
Catch ex As Exception
'MsgBox(ex.Message)
End Try
End Sub
Public Function getDataSet(ByVal Sqlstr As String, ByVal Sqcon As SqlConnection) As DataSet
Dim getDS As New DataSet
Try
Dim sqlad As New SqlDataAdapter(Sqlstr, Sqcon)
sqlad.Fill(getDS)
getDataSet = getDS
Catch ex As Exception
getDataSet = getDS
End Try
End Function
Public Function FetchValue(ByVal qStr As String, ByVal sCon As SqlConnection) As String
'Which will give the Find Value Based on Query
Try
Dim sqlFetch = New SqlCommand(qStr, sCon)
FetchValue = sqlFetch.ExecuteScalar()
sqlFetch.Dispose()
Catch ex As Exception
FetchValue = ""
End Try
End Function
Public Sub MessageBox(ByVal pName As Page, ByVal strMsg As String)
Dim lbl As New Label
lbl.Text = "<script language='javascript'>" & Environment.NewLine & "window.alert(" & "'" & strMsg & "'" & ")</script>"
pName.Controls.Add(lbl)
End Sub
Public Sub PageClear(ByVal pName As Page)
'-----------------------------------
'Which will Clear the Form
'-----------------------------------
Dim cCount As Control
Dim control As Control
For Each cCount In pName.Controls
For Each control In cCount.Controls
If TypeOf control Is TextBox Then
Dim TextBox As TextBox = control
TextBox.Text = ""
ElseIf TypeOf control Is DropDownList Then
Dim DropDownList As DropDownList = control
DropDownList.SelectedIndex = -1
ElseIf TypeOf control Is ListBox Then
Dim ListBox As ListBox = control
ListBox.SelectedIndex = -1
ElseIf TypeOf control Is RadioButton Then
Dim RadioButton As RadioButton = control
RadioButton.Checked = False
ElseIf TypeOf control Is CheckBox Then
Dim CheckBox As CheckBox = control
CheckBox.Checked = False
ElseIf TypeOf control Is RadDatePicker Then
Dim RadDatePicker As RadDatePicker = control
RadDatePicker.Clear()
RadDatePicker.Calendar.SelectedDates.Clear()
ElseIf TypeOf control Is RadDateTimePicker Then
Dim RadDateTimePicker As RadDateTimePicker = control
RadDateTimePicker.Clear()
RadDateTimePicker.Calendar.SelectedDates.Clear()
End If
Next
Next
End Sub
Public Function CustomEror(ByVal ErrCode As String) As String
If ErrCode = 5 Then
CustomEror = "Invalid procedure call or argument"
ElseIf ErrCode = 6 Then
CustomEror = "Overflow"
ElseIf ErrCode = 7 Then
CustomEror = "Out of memory"
ElseIf ErrCode = 9 Then
CustomEror = "Subscript out of range"
ElseIf ErrCode = 10 Then
CustomEror = "Array fixed or temporarily locked"
ElseIf ErrCode = 11 Then
CustomEror = "Division by zero"
ElseIf ErrCode = 13 Then
CustomEror = "Type mismatch"
ElseIf ErrCode = 14 Then
CustomEror = "Out of string space"
ElseIf ErrCode = 28 Then
CustomEror = "Out of stack space"
ElseIf ErrCode = 35 Then
CustomEror = "Sub or Function not defined"
ElseIf ErrCode = 48 Then
CustomEror = "Error in loading DLL"
ElseIf ErrCode = 51 Then
CustomEror = "Internal error"
ElseIf ErrCode = 53 Then
CustomEror = "File not found"
ElseIf ErrCode = 57 Then
CustomEror = "Device I/O error"
ElseIf ErrCode = 58 Then
CustomEror = "File already exists"
ElseIf ErrCode = 61 Then
CustomEror = "Disk full"
ElseIf ErrCode = 67 Then
CustomEror = "Too many files"
ElseIf ErrCode = 70 Then
CustomEror = "Permission denied"
ElseIf ErrCode = 75 Then
CustomEror = "Path/File access error"
ElseIf ErrCode = 76 Then
CustomEror = "Path not found"
ElseIf ErrCode = 91 Then
CustomEror = "Object variable or With block variable not set"
ElseIf ErrCode = 92 Then
CustomEror = "For loop not initialized"
ElseIf ErrCode = 94 Then
CustomEror = "Invalid use of Null"
ElseIf ErrCode = 322 Then
CustomEror = "Can't create necessary temporary file"
ElseIf ErrCode = 424 Then
CustomEror = "Object required"
ElseIf ErrCode = 429 Then
CustomEror = "ActiveX component can't create object"
ElseIf ErrCode = 430 Then
CustomEror = "Class doesn't support Automation"
ElseIf ErrCode = 432 Then
CustomEror = "File name or class name not found during Automation operation"
ElseIf ErrCode = 438 Then
CustomEror = "Object doesn't support this property or method"
ElseIf ErrCode = 440 Then
CustomEror = "Automation error"
ElseIf ErrCode = 445 Then
CustomEror = "Object doesn't support this action"
ElseIf ErrCode = 446 Then
CustomEror = "Object doesn't support named arguments"
ElseIf ErrCode = 447 Then
CustomEror = "Object doesn't support current local setting"
ElseIf ErrCode = 448 Then
CustomEror = "Named argument not found"
ElseIf ErrCode = 449 Then
CustomEror = "Argument not optional"
ElseIf ErrCode = 450 Then
CustomEror = "Wrong number of arguments or invalid property assignment"
ElseIf ErrCode = 451 Then
CustomEror = "Object not a collection"
ElseIf ErrCode = 453 Then
CustomEror = "Specified DLL function not found"
ElseIf ErrCode = 455 Then
CustomEror = "Code resource lock error"
ElseIf ErrCode = 457 Then
CustomEror = "This key already associated with an element of this "
ElseIf ErrCode = 458 Then
CustomEror = "Variable uses an Automation type not supported in VBScript"
ElseIf ErrCode = 500 Then
CustomEror = "Variable is undefined"
ElseIf ErrCode = 501 Then
CustomEror = "Illegal assignment"
ElseIf ErrCode = 502 Then
CustomEror = "Object not safe for scripting"
ElseIf ErrCode = 503 Then
CustomEror = "Object not safe for initializing"
ElseIf ErrCode = 1001 Then
CustomEror = "Out of memory"
ElseIf ErrCode = 1002 Then
CustomEror = "Syntax error"
ElseIf ErrCode = 1003 Then
CustomEror = "Expected ':'"
ElseIf ErrCode = 1004 Then
CustomEror = "Expected ';'"
ElseIf ErrCode = 1005 Then
CustomEror = "Expected '('"
ElseIf ErrCode = 1006 Then
CustomEror = "Expected ')'"
ElseIf ErrCode = 1007 Then
CustomEror = "Expected ']'"
ElseIf ErrCode = 1008 Then
CustomEror = "Expected '{'"
ElseIf ErrCode = 1009 Then
CustomEror = "Expected '}'"
ElseIf ErrCode = 1010 Then
CustomEror = "Expected identifier"
ElseIf ErrCode = 1011 Then
CustomEror = "Expected '='"
ElseIf ErrCode = 1012 Then
CustomEror = "Expected 'If'"
ElseIf ErrCode = 1013 Then
CustomEror = "Expected 'To'"
ElseIf ErrCode = 1014 Then
CustomEror = "Expected 'End'"
ElseIf ErrCode = 1015 Then
CustomEror = "Expected 'Function'"
ElseIf ErrCode = 1016 Then
CustomEror = "Expected 'Sub'"
ElseIf ErrCode = 1017 Then
CustomEror = "Expected 'Then'"
ElseIf ErrCode = 1018 Then
CustomEror = "Expected 'Wend'"
ElseIf ErrCode = 1019 Then
CustomEror = "Expected 'Loop'"
ElseIf ErrCode = 1020 Then
CustomEror = "Expected 'Next'"
ElseIf ErrCode = 1021 Then
CustomEror = "Expected 'Case'"
ElseIf ErrCode = 1022 Then
CustomEror = "Expected 'Select'"
ElseIf ErrCode = 1023 Then
CustomEror = "Expected expression"
ElseIf ErrCode = 1024 Then
CustomEror = "Expected statement"
ElseIf ErrCode = 1025 Then
CustomEror = "Expected end of statement"
ElseIf ErrCode = 1026 Then
CustomEror = "Expected integer constant"
ElseIf ErrCode = 1027 Then
CustomEror = "Expected 'While' or 'Until'"
ElseIf ErrCode = 1028 Then
CustomEror = "Expected 'While', 'Until', or end of statement"
ElseIf ErrCode = 1029 Then
CustomEror = "Too many locals or arguments"
ElseIf ErrCode = 1030 Then
CustomEror = "Identifier too long"
ElseIf ErrCode = 1031 Then
CustomEror = "Invalid number"
ElseIf ErrCode = 1032 Then
CustomEror = "Invalid character"
ElseIf ErrCode = 1033 Then
CustomEror = "Unterminated string constant"
ElseIf ErrCode = 1034 Then
CustomEror = "Unterminated comment"
ElseIf ErrCode = 1035 Then
CustomEror = "Nested comment"
ElseIf ErrCode = 1037 Then
CustomEror = "Invalid use of 'Me' keyword"
ElseIf ErrCode = 1038 Then
CustomEror = "'Loop' without 'Do'"
ElseIf ErrCode = 1039 Then
CustomEror = "Invalid 'Exit' statement"
ElseIf ErrCode = 1040 Then
CustomEror = "Invalid 'For' loop control variable"
ElseIf ErrCode = 1041 Then
CustomEror = "Name redefined"
ElseIf ErrCode = 1042 Then
CustomEror = "Must be first statement on the line"
ElseIf ErrCode = 1043 Then
CustomEror = "Can't assign to non-ByVal argument"
ElseIf ErrCode = 1044 Then
CustomEror = "Can't use parens when calling a Sub"
ElseIf ErrCode = 1045 Then
CustomEror = "Expected literal constant"
ElseIf ErrCode = 1046 Then
CustomEror = "Expected 'In'"
ElseIf ErrCode = 32766 Then
CustomEror = "TRUE"
ElseIf ErrCode = 32767 Then
CustomEror = "FALSE"
ElseIf ErrCode = 32811 Then
CustomEror = "Element not found"
Else
CustomEror = "Sorry, Unexception Error found"
End If
End Function
End Class
DB script-
create table tblpolicy(policyid int primary key,policyname varchar(30),uid int,providerid int foreign key references providertbl(providerid))
create table tblprovider(providerid int primary key,providername varchar(30))
create proc sp_AutoGenerateGrdVw(@policyid int)
as
begin
select distinct po.policyid,po.policyname,pr.providername,pr.providerid,po.[uid] from tblpolicy po inner join tblprovider pr on po.providerid=pr.providerid
where po.policyid=@policyid
end
No comments:
Post a Comment