星期二, 11月 01, 2005

眼睛視網膜病變

最近眼睛右眼看東西, 正中間都有一團黑影 , 導致東西都看不清楚 ,
至醫院檢查 , 發現是視網膜病變所引起 , 需要長期休息及作進一步檢查.
原因可能是愛情動作片看太多了 , ㄚ~ 不是啦 , 醫生說應該是壓力大 , 且
太長時間看電腦螢幕所引起的 .

目前正在家休養中 , 可能會休息一兩個月吧~~ 大家努力
工作之餘 , 更要保重身體啊~~

星期五, 9月 02, 2005

在asp.net中處理意外情況

於Global.asax 中的 Application_Error 事件加上以下的內容 , 如此
當系統發生意外情況時 , 則會將錯誤訊息 mail 給指定的人 , 並將網頁導至
Maintenance.aspx

Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
' 發生錯誤時引發
If (System.Web.HttpContext.Current.Request.Url.Authority <> "localhost") Then
''' Get the Exception object wrapped in the InnerException property
Dim unhandledException As Exception = Server.GetLastError().InnerException
''' Create a MailMessage
Dim mail As System.Web.Mail.MailMessage = New System.Web.Mail.MailMessage
mail.From = "error@abc.com"
mail.To = "admin@abc.com"
mail.BodyFormat = System.Web.Mail.MailFormat.Text
mail.Subject = "unHandledException.Message"
mail.Body = unhandledException.ToString()
System.Web.Mail.SmtpMail.SmtpServer = "127.0.0.1"
''' Send the email
System.Web.Mail.SmtpMail.Send(mail)
''' Redirect the user to a maintenence page
System.Web.HttpContext.Current.Response.Redirect("Maintenance.aspx")
End If
End Sub

星期一, 8月 15, 2005

利用crystal report 直接匯出pdf檔給client

'''利用crystal report 直接匯出pdf檔給client
'''在作業目錄底下新建一個reports目錄,權限設定為everyone可讀寫
'''記得要imports 以下兩項
'''Imports CrystalDecisions.CrystalReports.Engine
'''Imports CrystalDecisions.Shared
'''
Dim RptDoc As New ReportDocument
Dim rptFile As String = Server.MapPath("license.rpt")
'''
RptDoc.Load(rptFile)
''' 登入資料庫
Dim logonInfo As New TableLogOnInfo
Dim rptTable As Table
For Each rptTable In RptDoc.Database.Tables
logonInfo = rptTable.LogOnInfo
With logonInfo.ConnectionInfo
.ServerName = "localhost"
.DatabaseName = "ff"
.UserID = "aa"
.Password = "aa"
End With
rptTable.ApplyLogOnInfo(logonInfo)
Next

'RptDoc.ExportOptions.ExportFormatType = ExportFormatType.WordForWindows
RptDoc.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat
RptDoc.ExportOptions.FormatOptions = New PdfRtfWordFormatOptions
''' 設定參數
Dim Paravalues As New ParameterValues
Dim ParaDisValue As New ParameterDiscreteValue
'ParaDisValue = New ParameterDiscreteValue
ParaDisValue.Value = 6
Paravalues.Add(ParaDisValue)

RptDoc.DataDefinition.ParameterFields("License_Num").ApplyCurrentValues(Paravalues)

Dim crExportOptions As ExportOptions
Dim crDiskFileDestinationOptions As DiskFileDestinationOptions
Dim fname As String
fname = Server.MapPath("exports/") & Session.SessionID.ToString & ".pdf"
crDiskFileDestinationOptions = New DiskFileDestinationOptions
crDiskFileDestinationOptions.DiskFileName = fname
crExportOptions = RptDoc.ExportOptions
With crExportOptions
.DestinationOptions = crDiskFileDestinationOptions
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.PortableDocFormat
End With
RptDoc.Export()
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Response.WriteFile(fname)
Response.Flush()
Response.Close()
System.IO.File.Delete(fname)

利用window.open開啟新視窗

利用asp.net(VS.net)開發web程式, 相信很多人都知道, 一個aspx的網頁只能有一個
form, 也就是說如果要在程式中利用button按鈕點一下後,連結到新的視窗,一般就只能
靠java script 來完成了.
最好是利用 window.open, 而不要使用window.showModalDialog , 因為
後者並非標準的語法,只有IE能解譯.
例如:
Private Sub BTP_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles BTPestUse1.Load
Dim JavaScript As String
Dim Url As String
Url = "'pChoice.aspx?pestcd=' + " & "Form1." & Me.TBP.ClientID & ".value" '''
Url = "encodeURIComponent(" & Url & ")"
JavaScript = "window.open(" & Url & ",'','height=600,width=800,menubar=no');"
Me.BTP.Attributes("onclick") = JavaScript
end sub

於子視窗 pChoice.aspx 中可以利用request("pestcd")取得TBP這個TextBox輸入的值

星期二, 5月 17, 2005

取得 MCAD 認證(Microsoft Certified Application Developer )

之前就差一科就能取得 MCAD , 拖了好久 , 終於在昨天通過了 , 耶~~~

Microsoft Certification Status

Certification Version Date Achieved

Microsoft Certified Application Developer May 16, 2005
For Microsoft .NET May 16, 2005
Microsoft Certified Professional Dec 29, 2003


Microsoft Certification Exams Completed Successfully

Exam ID Description Date Completed
306 Developing and Implementing Windows®-based Applications with Microsoft® Visual Basic® .NET and Microsoft® Visual Studio® .NET May 16, 2005
310 Developing XML Web Services and Server Components with Microsoft® Visual Basic® .NET and the Microsoft® .NET Framework Feb 23, 2004
305 Developing and Implementing Web Applications with Microsoft® Visual Basic® .NET and Microsoft® Visual Studio® .NET