If Tables("任务信息").Current IsNot Nothing And Forms("新建任务").controls("ComboBox3").SelectedIndex>=0 And Forms("新建任务").controls("ComboBox6").SelectedIndex>=0 Then
Dim r2 As Row =Tables("任务信息").Current
''''''''''''''''任务编号'''''''''''''''''''''''''''''''''''''''''''''''
Dim dt As Date = r2("m")
Dim bh As String = Format(dt,"yyyyMM") '取得车辆编号的8位前缀
Dim max As String
Dim max2 As String
Dim max3 As String
Dim m As Integer
Dim m2 As Integer
Dim m3 As Integer
Dim mx As Integer
Dim idx As Integer
max = DataTables("任务信息").SQLCompute("Max(任务编号)","m = #" & r2("m") & "# And [_Identify] <> " & r2("_Identify")) '取得该天的最大车辆编号
max2 = DataTables("已分配任务").SQLCompute("Max(任务编号)","m = #" & r2("m") & "# And [_Identify] <> " & r2("_Identify")) '取得该天的最大车辆编号
max3 = DataTables("已完结任务").SQLCompute("Max(任务编号)","m = #" & r2("m") & "# And [_Identify] <> " & r2("_Identify")) '取得该天的最大车辆编号
If max Is Nothing And max2 Is Nothing And max3 Is Nothing Then
idx = 1 '否则顺序号等于1
Else
If max Is Nothing Then
max = "000000-000"
End If
If max2 Is Nothing Then
max2 = "000000-000"
End If
If max3 Is Nothing Then
max3 = "000000-000"
End If
m=CInt(max.Substring(7,3))
m2=CInt(max2.Substring(7,3))
m3=CInt(max3.Substring(7,3))
Dim N As New List(Of Integer)
N.Add(m)
N.Add(m2)
N.Add(m3)
Dim mmax As Integer=0
For Each i As Integer In N
If i > mmax Then
mmax = i
End If
Next
idx = mmax+1
End If
r2("任务编号") = bh & "-" & Format(idx,"000")
''''''''''''''''任务编号'''''''''''''''''''''''''''''''''''''''''''''''
If r2.DataRow.RowState <> DataRowState.Unchanged Then '如果当前行已经修改过
r2("最后操作者")=_UserName
End If
If r2("最后操作者")="" Then
r2("最后操作者")=_UserName
End If
If e.Form.Controls("ComboBox6").text = "待分配" Then
r2.Save()
Dim msg As String = "A#" & "任务信息" & "#" & e.Form.Controls("r").text
For Each bd As QQBuddy In QQClient.Buddies
If bd.Online Then
QQClient.Send(bd.name, msg)
End If
Next
e.Form.close()
Return
End If
If e.Form.Controls("ComboBox6").text = "国五一号仓" Or e.Form.Controls("ComboBox6").text ="国五二号仓" Or e.Form.Controls("ComboBox6").text ="其他" Then
Dim t As Row =Tables("已分配任务").AddNew()
t("任务编号")=r2("任务编号")
t("任务类型")=r2("任务类型")
t("LIMIS")=r2("LIMIS")
t("要求完成日期")=r2("要求完成日期")
t("项目负责人")=r2("项目负责人")
t("委托人")=r2("委托人")
t("委托人联系方式")=r2("委托人联系方式")
t("样车编号")=r2("样车编号")
t("是否要求滑行")=r2("是否要求滑行")
t("A")=r2("A")
t("B")=r2("B")
t("C")=r2("C")
t("试验标准")=r2("试验标准")
t("试验类型")=r2("试验类型")
t("试验次数")=r2("试验次数")
t("其他要求")=r2("其他要求")
t("添加人")=r2("添加人")
t("操作原因")=r2("操作原因")
t("试验室安排")=r2("试验室安排")
t("最后操作者")=r2("最后操作者")
t("任务下达时间")=r2("任务下达时间")
t("m")=r2("m")
Tables("已分配任务") .Save()
Dim msg As String = "A#" & "已分配任务" & "#" & t("_Identify")
For Each bd As QQBuddy In QQClient.Buddies
If bd.Online Then
QQClient.Send(bd.name, msg)
End If
Next
Dim r As String = e.Form.Controls("r").text
DataTables("任务信息").RemoveFor("[_Identify] = " & r) '移除行
DataTables("任务信息").save()
e.Form.close()
Return
End If
Else
MessageBox.Show("请完善新建任务!", "提示")
End If