Dim yh As DataRow = DataTables("User_info").Find("User_Name = '" & _username & "'" ) '获取当前用户信息
'If yh IsNot Nothing Then
'退出前删除空办单;
e.DataTable.DeleteFor("[Customer] Is Null and [Style_No] is null and [size] is null and [color] is null and [Follow_QA] = '" & yh("FullName") & "'") '删除空行
Dim dr1 As DataRow = DataTables("scheduling").Find("([排单顺序] Is Null or [Sewing_Team] Is Null or [sample_state] Is Null ) And [Follow_QA] = '" & yh("FullName") & "'") ' 找出当前用户出办日期为空,车缝组别,样办状态的办单;
Dim i As Integer = Tables("scheduling").Findrow("([排单顺序] Is Null or [Sewing_Team] Is Null or [sample_state] Is Null ) and [Follow_QA] = '" & yh("FullName") & "'") '找出当前用户出办日期为空的办单行的位置;
If e.DataRow.RowState <> DataRowState.Added And e.DataRow.RowState <> DataRowState.Modified Then
Return
End If
If dr1 Is Nothing Then '如果没有找到当前用户出办日期为空的办单,则保存当前排期,并给出新的内部办单号
'**************************设定办单号为自动编号*******************************
If e.DataRow.IsNull("Inside_SRS") Then
Dim d As Date = e.DataRow("input_date")
Dim y As Integer = d.Year
Dim m As Integer = d.Month
Dim Days As Integer = Date.DaysInMonth(y,m)
Dim fd As Date = New Date(y,m,1) '获得该月的第一天
Dim ld As Date = New Date(y,m,Days) '获得该月的最后一天
Dim bh As String = Format(d,"yyMM") '生成编号的前6位,4位年,2位月.
If e.DataRow("Inside_SRS").StartsWith(bh) = False '如果编号的前6位不符
Dim max As String
Dim idx As Integer
max = e.DataTable.Compute("Max(Inside_SRS)","Input_date >= #" & fd & "# And Input_date <= #" & ld & "# And [_Identify] <> " & e.DataRow("_Identify")) '取得该月的最大编号
If max > "" Then '如果存在最大编号
idx = CInt(max.Substring(7,4)) + 1 '获得最大编号的后四位顺序号,并加1
Else
idx = 1 '否则顺序号等于1
End If
e.DataRow("Inside_SRS") ="BR" & bh & "-" & Format(idx,"0000")
End If
End If
Else '否则需要补充【出办日期】与【车缝组别】才能保存,如果【样办状态】为空将会出现无法加载的情况
msgbox("办单号:" & dr1("SRS_No") & ",款号: " & dr1("Style_No") & "的【出办日期】,【样办状态】及【车缝组别】不能为空,请补充完毕后重新保存;")
e.Cancel = True
Tables("scheduling").Position = i
End If
'
'End If