1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015 |
- <?xml version="1.0" encoding="utf-8" ?>
- <Forms>
- <Form Name="FrmOverallSearchTable">
- <Client>
- <Events>
- <Load>
- <![CDATA[
- @Title="库存异动汇总";
- GetSchema();
- Search("SearchLocation");
- SuspendLayout();
- for(@i=0;@i<RowCount("#Location");@i=@i+1)
- {
- SetPosition("#Location", @i);
- cbLocation.Items.Add(#Location.Name_Location);
- }
- ResumeLayout();
- Search("SearchType");
- Search("SearchLowLocation");
- Search("SearchProductNo");
- Empty();
- EndDate.Value=GetCurrentTime();
- StartDate.Value=GetCurrentTime();
- dgProduct.ColumnVisibleByColumnName("TotalPrice",!GetFieldRight(@Title,"成本及总价","查看"));
- dgProduct.ColumnVisibleByColumnName("Cost_Product",!GetFieldRight(@Title,"成本及总价","查看"));
- cbLocation.Text = GetCurrentDepot();
- ]]>
- </Load>
- <Closing>
- ;<!--TODO-->
- </Closing>
- <Closed>
- ;<!--TODO-->
- </Closed>
- </Events>
- <Mode>
- <Search>
- <Lable name="Search" />
- </Search>
- </Mode>
- <Controls>
- <!--<IKCheckedListBox name="CLB_Location" DataSource="Location" DisplayMember="Name_location" ValueMember="ID_Location">
- <Events>
- <ItemCheck>
- if(CLB_Location.SelectedIndex == 0)
- CLB_Location.SelectAllItems();
- </ItemCheck>
- </Events>
- </IKCheckedListBox>-->
- <IKComboBox name ="cbLocation" DataSource="Location" DisplayMember="Name_Location" >
- </IKComboBox>
- <IKTextButton name="tbProductNo1" DataSource="ProductNo.No_Product">
- <Events>
- <Click>
- <![CDATA[
- if (tbProductNo1.ReadOnly == false)
- {
- @temp = ShowSearchBox("ProductSearch","INFOMATION",tbProductNo1.CValue);
- if( @temp == "" )
- return;
- tbProductNo1.CValue = @temp;
- }
- ]]>
- </Click>
- </Events>
- </IKTextButton>
- <IKTextButton name="tbProductNo2" DataSource="ProductNo.No_Product">
- <Events>
- <Click>
- <![CDATA[
- if (tbProductNo2.ReadOnly == false)
- {
- @temp = ShowSearchBox("ProductSearch","INFOMATION",tbProductNo2.CValue);
- if( @temp == "" )
- return;
- tbProductNo2.CValue = @temp;
- }
- ]]>
- </Click>
- </Events>
- </IKTextButton>
- <IKTextButton name="tbLocationNo1" DataSource="LowLocation.No_Location">
- <Events>
- <Click>
- <![CDATA[
- if (tbLocationNo1.ReadOnly == false)
- {
- @temp = ShowSearchBox("LocationSearch","INFOMATION",tbLocationNo1.CValue,cbLocation.SelectedItem);
- if( @temp == "" )
- return;
- tbLocationNo1.CValue = @temp;
- }
- ]]>
- </Click>
- </Events>
- </IKTextButton>
- <IKTextButton name="tbLocationNo2" DataSource="LowLocation.No_Location">
- <Events>
- <Click>
- <![CDATA[
- if (tbLocationNo2.ReadOnly == false)
- {
- @temp = ShowSearchBox("LocationSearch","INFOMATION",tbLocationNo2.CValue,cbLocation.SelectedItem);
- if( @temp == "" )
- return;
- tbLocationNo2.CValue = @temp;
- }
- ]]>
- </Click>
- </Events>
- </IKTextButton>
- <IKComboBoxEx name="cbType1" DataSource="Type" DisplayMember="Name_TypeDef" />
- <IKComboBoxEx name="cbType2" DataSource="Type" DisplayMember="Name_TypeDef" />
- <IKExtendGrid name="dgProduct" DataSource="Total" TableStyleIndex="0">
- <DataColumn Index="0" DataSource="Total.No_Product"/>
- <DataColumn Index="1" DataSource="Total.Name_Product"/>
- <DataColumn Index="2" DataSource="Total.Type_Product"/>
- <DataColumn Index="3" DataSource="Total.OpeningAvailableQty_ProductStocks"/>
- <DataColumn Index="4" DataSource="Total.OpeningStockQty_ProductStocks"/>
- <DataColumn Index="5" DataSource="Total.Quantity_IndentBillProduct"/>
- <DataColumn Index="6" DataSource="Total.Quantity_SaleBillProduct"/>
- <DataColumn Index="7" DataSource="Total.Quantity_SaleOutDepotBillProduct"/>
- <DataColumn Index="8" DataSource="Total.Quantity_SaleRtnBillProduct"/>
- <DataColumn Index="9" DataSource="Total.Quantity_RealSale"/>
- <DataColumn Index="10" DataSource="Total.OutQuantity_ModifyDepotBillProduct"/>
- <DataColumn Index="11" DataSource="Total.Quantity_PurchaseOrderBillProduct"/>
- <DataColumn Index="12" DataSource="Total.Quantity_PurchaseInDepotBillProduct"/>
- <DataColumn Index="13" DataSource="Total.InQuantity_ModifyDepotBillProduct"/>
- <DataColumn Index="14" DataSource="Total.InQuantity_StocktakingBillProduct"/>
- <DataColumn Index="15" DataSource="Total.OutQuantity_StocktakingBillProduct"/>
- <DataColumn Index="16" DataSource="Total.AvailableQty_ProductStocks"/>
- <DataColumn Index="17" DataSource="Total.StockQty_ProductStocks"/>
- <DataColumn Index="18" DataSource="Total.TotalPrice"/>
- <DataColumn Index="19" DataSource="Total.Cost_Product"/>
- <Events>
- <ClickPreview>
- PrintReport(dgProduct.CurrentView);
- </ClickPreview>
- <ClickRefresh>
- Empty();
- <Lable name="btnActionClick"/>
- </ClickRefresh>
- <ClickFilter>
- txtSum.CValue=SumOfCol("#Total.Quantity_RealSale",dgProduct.FilterCondition,true);
- </ClickFilter>
- <ClickNOFilter>
- txtSum.CValue=SumOfCol("#Total.Quantity_RealSale",dgProduct.FilterCondition,true);
- </ClickNOFilter>
- </Events>
- </IKExtendGrid>
- <IKButton name="btnAction">
- <Events>
- <Click>
- <Lable name="btnActionClick"/>
- </Click>
- </Events>
- </IKButton>
- <IKButton name="btnEmpty">
- <Events>
- <Click>
- Empty();
- </Click>
- </Events>
- </IKButton>
- </Controls>
- <ChildForms>
- <ChildForm name="LocationSearch" DataSource="Location" SearchFunction="SearchAllLocation" SearchFunctionByNo="" MappingName="库位" >
- <DataColumn Index="0" MappingName="#Location.No_Location" HeaderText="库位编号" Width="120" ColumnType="IKDataGridTextBoxColumn" ReturnMappingName="#LowLocation.No_Location"/>
- <DataColumn Index="1" MappingName="#Location.Name_Location" HeaderText="库位名称" Width="120" ColumnType="IKDataGridTextBoxColumn" />
- </ChildForm>
- <ChildForm name="ProductSearch" DataSource="Product" SearchFunction="SearchAllProduct" SearchFunctionByNo="" MappingName="产品" >
- <DataColumn Index="0" MappingName="#Product.No_Product" HeaderText="产品编号" Width="120" ColumnType="IKDataGridTextBoxColumn" ReturnMappingName="#ProductNo.No_Product"/>
- <DataColumn Index="1" MappingName="#Product.Name_Product" HeaderText="产品名称" Width="120" ColumnType="IKDataGridTextBoxColumn" />
- </ChildForm>
- </ChildForms>
- </Client>
- <Server>
- <Tables>
- <Table name="Total" Type="Parent">
- <GetSchema CmdType="Text" CmdText="
- Select Top 0 Product.No_Product,Product.Name_Product,Product.Type_Product,Product.Cost_Product,ProductStocks.OpeningAvailableQty_ProductStocks,OpeningStockQty_ProductStocks,ProductStocks.AvailableQty_ProductStocks,StockQty_ProductStocks,SaleBillProduct.Quantity_SaleBillProduct,SaleOutDepotBillProduct.Quantity_SaleOutDepotBillProduct,SaleRtnBillProduct.Quantity_SaleRtnBillProduct,IndentBillProduct.Quantity_IndentBillProduct,
- a.Quantity_ModifyDepotBillProduct As OutQuantity_ModifyDepotBillProduct,b.Quantity_ModifyDepotBillProduct As InQuantity_ModifyDepotBillProduct,PurchaseOrderBillProduct.Quantity_PurchaseOrderBillProduct,PurchaseInDepotBillProduct.Quantity_PurchaseInDepotBillProduct,
- c.Quantity_StocktakingBillProduct As OutQuantity_StocktakingBillProduct,d.Quantity_StocktakingBillProduct As InQuantity_StocktakingBillProduct,convert(decimal(18,6),0) As TotalPrice,convert(decimal(14,4),0) As Quantity_RealSale
- From Product
- Left Join ProductStocks On ProductStocks.ID_Product=Product.ID_Product
- Left Join IndentBillProduct On IndentBillProduct.ID_Product=Product.ID_Product
- Left Join SaleBillProduct On SaleBillProduct.ID_Product=Product.ID_Product
- Left Join SaleOutDepotBillProduct On SaleOutDepotBillProduct.ID_Product=Product.ID_Product
- Left Join SaleRtnBillProduct On SaleRtnBillProduct.ID_Product=Product.ID_Product
- Left Join ModifyDepotBillProduct a On a.ID_Product=Product.ID_Product
- Left Join ModifyDepotBillProduct b On b.ID_Product=Product.ID_Product
- Left Join PurchaseOrderBillProduct On PurchaseOrderBillProduct.ID_Product=Product.ID_Product
- Left Join PurchaseInDepotBillProduct On PurchaseInDepotBillProduct.ID_Product=Product.ID_Product
- Left Join StocktakingBillProduct c ON c.ID_Product=Product.ID_Product
- Left Join StocktakingBillProduct d On d.ID_Product=Product.ID_Product
- "/>
-
- </Table>
- </Tables>
- <Search>
-
- <SearchLocation CmdType="Text" CmdText="Select Name_Location,No_Location from Location where Level_Location = 0
- Union Select '全部' As Name_Location, '00' As No_Location">
- <Tables>
- <Table name="Location"/>
- </Tables>
- </SearchLocation>
- <SearchType CmdType="Text" CmdText=" SELECT Name_TypeDef From TypeDef Where Type_TypeDef=8 Order By Name_TypeDef ">
- <Tables>
- <Table name="Type"/>
- </Tables>
- </SearchType>
-
- <SearchAllLocation CmdType="Text" CmdText="Select No_Location,Name_Location
- From Location Where ID_Warehouse IN(
- Select ID_Location
- From Location
- ">
- <Tables>
- <Table name="AllLocation" />
- </Tables>
- </SearchAllLocation>
- <SearchAllProduct CmdType="Text" CmdText="Select No_Product
- ,Name_Product
- From Product
- Order By No_Product">
- <Tables>
- <Table name="AllProduct" />
- </Tables>
- </SearchAllProduct>
- <SearchLowLocation CmdType="" CmdText="Select No_Location From Location Where Level_Location = 1">
- <Tables>
- <Table name="LowLocation"/>
- </Tables>
- </SearchLowLocation>
- <SearchProductNo CmdType="Text" CmdText="Select No_Product From Product Order By No_Product">
- <Tables>
- <Table name="ProductNo"/>
- </Tables>
- </SearchProductNo>
- <SearchAllLocationID CmdType="Text" CmdText ="Select ID_Location From Location Where Level_Location = 0">
- <Tables>
- <Table name="AllLocationID"/>
- </Tables>
- </SearchAllLocationID>
- <SearchLocationID CmdType="Text" CmdText="Select ID_Location From Location Where Name_Location = @Name_Location">
- <Params>
- <Param name="@Name_Location" type="Location.Name_Location" Index="0" />
- </Params>
- <Tables>
- <Table name="LocationID"/>
- </Tables>
- </SearchLocationID>
- </Search>
- </Server>
- <Lables>
- <Search>
-
- </Search>
- <btnActionClick>
- if(cbLocation.SelectedItem == "全部")
- {
- if (Search("SearchAllLocationID"))
- {
- SuspendLayout();
- for(@i = 0; @i<RowCount("#AllLocationID");@i=@i+1)
- {
- SetPosition("#AllLocationID", @i);
- if (@i == 0)
- @a = "'"+FormatString(#AllLocationID.ID_Location)+"'";
- else
- @a = @a + "," +"'"+ FormatString(#AllLocationID.ID_Location)+"'";
- @Location = " In ( " + @a + ")";
- }
- ResumeLayout();
- }
- }
- else
- {
- Search("SearchLocationID",cbLocation.SelectedItem);
- @Location = " = '" + FormatString(#LocationID.ID_Location) +"'";
- }
- @dateCondition=" between "+" DATEADD(day,0,DATEDIFF(day,0,"+"'"+TypeConvert("String",StartDate.Value)+"'"+")) and "+" DATEADD(day,0,(DATEDIFF(day,0,"+"'"+TypeConvert("String",EndDate.Value)+"'"+")+1))";
- @bisNow=" <= DATEADD(day,0,(DATEDIFF(day,0,'"+TypeConvert("String",EndDate.Value)+"')+1))";
- @sqlCmd =" Select a.No_Product,a.Name_Product,a.Type_Product,a.Cost_Product,(IsNull(b.OpeningStockQty_ProductStocks,0)-IsNull(d1.Quantity_SaleOutDepotBillProduct,0)-IsNull(f1.OutQuantity_ModifyDepotBillProduct,0)+IsNull(h1.Quantity_PurchaseInDepotBillProduct,0)+IsNull(e1.InQuantity_ModifyDepotBillProduct,0)+IsNull(d.Quantity_SaleOutDepotBillProduct,0)+IsNull(f.OutQuantity_ModifyDepotBillProduct,0)-IsNull(h.Quantity_PurchaseInDepotBillProduct,0)-IsNull(e.InQuantity_ModifyDepotBillProduct,0)) As OpeningStockQty_ProductStocks ,(IsNull(b.OpeningStockQty_ProductStocks,0)-IsNull(d1.Quantity_SaleOutDepotBillProduct,0)-IsNull(f1.OutQuantity_ModifyDepotBillProduct,0)+IsNull(h1.Quantity_PurchaseInDepotBillProduct,0)+IsNull(e1.InQuantity_ModifyDepotBillProduct,0)) As StockQty_ProductStocks,a.Cost_Product*(IsNull(b.OpeningStockQty_ProductStocks,0)-IsNull(d1.Quantity_SaleOutDepotBillProduct,0)-IsNull(f1.OutQuantity_ModifyDepotBillProduct,0)+IsNull(h1.Quantity_PurchaseInDepotBillProduct,0)+IsNull(e1.InQuantity_ModifyDepotBillProduct,0)) As TotalPrice, "
- +" (IsNull(pb.OpeningAvailableQty_ProductStocks,0)-IsNull(c1.Quantity_SaleBillProduct,0)-IsNull(f1.OutQuantity_ModifyDepotBillProduct,0)+IsNull(h1.Quantity_PurchaseInDepotBillProduct,0)+IsNull(e1.InQuantity_ModifyDepotBillProduct,0)+IsNull(c.Quantity_SaleBillProduct,0)+IsNull(f.OutQuantity_ModifyDepotBillProduct,0)-IsNull(h.Quantity_PurchaseInDepotBillProduct,0)-IsNull(e.InQuantity_ModifyDepotBillProduct,0)) As OpeningAvailableQty_ProductStocks ,(IsNull(pb.OpeningAvailableQty_ProductStocks,0)-IsNull(c1.Quantity_SaleBillProduct,0)-IsNull(f1.OutQuantity_ModifyDepotBillProduct,0)+IsNull(h1.Quantity_PurchaseInDepotBillProduct,0)+IsNull(e1.InQuantity_ModifyDepotBillProduct,0)) As AvailableQty_ProductStocks,"
- +" IsNull(c.Quantity_SaleBillProduct,0) As Quantity_SaleBillProduct,IsNull(d.Quantity_SaleOutDepotBillProduct,0) As Quantity_SaleOutDepotBillProduct,IsNull(e.InQuantity_ModifyDepotBillProduct,0) As InQuantity_ModifyDepotBillProduct,IsNull(f.OutQuantity_ModifyDepotBillProduct,0) As OutQuantity_ModifyDepotBillProduct,(IsNull(d.Quantity_SaleOutDepotBillProduct,0)-IsNull(k.Quantity_SaleRtnBillProduct,0)) As Quantity_RealSale, "
- +" IsNull(g.Quantity_PurchaseOrderBillProduct,0) As Quantity_PurchaseOrderBillProduct,IsNull(h.Quantity_PurchaseInDepotBillProduct,0) As Quantity_PurchaseInDepotBillProduct,IsNull(i.InQuantity_StocktakingBillProduct,0) As InQuantity_StocktakingBillProduct,IsNull(j.OutQuantity_StocktakingBillProduct,0) As OutQuantity_StocktakingBillProduct,IsNull(k.Quantity_SaleRtnBillProduct,0) As Quantity_SaleRtnBillProduct,IsNull(ind.Quantity_IndentBillProduct,0) As Quantity_IndentBillProduct"
- +" From "
- +" ("
- +" Select ProductStocks.ID_Product,Sum(OpeningStockQty_ProductStocks) As OpeningStockQty_ProductStocks"
- +" From ProductStocks"
- +" Where ID_Location IN("
- +" Select x.ID_Location From Location x"
- +" Left Join Location s On x.ID_Warehouse = s.ID_Location"
- +" Where x.Level_Location = 1"
- +" And s.ID_Location" + @Location
- +" )"
- +" Group By ID_Product"
- +" )b "
-
- +" Join"
- +" ( "
- +" Select Product.ID_Product,Product.No_Product,Product.Type_Product,Product.Name_Product,Product.Cost_Product"
- +" From Product"
- +" )a On a.ID_Product=b.ID_Product"
- +" Join"
- +" ("
- +" Select ProductStocks.ID_Product,Sum(OpeningAvailableQty_ProductStocks) As OpeningAvailableQty_ProductStocks"
- +" From ProductStocks"
- +" Where ID_Location" + @Location
- +" Group By ID_Product"
- +" )pb On b.ID_Product=pb.ID_Product"
- +" Left Join"
- +" ("
- +" Select IndentBillProduct.ID_Product,Sum(IndentBillProduct.Quantity_IndentBillProduct) As Quantity_IndentBillProduct"
- +" From IndentBillProduct"
- +" Join IndentBill On IndentBill.ID_IndentBill=IndentBillProduct.ID_IndentBill"
- +" Where IndentBill.ID_Assessor Is Not Null And IndentBill.Date_IndentBill "+@dateCondition+" And IndentBill.ID_Location " + @Location
- +" Group By IndentBillProduct.ID_Product"
- +" )ind On b.ID_Product=ind.ID_Product"
- +" Left Join"
- +" ("
- +" Select SaleBillProduct.ID_Product,Sum(SaleBillProduct.Quantity_SaleBillProduct) As Quantity_SaleBillProduct"
- +" From SaleBillProduct"
- +" Join SaleBill On SaleBill.ID_SaleBill=SaleBillProduct.ID_SaleBill"
- +" Where SaleBill.ID_Assessor Is Not Null And SaleBill.Date_SaleBill "+@dateCondition +" And SaleBill.ID_Location " + @Location
- +" Group By SaleBillProduct.ID_Product"
- +" )c On b.ID_Product=c.ID_Product"
- +" Left Join"
- +" ("
- +" Select SaleOutDepotBillProduct.ID_Product,Sum(SaleOutDepotBillProduct.Quantity_SaleOutDepotBillProduct) As Quantity_SaleOutDepotBillProduct"
- +" From SaleOutDepotBillProduct"
- +" Join SaleOutDepotBill On SaleOutDepotBill.ID_SaleOutDepotBill=SaleOutDepotBillProduct.ID_SaleOutDepotBill"
- +" Where SaleOutDepotBill.ID_Assessor Is Not Null And SaleOutDepotBill.Date_SaleOutDepotBill "+@dateCondition + " And SaleOutDepotBill.ID_Location " + @Location
- +" Group By SaleOutDepotBillProduct.ID_Product"
- +" )d On b.ID_Product=d.ID_Product"
- +" Left Join"
- +" ("
- +" Select ModifyDepotBillProduct.ID_Product,Sum(Quantity_ModifyDepotBillProduct) As InQuantity_ModifyDepotBillProduct"
- +" From ModifyDepotBillProduct"
- +" Join ModifyDepotBill On ModifyDepotBillProduct.ID_ModifyDepotBill=ModifyDepotBill.ID_ModifyDepotBill"
- +" Join ModifyTypeSettings On ModifyTypeSettings.ID_ModifyTypeSettings=ModifyDepotBill.Style_ModifyDepotBill"
- +" Where ModifyDepotBill.ID_Assessor Is Not Null And ModifyTypeSettings.Type_ModifyTypeSettings=1 And Date_ModifyDepotBill "+@dateCondition+ " And ModifyDepotBill.ID_Location " + @Location
- +" Group By ModifyDepotBillProduct.ID_Product"
- +" )e On b.ID_Product=e.ID_Product"
- +" Left Join"
- +" ("
- +" Select ModifyDepotBillProduct.ID_Product,Sum(Quantity_ModifyDepotBillProduct) As OutQuantity_ModifyDepotBillProduct"
- +" From ModifyDepotBillProduct"
- +" Join ModifyDepotBill On ModifyDepotBillProduct.ID_ModifyDepotBill=ModifyDepotBill.ID_ModifyDepotBill"
- +" Join ModifyTypeSettings On ModifyTypeSettings.ID_ModifyTypeSettings=ModifyDepotBill.Style_ModifyDepotBill"
- +" Where ModifyDepotBill.ID_Assessor Is Not Null And ModifyTypeSettings.Type_ModifyTypeSettings=0 And Date_ModifyDepotBill "+@dateCondition+ " And ModifyDepotBill.ID_Location " + @Location
- +" Group By ModifyDepotBillProduct.ID_Product"
- +" )f On b.ID_Product=f.ID_Product"
- +" Left Join"
- +" ("
- +" Select PurchaseOrderBillProduct.ID_Product,Sum(Quantity_PurchaseOrderBillProduct) As Quantity_PurchaseOrderBillProduct"
- +" From PurchaseOrderBillProduct"
- +" Join PurchaseOrderBill On PurchaseOrderBill.ID_PurchaseOrderBill=PurchaseOrderBillProduct.ID_PurchaseOrderBill"
- +" Where PurchaseOrderBill.ID_Assessor Is Not Null And PurchaseOrderBill.Date_PurchaseOrderBill "+@dateCondition+" And PurchaseOrderBill.ID_Location " + @Location
- +" Group By PurchaseOrderBillProduct.ID_Product"
- +" )g On a.ID_Product=g.ID_Product"
- +" Left Join"
- +" ("
- +" Select PurchaseInDepotBillProduct.ID_Product,Sum(Quantity_PurchaseInDepotBillProduct) As Quantity_PurchaseInDepotBillProduct"
- +" From PurchaseInDepotBillProduct"
- +" Join PurchaseInDepotBill On PurchaseInDepotBill.ID_PurchaseInDepotBill=PurchaseInDepotBillProduct.ID_PurchaseInDepotBill"
- +" Where PurchaseInDepotBill.ID_Assessor Is Not Null And PurchaseInDepotBill.Date_PurchaseInDepotBill "+@dateCondition+ " And PurchaseInDepotBill.ID_Location " + @Location
- +" Group By PurchaseInDepotBillProduct.ID_Product"
- +" )h On b.ID_Product=h.ID_Product"
- +" Left Join"
- +" ("
- +" Select StocktakingBillProduct.ID_Product,Sum(StocktakingBillProduct.Quantity_StocktakingBillProduct-StocktakingBillProduct.StockQty_StocktakingBillProduct) As InQuantity_StocktakingBillProduct"
- +" From StocktakingBillProduct"
- +" Join StocktakingBill On StocktakingBill.ID_StocktakingBill=StocktakingBillProduct.ID_StocktakingBill"
- +" Where StocktakingBill.ID_Assessor Is Not Null And (StocktakingBillProduct.Quantity_StocktakingBillProduct-StocktakingBillProduct.StockQty_StocktakingBillProduct) > 0 And StocktakingBill.Date_StocktakingBill "+@dateCondition+ " And StocktakingBill.ID_Location " + @Location
- +" Group By StocktakingBillProduct.ID_Product"
- +" )i On b.ID_Product=i.ID_Product"
- +" Left Join"
- +" ("
- +" Select StocktakingBillProduct.ID_Product,-Sum(StocktakingBillProduct.Quantity_StocktakingBillProduct-StocktakingBillProduct.StockQty_StocktakingBillProduct) As OutQuantity_StocktakingBillProduct"
- +" From StocktakingBillProduct"
- +" Join StocktakingBill On StocktakingBill.ID_StocktakingBill=StocktakingBillProduct.ID_StocktakingBill"
- +" Where StocktakingBill.ID_Assessor Is Not Null And (StocktakingBillProduct.Quantity_StocktakingBillProduct-StocktakingBillProduct.StockQty_StocktakingBillProduct) < 0 And StocktakingBill.Date_StocktakingBill "+@dateCondition+ " And StocktakingBill.ID_Location " + @Location
- +" Group By StocktakingBillProduct.ID_Product"
- +" )j On b.ID_Product=j.ID_Product"
- +" Left Join"
- +" ("
- +" Select SaleRtnBillProduct.ID_Product,Sum(Quantity_SaleRtnBillProduct) As Quantity_SaleRtnBillProduct"
- +" From SaleRtnBillProduct"
- +" Join SaleRtnBill On SaleRtnBill.ID_SaleRtnBill=SaleRtnBillProduct.ID_SaleRtnBill"
- +" Where SaleRtnBill.ID_Assessor Is Not Null And SaleRtnBill.Date_SaleRtnBill "+@dateCondition+ " And SaleRtnBill.ID_Location " + @Location
- +" Group By SaleRtnBillProduct.ID_Product"
- +" )k On b.ID_Product=k.ID_Product"
- +" Left Join"
- +" ("
- +" Select SaleOutDepotBillProduct.ID_Product,Sum(SaleOutDepotBillProduct.Quantity_SaleOutDepotBillProduct) As Quantity_SaleOutDepotBillProduct"
- +" From SaleOutDepotBillProduct"
- +" Join SaleOutDepotBill On SaleOutDepotBill.ID_SaleOutDepotBill=SaleOutDepotBillProduct.ID_SaleOutDepotBill"
- +" Where SaleOutDepotBill.ID_Assessor Is Not Null And SaleOutDepotBill.Date_SaleOutDepotBill "+@bisNow+ " And SaleOutDepotBill.ID_Location " + @Location
- +" Group By SaleOutDepotBillProduct.ID_Product"
- +" )d1 On b.ID_Product=d1.ID_Product"
- +" Left Join"
- +" ("
- +" Select ModifyDepotBillProduct.ID_Product,Sum(Quantity_ModifyDepotBillProduct) As InQuantity_ModifyDepotBillProduct"
- +" From ModifyDepotBillProduct"
- +" Join ModifyDepotBill On ModifyDepotBillProduct.ID_ModifyDepotBill=ModifyDepotBill.ID_ModifyDepotBill"
- +" Join ModifyTypeSettings On ModifyTypeSettings.ID_ModifyTypeSettings=ModifyDepotBill.Style_ModifyDepotBill"
- +" Where ModifyDepotBill.ID_Assessor Is Not Null And ModifyTypeSettings.Type_ModifyTypeSettings=1 And Date_ModifyDepotBill "+@bisNow+ " And ModifyDepotBill.ID_Location " + @Location
- +" Group By ModifyDepotBillProduct.ID_Product"
- +" )e1 On b.ID_Product=e1.ID_Product"
- +" Left Join"
- +" ("
- +" Select ModifyDepotBillProduct.ID_Product,Sum(Quantity_ModifyDepotBillProduct) As OutQuantity_ModifyDepotBillProduct"
- +" From ModifyDepotBillProduct"
- +" Join ModifyDepotBill On ModifyDepotBillProduct.ID_ModifyDepotBill=ModifyDepotBill.ID_ModifyDepotBill"
- +" Join ModifyTypeSettings On ModifyTypeSettings.ID_ModifyTypeSettings=ModifyDepotBill.Style_ModifyDepotBill"
- +" Where ModifyDepotBill.ID_Assessor Is Not Null And ModifyTypeSettings.Type_ModifyTypeSettings=0 And Date_ModifyDepotBill "+@bisNow+ " And ModifyDepotBill.ID_Location " + @Location
- +" Group By ModifyDepotBillProduct.ID_Product"
- +" )f1 On b.ID_Product=f1.ID_Product"
- +" Left Join"
- +" ("
- +" Select PurchaseInDepotBillProduct.ID_Product,Sum(Quantity_PurchaseInDepotBillProduct) As Quantity_PurchaseInDepotBillProduct"
- +" From PurchaseInDepotBillProduct"
- +" Join PurchaseInDepotBill On PurchaseInDepotBill.ID_PurchaseInDepotBill=PurchaseInDepotBillProduct.ID_PurchaseInDepotBill"
- +" Where PurchaseInDepotBill.ID_Assessor Is Not Null And PurchaseInDepotBill.Date_PurchaseInDepotBill "+@bisNow+ " And PurchaseInDepotBill.ID_Location " + @Location
- +" Group By PurchaseInDepotBillProduct.ID_Product"
- +" )h1 On b.ID_Product=h1.ID_Product"
- +" Left Join"
- +" ("
- +" Select SaleBillProduct.ID_Product,Sum(SaleBillProduct.Quantity_SaleBillProduct) As Quantity_SaleBillProduct"
- +" From SaleBillProduct"
- +" Join SaleBill On SaleBill.ID_SaleBill=SaleBillProduct.ID_SaleBill"
- +" Where SaleBill.ID_Assessor Is Not Null And SaleBill.Date_SaleBill "+@bisNow+ " And SaleBill.ID_Location " + @Location
- +" Group By SaleBillProduct.ID_Product"
- +" )c1 On b.ID_Product=c1.ID_Product";
- @where=true;
- if(cbType1.Text!="")
- {
- if(@where==true)
- {
- @sqlCmd=@sqlCmd+" Where Type_Product >=" +"'"+cbType1.Text+"'";
- @where=false;
- }
- else
- {
- @sqlCmd=@sqlCmd+" And Type_Product >=" +"'"+cbType1.Text+"'";
- }
- }
- if(cbType2.Text!="")
- {
- if(@where==true)
- {
- @sqlCmd=@sqlCmd+" Where Type_Product <="+"'"+cbType2.Text+"'";
- @where=false;
- }
- else
- {
- @sqlCmd=@sqlCmd+" And Type_Product <="+"'"+cbType2.Text+"'";
- }
- }
-
- if(tbProductNo1.CValue!="")
- {
- if(@where==true)
- {
- @sqlCmd=@sqlCmd+" Where No_Product >=" +"'"+tbProductNo1.CValue+"'";
- @where=false;
- }
- else
- {
- @sqlCmd=@sqlCmd+" And No_Product >=" +"'"+tbProductNo1.CValue+"'";
- }
- }
- if(tbProductNo2.CValue!="")
- {
- if(@where==true)
- {
- @sqlCmd=@sqlCmd+" Where No_Product <="+"'"+tbProductNo2.CValue+"'";
- @where=false;
- }
- else
- {
- @sqlCmd=@sqlCmd+" And No_Product <="+"'"+tbProductNo2.CValue+"'";
- }
- }
-
- if(ckSuspend.Checked)
- {
- if(@where==true)
- {
- @sqlCmd=@sqlCmd+" Where (IsNull(c.Quantity_SaleBillProduct,0)+IsNull(d.Quantity_SaleOutDepotBillProduct,0)+IsNull(f.OutQuantity_ModifyDepotBillProduct,0)+IsNull(g.Quantity_PurchaseOrderBillProduct,0)+IsNull(h.Quantity_PurchaseInDepotBillProduct,0)+IsNull(e.InQuantity_ModifyDepotBillProduct,0)+IsNull(i.InQuantity_StocktakingBillProduct,0)+IsNull(j.OutQuantity_StocktakingBillProduct,0)+IsNull(k.Quantity_SaleRtnBillProduct,0)+IsNull(ind.Quantity_IndentBillProduct,0)) > 0 ";
- @where=false;
- }
- else
- {
- @sqlCmd=@sqlCmd+" And (IsNull(c.Quantity_SaleBillProduct,0)+IsNull(d.Quantity_SaleOutDepotBillProduct,0)+IsNull(f.OutQuantity_ModifyDepotBillProduct,0)+IsNull(g.Quantity_PurchaseOrderBillProduct,0)+IsNull(h.Quantity_PurchaseInDepotBillProduct,0)+IsNull(e.InQuantity_ModifyDepotBillProduct,0)+IsNull(i.InQuantity_StocktakingBillProduct,0)+IsNull(j.OutQuantity_StocktakingBillProduct,0)+IsNull(k.Quantity_SaleRtnBillProduct,0)) > 0 ";
- }
- }
- @sqlCmd=@sqlCmd+" Order By a.No_Product ";
- <!--MessageBox(@sqlCmd,"IS");-->
- SearchEx(@sqlCmd,"Total");
- txtSum.CValue=SumOfCol("#Total.Quantity_RealSale");
- </btnActionClick>
-
- <!--<btnActionClick>
-
- @LocationAll = " Location.No_Location In (Select No_Location From Location Where Level_Location = 0)" ;
- if(cbLocation.SelectedItem == "全部")
- {
- @Location = "x.Level_Location = 1";
- }
- else
- {
- @Location = " x.Level_Location = 1 And x.No_Location BETWEEN ISNULL(@StartNo_Location,x.No_Location) AND ISNULL(@EndNo_Location,x.No_Location) And s.Name_Location = '" + cbLocation.SelectedItem + "'";
- }
- @dateCondition=" between "+" DATEADD(day,0,DATEDIFF(day,0,"+"'"+TypeConvert("String",StartDate.Value)+"'"+")) and "+" DATEADD(day,0,(DATEDIFF(day,0,"+"'"+TypeConvert("String",EndDate.Value)+"'"+")+1))";
- @bisNow=" <= DATEADD(day,0,(DATEDIFF(day,0,'"+TypeConvert("String",EndDate.Value)+"')+1))";
-
- @sqlCmd=" Declare @StartNo_Location Nvarchar(64) Set @StartNo_Location = Null"
- +" Declare @EndNo_Location Nvarchar(64) Set @EndNo_Location = Null";
- if(tbLocationNo1.CValue != "")
- {
- @sqlCmd = @sqlCmd + " Set @StartNo_Location ='" +tbLocationNo1.CValue+"'";
- }
- if(tbLocationNo2.CValue != "")
- {
- @sqlCmd = @sqlCmd + " Set @EndNo_Location ='" +tbLocationNo2.CValue+"'";
- }
- @sqlCmd =@sqlCmd +" Select a.No_Product,a.Name_Product,a.Type_Product,a.Cost_Product,(IsNull(b.OpeningStockQty_ProductStocks,0)-IsNull(d1.Quantity_SaleOutDepotBillProduct,0)-IsNull(f1.OutQuantity_ModifyDepotBillProduct,0)+IsNull(h1.Quantity_PurchaseInDepotBillProduct,0)+IsNull(e1.InQuantity_ModifyDepotBillProduct,0)+IsNull(d.Quantity_SaleOutDepotBillProduct,0)+IsNull(f.OutQuantity_ModifyDepotBillProduct,0)-IsNull(h.Quantity_PurchaseInDepotBillProduct,0)-IsNull(e.InQuantity_ModifyDepotBillProduct,0)) As OpeningStockQty_ProductStocks ,(IsNull(b.OpeningStockQty_ProductStocks,0)-IsNull(d1.Quantity_SaleOutDepotBillProduct,0)-IsNull(f1.OutQuantity_ModifyDepotBillProduct,0)+IsNull(h1.Quantity_PurchaseInDepotBillProduct,0)+IsNull(e1.InQuantity_ModifyDepotBillProduct,0)) As StockQty_ProductStocks,a.Cost_Product*(IsNull(b.OpeningStockQty_ProductStocks,0)-IsNull(d1.Quantity_SaleOutDepotBillProduct,0)-IsNull(f1.OutQuantity_ModifyDepotBillProduct,0)+IsNull(h1.Quantity_PurchaseInDepotBillProduct,0)+IsNull(e1.InQuantity_ModifyDepotBillProduct,0)) As TotalPrice, "
- +" (IsNull(pb.OpeningAvailableQty_ProductStocks,0)-IsNull(c1.Quantity_SaleBillProduct,0)-IsNull(f1.OutQuantity_ModifyDepotBillProduct,0)+IsNull(h1.Quantity_PurchaseInDepotBillProduct,0)+IsNull(e1.InQuantity_ModifyDepotBillProduct,0)+IsNull(c.Quantity_SaleBillProduct,0)+IsNull(f.OutQuantity_ModifyDepotBillProduct,0)-IsNull(h.Quantity_PurchaseInDepotBillProduct,0)-IsNull(e.InQuantity_ModifyDepotBillProduct,0)) As OpeningAvailableQty_ProductStocks ,(IsNull(pb.OpeningAvailableQty_ProductStocks,0)-IsNull(c1.Quantity_SaleBillProduct,0)-IsNull(f1.OutQuantity_ModifyDepotBillProduct,0)+IsNull(h1.Quantity_PurchaseInDepotBillProduct,0)+IsNull(e1.InQuantity_ModifyDepotBillProduct,0)) As AvailableQty_ProductStocks,"
- +" IsNull(c.Quantity_SaleBillProduct,0) As Quantity_SaleBillProduct,IsNull(d.Quantity_SaleOutDepotBillProduct,0) As Quantity_SaleOutDepotBillProduct,IsNull(e.InQuantity_ModifyDepotBillProduct,0) As InQuantity_ModifyDepotBillProduct,IsNull(f.OutQuantity_ModifyDepotBillProduct,0) As OutQuantity_ModifyDepotBillProduct,(IsNull(d.Quantity_SaleOutDepotBillProduct,0)-IsNull(k.Quantity_SaleRtnBillProduct,0)) As Quantity_RealSale, "
- +" IsNull(g.Quantity_PurchaseOrderBillProduct,0) As Quantity_PurchaseOrderBillProduct,IsNull(h.Quantity_PurchaseInDepotBillProduct,0) As Quantity_PurchaseInDepotBillProduct,IsNull(i.InQuantity_StocktakingBillProduct,0) As InQuantity_StocktakingBillProduct,IsNull(j.OutQuantity_StocktakingBillProduct,0) As OutQuantity_StocktakingBillProduct,IsNull(k.Quantity_SaleRtnBillProduct,0) As Quantity_SaleRtnBillProduct,IsNull(ind.Quantity_IndentBillProduct,0) As Quantity_IndentBillProduct"
- +" From "
- +" ( "
- +" Select Product.ID_Product,Product.No_Product,Product.Type_Product,Product.Name_Product,Product.Cost_Product"
- +" From Product"
- +" )a"
- +" Join"
- +" ("
- +" Select ProductStocks.ID_Product,Sum(OpeningStockQty_ProductStocks) As OpeningStockQty_ProductStocks"
- +" From ProductStocks"
- +" Where ID_Location IN("
- +" Select x.ID_Location From Location x"
- +" Left Join Location s On x.ID_Warehouse = s.ID_Location Where "
- + @Location
- +" )"
- +" Group By ID_Product"
- +" )b On a.ID_Product=b.ID_Product"
-
- +" Join"
- +" ("
- +" Select ProductStocks.ID_Product,Sum(OpeningAvailableQty_ProductStocks) As OpeningAvailableQty_ProductStocks"
- +" From ProductStocks"
- +" Where ID_Location IN("
- +" Select ID_Location"
- +" From Location"
- +" Where Name_Location IN (";
- if(cbLocation.SelectedItem == "全部")
- {
- @sqlCmd=@sqlCmd +" Select Name_Location From Location Where Level_Location=0";
- }
- else
- {
- @sqlCmd=@sqlCmd +"'"+ cbLocation.SelectedItem+"'";
- }
- @sqlCmd=@sqlCmd +" )"
- +" )"
- +" Group By ID_Product"
- +" )pb On a.ID_Product=pb.ID_Product"
-
- +" Left Join"
- +" ("
- +" Select IndentBillProduct.ID_Product,Sum(IndentBillProduct.Quantity_IndentBillProduct) As Quantity_IndentBillProduct"
- +" From IndentBillProduct"
- +" Join IndentBill On IndentBill.ID_IndentBill=IndentBillProduct.ID_IndentBill"
- +" Join Location On Location.ID_Location=IndentBill.ID_Location"
- +" Where IndentBill.ID_Assessor Is Not Null And IndentBill.Date_IndentBill "+@dateCondition+ " And "+@LocationAll
- +" Group By IndentBillProduct.ID_Product"
- +" )ind On a.ID_Product=ind.ID_Product"
-
- +" Left Join"
- +" ("
- +" Select SaleBillProduct.ID_Product,Sum(SaleBillProduct.Quantity_SaleBillProduct) As Quantity_SaleBillProduct"
- +" From SaleBillProduct"
- +" Join SaleBill On SaleBill.ID_SaleBill=SaleBillProduct.ID_SaleBill"
- +" Join Location On Location.ID_Location=SaleBill.ID_Location"
- +" Where SaleBill.ID_Assessor Is Not Null And SaleBill.Date_SaleBill "+@dateCondition+ " And "+@LocationAll
- +" Group By SaleBillProduct.ID_Product"
- +" )c On a.ID_Product=c.ID_Product"
- +" Left Join"
- +" ("
- +" Select SaleOutDepotBillProduct.ID_Product,Sum(SaleOutDepotBillProduct.Quantity_SaleOutDepotBillProduct) As Quantity_SaleOutDepotBillProduct"
- +" From SaleOutDepotBillProduct"
- +" Join SaleOutDepotBill On SaleOutDepotBill.ID_SaleOutDepotBill=SaleOutDepotBillProduct.ID_SaleOutDepotBill"
- +" Join Location On Location.ID_Location=SaleOutDepotBill.ID_Location"
- +" Where SaleOutDepotBill.ID_Assessor Is Not Null And SaleOutDepotBill.Date_SaleOutDepotBill "+@dateCondition+ " And "+@LocationAll
- +" Group By SaleOutDepotBillProduct.ID_Product"
- +" )d On a.ID_Product=d.ID_Product"
- +" Left Join"
- +" ("
- +" Select ModifyDepotBillProduct.ID_Product,Sum(Quantity_ModifyDepotBillProduct) As InQuantity_ModifyDepotBillProduct"
- +" From ModifyDepotBillProduct"
- +" Join ModifyDepotBill On ModifyDepotBillProduct.ID_ModifyDepotBill=ModifyDepotBill.ID_ModifyDepotBill"
- +" Join ModifyTypeSettings On ModifyTypeSettings.ID_ModifyTypeSettings=ModifyDepotBill.Style_ModifyDepotBill"
- +" Join Location On Location.ID_Location=ModifyDepotBill.ID_Location"
- +" Where ModifyDepotBill.ID_Assessor Is Not Null And ModifyTypeSettings.Type_ModifyTypeSettings=1 And Date_ModifyDepotBill "+@dateCondition+ " And "+@LocationAll
- +" Group By ModifyDepotBillProduct.ID_Product"
- +" )e On a.ID_Product=e.ID_Product"
- +" Left Join"
- +" ("
- +" Select ModifyDepotBillProduct.ID_Product,Sum(Quantity_ModifyDepotBillProduct) As OutQuantity_ModifyDepotBillProduct"
- +" From ModifyDepotBillProduct"
- +" Join ModifyDepotBill On ModifyDepotBillProduct.ID_ModifyDepotBill=ModifyDepotBill.ID_ModifyDepotBill"
- +" Join ModifyTypeSettings On ModifyTypeSettings.ID_ModifyTypeSettings=ModifyDepotBill.Style_ModifyDepotBill"
- +" Join Location On Location.ID_Location=ModifyDepotBill.ID_Location"
- +" Where ModifyDepotBill.ID_Assessor Is Not Null And ModifyTypeSettings.Type_ModifyTypeSettings=0 And Date_ModifyDepotBill "+@dateCondition+ " And "+@LocationAll
- +" Group By ModifyDepotBillProduct.ID_Product"
- +" )f On a.ID_Product=f.ID_Product"
- +" Left Join"
- +" ("
- +" Select PurchaseOrderBillProduct.ID_Product,Sum(Quantity_PurchaseOrderBillProduct) As Quantity_PurchaseOrderBillProduct"
- +" From PurchaseOrderBillProduct"
- +" Join PurchaseOrderBill On PurchaseOrderBill.ID_PurchaseOrderBill=PurchaseOrderBillProduct.ID_PurchaseOrderBill"
- +" Join Location On Location.ID_Location=PurchaseOrderBill.ID_Location"
- +" Where PurchaseOrderBill.ID_Assessor Is Not Null And PurchaseOrderBill.Date_PurchaseOrderBill "+@dateCondition+ " And "+@LocationAll
- +" Group By PurchaseOrderBillProduct.ID_Product"
- +" )g On a.ID_Product=g.ID_Product"
- +" Left Join"
- +" ("
- +" Select PurchaseInDepotBillProduct.ID_Product,Sum(Quantity_PurchaseInDepotBillProduct) As Quantity_PurchaseInDepotBillProduct"
- +" From PurchaseInDepotBillProduct"
- +" Join PurchaseInDepotBill On PurchaseInDepotBill.ID_PurchaseInDepotBill=PurchaseInDepotBillProduct.ID_PurchaseInDepotBill"
- +" Join Location On Location.ID_Location=PurchaseInDepotBill.ID_Location"
- +" Where PurchaseInDepotBill.ID_Assessor Is Not Null And PurchaseInDepotBill.Date_PurchaseInDepotBill "+@dateCondition+ " And "+@LocationAll
- +" Group By PurchaseInDepotBillProduct.ID_Product"
- +" )h On a.ID_Product=h.ID_Product"
- +" Left Join"
- +" ("
- +" Select StocktakingBillProduct.ID_Product,Sum(StocktakingBillProduct.Quantity_StocktakingBillProduct-StocktakingBillProduct.StockQty_StocktakingBillProduct) As InQuantity_StocktakingBillProduct"
- +" From StocktakingBillProduct"
- +" Join StocktakingBill On StocktakingBill.ID_StocktakingBill=StocktakingBillProduct.ID_StocktakingBill"
- +" Join Location On Location.ID_Location=StocktakingBill.ID_Location"
- +" Where StocktakingBill.ID_Assessor Is Not Null And (StocktakingBillProduct.Quantity_StocktakingBillProduct-StocktakingBillProduct.StockQty_StocktakingBillProduct) > 0 And StocktakingBill.Date_StocktakingBill "+@dateCondition+ " And "+@LocationAll
- +" Group By StocktakingBillProduct.ID_Product"
- +" )i On a.ID_Product=i.ID_Product"
- +" Left Join"
- +" ("
- +" Select StocktakingBillProduct.ID_Product,-Sum(StocktakingBillProduct.Quantity_StocktakingBillProduct-StocktakingBillProduct.StockQty_StocktakingBillProduct) As OutQuantity_StocktakingBillProduct"
- +" From StocktakingBillProduct"
- +" Join StocktakingBill On StocktakingBill.ID_StocktakingBill=StocktakingBillProduct.ID_StocktakingBill"
- +" Join Location On Location.ID_Location=StocktakingBill.ID_Location"
- +" Where StocktakingBill.ID_Assessor Is Not Null And (StocktakingBillProduct.Quantity_StocktakingBillProduct-StocktakingBillProduct.StockQty_StocktakingBillProduct) < 0 And StocktakingBill.Date_StocktakingBill "+@dateCondition+ " And "+@LocationAll
- +" Group By StocktakingBillProduct.ID_Product"
- +" )j On a.ID_Product=j.ID_Product"
- +" Left Join"
- +" ("
- +" Select SaleRtnBillProduct.ID_Product,Sum(Quantity_SaleRtnBillProduct) As Quantity_SaleRtnBillProduct"
- +" From SaleRtnBillProduct"
- +" Join SaleRtnBill On SaleRtnBill.ID_SaleRtnBill=SaleRtnBillProduct.ID_SaleRtnBill"
- +" Join Location On Location.ID_Location=SaleRtnBill.ID_Location"
- +" Where SaleRtnBill.ID_Assessor Is Not Null And SaleRtnBill.Date_SaleRtnBill "+@dateCondition+ " And "+@LocationAll
- +" Group By SaleRtnBillProduct.ID_Product"
- +" )k On a.ID_Product=k.ID_Product"
- +" Left Join"
- +" ("
- +" Select SaleOutDepotBillProduct.ID_Product,Sum(SaleOutDepotBillProduct.Quantity_SaleOutDepotBillProduct) As Quantity_SaleOutDepotBillProduct"
- +" From SaleOutDepotBillProduct"
- +" Join SaleOutDepotBill On SaleOutDepotBill.ID_SaleOutDepotBill=SaleOutDepotBillProduct.ID_SaleOutDepotBill"
- +" Join Location On Location.ID_Location=SaleOutDepotBill.ID_Location"
- +" Where SaleOutDepotBill.ID_Assessor Is Not Null And SaleOutDepotBill.Date_SaleOutDepotBill "+@bisNow+ " And "+@LocationAll
- +" Group By SaleOutDepotBillProduct.ID_Product"
- +" )d1 On a.ID_Product=d1.ID_Product"
- +" Left Join"
- +" ("
- +" Select ModifyDepotBillProduct.ID_Product,Sum(Quantity_ModifyDepotBillProduct) As InQuantity_ModifyDepotBillProduct"
- +" From ModifyDepotBillProduct"
- +" Join ModifyDepotBill On ModifyDepotBillProduct.ID_ModifyDepotBill=ModifyDepotBill.ID_ModifyDepotBill"
- +" Join ModifyTypeSettings On ModifyTypeSettings.ID_ModifyTypeSettings=ModifyDepotBill.Style_ModifyDepotBill"
- +" Join Location On Location.ID_Location=ModifyDepotBill.ID_Location"
- +" Where ModifyDepotBill.ID_Assessor Is Not Null And ModifyTypeSettings.Type_ModifyTypeSettings=1 And Date_ModifyDepotBill "+@bisNow+ " And "+@LocationAll
- +" Group By ModifyDepotBillProduct.ID_Product"
- +" )e1 On a.ID_Product=e1.ID_Product"
- +" Left Join"
- +" ("
- +" Select ModifyDepotBillProduct.ID_Product,Sum(Quantity_ModifyDepotBillProduct) As OutQuantity_ModifyDepotBillProduct"
- +" From ModifyDepotBillProduct"
- +" Join ModifyDepotBill On ModifyDepotBillProduct.ID_ModifyDepotBill=ModifyDepotBill.ID_ModifyDepotBill"
- +" Join ModifyTypeSettings On ModifyTypeSettings.ID_ModifyTypeSettings=ModifyDepotBill.Style_ModifyDepotBill"
- +" Join Location On Location.ID_Location=ModifyDepotBill.ID_Location"
- +" Where ModifyDepotBill.ID_Assessor Is Not Null And ModifyTypeSettings.Type_ModifyTypeSettings=0 And Date_ModifyDepotBill "+@bisNow+ " And "+@LocationAll
- +" Group By ModifyDepotBillProduct.ID_Product"
- +" )f1 On a.ID_Product=f1.ID_Product"
- +" Left Join"
- +" ("
- +" Select PurchaseInDepotBillProduct.ID_Product,Sum(Quantity_PurchaseInDepotBillProduct) As Quantity_PurchaseInDepotBillProduct"
- +" From PurchaseInDepotBillProduct"
- +" Join PurchaseInDepotBill On PurchaseInDepotBill.ID_PurchaseInDepotBill=PurchaseInDepotBillProduct.ID_PurchaseInDepotBill"
- +" Join Location On Location.ID_Location=PurchaseInDepotBill.ID_Location"
- +" Where PurchaseInDepotBill.ID_Assessor Is Not Null And PurchaseInDepotBill.Date_PurchaseInDepotBill "+@bisNow+ " And "+@LocationAll
- +" Group By PurchaseInDepotBillProduct.ID_Product"
- +" )h1 On a.ID_Product=h1.ID_Product"
- +" Left Join"
- +" ("
- +" Select SaleBillProduct.ID_Product,Sum(SaleBillProduct.Quantity_SaleBillProduct) As Quantity_SaleBillProduct"
- +" From SaleBillProduct"
- +" Join SaleBill On SaleBill.ID_SaleBill=SaleBillProduct.ID_SaleBill"
- +" Join Location On Location.ID_Location=SaleBill.ID_Location"
- +" Where SaleBill.ID_Assessor Is Not Null And SaleBill.Date_SaleBill "+@bisNow+ " And "+@LocationAll
- +" Group By SaleBillProduct.ID_Product"
- +" )c1 On a.ID_Product=c1.ID_Product";
- @where=true;
- if(cbType1.Text!="")
- {
- if(@where==true)
- {
- @sqlCmd=@sqlCmd+" Where Type_Product >=" +"'"+cbType1.Text+"'";
- @where=false;
- }
- else
- {
- @sqlCmd=@sqlCmd+" And Type_Product >=" +"'"+cbType1.Text+"'";
- }
- }
- if(cbType2.Text!="")
- {
- if(@where==true)
- {
- @sqlCmd=@sqlCmd+" Where Type_Product <="+"'"+cbType2.Text+"'";
- @where=false;
- }
- else
- {
- @sqlCmd=@sqlCmd+" And Type_Product <="+"'"+cbType2.Text+"'";
- }
- }
- if(ckSuspend.Checked)
- {
- if(@where==true)
- {
- @sqlCmd=@sqlCmd+" Where (IsNull(c.Quantity_SaleBillProduct,0)+IsNull(d.Quantity_SaleOutDepotBillProduct,0)+IsNull(f.OutQuantity_ModifyDepotBillProduct,0)+IsNull(g.Quantity_PurchaseOrderBillProduct,0)+IsNull(h.Quantity_PurchaseInDepotBillProduct,0)+IsNull(e.InQuantity_ModifyDepotBillProduct,0)+IsNull(i.InQuantity_StocktakingBillProduct,0)+IsNull(j.OutQuantity_StocktakingBillProduct,0)+IsNull(k.Quantity_SaleRtnBillProduct,0)+IsNull(ind.Quantity_IndentBillProduct,0)) > 0 ";
- @where=false;
- }
- else
- {
- @sqlCmd=@sqlCmd+" And (IsNull(c.Quantity_SaleBillProduct,0)+IsNull(d.Quantity_SaleOutDepotBillProduct,0)+IsNull(f.OutQuantity_ModifyDepotBillProduct,0)+IsNull(g.Quantity_PurchaseOrderBillProduct,0)+IsNull(h.Quantity_PurchaseInDepotBillProduct,0)+IsNull(e.InQuantity_ModifyDepotBillProduct,0)+IsNull(i.InQuantity_StocktakingBillProduct,0)+IsNull(j.OutQuantity_StocktakingBillProduct,0)+IsNull(k.Quantity_SaleRtnBillProduct,0)) > 0 ";
- }
- }
- @sqlCmd=@sqlCmd+" Order By a.No_Product ";
- MessageBox(@sqlCmd,"IS");
- SearchEx(@sqlCmd,"Total");
- txtSum.CValue=SumOfCol("#Total.Quantity_RealSale");
- </btnActionClick> 2008-11-18-->
-
- <!--<btnActionClick>
- @sqlLocation="(";
- @empty=true;
- @first=true;
- for(@i=1;@i < CLB_Location.GetItemsCount();@i++){
- if(CLB_Location.GetItemChecked(@i)){
- @empty=false;
- if(@first==true){
- @sqlLocation=@sqlLocation+"'"+CLB_Location.GetSelectedName(@i)+"'";
- @first=false;
- }else{
- @sqlLocation=@sqlLocation+","+"'"+CLB_Location.GetSelectedName(@i)+"'";
- }
- }
- }
- @sqlLocation=@sqlLocation+") ";
- if(@empty==true)
- {
- MessageBox("请选择仓库!",@Title);
- return;
- }
- @dateCondition=" between "+" DATEADD(day,0,DATEDIFF(day,0,"+"'"+TypeConvert("String",StartDate.Value)+"'"+")) and "+" DATEADD(day,0,(DATEDIFF(day,0,"+"'"+TypeConvert("String",EndDate.Value)+"'"+")+1))";
- @bisNow=" <= DATEADD(day,0,(DATEDIFF(day,0,'"+TypeConvert("String",EndDate.Value)+"')+1))";
- @Location=" Location.Name_Location In " +@sqlLocation;
-
- @sqlCmd=" Select a.No_Product,a.Name_Product,a.Type_Product,a.Cost_Product,(IsNull(b.OpeningStockQty_ProductStocks,0)-IsNull(d1.Quantity_SaleOutDepotBillProduct,0)-IsNull(f1.OutQuantity_ModifyDepotBillProduct,0)+IsNull(h1.Quantity_PurchaseInDepotBillProduct,0)+IsNull(e1.InQuantity_ModifyDepotBillProduct,0)+IsNull(d.Quantity_SaleOutDepotBillProduct,0)+IsNull(f.OutQuantity_ModifyDepotBillProduct,0)-IsNull(h.Quantity_PurchaseInDepotBillProduct,0)-IsNull(e.InQuantity_ModifyDepotBillProduct,0)) As OpeningStockQty_ProductStocks ,(IsNull(b.OpeningStockQty_ProductStocks,0)-IsNull(d1.Quantity_SaleOutDepotBillProduct,0)-IsNull(f1.OutQuantity_ModifyDepotBillProduct,0)+IsNull(h1.Quantity_PurchaseInDepotBillProduct,0)+IsNull(e1.InQuantity_ModifyDepotBillProduct,0)) As StockQty_ProductStocks,a.Cost_Product*(IsNull(b.OpeningStockQty_ProductStocks,0)-IsNull(d1.Quantity_SaleOutDepotBillProduct,0)-IsNull(f1.OutQuantity_ModifyDepotBillProduct,0)+IsNull(h1.Quantity_PurchaseInDepotBillProduct,0)+IsNull(e1.InQuantity_ModifyDepotBillProduct,0)) As TotalPrice, "
- +" (IsNull(pb.OpeningAvailableQty_ProductStocks,0)-IsNull(c1.Quantity_SaleBillProduct,0)-IsNull(f1.OutQuantity_ModifyDepotBillProduct,0)+IsNull(h1.Quantity_PurchaseInDepotBillProduct,0)+IsNull(e1.InQuantity_ModifyDepotBillProduct,0)+IsNull(c.Quantity_SaleBillProduct,0)+IsNull(f.OutQuantity_ModifyDepotBillProduct,0)-IsNull(h.Quantity_PurchaseInDepotBillProduct,0)-IsNull(e.InQuantity_ModifyDepotBillProduct,0)) As OpeningAvailableQty_ProductStocks ,(IsNull(pb.OpeningAvailableQty_ProductStocks,0)-IsNull(c1.Quantity_SaleBillProduct,0)-IsNull(f1.OutQuantity_ModifyDepotBillProduct,0)+IsNull(h1.Quantity_PurchaseInDepotBillProduct,0)+IsNull(e1.InQuantity_ModifyDepotBillProduct,0)) As AvailableQty_ProductStocks,"
- +" IsNull(c.Quantity_SaleBillProduct,0) As Quantity_SaleBillProduct,IsNull(d.Quantity_SaleOutDepotBillProduct,0) As Quantity_SaleOutDepotBillProduct,IsNull(e.InQuantity_ModifyDepotBillProduct,0) As InQuantity_ModifyDepotBillProduct,IsNull(f.OutQuantity_ModifyDepotBillProduct,0) As OutQuantity_ModifyDepotBillProduct,(IsNull(d.Quantity_SaleOutDepotBillProduct,0)-IsNull(k.Quantity_SaleRtnBillProduct,0)) As Quantity_RealSale, "
- +" IsNull(g.Quantity_PurchaseOrderBillProduct,0) As Quantity_PurchaseOrderBillProduct,IsNull(h.Quantity_PurchaseInDepotBillProduct,0) As Quantity_PurchaseInDepotBillProduct,IsNull(i.InQuantity_StocktakingBillProduct,0) As InQuantity_StocktakingBillProduct,IsNull(j.OutQuantity_StocktakingBillProduct,0) As OutQuantity_StocktakingBillProduct,IsNull(k.Quantity_SaleRtnBillProduct,0) As Quantity_SaleRtnBillProduct,IsNull(ind.Quantity_IndentBillProduct,0) As Quantity_IndentBillProduct"
- +" From "
- +" ( "
- +" Select Product.ID_Product,Product.No_Product,Product.Type_Product,Product.Name_Product,Product.Cost_Product"
- +" From Product"
- +" )a"
- +" Join"
- +" ("
- +" Select ProductStocks.ID_Product,Sum(OpeningStockQty_ProductStocks) As OpeningStockQty_ProductStocks"
- +" From ProductStocks"
- +" Where ID_Location IN("
- +" Select ID_Location"
- +" From Location Where ID_Warehouse IN("
- +" Select ID_Location"
- +" From Location"
- +" Where"
- + @Location
- +" ) And Level_Location=1"
- +" )"
- +" Group By ID_Product"
- +" )b On a.ID_Product=b.ID_Product"
-
- +" Join"
- +" ("
- +" Select ProductStocks.ID_Product,Sum(OpeningAvailableQty_ProductStocks) As OpeningAvailableQty_ProductStocks"
- +" From ProductStocks"
- +" Where ID_Location IN("
- +" Select ID_Location"
- +" From Location"
- +" Where"
- + @Location
- +" )"
- +" Group By ID_Product"
- +" )pb On a.ID_Product=pb.ID_Product"
-
- +" Left Join"
- +" ("
- +" Select IndentBillProduct.ID_Product,Sum(IndentBillProduct.Quantity_IndentBillProduct) As Quantity_IndentBillProduct"
- +" From IndentBillProduct"
- +" Join IndentBill On IndentBill.ID_IndentBill=IndentBillProduct.ID_IndentBill"
- +" Join Location On Location.ID_Location=IndentBill.ID_Location"
- +" Where IndentBill.ID_Assessor Is Not Null And IndentBill.Date_IndentBill "+@dateCondition+ " And "+@Location
- +" Group By IndentBillProduct.ID_Product"
- +" )ind On a.ID_Product=ind.ID_Product"
-
- +" Left Join"
- +" ("
- +" Select SaleBillProduct.ID_Product,Sum(SaleBillProduct.Quantity_SaleBillProduct) As Quantity_SaleBillProduct"
- +" From SaleBillProduct"
- +" Join SaleBill On SaleBill.ID_SaleBill=SaleBillProduct.ID_SaleBill"
- +" Join Location On Location.ID_Location=SaleBill.ID_Location"
- +" Where SaleBill.ID_Assessor Is Not Null And SaleBill.Date_SaleBill "+@dateCondition+ " And "+@Location
- +" Group By SaleBillProduct.ID_Product"
- +" )c On a.ID_Product=c.ID_Product"
- +" Left Join"
- +" ("
- +" Select SaleOutDepotBillProduct.ID_Product,Sum(SaleOutDepotBillProduct.Quantity_SaleOutDepotBillProduct) As Quantity_SaleOutDepotBillProduct"
- +" From SaleOutDepotBillProduct"
- +" Join SaleOutDepotBill On SaleOutDepotBill.ID_SaleOutDepotBill=SaleOutDepotBillProduct.ID_SaleOutDepotBill"
- +" Join Location On Location.ID_Location=SaleOutDepotBill.ID_Location"
- +" Where SaleOutDepotBill.ID_Assessor Is Not Null And SaleOutDepotBill.Date_SaleOutDepotBill "+@dateCondition+ " And "+@Location
- +" Group By SaleOutDepotBillProduct.ID_Product"
- +" )d On a.ID_Product=d.ID_Product"
- +" Left Join"
- +" ("
- +" Select ModifyDepotBillProduct.ID_Product,Sum(Quantity_ModifyDepotBillProduct) As InQuantity_ModifyDepotBillProduct"
- +" From ModifyDepotBillProduct"
- +" Join ModifyDepotBill On ModifyDepotBillProduct.ID_ModifyDepotBill=ModifyDepotBill.ID_ModifyDepotBill"
- +" Join ModifyTypeSettings On ModifyTypeSettings.ID_ModifyTypeSettings=ModifyDepotBill.Style_ModifyDepotBill"
- +" Join Location On Location.ID_Location=ModifyDepotBill.ID_Location"
- +" Where ModifyDepotBill.ID_Assessor Is Not Null And ModifyTypeSettings.Type_ModifyTypeSettings=1 And Date_ModifyDepotBill "+@dateCondition+ " And "+@Location
- +" Group By ModifyDepotBillProduct.ID_Product"
- +" )e On a.ID_Product=e.ID_Product"
- +" Left Join"
- +" ("
- +" Select ModifyDepotBillProduct.ID_Product,Sum(Quantity_ModifyDepotBillProduct) As OutQuantity_ModifyDepotBillProduct"
- +" From ModifyDepotBillProduct"
- +" Join ModifyDepotBill On ModifyDepotBillProduct.ID_ModifyDepotBill=ModifyDepotBill.ID_ModifyDepotBill"
- +" Join ModifyTypeSettings On ModifyTypeSettings.ID_ModifyTypeSettings=ModifyDepotBill.Style_ModifyDepotBill"
- +" Join Location On Location.ID_Location=ModifyDepotBill.ID_Location"
- +" Where ModifyDepotBill.ID_Assessor Is Not Null And ModifyTypeSettings.Type_ModifyTypeSettings=0 And Date_ModifyDepotBill "+@dateCondition+ " And "+@Location
- +" Group By ModifyDepotBillProduct.ID_Product"
- +" )f On a.ID_Product=f.ID_Product"
- +" Left Join"
- +" ("
- +" Select PurchaseOrderBillProduct.ID_Product,Sum(Quantity_PurchaseOrderBillProduct) As Quantity_PurchaseOrderBillProduct"
- +" From PurchaseOrderBillProduct"
- +" Join PurchaseOrderBill On PurchaseOrderBill.ID_PurchaseOrderBill=PurchaseOrderBillProduct.ID_PurchaseOrderBill"
- +" Join Location On Location.ID_Location=PurchaseOrderBill.ID_Location"
- +" Where PurchaseOrderBill.ID_Assessor Is Not Null And PurchaseOrderBill.Date_PurchaseOrderBill "+@dateCondition+ " And "+@Location
- +" Group By PurchaseOrderBillProduct.ID_Product"
- +" )g On a.ID_Product=g.ID_Product"
- +" Left Join"
- +" ("
- +" Select PurchaseInDepotBillProduct.ID_Product,Sum(Quantity_PurchaseInDepotBillProduct) As Quantity_PurchaseInDepotBillProduct"
- +" From PurchaseInDepotBillProduct"
- +" Join PurchaseInDepotBill On PurchaseInDepotBill.ID_PurchaseInDepotBill=PurchaseInDepotBillProduct.ID_PurchaseInDepotBill"
- +" Join Location On Location.ID_Location=PurchaseInDepotBill.ID_Location"
- +" Where PurchaseInDepotBill.ID_Assessor Is Not Null And PurchaseInDepotBill.Date_PurchaseInDepotBill "+@dateCondition+ " And "+@Location
- +" Group By PurchaseInDepotBillProduct.ID_Product"
- +" )h On a.ID_Product=h.ID_Product"
- +" Left Join"
- +" ("
- +" Select StocktakingBillProduct.ID_Product,Sum(StocktakingBillProduct.Quantity_StocktakingBillProduct-StocktakingBillProduct.StockQty_StocktakingBillProduct) As InQuantity_StocktakingBillProduct"
- +" From StocktakingBillProduct"
- +" Join StocktakingBill On StocktakingBill.ID_StocktakingBill=StocktakingBillProduct.ID_StocktakingBill"
- +" Join Location On Location.ID_Location=StocktakingBill.ID_Location"
- +" Where StocktakingBill.ID_Assessor Is Not Null And (StocktakingBillProduct.Quantity_StocktakingBillProduct-StocktakingBillProduct.StockQty_StocktakingBillProduct) > 0 And StocktakingBill.Date_StocktakingBill "+@dateCondition+ " And "+@Location
- +" Group By StocktakingBillProduct.ID_Product"
- +" )i On a.ID_Product=i.ID_Product"
- +" Left Join"
- +" ("
- +" Select StocktakingBillProduct.ID_Product,-Sum(StocktakingBillProduct.Quantity_StocktakingBillProduct-StocktakingBillProduct.StockQty_StocktakingBillProduct) As OutQuantity_StocktakingBillProduct"
- +" From StocktakingBillProduct"
- +" Join StocktakingBill On StocktakingBill.ID_StocktakingBill=StocktakingBillProduct.ID_StocktakingBill"
- +" Join Location On Location.ID_Location=StocktakingBill.ID_Location"
- +" Where StocktakingBill.ID_Assessor Is Not Null And (StocktakingBillProduct.Quantity_StocktakingBillProduct-StocktakingBillProduct.StockQty_StocktakingBillProduct) < 0 And StocktakingBill.Date_StocktakingBill "+@dateCondition+ " And "+@Location
- +" Group By StocktakingBillProduct.ID_Product"
- +" )j On a.ID_Product=j.ID_Product"
- +" Left Join"
- +" ("
- +" Select SaleRtnBillProduct.ID_Product,Sum(Quantity_SaleRtnBillProduct) As Quantity_SaleRtnBillProduct"
- +" From SaleRtnBillProduct"
- +" Join SaleRtnBill On SaleRtnBill.ID_SaleRtnBill=SaleRtnBillProduct.ID_SaleRtnBill"
- +" Join Location On Location.ID_Location=SaleRtnBill.ID_Location"
- +" Where SaleRtnBill.ID_Assessor Is Not Null And SaleRtnBill.Date_SaleRtnBill "+@dateCondition+ " And "+@Location
- +" Group By SaleRtnBillProduct.ID_Product"
- +" )k On a.ID_Product=k.ID_Product"
- +" Left Join"
- +" ("
- +" Select SaleOutDepotBillProduct.ID_Product,Sum(SaleOutDepotBillProduct.Quantity_SaleOutDepotBillProduct) As Quantity_SaleOutDepotBillProduct"
- +" From SaleOutDepotBillProduct"
- +" Join SaleOutDepotBill On SaleOutDepotBill.ID_SaleOutDepotBill=SaleOutDepotBillProduct.ID_SaleOutDepotBill"
- +" Join Location On Location.ID_Location=SaleOutDepotBill.ID_Location"
- +" Where SaleOutDepotBill.ID_Assessor Is Not Null And SaleOutDepotBill.Date_SaleOutDepotBill "+@bisNow+ " And "+@Location
- +" Group By SaleOutDepotBillProduct.ID_Product"
- +" )d1 On a.ID_Product=d1.ID_Product"
- +" Left Join"
- +" ("
- +" Select ModifyDepotBillProduct.ID_Product,Sum(Quantity_ModifyDepotBillProduct) As InQuantity_ModifyDepotBillProduct"
- +" From ModifyDepotBillProduct"
- +" Join ModifyDepotBill On ModifyDepotBillProduct.ID_ModifyDepotBill=ModifyDepotBill.ID_ModifyDepotBill"
- +" Join ModifyTypeSettings On ModifyTypeSettings.ID_ModifyTypeSettings=ModifyDepotBill.Style_ModifyDepotBill"
- +" Join Location On Location.ID_Location=ModifyDepotBill.ID_Location"
- +" Where ModifyDepotBill.ID_Assessor Is Not Null And ModifyTypeSettings.Type_ModifyTypeSettings=1 And Date_ModifyDepotBill "+@bisNow+ " And "+@Location
- +" Group By ModifyDepotBillProduct.ID_Product"
- +" )e1 On a.ID_Product=e1.ID_Product"
- +" Left Join"
- +" ("
- +" Select ModifyDepotBillProduct.ID_Product,Sum(Quantity_ModifyDepotBillProduct) As OutQuantity_ModifyDepotBillProduct"
- +" From ModifyDepotBillProduct"
- +" Join ModifyDepotBill On ModifyDepotBillProduct.ID_ModifyDepotBill=ModifyDepotBill.ID_ModifyDepotBill"
- +" Join ModifyTypeSettings On ModifyTypeSettings.ID_ModifyTypeSettings=ModifyDepotBill.Style_ModifyDepotBill"
- +" Join Location On Location.ID_Location=ModifyDepotBill.ID_Location"
- +" Where ModifyDepotBill.ID_Assessor Is Not Null And ModifyTypeSettings.Type_ModifyTypeSettings=0 And Date_ModifyDepotBill "+@bisNow+ " And "+@Location
- +" Group By ModifyDepotBillProduct.ID_Product"
- +" )f1 On a.ID_Product=f1.ID_Product"
- +" Left Join"
- +" ("
- +" Select PurchaseInDepotBillProduct.ID_Product,Sum(Quantity_PurchaseInDepotBillProduct) As Quantity_PurchaseInDepotBillProduct"
- +" From PurchaseInDepotBillProduct"
- +" Join PurchaseInDepotBill On PurchaseInDepotBill.ID_PurchaseInDepotBill=PurchaseInDepotBillProduct.ID_PurchaseInDepotBill"
- +" Join Location On Location.ID_Location=PurchaseInDepotBill.ID_Location"
- +" Where PurchaseInDepotBill.ID_Assessor Is Not Null And PurchaseInDepotBill.Date_PurchaseInDepotBill "+@bisNow+ " And "+@Location
- +" Group By PurchaseInDepotBillProduct.ID_Product"
- +" )h1 On a.ID_Product=h1.ID_Product"
- +" Left Join"
- +" ("
- +" Select SaleBillProduct.ID_Product,Sum(SaleBillProduct.Quantity_SaleBillProduct) As Quantity_SaleBillProduct"
- +" From SaleBillProduct"
- +" Join SaleBill On SaleBill.ID_SaleBill=SaleBillProduct.ID_SaleBill"
- +" Join Location On Location.ID_Location=SaleBill.ID_Location"
- +" Where SaleBill.ID_Assessor Is Not Null And SaleBill.Date_SaleBill "+@bisNow+ " And "+@Location
- +" Group By SaleBillProduct.ID_Product"
- +" )c1 On a.ID_Product=c1.ID_Product";
- @where=true;
- if(cbType1.Text!="")
- {
- if(@where==true)
- {
- @sqlCmd=@sqlCmd+" Where Type_Product >=" +"'"+cbType1.Text+"'";
- @where=false;
- }
- else
- {
- @sqlCmd=@sqlCmd+" And Type_Product >=" +"'"+cbType1.Text+"'";
- }
- }
- if(cbType2.Text!="")
- {
- if(@where==true)
- {
- @sqlCmd=@sqlCmd+" Where Type_Product <="+"'"+cbType2.Text+"'";
- @where=false;
- }
- else
- {
- @sqlCmd=@sqlCmd+" And Type_Product <="+"'"+cbType2.Text+"'";
- }
- }
- if(ckSuspend.Checked)
- {
- if(@where==true)
- {
- @sqlCmd=@sqlCmd+" Where (IsNull(c.Quantity_SaleBillProduct,0)+IsNull(d.Quantity_SaleOutDepotBillProduct,0)+IsNull(f.OutQuantity_ModifyDepotBillProduct,0)+IsNull(g.Quantity_PurchaseOrderBillProduct,0)+IsNull(h.Quantity_PurchaseInDepotBillProduct,0)+IsNull(e.InQuantity_ModifyDepotBillProduct,0)+IsNull(i.InQuantity_StocktakingBillProduct,0)+IsNull(j.OutQuantity_StocktakingBillProduct,0)+IsNull(k.Quantity_SaleRtnBillProduct,0)+IsNull(ind.Quantity_IndentBillProduct,0)) > 0 ";
- @where=false;
- }
- else
- {
- @sqlCmd=@sqlCmd+" And (IsNull(c.Quantity_SaleBillProduct,0)+IsNull(d.Quantity_SaleOutDepotBillProduct,0)+IsNull(f.OutQuantity_ModifyDepotBillProduct,0)+IsNull(g.Quantity_PurchaseOrderBillProduct,0)+IsNull(h.Quantity_PurchaseInDepotBillProduct,0)+IsNull(e.InQuantity_ModifyDepotBillProduct,0)+IsNull(i.InQuantity_StocktakingBillProduct,0)+IsNull(j.OutQuantity_StocktakingBillProduct,0)+IsNull(k.Quantity_SaleRtnBillProduct,0)) > 0 ";
- }
- }
- @sqlCmd=@sqlCmd+" Order By a.No_Product ";
- SearchEx(@sqlCmd,"Total");
- txtSum.CValue=SumOfCol("#Total.Quantity_RealSale");
- </btnActionClick>-->
- </Lables>
- </Form>
- </Forms>
-
|