Dim Result As DialogResult
Result = MessageBox.Show("确定提交新增订单吗?【是:确定提交; 否:返回修改; 取消:取消提交】","确认提示",MessageBoxButtons.YesNoCancel,MessageBoxIcon.Question)
If Result = DialogResult.Yes Then
Dim cmd As new SQLCommand
Dim dt As Date
cmd.C
cmd.CommandText = "select getdate()"
dt = cmd.ExecuteScalar
Tables("订单明细表").current.DataRow("订单内容_上单时间") = dt
Tables("订单明细表").current.DataRow("订单状态") = "待进行"
If r IsNot Nothing Then
Dim dr5 As DataRow
If r.IsNull("客户_电话") = False
Dim dhs() As String = r("客户_电话").trim().split("/")
For Each dh As String In dhs
dr5 = DataTables("客户数据表") .SQLFind("'/'+客户电话+'/' like '%/" & dh & "/%'")
If dr5 IsNot Nothing Then Exit For
Next
If dr5 IsNot Nothing Then
Dim lst As new List(of String)
For Each d As String In dr5("客户电话").trim().split("/")
If lst.Contains(d) = False Then lst.Add(d)
Next
For Each d As String In dhs
If lst.Contains(d) = False Then lst.Add(d)
Next
dr5("客户电话") = String.Join("/",lst.ToArray)
If dr5.IsNull("客户QQ")
dr5("客户QQ")=r("客户_QQ")
Else
lst.Clear
For Each d As String In dr5("客户QQ").trim().split("/")
If lst.Contains(d) = False Then lst.Add(d)
Next
For Each d As String In r("客户_QQ").trim().split("/")
If lst.Contains(d) = False Then lst.Add(d)
Next
dr5("客户QQ") = String.Join("/",lst.ToArray)
End If
If dr5.IsNull("客户微信")
dr5("客户微信")= r("客户_微信")
Else
lst.Clear
For Each d As String In dr5("客户微信").trim().split("/")
If lst.Contains(d) = False Then lst.Add(d)
Next
For Each d As String In r("客户_微信").trim().split("/")
If lst.Contains(d) = False Then lst.Add(d)
Next
dr5("客户微信") = String.Join("/",lst.ToArray)
End If
End If
End If
If dr5 Is Nothing AndAlso r.IsNull("客户_QQ") = False
Dim dhs() As String = r("客户_QQ").trim().split("/")
For Each dh As String In dhs
dr5 = DataTables("客户数据表") .SQLFind("'/'+客户QQ+'/' like '%/" & dh & "/%'")
If dr5 IsNot Nothing Then Exit For
Next
If dr5 IsNot Nothing Then
Dim lst As new List(of String)
For Each d As String In dr5("客户QQ").trim().split("/")
If lst.Contains(d) = False Then lst.Add(d)
Next
For Each d As String In dhs
If lst.Contains(d) = False Then lst.Add(d)
Next
dr5("客户QQ") = String.Join("/",lst.ToArray)
If dr5.IsNull("客户电话")
dr5("客户电话")=r("客户_电话")
Else
lst.Clear
For Each d As String In dr5("客户电话").trim().split("/")
If lst.Contains(d) = False Then lst.Add(d)
Next
For Each d As String In r("客户_电话").trim().split("/")
If lst.Contains(d) = False Then lst.Add(d)
Next
dr5("客户电话") = String.Join("/",lst.ToArray)
End If
If dr5.IsNull("客户微信")
dr5("客户微信")= r("客户_微信")
Else
lst.Clear
For Each d As String In dr5("客户微信").trim().split("/")
If lst.Contains(d) = False Then lst.Add(d)
Next
For Each d As String In r("客户_微信").trim().split("/")
If lst.Contains(d) = False Then lst.Add(d)
Next
dr5("客户微信") = String.Join("/",lst.ToArray)
End If
End If
End If
If dr5 Is Nothing AndAlso r.IsNull("客户_微信") = False
Dim dhs() As String = r("客户_微信").trim().split("/")
For Each dh As String In dhs
dr5 = DataTables("客户数据表") .SQLFind("'/'+客户微信+'/' like '%/" & dh & "/%'")
If dr5 IsNot Nothing Then Exit For
Next
If dr5 IsNot Nothing Then
Dim lst As new List(of String)
For Each d As String In dr5("客户微信").trim().split("/")
If lst.Contains(d) = False Then lst.Add(d)
Next
For Each d As String In dhs
If lst.Contains(d) = False Then lst.Add(d)
Next
dr5("客户微信") = String.Join("/",lst.ToArray)
If dr5.IsNull("客户电话")
dr5("客户电话")=r("客户_电话")
Else
lst.Clear
For Each d As String In dr5("客户电话").trim().split("/")
If lst.Contains(d) = False Then lst.Add(d)
Next
For Each d As String In r("客户_电话").trim().split("/")
If lst.Contains(d) = False Then lst.Add(d)
Next
dr5("客户电话") = String.Join("/",lst.ToArray)
End If
If dr5.IsNull("客户QQ")
dr5("客户QQ")= r("客户_QQ")
Else
lst.Clear
For Each d As String In dr5("客户QQ").trim().split("/")
If lst.Contains(d) = False Then lst.Add(d)
Next
For Each d As String In r("客户_QQ").trim().split("/")
If lst.Contains(d) = False Then lst.Add(d)
Next
dr5("客户QQ") = String.Join("/",lst.ToArray)
End If
End If
End If
If dr5 IsNot Nothing Then
Dim dr As DataRow
dr = CurrentTable.DataTable.find("客户_编号 = '" & dr5("客户编号") & "' and 订单日期 >= '" & Date.Today & "'")
If dr IsNot Nothing Then
If dr("客服类型_主客服") <> user.name Then
MessageBox.Show("对不起,此客户最近四天其它客服有上单,不能重复安排!","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning)
dr5.Reject()
r .Reject()
e.Form.close()
Return
Else
Dim Result1 As DialogResult
Result1 = MessageBox.Show("此客户你最近四天有上单,是否还需要继续?","提示",MessageBoxButtons.YesNo,MessageBoxIcon.Question)
If Result1 = DialogResult.No Then
dr5.Reject()
r.Reject()
e.Form.close()
Return
End If
End If
End If
dr = CurrentTable.DataTable.find("客户_编号 = '" & dr5("客户编号") & "' and 订单日期 < '" & Date.Today & "' and 调度操作_订单结果 = '成功' ","订单日期 desc")
If dr IsNot Nothing Then
Dim dr50 As String = "202020220"
msgbox(dr50)
Dim d1 As Date = dr("订单日期")
Dim d2 As Date = Date.Today
Dim t As TimeSpan = d2-d1
If t.TotalDays < 60 Then
If dr("客服类型_主客服") <> user.name Then
Dim dr100 As DataRow = CurrentTable.DataTable.find("客户_编号 = '" & dr5("客户编号") & "' and 订单日期 < '" & Date.Today & "' and 调度操作_订单结果 = '成功' and 价格收款_单位 = 'YZ'","订单日期 desc")
If dr100 Is Nothing Then
MessageBox.Show("对不起,其它客服60天专属保护期内客户不能安排,请提交申请批准后方可安排!","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning)
dr5.Reject()
r.Reject()
e.Form.close()
Return
Else
If dr100("客服类型_主客服") <> user.name Then
MessageBox.Show("对不起,其它客服60天专属保护期内客户不能安排,请提交申请批准后方可安排!","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning)
dr5.Reject()
r.Reject()
e.Form.close()
Return
End If
End If
End If
End If
End If
If dr5.IsNull("客户网名")
dr5("客户网名")= r("客户_网名")
Else
Dim qqs As new List(of String)
For Each d As String In dr5("客户网名").trim().split("/")
If qqs.Contains(d) = False Then qqs.Add(d)
Next
For Each d As String In r("客户_网名").trim().split("/")
If qqs.Contains(d) = False Then qqs.Add(d)
Next
dr5("客户网名") = String.Join("/",qqs.ToArray)
End If
r("客户_编号") = dr5("客户编号")
If r("客户_编号") IsNot Nothing And r("员工_姓名") IsNot Nothing Then
Dim sr As DataRow = DataTables("订单明细表").Find(" 客户_编号 = '" & r("客户_编号") &"' And 员工_姓名 = '" & r("员工_姓名") &"' and 调度操作_订单结果 = '成功'")
If sr IsNot Nothing Then
If sr("客服类型_主客服") = r("客服类型_主客服") Then
r("客户_回头约") = True
Else
MessageBox.show("对不起,你所选择的员工已经约过此客人,请返回修改或取消!","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning)
r("客户_回头约") = False
Return
End If
End If
End If
Else
dr5 = DataTables("客户数据表").AddNew()
Dim bh2 As String
Dim Inx2 As Integer
bh2 = DataTables("客户数据表").SQLCompute("Max(客户编号)")
Inx2 = CInt(bh2.SubString(3,5) + 1)
dr5("客户编号") = "KH" & "-" & Format(Inx2,"00000")
r("客户_编号") = dr5("客户编号")
dr5("客户网名") = r("客户_网名")
dr5("网名备注") = r("客户_网名备注")
dr5("客户电话")= r("客户_电话")
dr5("客户QQ") = r("客户_QQ")
dr5("WT") = r("价格收款_WT")
dr5("客户微信") = r("客户_微信")
dr5("客户类型") = r("客户_类型")
dr5("YZ") = r("客户_YZ")
dr5("首单日期") = r("订单日期")
dr5("尾单日期") = r("订单日期")
End If
r.Save()
dr5.Save()
End If
DataTables("客户数据表").load
QQClient.Send("调度部.倩倩","收到一份 & '" & user.name &"'新的订单,请处理",True)
e.Form.close()
Else If Result = DialogResult.Cancel Then
CurrentTable.Current.Reject()
e.Form.Close()
End If