www.pudn.com > jxc001.rar > FrmSaleEdit.frm
VERSION 5.00
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Object = "{F0D2F211-CCB0-11D0-A316-00AA00688B10}#1.0#0"; "MSDATLST.OCX"
Begin VB.Form FrmSaleEdit
Caption = "出库单编辑"
ClientHeight = 6900
ClientLeft = 60
ClientTop = 345
ClientWidth = 7725
Icon = "FrmSaleEdit.frx":0000
LinkTopic = "Form1"
MDIChild = -1 'True
ScaleHeight = 6900
ScaleWidth = 7725
Begin VB.Frame Frame2
Height = 3900
Left = 0
TabIndex = 8
Top = 2940
Width = 7695
Begin MSDataListLib.DataCombo DCboSaUser
Bindings = "FrmSaleEdit.frx":0442
DataField = "sale_user"
DataMember = "ComSaleHA"
DataSource = "DEjxc"
Height = 330
Left = 6300
TabIndex = 31
Top = 660
Width = 1155
_ExtentX = 2037
_ExtentY = 582
_Version = 393216
Enabled = 0 'False
MatchEntry = -1 'True
ListField = "employee_name"
BoundColumn = "employee_id"
Text = ""
Object.DataMember = "ComEmployee"
End
Begin MSDataListLib.DataCombo DCboSaRid
Bindings = "FrmSaleEdit.frx":0460
DataField = "sale_rid"
DataMember = "ComSaleHA"
DataSource = "DEjxc"
Height = 330
Left = 1020
TabIndex = 30
Top = 660
Width = 2415
_ExtentX = 4260
_ExtentY = 582
_Version = 393216
Enabled = 0 'False
Style = 2
ListField = "department_name"
BoundColumn = "department_id"
Text = ""
Object.DataMember = "ComDepartment"
End
Begin MSDataListLib.DataCombo DCboSaleType
Bindings = "FrmSaleEdit.frx":047E
DataField = "sale_type_id"
DataMember = "ComSaleHA"
DataSource = "DEjxc"
Height = 330
Left = 1020
TabIndex = 29
Top = 240
Width = 1515
_ExtentX = 2672
_ExtentY = 582
_Version = 393216
Enabled = 0 'False
Style = 2
ListField = "type_name"
BoundColumn = "type_id"
Text = ""
Object.DataMember = "ComSaleType"
End
Begin VB.TextBox txtsale_demo
DataField = "sale_demo"
DataMember = "ComSaleHA"
DataSource = "DEjxc"
Enabled = 0 'False
Height = 330
Left = 3105
TabIndex = 28
Top = 1065
Width = 4335
End
Begin VB.TextBox txtsale_car
DataField = "sale_car"
DataMember = "ComSaleHA"
DataSource = "DEjxc"
Enabled = 0 'False
Height = 330
Left = 1020
TabIndex = 26
Top = 1065
Width = 1260
End
Begin VB.TextBox txtsale_maker
DataField = "sale_maker"
DataMember = "ComSaleHA"
DataSource = "DEjxc"
Enabled = 0 'False
Height = 330
Left = 4425
TabIndex = 24
Top = 660
Width = 900
End
Begin VB.TextBox txtsale_date
DataField = "sale_date"
DataMember = "ComSaleHA"
DataSource = "DEjxc"
Enabled = 0 'False
Height = 330
Left = 6105
TabIndex = 19
Top = 240
Width = 1320
End
Begin VB.TextBox txtsale_id
DataField = "sale_id"
DataMember = "ComSaleHA"
DataSource = "DEjxc"
Enabled = 0 'False
Height = 330
Left = 3645
TabIndex = 17
Top = 240
Width = 1245
End
Begin VB.TextBox Txtgrid2
Height = 270
Left = 1200
TabIndex = 14
Top = 2100
Visible = 0 'False
Width = 1215
End
Begin VB.CommandButton CmdAct
Caption = "删除明细(&M)"
Enabled = 0 'False
Height = 315
Index = 3
Left = 6060
TabIndex = 13
Top = 3480
Width = 1275
End
Begin VB.CommandButton CmdAct
Caption = "增加明细(&A)"
Enabled = 0 'False
Height = 315
Index = 2
Left = 4180
TabIndex = 12
Top = 3480
Width = 1275
End
Begin MSDataGridLib.DataGrid DataGrid2
Bindings = "FrmSaleEdit.frx":049C
Height = 1575
Left = 420
TabIndex = 11
Top = 1440
Width = 6855
_ExtentX = 12091
_ExtentY = 2778
_Version = 393216
AllowUpdate = 0 'False
Enabled = -1 'True
HeadLines = 1
RowHeight = 17
FormatLocked = -1 'True
BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
DataMember = "ComSaleDA"
ColumnCount = 5
BeginProperty Column00
DataField = "sale_id"
Caption = "order_id"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column01
DataField = "p_id"
Caption = "物品编号"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column02
DataField = "unit_price"
Caption = "单价"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 1
Format = "0.00"
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column03
DataField = "qty"
Caption = "数量"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 1
Format = "#,##0.0000"
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column04
DataField = "price"
Caption = "金额"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 1
Format = "#,##0.00"
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
SplitCount = 1
BeginProperty Split0
BeginProperty Column00
ColumnAllowSizing= 0 'False
Object.Visible = 0 'False
ColumnWidth = 1275.024
EndProperty
BeginProperty Column01
Alignment = 1
ColumnAllowSizing= 0 'False
ColumnWidth = 1184.882
EndProperty
BeginProperty Column02
Alignment = 1
ColumnAllowSizing= 0 'False
ColumnWidth = 1500.095
EndProperty
BeginProperty Column03
Alignment = 1
ColumnAllowSizing= 0 'False
ColumnWidth = 1800
EndProperty
BeginProperty Column04
Alignment = 1
ColumnAllowSizing= 0 'False
ColumnWidth = 1800
EndProperty
EndProperty
End
Begin VB.CommandButton CmdAct
Caption = "恢复(&U)"
Enabled = 0 'False
Height = 315
Index = 1
Left = 2300
TabIndex = 10
Top = 3480
Width = 1275
End
Begin VB.CommandButton CmdAct
Caption = "保存(&S)"
Enabled = 0 'False
Height = 315
Index = 0
Left = 420
TabIndex = 9
Top = 3480
Width = 1275
End
Begin VB.Label lblFieldLabel
Alignment = 1 'Right Justify
AutoSize = -1 'True
Caption = "备注:"
Height = 180
Index = 7
Left = 2625
TabIndex = 27
Top = 1110
Width = 450
End
Begin VB.Label lblFieldLabel
Alignment = 1 'Right Justify
AutoSize = -1 'True
Caption = "车号:"
Height = 180
Index = 6
Left = 525
TabIndex = 25
Top = 1110
Width = 450
End
Begin VB.Label lblFieldLabel
Alignment = 1 'Right Justify
AutoSize = -1 'True
Caption = "制单人:"
Height = 180
Index = 5
Left = 3765
TabIndex = 23
Top = 720
Width = 630
End
Begin VB.Label lblFieldLabel
Alignment = 1 'Right Justify
AutoSize = -1 'True
Caption = "领用人:"
Height = 180
Index = 4
Left = 5625
TabIndex = 22
Top = 720
Width = 630
End
Begin VB.Label lblFieldLabel
Alignment = 1 'Right Justify
AutoSize = -1 'True
Caption = "对方单位:"
Height = 180
Index = 3
Left = 165
TabIndex = 21
Top = 720
Width = 810
End
Begin VB.Label lblFieldLabel
Alignment = 1 'Right Justify
AutoSize = -1 'True
Caption = "单据类型:"
Height = 180
Index = 2
Left = 165
TabIndex = 20
Top = 315
Width = 810
End
Begin VB.Label lblFieldLabel
Alignment = 1 'Right Justify
AutoSize = -1 'True
Caption = "单据日期:"
Height = 180
Index = 1
Left = 5265
TabIndex = 18
Top = 315
Width = 810
End
Begin VB.Label lblFieldLabel
Alignment = 1 'Right Justify
AutoSize = -1 'True
Caption = "单据编号:"
Height = 180
Index = 0
Left = 2805
TabIndex = 16
Top = 315
Width = 810
End
Begin VB.Label LblStatus
BorderStyle = 1 'Fixed Single
ForeColor = &H00FF0000&
Height = 315
Left = 420
TabIndex = 15
Top = 3060
Width = 6855
End
End
Begin VB.Frame Frame1
Height = 2955
Left = 0
TabIndex = 0
Top = -60
Width = 7695
Begin VB.CommandButton CmdDep
Caption = "退出(&X)"
Height = 315
Index = 5
Left = 6360
TabIndex = 7
Top = 2520
Width = 1275
End
Begin VB.CommandButton CmdDep
Caption = "列表(&P)"
Height = 315
Index = 4
Left = 6360
TabIndex = 6
Top = 2052
Width = 1275
End
Begin VB.CommandButton CmdDep
Caption = "删除(&D)"
Height = 315
Index = 3
Left = 6360
TabIndex = 5
Top = 1584
Width = 1275
End
Begin VB.CommandButton CmdDep
Caption = "查询(&F)"
Height = 315
Index = 2
Left = 6360
TabIndex = 4
Top = 1116
Width = 1275
End
Begin VB.CommandButton CmdDep
Caption = "编辑(&E)"
Height = 315
Index = 1
Left = 6360
TabIndex = 3
Top = 648
Width = 1275
End
Begin VB.CommandButton CmdDep
Caption = "增加(&N)"
Height = 315
Index = 0
Left = 6360
TabIndex = 2
Top = 180
Width = 1275
End
Begin MSDataGridLib.DataGrid DataGrid1
Bindings = "FrmSaleEdit.frx":04B0
Height = 2655
Left = 60
TabIndex = 1
Top = 180
Width = 6255
_ExtentX = 11033
_ExtentY = 4683
_Version = 393216
AllowUpdate = 0 'False
AllowArrows = -1 'True
HeadLines = 1
RowHeight = 15
TabAcrossSplits = -1 'True
TabAction = 2
WrapCellPointer = -1 'True
FormatLocked = -1 'True
BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
DataMember = "ComSaleHA"
ColumnCount = 8
BeginProperty Column00
DataField = "sale_id"
Caption = "单据编号"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column01
DataField = "sale_date"
Caption = "日期"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column02
DataField = "sale_type_id"
Caption = "单据类型"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column03
DataField = "sale_rid"
Caption = "对方单位"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column04
DataField = "sale_user"
Caption = "领用人"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column05
DataField = "sale_maker"
Caption = "制单人"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column06
DataField = "sale_car"
Caption = "车号"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column07
DataField = "sale_demo"
Caption = "备注"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
SplitCount = 1
BeginProperty Split0
BeginProperty Column00
Alignment = 1
ColumnAllowSizing= 0 'False
ColumnWidth = 854.929
EndProperty
BeginProperty Column01
Alignment = 1
ColumnAllowSizing= 0 'False
ColumnWidth = 705.26
EndProperty
BeginProperty Column02
Alignment = 1
ColumnAllowSizing= 0 'False
ColumnWidth = 750.047
EndProperty
BeginProperty Column03
Alignment = 1
ColumnAllowSizing= 0 'False
ColumnWidth = 750.047
EndProperty
BeginProperty Column04
Alignment = 1
ColumnAllowSizing= 0 'False
ColumnWidth = 599.811
EndProperty
BeginProperty Column05
Alignment = 1
ColumnAllowSizing= 0 'False
ColumnWidth = 599.811
EndProperty
BeginProperty Column06
Alignment = 1
ColumnAllowSizing= 0 'False
ColumnWidth = 494.929
EndProperty
BeginProperty Column07
Alignment = 1
ColumnAllowSizing= 0 'False
ColumnWidth = 1200.189
EndProperty
EndProperty
End
End
End
Attribute VB_Name = "FrmSaleEdit"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private rsSaHA As ADODB.Recordset
Private rsSalDA As ADODB.Recordset
Private cmSaHA As ADODB.Command
Private strMaxNum As String
Private Sub CmdAct_Click(Index As Integer)
Dim intRow As Integer
Dim blnIsTrue As Boolean
With rsSaHA
Select Case Index
Case 0
blnIsTrue = SaveValid()
If Not blnIsTrue Then
Exit Sub
End If
With rsSalDA
If .RecordCount <> 0 Then
.MoveFirst
While Not .EOF
!sale_id = Me.txtsale_id.Text
.MoveNext
Wend
End If
End With
rsSalDA.Filter = "sale_id='" & Me.txtsale_id.Text & "'"
rsSalDA.UpdateBatch
.Filter = "sale_id<>''"
.UpdateBatch
.MoveLast
Call IsEdit(False)
Case 1
rsSalDA.CancelBatch
.Filter = "sale_id<>''"
If .RecordCount <> 0 Then
.MoveFirst
End If
.CancelBatch
Call IsEdit(False)
rsSalDA.Filter = "sale_id='" & Me.txtsale_id.Text & "'"
Case 2
rsSalDA.AddNew "sale_id", Me.txtsale_id.Text
rsSalDA.Filter = "sale_id='" & Me.txtsale_id.Text & "'"
rsSalDA.MoveLast
DataGrid2.Col = 1
Call IsEdit(True)
Call Txtgrid2_Leave
Case 3
If rsSalDA.RecordCount <> 0 Then
rsSalDA.Delete
End If
If rsSalDA.RecordCount <> 0 Then
rsSalDA.MoveFirst
DataGrid2.Col = 1
Call IsEdit(True)
Call Txtgrid2_Leave
End If
End Select
End With
End Sub
Private Sub CmdDep_Click(Index As Integer)
Dim intAnswer As Integer
Dim strSQL As String
Select Case Index
Case 0
Call SaHAAddNew
Case 1
Call IsEdit(True)
Me.txtsale_id.SetFocus
With rsSalDA
If .RecordCount <> 0 Then
.MoveFirst
DataGrid2.Col = 1
Call Txtgrid2_Leave
End If
End With
Case 2
FrmSql.intNumField = 8
FrmSql.Show vbModal
Select Case FrmSql.intNumField
Case -1
CmdDep(0).Enabled = True
CmdDep(3).Enabled = True
rsSaHA.Filter = Me.DataGrid1.Columns.Item(0).DataField & _
"<>''"
rsSalDA.Filter = "sale_id ='" & Me.txtsale_id.Text & "'"
Case -2
Case Else
CmdDep(0).Enabled = False
CmdDep(3).Enabled = False
rsSaHA.Filter = Me.DataGrid1.Columns.Item(FrmSql.intNumField).DataField & _
" like '*" & FrmSql.strSqlField & "*'"
rsSalDA.Filter = "sale_id ='" & Me.txtsale_id.Text & "'"
End Select
Case 3
intAnswer = MsgBox("确认删除当前记录吗?", vbYesNo + vbQuestion, "删除确认")
If intAnswer = vbYes Then
With rsSaHA
strSQL = "delete from sale_detail_a where sale_id='" & Me.txtsale_id.Text & "'"
cmSaHA.CommandText = strSQL
cmSaHA.Execute
.Delete
.UpdateBatch
If .RecordCount <> 0 Then
.MoveFirst
End If
rsSalDA.Filter = "sale_id ='" & Me.txtsale_id.Text & "'"
End With
End If
Case 4
Case 5
Unload Me
End Select
End Sub
Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
rsSalDA.Filter = "sale_id ='" & Me.txtsale_id.Text & "'"
End Sub
Private Sub DataGrid2_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
If CmdDep(2).Enabled = True Then
LblStatus.Caption = Product_Status(DataGrid2.Columns(1).Text)
End If
End Sub
Private Sub DCboSaleType_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 And (Not IsNull(Me.DCboSaleType.SelectedItem)) Then
Me.txtsale_id.SetFocus
End If
End Sub
Private Sub DCboSaleType_Validate(Cancel As Boolean)
If IsNull(Me.DCboSaleType.SelectedItem) Then
Cancel = True
End If
End Sub
Private Sub DCboSaRid_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then Me.txtsale_maker.SetFocus
End Sub
Private Sub DCboSaUser_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then Me.txtsale_car.SetFocus
End Sub
Private Sub Form_Load()
intNumWindows = OpenWindow(intNumWindows)
Me.Height = 7305
Me.Width = 7845
Call SetFormStu(Me, frmMain)
Set rsSaHA = DEjxc.rsComSaleHA
Set rsSalDA = DEjxc.rsComSaleDA
Set cmSaHA = New ADODB.Command
cmSaHA.ActiveConnection = DEjxc.Conjxc
cmSaHA.CommandType = adCmdText
rsSalDA.Filter = "sale_id ='" & Me.txtsale_id.Text & "'"
Call IsEdit(False)
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If CmdDep(5).Enabled = False Then
MsgBox "请先退出编辑状态后再退出该程序!", , "提示"
Cancel = True
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
intNumWindows = Closewindow(intNumWindows)
rsSaHA.Close
rsSalDA.Close
Set rsSaHA = Nothing
Set rsSalDA = Nothing
Set cmSaHA = Nothing
End Sub
Private Sub SaHAAddNew()
Dim strSQL As String
With rsSaHA
.AddNew
rsSalDA.Filter = "sale_id ='" & Me.txtsale_id.Text & "'"
Call IsEdit(True)
Me.txtsale_date.Text = CStr(dteSysDate)
Me.txtsale_maker.Text = strCurUser
Me.DCboSaleType.SetFocus
End With
End Sub
Private Sub IsEdit(blnIsEdit As Boolean)
Dim intNum As Integer
Me.txtsale_car.Enabled = blnIsEdit
Me.txtsale_date.Enabled = blnIsEdit
Me.txtsale_demo.Enabled = blnIsEdit
Me.txtsale_id.Enabled = blnIsEdit
Me.txtsale_maker.Enabled = blnIsEdit
Me.DCboSaleType.Enabled = blnIsEdit
Me.DCboSaRid.Enabled = blnIsEdit
Me.DCboSaUser.Enabled = blnIsEdit
Me.DataGrid1.Enabled = Not blnIsEdit
If rsSalDA.RecordCount <> 0 Then
Txtgrid2.Visible = blnIsEdit
Else
Txtgrid2.Visible = False
End If
For intNum = 0 To 3
Me.CmdAct(intNum).Enabled = blnIsEdit
Next
For intNum = 0 To 5
Me.CmdDep(intNum).Enabled = Not blnIsEdit
Next
If Me.txtsale_id = "" Then
For intNum = 2 To 3
Me.CmdAct(intNum).Enabled = False
Next
End If
If rsSaHA.RecordCount = 0 Then
For intNum = 1 To 4
Me.CmdDep(intNum).Enabled = False
Next
End If
End Sub
Private Sub Txtgrid2_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyF2
If DataGrid2.Col = 1 Then
FrmFindPro.strFindPro = Txtgrid2.Text
FrmFindPro.Show vbModal
If FrmFindPro.strFindPro <> "" Then
Txtgrid2.Text = FrmFindPro.strFindPro
DataGrid2.Columns(1).Text = Txtgrid2.Text
End If
End If
'If DataGrid2.Col = 2 Then
' FrmFindUnPr.strFindUnPr = DataGrid2.Columns(1).Text
' FrmFindUnPr.Show vbModal
' If FrmFindUnPr.strFindUnPr <> "" Then
' Txtgrid2.Text = FrmFindUnPr.strFindUnPr
' DataGrid2.Columns(2).Text = Txtgrid2.Text
' End If
'End If
Case vbKeyReturn
Call Column_value
Call Cal_Price
Call ColToRight
Call Txtgrid2_Leave
Case vbKeyLeft
Call Column_value
Call Cal_Price
Call ColToLeft
Call Txtgrid2_Leave
Case vbKeyRight
Call Column_value
Call Cal_Price
Call ColToRight
Call Txtgrid2_Leave
Case vbKeyUp
Call Column_value
Call Cal_Price
Call RowToUp
Call Txtgrid2_Leave
Case vbKeyDown
Call Column_value
Call Cal_Price
Call RowToDown
Call Txtgrid2_Leave
End Select
End Sub
Private Sub Txtgrid2_KeyPress(KeyAscii As Integer)
Dim strValid As String
If DataGrid2.Col = 2 Or DataGrid2.Col = 3 Then
strValid = "0123456789."
If KeyAscii > 26 Then
If InStr(strValid, Chr(KeyAscii)) = 0 Then
KeyAscii = 0
End If
End If
End If
End Sub
Private Sub txtsale_car_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then Me.txtsale_demo.SetFocus
End Sub
Private Sub txtsale_date_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then Me.DCboSaRid.SetFocus
End Sub
Private Sub txtsale_id_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 And txtsale_id.Text <> "" Then
If Len(txtsale_id.Text) = 7 Then
Select Case Me.DCboSaleType.SelectedItem
Case 1
txtsale_id.Text = "LC" & txtsale_id.Text
Case 2
txtsale_id.Text = "DC" & txtsale_id.Text
End Select
End If
CmdAct(2).Enabled = True
CmdAct(3).Enabled = True
Me.txtsale_date.SetFocus
Else
CmdAct(2).Enabled = False
CmdAct(3).Enabled = False
End If
End Sub
Private Sub txtsale_id_Validate(Cancel As Boolean)
If txtsale_id.Text <> "" Then
If Len(txtsale_id.Text) = 7 Then
Select Case Me.DCboSaleType.SelectedItem
Case 1
txtsale_id.Text = "LC" & txtsale_id.Text
Case 2
txtsale_id.Text = "DC" & txtsale_id.Text
End Select
End If
CmdAct(2).Enabled = True
CmdAct(3).Enabled = True
Else
CmdAct(2).Enabled = False
CmdAct(3).Enabled = False
End If
End Sub
Private Sub Txtgrid2_Leave()
With DataGrid2
If .Columns(1).Text <> "" Then
LblStatus.Caption = Product_Status(.Columns(1).Text)
If .Columns(3).Text <> "" Then
If Not SaleTooLarge(.Columns(0).Text, .Columns(1).Text, .Columns(3).Text) Then
MsgBox "出库量大于库存量!", vbCritical, "错误"
End If
End If
Else
LblStatus.Caption = ""
End If
End With
Txtgrid2.Text = DataGrid2.Columns(DataGrid2.Col).Text
Txtgrid2.SelStart = 0
Txtgrid2.SelLength = Len(Txtgrid2.Text)
Txtgrid2.Width = DataGrid2.Columns(DataGrid2.Col).Width
Txtgrid2.Left = DataGrid2.Left + DataGrid2.Columns(DataGrid2.Col).Left
Txtgrid2.Top = DataGrid2.Top + DataGrid2.Row * DataGrid2.RowHeight + 225
Txtgrid2.SetFocus
End Sub
Private Sub ColToRight()
If DataGrid2.Col < DataGrid2.Columns.Count - 2 Then
DataGrid2.Col = DataGrid2.Col + 1
Else
Call RowToDown
DataGrid2.Col = 1
End If
End Sub
Private Sub ColToLeft()
If DataGrid2.Col > 1 Then
DataGrid2.Col = DataGrid2.Col - 1
End If
End Sub
Private Sub RowToUp()
With rsSalDA
If Not .BOF Then
.MovePrevious
End If
If .BOF Then .MoveNext
End With
End Sub
Private Sub RowToDown()
With rsSalDA
If Not .EOF Then
.MoveNext
End If
If .EOF Then .MovePrevious
End With
End Sub
Private Sub Cal_Price()
With DataGrid2
If .Columns(2).Text <> "" And .Columns(3).Text <> "" Then
.Columns(4).Value = Sale_Price(.Columns(0).Text, .Columns(1).Text, .Columns(2).Text, .Columns(3).Text)
End If
End With
End Sub
Private Function SaveValid() As Boolean
If (Left(Me.txtsale_id.Text, 2) <> "LC" And Left(Me.txtsale_id.Text, 2) <> "DC") Or Len(Me.txtsale_id.Text) <> 9 Then
MsgBox "单据编号格式错误!", vbCritical, "错误"
txtsale_id.SetFocus
SaveValid = False
Exit Function
End If
If Me.txtsale_date.Text = "" Or (Not IsDate(Me.txtsale_date.Text)) Then
MsgBox "日期格式错误!", vbCritical, "错误"
txtsale_date.SetFocus
SaveValid = False
Exit Function
End If
If IsNull(Me.DCboSaleType.SelectedItem) Then
MsgBox "必须选择单据类型!", vbCritical, "错误"
Me.DCboSaleType.SetFocus
SaveValid = False
Exit Function
End If
If Me.txtsale_maker = "" Then
MsgBox "制单人不能为空!", vbCritical, "错误"
txtsale_maker.SetFocus
SaveValid = False
Exit Function
End If
If IsNull(Me.DCboSaRid.SelectedItem) Then
MsgBox "必须选择一个部门!", vbCritical, "错误"
Me.DCboSaRid.SetFocus
SaveValid = False
Exit Function
End If
If rsSalDA.RecordCount = 0 Then
MsgBox "单据明细项不能为空!", vbCritical, "错误"
txtsale_id.SetFocus
SaveValid = False
Exit Function
End If
SaveValid = True
End Function
Private Sub txtsale_maker_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then Me.DCboSaUser.SetFocus
End Sub
Private Sub Column_value()
With DataGrid2
If .Col = 2 Then
.Columns(.Col).Text = CStr(SaleUnPr(.Columns(0).Text, .Columns(1).Text))
ElseIf .Col = 3 Then
If Txtgrid2.Text <> "" Then .Columns(.Col).Text = CStr(Round(CSng(Txtgrid2.Text), 4))
Else
.Columns(.Col).Text = Txtgrid2.Text
End If
End With
End Sub