Dim yh As DataRow = DataTables("User_info").Find("User_Name = '" & _username & "'" ) '获取当前用户信息
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位月.
Dim bh1 As String ="BR" & bh
If e.DataRow("Inside_SRS").StartsWith(bh) = False '如果编号的前6位不符
Dim idx As Integer = e.DataRow("_Identify")
e.DataRow("Inside_SRS") = bh1 & "-" & Format(idx,"000000")
End If
End If
Else '否则需要补充【出办日期】与【车缝组别】才能保存,如果【样办状态】为空将会出现无法加载的情况
msgbox("办单号:" & dr1("SRS_No") & ",款号: " & dr1("Style_No") & "的【出办日期】,【样办状态】及【车缝组别】不能为空,请补充完毕后重新保存;")
e.Cancel = True
Tables("scheduling").Position = i
End If