| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 896 人关注过本帖
标题:這么長(不想干了)
取消只看楼主 加入收藏
西风独自凉
Rank: 8Rank: 8
等 级:贵宾
威 望:43
帖 子:3380
专家分:28
注 册:2007-8-2
结帖率:100%
收藏
 问题点数:0 回复次数:2 
這么長(不想干了)
Me.RecordSource = "SELECT TOP 100 PERCENT dbo.tbl_Store_DeliveryNote.DocID,   dbo.tbl_Store_DeliveryNote.Customer_PName, dbo.qry_Sales_SO_Active.sName,dbo.Qry_Sales_SO_Active.CS,dbo.Qry_Sales_SO_Active.salesman, " & _
                          "dbo.tbl_Store_DeliveryNote.DeliveryAddress, dbo.tbl_Store_DeliveryNote.CountryOfOrigin, " & _
                          "dbo.tbl_Store_DeliveryNote.ContactP, dbo.tbl_Store_DeliveryNote.ContactTel, " & _
                          "dbo.tbl_Store_DeliveryNote.ContactFax, dbo.tbl_Store_DeliveryNote.Remark AS DN_Remark, " & _
                          "dbo.tbl_Store_DeliveryNote_Detail.Item_No,tbl_Custom_CustomerItem.Custom_Name_Out, " & _
                          "SUM(CASE WHEN A.UOM_Cust = 'pcs' THEN dbo.tbl_Store_DeliveryNote_Detail.Quantity_Ar/A.Cust2Std ELSE dbo.tbl_Store_DeliveryNote_Detail.Quantity_Ar END) AS quantity_ar," & _
                          "SUM(dbo.tbl_Store_DeliveryNote_Detail.NOP) AS nop, dbo.tbl_Store_DeliveryNote_Detail.Remark AS Detail_Remark, " & _
                          "dbo.tbl_ItemMaster.Item_Desc, dbo.tbl_ItemMaster.Custom_No, dbo.tbl_Store_DeliveryNote.DocDate, " & _
                          "SUM((CASE WHEN A.UOM_Cust = 'pcs'  THEN dbo.tbl_Store_DeliveryNote_Detail.Quantity_Ar/A.Cust2Std ELSE dbo.tbl_Store_DeliveryNote_Detail.Quantity_Ar END) *  (Case When T.UOM2Rate Is Null Then dbo.tbl_ItemMaster.UOM2Rate Else  T.UOM2Rate End)) SumWeight,  dbo.qry_Sales_SO_Active.cust_Item_No, " & _
                          " (Case when Left( dbo.tbl_Store_DeliveryNote_Detail.Item_No,1)='F' and A.UOM_Cust is null then 'PCS'  When Left( dbo.tbl_Store_DeliveryNote_Detail.Item_No,1)<>'F' and A.UOM_Cust is null then 'K' else A.UOM_Cust end ) AS UOM, dbo.qry_Sales_SO_Active.Doc_ID, dbo.qry_Sales_SO_Active.po_No " & _
                          " FROM dbo.tbl_Store_DeliveryNote INNER JOIN dbo.tbl_Store_DeliveryNote_Detail ON " & _
                          " dbo.tbl_Store_DeliveryNote.DN_ID = dbo.tbl_Store_DeliveryNote_Detail.DN_ID INNER Join dbo.qry_Sales_SO_Active INNER JOIN " & _
                          " dbo.tbl_ItemMaster ON dbo.qry_Sales_SO_Active.item_No = dbo.tbl_ItemMaster.Item_NO ON " & _
                          " dbo.tbl_Store_DeliveryNote_Detail.So_ItemID = dbo.qry_Sales_SO_Active.SO_Item_ID  " & _
                          " Left Outer Join (Select Customer_ID,Item_NO,Cust_Item_NO,Min(Custom_uKey) As Custom_uKey  From  tbl_Sales_CustomerItem  Where Custom_uKey is not null Group By Customer_ID,Item_NO,Cust_Item_NO) TC ON Qry_Sales_SO_Active.Customer_ID=TC.Customer_ID AND Qry_Sales_SO_Active.Item_NO=TC.Item_NO AND Qry_Sales_SO_Active.Cust_Item_No=TC.Cust_Item_NO " & _
                          " Left Outer JOIN tbl_Custom_CustomerItem ON TC.Custom_uKey=tbl_Custom_CustomerItem.DetailKey AND TC.Customer_ID=tbl_Custom_CustomerItem.Customer_ID " & _
                          " Left Outer Join ( SELECT T1.item_No,T1.LotID,AVG(UOM2Rate) AS uom2rate   from dbo.tbl_Store_FinProIN_Detail  Right Outer Join  (Select distinct Item_No,LotID From  dbo.tbl_Store_DeliveryNote_Detail, dbo.tbl_Store_DeliveryNote where dbo.tbl_Store_DeliveryNote_Detail.dn_ID= dbo.tbl_Store_DeliveryNote.dn_ID and  dbo.tbl_Store_DeliveryNote.DocID= '" & Str_DocID & "') T1 On dbo.tbl_Store_FinProIN_Detail.Item_No=T1.Item_No and dbo.tbl_Store_FinProIN_Detail.LotID=T1.LotID Group bY T1.item_No,T1.LotID) T ON  dbo.tbl_Store_DeliveryNote_Detail.Item_No=T.Item_No and dbo.tbl_Store_DeliveryNote_Detail.LotID=T.LotID  " & _
                          " LEFT OUTER Join (select  distinct customer_ID,Item_no,(Case When  Left(Cust_Item_no,1)='*' then Right(Cust_Item_no,Len(Cust_Item_no)-1)  When Left(Cust_Item_no,2)='**' then Right(Cust_Item_no,Len(Cust_Item_no)-2) When Left(Cust_Item_no,3)='***' then Right(Cust_Item_no,Len(Cust_Item_no)-3) When Left(Cust_Item_no,4)='****' then Right(Cust_Item_no,Len(Cust_Item_no)-4) When Left(Cust_Item_no,5)='*****' then Right(Cust_Item_no,Len(Cust_Item_no)-5)  When Left(Cust_Item_no,6)='******' then Right(Cust_Item_no,Len(Cust_Item_no)-6) else Cust_Item_no end) AS Cust_Item_no ,UOM_Cust,Cust2Std from dbo.tbl_sales_CustomerItem) A ON dbo.qry_Sales_SO_Active.customer_ID = A.customer_ID AND dbo.qry_Sales_SO_Active.item_No = A.Item_no AND " & _
                          " a.cust_Item_No = dbo.qry_Sales_SO_Active.cust_Item_No WHERE  dbo.tbl_Store_DeliveryNote_Detail.Quantity_Ar>0   GROUP BY  dbo.tbl_Store_DeliveryNote.DocID, dbo.tbl_Store_DeliveryNote.Customer_PName, " & _
                          " dbo.qry_Sales_SO_Active.sName,dbo.Qry_Sales_SO_Active.CS,dbo.Qry_Sales_SO_Active.salesman,dbo.tbl_Store_DeliveryNote.DeliveryAddress, dbo.tbl_Store_DeliveryNote.CountryOfOrigin, dbo.tbl_Store_DeliveryNote.ContactP, dbo.tbl_Store_DeliveryNote.ContactTel, " & _
                          "dbo.tbl_Store_DeliveryNote.ContactFax, dbo.tbl_Store_DeliveryNote.Remark, dbo.tbl_Store_DeliveryNote_Detail.Item_No, dbo.tbl_Store_DeliveryNote_Detail.Remark, dbo.tbl_ItemMaster.Item_Desc, " & _
                          "dbo.tbl_ItemMaster.Custom_No,  dbo.tbl_Store_DeliveryNote.DocDate, dbo.qry_Sales_SO_Active.cust_Item_No, (Case when Left( dbo.tbl_Store_DeliveryNote_Detail.Item_No,1)='F' and A.UOM_Cust is null then 'PCS'  When Left(dbo.tbl_Store_DeliveryNote_Detail.Item_No,1)<>'F' and A.UOM_Cust is null then 'K' else A.UOM_Cust end ), dbo.qry_Sales_SO_Active.Doc_ID,dbo.tbl_ItemMaster.UOM2Rate, " & _
                          " dbo.qry_Sales_SO_Active.po_No, A.Cust2Std,tbl_Custom_CustomerItem.Custom_Name_Out having (dbo.tbl_Store_DeliveryNote.DocID = '" & Str_DocID & "')    " & _
                    "ORDER BY dbo.tbl_Store_DeliveryNote_Detail.Item_No, dbo.tbl_Store_DeliveryNote_Detail.Quantity_Ar "
搜索更多相关主题的帖子: 132546 
2008-07-09 15:06
西风独自凉
Rank: 8Rank: 8
等 级:贵宾
威 望:43
帖 子:3380
专家分:28
注 册:2007-8-2
收藏
得分:0 
sdf


[[it] 本帖最后由 西风独自凉 于 2008-7-9 18:01 编辑 [/it]]

2008-07-09 18:00
西风独自凉
Rank: 8Rank: 8
等 级:贵宾
威 望:43
帖 子:3380
专家分:28
注 册:2007-8-2
收藏
得分:0 
是以前開發的人寫的。現在我在唯護。。。。天啊﹐何時才是盡頭。
用几個小時﹐總算弄清了一點

2008-07-09 18:00
快速回复:這么長(不想干了)
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.029064 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved