LoginPage

Login page

Simple Login Page

Username Password

Minggu, 08 Februari 2009

Read xml file from Web services

_
Public Function UploadRFQ_SF() As String
Dim cn As New SqlConnection(strConn)
Dim xmlDocument As XmlDocument = New XmlDocument
Dim cmd As New SqlCommand
Dim strFIELDS As String
Dim strVALUES As String

Dim strsql As String

cn.Open()
xmlDocument.Load("http://rptmanager.ktibali.com/rptmanager/scmglm/Files/XML_FIleName.xml")

Dim xmlNodeList As XmlNodeList = xmlDocument.SelectNodes("/NewDataSet/hasil")

Dim node As XmlNode
Dim i As Integer = 0

cmd.Connection = cn
For Each node In xmlNodeList
strFIELDS = "RFQID_sf"
strVALUES = node.SelectSingleNode("RFQID_sf").InnerXml

strFIELDS = strFIELDS & ",RFQID"
strVALUES = strVALUES & "," & node.SelectSingleNode("RFQID").InnerXml

strFIELDS = strFIELDS & ",SuppID"
strVALUES = strVALUES & "," & node.SelectSingleNode("SuppID").InnerXml

strFIELDS = strFIELDS & ",InputDate"
strVALUES = strVALUES & ",'" & CDate(node.SelectSingleNode("InputDate").InnerXml) & "'"

strFIELDS = strFIELDS & ",companyID"
strVALUES = strVALUES & "," & node.SelectSingleNode("companyID").InnerXml

strsql = "INSERT INTO tblSource (" & strFIELDS & ") VALUES (" & strVALUES & ")"
cmd.CommendText = strsql

cmd.ExecuteNonQuery()
Next
End Function

Jumat, 16 Januari 2009

.NET Report (rdlc) using image physically

1. In file of Report(rdlc), in value, choose expression
2. Fill expression with the path of image file as follow : ="file://C:/My Pictures/DSC00528.jpg"
3. In form which reportViewer is in it, add follow code before Refresh report :
Me.ReportViewer1.LocalReport.EnableExternalImages = True
Me.ReportViewer1.RefreshReport()
4. Finish.

You can change the path by field so the report can show image dinamically.
Don't forget to the expression must begin with "file://" and suing slash instead of backslash.

Hope this will help you

Senin, 12 Januari 2009

Export Gridview into Excel File

To use below export Gridview to excel as follow :

GridViewExportUtil.Export("ExcelFileName.xls", GridViewName);
Here it is the code
======================================================================

Imports System
Imports System.Data
Imports System.Configuration
Imports System.IO
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls

Public Class GridViewExportUtil

Public Shared Sub Export(ByVal fileName As String, ByVal gv As GridView)
HttpContext.Current.Response.Clear()
HttpContext.Current.Response.AddHeader("content-disposition", String.Format("attachment; filename={0}", fileName))
HttpContext.Current.Response.ContentType = "application/ms-excel"
Dim sw As StringWriter = New StringWriter
Dim htw As HtmlTextWriter = New HtmlTextWriter(sw)
' Create a form to contain the grid
Dim table As Table = New Table
table.GridLines = gv.GridLines
' add the header row to the table
If (Not (gv.HeaderRow) Is Nothing) Then
GridViewExportUtil.PrepareControlForExport(gv.HeaderRow)
table.Rows.Add(gv.HeaderRow)
End If
' add each of the data rows to the table
For Each row As GridViewRow In gv.Rows
GridViewExportUtil.PrepareControlForExport(row)
table.Rows.Add(row)
Next
' add the footer row to the table
If (Not (gv.FooterRow) Is Nothing) Then
GridViewExportUtil.PrepareControlForExport(gv.FooterRow)
table.Rows.Add(gv.FooterRow)
End If
' render the table into the htmlwriter
table.RenderControl(htw)
' render the htmlwriter into the response
HttpContext.Current.Response.Write(sw.ToString)
HttpContext.Current.Response.End()
End Sub

' Replace any of the contained controls with literals
Private Shared Sub PrepareControlForExport(ByVal control As Control)
Dim i As Integer = 0
Do While (i < control.Controls.Count)
Dim current As Control = control.Controls(i)
If (TypeOf current Is LinkButton) Then
control.Controls.Remove(current)
control.Controls.AddAt(i, New LiteralControl(CType(current, LinkButton).Text))
ElseIf (TypeOf current Is ImageButton) Then
control.Controls.Remove(current)
control.Controls.AddAt(i, New LiteralControl(CType(current, ImageButton).AlternateText))
ElseIf (TypeOf current Is HyperLink) Then
control.Controls.Remove(current)
control.Controls.AddAt(i, New LiteralControl(CType(current, HyperLink).Text))
ElseIf (TypeOf current Is DropDownList) Then
control.Controls.Remove(current)
control.Controls.AddAt(i, New LiteralControl(CType(current, DropDownList).SelectedItem.Text))
ElseIf (TypeOf current Is CheckBox) Then
control.Controls.Remove(current)
control.Controls.AddAt(i, New LiteralControl(CType(current, CheckBox).Checked))
'TODO: Warning!!!, inline IF is not supported ?
End If
If current.HasControls Then
GridViewExportUtil.PrepareControlForExport(current)
End If
i = (i + 1)
Loop
End Sub
End Class