12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220 |
- <?xml version="1.0" encoding="utf-8" ?>
- <Forms>
- <Form Name="FrmProductSalesStatistics">
- <Client>
- <Events>
- <Load><![CDATA[
- @Title="产品销售统计表";
- GetSchema();
- txtCoNo.CValue=GetCurrentCompanyNo();
- txtCoName.CValue=GetCurrentCompanyShortName();
- Empty();
- NewInstance();
- #Condition.StartDate_SaleBill=GetCurrentTime();
- #Condition.EndDate_SaleBill=GetCurrentTime();
- ]]></Load>
- <Closing>
- ;
- </Closing>
- <Closed>
- ;
- </Closed>
- </Events>
- <Mode>
- <Search>
- <Lable name="Search" />
- </Search>
- </Mode>
- <Controls>
- <IKDateTimePicker name="dtStart" DataSource="Condition.StartDate_SaleBill" >
- <Events>
- <CheckedChanged>
- dtEnd.Checked = dtStart.Checked;
- </CheckedChanged>
- <ValueChanged>
- dtEnd.CValue = dtStart.CValue;
- </ValueChanged>
- </Events>
- </IKDateTimePicker>
- <IKDateTimePicker name="dtEnd" DataSource="Condition.EndDate_SaleBill" />
- <IKTextButton name="tbCustomerNoFrom" DataSource="Condition.CustomerNoFrom">
- <Events>
- <Click>
- @temp = ShowSearchBox("CustomerSearch","INFOMATION",tbCustomerNoFrom.CValue);
- if( @temp == "" )
- return;
- tbCustomerNoFrom.CValue = @temp;
- </Click>
- <TextBoxButtonTextChanged>
- tbCustomerNoTo.CValue = tbCustomerNoFrom.CValue;
- </TextBoxButtonTextChanged>
- </Events>
- </IKTextButton>
- <IKTextButton name="tbCustomerNoTo" DataSource="Condition.CustomerNoTo">
- <Events>
- <Click>
- @temp = ShowSearchBox("CustomerSearch","INFOMATION",tbCustomerNoTo.CValue);
- if( @temp == "" )
- return;
- tbCustomerNoTo.CValue = @temp;
- </Click>
- </Events>
- </IKTextButton>
- <IKTextButton name="tbProductNoFrom" DataSource="Condition.ProductNoFrom">
- <Events>
- <Click>
- @temp = ShowSearchBox("ProductSearch","INFOMATION",tbProductNoFrom.CValue);
- if( @temp == "" )
- return;
- tbProductNoFrom.CValue = @temp;
- </Click>
- <TextBoxButtonTextChanged>
- tbProductNoTo.CValue = tbProductNoFrom.CValue;
- </TextBoxButtonTextChanged>
- </Events>
- </IKTextButton>
- <IKTextButton name="tbProductNoTo" DataSource="Condition.ProductNoTo">
- <Events>
- <Click>
- @temp = ShowSearchBox("ProductSearch","INFOMATION",tbProductNoTo.CValue);
- if( @temp == "" )
- return;
- tbProductNoTo.CValue = @temp;
- </Click>
- </Events>
- </IKTextButton>
- <IKComboBoxEx name="cbLevel_CustomerFrom" DisplaySource="Condition.Level_CustomerFrom" DataSource="CustomerLevel" DisplayMember="Level_Customer" >
- <Events>
- <Reload>
- UpdateForm(false, "cbLevel_CustomerFrom");
- Search("SearchCustomerLevel");
- UpdateForm(true, "cbLevel_CustomerFrom");
- </Reload>
- <TextChanged>
- cbLevel_CustomerTo.Text = cbLevel_CustomerFrom.Text;
- </TextChanged>
- </Events>
- </IKComboBoxEx>
- <IKComboBoxEx name="cbLevel_CustomerTo" DisplaySource="Condition.Level_CustomerTo" DataSource="CustomerLevel" DisplayMember="Level_Customer">
- <Events>
- <Reload>
- UpdateForm(false, "cbLevel_CustomerTo");
- Search("SearchCustomerLevel");
- UpdateForm(true, "cbLevel_CustomerTo");
- </Reload>
- </Events>
- </IKComboBoxEx>
- <IKComboBoxEx name="cbPrincipalFrom" DisplaySource="Condition.StartPrincipal" NoSource="Condition.StartNo_Principal" DataSource="Principal" DisplayMember="Name_Employee" NoMember="No_Employee">
- <Events>
- <Reload>
- UpdateForm(false, "cbPrincipalFrom");
- Search("SearchPrincipal");
- UpdateForm(true, "cbPrincipalFrom");
- </Reload>
- <TextChanged>
- cbPrincipalTo.SelectedName = cbPrincipalFrom.SelectedName;
- cbPrincipalTo.SelectedNo=cbPrincipalFrom.SelectedNo;
- </TextChanged>
- </Events>
- </IKComboBoxEx>
- <IKComboBoxEx name="cbPrincipalTo" DisplaySource="Condition.EndPrincipal" NoSource="Condition.EndNo_Principal" DataSource="Principal" DisplayMember="Name_Employee" NoMember="No_Employee">
- <Events>
- <Reload>
- UpdateForm(false, "cbPrincipalTo");
- Search("SearchPrincipal");
- UpdateForm(true, "cbPrincipalTo");
- </Reload>
- </Events>
- </IKComboBoxEx>
- <IKComboBoxEx name="cbTypeFrom" DisplaySource="Condition.TypeFrom" DataSource="Type" DisplayMember="Type_Product">
- <Events>
- <Reload>
- UpdateForm(false, "cbTypeFrom");
- Search("SearchType");
- UpdateForm(true, "cbTypeFrom");
- </Reload>
- <TextChanged>
- cbTypeTo.Text = cbTypeFrom.Text;
- </TextChanged>
- </Events>
- </IKComboBoxEx>
- <IKComboBoxEx name="cbTypeTo" DisplaySource="Condition.TypeTo" DataSource="Type" DisplayMember="Type_Product">
- <Events>
- <Reload>
- UpdateForm(false, "cbTypeTo");
- Search("SearchType");
- UpdateForm(true, "cbTypeTo");
- </Reload>
- </Events>
- </IKComboBoxEx>
- <IKButton name="btnExcel">
- <Events>
- <Click>
- if(!rbCP.Checked && !rbCPS.Checked && !rbPP.Checked&& !rbPPS.Checked &&!rbPCP.Checked)
- {
- MessageBox("请选择格式!",@Title);
- return;
- }
- UpdateForm(false,"");
- #Condition.Name_Creator = GetCurrentUser();
- #Condition.CreateDate=GetCurrentTime();
- @StartDate_SaleBill=DBNull();
- @EndDate_SaleBill=DBNull();
- @CustomerNoFrom = DBNull();
- @CustomerNoTo = DBNull();
- @ProductNoFrom = DBNull();
- @ProductNoTo = DBNull();
- @Level_CustomerFrom = DBNull();
- @Level_CustomerTo = DBNull();
- @StartNo_Principal = DBNull();
- @EndNo_Principal = DBNull();
- @TypeFrom = DBNull();
- @TypeTo = DBNull();
- if(dtStart.Checked)
- @StartDate_SaleBill=dtStart.Value;
- else
- #Condition.StartDate_SaleBill=DBNull();
- if(dtEnd.Checked)
- @EndDate_SaleBill=dtEnd.Value;
- else
- #Condition.EndDate_SaleBill=DBNull();
- if(tbCustomerNoFrom.CValue != "")
- @CustomerNoFrom = tbCustomerNoFrom.CValue;
- if(tbCustomerNoTo.CValue != "")
- @CustomerNoTo = tbCustomerNoTo.CValue;
- if(cbLevel_CustomerFrom.Text != "")
- @Level_CustomerFrom = cbLevel_CustomerFrom.Text;
- if(cbLevel_CustomerTo.Text != "")
- @Level_CustomerTo = cbLevel_CustomerTo.Text;
- if(cbPrincipalFrom.Text!="")
- {
- if(!cbPrincipalFrom.CheckSelectedItem())
- {
- MessageBox("请选择有效的业务负责人!",@Title);
- cbPrincipalFrom.Focus();
- return;
- }
- else
- {
- @StartNo_Principal = cbPrincipalFrom.SelectedNo;
- }
- }
- if(cbPrincipalTo.Text!="")
- {
- if(!cbPrincipalTo.CheckSelectedItem())
- {
- MessageBox("请选择有效的业务负责人!",@Title);
- cbPrincipalTo.Focus();
- return;
- }
- else
- {
- @EndNo_Principal = cbPrincipalTo.SelectedNo;
- }
- }
- if(tbProductNoFrom.CValue != "")
- @ProductNoFrom = tbProductNoFrom.CValue;
- if(tbProductNoTo.CValue != "")
- @ProductNoTo = tbProductNoTo.CValue;
- if(cbTypeFrom.Text != "")
- @TypeFrom = cbTypeFrom.Text;
- if(cbTypeTo.Text != "")
- @TypeTo = cbTypeTo.Text;
- if(rbCP.Checked)
- {
- Search("SearchSalesByCustomerProduct",@StartDate_SaleBill,@EndDate_SaleBill,@CustomerNoFrom ,@CustomerNoTo ,@ProductNoFrom ,@ProductNoTo ,@Level_CustomerFrom ,@Level_CustomerTo ,@StartNo_Principal ,@EndNo_Principal ,@TypeFrom ,@TypeTo,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight("销货单","特价单","查看"));
- if(RowCount("#FrmProductSalesStatistics") ==0)
- {
- MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
- }
- else
- {
- ExportReport("Excel","ProductSalesStatistics_CustomerProduct","Condition","FrmProductSalesStatistics");
- }
- }
- else if(rbCPS.Checked)
- {
- Search("SearchSalesByCutomerProductType",@StartDate_SaleBill,@EndDate_SaleBill,@CustomerNoFrom ,@CustomerNoTo ,@ProductNoFrom ,@ProductNoTo ,@Level_CustomerFrom ,@Level_CustomerTo ,@StartNo_Principal ,@EndNo_Principal ,@TypeFrom ,@TypeTo,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight("销货单","特价单","查看"));
- if(RowCount("#FrmProductSalesStatisticsCTP") ==0)
- {
- MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
- }
- else
- {
- ExportReport("Excel","ProductSalesStatistics_CutomerProductType","Condition","FrmProductSalesStatisticsCTP");
- }
- }else if(rbPP.Checked)
- {
- Search("SearchSalesByPrincipalProduct",@StartDate_SaleBill,@EndDate_SaleBill,@CustomerNoFrom ,@CustomerNoTo ,@ProductNoFrom ,@ProductNoTo ,@Level_CustomerFrom ,@Level_CustomerTo ,@StartNo_Principal ,@EndNo_Principal ,@TypeFrom ,@TypeTo,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight("销货单","特价单","查看"));
- if(RowCount("#FrmProductSalesStatistics") ==0)
- {
- MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
- }
- else
- {
- ExportReport("Excel","ProductSalesStatistics_PrincipalProduct","Condition","FrmProductSalesStatistics");
- }
- }else if(rbPPS.Checked)
- {
- Search("SearchSalesByPrincipalProductType",@StartDate_SaleBill,@EndDate_SaleBill,@CustomerNoFrom ,@CustomerNoTo ,@ProductNoFrom ,@ProductNoTo ,@Level_CustomerFrom ,@Level_CustomerTo ,@StartNo_Principal ,@EndNo_Principal ,@TypeFrom ,@TypeTo,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight("销货单","特价单","查看"));
- if(RowCount("#FrmProductSalesStatistics") ==0)
- {
- MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
- }
- else
- {
- ExportReport("Excel","ProductSalesStatistics_PrincipalProductType","Condition","FrmProductSalesStatistics");
- }
- }
- else
- {
- Search("SearchSalesByPrincipaCustomerProduct",@StartDate_SaleBill,@EndDate_SaleBill,@CustomerNoFrom ,@CustomerNoTo ,@ProductNoFrom ,@ProductNoTo ,@Level_CustomerFrom ,@Level_CustomerTo ,@StartNo_Principal ,@EndNo_Principal ,@TypeFrom ,@TypeTo,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight("销货单","特价单","查看"));
- if(RowCount("#FrmProductSalesStatisticsPCP") ==0)
- {
- MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
- }
- else
- {
- ExportReport("Excel","ProductSalesStatistics_PrincipaCustomerProduct","Condition","FrmProductSalesStatisticsPCP");
- }
- }
- </Click>
- </Events>
- </IKButton>
- <IKButton name="btnWord">
- <Events>
- <Click>
- if(!rbCP.Checked && !rbCPS.Checked && !rbPP.Checked&& !rbPPS.Checked &&!rbPCP.Checked)
- {
- MessageBox("请选择格式!",@Title);
- return;
- }
- UpdateForm(false,"");
- #Condition.Name_Creator = GetCurrentUser();
- #Condition.CreateDate=GetCurrentTime();
- @StartDate_SaleBill=DBNull();
- @EndDate_SaleBill=DBNull();
- @CustomerNoFrom = DBNull();
- @CustomerNoTo = DBNull();
- @ProductNoFrom = DBNull();
- @ProductNoTo = DBNull();
- @Level_CustomerFrom = DBNull();
- @Level_CustomerTo = DBNull();
- @StartNo_Principal = DBNull();
- @EndNo_Principal = DBNull();
- @TypeFrom = DBNull();
- @TypeTo = DBNull();
- if(dtStart.Checked)
- @StartDate_SaleBill=dtStart.Value;
- else
- #Condition.StartDate_SaleBill=DBNull();
- if(dtEnd.Checked)
- @EndDate_SaleBill=dtEnd.Value;
- else
- #Condition.EndDate_SaleBill=DBNull();
- if(tbCustomerNoFrom.CValue != "")
- @CustomerNoFrom = tbCustomerNoFrom.CValue;
- if(tbCustomerNoTo.CValue != "")
- @CustomerNoTo = tbCustomerNoTo.CValue;
- if(cbLevel_CustomerFrom.Text != "")
- @Level_CustomerFrom = cbLevel_CustomerFrom.Text;
- if(cbLevel_CustomerTo.Text != "")
- @Level_CustomerTo = cbLevel_CustomerTo.Text;
- if(cbPrincipalFrom.Text!="")
- {
- if(!cbPrincipalFrom.CheckSelectedItem())
- {
- MessageBox("请选择有效的业务负责人!",@Title);
- cbPrincipalFrom.Focus();
- return;
- }
- else
- {
- @StartNo_Principal = cbPrincipalFrom.SelectedNo;
- }
- }
- if(cbPrincipalTo.Text!="")
- {
- if(!cbPrincipalTo.CheckSelectedItem())
- {
- MessageBox("请选择有效的业务负责人!",@Title);
- cbPrincipalTo.Focus();
- return;
- }
- else
- {
- @EndNo_Principal = cbPrincipalTo.SelectedNo;
- }
- }
- if(tbProductNoFrom.CValue != "")
- @ProductNoFrom = tbProductNoFrom.CValue;
- if(tbProductNoTo.CValue != "")
- @ProductNoTo = tbProductNoTo.CValue;
- if(cbTypeFrom.Text != "")
- @TypeFrom = cbTypeFrom.Text;
- if(cbTypeTo.Text != "")
- @TypeTo = cbTypeTo.Text;
- if(rbCP.Checked)
- {
- Search("SearchSalesByCustomerProduct",@StartDate_SaleBill,@EndDate_SaleBill,@CustomerNoFrom ,@CustomerNoTo ,@ProductNoFrom ,@ProductNoTo ,@Level_CustomerFrom ,@Level_CustomerTo ,@StartNo_Principal ,@EndNo_Principal ,@TypeFrom ,@TypeTo,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight("销货单","特价单","查看"));
- if(RowCount("#FrmProductSalesStatistics") ==0)
- {
- MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
- }
- else
- {
- ExportReport("Word","ProductSalesStatistics_CustomerProduct","Condition","FrmProductSalesStatistics");
- }
- }
- else if(rbCPS.Checked)
- {
- Search("SearchSalesByCutomerProductType",@StartDate_SaleBill,@EndDate_SaleBill,@CustomerNoFrom ,@CustomerNoTo ,@ProductNoFrom ,@ProductNoTo ,@Level_CustomerFrom ,@Level_CustomerTo ,@StartNo_Principal ,@EndNo_Principal ,@TypeFrom ,@TypeTo,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight("销货单","特价单","查看"));
- if(RowCount("#FrmProductSalesStatisticsCTP") ==0)
- {
- MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
- }
- else
- {
- ExportReport("Word","ProductSalesStatistics_CutomerProductType","Condition","FrmProductSalesStatisticsCTP");
- }
- }else if(rbPP.Checked)
- {
- Search("SearchSalesByPrincipalProduct",@StartDate_SaleBill,@EndDate_SaleBill,@CustomerNoFrom ,@CustomerNoTo ,@ProductNoFrom ,@ProductNoTo ,@Level_CustomerFrom ,@Level_CustomerTo ,@StartNo_Principal ,@EndNo_Principal ,@TypeFrom ,@TypeTo,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight("销货单","特价单","查看"));
- if(RowCount("#FrmProductSalesStatistics") ==0)
- {
- MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
- }
- else
- {
- ExportReport("Word","ProductSalesStatistics_PrincipalProduct","Condition","FrmProductSalesStatistics");
- }
- }else if(rbPPS.Checked)
- {
- Search("SearchSalesByPrincipalProductType",@StartDate_SaleBill,@EndDate_SaleBill,@CustomerNoFrom ,@CustomerNoTo ,@ProductNoFrom ,@ProductNoTo ,@Level_CustomerFrom ,@Level_CustomerTo ,@StartNo_Principal ,@EndNo_Principal ,@TypeFrom ,@TypeTo,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight("销货单","特价单","查看"));
- if(RowCount("#FrmProductSalesStatistics") ==0)
- {
- MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
- }
- else
- {
- ExportReport("Word","ProductSalesStatistics_PrincipalProductType","Condition","FrmProductSalesStatistics");
- }
- }
- else
- {
- Search("SearchSalesByPrincipaCustomerProduct",@StartDate_SaleBill,@EndDate_SaleBill,@CustomerNoFrom ,@CustomerNoTo ,@ProductNoFrom ,@ProductNoTo ,@Level_CustomerFrom ,@Level_CustomerTo ,@StartNo_Principal ,@EndNo_Principal ,@TypeFrom ,@TypeTo,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight("销货单","特价单","查看"));
- if(RowCount("#FrmProductSalesStatisticsPCP") ==0)
- {
- MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
- }
- else
- {
- ExportReport("Word","ProductSalesStatistics_PrincipaCustomerProduct","Condition","FrmProductSalesStatisticsPCP");
- }
- }
- </Click>
- </Events>
- </IKButton>
- <IKButton name="btnPrint">
- <Events>
- <Click>
- if(!rbCP.Checked && !rbCPS.Checked && !rbPP.Checked&& !rbPPS.Checked &&!rbPCP.Checked)
- {
- MessageBox("请选择格式!",@Title);
- return;
- }
- UpdateForm(false,"");
- #Condition.Name_Creator = GetCurrentUser();
- #Condition.CreateDate=GetCurrentTime();
- @StartDate_SaleBill=DBNull();
- @EndDate_SaleBill=DBNull();
- @CustomerNoFrom = DBNull();
- @CustomerNoTo = DBNull();
- @ProductNoFrom = DBNull();
- @ProductNoTo = DBNull();
- @Level_CustomerFrom = DBNull();
- @Level_CustomerTo = DBNull();
- @StartNo_Principal = DBNull();
- @EndNo_Principal = DBNull();
- @TypeFrom = DBNull();
- @TypeTo = DBNull();
- if(dtStart.Checked)
- @StartDate_SaleBill=dtStart.Value;
- else
- #Condition.StartDate_SaleBill=DBNull();
- if(dtEnd.Checked)
- @EndDate_SaleBill=dtEnd.Value;
- else
- #Condition.EndDate_SaleBill=DBNull();
- if(tbCustomerNoFrom.CValue != "")
- @CustomerNoFrom = tbCustomerNoFrom.CValue;
- if(tbCustomerNoTo.CValue != "")
- @CustomerNoTo = tbCustomerNoTo.CValue;
- if(cbLevel_CustomerFrom.Text != "")
- @Level_CustomerFrom = cbLevel_CustomerFrom.Text;
- if(cbLevel_CustomerTo.Text != "")
- @Level_CustomerTo = cbLevel_CustomerTo.Text;
- if(cbPrincipalFrom.Text!="")
- {
- if(!cbPrincipalFrom.CheckSelectedItem())
- {
- MessageBox("请选择有效的业务负责人!",@Title);
- cbPrincipalFrom.Focus();
- return;
- }
- else
- {
- @StartNo_Principal = cbPrincipalFrom.SelectedNo;
- }
- }
- if(cbPrincipalTo.Text!="")
- {
- if(!cbPrincipalTo.CheckSelectedItem())
- {
- MessageBox("请选择有效的业务负责人!",@Title);
- cbPrincipalTo.Focus();
- return;
- }
- else
- {
- @EndNo_Principal = cbPrincipalTo.SelectedNo;
- }
- }
- if(tbProductNoFrom.CValue != "")
- @ProductNoFrom = tbProductNoFrom.CValue;
- if(tbProductNoTo.CValue != "")
- @ProductNoTo = tbProductNoTo.CValue;
- if(cbTypeFrom.Text != "")
- @TypeFrom = cbTypeFrom.Text;
- if(cbTypeTo.Text != "")
- @TypeTo = cbTypeTo.Text;
- if(rbCP.Checked)
- {
- Search("SearchSalesByCustomerProduct",@StartDate_SaleBill,@EndDate_SaleBill,@CustomerNoFrom ,@CustomerNoTo ,@ProductNoFrom ,@ProductNoTo ,@Level_CustomerFrom ,@Level_CustomerTo ,@StartNo_Principal ,@EndNo_Principal ,@TypeFrom ,@TypeTo,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight("销货单","特价单","查看"));
- if(RowCount("#FrmProductSalesStatistics") ==0)
- {
- MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
- }
- else
- {
- ExportReport("PrintToPrinter","ProductSalesStatistics_CustomerProduct","Condition","FrmProductSalesStatistics");
- }
- }
- else if(rbCPS.Checked)
- {
- Search("SearchSalesByCutomerProductType",@StartDate_SaleBill,@EndDate_SaleBill,@CustomerNoFrom ,@CustomerNoTo ,@ProductNoFrom ,@ProductNoTo ,@Level_CustomerFrom ,@Level_CustomerTo ,@StartNo_Principal ,@EndNo_Principal ,@TypeFrom ,@TypeTo,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight("销货单","特价单","查看"));
- if(RowCount("#FrmProductSalesStatisticsCTP") ==0)
- {
- MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
- }
- else
- {
- ExportReport("PrintToPrinter","ProductSalesStatistics_CutomerProductType","Condition","FrmProductSalesStatisticsCTP");
- }
- }else if(rbPP.Checked)
- {
- Search("SearchSalesByPrincipalProduct",@StartDate_SaleBill,@EndDate_SaleBill,@CustomerNoFrom ,@CustomerNoTo ,@ProductNoFrom ,@ProductNoTo ,@Level_CustomerFrom ,@Level_CustomerTo ,@StartNo_Principal ,@EndNo_Principal ,@TypeFrom ,@TypeTo,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight("销货单","特价单","查看"));
- if(RowCount("#FrmProductSalesStatistics") ==0)
- {
- MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
- }
- else
- {
- ExportReport("PrintToPrinter","ProductSalesStatistics_PrincipalProduct","Condition","FrmProductSalesStatistics");
- }
- }else if(rbPPS.Checked)
- {
- Search("SearchSalesByPrincipalProductType",@StartDate_SaleBill,@EndDate_SaleBill,@CustomerNoFrom ,@CustomerNoTo ,@ProductNoFrom ,@ProductNoTo ,@Level_CustomerFrom ,@Level_CustomerTo ,@StartNo_Principal ,@EndNo_Principal ,@TypeFrom ,@TypeTo,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight("销货单","特价单","查看"));
- if(RowCount("#FrmProductSalesStatistics") ==0)
- {
- MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
- }
- else
- {
- ExportReport("PrintToPrinter","ProductSalesStatistics_PrincipalProductType","Condition","FrmProductSalesStatistics");
- }
- }
- else
- {
- Search("SearchSalesByPrincipaCustomerProduct",@StartDate_SaleBill,@EndDate_SaleBill,@CustomerNoFrom ,@CustomerNoTo ,@ProductNoFrom ,@ProductNoTo ,@Level_CustomerFrom ,@Level_CustomerTo ,@StartNo_Principal ,@EndNo_Principal ,@TypeFrom ,@TypeTo,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight("销货单","特价单","查看"));
- if(RowCount("#FrmProductSalesStatisticsPCP") ==0)
- {
- MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
- }
- else
- {
- ExportReport("PrintToPrinter","ProductSalesStatistics_PrincipaCustomerProduct","Condition","FrmProductSalesStatisticsPCP");
- }
- }
- </Click>
- </Events>
- </IKButton>
- <IKButton name="btnView">
- <Events>
- <Click>
- if(!rbCP.Checked && !rbCPS.Checked && !rbPP.Checked&& !rbPPS.Checked &&!rbPCP.Checked)
- {
- MessageBox("请选择格式!",@Title);
- return;
- }
- UpdateForm(false,"");
- #Condition.Name_Creator = GetCurrentUser();
- #Condition.CreateDate=GetCurrentTime();
- @StartDate_SaleBill=DBNull();
- @EndDate_SaleBill=DBNull();
- @CustomerNoFrom = DBNull();
- @CustomerNoTo = DBNull();
- @ProductNoFrom = DBNull();
- @ProductNoTo = DBNull();
- @Level_CustomerFrom = DBNull();
- @Level_CustomerTo = DBNull();
- @StartNo_Principal = DBNull();
- @EndNo_Principal = DBNull();
- @TypeFrom = DBNull();
- @TypeTo = DBNull();
- if(dtStart.Checked)
- @StartDate_SaleBill=dtStart.Value;
- else
- #Condition.StartDate_SaleBill=DBNull();
- if(dtEnd.Checked)
- @EndDate_SaleBill=dtEnd.Value;
- else
- #Condition.EndDate_SaleBill=DBNull();
- if(tbCustomerNoFrom.CValue != "")
- @CustomerNoFrom = tbCustomerNoFrom.CValue;
- if(tbCustomerNoTo.CValue != "")
- @CustomerNoTo = tbCustomerNoTo.CValue;
- if(cbLevel_CustomerFrom.Text != "")
- @Level_CustomerFrom = cbLevel_CustomerFrom.Text;
- if(cbLevel_CustomerTo.Text != "")
- @Level_CustomerTo = cbLevel_CustomerTo.Text;
- if(cbPrincipalFrom.Text!="")
- {
- if(!cbPrincipalFrom.CheckSelectedItem())
- {
- MessageBox("请选择有效的业务负责人!",@Title);
- cbPrincipalFrom.Focus();
- return;
- }
- else
- {
- @StartNo_Principal = cbPrincipalFrom.SelectedNo;
- }
- }
- if(cbPrincipalTo.Text!="")
- {
- if(!cbPrincipalTo.CheckSelectedItem())
- {
- MessageBox("请选择有效的业务负责人!",@Title);
- cbPrincipalTo.Focus();
- return;
- }
- else
- {
- @EndNo_Principal = cbPrincipalTo.SelectedNo;
- }
- }
- if(tbProductNoFrom.CValue != "")
- @ProductNoFrom = tbProductNoFrom.CValue;
- if(tbProductNoTo.CValue != "")
- @ProductNoTo = tbProductNoTo.CValue;
- if(cbTypeFrom.Text != "")
- @TypeFrom = cbTypeFrom.Text;
- if(cbTypeTo.Text != "")
- @TypeTo = cbTypeTo.Text;
- if(rbCP.Checked)
- {
- Search("SearchSalesByCustomerProduct",@StartDate_SaleBill,@EndDate_SaleBill,@CustomerNoFrom ,@CustomerNoTo ,@ProductNoFrom ,@ProductNoTo ,@Level_CustomerFrom ,@Level_CustomerTo ,@StartNo_Principal ,@EndNo_Principal ,@TypeFrom ,@TypeTo,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight("销货单","特价单","查看"));
- if(RowCount("#FrmProductSalesStatistics") ==0)
- {
- MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
- }
- else
- {
- PrintReport("ProductSalesStatistics_CustomerProduct","Condition","FrmProductSalesStatistics");
- }
- }
- else if(rbCPS.Checked)
- {
- Search("SearchSalesByCutomerProductType",@StartDate_SaleBill,@EndDate_SaleBill,@CustomerNoFrom ,@CustomerNoTo ,@ProductNoFrom ,@ProductNoTo ,@Level_CustomerFrom ,@Level_CustomerTo ,@StartNo_Principal ,@EndNo_Principal ,@TypeFrom ,@TypeTo,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight("销货单","特价单","查看"));
- if(RowCount("#FrmProductSalesStatisticsCTP") ==0)
- {
- MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
- }
- else
- {
- PrintReport("ProductSalesStatistics_CutomerProductType","Condition","FrmProductSalesStatisticsCTP");
- }
- }else if(rbPP.Checked)
- {
- Search("SearchSalesByPrincipalProduct",@StartDate_SaleBill,@EndDate_SaleBill,@CustomerNoFrom ,@CustomerNoTo ,@ProductNoFrom ,@ProductNoTo ,@Level_CustomerFrom ,@Level_CustomerTo ,@StartNo_Principal ,@EndNo_Principal ,@TypeFrom ,@TypeTo,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight("销货单","特价单","查看"));
- if(RowCount("#FrmProductSalesStatistics") ==0)
- {
- MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
- }
- else
- {
- PrintReport("ProductSalesStatistics_PrincipalProduct","Condition","FrmProductSalesStatistics");
- }
- }else if(rbPPS.Checked)
- {
- Search("SearchSalesByPrincipalProductType",@StartDate_SaleBill,@EndDate_SaleBill,@CustomerNoFrom ,@CustomerNoTo ,@ProductNoFrom ,@ProductNoTo ,@Level_CustomerFrom ,@Level_CustomerTo ,@StartNo_Principal ,@EndNo_Principal ,@TypeFrom ,@TypeTo,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight("销货单","特价单","查看"));
- if(RowCount("#FrmProductSalesStatistics") ==0)
- {
- MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
- }
- else
- {
- PrintReport("ProductSalesStatistics_PrincipalProductType","Condition","FrmProductSalesStatistics");
- }
- }
- else
- {
- Search("SearchSalesByPrincipaCustomerProduct",@StartDate_SaleBill,@EndDate_SaleBill,@CustomerNoFrom ,@CustomerNoTo ,@ProductNoFrom ,@ProductNoTo ,@Level_CustomerFrom ,@Level_CustomerTo ,@StartNo_Principal ,@EndNo_Principal ,@TypeFrom ,@TypeTo,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight("销货单","特价单","查看"));
- if(RowCount("#FrmProductSalesStatisticsPCP") ==0)
- {
- MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
- }
- else
- {
- PrintReport("ProductSalesStatistics_PrincipaCustomerProduct","Condition","FrmProductSalesStatisticsPCP");
- }
- }
- </Click>
- </Events>
- </IKButton>
- </Controls>
- <ChildForms>
- <ChildForm name="CustomerSearch" DataSource="Customer" SearchFunction="SearchAllCustomer" SearchFunctionCondition="SearchCustomerCondition" SearchFunctionByNo=""
- MappingName="客户">
- <DataColumn Index="0" MappingName="#Customer.No_Customer" HeaderText="客户编号" Width="90" ColumnType="IKDataGridTextBoxColumn" />
- <DataColumn Index="1" MappingName="#Customer.ShortName_Customer" HeaderText="客户简称" Width="90" ColumnType="IKDataGridTextBoxColumn" />
- <DataColumn Index="2" MappingName="#Customer.Type_Customer" HeaderText="客户类型" Width="75" ColumnType="IKDataGridTextBoxColumn" />
- <DataColumn Index="3" MappingName="#Customer.Level_Customer" HeaderText="客户等级" Width="75" ColumnType="IKDataGridTextBoxColumn" />
- <DataColumn Index="4" MappingName="#Customer.IsGeneric_Customer" HeaderText="一般客户" Width="75" ColumnType="IKDataGridBoolColumn" />
- </ChildForm>
- <ChildForm name="ProductSearch" DataSource="Product" SearchFunction="SearchAllProduct" SearchFunctionByNo=""
- MappingName="产品">
- <DataColumn Index="0" MappingName="#Product.No_Product" HeaderText="产品编号" Width="120" ColumnType="IKDataGridTextBoxColumn" />
- <DataColumn Index="1" MappingName="#Product.Name_Product" HeaderText="产品简称" Width="120" ColumnType="IKDataGridTextBoxColumn" />
- </ChildForm>
- </ChildForms>
- <FormatString>
- <Format name="SearchCustomerCondition">
- if(GetRight("客户基本资料","全权查看"))
- {
- FormatString("");
- }
- else
- {
- FormatString(" Customer.ID_Creator='{0}' ",GetLoginUserID());
- }
- </Format>
- </FormatString>
- </Client>
- <Server>
- <Tables>
- <Table name="Condition" Type="Parent">
- <GetSchema CmdType="Text" CmdText=" SELECT TOP 0 convert(datetime,0) As StartDate_SaleBill,convert(datetime,0) As EndDate_SaleBill,
- convert(nvarchar(64),'') as CustomerNoFrom,convert(nvarchar(64),'') as CustomerNoTo,
- convert(nvarchar(64),'') as ProductNoFrom,convert(nvarchar(64),'') as ProductNoTo,
- convert(nvarchar(64),'') as Level_CustomerFrom,convert(nvarchar(64),'') as Level_CustomerTo,
- convert(nvarchar(64),'') As StartPrincipal,convert(nvarchar(64),'') As EndPrincipal,
- convert(nvarchar(64),'') As StartNo_Principal,convert(nvarchar(64),'') As EndNo_Principal,convert(nvarchar(64),'') As No_Principal,
- convert(nvarchar(64),'') As TypeFrom,convert(nvarchar(64),'') As TypeTo,
- convert(nvarchar(64),'') as Name_Creator,convert(datetime,0) As CreateDate
- " />
- </Table>
- </Tables>
- <Search>
- <SearchCustomerLevel CmdType="Text" CmdText="SELECT Name_TypeDef as Level_Customer FROM TypeDef WHERE Type_TypeDef = 16 ORDER BY Name_TypeDef">
- <Tables>
- <Table name="CustomerLevel" />
- </Tables>
- </SearchCustomerLevel>
- <SearchPrincipal CmdType="Text" CmdText="
- Select No_Employee,Name_Employee
- From Employee
- Order By No_Employee
- ">
- <Tables>
- <Table name="Principal" />
- </Tables>
- </SearchPrincipal>
- <SearchType CmdType="Text" CmdText="SELECT Name_TypeDef as Type_Product FROM TypeDef WHERE (Type_TypeDef = 8) ORDER BY Name_TypeDef">
- <Tables>
- <Table name="Type" />
- </Tables>
- </SearchType>
- <SearchAllCustomer CmdType="Text" CmdText="SELECT Customer.No_Customer,Customer.ShortName_Customer,Customer.Type_Customer,Customer.Level_Customer,Customer.IsGeneric_Customer FROM Customer ">
- <Tables>
- <Table name="AllCustomer" />
- </Tables>
- </SearchAllCustomer>
- <SearchAllProduct CmdType="Text" CmdText="SELECT Product.No_Product,Product.Name_Product FROM Product ">
- <Tables>
- <Table name="AllProduct" />
- </Tables>
- </SearchAllProduct>
- <SearchSalesByCustomerProduct CmdType="Text" CmdText="declare @cessIn decimal(14,4)
- Select @cessIn=CessIn_SystemSetting From SystemSetting
- declare @sqlCmd nvarchar(4000)
- SELECT A.No_Customer,A.ShortName_Customer, A.No_Product, A.Name_Product,
- ISNULL(SUM(A.GoodsSaleBillAmount),0) AS GoodsSaleBillAmount,ISNULL(SUM(A.GoodsSaleRtnBillAmount),0) AS GoodsSaleRtnBillAmount,
- (ISNULL(SUM(A.GoodsSaleBillAmount),0)-ISNULL(SUM(A.GoodsSaleRtnBillAmount),0)) AS RealSallAmount,
- ISNULL(SUM(A.Quantity_SaleBillProduct),0) AS Quantity_SaleBillProduct,
- ISNULL(SUM(A.Quantity_SaleRtnBillProduct),0) AS Quantity_SaleRtnBillProduct,
- (ISNULL(SUM(A.Quantity_SaleBillProduct),0)-ISNULL(SUM(A.Quantity_SaleRtnBillProduct),0)) as RealSallQuantity
- FROM
- (
- (
- SELECT Customer.No_Customer,Customer.ShortName_Customer,Product.No_Product,Product.Name_Product,
- GoodsSaleBillAmount = case SaleBill.TaxCurrency_SaleBill
- When '外加' Then (Quantity_SaleBillProduct*UnitPrice_SaleBillProduct)*(1+@cessIn/100)
- else (Quantity_SaleBillProduct*UnitPrice_SaleBillProduct) end,
- CONVERT(DECIMAL,0.00) as GoodsSaleRtnBillAmount,SaleBillProduct.Quantity_SaleBillProduct as Quantity_SaleBillProduct,CONVERT(DECIMAL,0.00) as Quantity_SaleRtnBillProduct
- FROM SaleBill
- LEFT JOIN SaleBillProduct ON SaleBill.ID_SaleBill=SaleBillProduct.ID_SaleBill
- LEFT JOIN Product ON Product.ID_Product = SaleBillProduct.ID_Product
- LEFT JOIN Customer ON Customer.ID_Customer = SaleBill.ID_Customer
- LEFT JOIN Employee ON Employee.ID_Employee = SaleBill.ID_Principal
- Where SaleBill.ID_Assessor IS Not Null
- AND SaleBill.Date_SaleBill Between isnull(DateAdd(day,DateDiff(day,0,@StartDate_SaleBill),0),SaleBill.Date_SaleBill) AND Isnull(DateAdd(day,DateDiff(day,0,@EndDate_SaleBill),1),SaleBill.Date_SaleBill)
- AND No_Customer BETWEEN ISNULL(@CustomerNoFrom,No_Customer) AND ISNULL(@CustomerNoTo,No_Customer)
- AND No_Product BETWEEN ISNULL(@ProductNoFrom,No_Product) AND ISNULL(@ProductNoTo,No_Product)
- AND Level_Customer BETWEEN ISNULL(@Level_CustomerFrom,Level_Customer) AND ISNULL(@Level_CustomerTo,Level_Customer)
- AND Employee.No_Employee BETWEEN ISNULL(@StartNo_Principal,No_Employee) AND ISNULL(@EndNo_Principal,No_Employee)
- AND Type_Product BETWEEN ISNULL(@TypeFrom,Type_Product) AND ISNULL(@TypeTo,Type_Product)
- AND Customer.ID_Creator = isnull(@Right,Customer.ID_Creator)
- and Special_SaleBill=case @Special when 1 then Special_SaleBill else 0 End
- )
- union all
- (
- SELECT Customer.No_Customer,Customer.ShortName_Customer,Product.No_Product,Product.Name_Product,
- CONVERT(DECIMAL,0.00) as GoodsSaleBillAmount,
- GoodsSaleRtnBillAmount =case SaleRtnBill.TaxCurrency_SaleRtnBill
- When '外加' Then (Quantity_SaleRtnBillProduct*UnitPrice_SaleRtnBillProduct)*(1+@cessIn/100)
- else (Quantity_SaleRtnBillProduct*UnitPrice_SaleRtnBillProduct) end
- ,CONVERT(DECIMAL,0.00) as Quantity_SaleBillProduct,SaleRtnBillProduct.Quantity_SaleRtnBillProduct as Quantity_SaleRtnBillProduct
- FROM SaleRtnBill
- LEFT JOIN SaleRtnBillProduct ON SaleRtnBill.ID_SaleRtnBill = SaleRtnBillProduct.ID_SaleRtnBill
- LEFT JOIN Product ON Product.ID_Product = SaleRtnBillProduct.ID_Product
- LEFT JOIN Customer ON Customer.ID_Customer = SaleRtnBill.ID_Customer
- LEFT JOIN Employee ON Employee.ID_Employee = SaleRtnBill.ID_Principal
- WHERE SaleRtnBill.ID_Assessor IS NOT NULL
- AND SaleRtnBill.Date_SaleRtnBill Between isnull(DateAdd(day,DateDiff(day,0,@StartDate_SaleBill),0),SaleRtnBill.Date_SaleRtnBill) AND Isnull(DateAdd(day,DateDiff(day,0,@EndDate_SaleBill),1),SaleRtnBill.Date_SaleRtnBill)
- AND No_Customer BETWEEN ISNULL(@CustomerNoFrom,No_Customer) AND ISNULL(@CustomerNoTo,No_Customer)
- AND No_Product BETWEEN ISNULL(@ProductNoFrom,No_Product) AND ISNULL(@ProductNoTo,No_Product)
- AND Level_Customer BETWEEN ISNULL(@Level_CustomerFrom,Level_Customer) AND ISNULL(@Level_CustomerTo,Level_Customer)
- AND Employee.No_Employee BETWEEN ISNULL(@StartNo_Principal,No_Employee) AND ISNULL(@EndNo_Principal,No_Employee)
- AND Type_Product BETWEEN ISNULL(@TypeFrom,Type_Product) AND ISNULL(@TypeTo,Type_Product)
- AND Customer.ID_Creator = isnull(@Right,Customer.ID_Creator)
- )
- )A
- GROUP BY A.No_Customer,A.ShortName_Customer,A.No_Product,A.Name_Product
- ORDER BY No_Customer
- ">
-
- <Params>
- <Param name="@StartDate_SaleBill" type="SaleBill.Date_SaleBill" Index="0" />
- <Param name="@EndDate_SaleBill" type="SaleBill.Date_SaleBill" Index="1" />
- <Param name="@CustomerNoFrom" type="SaleBill.No_SaleBill" Index="2" />
- <Param name="@CustomerNoTo" type="SaleBill.No_SaleBill" Index="3" />
- <Param name="@ProductNoFrom" type="Customer.No_Customer" Index="4" />
- <Param name="@ProductNoTo" type="Customer.No_Customer" Index="5" />
- <Param name="@Level_CustomerFrom" type="SaleBill.No_SaleBill" Index="6" />
- <Param name="@Level_CustomerTo" type="SaleBill.No_SaleBill" Index="7" />
- <Param name="@StartNo_Principal" type="Location.Name_Location" Index="8" />
- <Param name="@EndNo_Principal" type="Location.Name_Location" Index="9" />
- <Param name="@TypeFrom" type="Location.Name_Location" Index="10" />
- <Param name="@TypeTo" type="Location.Name_Location" Index="11" />
- <Param name="@Right" type="SaleBill.ID_Customer" Index="12" />
- <Param name="@Special" type="SaleBill.Special_SaleBill" Index="13" />
- </Params>
- <Tables>
- <Table name="FrmProductSalesStatistics"/>
- </Tables>
- </SearchSalesByCustomerProduct>
- <SearchSalesByPrincipalProduct CmdType="Text" CmdText="declare @cessIn decimal(14,4)
- Select @cessIn=CessIn_SystemSetting From SystemSetting
- declare @sqlCmd nvarchar(4000)
- SELECT A.Principal_SaleBill,A.NoProduct,A.NameProduct,
- ISNULL(SUM(A.GoodsSaleBillAmount),0) AS GoodsSaleBillAmount,ISNULL(SUM(A.GoodsSaleRtnBillAmount),0) AS GoodsSaleRtnBillAmount,
- (ISNULL(SUM(A.GoodsSaleBillAmount),0)-ISNULL(SUM(A.GoodsSaleRtnBillAmount),0)) AS RealSallAmount,
- ISNULL(SUM(A.Quantity_SaleBillProduct),0) AS Quantity_SaleBillProduct,
- ISNULL(SUM(A.Quantity_SaleRtnBillProduct),0) AS Quantity_SaleRtnBillProduct,
- (ISNULL(SUM(A.Quantity_SaleBillProduct),0)-ISNULL(SUM(A.Quantity_SaleRtnBillProduct),0)) as RealSallQuantity
- FROM
- (
- (
- SELECT Employee.Name_Employee as Principal_SaleBill,Product.No_Product as NoProduct,Product.Name_Product as NameProduct,
- GoodsSaleBillAmount = case SaleBill.TaxCurrency_SaleBill
- When '外加' Then (Quantity_SaleBillProduct*UnitPrice_SaleBillProduct)*(1+@cessIn/100)
- else (Quantity_SaleBillProduct*UnitPrice_SaleBillProduct) end,
- CONVERT(DECIMAL,0.00) as GoodsSaleRtnBillAmount,SaleBillProduct.Quantity_SaleBillProduct as Quantity_SaleBillProduct,CONVERT(DECIMAL,0.00) as Quantity_SaleRtnBillProduct
- FROM SaleBill
- LEFT JOIN SaleBillProduct ON SaleBill.ID_SaleBill=SaleBillProduct.ID_SaleBill
- LEFT JOIN Product ON Product.ID_Product = SaleBillProduct.ID_Product
- LEFT JOIN Customer ON Customer.ID_Customer = SaleBill.ID_Customer
- LEFT JOIN Employee ON Employee.ID_Employee = SaleBill.ID_Principal
- Where SaleBill.ID_Assessor IS Not Null
- AND SaleBill.Date_SaleBill Between isnull(DateAdd(day,DateDiff(day,0,@StartDate_SaleBill),0),SaleBill.Date_SaleBill) AND Isnull(DateAdd(day,DateDiff(day,0,@EndDate_SaleBill),1),SaleBill.Date_SaleBill)
- AND No_Customer BETWEEN ISNULL(@CustomerNoFrom,No_Customer) AND ISNULL(@CustomerNoTo,No_Customer)
- AND No_Product BETWEEN ISNULL(@ProductNoFrom,No_Product) AND ISNULL(@ProductNoTo,No_Product)
- AND Level_Customer BETWEEN ISNULL(@Level_CustomerFrom,Level_Customer) AND ISNULL(@Level_CustomerTo,Level_Customer)
- AND Employee.No_Employee BETWEEN ISNULL(@StartNo_Principal,No_Employee) AND ISNULL(@EndNo_Principal,No_Employee)
- AND Type_Product BETWEEN ISNULL(@TypeFrom,Type_Product) AND ISNULL(@TypeTo,Type_Product)
- AND Customer.ID_Creator = isnull(@Right,Customer.ID_Creator)
- and Special_SaleBill=case @Special when 1 then Special_SaleBill else 0 End
- )
- union all
- (
- SELECT Employee.Name_Employee as Principal_SaleBill ,Product.No_Product as NoProduct,Product.Name_Product as NameProduct,
- CONVERT(DECIMAL,0.00) as GoodsSaleBillAmount,
- GoodsSaleRtnBillAmount =case SaleRtnBill.TaxCurrency_SaleRtnBill
- When '外加' Then (Quantity_SaleRtnBillProduct*UnitPrice_SaleRtnBillProduct)*(1+@cessIn/100)
- else (Quantity_SaleRtnBillProduct*UnitPrice_SaleRtnBillProduct) end
- ,CONVERT(DECIMAL,0.00) as Quantity_SaleBillProduct,SaleRtnBillProduct.Quantity_SaleRtnBillProduct as Quantity_SaleRtnBillProduct
- FROM SaleRtnBill
- LEFT JOIN SaleRtnBillProduct ON SaleRtnBill.ID_SaleRtnBill = SaleRtnBillProduct.ID_SaleRtnBill
- LEFT JOIN Product ON Product.ID_Product = SaleRtnBillProduct.ID_Product
- LEFT JOIN Customer ON Customer.ID_Customer = SaleRtnBill.ID_Customer
- LEFT JOIN Employee ON Employee.ID_Employee = SaleRtnBill.ID_Principal
- WHERE SaleRtnBill.ID_Assessor IS NOT NULL
- AND SaleRtnBill.Date_SaleRtnBill Between isnull(DateAdd(day,DateDiff(day,0,@StartDate_SaleBill),0),SaleRtnBill.Date_SaleRtnBill) AND Isnull(DateAdd(day,DateDiff(day,0,@EndDate_SaleBill),1),SaleRtnBill.Date_SaleRtnBill)
- AND No_Customer BETWEEN ISNULL(@CustomerNoFrom,No_Customer) AND ISNULL(@CustomerNoTo,No_Customer)
- AND No_Product BETWEEN ISNULL(@ProductNoFrom,No_Product) AND ISNULL(@ProductNoTo,No_Product)
- AND Level_Customer BETWEEN ISNULL(@Level_CustomerFrom,Level_Customer) AND ISNULL(@Level_CustomerTo,Level_Customer)
- AND Employee.No_Employee BETWEEN ISNULL(@StartNo_Principal,No_Employee) AND ISNULL(@EndNo_Principal,No_Employee)
- AND Type_Product BETWEEN ISNULL(@TypeFrom,Type_Product) AND ISNULL(@TypeTo,Type_Product)
- AND Customer.ID_Creator = isnull(@Right,Customer.ID_Creator)
- )
- )A
- GROUP BY A.Principal_SaleBill,A.NoProduct,A.NameProduct
- ORDER BY A.Principal_SaleBill
- ">
-
- <Params>
- <Param name="@StartDate_SaleBill" type="SaleBill.Date_SaleBill" Index="0" />
- <Param name="@EndDate_SaleBill" type="SaleBill.Date_SaleBill" Index="1" />
- <Param name="@CustomerNoFrom" type="SaleBill.No_SaleBill" Index="2" />
- <Param name="@CustomerNoTo" type="SaleBill.No_SaleBill" Index="3" />
- <Param name="@ProductNoFrom" type="Customer.No_Customer" Index="4" />
- <Param name="@ProductNoTo" type="Customer.No_Customer" Index="5" />
- <Param name="@Level_CustomerFrom" type="SaleBill.No_SaleBill" Index="6" />
- <Param name="@Level_CustomerTo" type="SaleBill.No_SaleBill" Index="7" />
- <Param name="@StartNo_Principal" type="Location.Name_Location" Index="8" />
- <Param name="@EndNo_Principal" type="Location.Name_Location" Index="9" />
- <Param name="@TypeFrom" type="Location.Name_Location" Index="10" />
- <Param name="@TypeTo" type="Location.Name_Location" Index="11" />
- <Param name="@Right" type="SaleBill.ID_Customer" Index="12" />
- <Param name="@Special" type="SaleBill.Special_SaleBill" Index="13" />
- </Params>
- <Tables>
- <Table name="FrmProductSalesStatistics"/>
- </Tables>
- </SearchSalesByPrincipalProduct>
- <SearchSalesByPrincipalProductType CmdType="Text" CmdText="
- declare @cessIn decimal(14,4)
- Select @cessIn=CessIn_SystemSetting From SystemSetting
- declare @sqlCmd nvarchar(4000)
- SELECT A.Principal_SaleBill,A.Type_Product,
- ISNULL(SUM(A.GoodsSaleBillAmount),0) AS GoodsSaleBillAmount,ISNULL(SUM(A.GoodsSaleRtnBillAmount),0) AS GoodsSaleRtnBillAmount,
- (ISNULL(SUM(A.GoodsSaleBillAmount),0)-ISNULL(SUM(A.GoodsSaleRtnBillAmount),0)) AS RealSallAmount,
- ISNULL(SUM(A.Quantity_SaleBillProduct),0) AS Quantity_SaleBillProduct,
- ISNULL(SUM(A.Quantity_SaleRtnBillProduct),0) AS Quantity_SaleRtnBillProduct,
- (ISNULL(SUM(A.Quantity_SaleBillProduct),0)-ISNULL(SUM(A.Quantity_SaleRtnBillProduct),0)) as RealSallQuantity
- FROM
- (
- (
- SELECT Employee.Name_Employee as Principal_SaleBill,Product.Type_Product,SaleBill.TaxCurrency_SaleBill as TaxCurrency,
- GoodsSaleBillAmount = case SaleBill.TaxCurrency_SaleBill
- When '外加' Then (Quantity_SaleBillProduct*UnitPrice_SaleBillProduct)*(1+@cessIn/100)
- else (Quantity_SaleBillProduct*UnitPrice_SaleBillProduct) end,
- CONVERT(DECIMAL,0.00) as GoodsSaleRtnBillAmount,SaleBillProduct.Quantity_SaleBillProduct as Quantity_SaleBillProduct,CONVERT(DECIMAL,0.00) as Quantity_SaleRtnBillProduct
- FROM SaleBill
- LEFT JOIN SaleBillProduct ON SaleBill.ID_SaleBill=SaleBillProduct.ID_SaleBill
- LEFT JOIN Product ON Product.ID_Product = SaleBillProduct.ID_Product
- LEFT JOIN Customer ON Customer.ID_Customer = SaleBill.ID_Customer
- LEFT JOIN Employee ON Employee.ID_Employee = SaleBill.ID_Principal
- Where SaleBill.ID_Assessor IS Not Null
- AND SaleBill.Date_SaleBill Between isnull(DateAdd(day,DateDiff(day,0,@StartDate_SaleBill),0),SaleBill.Date_SaleBill) AND Isnull(DateAdd(day,DateDiff(day,0,@EndDate_SaleBill),1),SaleBill.Date_SaleBill)
- AND No_Customer BETWEEN ISNULL(@CustomerNoFrom,No_Customer) AND ISNULL(@CustomerNoTo,No_Customer)
- AND No_Product BETWEEN ISNULL(@ProductNoFrom,No_Product) AND ISNULL(@ProductNoTo,No_Product)
- AND Level_Customer BETWEEN ISNULL(@Level_CustomerFrom,Level_Customer) AND ISNULL(@Level_CustomerTo,Level_Customer)
- AND Employee.No_Employee BETWEEN ISNULL(@StartNo_Principal,No_Employee) AND ISNULL(@EndNo_Principal,No_Employee)
- AND Type_Product BETWEEN ISNULL(@TypeFrom,Type_Product) AND ISNULL(@TypeTo,Type_Product)
- AND Customer.ID_Creator = isnull(@Right,Customer.ID_Creator)
- and Special_SaleBill=case @Special when 1 then Special_SaleBill else 0 End
- )
- union all
- (
- SELECT Employee.Name_Employee as Principal_SaleBill ,Product.Type_Product,SaleRtnBill.TaxCurrency_SaleRtnBill as TaxCurrency,
- CONVERT(DECIMAL,0.00) as GoodsSaleBillAmount,
- GoodsSaleRtnBillAmount =case SaleRtnBill.TaxCurrency_SaleRtnBill
- When '外加' Then (Quantity_SaleRtnBillProduct*UnitPrice_SaleRtnBillProduct)*(1+@cessIn/100)
- else (Quantity_SaleRtnBillProduct*UnitPrice_SaleRtnBillProduct) end
- ,CONVERT(DECIMAL,0.00) as Quantity_SaleBillProduct,SaleRtnBillProduct.Quantity_SaleRtnBillProduct as Quantity_SaleRtnBillProduct
- FROM SaleRtnBill
- LEFT JOIN SaleRtnBillProduct ON SaleRtnBill.ID_SaleRtnBill = SaleRtnBillProduct.ID_SaleRtnBill
- LEFT JOIN Product ON Product.ID_Product = SaleRtnBillProduct.ID_Product
- LEFT JOIN Customer ON Customer.ID_Customer = SaleRtnBill.ID_Customer
- LEFT JOIN Employee ON Employee.ID_Employee = SaleRtnBill.ID_Principal
- WHERE SaleRtnBill.ID_Assessor IS NOT NULL
- AND SaleRtnBill.Date_SaleRtnBill Between isnull(DateAdd(day,DateDiff(day,0,@StartDate_SaleBill),0),SaleRtnBill.Date_SaleRtnBill) AND Isnull(DateAdd(day,DateDiff(day,0,@EndDate_SaleBill),1),SaleRtnBill.Date_SaleRtnBill)
- AND No_Customer BETWEEN ISNULL(@CustomerNoFrom,No_Customer) AND ISNULL(@CustomerNoTo,No_Customer)
- AND No_Product BETWEEN ISNULL(@ProductNoFrom,No_Product) AND ISNULL(@ProductNoTo,No_Product)
- AND Level_Customer BETWEEN ISNULL(@Level_CustomerFrom,Level_Customer) AND ISNULL(@Level_CustomerTo,Level_Customer)
- AND Employee.No_Employee BETWEEN ISNULL(@StartNo_Principal,No_Employee) AND ISNULL(@EndNo_Principal,No_Employee)
- AND Type_Product BETWEEN ISNULL(@TypeFrom,Type_Product) AND ISNULL(@TypeTo,Type_Product)
- AND Customer.ID_Creator = isnull(@Right,Customer.ID_Creator)
- )
- )A
- GROUP BY A.Principal_SaleBill,A.Type_Product
- ORDER BY A.Principal_SaleBill
- ">
-
- <Params>
- <Param name="@StartDate_SaleBill" type="SaleBill.Date_SaleBill" Index="0" />
- <Param name="@EndDate_SaleBill" type="SaleBill.Date_SaleBill" Index="1" />
- <Param name="@CustomerNoFrom" type="SaleBill.No_SaleBill" Index="2" />
- <Param name="@CustomerNoTo" type="SaleBill.No_SaleBill" Index="3" />
- <Param name="@ProductNoFrom" type="Customer.No_Customer" Index="4" />
- <Param name="@ProductNoTo" type="Customer.No_Customer" Index="5" />
- <Param name="@Level_CustomerFrom" type="SaleBill.No_SaleBill" Index="6" />
- <Param name="@Level_CustomerTo" type="SaleBill.No_SaleBill" Index="7" />
- <Param name="@StartNo_Principal" type="Location.Name_Location" Index="8" />
- <Param name="@EndNo_Principal" type="Location.Name_Location" Index="9" />
- <Param name="@TypeFrom" type="Location.Name_Location" Index="10" />
- <Param name="@TypeTo" type="Location.Name_Location" Index="11" />
- <Param name="@Right" type="SaleBill.ID_Customer" Index="12" />
- <Param name="@Special" type="SaleBill.Special_SaleBill" Index="13" />
- </Params>
- <Tables>
- <Table name="FrmProductSalesStatistics"/>
- </Tables>
- </SearchSalesByPrincipalProductType>
-
- <SearchSalesByPrincipaCustomerProduct CmdType="Text" CmdText="
- declare @cessOut decimal(14,4)
- declare @sqlCmd nvarchar(4000)
- Select @cessOut=CessOut_SystemSetting From SystemSetting
- set @sqlCmd=N'Select Employee.Name_Employee As Principal,Customer.No_Customer,Customer.ShortName_Customer,Product.No_Product,Product.Name_Product,ab.SaleBillMoney,ab.SaleRtnBillMoney,ab.RealMoney, ab.Quantity_SaleBillProduct,ab.Quantity_SaleRtnBillProduct,ab.RealQuantity '
- +N' From '
- +N' ( '
- +N' Select a.ID_Principal,a.ID_Customer,a.ID_Product,Sum(a.SaleBillMoney) As SaleBillMoney,Sum(a.SaleRtnBillMoney) As SaleRtnBillMoney,Sum(a.SaleBillMoney-a.SaleRtnBillMoney) As RealMoney, Sum(a.Quantity_SaleBillProduct) As Quantity_SaleBillProduct,Sum(a.Quantity_SaleRtnBillProduct) As Quantity_SaleRtnBillProduct,Sum(a.Quantity_SaleBillProduct-a.Quantity_SaleRtnBillProduct) As RealQuantity '
- +N' From '
- +N' ( '
- +N' ( '
- +N' Select SaleBill.ID_Principal,ID_Customer,SaleBillProduct.ID_Product, '
- +N' SaleBillMoney=case SaleBill.TaxCurrency_SaleBill'
- +N' When '+nchar(39)+'外加'+nchar(39)+N' Then (Quantity_SaleBillProduct*UnitPrice_SaleBillProduct*(1+'+convert(nvarchar(64),@cessOut)+N'/100))'
- +N' else (Quantity_SaleBillProduct*UnitPrice_SaleBillProduct) end,convert(decimal(14,4),0) As SaleRtnBillMoney ,'
- +N' SaleBillProduct.Quantity_SaleBillProduct as Quantity_SaleBillProduct,CONVERT(DECIMAL(14,4),0.00) as Quantity_SaleRtnBillProduct '
- +N' From SaleBillProduct '
- +N' Join SaleBill On SaleBill.ID_SaleBill=SaleBillProduct.ID_SaleBill '
- +N' Where SaleBill.ID_Assessor Is Not Null '
- if(@StartDate_SaleBill Is Not Null)
- set @sqlCmd=@sqlCmd+N' And DateDiff(day,'+nchar(39)+convert(nvarchar(64),@StartDate_SaleBill)+nchar(39)+N', SaleBill.Date_SaleBill) >= 0 '
- if(@EndDate_SaleBill Is Not Null)
- set @sqlCmd=@sqlCmd+N' And DateDiff(day,'+nchar(39)+convert(nvarchar(64),@EndDate_SaleBill)+nchar(39)+N' ,SaleBill.Date_SaleBill) <= 0 '
- if(@Special=0)
- set @sqlCmd=@sqlCmd+N' And Special_SaleBill=0 '
-
- set @sqlCmd=@sqlCmd+N') union all '
- +N' ( '
- +N' Select SaleRtnBill.ID_Principal,ID_Customer,SaleRtnBillProduct.ID_Product,convert(decimal(14,4),0) As SaleBillMoney, '
- +N' SaleRtnBillMoney=case SaleRtnBill.TaxCurrency_SaleRtnBill'
- +N' When '+nchar(39)+'外加'+nchar(39)+N' Then (Quantity_SaleRtnBillProduct*UnitPrice_SaleRtnBillProduct*(1+'+convert(nvarchar(64),@cessOut)+N'/100))'
- +N' else (Quantity_SaleRtnBillProduct*UnitPrice_SaleRtnBillProduct) end,'
- +N' CONVERT(DECIMAL(14,4),0.00) as Quantity_SaleBillProduct,SaleRtnBillProduct.Quantity_SaleRtnBillProduct as Quantity_SaleRtnBillProduct '
- +N' From SaleRtnBillProduct '
- +N' Join SaleRtnBill On SaleRtnBill.ID_SaleRtnBill=SaleRtnBillProduct.ID_SaleRtnBill '
- +N' Join Employee On Employee.ID_Employee=SaleRtnBill.ID_Principal '
- +N' Where SaleRtnBill.ID_Assessor Is Not Null '
- if(@StartDate_SaleBill Is Not Null)
- set @sqlCmd=@sqlCmd+N' And DateDiff(day,'+nchar(39)+convert(nvarchar(64),@StartDate_SaleBill)+nchar(39)+N', SaleRtnBill.Date_SaleRtnBill) >= 0 '
- if(@EndDate_SaleBill Is Not Null)
- set @sqlCmd=@sqlCmd+N' And DateDiff(day,'+nchar(39)+convert(nvarchar(64),@EndDate_SaleBill)+nchar(39)+N', SaleRtnBill.Date_SaleRtnBill) <= 0 '
- set @sqlCmd=@sqlCmd + N') '
- +N' )a Group By a.ID_Principal,ID_Customer,ID_Product '
- +N' )ab '
- +N' Join Customer ON Customer.ID_Customer=ab.ID_Customer '
- +N' Join Product On Product.ID_Product=ab.ID_Product '
- +N' Join Employee ON Employee.ID_Employee=ab.ID_Principal '
- if(@CustomerNoFrom Is Not Null)
- set @sqlCmd=@sqlCmd+N' And No_Customer >= '+nchar(39)+@CustomerNoFrom+nchar(39)
- if(@CustomerNoTo Is Not Null)
- set @sqlCmd=@sqlCmd+N' And No_Customer <= '+nchar(39)+@CustomerNoTo+nchar(39)
- if(@ProductNoFrom Is Not Null)
- set @sqlCmd=@sqlCmd+N' And No_Product >= '+nchar(39)+@ProductNoFrom+nchar(39)
- if(@ProductNoTo Is Not Null)
- set @sqlCmd=@sqlCmd+N' And No_Product <= '+nchar(39)+@ProductNoTo+nchar(39)
- if(@Level_CustomerFrom Is Not Null)
- set @sqlCmd=@sqlCmd+N' And Level_Customer >= '+nchar(39)+@Level_CustomerFrom +nchar(39)
- if(@Level_CustomerTo Is Not Null)
- set @sqlCmd=@sqlCmd+N' And Level_Customer <= '+nchar(39)+@Level_CustomerTo+nchar(39)
- if(@StartNo_Principal Is Not Null)
- set @sqlCmd=@sqlCmd+N' And No_Employee >= '+nchar(39)+@StartNo_Principal +nchar(39)
- if(@EndNo_Principal Is Not Null)
- set @sqlCmd=@sqlCmd+N' And No_Employee <= '+nchar(39)+@EndNo_Principal+nchar(39)
- if(@TypeFrom Is Not Null)
- set @sqlCmd=@sqlCmd+N' And Type_Product >= '+nchar(39)+@TypeFrom +nchar(39)
- if(@TypeTo Is Not Null)
- set @sqlCmd=@sqlCmd+N' And Type_Product <= '+nchar(39)+@TypeTo+nchar(39)
- if(@Right Is Not Null)
- set @sqlCmd=@sqlCmd+N' And Customer.ID_Creator= '+nchar(39)+Convert(nvarchar(64),@Right)+nchar(39)
-
- set @sqlCmd=@sqlCmd+N' Order By Principal,No_Customer,No_Product '
- EXECUTE sp_executesql @sqlCmd
- ">
-
- <Params>
- <Param name="@StartDate_SaleBill" type="SaleBill.Date_SaleBill" Index="0" />
- <Param name="@EndDate_SaleBill" type="SaleBill.Date_SaleBill" Index="1" />
- <Param name="@CustomerNoFrom" type="SaleBill.No_SaleBill" Index="2" />
- <Param name="@CustomerNoTo" type="SaleBill.No_SaleBill" Index="3" />
- <Param name="@ProductNoFrom" type="Customer.No_Customer" Index="4" />
- <Param name="@ProductNoTo" type="Customer.No_Customer" Index="5" />
- <Param name="@Level_CustomerFrom" type="SaleBill.No_SaleBill" Index="6" />
- <Param name="@Level_CustomerTo" type="SaleBill.No_SaleBill" Index="7" />
- <Param name="@StartNo_Principal" type="Location.Name_Location" Index="8" />
- <Param name="@EndNo_Principal" type="Location.Name_Location" Index="9" />
- <Param name="@TypeFrom" type="Location.Name_Location" Index="10" />
- <Param name="@TypeTo" type="Location.Name_Location" Index="11" />
- <Param name="@Right" type="SaleBill.ID_Customer" Index="12" />
- <Param name="@Special" type="SaleBill.Special_SaleBill" Index="13" />
- </Params>
- <Tables>
- <Table name="FrmProductSalesStatisticsPCP"/>
- </Tables>
- </SearchSalesByPrincipaCustomerProduct>
-
- <SearchSalesByCutomerProductType CmdType="Text" CmdText="
-
- declare @cessOut decimal(14,4)
- declare @sqlCmd nvarchar(4000)
- Select @cessOut=CessOut_SystemSetting From SystemSetting
- Set @sqlCmd=N'Select Customer.No_Customer,ab.Type_Product,ab.SaleBillMoney,ab.SaleRtnBillMoney,ab.RealMoney , ab.Quantity_SaleBillProduct,ab.Quantity_SaleRtnBillProduct,ab.RealQuantity '
- +N' From '
- +N' ( '
- +N' Select a.ID_Customer,a.Type_Product,Sum(a.SaleBillMoney) As SaleBillMoney,Sum(a.SaleRtnBillMoney) As SaleRtnBillMoney,Sum(a.SaleBillMoney-a.SaleRtnBillMoney) As RealMoney , Sum(a.Quantity_SaleBillProduct) As Quantity_SaleBillProduct,Sum(a.Quantity_SaleRtnBillProduct) As Quantity_SaleRtnBillProduct,Sum(a.Quantity_SaleBillProduct-a.Quantity_SaleRtnBillProduct) As RealQuantity '
- +N' From '
- +N' ( '
- +N' ( '
- +N' Select ID_Customer,Type_Product,'
- +N' SaleBillMoney=case SaleBill.TaxCurrency_SaleBill'
- +N' When '+nchar(39)+'外加'+nchar(39)+N' Then (Quantity_SaleBillProduct*UnitPrice_SaleBillProduct*(1+'+convert(nvarchar(64),@cessOut)+N'/100))'
- +N' else (Quantity_SaleBillProduct*UnitPrice_SaleBillProduct) end,convert(decimal(14,4), 0) As SaleRtnBillMoney ,'
- +N' SaleBillProduct.Quantity_SaleBillProduct as Quantity_SaleBillProduct,CONVERT(DECIMAL(14,4),0.00) as Quantity_SaleRtnBillProduct '
- +N' From SaleBillProduct '
- +N' Join SaleBill On SaleBill.ID_SaleBill=SaleBillProduct.ID_SaleBill '
- +N' Join Product On Product.ID_Product=SaleBillProduct.ID_Product '
- +N' Join Employee On Employee.ID_Employee=SaleBill.ID_Principal '
- +N' Where SaleBill.ID_Assessor Is Not Null '
- if(@StartDate_SaleBill Is Not Null)
- set @sqlCmd=@sqlCmd+N' And DateDiff(day,'+nchar(39)+convert(nvarchar(64),@StartDate_SaleBill)+nchar(39)+N', SaleBill.Date_SaleBill) >= 0 '
- if(@EndDate_SaleBill Is Not Null)
- set @sqlCmd=@sqlCmd+N' And DateDiff(day,'+nchar(39)+convert(nvarchar(64),@EndDate_SaleBill)+nchar(39)+N', SaleBill.Date_SaleBill) <= 0 '
- if(@ProductNoFrom Is Not Null)
- set @sqlCmd=@sqlCmd+N' And No_Product >= '+nchar(39)+@ProductNoFrom+nchar(39)
- if(@ProductNoTo Is Not Null)
- set @sqlCmd=@sqlCmd+N' And No_Product <= '+nchar(39)+@ProductNoTo+nchar(39)
- if(@TypeFrom Is Not Null)
- set @sqlCmd=@sqlCmd+N' And Type_Product >= '+nchar(39)+@TypeFrom +nchar(39)
- if(@TypeTo Is Not Null)
- set @sqlCmd=@sqlCmd+N' And Type_Product <= '+nchar(39)+@TypeTo+nchar(39)
- if(@StartNo_Principal Is Not Null)
- set @sqlCmd=@sqlCmd+N' And No_Employee >= '+nchar(39)+@StartNo_Principal +nchar(39)
- if(@EndNo_Principal Is Not Null)
- set @sqlCmd=@sqlCmd+N' And No_Employee <= '+nchar(39)+@EndNo_Principal+nchar(39)
- if(@Special=0)
- set @sqlCmd=@sqlCmd+N' And Special_SaleBill=0 '
- set @sqlCmd=@sqlCmd+N' ) '
- +N' union all'
- +N' ( '
- +N' Select ID_Customer,Type_Product,convert(decimal(14,4),0) As SaleBillMoney,'
- +N' SaleRtnBillMoney=case SaleRtnBill.TaxCurrency_SaleRtnBill'
- +N' When '+nchar(39)+'外加'+nchar(39)+N' Then (Quantity_SaleRtnBillProduct*UnitPrice_SaleRtnBillProduct*(1+'+convert(nvarchar(64),@cessOut)+N'/100))'
- +N' else (Quantity_SaleRtnBillProduct*UnitPrice_SaleRtnBillProduct) end , '
- +N' CONVERT(DECIMAL(14,4),0.00) as Quantity_SaleBillProduct,SaleRtnBillProduct.Quantity_SaleRtnBillProduct as Quantity_SaleRtnBillProduct '
- +N' From SaleRtnBillProduct '
- +N' Join SaleRtnBill On SaleRtnBill.ID_SaleRtnBill=SaleRtnBillProduct.ID_SaleRtnBill '
- +N' Join Product On Product.ID_Product=SaleRtnBillProduct.ID_Product '
- +N' Join Employee On Employee.ID_Employee=SaleRtnBill.ID_Principal '
- +N' Where SaleRtnBill.ID_Assessor Is Not Null '
- if(@StartDate_SaleBill Is Not Null)
- set @sqlCmd=@sqlCmd+N' And DateDiff(day,'+nchar(39)+convert(nvarchar(64),@StartDate_SaleBill)+nchar(39)+N', SaleRtnBill.Date_SaleRtnBill) >= 0 '
- if(@EndDate_SaleBill Is Not Null)
- set @sqlCmd=@sqlCmd+N' And DateDiff(day,'+nchar(39)+convert(nvarchar(64),@EndDate_SaleBill)+nchar(39)+N', SaleRtnBill.Date_SaleRtnBill) <= 0 '
- if(@ProductNoFrom Is Not Null)
- set @sqlCmd=@sqlCmd+N' And No_Product >= '+nchar(39)+@ProductNoFrom+nchar(39)
- if(@ProductNoTo Is Not Null)
- set @sqlCmd=@sqlCmd+N' And No_Product <= '+nchar(39)+@ProductNoTo+nchar(39)
- if(@TypeFrom Is Not Null)
- set @sqlCmd=@sqlCmd+N' And Type_Product >= '+nchar(39)+@TypeFrom +nchar(39)
- if(@TypeTo Is Not Null)
- set @sqlCmd=@sqlCmd+N' And Type_Product <= '+nchar(39)+@TypeTo+nchar(39)
- if(@StartNo_Principal Is Not Null)
- set @sqlCmd=@sqlCmd+N' And No_Employee >= '+nchar(39)+@StartNo_Principal +nchar(39)
- if(@EndNo_Principal Is Not Null)
- set @sqlCmd=@sqlCmd+N' And No_Employee <= '+nchar(39)+@EndNo_Principal+nchar(39)
- set @sqlCmd=@sqlCmd+N' ) '
- +N' )a Group By a.ID_Customer,a.Type_Product '
- +N' )ab '
- +N' Join Customer On Customer.ID_Customer=ab.ID_Customer '
- if(@CustomerNoFrom Is Not Null)
- set @sqlCmd=@sqlCmd+N' And No_Customer >= '+nchar(39)+@CustomerNoFrom+nchar(39)
- if(@CustomerNoTo Is Not Null)
- set @sqlCmd=@sqlCmd+N' And No_Customer <= '+nchar(39)+@CustomerNoTo+nchar(39)
- if(@Level_CustomerFrom Is Not Null)
- set @sqlCmd=@sqlCmd+N' And Level_Customer >= '+nchar(39)+@Level_CustomerFrom +nchar(39)
- if(@Level_CustomerTo Is Not Null)
- set @sqlCmd=@sqlCmd+N' And Level_Customer <= '+nchar(39)+@Level_CustomerTo+nchar(39)
- if(@Right Is Not Null)
- set @sqlCmd=@sqlCmd+N' And Customer.ID_Creator= '+nchar(39)+Convert(nvarchar(64),@Right)+nchar(39)
-
- set @sqlCmd=@sqlCmd+N' Order By No_Customer,Type_Product'
- EXECUTE sp_executesql @sqlCmd
- ">
-
- <Params>
- <Param name="@StartDate_SaleBill" type="SaleBill.Date_SaleBill" Index="0" />
- <Param name="@EndDate_SaleBill" type="SaleBill.Date_SaleBill" Index="1" />
- <Param name="@CustomerNoFrom" type="SaleBill.No_SaleBill" Index="2" />
- <Param name="@CustomerNoTo" type="SaleBill.No_SaleBill" Index="3" />
- <Param name="@ProductNoFrom" type="Customer.No_Customer" Index="4" />
- <Param name="@ProductNoTo" type="Customer.No_Customer" Index="5" />
- <Param name="@Level_CustomerFrom" type="SaleBill.No_SaleBill" Index="6" />
- <Param name="@Level_CustomerTo" type="SaleBill.No_SaleBill" Index="7" />
- <Param name="@StartNo_Principal" type="Location.Name_Location" Index="8" />
- <Param name="@EndNo_Principal" type="Location.Name_Location" Index="9" />
- <Param name="@TypeFrom" type="Location.Name_Location" Index="10" />
- <Param name="@TypeTo" type="Location.Name_Location" Index="11" />
- <Param name="@Right" type="SaleBill.ID_Customer" Index="12" />
- <Param name="@Special" type="SaleBill.Special_SaleBill" Index="13" />
- </Params>
- <Tables>
- <Table name="FrmProductSalesStatisticsCTP"/>
- </Tables>
- </SearchSalesByCutomerProductType>
- </Search>
- </Server>
- <Lables>
- <Search>
-
- </Search>
- </Lables>
- </Form>
- </Forms>
|