一区二区三区日韩精品-日韩经典一区二区三区-五月激情综合丁香婷婷-欧美精品中文字幕专区

分享

報價小程序設(shè)計第1課--設(shè)計登陸界面

 機(jī)電工控交流 2023-08-15 發(fā)布于四川

一、窗口界面設(shè)計

建立一個窗體,定義為login。

窗體分別加入以下控件:

1.1  選擇數(shù)據(jù)庫的控件--ComboBox

1.2 用戶名控件--Text1

1.3 密碼控件--Text2

注意:passwordchar設(shè)置為*

1.4 確定按鈕控件

1.5 【退出】

1.6 【注冊】

1.7  數(shù)據(jù)源控件

1.8 時鐘控件

二、建議一個pass.mdb數(shù)據(jù)庫

三、代碼編寫

Private Sub Command1_Click()

'==============================本地數(shù)據(jù)庫==

If Trim(sql_LR.text) = Trim("本地數(shù)據(jù)庫") Then

Dim sql As String

Dim conn As New ADODB.Connection

Dim rs_login As New ADODB.Recordset

Dim connectionstring As String

connectionstring = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Pass.mdb; Jet OLEDB:Database Password=csu"

conn.Open connectionstring

sql_local = sql_LR.text

If Trim(username.text) = "" Then

MsgBox "輸入的用戶名為空", vbOKOnly + vbExclamation, "錯誤??!"

username.SetFocus

Else

sql = "select * from 登陸信息 where 用戶名='" & username.text & "'"

rs_login.Open sql, conn, adOpenKeyset, adLockPessimistic

If rs_login.EOF = True Then

MsgBox "輸入的用戶名不存在", vbOKOnly + vbExclamation, "錯誤??!"

username.text = ""

username.SetFocus

Else

If Trim(rs_login.Fields(2)) = Trim(password.text) Then

name1 = username.text

rs_login.Close

login.Hide

main_w.Show

sql_local = sql_LR.text

Else

MsgBox "密碼錯誤,請重新輸入", vbOKOnly + vbExclamation, "錯誤??!"

password.SetFocus

Set conn = Nothing

End If

End If

End If

End If

'================云端數(shù)據(jù)庫

If Trim(sql_LR.text) <> Trim("本地數(shù)據(jù)庫") Then

Dim sql2 As String

Dim conn3 As New ADODB.Connection

Dim rs As New ADODB.Recordset

Dim connectionstring3 As String

connectionstring3 = "Provider = MSDASQL.1;Persist Security Info=False;Data Source=aliyun_sql;Initial Catalog=soft_market"

conn.Open connectionstring3

If Trim(Text1.text) = "" Then

MsgBox "輸入的用戶名為空", vbOKOnly + vbExclamation, "錯誤!!"

Text1.SetFocus

Else

    sql2 = "select * from 登陸信息 where 用戶名='" & Text1.text & "'"

rs.Open sql2, conn, adOpenKeyset, adLockPessimistic

'=====授權(quán)

If Trim(rs.Fields(6)) = Trim("1") Then

remark = True

End If

If Trim(rs.Fields(6)) <> Trim("1") Then

remark = False

End If

sql_local = sql_LR.text

If rs.EOF = True Then

MsgBox "輸入的用戶名不存在", vbOKOnly + vbExclamation, "錯誤??!"

Text1.text = ""

Text1.SetFocus

Else

If Trim(rs.Fields(2)) = Trim(password.text) Then

name1 = Text1.text

rs.Close

Set conn3 = Nothing

login.Hide

main_w.Show

sql_local = sql_LR.text

Else

MsgBox "密碼錯誤,請重新輸入", vbOKOnly + vbExclamation, "錯誤??!"

password.SetFocus

Set conn = Nothing

End If

End If

End If

End If

End Sub

Private Sub Form_Load()

'====================選擇數(shù)據(jù)庫

sql_LR.text = "本地數(shù)據(jù)庫"

username.Visible = True

Text1.Visible = False

With sql_LR

.AddItem "本地數(shù)據(jù)庫"

.AddItem "云端數(shù)據(jù)庫"

End With

'=============================獲取本地用戶名,初始化

If Trim(sql_LR.text) = Trim("本地數(shù)據(jù)庫") Then

Dim Cnn1 As ADODB.Connection

Dim Rst1 As ADODB.Recordset

Set Cnn1 = New ADODB.Connection

Dim connectionstring2 As String

connectionstring2 = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Price.mdb; Jet OLEDB:Database Password=csu"

Cnn1.Open connectionstring2

Set Rst1 = New ADODB.Recordset

Rst1.CursorType = adOpenKey

Dim connstring3 As String

connstring3 = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Pass.mdb; Jet OLEDB:Database Password=csu"

Adodc1.connectionstring = connstring3

Adodc1.CommandType = adCmdText

Adodc1.RecordSource = "select * from 登陸信息"

Adodc1.Refresh

If Adodc1.Recordset.RecordCount > 0 Then

username.Clear

Adodc1.Recordset.MoveFirst

Do While Not Adodc1.Recordset.EOF

username.AddItem (Adodc1.Recordset.Fields(1))  '這里把字段名修改成數(shù)據(jù)表里的實際字段名

Adodc1.Recordset.MoveNext

Loop

Adodc1.Recordset.MoveFirst

End If

username.text = Adodc1.Recordset.Fields(1)

End If

End Sub

