近來向Open course學習,以下是關鍵字摘要。
權能區分
直的分層,橫的分科
坐井觀天
馬馬虎虎
碰碰運氣
策略:
1.成本領導(成本最低)
2.差異化領導
3.Focus領導
環境變動很快,組織配合環境重新設計組織架構。
組織設計
1.工作專業化 - 把一個工作打破分成細小工作。
2.部門化 [橫分科,直分層 (複雜度)]
3.指揮鏈
4.管轄幅度
5.集權
6.形式化
創新,變革 (Innovation and change)
溝通(聽說讀寫):意義的移轉與了解。
男:重視地位
女:重視連結
第一次溝通很重要,需要回饋。
要素:「天龍八部」
發訊者,訊息,編碼,管道
解碼,愛訊者,回饋,噪音
讀的原則:
Preview
Question
Read
State
Test
寫的原則:
Introduction : what, why
Method & Material : how
Results
Discussion
Appendix
聽的原則:
不要多話。
用自已的話說說看。
說的原則:
自信
使用麥克風
素材的準備
備忘錄
利用視覺效果
回答問題
準備1分鐘的自我介紹,250中文字,100英文字
Iden, Java and Flash talking
Focus on Java, VB.NET, Flash and C++
6/08/2011
12/22/2010
冬至送湯圓
┴┬┴┬/ ̄\_/ ̄\
┬┴┬┴▏ ▏▔▔▔▔\ 冬至到 ..送湯圓..
┴┬┴/\ / ﹨
┬┴∕ / ) ╮╰╮ ╭ ╯╭╰╮
┴┬▏ ● ▏ ╮╰╮ ╭ ╯╭╰╮
┬┴▏ ▔█ ◥█□█□█□█◤
┴◢██◣ \__/ █○●○●○█
┬█████◣ / █○●○●○█
┴████████████◣ ◥█□█□█◤
◢████████████▆▄ ▆███▆
█◤◢██◣◥███████◤\
◥◢████ ██████◤ \
┴█████ █████◤ ﹨
┬│ │█████◤ ▏
┴│ │ ▏
┬∕ ∕
┬┴┬┴▏ ▏▔▔▔▔\ 冬至到 ..送湯圓..
┴┬┴/\ / ﹨
┬┴∕ / ) ╮╰╮ ╭ ╯╭╰╮
┴┬▏ ● ▏ ╮╰╮ ╭ ╯╭╰╮
┬┴▏ ▔█ ◥█□█□█□█◤
┴◢██◣ \__/ █○●○●○█
┬█████◣ / █○●○●○█
┴████████████◣ ◥█□█□█◤
◢████████████▆▄ ▆███▆
█◤◢██◣◥███████◤\
◥◢████ ██████◤ \
┴█████ █████◤ ﹨
┬│ │█████◤ ▏
┴│ │ ▏
┬∕ ∕
10/19/2010
vb.net限制輸入數字並只到小數點後2位
Private Sub txtRatio_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtRatio.KeyPress
'輸入為數字,小數點或backspace
If Char.IsDigit(e.KeyChar) Or e.KeyChar = "." Or e.KeyChar = Chr(8) Then 'Backspace:
'輸入的小數點為唯一
If e.KeyChar = "." And InStr(CType(sender, System.Windows.Forms.TextBox).Text, ".") > 0 Then
e.Handled = True
Else
'小數最多2位
If e.KeyChar <> Chr(8) And InStr(CType(sender, System.Windows.Forms.TextBox).Text, ".") > 0 Then
Dim sAry() As String = CType(sender, System.Windows.Forms.TextBox).Text.Split(".")
If sAry(1).Length >= 2 Then
e.Handled = True
Else
e.Handled = False
End If
Else
e.Handled = False
End If
End If
'輸入的負號是否在第一位
ElseIf e.KeyChar = "-" And CType(sender, System.Windows.Forms.TextBox).Text = "" Then
e.Handled = False
Else
e.Handled = True
End If
End Sub
Labels:
.net,
MS Visual Studio 2005,
vb
9/29/2010
SVN backup incremental
It is a simple way to backup svn project incremental.
In the console >
svnadmin dump _svn -r 25:125 --incremental > svnbackup_20100929.rev25_125.dump
In the console >
svnadmin dump _svn -r 25:125 --incremental > svnbackup_20100929.rev25_125.dump
Labels:
SVN backup
7/14/2010
Class for connection DB for .net 2.0
We always write some common code for any project. I share one of connecting MS SQL 2005.
This class help us to connect DB, show message on browser and export EXCEL file. We can insert, update, delete and query.
This class help us to connect DB, show message on browser and export EXCEL file. We can insert, update, delete and query.
' /**********************************************************************/
' /* System : */
' /* Sub System : */
' /* Module Name : */
' /* Description : */
' /* */
' /* Environment : Windows XP + MS Visual Studio 2005 */
' /* Transacion : None */
' /* Modification history */
' /* Date Label Editor Description */
' /* ========== ========== ========== ============================== */
' /* YYYY/MM/DD Author Create */
' /**********************************************************************/
Imports Microsoft.VisualBasic
Imports System.Data.SqlClient
Imports System.Data.OleDb
Imports System.Data
Imports System.IO
Public Class clsDb
Public Shared _ConnStr As String = "Data Source=your server name; Initial Catalog=your catalog; User Id=account;Password=password; Min Pool Size=2; Max Pool Size=40;Pooling=true; Connect Timeout=60"
Private Shared _logPath As String = "logs.log"
Public Sub New(ByVal xmlPath As String)
'constructor
End Sub
'query data from MSSQL
Public Shared Function QueryRunSQL(ByVal sSQL As String) As DataSet
Return QueryRunSQL(sSQL, clsDb._ConnStr)
End Function
'query data from MSSQL
Public Shared Function QueryRunSQL(ByVal sSQL As String, ByVal sConnStr As String) As DataSet
Dim sqlConn As SqlConnection = New SqlConnection(sConnStr)
Dim sqlDapt As SqlDataAdapter
Dim scmd As String = ""
Dim dsSource As New DataSet
Try
sqlDapt = New SqlDataAdapter(sSQL, sqlConn)
sqlDapt.Fill(dsSource)
Catch ex As Exception
dsSource = ErrorData(ex.Message)
Finally
sqlConn.Close()
sqlConn.Dispose()
SqlConnection.ClearAllPools()
End Try
Return dsSource
End Function
'insert, update or delete data from MSSQL
Public Shared Function ExecuteRunSQL(ByVal sql As String) As Integer
Dim list As ArrayList = New ArrayList()
list.Add(sql)
Return ExecuteRunSQL(list)
End Function
'insert, update or delete data from MSSQL
Public Shared Function ExecuteRunSQL(ByVal list As ArrayList) As Integer
Return ExecuteRunSQL(list, clsDb._ConnStr)
End Function
'insert, update or delete data from MSSQL
Public Shared Function ExecuteRunSQL(ByVal list As ArrayList, ByVal sConnStr As String) As Integer
Dim iProcess As Integer = 0
Try
If list Is Nothing Then
Return False
End If
Dim conn As SqlConnection = New SqlConnection(sConnStr)
conn.Open()
Dim trx = conn.BeginTransaction()
Dim command As New SqlCommand
command.Connection = conn
command.Transaction = trx
Try
For Each sSql As String In list
command.CommandText = sSql 'sSql is "delete * from table where condition"
iProcess = command.ExecuteNonQuery()
Next
trx.Commit()
Catch ex As Exception
trx.Rollback()
conn.Close()
Throw ex
Finally
conn.Close()
End Try
Catch ex As Exception
Throw New Exception(ex.Message + Chr(10) + Chr(13) + ex.StackTrace, ex)
Finally
list = Nothing
End Try
Return iProcess
End Function
'sorting hashtable
Public Function SortHashtable(ByVal oHash As Hashtable) As DataView
Dim oTable As New Data.DataTable
oTable.Columns.Add(New Data.DataColumn("key"))
oTable.Columns.Add(New Data.DataColumn("value"))
For Each oEntry As Collections.DictionaryEntry In oHash
Dim oDataRow As DataRow = oTable.NewRow()
oDataRow("key") = oEntry.Key
oDataRow("value") = oEntry.Value
oTable.Rows.Add(oDataRow)
Next
Dim oDataView As DataView = New DataView(oTable)
oDataView.Sort = "value DESC, key ASC"
Return oDataView
End Function
Public Shared Sub MessageBox(ByVal pgMain As Page, ByVal msg As String)
Dim strScript As String = ""
Try
msg = msg.Replace("'", "\'")
msg = msg.Replace(vbCrLf, "\r\n")
msg = msg.Replace(vbLf, "\n")
msg = msg.Replace(vbCr, "\r")
msg = msg.Replace("\""", "\\""")
strScript += ""
If (Not pgMain.ClientScript.IsStartupScriptRegistered(pgMain.GetType(), "MessageBox")) Then
pgMain.ClientScript.RegisterStartupScript(pgMain.GetType(), "MessageBox", strScript)
End If
Catch ex As Exception
pgMain.Response.Write(ex.ToString())
End Try
End Sub
Public Shared Function ShowError(ByVal dsSource As DataSet) As String
Dim sError As String = ""
Try
Dim msg As String = ""
If dsSource.Tables.Count > 0 Then
Dim dtTempTable As DataTable = dsSource.Tables("ErrorMessage")
Dim iJ As Integer
If dtTempTable.Rows.Count > 0 Then
For iJ = 0 To dtTempTable.Rows.Count - 1
msg = dtTempTable.Rows(iJ).Item(0).ToString.Replace("'", "")
msg = msg.Replace("。", "!")
msg = msg.Replace(vbCrLf, "\r\n")
Next
End If
End If
sError = msg
Catch ex As Exception
WriteLog(ex.ToString, "Exception Handler", _logPath)
End Try
Return sError
End Function
Public Shared Function ErrorData(ByVal errorMessage As String) As DataSet
Dim dsSource As New DataSet
Dim dtNewTable As DataTable = New DataTable("ErrorMessage")
dtNewTable.Columns.Add("Message")
Dim dr As DataRow = dtNewTable.NewRow()
dr("Message") = errorMessage
dtNewTable.Rows.Add(dr)
dsSource.Tables.Add(dtNewTable)
Return dsSource
End Function
Public Shared Sub WriteLog(ByVal sErrorMessage As String, ByVal sWho As String, ByVal sFileName As String)
Dim sFile As String
If sFileName Is Nothing Then
sFile = ".\\commonLogs.log"
Else
sFile = sFileName
End If
Dim sLogWriter As IO.StreamWriter = New IO.StreamWriter(sFile, True, System.Text.Encoding.Default)
Try
sLogWriter.WriteLine("[" & Format(DateTime.Now, "yyyy-MM-dd HH:mm:ss") + " user:" + sWho + "] message: " + sErrorMessage)
sLogWriter.Close()
Catch ex As Exception
sLogWriter.WriteLine("[Exception" & Format(DateTime.Now, "yyyy-MM-dd HH:mm:ss") + " user:" + sWho + "] message: " + ex.ToString)
sLogWriter.Close()
Exit Sub
End Try
End Sub
'export to Excel file
Public Shared Function ExportToXls(ByVal dt As System.Data.DataTable, ByVal xlsPath As String) As Boolean
If xlsPath.Trim = "" Then Exit Function
Dim txtPath As String = Replace(xlsPath, ".xls", ".csv")
If File.Exists(txtPath) = True Then File.Delete(txtPath)
If File.Exists(xlsPath) = True Then File.Delete(xlsPath)
Dim oExcel As Object = CreateObject("Excel.Application")
GC.Collect() : GC.WaitForPendingFinalizers()
Try
'---------------------------------
'create header
'---------------------------------
Dim sb As New StringBuilder
Dim icount As Integer
Dim sColumn As String = ""
For icount = 0 To dt.Columns.Count - 1
sColumn += dt.Columns(icount).ToString + ","
Next
sb.Append(sColumn.TrimEnd(","))
sb.Append(Chr(13) + Chr(10))
'---------------------------------
'create data
'---------------------------------
If dt.Rows.Count > 0 Then
For Each dr As DataRow In dt.Rows
Dim en_data As IEnumerator = dt.Columns.GetEnumerator
While en_data.MoveNext
sb.Append(dr.Item(en_data.Current).ToString).Append(",")
End While
sb.Append(Chr(13) + Chr(10))
Next
End If
'out a text file
Dim sw As StreamWriter = New StreamWriter(txtPath, False, System.Text.Encoding.Unicode)
sw.WriteLine(sb.ToString)
sw.Flush()
sw.Close()
'out a excel file
oExcel.Visible = False : oExcel.DisplayAlerts = False
oExcel.Workbooks.OpenText(Filename:=txtPath, StartRow:=1, DataType:=1, _
TextQualifier:=1, ConsecutiveDelimiter:=False, TAB:=False, _
Semicolon:=False, Comma:=True, _
Space:=False, Other:=False, TrailingMinusNumbers:=True)
'oExcel.ActiveWorkbook.SaveAs(Filename:=xlsPath) 'output Excel file
Catch ex As Exception
ExportToXls = False
Throw New Exception(ex.ToString)
Finally
'If File.Exists(txtPath) = True Then File.Delete(txtPath) 'Del temp csv
oExcel.ActiveWorkbook.Close()
oExcel.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComObject(oExcel)
oExcel = Nothing
GC.Collect()
ExportToXls = True
End Try
Return ExportToXls
End Function
Public Shared Function Now() As String
Return Format(DateTime.Now, "yyyy-MM-dd HH:mm:ss").Replace("-", "_").Replace(" ", "_").Replace(":", "_")
End Function
End Class
Labels:
.net,
code,
MS Visual Studio 2005
3/24/2010
1/15/2010
訂閱:
意見 (Atom)