貌似是 msflexgrid
或者是其他的表格空间
Sub initTable() 过程名称
Dim j As Integer '/////定义一个整形变量
fgProducts.Rows = 1 '////行为1
fgProducts.Cols = 6 '/////列为1
fgProducts.RowHeight(fgProducts.Rows - 1) = 280
fgProducts.Row = fgProducts.Rows - 1
For j = 0 To fgProducts.Cols - 1 '/////循环到最后一列
fgProducts.Col = j
fgProducts.CellAlignment = 4 '/////文字居中
Select Case j '/////判断 6列 并改变列名称和宽度
Case 0
fgProducts.ColWidth(j) = 600
fgProducts.Text = "序号"
Case 1
fgProducts.ColWidth(j) = 1600
fgProducts.Text = "产品名称"
Case 2
fgProducts.ColWidth(j) = 1200
fgProducts.Text = "订单号"
Case 3
fgProducts.ColWidth(j) = 1600
fgProducts.Text = "客户名称"
Case 4
fgProducts.ColWidth(j) = 1000
fgProducts.Text = "定购数量"
Case 5
fgProducts.ColWidth(j) = 1000
fgProducts.Text = "单价"
End Select
Next j
End Sub
Sub addProductToOrder()
Dim i As Integer
Dim j As Integer
If txtProduct(0).Text = "" Then '/////如果 txtProduct(0).Text 是空白
MsgBox "请填写数量!", vbExclamation, "提示" '///// 弹出提示 请填写数量
Exit Sub '///// 退出子过程
End If '/////结束判断
fgProducts.Rows = fgProducts.Rows + 1
fgProducts.RowHeight(fgProducts.Rows - 1) = 280
fgProducts.Row = fgProducts.Rows - 1
For j = 0 To fgProducts.Cols - 1
fgProducts.Col = j
fgProducts.CellAlignment = 4
Select Case j
Case 0
fgProducts.Text = fgProducts.Rows - 1
Case 1
fgProducts.Text = cboProduct.Text
Case 2
fgProducts.Text = cboNo.Text
Case 3
fgProducts.Text = cboClient.Text
Case 4
fgProducts.Text = txtProduct(0).Text
Case 5
fgProducts.Text = txtProduct(1).Text
End Select
Next j
End Sub
Sub saveOrder()
saveBasicInfo
saveProductsInOrder
End Sub
Sub saveBasicInfo() '/////AQL语句 连接数据库
Dim conn As ADODB.Connection
If txtOrder(3).Text = "" Then
sqlStr = "insert into orders(orderNo,clientName," _
& "orderDate,dueDate) values('" _
& txtOrder(0).Text & "','" & cboClient.Text & "','" _
& txtOrder(1).Text & "','" & txtOrder(2).Text & "')"
Else
sqlStr = "insert into orders(orderNo,clientName," _
& "orderDate,dueDate,deliverDate) values('" _
& txtOrder(0).Text & "','" & cboClient.Text & "','" _
& txtOrder(1).Text & "','" & txtOrder(2).Text & "','" _
& txtOrder(3).Text & "')"
End If
' On Error GoTo exitSub '/////错误处理 遇到错误退出过程
Set conn = New ADODB.Connection
conn.Open connStr
conn.Execute sqlStr
MsgBox "成功修改订单基本信息!!"
exitSub:
conn.Close
End Sub
Sub initTable()
Dim j As Integer '定义j是整型
fgProducts.Rows = 1 '产品的行是1
fgProducts.Cols = 6 '产品的列是6
fgProducts.RowHeight(fgProducts.Rows - 1) = 280 行高是280
fgProducts.Row = fgProducts.Rows - 1
For j = 0 To fgProducts.Cols - 1
fgProducts.Col = j
fgProducts.CellAlignment = 4
Select Case j '定义每一列的列头和宽度
Case 0
fgProducts.ColWidth(j) = 600
fgProducts.Text = "序号"
Case 1
fgProducts.ColWidth(j) = 1600
fgProducts.Text = "产品名称"
Case 2
fgProducts.ColWidth(j) = 1200
fgProducts.Text = "订单号"
Case 3
fgProducts.ColWidth(j) = 1600
fgProducts.Text = "客户名称"
Case 4
fgProducts.ColWidth(j) = 1000
fgProducts.Text = "定购数量"
Case 5
fgProducts.ColWidth(j) = 1000
fgProducts.Text = "单价"
End Select
Next j
End Sub
Sub addProductToOrder() '定义订单的生成
Dim i As Integer
Dim j As Integer
If txtProduct(0).Text = "" Then '如果产品数量为空,进行提示
MsgBox "请填写数量!", vbExclamation, "提示"
Exit Sub
End If
fgProducts.Rows = fgProducts.Rows + 1
fgProducts.RowHeight(fgProducts.Rows - 1) = 280
fgProducts.Row = fgProducts.Rows - 1
For j = 0 To fgProducts.Cols - 1
fgProducts.Col = j
fgProducts.CellAlignment = 4
Select Case j '读取数据
Case 0
fgProducts.Text = fgProducts.Rows - 1
Case 1
fgProducts.Text = cboProduct.Text
Case 2
fgProducts.Text = cboNo.Text
Case 3
fgProducts.Text = cboClient.Text
Case 4
fgProducts.Text = txtProduct(0).Text
Case 5
fgProducts.Text = txtProduct(1).Text
End Select
Next j
End Sub
Sub saveOrder() '定义保存订单
saveBasicInfo '基础信息事件
saveProductsInOrder '产品订单事件
End Sub
Sub saveBasicInfo()
Dim conn As ADODB.Connection '连数据库
If txtOrder(3).Text = "" Then '保存每条信息
sqlStr = "insert into orders(orderNo,clientName," _
& "orderDate,dueDate) values('" _
& txtOrder(0).Text & "','" & cboClient.Text & "','" _
& txtOrder(1).Text & "','" & txtOrder(2).Text & "')"
Else
sqlStr = "insert into orders(orderNo,clientName," _
& "orderDate,dueDate,deliverDate) values('" _
& txtOrder(0).Text & "','" & cboClient.Text & "','" _
& txtOrder(1).Text & "','" & txtOrder(2).Text & "','" _
& txtOrder(3).Text & "')"
End If
' On Error GoTo exitSub '出错后退出过程
Set conn = New ADODB.Connection
conn.Open connStr
conn.Execute sqlStr
MsgBox "成功修改订单基本信息!!" '保存成功
exitSub:
conn.Close '关闭链接
End Sub
Sub initTable()
初始化表格,填写表头,列宽之类的
Sub addProductToOrder()
把用户选择保存到 表格里,看情况应该有text和cbo控件选择
自动添加行数 cbo选项,数量等
Sub saveOrder()
保存表格信息到数据库里面有两个 sub
sub saveBasicInfo()
把表格基本信息保存到数据
首先是根据情况写 sql语句 就是sqlStr 这个string变量了
然后连接数据库,执行sql 的 insert语句
sub saveProductsInOrder()
丢失的sub
应该是保存具体数量信息之类的到数据库吧,
跟sub saveBasicInfo()类似