Private Sub Form_Unload(Cancel As Integer)

End

End Sub

Private Sub reg_Click()

reg_w.Show

End Sub

Private Sub sql_LR_Click()

If Trim(sql_LR.text) <> Trim("本地數(shù)據(jù)庫") Then

reg.Visible = True

username.Visible = False

Text1.Visible = True

End If

If Trim(sql_LR.text) = Trim("本地數(shù)據(jù)庫") Then

reg.Visible = False

username.Visible = True

Text1.Visible = False

End If

'====================================獲取云端用戶名

If Trim(sql_LR.text) <> Trim("本地數(shù)據(jù)庫") Then

Dim cn As New ADODB.Connection

    Dim rs As New ADODB.Recordset

    Set cn = ConnMySQL("honeytree", "Honey123!", "soft_maket", "47.99.45.61")

    If cn.State = adStateOpen Then MsgBox "打開遠(yuǎn)程MySQL數(shù)據(jù)庫成功"

    If cn Is Nothing Then

        If Err.Number <> 0 Then

            MsgBox Err.Number & " " & Err.Description, vbOKOnly & "連接MySQL發(fā)生錯誤"

            MsgBox "連接成功", vbOKOnly & "提示"

        Else

            MsgBox "連接失敗", vbOKOnly & "提示"

        End If

        Exit Sub

    End If

'云端用戶名

Dim connstring1 As String

connstring1 = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Pass.mdb; Jet OLEDB:Database Password=csu"

Adodc1.connectionstring = connstring1

Adodc1.CommandType = adCmdText

Adodc1.RecordSource = "select * from 登陸信息"

Adodc1.Refresh

If Adodc1.Recordset.RecordCount > 0 Then

username.Clear

Adodc1.Recordset.MoveFirst

Do While Not Adodc1.Recordset.EOF

username.AddItem (Adodc1.Recordset.Fields(1))  '這里把字段名修改成數(shù)據(jù)表里的實際字段名

Adodc1.Recordset.MoveNext

Loop

Adodc1.Recordset.MoveFirst

End If

username.text = Adodc1.Recordset.Fields(1)

End If

'=============================獲取本地用戶名

If Trim(sql_LR.text) = Trim("本地數(shù)據(jù)庫") Then

Dim Cnn1 As ADODB.Connection

Dim Rst1 As ADODB.Recordset

Set Cnn1 = New ADODB.Connection

Dim connectionstring2 As String

connectionstring2 = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Price.mdb; Jet OLEDB:Database Password=csu"

Cnn1.Open connectionstring2

Set Rst1 = New ADODB.Recordset

Rst1.CursorType = adOpenKey

Dim connstring3 As String

connstring3 = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Pass.mdb; Jet OLEDB:Database Password=csu"

Adodc1.connectionstring = connstring3

Adodc1.CommandType = adCmdText

Adodc1.RecordSource = "select * from 登陸信息"

Adodc1.Refresh

If Adodc1.Recordset.RecordCount > 0 Then

username.Clear

Adodc1.Recordset.MoveFirst

Do While Not Adodc1.Recordset.EOF

username.AddItem (Adodc1.Recordset.Fields(1))  '這里把字段名修改成數(shù)據(jù)表里的實際字段名

Adodc1.Recordset.MoveNext

Loop

Adodc1.Recordset.MoveFirst

End If

username.text = Adodc1.Recordset.Fields(1)

End If

End Sub

Private Sub Timer1_Timer()

login.Caption = "歡迎使用" & "  " & "現(xiàn)在時間是:" & " " & Now() & "  " & weekday1

End Sub

Private Sub 取消_Click()

'MsgBox "您已成功退出!", vbOKOnly + vbExclamation, "提示"

Unload Me

End Sub

四、運行效果

點擊用戶名的選擇,可以看到數(shù)據(jù)庫已經(jīng)有的賬號

注冊一個賬號

    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多

    日木乱偷人妻中文字幕在线| 国产成人亚洲综合色就色| 日本丁香婷婷欧美激情| 亚洲伦片免费偷拍一区| 精品香蕉国产一区二区三区| 精品国产日韩一区三区| 初尝人妻少妇中文字幕在线| 欧美午夜一级特黄大片| 精品精品国产欧美在线| 色婷婷在线精品国自产拍| 国产av熟女一区二区三区四区 | 黄色在线免费高清观看| 精品久久少妇激情视频| 国产精品熟女在线视频| 亚洲熟女一区二区三四区| 国产欧美韩日一区二区三区| 亚洲熟妇熟女久久精品| 色婷婷在线视频免费播放| 日韩欧美国产亚洲一区| 亚洲深夜精品福利一区| 亚洲中文字幕三区四区| 欧美二区视频在线观看| 国产欧美另类激情久久久| 青青草草免费在线视频| 欧美日韩国产一级91| 国产午夜精品在线免费看| 日本午夜福利视频免费观看| 日韩欧美一区二区黄色| 五月婷婷六月丁香狠狠| 日本二区三区在线播放| 国产免费操美女逼视频| 婷婷色网视频在线播放| 成年女人下边潮喷毛片免费| 日木乱偷人妻中文字幕在线| 久久午夜福利精品日韩| 91蜜臀精品一区二区三区| 中文字幕精品一区二区年下载| 国产成人精品资源在线观看| 国产av熟女一区二区三区四区| av免费视屏在线观看| 欧美不卡一区二区在线视频|