Saturday, October 18, 2014

search button

Posted by Gnani Palepu  |  No comments


 if you want more related search please click here  
 please help to other  
 http://scriptquery.blogspot.in/  

 Search all button model using 3-tier in vb.net and javascript also with out using master page  
 ----------------------------------------------------------------------------------------------------------------  
 entire code is here with us, plese dont confuse,  
 just fallow me okay ,  
 here i am giving (sp, request and responese, DAO,BO,UI) full coding  
  just fallow just 5 step below  
 1)actually if we select the search all button, it is redirected to some this page.  
 2)first we need to write the stored procedure ( through particular table)  
 3)write request and response(give datatable in each) after DAO,BO  
 4) create one page(redirected page)  
 this is normal page with out master page( okay)  
 step 1:  
 -------  
 copy this code and paste it in your vb source file  
 <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Find.aspx.vb" Inherits="Filter"  
   Buffer="true" %>  
 <%@ Register Namespace="Telerik.Web.UI" TagPrefix="UI" %>  
 <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>  
 <%@ 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>Leave Application</title>  
   <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>  
   <style type="text/css">  
     .pdfButton  
     {  
       color: White;  
       border: 0;  
       height: 48px;  
       background: url('Images/pdfLogo.jpg') no-repeat center;  
       cursor: pointer;  
     }  
   </style>  
   <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">  
     <script type="text/javascript">  
       function Filter(colName, filtertxt) {  
         var filterTxt = document.getElementById(filtertxt);  
         var MasterTable = $find("<%= GridList.ClientID %>").get_masterTableView();  
         var hidden = document.getElementById('<%=Hidden1.ClientID %>');  
         hidden.value = colName;  
         if (filterTxt.value.length > 0) {  
           MasterTable.filter(colName, filterTxt.value, Telerik.Web.UI.GridFilterFunction.Contains);  
         }  
         else {  
           MasterTable.filter(colName, filterTxt.value, Telerik.Web.UI.GridFilterFunction.NoFilter);  
         }  
       }  
       function FocusFilter(filter) {  
         var input = document.getElementById(filter);  
         var cursorPosition = document.getElementById(filter).value.length;  
         if (input.createTextRange) {  
           var FieldRange = input.createTextRange();  
           FieldRange.move('character', input.value.length);  
           FieldRange.select(0, input.value.length);  
         }  
         else {  
           if (input.selectionStart) {  
             input.focus();  
             input.setSelectionRange(cursorPosition, cursorPosition);  
             // alert("mozila");  
           }  
           else {  
             input.focus();  
             input.setSelectionRange(cursorPosition, cursorPosition);  
             // alert("mozila1");  
           }  
         }  
       }  
     </script>  
     <script type="text/javascript">  
       function OnColumnClick(sender, eventArgs) {  
         var columnUniqueName = eventArgs.get_gridColumn().get_uniqueName();  
         alert("This column will be Freeze (or) UnFreeze if already Freezed");  
         var oldClass = eventArgs.get_gridColumn().get_element().className;  
         eventArgs.get_gridColumn().get_element().className = oldClass + " doubleClickedColumnHeader";  
         $find("<%= GridList.ClientID %>").get_masterTableView().fireCommand("FreezeCommand", getColumnIndexByUniqueName(columnUniqueName) + "," + columnUniqueName);  
       }  
       function getColumnIndexByUniqueName(columnName) {  
         var masterTableView = $find('<%= GridList.ClientID %>').get_masterTableView();  
         var column = masterTableView.getColumnByUniqueName(columnName);  
         var element = column.get_element();  
         return element.cellIndex;  
       }  
       function cellSelecting(sender, eventArgs) {  
         var columnUniqueName = eventArgs.get_column();  
         var ColumnName = columnUniqueName.get_uniqueName();  
         alert(ColumnName);  
         $find("<%= GridList.ClientID %>").get_masterTableView().fireCommand("FreezeCommand", getColumnIndexByUniqueName(ColumnName) + "," + ColumnName);  
       }  
     </script>  
   </telerik:RadCodeBlock>  
   <telerik:RadCodeBlock ID="RadCodeBlock2" runat="server">  
     <script type="text/javascript">  
       document.onkeydown = checkShortcuts;  
       function checkShortcuts(event) {  
         switch (event.keyCode) {  
           case 119:  
             // GetAccessKeyValues(27);  
             enterKeyPressed();  
             break;  
           default:  
             break;  
         }  
       }  
       //      function enterKeyPressed() {  
       //        document.getElementById('<%= btnImgBack.ClientID %>').click();  
       //      }  
       function GetAccessKeyValues(key) {  
         if (key == 27) {  
           document.getElementById('HiddentJsValue').value = 'ESC';  
         }  
       }  
     </script>  
   </telerik:RadCodeBlock>  
   <link href="../../CSS/headers.css" rel="stylesheet" type="text/css" />  
 </head>  
 <body onload="init();">  
   <div id="loading" style="position: absolute; width: 100%; text-align: center; top: 280px;  
     left: -1px;" enableviewstate="false">  
     <asp:Image ID="Image3" runat="server" ImageUrl="~/Images/ajax-loader.gif" EnableViewState="false" />  
   </div>  
   <script language="javascript" type="text/javascript">  
     var ld = (document.all);  
     var ns4 = document.layers;  
     var ns6 = document.getElementById && !document.all;  
     var ie4 = document.all;  
     if (ns4)  
       ld = document.loading;  
     else if (ns6)  
       ld = document.getElementById("loading").style;  
     else if (ie4)  
       ld = document.all.loading.style;  
     function init() {  
       if (ns4) { ld.visibility = "hidden"; }  
       else if (ns6 || ie4) ld.display = "none";  
     }  
   </script>  
   <form id="form1" runat="server">  
   <div>  
     <center>  
       <asp:UpdateProgress ID="UpdateProgress" runat="server">  
         <ProgressTemplate>  
           <div id="loading" style="position: absolute; width: 100%; text-align: center; top: 280px;  
             left: -1px;" enableviewstate="false">  
             <asp:Image ID="Image1" runat="server" ImageUrl="~/Images/ajax-loader.gif" EnableViewState="false" />  
           </div>  
         </ProgressTemplate>  
       </asp:UpdateProgress>  
       <table>  
         <tr>  
           <td width="100%">  
             <asp:ScriptManager runat="server" ID="scriptdd">  
               <CompositeScript>  
                 <Scripts>  
                   <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />  
                   <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />  
                   <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />  
                 </Scripts>  
               </CompositeScript>  
             </asp:ScriptManager>  
             <telerik:RadWindowManager ID="RadWindowManagerAlert" runat="server" EnableShadow="true">  
             </telerik:RadWindowManager>  
             <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">  
               <AjaxSettings>  
                 <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">  
                   <UpdatedControls>  
                     <telerik:AjaxUpdatedControl ControlID="GridList" LoadingPanelID="gridLoadingPanel">  
                     </telerik:AjaxUpdatedControl>  
                   </UpdatedControls>  
                 </telerik:AjaxSetting>  
               </AjaxSettings>  
             </telerik:RadAjaxManager>  
             <telerik:RadAjaxLoadingPanel runat="server" ID="gridLoadingPanel">  
             </telerik:RadAjaxLoadingPanel>  
             <asp:HiddenField ID="HiddentJsValue" runat="server" />  
             <asp:LinkButton runat="server" ID="LbtnOpenAdd" CausesValidation="false"></asp:LinkButton>  
           </td>  
         </tr>  
       </table>  
       <%--<div class="header">  
         <div class="locName">  
           <asp:Label runat="server" Text="" ID="lblLocName"></asp:Label>  
         </div>  
         <div class="headerRgt">  
           <a href="../Menu/Menu.aspx">Home</a> | <a href="../../Login.aspx">Logout</a> | <a  
             href="#">Help</a>  
           <p>  
             <asp:Label ID="lblusername" runat="server" Font-Size="12px" ForeColor="Purple"></asp:Label>  
           </p>  
         </div>  
       </div>--%>  
       <div style= "background-image: url(~/images/Master/header_bg.jpg); width:100%; height:80px;">  
       </div>  
       <table width="1000px">  
         <tr>  
           <td width="100%" align="center">  
             <input id="Hidden1" runat="server" name="Hidden1" type="hidden" />  
             <telerik:RadGrid ID="GridList" runat="server" AllowFilteringByColumn="True" GridLines="Both"  
               AllowSorting="true" AllowPaging="True" PageSize="100" CellPadding="0" Width="1250px"  
               Height="550px">  
               <GroupingSettings CaseSensitive="false"></GroupingSettings>  
               <MasterTableView AutoGenerateColumns="true" HeaderStyle-HorizontalAlign="Center"  
                 CellPadding="1" FilterItemStyle-HorizontalAlign="Center">  
                 <Columns>  
                   <telerik:GridButtonColumn Text="Select" CommandName="SELROW" />  
                 </Columns>  
               </MasterTableView>  
               <ClientSettings>  
                 <Scrolling AllowScroll="True" UseStaticHeaders="True" />  
                 <ClientEvents OnColumnClick="OnColumnClick" />  
               </ClientSettings>  
             </telerik:RadGrid>  
           </td>  
         </tr>  
         <tr>  
           <td style="width: 1340px">  
             <table style="border-style: solid; border-width: 1px; width: 100%">  
               <tr>  
                 <td style="width: 20%">  
                 </td>  
                 <td style="width: 60%" align="center" valign="top">  
                   <table>  
                     <tr>  
                       <td>  
                         <telerik:RadComboBox runat="server" Width="150px" ID="cbChangeSkin" AutoPostBack="true"  
                           EmptyMessage="Change Skin" Filter="Contains" Label="Change Grid Skin">  
                           <Items>  
                             <telerik:RadComboBoxItem Value="0" Text="Default" Selected="true" />  
                             <telerik:RadComboBoxItem Value="1" Text="WebBlue" />  
                             <telerik:RadComboBoxItem Value="2" Text="Windows7" />  
                             <telerik:RadComboBoxItem Value="3" Text="Web20" />  
                             <telerik:RadComboBoxItem Value="4" Text="Vista" />  
                             <telerik:RadComboBoxItem Value="5" Text="Telerik" />  
                             <telerik:RadComboBoxItem Value="6" Text="Sunset" />  
                             <telerik:RadComboBoxItem Value="7" Text="Simple" />  
                             <telerik:RadComboBoxItem Value="8" Text="Silk" />  
                             <telerik:RadComboBoxItem Value="9" Text="Outlook" />  
                             <telerik:RadComboBoxItem Value="10" Text="Office2010Silver" />  
                             <telerik:RadComboBoxItem Value="11" Text="Office2010Blue" />  
                             <telerik:RadComboBoxItem Value="12" Text="Office2007" />  
                             <telerik:RadComboBoxItem Value="13" Text="MetroTouch" />  
                             <telerik:RadComboBoxItem Value="14" Text="Metro" />  
                             <telerik:RadComboBoxItem Value="15" Text="Glow" />  
                             <telerik:RadComboBoxItem Value="16" Text="Black" />  
                             <telerik:RadComboBoxItem Value="17" Text="BlackMetroTouch" />  
                           </Items>  
                         </telerik:RadComboBox>  
                       </td>  
                       <td>  
                         <asp:ImageButton runat="server" ID="btnImgExcel" ImageUrl="~/Images/excel.png" Height="30px"  
                           Width="50px" />  
                         &nbsp;&nbsp;&nbsp;  
                         <asp:ImageButton runat="server" ID="btnImgWord" ImageUrl="~/Images/word.png" Height="30px"  
                           Width="50px" />  
                         &nbsp;&nbsp;&nbsp;  
                         <asp:ImageButton runat="server" ID="btnImgBack" ImageUrl="~/Images/back.jpg" Height="30px"  
                           Width="50px" />  
                         <%-- &nbsp;&nbsp;&nbsp;  
                         <asp:ImageButton runat="server" ID="btnImgPdf" ImageUrl="~/Images/pdf.png" Visible="false" />--%>                             
                       </td>  
                     </tr>  
                   </table>  
                 </td>  
                 <td align="right" style="width: 20%">  
                   <asp:Label runat="server" ID="lblTotNoRc" ForeColor="Blue" Font-Bold="true"></asp:Label>  
                 </td>  
           </tr> </table> </td>  
         </tr>  
         <%--        <tr>  
           <td width="100%">  
             <br />  
           </td>  
         </tr>  
         <tr>  
           <td align="center" style="width: 400px">  
             <asp:DropDownList ID="Ddlexport" runat="server">  
               <asp:ListItem Text="Select" Value="0"></asp:ListItem>  
               <asp:ListItem Text="Excel" Value="1"></asp:ListItem>  
                <asp:ListItem Text="Email" Value="2"></asp:ListItem>  
             </asp:DropDownList>  
             <asp:Button ID="BtnExport" runat="server" Text="Export" CausesValidation="false"  
               CssClass="btn-primary" />  
             <telerik:RadButton runat="server" ID="BtnBack" Text="Back(F8)">  
             </telerik:RadButton>  
           </td>  
         </tr>--%>  
       </table>  
     </center>  
   </div>  
   </form>  
 </body>  
 </html>  
 this is code view of this page.  
 step 2:  
 -------  
 #Region "Includes"  
 Imports System  
 Imports System.Data  
 Imports System.Web.UI.WebControls  
 Imports Telerik.Web.UI  
 'Imports SMIC.Common  
 Imports LMSBEntities  
 Imports LMSBobjects  
 Imports Exportexcel  
 #End Region  
 #Region "public class"  
 Partial Class Filter  
   Inherits System.Web.UI.Page  
   Private dt As DataTable  
   Dim strSql As String  
   'Dim clsSvt As New svtLibrary  
   'Dim cls As ClsSvtConstant  
   Dim sortExpr As GridSortExpression  
   Private isPdfExport As Boolean = False  
   Dim url As String  
   Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load  
     url = Request.QueryString("ARGFILLIDSTFACURL")  
     GridList.MasterTableView.DataKeyNames = New String() {Session("DataKeyName")}  
     If Not IsPostBack Then  
       Session("filterDt") = Nothing  
       'lblusername.Text = "Welcome : " & Session("UserCode").ToString()  
       'lblLocName.Text = Session("LocName").ToString()  
       'lbltitle.Text = Session("PageCaption")  
       Try  
         If Request.Cookies("Skin" & Session("UserID")).ToString() IsNot Nothing Then  
           Try  
             GridList.Skin = Request.Cookies("Skin" & Session("UserID")).Value  
             cbChangeSkin.FindItemByText(Request.Cookies("Skin" & Session("UserID")).Value).Selected = True  
           Catch ex As Exception  
             GridList.Skin = "WebBlue"  
             cbChangeSkin.FindItemByText("WebBlue").Selected = True  
           End Try  
         Else  
           GridList.Skin = "WebBlue"  
           cbChangeSkin.FindItemByText("WebBlue").Selected = True  
         End If  
       Catch ex As Exception  
         GridList.Skin = "WebBlue"  
         cbChangeSkin.FindItemByText("WebBlue").Selected = True  
       End Try  
     End If  
   End Sub  
   Protected Sub GridList_ItemCommand(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles GridList.ItemCommand  
     If e.CommandName = "SELROW" Then  
       Dim item As GridEditableItem = DirectCast(e.Item, GridEditableItem)  
       Dim stid As [String] = item.GetDataKeyValue(Session("DataKeyName")).ToString()  
       Session("BackID") = ""  
       If Session("PageType") = 2 Then  
         Session.Remove("PageType")  
       Else  
         Session.Remove("PageType")  
       End If  
       Response.Redirect(url & "?ARGFILLIDSTFAC=" & stid)  
     End If  
     If e.CommandName = "FreezeCommand" Then  
       Dim argstr As String() = e.CommandArgument.ToString().Split(",")  
       For Each column As GridColumn In GridList.MasterTableView.RenderColumns  
         If column.UniqueName.ToString() = argstr(1) Then  
           If Convert.ToInt32(argstr(0)) = GridList.ClientSettings.Scrolling.FrozenColumnsCount Then  
             GridList.ClientSettings.Scrolling.FrozenColumnsCount = 0  
             column.ItemStyle.ForeColor = Drawing.Color.Black  
           Else  
             GridList.ClientSettings.Scrolling.FrozenColumnsCount = Convert.ToInt32(argstr(0))  
             column.ItemStyle.ForeColor = Drawing.Color.Green  
           End If  
           GridList.Rebind()  
         End If  
       Next  
     End If  
     If e.CommandName = RadGrid.ExportToPdfCommandName Then  
       isPdfExport = True  
     End If  
   End Sub  
   Protected Sub GridList_NeedDataSource(ByVal source As Object, ByVal e As GridNeedDataSourceEventArgs) Handles GridList.NeedDataSource  
     Try  
       'Dim argPra As String() = New String() {"@Msp_Qry"}, argVal As String() = New String() {Session("StrSearchSql")}  
       Dim request = New LMSSearchallRequest()  
       request.EmpID = Session("EmpID")  
       Dim obj = New LMSBO()  
       Dim response = obj.SearchAll(request)  
       Session("filterDt") = response.SearchAllDt 'clsSvt.GetDataTableFromSPWithParameters(Common.SpNames.MSPgetDtFromFormedQuery, argPra, argVal)  
       Me.GridList.DataSource = Session("filterDt")  
     Catch ex As Exception  
     End Try  
   End Sub  
   Protected Sub GridList_ColumnCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridColumnCreatedEventArgs) Handles GridList.ColumnCreated  
     e.Column.ShowFilterIcon = False  
     e.Column.FilterControlWidth = 100  
     Try  
       If e.Column.DataTypeName = "System.DateTime" Then  
         Dim boundColumn As GridBoundColumn = CType(e.Column, GridBoundColumn)  
         boundColumn.DataFormatString = "{0:dd MMM yyyy}"  
       End If  
     Catch ex As Exception  
     End Try  
     Try  
       If UCase(e.Column.UniqueName) = UCase(Session("DataKeyName")) Then  
         Dim boundColumn As GridBoundColumn = CType(e.Column, GridBoundColumn)  
         boundColumn.Display = False  
       End If  
     Catch ex As Exception  
     End Try  
   End Sub  
   Protected Sub GridList_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles GridList.ItemDataBound  
     If TypeOf e.Item Is GridFilteringItem Then  
       Dim filterItem As GridFilteringItem = CType(e.Item, GridFilteringItem)  
       For Each col As GridColumn In GridList.MasterTableView.RenderColumns  
         If col.UniqueName <> "ExpandColumn" And col.UniqueName <> "RowIndicator" Then  
           Try  
             Dim filtertxt As TextBox = CType(filterItem(col.UniqueName).Controls(0), TextBox)  
             filtertxt.Attributes.Add("onkeyup", "javascript:Filter('" + col.UniqueName + "','" + filtertxt.ClientID + "');")  
           Catch ex As Exception  
           End Try  
         End If  
       Next  
     End If  
   End Sub  
   Protected Sub GridList_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridList.PreRender  
     If Hidden1.Value <> "" Then  
       Try  
         Dim filter As GridFilteringItem = CType(GridList.MasterTableView.GetItems(GridItemType.FilteringItem)(0), GridFilteringItem)  
         Dim txtfilter As TextBox = CType(filter(Hidden1.Value).Controls(0), TextBox)  
         txtfilter.Focus()  
         txtfilter.Attributes.Add("onfocus", "javascript:FocusFilter('" + txtfilter.ClientID + "');")  
       Catch ex As Exception  
       End Try  
     End If  
   End Sub  
 #Region "Export Excel"  
   Protected Sub btnImgExcel_Click(sender As Object, e As System.Web.UI.ImageClickEventArgs) Handles btnImgExcel.Click  
     Dim dt As New DataTable()  
     dt = ExportGridData()  
     Dim response = ExporttoExcel(dt, "LeaveDetails", 1) '1 for Excel  
   End Sub  
 #End Region  
 #Region "Export Word"  
   Protected Sub btnImgWord_Click(sender As Object, e As System.Web.UI.ImageClickEventArgs) Handles btnImgWord.Click  
     Dim dt As New DataTable()  
     dt = ExportGridData()  
     Dim response = ExporttoExcel(dt, "LeaveDetails", 2) '1 for Word  
   End Sub  
 #End Region  
 #Region "Export PDF"  
   '  Protected Sub btnImgPdf_Click(sender As Object, e As System.Web.UI.ImageClickEventArgs) Handles btnImgPdf.Click  
   '    ' Dim response = ExportFiles.ExporttoExcel(Session("filterDt"), Session("Prefix"), 3) '1 for PDF  
   '  End Sub  
 #End Region  
 #Region "Back"  
   Protected Sub btnImgBack_Click(sender As Object, e As System.Web.UI.ImageClickEventArgs) Handles btnImgBack.Click  
     Response.Redirect(url)  
   End Sub  
 #End Region  
 #Region "Change Skin of grid"  
   Protected Sub cbChangeSkin_SelectedIndexChanged(sender As Object, e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs) Handles cbChangeSkin.SelectedIndexChanged  
     Try  
       GridList.Skin = cbChangeSkin.SelectedItem.Text  
       GridList.Rebind()  
       Response.Cookies("Skin" & Session("UserID")).Value = cbChangeSkin.SelectedItem.Text  
       Response.Cookies("Skin" & Session("UserID")).Expires = DateTime.Now.AddDays(365)  
     Catch ex As Exception  
     End Try  
   End Sub  
 #End Region  
 #Region "Export Data Table"  
   Private Function ExportGridData() As DataTable  
     Dim dt = New DataTable()  
     dt = Session("filterDt")  
     Try  
       dt.Columns.Remove(Session("DataKeyName"))  
     Catch ex As Exception  
     End Try  
     Try  
       dt.Columns.Remove("AddedOn")  
     Catch ex As Exception  
     End Try  
     Try  
       dt.Columns.Remove("AddedBy")  
     Catch ex As Exception  
     End Try  
     Try  
       dt.Columns.Remove("PartyID")  
     Catch ex As Exception  
     End Try  
     Try  
       dt.Columns.Remove("PartyDocID")  
     Catch ex As Exception  
     End Try  
     Try  
       dt.Columns.Remove("AddID")  
     Catch ex As Exception  
     End Try  
     Try  
       dt.Columns.Remove("LOCID")  
     Catch ex As Exception  
     End Try  
     Try  
       dt.Columns.Remove("BOOTPWD")  
     Catch ex As Exception  
     End Try  
     Try  
       dt.Columns.Remove("SEID")  
     Catch ex As Exception  
     End Try  
     Return dt  
   End Function  
 #End Region  
   Public Shared Function ExporttoExcel(ByVal dt As DataTable, ByVal filename As String, exportType As Integer, Optional ByVal type As Integer = 0) As Boolean  
     Try  
       Dim itemRequest = New BusinessEntities.ExcelRequest()  
       itemRequest.ItemList = dt  
       itemRequest.FileName = filename  
       itemRequest.Heading = ""  
       itemRequest.Address = ""  
       itemRequest.ReportsName = filename  
       itemRequest.FromDate = System.DateTime.Now.ToString("dd MMM yyyy")  
       itemRequest.ToDate = System.DateTime.Now.ToString("dd MMM yyyy")  
       itemRequest.FooterName = ""  
       itemRequest.AdressSplit = ","  
       itemRequest.Type = type  
       itemRequest.FooterType = True  
       Dim resObj = New Excel()  
       If exportType = 1 Then  
         resObj.ExportToExcel(itemRequest)  
       ElseIf exportType = 2 Then  
         resObj.ExportToWord(itemRequest)  
       ElseIf exportType = 3 Then  
         resObj.ExportToPDF(itemRequest)  
       End If  
       Return True  
     Catch ex As Exception  
       Return False  
     End Try  
   End Function  
 End Class  
 #End Region  
 step 3:  
 ------  
 getting the datatable (DAO) layer  
 -----------------------  
 #region Search All  
     public LMSSearchallResponse SearchAll(LMSSearchallRequest request)  
     {  
       var response = new LMSSearchallResponse();  
       SqlCommand cmd = new SqlCommand();  
       var dt = new DataTable();  
       var da = new SqlDataAdapter();  
       con.Open();  
       cmd = new SqlCommand("USP_GET_SEARCH_ALL", con);  
       cmd.CommandType = CommandType.StoredProcedure;  
       cmd.Parameters.Add("@EMPID", SqlDbType.VarChar).Value = request.EmpID ;  
       //cmd.Parameters.Add("@Type", SqlDbType.Int).Value = request.Type;  
       da.SelectCommand = cmd;  
       da.Fill(dt);  
       response.SearchAllDt = dt;  
       con.Close();  
       return response;  
     }  
     #endregion Search All  
 step 4:)  
 --------  
 calling in BO  
 #region Search All  
     public LMSSearchallResponse SearchAll(LMSSearchallRequest request)  
     {  
       var response = new LMSSearchallResponse();  
       var obj = new LMSDAO();  
       response = obj.SearchAll(request);  
       return response;  
     }  
     #endregion Search All  
 step 5:  
 -------  
 Sp  
 ----  
 USE [LMS]  
 GO  
 /****** Object: StoredProcedure [dbo].[USP_GET_SEARCH_ALL]  ******/  
 SET ANSI_NULLS ON  
 GO  
 SET QUOTED_IDENTIFIER ON  
 GO  
 -- =============================================  
 -- Author : GNANI  
 -- Create date : 07/06/2014  
 -- Description : Stored Procedure to USP_GET_SEARCH_ALL  
 -- =============================================  
 CREATE PROCEDURE [dbo].[USP_GET_SEARCH_ALL]  
 @EMPID INT = NULL  
 AS  
 BEGIN  
  BEGIN  
  SELECT * FROM EMPLEAVEDETAILS  
  WHERE EMPID = @EMPID order by EntryDate desc  
  END    
 END  

 if you want more related search please click here  
 please help to other  
 http://scriptquery.blogspot.in/  


11:36 PM Share:

0 comments:

Get updates in your email box
Complete the form below, and we'll send you the best coupons.

Deliver via FeedBurner
Proudly Powered by Blogger.
back to top