-- 作者:小狐
-- 发布时间:2011/1/5 17:41:00
-- 这里的符号要使用方式对吗?(红色部分)另外在想问一下黄色问题是否有捷径
Dim tian As String \' 天数 Dim cp As String \' 产品 Dim datastr As String \' 地址 \'天数输入 If e.Form.Controls("NumericComboBox1").Value Is Nothing Then MessageBox.Show("天数还没有输入") Return Else tian =e.Form.Controls("NumericComboBox1").value End If \'产品输入 Dim Val,val1 As String For Each ctl As WinForm.Control In e.Form.Controls \'如果只选择一个产品为何要循环判断每一个值是否打勾,有方便的方法吗 If Typeof ctl Is WinForm.CheckedListBox Dim lst As WinForm.CheckedListBox = ctl val = lst.Value val1 = val & val1 End If Next Dim vals() As String vals = val1.Split("-") If vals.Length > 2 Then messagebox.Show("只能选择一个产品") Return Else If vals(0) = "" Then MessageBox.show("请选择产品") Return Else cp = vals(0) End If End If \' 地址选择 Dim tr As WinForm.TreeView Dim nd As WinForm.TreeNode Dim dm,dms As String tr = e.Form.Controls("TreeView1") nd = tr.SelectedNode If nd IsNot Nothing dm = nd.Name dm = dm.Replace("\\","") dm = dm.trim(" ") Dim data As DataRow = DataTables("单位树").Find("标题id = \'"& dm &"\'") datastr = data("市场代码") datastr = "DA-" & datastr datastr = "\'" & datastr & "%\'" dms = nd.FullPath dms = dms.Replace("\\","") dms= dms.trim(" ") Else messagebox.Show("地址选择了吗?") Return End If \'开始计算 If tian IsNot Nothing And cp IsNot Nothing And datastr IsNot Nothing Then vars("TanChanPi") = dms & cp & "超" & tian & "天未订货" Dim tan As Integer = CInt(tian) e.Form.StopRedraw() Dim ta As DataTable = DataTables("客户查询表")
ta.Fill(";with cte as (select c.客户编号,c.客户名称,c.客户类型,c.地标_经度,c.地标_纬度,c.地标_图标,c.联系人,c.电话,a.出库单号,a.日期,b.产品,b.数量,b.金额,d.编码as 产品编码,d.产品系列 from 出库 a , 出库明细 b , 客户档案 c , 产品品项 d where a.客户编号 like \'"& datastr &"\' And d.编码 = \'"& cp &"\' And datediff(d,a.日期,getdate()) >= "& tan &" And a.出库单号= b.出库单号and a.客户编号= c.客户编号and b.产品= d.名称 ) Select t.客户编号,t.客户类型,t.客户名称,t.地标_经度,t.地标_纬度,t.地标_图标,t.产品系列,t.产品编码, \'超出:\' + isnull(replace(str(datediff(d,t.日期,getdate())),\' \',\'\'),\'--\') + \'天,最后进货日期:\'+ isnull(CONVERT(varchar(10), t.日期, 102),\'--\') +\', 数量:\'+ isnull(replace(str(t.数量),\' \',\'\'),\'--\') + \', 金额:\' + isnull(replace(str(t.金额),\' \',\'\'),\'--\') +\'元,联系人:\' +isnull(t.联系人,\'--\')+\',电话:\'+isnull(t.电话,\'--\') as 备注 from cte t where not exists( select 1 from cte where 客户编号= t.客户编号and 产品编码= t.产品编码and 日期> t.日期)","销售系统",True)
e.Form.ResumeRedraw() End If
|