WebConfig
------- -Database set -----------
import system.data
import system.sqlclient
----- Connection Testing ---------
-- For MS Access ----
Dim con as new oledb.oleDbConnection
Dim ds As New DataSet
Dim da As OleDb.OleDbDataAdapter
Dim strSQL as String
da = New OleDb.OleDbDataAdapter(sql, con)
Con.ConnectionString = "Provider=Microsoft.Jet.OleDB.4.0;Data Source=C:\AddressBook.mdb"
con.open()
sql = "SELECT * from tbl"
da = New OleDb.OleDbDataAdapter(sql, con)
con.close()
------------- To View record ---------------
Dim ds As New DataSet
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds,"Employee")
con.Close()
txtFname.text = ds.table("AddressBook").Rows.(0).Item(1)
or
txtFname.text = ds.table("AddressBook").Rows.(0).Item("Fname")
------------------- Create Function SQL storedProc ----------------------
Public Shared Function GetAgentName(ByVal strTeam As String) As DataTable
Dim _cn As New SqlConnection(ConfigurationManager.ConnectionStrings.Item("RetentionCRTConnectionString").ConnectionString)
Dim retTable As New DataTable
Try
Dim cmd As New SqlCommand("usp_GetAgentName", _cn)
With cmd
.CommandType = CommandType.StoredProcedure
.Parameters.AddWithValue("vrTeam", strTeam)
End With
Dim da As New SqlDataAdapter(cmd)
da.Fill(retTable)
_cn.Close()
Catch ex As Exception
HttpContext.Current.Session("Error") = "Procedure : GetCancelReasons
" & ex.Message
HttpContext.Current.Response.Redirect("Error.aspx")
End Try
Return retTable
End Function
---------------------- With return Value ----------------------------------
Public Shared Function GetSaveRateOld(ByVal AgentID As Integer) As String()
Dim retVal(2) As String
Dim _cn As New SqlConnection(ConfigurationManager.ConnectionStrings.Item("RetentionCRTConnectionString").ConnectionString)
Try
Dim cmd As New SqlCommand("usp_GetSaveRateOld", _cn)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.AddWithValue("AgentID", AgentID)
If _cn.State = ConnectionState.Closed Then
_cn.Open()
End If
Dim reader As SqlDataReader = cmd.ExecuteReader()
reader.Read()
retVal(0) = reader.Item("IsCount").ToString
retVal(1) = reader.Item("IsTermed").ToString
reader.Close()
_cn.Close()
Catch ex As Exception
HttpContext.Current.Session("Error") = "Procedure : GetSaveRateOld
" & ex.Message
HttpContext.Current.Response.Redirect("Error.aspx")
End Try
Return retVal
End Function
----------------- Add,Edit,update ----------------------------
Dim cmd As New SqlCommand(strSQL, _cn)
If _cn.State = ConnectionState.Closed Then
_cn.Open()
End If
cmd.ExecuteNonQuery()
------------------ DataBind ---------------------------------
Dim dt As DataTable = AgentDLC.GetAgentName(cboTL.SelectedValue)
cboAgent.Items.Clear()
cboAgent.Items.Add("")
For Each dr As DataRow In dt.Rows
cboAgent.Items.Add(New ListItem((dr.Item("AgentName")), (dr.Item("UserId"))))
Next
------------------ Excel Report --------------------------------
'Add Web Reference COM MS Excel
Dim dsExport As New DataSet()
Dim tw As New System.IO.StringWriter()
Dim hw As New System.Web.UI.HtmlTextWriter(tw)
Dim dgReports As New DataGrid()
dgReports.DataSource = AgentDLC.GetCallReportTest(strSQL)
dgReports.DataBind()
dgReports.DataBind()
hw.WriteLine(" Vonage Call Tracker System Report ")
' Get the HTML for the control.
dgReports.HeaderStyle.Font.Bold = True
dgReports.RenderControl(hw)
' Write the HTML back to the browser.
Response.ContentType = "application/vnd.ms-excel"
Me.EnableViewState = False
Response.Write(tw.ToString())
Response.End()
------------------ Table Style ---------------------------------
BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px"
CellPadding="3" GridLines="Vertical" Font-Names="Verdana" Font-Size="X-Small"
AllowPaging="false" >
----------------- Table With Link and Number --------------------
PageSize="5"
PagerStyle-Mode="NumericPages"
PagerStyle-PageButtonCount="5"
PagerStyle-HorizontalAlign="Right"
Width="616px"
BackColor="White"
BorderColor="#999999"
BorderStyle="None"
BorderWidth="1px"
CellPadding="3"
Font-Names="Verdana"
Font-Size="X-Small"
GridLines="Vertical"
OnPageIndexChanged="dgWorkOrder_pageIndexChanged"
>
Sub dgWorkOrder_pageIndexChanged(ByVal s As Object, ByVal e As DataGridPageChangedEventArgs)
dgWorkOrder.CurrentPageIndex = e.NewPageIndex
BindWorkOrder()
End Sub
Sub BindWorkOrder()
Dim cn As New SqlConnection(ConfigurationManager.ConnectionStrings.Item("ConnStrDB").ConnectionString)
lblUser.Text = clsUI.GetLoginDet(Session("UserLogin"))
Dim PendingWorkTable As New DataTable
cn.Open()
Dim cmd As New SqlCommand("Select fid,fid [REF.NO.],fdate [DATE FILED],fComment SUBJECT,fReply REPLY,fstatus STATUS from tblFeedback order by fdate desc", cn)
With cmd
.CommandType = CommandType.Text
End With
Dim da As New SqlDataAdapter(cmd)
Dim dt As New DataTable
da.Fill(dt)
dgWorkOrder.DataSource = dt
dgWorkOrder.DataBind()
cmd.Dispose()
cn.Close()
End Sub
-------------------- Table With Picture ----------------------
- GridView -
top: 161px" Width="650px" Font-Names="Verdana" Font-Size="Smaller">
datanavigateurlformatstring="view.aspx?id={0}"
Target="_blank"
DataNavigateUrlFields = "id" />
datanavigateurlformatstring="view.aspx?id={0}"
Target="_blank"
DataNavigateUrlFields = "id" />
Function formaturl(ByVal strarguement) As String
Return ("Image.aspx?id=" & strarguement)
End Function
- Image.aspx -
Dim strimageid As String = Request.QueryString("id")
Dim cn As New SqlConnection("Server=vxiphsql1;Database=hr;Uid=sa;Pwd=vx1PHs@;")
Dim cmd3 As SqlCommand
cn.Open()
cmd3 = New SqlCommand("select * from ImageLibrary where FileName= '" & strimageid & "'", cn)
Dim rdimg As SqlDataReader
rdimg = cmd3.ExecuteReader
Do While (rdimg.Read())
Response.BinaryWrite(rdimg.Item("FileImage"))
Loop
cn.Close()
- DetailView.aspx -
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim strSQL As String
Dim id As String = Request.QueryString("id")
strSQL = " SELECT a.id,Lname + ', ' + Fname + ' ' + Mname Name,Position_Title,Team ,isnull((Select esName from empStatus Where Status = esCode),'ACTIVE') Status,a.Comments,fileimage,filename " & _
" from employee A,inactive B,imagelibrary C where a.id like '%" & id & "%' " & _
" and a.id *= b.id " & _
" and cast(a.id as varchar(7)) *= filename " & _
" "
Dim cn As New SqlConnection("Server=vxiphsql1;Database=hr;Uid=sa;Pwd=vx1PHs@;")
cn.Close()
Dim cmd As SqlCommand = New SqlCommand(strSQL, cn)
cmd.Connection.Open()
planDetails.DataSource = cmd.ExecuteReader()
planDetails.DataBind()
'If cmd.ExecuteReader.HasRows = True Then
' gvEmployee.DataSource = cmd.ExecuteReader()
' gvEmployee.DataBind()
'Else
' lblstatus.Text = "No Record Found."
'End If
cmd.Connection.Close()
cmd.Connection.Dispose()
End Sub
Function formaturl(ByVal strarguement) As String
Return ("ImageDetails.aspx?id=" & strarguement)
End Function
------------------- World Time --------------------------------
style="position:absolute; color:white; height:100px; width:800px; top:20px;left:450px;font-family:Tahoma; font-size: smaller; text-align:right;">

No comments:
Post a Comment