vb2010.net + SQL2005 簡單搞定。
創(chuàng)新互聯(lián)建站主要從事做網(wǎng)站、成都網(wǎng)站建設、網(wǎng)頁設計、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務。立足成都服務黃南州,十年網(wǎng)站建設經(jīng)驗,價格優(yōu)惠、服務專業(yè),歡迎來電咨詢建站服務:18982081108
就是數(shù)據(jù)庫的最基本操作,增加修改刪除!
剛好做過這個論文,給你回答啦~~獨家哦,分數(shù)要給偶~~
1) 系統(tǒng)意義
隨著計算機應用的日益普及,各企事業(yè)在人事方面實現(xiàn)規(guī)范化、計算機自動化管理勢在必行,是提高科學管理水平的重要手段,是提高工作效率的可靠途徑。
2) 系統(tǒng)特點
1 將人事信息實現(xiàn)自動化管理;
2 提供各種查詢、修改、刪除、插入人才信息功能;
3 提供各種信息統(tǒng)計功能。
3) 系統(tǒng)設計環(huán)境
1 Windows 2000 Server 或 Windows XP;
2 SQL Server 2000數(shù)據(jù)庫管理系統(tǒng);
3 VB 6.0。
二 系統(tǒng)需求分析
1) 系統(tǒng)設計目標
1 在人事管理過程中,實現(xiàn)信息自動化管理。
2 實現(xiàn)各種信息的修改、刪除、插入功能。
3 實現(xiàn)對各種信息的查詢、統(tǒng)計。
4 按年份月份統(tǒng)計某個職工的出勤情況信息。
5 按某年某月某日統(tǒng)計查詢某部門的遲到和早退人數(shù)。
6 按月統(tǒng)計每個人的加班天數(shù)。
7 按年統(tǒng)計調入調出人數(shù)信息。
2) 系統(tǒng)需求分析
1. 信息需求分析
通過對人事信息系統(tǒng)的分析,此系統(tǒng)需要包含如下信息(數(shù)據(jù)字典):
1)人事檔案基本信息:
編號、姓名、性別、出生日期、工作年限、電話、地址、E-mail、學歷、專業(yè)、進入本單位時間(編號要求:長度為6的數(shù)字字符組成)
2)人事調動信息:
原部門、新部門、原職務、新職務、調出時間、調入時間
3)人事考勤信息:
上下班時間、遲到次數(shù)、早退次數(shù)、請假天數(shù)、加班天數(shù)、加班日期
4)系統(tǒng)用戶管理信息:
用戶帳號、密碼(由6個數(shù)字組成)、記錄用戶最近一次登錄信息:年月日
2.功能需求分析
1)人事檔案基本信息的錄入、更新、刪除、查詢;
2)人事調動信息的錄入、更新、刪除、查詢;
3)人事考勤信息的錄入、更新、刪除、查詢;
3. 概念結構設計
系統(tǒng)的E-R圖如圖1.1所示:
1)數(shù)據(jù)庫設計
1 邏輯結構設計
人事基本信息(編號,姓名,出生日期,工作年限,電話,E-mail,學歷,進單位時間);
人事調動信息(編號,原部門,新部門,原職務,新職務,調出時間,調入時間);
人事考勤信息(編號,上下班時間,遲到次數(shù),早退次數(shù),請假天數(shù),加班天數(shù),加班日期)。
2 各數(shù)據(jù)表結構
根據(jù)實體間E – R模型的需求分析,本系統(tǒng)需要4個數(shù)據(jù)表分別來存放人是基本信息,調動信息,考勤信息和系統(tǒng)管理員帳號信息,具體如下:
人事基本信息表
字段名 數(shù)據(jù)類型 長度 是否為空 說明
bh char 10 Not null 編號
name varchar 8 Not null 姓名
sex varChar 3 Not null 性別
gznx varchar 10 null 工作年限
birth Datetime 10 null 出生日期
email Varchar 20 null E-mail
dh Varchar 20 null 電話
xl Varchar 10 null 學歷
jdwsj Datetime 10 null 進單位時間
人事調動表
字段名 數(shù)據(jù)類型 長度 是否為空 說明
ybm varchar 12 Not null 原部門
xbm varchar 12 Not null 新部門
yzw varChar 12 Not null 原職務
xzw varchar 12 null 新職務
dcsj Datetime 10 null 調出時間
drsj Datetime 10 null 調入時間
人事考勤表
字段名 數(shù)據(jù)類型 長度 是否為空 說明
sxb varchar 10 Not null 上下班時間
cd varchar 5 Not null 遲到次數(shù)
zt varChar 5 Not null 早退次數(shù)
qj varchar 5 null 請假天數(shù)
jbts Datetime 5 null 加班天數(shù)
jbrq Datetime 10 null 加班日期
管理員表
字段名 數(shù)據(jù)類型 長度 是否為空 說明
name char 20 Not null 用戶名
password char 8 Not null 密碼
人事基本信息模塊代碼
Option Explicit
Dim mblchange As Boolean
Public txtSQL As String
Public msgtext As String
Dim mrc As ADODB.Recordset
Private Sub cmdcancle_Click()
Unload Me
End Sub
Private Sub cmdOK_Click()
Dim intCount As Integer
Dim txtSQL As String
Dim MsgString As String
Dim sMeg As String
Dim i As Integer
For intCount = 0 To 1
If Trim(Text1(intCount) "") = "" Then
Select Case intCount
Case 0
sMeg = "編號"
Case 1
sMeg = "姓名"
End Select
sMeg = sMeg "不能為空"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
Text1(intCount).SetFocus
Exit Sub
End If
Next intCount
If Trim(Text1(3) "") = "" Then
MsgBox "出生日期不能為空", vbOKOnly + vbExclamation, "警告"
End If
If Trim(Text1(3) "") "" Then
If Not IsDate(Text1(3)) Then
MsgBox "出生日期應為(yyyy-mm-dd)!", vbOKOnly + vbExclamation, "警告"
Text1(3).SetFocus
Exit Sub
Else
Text1(3) = Format(Text1(3), "yyyy-mm-dd")
End If
End If
If Trim(Text1(2) "") = "" Then
MsgBox "年齡不能為空", vbOKOnly + vbExclamation, "警告"
Exit Sub
End If
If gintMode = 1 Then
txtSQL = "select * from dangan where ygid='" Trim(Text1(0)) "'"
Set mrc = ExecuteSQL(txtSQL, msgtext)
If mrc.EOF = False Then
MsgBox "有重復記錄", vbOKOnly + vbExclamation, "警告"
Text1(0).SetFocus
End If
mrc.Close
txtSQL = "delete * from dangan where ygid='" Trim(Text1(0)) "'"
Set mrc = ExecuteSQL(txtSQL, msgtext)
txtSQL = "select * from dangan"
Set mrc = ExecuteSQL(txtSQL, msgtext)
mrc.AddNew
For intCount = 0 To 1
mrc.Fields(intCount) = Trim(Text1(intCount))
Next intCount
For intCount = 2 To 5
mrc.Fields(intCount) = Trim(Text1(intCount))
Next intCount
For intCount = 6 To 10
mrc.Fields(intCount) = Trim(Text1(intCount))
Next intCount
mrc.Fields(11) = Trim(Combo1.Text)
mrc.Update
If gintMode = 1 Then
MsgBox "添加記錄成功", vbOKOnly, "提示"
For i = 0 To 10
Text1(i).Text = ""
Next i
frmyuangong.Show
frmyuangong.ZOrder 0
frmmanrecord.ShowTitle
frmmanrecord.ShowData
frmmanrecord.ZOrder 1
End If
ElseIf gintMode = 2 Then
txtSQL = "select * from dangan where ygid='" Trim(Text1(0).Text) "'"
Set mrc = ExecuteSQL(txtSQL, msgtext)
For intCount = 0 To 10
mrc.Fields(intCount) = Trim(Text1(intCount))
Next intCount
mrc.Fields(11) = Trim(Combo1.Text)
mrc.Update
MsgBox "修改成功", vbOKOnly, "提示"
Unload Me
frmmanrecord.ShowTitle
frmmanrecord.ShowData
frmmanrecord.ZOrder 0
End If
gintMode = 0
End Sub
Private Sub Form_Load()
Dim msgtext As String
Dim intCount As Integer
With Combo1
.AddItem "男"
.AddItem "女"
End With
If gintMode = 1 Then
Me.Caption = Me.Caption "添加"
Combo1.ListIndex = 0
ElseIf gintMode = 2 Then
Set mrc = ExecuteSQL(txtSQL, msgtext)
If mrc.EOF = False Then
With mrc
For intCount = 0 To 10
Text1(intCount) = .Fields(intCount)
Next intCount
If Not IsNull(!sex) Then
Combo1 = !sex
End If
mrc.Close
Me.Caption = Me.Caption "修改"
End With
End If
End If
mblchange = False
End Sub
Option Explicit
Public sQSql As String
Public mrc As ADODB.Recordset
Public txtSQL As String
Public msgtext As String
Private Sub Check1_Click(Index As Integer)
If Index = 0 Then
Text1(Index).SetFocus
End If
If Index = 1 Then
Text1(Index).SetFocus
Else
Text1(Index).SetFocus
End If
End Sub
Private Sub cmdcancel_Click()
Unload Me
End Sub
Private Sub cmdOK_Click()
If Check1(0).Value = vbChecked Then
sQSql = "ygname='" Trim(Text1(0) "") "'"
End If
If Check1(1).Value = vbChecked Then
If Trim(sQSql " ") = "" Then
sQSql = "ygid='" Trim(Text1(1) "") "'"
Else
sQSql = sQSql "and ygid='" Trim(Text1(1) "") "'"
End If
End If
If Check1(2).Value = vbChecked Then
If Trim(sQSql " ") = "" Then
sQSql = "ygdept='" Trim(Text1(2) "") ""
Else
sQSql = sQSql "and ygdept='" Trim(Text1(2) "") "'"
End If
End If
If Trim(sQSql " ") = "" Then
frmmanrecord.txtSQL = "select * from dangan"
flagEdit = True
frmmanrecord.ShowTitle
frmmanrecord.ShowData
frmmanrecord.Show
Else
frmmanrecord.txtSQL = "select * from dangan where " sQSql
flagEdit = True
frmmanrecord.ShowTitle
frmmanrecord.ShowData
frmmanrecord.Show
End If
Me.Hide
End Sub
Private Sub Form_Load()
Dim i As Integer
For i = 0 To 2
Text1(i) = ""
Next
End Sub
人事考勤模塊代碼
Option Explicit
Dim mblchange As Boolean
Dim mrc As ADODB.Recordset
Public txtSQL As String
Private Sub cboItem_Click(Index As Integer)
Dim msgtext As String
txtSQL = "select ygid,ygname from dangan where ygdept='" Trim(DataCombo1) "'"
Set mrc = ExecuteSQL(txtSQL, msgtext)
mrc.MoveFirst
mrc.Move cboItem(1).ListIndex
txtid = Trim(mrc!ygid)
End Sub
Private Sub cboItem_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
EnterToTab KeyCode
End Sub
Private Sub cboMonth_Click()
Dim dateTemp As Date
dateTemp = DateAdd("d", -1, DateAdd("m", 1, DateSerial(CInt(cboYear), CInt(cboMonth), 1)))
txtItem(0) = Day(dateTemp)
End Sub
Private Sub cboYear_Click()
Dim dateTemp As Date
If Trim(cboMonth " ") "" Then
dateTemp = DateAdd("d", -1, DateAdd("m", 1, DateSerial(CInt(cboYear), CInt(cboMonth), 1)))
txtItem(0) = Day(dateTemp)
End If
End Sub
Private Sub cmdExit_Click()
If mblchange And gintMode 3 And cmdSave.Enabled Then
If MsgBox("保存當前記錄的變化嗎?", vbOKCancel + vbExclamation, "警告") = vbOK Then
Call cmdSave_Click
End If
End If
Unload Me
End Sub
Private Sub cmdSave_Click()
Dim intCount As Integer
Dim sMeg As String
Dim rectemp As Recordset
Dim sSql As String
Dim msgtext As String
For intCount = 0 To 3
If Trim(txtItem(intCount) " ") = "" Then
Select Case intCount
Case 0
sMeg = "本月天數(shù)"
Case 2
sMeg = "應出勤天數(shù)"
Case 3
sMeg = "出勤"
End Select
If intCount 1 Then
sMeg = sMeg "不能為空!"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
txtItem(intCount).SetFocus
Exit Sub
End If
End If
Next intCount
If gintMode = 1 Then
txtSQL = "select * from checkin where kqid='" Trim(txtid) "' and kqdate= '" Format(cboYear.Text "-" cboMonth.Text "-01", "yyyy-mm-dd") "'"
Set mrc = ExecuteSQL(txtSQL, msgtext)
If mrc.EOF = False Then
MsgBox "已經(jīng)存在該員工在該月的考勤記錄!", vbOKOnly + vbExclamation, "警告"
cboMonth.SetFocus
Exit Sub
End If
mrc.Close
txtSQL = "delete from checkin where kqid='" Trim(txtid) "' and kqdate='" Format(cboYear "-" cboMonth "-01", "yyyy-mm-dd") "'"
Set mrc = ExecuteSQL(txtSQL, msgtext)
txtSQL = "select * from checkin"
Set mrc = ExecuteSQL(txtSQL, msgtext)
mrc.AddNew
mrc.Fields(0) = Trim(txtid)
mrc.Fields(1) = Trim(cboItem(1))
mrc.Fields(2) = Format(cboYear "-" cboMonth "-01", "yyyy-mm-dd")
For intCount = 0 To 15
mrc.Fields(intCount + 3) = Trim(txtItem(intCount).Text)
Next intCount
For intCount = 16 To 17
mrc.Fields(intCount + 3) = Trim(txtItem(intCount).Text)
Next intCount
mrc.Update
MsgBox "記錄添加成功!", vbOKOnly + vbExclamation, "警告"
For intCount = 0 To 17
txtItem(intCount) = ""
Next intCount
mblchange = False
ElseIf gintMode = 2 Then
txtSQL = "select kqid,kqname,kqdays,kqrday,kqtday,kqwork,kqabsent,kqrest,kqleave,kqlate,kqearly,kqforget,kqover1,kqvoer2,kqfill,kqgo,kqpay,kqdeduct,kqother,kqremark from checkin where kqid='" Trim(txtid) "'"
Set mrc = ExecuteSQL(txtSQL, msgtext)
mrc.Fields(0) = Trim(txtid)
mrc.Fields(1) = Trim(cboItem(1))
For intCount = 0 To 15
mrc.Fields(intCount + 2) = Trim(txtItem(intCount).Text)
Next intCount
For intCount = 16 To 17
mrc.Fields(intCount + 2) = Trim(txtItem(intCount).Text)
Next intCount
mrc.Update
MsgBox "記錄修改成功!", vbOKOnly, "提示"
mrc.Close
Unload Me
frmCheck.ShowTitle
frmCheck.ShowData
frmCheck.ZOrder 0
End If
gintMode = 0
End Sub
Private Sub DataCombo1_Click(Area As Integer)
Dim sSql As String
Dim msgtext As String
txtSQL = "select ygid,ygname from dangan where ygdept='" Trim(DataCombo1) "'"
Set mrc = ExecuteSQL(txtSQL, msgtext)
cboItem(1).Clear
If Not mrc.EOF Then
With cboItem(1)
Do While Not mrc.EOF
.AddItem Trim(mrc!ygname)
mrc.MoveNext
Loop
.ListIndex = 0
End With
cmdSave.Enabled = True
Else
MsgBox "請先建立員工檔案!", vbOKOnly + vbExclamation, "警告"
cmdSave.Enabled = False
Exit Sub
End If
End Sub
Private Sub Form_Load()
Dim intCount As Integer
Dim dateTemp As Date
Dim msgtext As String
Adodc1.Visible = False
cboYear.AddItem Year(Now)
cboYear.AddItem Year(Now) - 1
cboYear.ListIndex = 0
For intCount = 1 To 12
cboMonth.AddItem intCount
Next intCount
cboMonth = Month(Now)
If gintMode = 1 Then
Me.Caption = Me.Caption "添加"
'初始化部門名稱
txtSQL = "select DISTINCT ygdept from dangan"
Set mrc = ExecuteSQL(txtSQL, msgtext)
If mrc.EOF Then
MsgBox "請先進行員工檔案登記!", vbOKOnly + vbExclamation, "警告"
cmdSave.Enabled = False
Exit Sub
End If
'初始化本月天數(shù)
dateTemp = DateAdd("d", -1, DateAdd("m", 1, DateSerial(CInt(cboYear), CInt(cboMonth), 1)))
txtItem(0) = Day(dateTemp)
mrc.Close
ElseIf gintMode = 2 Then
Set mrc = ExecuteSQL(txtSQL, msgtext)
If mrc.EOF = False Then
With mrc
cboItem(1).AddItem .Fields(1)
cboItem(1).ListIndex = 0
For intCount = 2 To 19
If Not IsNull(.Fields(intCount)) Then
txtItem(intCount - 2) = .Fields(intCount)
End If
Next intCount
txtid = .Fields(0)
End With
End If
mrc.Close
Me.Caption = Me.Caption "修改"
End If
mblchange = False
End Sub
人事調動模塊代碼
Option Explicit
Dim mblchange As Boolean
Public txtSQL As String
Public msgtext As String
Dim mrc As ADODB.Recordset
Dim mybookmark As Variant
Private Sub cmdcancel_Click()
Unload Me
End Sub
Private Sub cmdchange_Click()
cmdchange.Enabled = False
Command1.Enabled = False
cmddelete.Enabled = False
gintMode = 2
End Sub
Private Sub cmddelete_Click()
Dim st As String
mybookmark = mrc.Bookmark
st = MsgBox("是否刪除當前記錄?", vbOKCancel, "提示")
If st = vbOK Then
mrc.MoveNext
If mrc.EOF Then
mrc.MoveFirst
mybookmark = mrc.Bookmark
mrc.MoveLast
mrc.Delete
mybookmark = mrc.Bookmark
Call viewdata
Else
mybookmark = mrc.Bookmark
mrc.MovePrevious
mrc.Delete
mrc.Bookmark = mybookmark
Call viewdata
End If
Else
mrc.Bookmark = mybookmark
Call viewdata
End If
End Sub
Private Sub cmdOK_Click()
Dim intCount As Integer
Dim txtSQL As String
Dim MsgString As String
If Text(0) = "" Then
MsgBox "編號不能為空!", vbOKOnly + vbExclamation, "警告"
Text(0).SetFocus
End If
If Text(1) = "" Then
MsgBox "事件不能為空!", vbOKOnly + vbExclamation, "警告"
Text(1).SetFocus
End If
If gintMode = 1 Then
txtSQL = "select * from renshi1 where id='" Trim(Text(0)) "'"
Set mrc = ExecuteSQL(txtSQL, msgtext)
If mrc.EOF = False Then
MsgBox "己存在此編號的記錄,請重新輸入!", vbOKOnly + vbExclamation, "警告"
Text(0).SetFocus
Exit Sub
End If
mrc.Close
txtSQL = "delete * from renshi1 where id='" Trim(Text(0)) "'"
Set mrc = ExecuteSQL(txtSQL, msgtext)
txtSQL = "select * from renshi1"
Set mrc = ExecuteSQL(txtSQL, msgtext)
mrc.AddNew
For intCount = 0 To 2
mrc.Fields(intCount) = Trim(Text(intCount))
Next intCount
mrc.Update
MsgBox "添加記錄成功!", vbOKOnly, "提示"
frmrenshi.ZOrder 1
frmrenshi.Show
Command1.Enabled = True
cmdchange.Enabled = True
cmddelete.Enabled = True
first.Enabled = True
previous.Enabled = True
next1.Enabled = True
last.Enabled = True
End If
If gintMode = 2 Then
txtSQL = "select * from renshi1"
Set mrc = ExecuteSQL(txtSQL, msgtext)
For intCount = 0 To 2
mrc.Fields(intCount) = Text(intCount).Text
Next intCount
mrc.Update
MsgBox "記錄修改成功!", vbOKOnly, "提示"
cmdchange.Enabled = True
Command1.Enabled = True
cmddelete.Enabled = True
End If
gintMode = 0
End Sub
Private Sub Command1_Click()
Dim i As Integer
For i = 0 To 2
Text(i).Text = ""
Next i
Command1.Enabled = False
cmdchange.Enabled = False
cmddelete.Enabled = False
first.Enabled = False
previous.Enabled = False
next1.Enabled = False
last.Enabled = False
gintMode = 1
End Sub
Private Sub first_Click()
mrc.MoveFirst
Call viewdata
End Sub
Private Sub Form_Load()
Dim txtSQL As String
Dim msgtext As String
Dim i As Integer
txtSQL = "select * from renshi1 "
Set mrc = ExecuteSQL(txtSQL, msgtext)
If mrc.EOF = True Then
MsgBox "沒有任何記錄,請?zhí)砑?", vbOKOnly, "提示"
Else
mrc.MoveFirst
Call viewdata
mybookmark = mrc.Bookmark
mblchange = True
End If
mblchange = True
End Sub
Private Sub next1_Click()
mrc.MoveNext
If mrc.EOF Then
mrc.MoveFirst
End If
Call viewdata
End Sub
Private Sub previous_Click()
mrc.MovePrevious
If mrc.BOF Then
mrc.MoveLast
End If
Call viewdata
End Sub
Public Sub viewdata()
Dim intCount As Integer
For intCount = 0 To 2
Text(intCount) = mrc.Fields(intCount)
Next intCount
End Sub
本機上的數(shù)據(jù)庫名字和原來的不一樣,所以系統(tǒng)找不到數(shù)據(jù)庫報錯
1、vb.net ?完全符合面向對象的編程語言抽象、封裝、繼承的四大特性,而vb不支持繼承。
2、錯誤處理不同。
vb中只是On Error.....goto和On Errer Resume Next ,這些錯誤稱為非結構化異常處理。而在vb.net中采用的結構化異常處理機制,try...catch....finally控制。
3、兩者產(chǎn)生的窗體不同。
vb.net 允許創(chuàng)建不同類型的應用程序,例如,創(chuàng)建ASP.NET和ASP.NET Web 服務應用程序,還允許創(chuàng)建控制臺應用程序和作為桌面服務運行的應用程序。但是vb 只能創(chuàng)建Windows窗體。
4、數(shù)據(jù)庫訪問的差別。
vb6.0是通過ADO(Active X Data Objext)來實現(xiàn)對數(shù)據(jù)庫訪問。而vb.net 是通過ADO.NET來訪問數(shù)據(jù)庫。
擴展資料
Visual Basic(簡稱VB)是Microsoft公司開發(fā)的一種通用的基于對象的程序設計語言,為結構化的、模塊化的、面向對象的、包含協(xié)助開發(fā)環(huán)境的事件驅動為機制的可視化程序設計語言。是一種可用于微軟自家產(chǎn)品開發(fā)的語言。
“Visual” 指的是開發(fā)圖形用戶界面 (GUI) 的方法——不需編寫大量代碼去描述界面元素的外觀和位置,而只要把預先建立的對象add到屏幕上的一點即可。
“Basic”指的是 BASIC (Beginners All-Purpose Symbolic Instruction Code) 語言,是一種在計算技術發(fā)展歷史上應用得最為廣泛的語言。
Visual Basic源自于BASIC編程語言。VB擁有圖形用戶界面(GUI)和快速應用程序開發(fā)(RAD)系統(tǒng),可以輕易的使用DAO、RDO、ADO連接數(shù)據(jù)庫,或者輕松的創(chuàng)建Active?X控件,用于高效生成類型安全和面向對象的應用程序 。
參考資料:百度百科-Visual Basic