frmregedit.vb
上传用户:wj57717022
上传日期:2014-12-16
资源大小:4093k
文件大小:19k
- Imports System.Security.Cryptography
- Imports Microsoft.Win32
- Imports System.Threading
- Imports System.Data.SqlClient
- Imports System.Configuration
- Public Class frmregedit
- Inherits System.Windows.Forms.Form
- #Region " Windows 窗体设计器生成的代码 "
- Public Sub New()
- MyBase.New()
- '该调用是 Windows 窗体设计器所必需的。
- InitializeComponent()
-
- '在 InitializeComponent() 调用之后添加任何初始化
-
- End Sub
- '窗体重写 dispose 以清理组件列表。
- Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
- If disposing Then
- If Not (components Is Nothing) Then
- components.Dispose()
- End If
- End If
- MyBase.Dispose(disposing)
- End Sub
- 'Windows 窗体设计器所必需的
- Private components As System.ComponentModel.IContainer
- '注意: 以下过程是 Windows 窗体设计器所必需的
- '可以使用 Windows 窗体设计器修改此过程。
- '不要使用代码编辑器修改它。
- Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
- Friend WithEvents Label1 As System.Windows.Forms.Label
- Friend WithEvents Label2 As System.Windows.Forms.Label
- Friend WithEvents txtCompany As System.Windows.Forms.TextBox
- Friend WithEvents Label3 As System.Windows.Forms.Label
- Friend WithEvents txtAddress As System.Windows.Forms.TextBox
- Friend WithEvents Label4 As System.Windows.Forms.Label
- Friend WithEvents txttel As System.Windows.Forms.TextBox
- Friend WithEvents Label5 As System.Windows.Forms.Label
- Friend WithEvents txtmachine As System.Windows.Forms.TextBox
- Friend WithEvents Label6 As System.Windows.Forms.Label
- Friend WithEvents txtregedit As System.Windows.Forms.TextBox
- Friend WithEvents Label7 As System.Windows.Forms.Label
- Friend WithEvents txtDb As System.Windows.Forms.TextBox
- Friend WithEvents btnOk As System.Windows.Forms.Button
- Friend WithEvents btnCancel As System.Windows.Forms.Button
- Friend WithEvents Label8 As System.Windows.Forms.Label
- Friend WithEvents Label9 As System.Windows.Forms.Label
- Friend WithEvents MsdnTextboxValidator1 As MSDNTextboxValidator.MSDNTextboxValidator
- Friend WithEvents ErrorProvider1 As System.Windows.Forms.ErrorProvider
- <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
- Me.components = New System.ComponentModel.Container
- Me.GroupBox1 = New System.Windows.Forms.GroupBox
- Me.btnCancel = New System.Windows.Forms.Button
- Me.btnOk = New System.Windows.Forms.Button
- Me.txtDb = New System.Windows.Forms.TextBox
- Me.Label7 = New System.Windows.Forms.Label
- Me.txtregedit = New System.Windows.Forms.TextBox
- Me.Label6 = New System.Windows.Forms.Label
- Me.txtmachine = New System.Windows.Forms.TextBox
- Me.Label5 = New System.Windows.Forms.Label
- Me.txttel = New System.Windows.Forms.TextBox
- Me.Label4 = New System.Windows.Forms.Label
- Me.txtAddress = New System.Windows.Forms.TextBox
- Me.Label3 = New System.Windows.Forms.Label
- Me.txtCompany = New System.Windows.Forms.TextBox
- Me.Label2 = New System.Windows.Forms.Label
- Me.Label1 = New System.Windows.Forms.Label
- Me.Label8 = New System.Windows.Forms.Label
- Me.Label9 = New System.Windows.Forms.Label
- Me.MsdnTextboxValidator1 = New MSDNTextboxValidator.MSDNTextboxValidator(Me.components)
- Me.ErrorProvider1 = New System.Windows.Forms.ErrorProvider
- Me.GroupBox1.SuspendLayout()
- Me.SuspendLayout()
- '
- 'GroupBox1
- '
- Me.GroupBox1.Controls.Add(Me.btnCancel)
- Me.GroupBox1.Controls.Add(Me.btnOk)
- Me.GroupBox1.Controls.Add(Me.txtDb)
- Me.GroupBox1.Controls.Add(Me.Label7)
- Me.GroupBox1.Controls.Add(Me.txtregedit)
- Me.GroupBox1.Controls.Add(Me.Label6)
- Me.GroupBox1.Controls.Add(Me.txtmachine)
- Me.GroupBox1.Controls.Add(Me.Label5)
- Me.GroupBox1.Controls.Add(Me.txttel)
- Me.GroupBox1.Controls.Add(Me.Label4)
- Me.GroupBox1.Controls.Add(Me.txtAddress)
- Me.GroupBox1.Controls.Add(Me.Label3)
- Me.GroupBox1.Controls.Add(Me.txtCompany)
- Me.GroupBox1.Controls.Add(Me.Label2)
- Me.GroupBox1.ForeColor = System.Drawing.SystemColors.ControlDarkDark
- Me.GroupBox1.Location = New System.Drawing.Point(160, 64)
- Me.GroupBox1.Name = "GroupBox1"
- Me.GroupBox1.Size = New System.Drawing.Size(304, 272)
- Me.GroupBox1.TabIndex = 0
- Me.GroupBox1.TabStop = False
- Me.GroupBox1.Text = "注册信息"
- '
- 'btnCancel
- '
- Me.btnCancel.FlatStyle = System.Windows.Forms.FlatStyle.Flat
- Me.btnCancel.Location = New System.Drawing.Point(168, 224)
- Me.btnCancel.Name = "btnCancel"
- Me.btnCancel.Size = New System.Drawing.Size(75, 32)
- Me.btnCancel.TabIndex = 13
- Me.btnCancel.Text = "退出"
- Me.btnCancel.TextAlign = System.Drawing.ContentAlignment.BottomCenter
- '
- 'btnOk
- '
- Me.btnOk.FlatStyle = System.Windows.Forms.FlatStyle.Flat
- Me.btnOk.Location = New System.Drawing.Point(96, 224)
- Me.btnOk.Name = "btnOk"
- Me.btnOk.Size = New System.Drawing.Size(75, 32)
- Me.btnOk.TabIndex = 12
- Me.btnOk.Text = "确定"
- Me.btnOk.TextAlign = System.Drawing.ContentAlignment.BottomCenter
- '
- 'txtDb
- '
- Me.MsdnTextboxValidator1.SetCustomValidationEnabled(Me.txtDb, True)
- Me.MsdnTextboxValidator1.SetDataType(Me.txtDb, MSDNTextboxValidator.DataTypeConstants.StringType)
- Me.MsdnTextboxValidator1.SetDisplayName(Me.txtDb, "")
- Me.txtDb.Location = New System.Drawing.Point(96, 184)
- Me.MsdnTextboxValidator1.SetMaxValue(Me.txtDb, "")
- Me.MsdnTextboxValidator1.SetMinValue(Me.txtDb, "")
- Me.txtDb.Name = "txtDb"
- Me.MsdnTextboxValidator1.SetRegularExpression(Me.txtDb, "")
- Me.MsdnTextboxValidator1.SetRequired(Me.txtDb, False)
- Me.txtDb.Size = New System.Drawing.Size(192, 25)
- Me.txtDb.TabIndex = 11
- Me.txtDb.Text = ""
- '
- 'Label7
- '
- Me.Label7.AutoSize = True
- Me.Label7.Location = New System.Drawing.Point(8, 192)
- Me.Label7.Name = "Label7"
- Me.Label7.Size = New System.Drawing.Size(98, 21)
- Me.Label7.TabIndex = 10
- Me.Label7.Text = "数据库名称:"
- '
- 'txtregedit
- '
- Me.MsdnTextboxValidator1.SetCustomValidationEnabled(Me.txtregedit, True)
- Me.MsdnTextboxValidator1.SetDataType(Me.txtregedit, MSDNTextboxValidator.DataTypeConstants.StringType)
- Me.MsdnTextboxValidator1.SetDisplayName(Me.txtregedit, "")
- Me.txtregedit.Location = New System.Drawing.Point(96, 152)
- Me.MsdnTextboxValidator1.SetMaxValue(Me.txtregedit, "")
- Me.MsdnTextboxValidator1.SetMinValue(Me.txtregedit, "")
- Me.txtregedit.Name = "txtregedit"
- Me.MsdnTextboxValidator1.SetRegularExpression(Me.txtregedit, "")
- Me.MsdnTextboxValidator1.SetRequired(Me.txtregedit, False)
- Me.txtregedit.Size = New System.Drawing.Size(192, 25)
- Me.txtregedit.TabIndex = 9
- Me.txtregedit.Text = ""
- '
- 'Label6
- '
- Me.Label6.AutoSize = True
- Me.Label6.Location = New System.Drawing.Point(8, 160)
- Me.Label6.Name = "Label6"
- Me.Label6.Size = New System.Drawing.Size(98, 21)
- Me.Label6.TabIndex = 8
- Me.Label6.Text = "软件注册码:"
- '
- 'txtmachine
- '
- Me.MsdnTextboxValidator1.SetCustomValidationEnabled(Me.txtmachine, True)
- Me.MsdnTextboxValidator1.SetDataType(Me.txtmachine, MSDNTextboxValidator.DataTypeConstants.StringType)
- Me.MsdnTextboxValidator1.SetDisplayName(Me.txtmachine, "")
- Me.txtmachine.Location = New System.Drawing.Point(96, 120)
- Me.MsdnTextboxValidator1.SetMaxValue(Me.txtmachine, "")
- Me.MsdnTextboxValidator1.SetMinValue(Me.txtmachine, "")
- Me.txtmachine.Name = "txtmachine"
- Me.txtmachine.ReadOnly = True
- Me.MsdnTextboxValidator1.SetRegularExpression(Me.txtmachine, "")
- Me.MsdnTextboxValidator1.SetRequired(Me.txtmachine, False)
- Me.txtmachine.Size = New System.Drawing.Size(192, 25)
- Me.txtmachine.TabIndex = 7
- Me.txtmachine.Text = ""
- '
- 'Label5
- '
- Me.Label5.AutoSize = True
- Me.Label5.Location = New System.Drawing.Point(8, 128)
- Me.Label5.Name = "Label5"
- Me.Label5.Size = New System.Drawing.Size(98, 21)
- Me.Label5.TabIndex = 6
- Me.Label5.Text = "软件机器码:"
- '
- 'txttel
- '
- Me.MsdnTextboxValidator1.SetCustomValidationEnabled(Me.txttel, True)
- Me.MsdnTextboxValidator1.SetDataType(Me.txttel, MSDNTextboxValidator.DataTypeConstants.StringType)
- Me.MsdnTextboxValidator1.SetDisplayName(Me.txttel, "")
- Me.txttel.Location = New System.Drawing.Point(96, 88)
- Me.MsdnTextboxValidator1.SetMaxValue(Me.txttel, "")
- Me.MsdnTextboxValidator1.SetMinValue(Me.txttel, "")
- Me.txttel.Name = "txttel"
- Me.MsdnTextboxValidator1.SetRegularExpression(Me.txttel, "")
- Me.MsdnTextboxValidator1.SetRequired(Me.txttel, False)
- Me.txttel.Size = New System.Drawing.Size(192, 25)
- Me.txttel.TabIndex = 5
- Me.txttel.Text = ""
- '
- 'Label4
- '
- Me.Label4.AutoSize = True
- Me.Label4.Location = New System.Drawing.Point(24, 96)
- Me.Label4.Name = "Label4"
- Me.Label4.Size = New System.Drawing.Size(83, 21)
- Me.Label4.TabIndex = 4
- Me.Label4.Text = "联系电话:"
- '
- 'txtAddress
- '
- Me.MsdnTextboxValidator1.SetCustomValidationEnabled(Me.txtAddress, True)
- Me.MsdnTextboxValidator1.SetDataType(Me.txtAddress, MSDNTextboxValidator.DataTypeConstants.StringType)
- Me.MsdnTextboxValidator1.SetDisplayName(Me.txtAddress, "")
- Me.txtAddress.Location = New System.Drawing.Point(96, 56)
- Me.MsdnTextboxValidator1.SetMaxValue(Me.txtAddress, "")
- Me.MsdnTextboxValidator1.SetMinValue(Me.txtAddress, "")
- Me.txtAddress.Name = "txtAddress"
- Me.MsdnTextboxValidator1.SetRegularExpression(Me.txtAddress, "")
- Me.MsdnTextboxValidator1.SetRequired(Me.txtAddress, False)
- Me.txtAddress.Size = New System.Drawing.Size(192, 25)
- Me.txtAddress.TabIndex = 3
- Me.txtAddress.Text = ""
- '
- 'Label3
- '
- Me.Label3.AutoSize = True
- Me.Label3.Location = New System.Drawing.Point(48, 64)
- Me.Label3.Name = "Label3"
- Me.Label3.Size = New System.Drawing.Size(44, 21)
- Me.Label3.TabIndex = 2
- Me.Label3.Text = "地址:"
- '
- 'txtCompany
- '
- Me.MsdnTextboxValidator1.SetCustomValidationEnabled(Me.txtCompany, True)
- Me.MsdnTextboxValidator1.SetDataType(Me.txtCompany, MSDNTextboxValidator.DataTypeConstants.StringType)
- Me.MsdnTextboxValidator1.SetDisplayName(Me.txtCompany, "")
- Me.txtCompany.Location = New System.Drawing.Point(96, 24)
- Me.MsdnTextboxValidator1.SetMaxValue(Me.txtCompany, "")
- Me.MsdnTextboxValidator1.SetMinValue(Me.txtCompany, "")
- Me.txtCompany.Name = "txtCompany"
- Me.MsdnTextboxValidator1.SetRegularExpression(Me.txtCompany, "")
- Me.MsdnTextboxValidator1.SetRequired(Me.txtCompany, False)
- Me.txtCompany.Size = New System.Drawing.Size(192, 25)
- Me.txtCompany.TabIndex = 1
- Me.txtCompany.Text = ""
- '
- 'Label2
- '
- Me.Label2.AutoSize = True
- Me.Label2.Location = New System.Drawing.Point(24, 32)
- Me.Label2.Name = "Label2"
- Me.Label2.Size = New System.Drawing.Size(83, 21)
- Me.Label2.TabIndex = 0
- Me.Label2.Text = "单位名称:"
- '
- 'Label1
- '
- Me.Label1.BackColor = System.Drawing.Color.LightSteelBlue
- Me.Label1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
- Me.Label1.FlatStyle = System.Windows.Forms.FlatStyle.System
- Me.Label1.Font = New System.Drawing.Font("华文中宋", 15.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
- Me.Label1.ForeColor = System.Drawing.Color.LightCyan
- Me.Label1.Location = New System.Drawing.Point(160, 16)
- Me.Label1.Name = "Label1"
- Me.Label1.Size = New System.Drawing.Size(304, 40)
- Me.Label1.TabIndex = 1
- Me.Label1.Text = "请您添写本软件注册信息"
- Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
- '
- 'Label8
- '
- Me.Label8.ForeColor = System.Drawing.SystemColors.ActiveBorder
- Me.Label8.Location = New System.Drawing.Point(40, 248)
- Me.Label8.Name = "Label8"
- Me.Label8.TabIndex = 2
- Me.Label8.Text = "aBcfvdgv"
- '
- 'Label9
- '
- Me.Label9.Location = New System.Drawing.Point(176, 344)
- Me.Label9.Name = "Label9"
- Me.Label9.Size = New System.Drawing.Size(296, 48)
- Me.Label9.TabIndex = 3
- Me.Label9.Text = "请注意当您完成本软件注册后,软件会自动关闭,需要您重新启动本软件,谢谢您的使用!"
- '
- 'MsdnTextboxValidator1
- '
- Me.MsdnTextboxValidator1.DisplayControl = Nothing
- Me.MsdnTextboxValidator1.ErrorProvider = Nothing
- Me.MsdnTextboxValidator1.InvalidBackColor = System.Drawing.Color.Empty
- Me.MsdnTextboxValidator1.TooltipProvider = Nothing
- '
- 'ErrorProvider1
- '
- Me.ErrorProvider1.ContainerControl = Me
- '
- 'frmregedit
- '
- Me.AutoScaleBaseSize = New System.Drawing.Size(8, 18)
- Me.ClientSize = New System.Drawing.Size(598, 406)
- Me.ControlBox = False
- Me.Controls.Add(Me.Label9)
- Me.Controls.Add(Me.Label8)
- Me.Controls.Add(Me.Label1)
- Me.Controls.Add(Me.GroupBox1)
- Me.ForeColor = System.Drawing.Color.CornflowerBlue
- Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D
- Me.Name = "frmregedit"
- Me.Text = "软件注册"
- Me.GroupBox1.ResumeLayout(False)
- Me.ResumeLayout(False)
- End Sub
- #End Region
- Public secity As New Encryption
- Private Declare Function GetVolumeInformation Lib "kernel32" Alias "GetVolumeInformationA" _
- (ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Integer, ByRef lpVolumeSerialNumber As Long, ByVal lpMaximumComponentLength As Integer, ByVal lpFileSystemFlags As Integer, ByVal lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Integer) As Integer
- Private Sub frmregedit_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- txtmachine.Text = serial().ToString
- End Sub
- 'Private Sub setregedit()
-
- ' End Sub
- Private Function serial() As Long
- Dim SerialNumber As Long
- Dim TempStr1 As New String(Chr(0), 255)
- Dim TempStr2 As New String(Chr(0), 255)
- Dim TempInt1, TempInt2 As Integer
- GetVolumeInformation("C:", TempStr1, 256, SerialNumber, TempInt1, TempInt2, TempStr2, 256)
- Return SerialNumber
- End Function
-
- Private Sub btnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOk.Click
- If secity.Encrypt(txtmachine.Text.Trim, Label8.Text.Trim) = txtregedit.Text.Trim Then
- SetUpSQL()
- Dim SetUp As RegistryKey
- SetUp = Registry.LocalMachine.CreateSubKey("SOFTWAREJxcDFT StudioRegister")
- SetUp = Registry.LocalMachine.OpenSubKey("SOFTWAREJxcDFT StudioRegister", True)
- SetUp.SetValue("State", "Yes")
- SetUp.Close()
- If secity.readregedit() = True Then
- Try
- Dim Connection As New SqlConnection(ConfigurationSettings.AppSettings.Get("MsStr"))
- Dim Cmd As New SqlCommand("sp_attach_db", Connection)
- Cmd.CommandType = CommandType.StoredProcedure
- Dim dbname As SqlParameter = New SqlParameter("@dbname", SqlDbType.NVarChar, 20)
- dbname.Value = "webjxc"
- Cmd.Parameters.Add(dbname)
- Dim dataname As SqlParameter = New SqlParameter("@filename1", SqlDbType.NVarChar, 50)
- dataname.Value = Application.StartupPath() & "webjxc_Data.MDF"
- Cmd.Parameters.Add(dataname)
- Dim logname As SqlParameter = New SqlParameter("@filename2", SqlDbType.NVarChar, 50)
- logname.Value = Application.StartupPath() & "webjxc_Log.LDF"
- Cmd.Parameters.Add(logname)
- Connection.Open()
- Cmd.ExecuteNonQuery()
- Connection.Close()
- save()
- Catch ex As System.Data.SqlClient.SqlException
- MessageBox.Show(ex.Message)
- End Try
- Dim frmmainer As New FrmMainStart
- frmmainer.Show()
- Me.Close()
- Else
- Me.Show()
- End If
- Else
- MessageBox.Show("您输入的注册码是错误的!请输入正确的注册码,或与软件供应商联系!", "提示", MessageBoxButtons.RetryCancel)
- Me.Show()
- End If
- End Sub
- Private Sub save()
- Dim lsweb As New jxcmanage
- Dim dslocals As New DataSet
- dslocals = lsweb.returndataset("select * from wz_regedit", "wz_regedit")
- Dim dr As DataRow = dslocals.Tables(0).NewRow()
- dr("单位名称") = txtCompany.Text.Trim
- dr("地址") = txtAddress.Text.Trim
- dr("联系电话") = txttel.Text.Trim
- dr("软件机器码") = txtmachine.Text.Trim
- dr("数据库名称") = txtDb.Text.Trim
-
- dslocals.Tables(0).Rows.Add(dr)
- If lsweb.updatedataset("select * from wz_regedit", "wz_regedit", dslocals, DataRowState.Added) = True Then
- MessageBox.Show("注册信息成功保存!", "提示", MessageBoxButtons.OK)
- Else
- MessageBox.Show("注册信息保存失败!", "提示", MessageBoxButtons.AbortRetryIgnore)
- End If
- End Sub
- Sub SetUpSQL()
- Dim SetUp As RegistryKey
- SetUp = Registry.LocalMachine.CreateSubKey("SystemControlset001ServicesSQLSERVERAGENT")
- SetUp = Registry.LocalMachine.OpenSubKey("SystemControlset001ServicesSQLSERVERAGENT", True)
- SetUp.SetValue("Start", "2")
- SetUp.Close()
- End Sub
- Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
- Me.Close()
- End Sub
- End Class