www.pudn.com > SalesManager.rar > frmCusModify.vb
Imports System.Data.OleDb
Public Class frmCusModify
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 Label6 As System.Windows.Forms.Label
Friend WithEvents Label7 As System.Windows.Forms.Label
Friend WithEvents Label8 As System.Windows.Forms.Label
Friend WithEvents Label9 As System.Windows.Forms.Label
Friend WithEvents txtCusDate As System.Windows.Forms.TextBox
Friend WithEvents labCusLevel As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents txtCusName As System.Windows.Forms.TextBox
Friend WithEvents txtCusAddress As System.Windows.Forms.TextBox
Friend WithEvents txtCusPost As System.Windows.Forms.TextBox
Friend WithEvents txtCusPhone As System.Windows.Forms.TextBox
Friend WithEvents txtCusBankNumber As System.Windows.Forms.TextBox
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents Label5 As System.Windows.Forms.Label
Friend WithEvents PictureBox2 As System.Windows.Forms.PictureBox
Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
Friend WithEvents btnDelete As System.Windows.Forms.Button
Friend WithEvents btnCancel As System.Windows.Forms.Button
Friend WithEvents btnModify As System.Windows.Forms.Button
Friend WithEvents cbCusID As System.Windows.Forms.ComboBox
Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(frmCusModify))
Me.GroupBox1 = New System.Windows.Forms.GroupBox
Me.cbCusID = New System.Windows.Forms.ComboBox
Me.Label6 = New System.Windows.Forms.Label
Me.Label7 = New System.Windows.Forms.Label
Me.Label8 = New System.Windows.Forms.Label
Me.Label9 = New System.Windows.Forms.Label
Me.txtCusDate = New System.Windows.Forms.TextBox
Me.labCusLevel = New System.Windows.Forms.Label
Me.Label3 = New System.Windows.Forms.Label
Me.txtCusName = New System.Windows.Forms.TextBox
Me.txtCusAddress = New System.Windows.Forms.TextBox
Me.txtCusPost = New System.Windows.Forms.TextBox
Me.txtCusPhone = New System.Windows.Forms.TextBox
Me.txtCusBankNumber = New System.Windows.Forms.TextBox
Me.Label4 = New System.Windows.Forms.Label
Me.Label5 = New System.Windows.Forms.Label
Me.PictureBox2 = New System.Windows.Forms.PictureBox
Me.PictureBox1 = New System.Windows.Forms.PictureBox
Me.btnDelete = New System.Windows.Forms.Button
Me.btnCancel = New System.Windows.Forms.Button
Me.btnModify = New System.Windows.Forms.Button
Me.GroupBox1.SuspendLayout()
Me.SuspendLayout()
'
'GroupBox1
'
Me.GroupBox1.Controls.Add(Me.cbCusID)
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.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 = 106
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "客户信息"
'
'cbCusID
'
Me.cbCusID.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
Me.cbCusID.Location = New System.Drawing.Point(80, 27)
Me.cbCusID.Name = "cbCusID"
Me.cbCusID.Size = New System.Drawing.Size(124, 20)
Me.cbCusID.TabIndex = 103
'
'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 = "客户地址:"
'
'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 = "联系电话:"
'
'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 = "银行帐号:"
'
'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 = "加入日期:"
'
'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 = ""
'
'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, 31)
Me.labCusLevel.Name = "labCusLevel"
Me.labCusLevel.Size = New System.Drawing.Size(64, 16)
Me.labCusLevel.TabIndex = 102
Me.labCusLevel.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 = "客户编号:"
'
'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 = ""
'
'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 = ""
'
'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 = ""
'
'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 = ""
'
'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 = ""
'
'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 = "客户姓名:"
'
'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 = "客户邮编:"
'
'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 = 105
Me.PictureBox2.TabStop = False
'
'PictureBox1
'
Me.PictureBox1.Image = CType(resources.GetObject("PictureBox1.Image"), System.Drawing.Image)
Me.PictureBox1.Location = New System.Drawing.Point(12, 12)
Me.PictureBox1.Name = "PictureBox1"
Me.PictureBox1.Size = New System.Drawing.Size(116, 244)
Me.PictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
Me.PictureBox1.TabIndex = 104
Me.PictureBox1.TabStop = False
'
'btnDelete
'
Me.btnDelete.Location = New System.Drawing.Point(192, 244)
Me.btnDelete.Name = "btnDelete"
Me.btnDelete.Size = New System.Drawing.Size(72, 24)
Me.btnDelete.TabIndex = 109
Me.btnDelete.Text = "删除(&D)"
'
'btnCancel
'
Me.btnCancel.Location = New System.Drawing.Point(360, 244)
Me.btnCancel.Name = "btnCancel"
Me.btnCancel.Size = New System.Drawing.Size(72, 24)
Me.btnCancel.TabIndex = 108
Me.btnCancel.Text = "关闭(&C)"
'
'btnModify
'
Me.btnModify.Location = New System.Drawing.Point(276, 244)
Me.btnModify.Name = "btnModify"
Me.btnModify.Size = New System.Drawing.Size(72, 24)
Me.btnModify.TabIndex = 107
Me.btnModify.Text = "修改(&M)"
'
'frmCusModify
'
Me.AcceptButton = Me.btnCancel
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(444, 275)
Me.Controls.Add(Me.btnDelete)
Me.Controls.Add(Me.btnCancel)
Me.Controls.Add(Me.btnModify)
Me.Controls.Add(Me.GroupBox1)
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 = "frmCusModify"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent
Me.Text = "客户信息管理"
Me.GroupBox1.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub frmCusModify_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim myConn As OleDbConnection = New OleDbConnection(strConn)
Dim myComm As OleDbCommand = New OleDbCommand
myComm.Connection = myConn
myComm.CommandText = "select id from customer"
Dim myReader As OleDbDataReader
myConn.Open()
myReader = myComm.ExecuteReader()
While myReader.Read
cbCusID.Items.Add(myReader.GetInt32(0))
End While
myConn.Close()
Me.txtCusDate.Enabled = False
End Sub
Private Sub cbCusID_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbCusID.SelectedIndexChanged
If cbCusID.SelectedIndex > -1 Then
Dim myConn As OleDbConnection = New OleDbConnection(strConn)
Dim myComm As OleDbCommand = New OleDbCommand
myComm.Connection = myConn
myComm.CommandText = "select * from customer where id = " & cbCusID.SelectedItem
Dim myReader As OleDbDataReader
myConn.Open()
myReader = myComm.ExecuteReader()
While myReader.Read
txtCusName.Text = myReader.GetString(1)
txtCusAddress.Text = myReader.GetString(2)
txtCusPost.Text = myReader.GetString(3)
txtCusBankNumber.Text = myReader.GetString(4)
txtCusPhone.Text = myReader.GetString(5)
txtCusDate.Text = myReader.GetDateTime(6)
labCusLevel.Text = myReader.GetString(7)
End While
myConn.Close()
End If
End Sub
Private Sub btnModify_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnModify.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 = "update customer set name=@name,address=@address,post=@post,phone=@phone,banknumber=@banknumber where id=" & cbCusID.SelectedItem
myComm.Parameters.Add("@name", txtCusName.Text)
myComm.Parameters.Add("@address", txtCusAddress.Text)
myComm.Parameters.Add("@post", txtCusPost.Text)
myComm.Parameters.Add("@phone", txtCusPhone.Text)
myComm.Parameters.Add("@banknumber", txtCusBankNumber.Text)
myConn.Open()
myComm.ExecuteNonQuery()
myConn.Close()
MsgBox("客户信息修改成功!", MsgBoxStyle.Information, "提示信息")
End Sub
Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click
If cbCusID.SelectedIndex = -1 Then
Exit Sub
End If
Dim temp As MsgBoxResult
temp = MsgBox("确实要删除此条记录吗?", MsgBoxStyle.YesNo, "提示信息:")
If temp = MsgBoxResult.Yes Then
Dim myConn As OleDbConnection = New OleDbConnection(strConn)
Dim myComm As OleDbCommand = New OleDbCommand
myComm.Connection = myConn
myComm.CommandText = "delete from customer where id =@id"
myComm.Parameters.Add("@id", CLng(cbCusID.SelectedItem))
cbCusID.Items.RemoveAt(cbCusID.SelectedIndex)
myConn.Open()
myComm.ExecuteNonQuery()
myConn.Close()
cbCusID.SelectedIndex = -1
txtCusName.Text = ""
txtCusAddress.Text = ""
txtCusPost.Text = ""
txtCusPhone.Text = ""
txtCusBankNumber.Text = ""
txtCusDate.Text = ""
labCusLevel.Text = ""
Else
Exit Sub
End If
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