www.pudn.com > SalesManager.rar > frmCusAdd.vb
Imports System.Data.OleDb
Public Class frmCusAdd
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 PictureBox2 As System.Windows.Forms.PictureBox
Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
Friend WithEvents btnReset As System.Windows.Forms.Button
Friend WithEvents btnCancel As System.Windows.Forms.Button
Friend WithEvents btnAdd As System.Windows.Forms.Button
Friend WithEvents labCusLevel As System.Windows.Forms.Label
Friend WithEvents txtCusDate As System.Windows.Forms.TextBox
Friend WithEvents Label9 As System.Windows.Forms.Label
Friend WithEvents Label8 As System.Windows.Forms.Label
Friend WithEvents Label7 As System.Windows.Forms.Label
Friend WithEvents Label6 As System.Windows.Forms.Label
Friend WithEvents Label5 As System.Windows.Forms.Label
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents txtCusBankNumber As System.Windows.Forms.TextBox
Friend WithEvents txtCusPhone As System.Windows.Forms.TextBox
Friend WithEvents txtCusPost As System.Windows.Forms.TextBox
Friend WithEvents txtCusAddress As System.Windows.Forms.TextBox
Friend WithEvents txtCusName As System.Windows.Forms.TextBox
Friend WithEvents txtCusID As System.Windows.Forms.TextBox
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(frmCusAdd))
Me.PictureBox2 = New System.Windows.Forms.PictureBox
Me.PictureBox1 = New System.Windows.Forms.PictureBox
Me.btnReset = New System.Windows.Forms.Button
Me.btnCancel = New System.Windows.Forms.Button
Me.btnAdd = New System.Windows.Forms.Button
Me.labCusLevel = New System.Windows.Forms.Label
Me.txtCusDate = New System.Windows.Forms.TextBox
Me.Label9 = New System.Windows.Forms.Label
Me.Label8 = New System.Windows.Forms.Label
Me.Label7 = New System.Windows.Forms.Label
Me.Label6 = New System.Windows.Forms.Label
Me.Label5 = New System.Windows.Forms.Label
Me.Label4 = New System.Windows.Forms.Label
Me.txtCusBankNumber = New System.Windows.Forms.TextBox
Me.txtCusPhone = New System.Windows.Forms.TextBox
Me.txtCusPost = New System.Windows.Forms.TextBox
Me.txtCusAddress = New System.Windows.Forms.TextBox
Me.txtCusName = New System.Windows.Forms.TextBox
Me.txtCusID = New System.Windows.Forms.TextBox
Me.Label3 = New System.Windows.Forms.Label
Me.GroupBox1 = New System.Windows.Forms.GroupBox
Me.GroupBox1.SuspendLayout()
Me.SuspendLayout()
'
'PictureBox2
'
Me.PictureBox2.Image = CType(resources.GetObject("PictureBox2.Image"), System.Drawing.Image)
Me.PictureBox2.Location = New System.Drawing.Point(56, 20)
Me.PictureBox2.Name = "PictureBox2"
Me.PictureBox2.Size = New System.Drawing.Size(61, 61)
Me.PictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize
Me.PictureBox2.TabIndex = 84
Me.PictureBox2.TabStop = False
'
'PictureBox1
'
Me.PictureBox1.Image = CType(resources.GetObject("PictureBox1.Image"), System.Drawing.Image)
Me.PictureBox1.Location = New System.Drawing.Point(12, 16)
Me.PictureBox1.Name = "PictureBox1"
Me.PictureBox1.Size = New System.Drawing.Size(116, 236)
Me.PictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
Me.PictureBox1.TabIndex = 83
Me.PictureBox1.TabStop = False
'
'btnReset
'
Me.btnReset.Location = New System.Drawing.Point(292, 244)
Me.btnReset.Name = "btnReset"
Me.btnReset.Size = New System.Drawing.Size(64, 24)
Me.btnReset.TabIndex = 87
Me.btnReset.Text = "重置(&R)"
'
'btnCancel
'
Me.btnCancel.Location = New System.Drawing.Point(368, 244)
Me.btnCancel.Name = "btnCancel"
Me.btnCancel.Size = New System.Drawing.Size(64, 24)
Me.btnCancel.TabIndex = 86
Me.btnCancel.Text = "关闭(&C)"
'
'btnAdd
'
Me.btnAdd.Location = New System.Drawing.Point(216, 244)
Me.btnAdd.Name = "btnAdd"
Me.btnAdd.Size = New System.Drawing.Size(64, 24)
Me.btnAdd.TabIndex = 85
Me.btnAdd.Text = "添加(&A)"
'
'labCusLevel
'
Me.labCusLevel.Font = New System.Drawing.Font("宋体", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.labCusLevel.ForeColor = System.Drawing.SystemColors.ControlText
Me.labCusLevel.Location = New System.Drawing.Point(204, 27)
Me.labCusLevel.Name = "labCusLevel"
Me.labCusLevel.Size = New System.Drawing.Size(64, 16)
Me.labCusLevel.TabIndex = 102
Me.labCusLevel.Text = "★☆☆☆"
'
'txtCusDate
'
Me.txtCusDate.AutoSize = False
Me.txtCusDate.Location = New System.Drawing.Point(80, 195)
Me.txtCusDate.MaxLength = 10
Me.txtCusDate.Name = "txtCusDate"
Me.txtCusDate.Size = New System.Drawing.Size(124, 18)
Me.txtCusDate.TabIndex = 101
Me.txtCusDate.Text = ""
'
'Label9
'
Me.Label9.Font = New System.Drawing.Font("宋体", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Label9.ForeColor = System.Drawing.SystemColors.ControlText
Me.Label9.Location = New System.Drawing.Point(12, 195)
Me.Label9.Name = "Label9"
Me.Label9.Size = New System.Drawing.Size(64, 16)
Me.Label9.TabIndex = 100
Me.Label9.Text = "加入日期:"
'
'Label8
'
Me.Label8.Font = New System.Drawing.Font("宋体", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Label8.ForeColor = System.Drawing.SystemColors.ControlText
Me.Label8.Location = New System.Drawing.Point(12, 167)
Me.Label8.Name = "Label8"
Me.Label8.Size = New System.Drawing.Size(64, 16)
Me.Label8.TabIndex = 99
Me.Label8.Text = "银行帐号:"
'
'Label7
'
Me.Label7.Font = New System.Drawing.Font("宋体", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Label7.ForeColor = System.Drawing.SystemColors.ControlText
Me.Label7.Location = New System.Drawing.Point(12, 139)
Me.Label7.Name = "Label7"
Me.Label7.Size = New System.Drawing.Size(64, 16)
Me.Label7.TabIndex = 98
Me.Label7.Text = "联系电话:"
'
'Label6
'
Me.Label6.Font = New System.Drawing.Font("宋体", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Label6.ForeColor = System.Drawing.SystemColors.ControlText
Me.Label6.Location = New System.Drawing.Point(12, 83)
Me.Label6.Name = "Label6"
Me.Label6.Size = New System.Drawing.Size(64, 16)
Me.Label6.TabIndex = 97
Me.Label6.Text = "客户地址:"
'
'Label5
'
Me.Label5.Font = New System.Drawing.Font("宋体", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Label5.ForeColor = System.Drawing.SystemColors.ControlText
Me.Label5.Location = New System.Drawing.Point(12, 111)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(64, 16)
Me.Label5.TabIndex = 96
Me.Label5.Text = "客户邮编:"
'
'Label4
'
Me.Label4.Font = New System.Drawing.Font("宋体", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Label4.ForeColor = System.Drawing.SystemColors.ControlText
Me.Label4.Location = New System.Drawing.Point(12, 55)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(64, 16)
Me.Label4.TabIndex = 95
Me.Label4.Text = "客户姓名:"
'
'txtCusBankNumber
'
Me.txtCusBankNumber.AutoSize = False
Me.txtCusBankNumber.Location = New System.Drawing.Point(80, 167)
Me.txtCusBankNumber.MaxLength = 20
Me.txtCusBankNumber.Name = "txtCusBankNumber"
Me.txtCusBankNumber.Size = New System.Drawing.Size(192, 18)
Me.txtCusBankNumber.TabIndex = 94
Me.txtCusBankNumber.Text = ""
'
'txtCusPhone
'
Me.txtCusPhone.AutoSize = False
Me.txtCusPhone.Location = New System.Drawing.Point(80, 139)
Me.txtCusPhone.MaxLength = 10
Me.txtCusPhone.Name = "txtCusPhone"
Me.txtCusPhone.Size = New System.Drawing.Size(124, 18)
Me.txtCusPhone.TabIndex = 93
Me.txtCusPhone.Text = ""
'
'txtCusPost
'
Me.txtCusPost.AutoSize = False
Me.txtCusPost.Location = New System.Drawing.Point(80, 111)
Me.txtCusPost.MaxLength = 10
Me.txtCusPost.Name = "txtCusPost"
Me.txtCusPost.Size = New System.Drawing.Size(124, 18)
Me.txtCusPost.TabIndex = 92
Me.txtCusPost.Text = ""
'
'txtCusAddress
'
Me.txtCusAddress.AutoSize = False
Me.txtCusAddress.Location = New System.Drawing.Point(80, 83)
Me.txtCusAddress.MaxLength = 10
Me.txtCusAddress.Name = "txtCusAddress"
Me.txtCusAddress.Size = New System.Drawing.Size(192, 18)
Me.txtCusAddress.TabIndex = 91
Me.txtCusAddress.Text = ""
'
'txtCusName
'
Me.txtCusName.AutoSize = False
Me.txtCusName.Location = New System.Drawing.Point(80, 55)
Me.txtCusName.MaxLength = 10
Me.txtCusName.Name = "txtCusName"
Me.txtCusName.Size = New System.Drawing.Size(124, 18)
Me.txtCusName.TabIndex = 90
Me.txtCusName.Text = ""
'
'txtCusID
'
Me.txtCusID.AutoSize = False
Me.txtCusID.Location = New System.Drawing.Point(80, 27)
Me.txtCusID.MaxLength = 8
Me.txtCusID.Name = "txtCusID"
Me.txtCusID.Size = New System.Drawing.Size(124, 18)
Me.txtCusID.TabIndex = 89
Me.txtCusID.Text = ""
'
'Label3
'
Me.Label3.Font = New System.Drawing.Font("宋体", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Label3.ForeColor = System.Drawing.SystemColors.ControlText
Me.Label3.Location = New System.Drawing.Point(12, 27)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(64, 16)
Me.Label3.TabIndex = 88
Me.Label3.Text = "客户编号:"
'
'GroupBox1
'
Me.GroupBox1.Controls.Add(Me.Label6)
Me.GroupBox1.Controls.Add(Me.Label7)
Me.GroupBox1.Controls.Add(Me.Label8)
Me.GroupBox1.Controls.Add(Me.Label9)
Me.GroupBox1.Controls.Add(Me.txtCusDate)
Me.GroupBox1.Controls.Add(Me.labCusLevel)
Me.GroupBox1.Controls.Add(Me.Label3)
Me.GroupBox1.Controls.Add(Me.txtCusID)
Me.GroupBox1.Controls.Add(Me.txtCusName)
Me.GroupBox1.Controls.Add(Me.txtCusAddress)
Me.GroupBox1.Controls.Add(Me.txtCusPost)
Me.GroupBox1.Controls.Add(Me.txtCusPhone)
Me.GroupBox1.Controls.Add(Me.txtCusBankNumber)
Me.GroupBox1.Controls.Add(Me.Label4)
Me.GroupBox1.Controls.Add(Me.Label5)
Me.GroupBox1.Location = New System.Drawing.Point(144, 12)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(288, 224)
Me.GroupBox1.TabIndex = 103
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "客户信息"
'
'frmCusAdd
'
Me.AcceptButton = Me.btnCancel
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(444, 275)
Me.Controls.Add(Me.GroupBox1)
Me.Controls.Add(Me.btnReset)
Me.Controls.Add(Me.btnCancel)
Me.Controls.Add(Me.btnAdd)
Me.Controls.Add(Me.PictureBox2)
Me.Controls.Add(Me.PictureBox1)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "frmCusAdd"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent
Me.Text = "客户添加"
Me.GroupBox1.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub frmCusAdd_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
txtCusID.Text = "自动"
txtCusName.Text = ""
txtCusAddress.Text = ""
txtCusPost.Text = ""
txtCusPhone.Text = ""
txtCusBankNumber.Text = ""
txtCusDate.Text = "系统时间"
labCusLevel.Text = ""
txtCusID.Enabled = False
txtCusDate.Enabled = False
End Sub
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
'检查输入的各字段是否符合要求
If txtCusName.Text = "" Then
MsgBox("客户姓名不可为空!", MsgBoxStyle.Information, "提示信息:")
Exit Sub
End If
If txtCusAddress.Text = "" Then
MsgBox("客户地址不可为空!", MsgBoxStyle.Information, "提示信息:")
Exit Sub
End If
If txtCusPost.Text = "" Then
MsgBox("客户邮编不可为空!", MsgBoxStyle.Information, "提示信息:")
Exit Sub
End If
If txtCusPhone.Text = "" Then
MsgBox("客户电话不可为空!", MsgBoxStyle.Information, "提示信息:")
Exit Sub
End If
If txtCusBankNumber.Text = "" Then
MsgBox("银行帐号不可为空!", MsgBoxStyle.Information, "提示信息:")
Exit Sub
End If
Dim myConn As OleDbConnection = New OleDbConnection(strConn)
Dim myComm As OleDbCommand = New OleDbCommand
myComm.Connection = myConn
myComm.CommandText = "select max(id) from customer"
Dim myReader As OleDbDataReader
myConn.Open()
Dim maxIDTemp As Long
Dim maxId As Object = myComm.ExecuteScalar()
If maxId Is System.DBNull.Value Then
maxIDTemp = 10000001
Else
Dim strid As String
strid = CStr(maxId)
maxIDTemp = CInt(strid)
maxIDTemp = maxIDTemp + 1
End If
myConn.Close()
Dim saveComm As OleDbCommand = New OleDbCommand
saveComm.CommandText = "insert into customer (id,name,address,post,phone,banknumber,cdate,clevel) values (@id,@name,@address,@post,@phone,@banknumber,@cdate,@clevel)"
saveComm.Connection = myConn
saveComm.Parameters.Add("@id", maxIDTemp)
saveComm.Parameters.Add("@name", txtCusName.Text)
saveComm.Parameters.Add("@address", txtCusAddress.Text)
saveComm.Parameters.Add("@post", txtCusPost.Text)
saveComm.Parameters.Add("@phone", txtCusPhone.Text)
saveComm.Parameters.Add("@banknumber", txtCusBankNumber.Text)
saveComm.Parameters.Add("@cdate", DateTime.Today)
saveComm.Parameters.Add("@clevel", "★☆☆☆")
myConn.Open()
Try
saveComm.ExecuteNonQuery()
Catch ex As Exception
MsgBox(Err.Description)
End Try
MsgBox("客户信息添加成功,客户号为: " & maxIDTemp, MsgBoxStyle.Information, "提示信息")
Me.Close()
End Sub
Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReset.Click
txtCusID.Text = "自动"
txtCusName.Text = ""
txtCusAddress.Text = ""
txtCusPost.Text = ""
txtCusPhone.Text = ""
txtCusBankNumber.Text = ""
txtCusDate.Text = "系统日期"
labCusLevel.Text = ""
End Sub
Private Sub txtCusPost_TextChange(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtCusPost.LostFocus
modMain.checkNum(txtCusPost)
End Sub
Private Sub txtCusBankNumber_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtCusPost.LostFocus
modMain.checkNum(txtCusBankNumber)
End Sub
Private Sub txtCusPhone_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtCusPhone.TextChanged
modMain.checkNum(txtCusPhone)
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