123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583 |
- <?xml version="1.0" encoding="utf-8" ?>
- <Forms>
- <Form Name="FrmReceivableStrikeStatistics">
- <Client>
- <Events>
- <Load>
- <![CDATA[
- @Title="应收款统计";
- GetSchema();
- txtCoNo.CValue=GetCurrentCompanyNo();
- txtCoName.CValue=GetCurrentCompanyShortName();
- ComboCompany.Enabled = false;
- Empty();
- NewInstance();
- ]]>
- </Load>
- <Closing>
- ;
- </Closing>
- <Closed>
- ;
- </Closed>
- </Events>
- <Mode>
- <Search>
- <Lable name="Search"/>
- </Search>
- </Mode>
- <Controls>
- <IKComboBoxEx name="comboYear" DisplaySource="UI.Start_Year" DataSource="BillYear" DisplayMember="Bill_Year" >
- <Events>
- <Reload>
- UpdateForm(false, "comboYear");
- Search("SearchYearr");
- UpdateForm(true, "comboYear");
- </Reload>
- </Events>
- </IKComboBoxEx>
- <IKComboBoxEx name="comboFlag" DisplaySource="UI.Start_Month" DataSource="HalfYear" DisplayMember="Half_Year" >
- <Events>
- <Reload>
- UpdateForm(false, "comboFlag");
- Search("SearchHalfYear");
- UpdateForm(true, "comboFlag");
- </Reload>
- </Events>
- </IKComboBoxEx>
- <IKTextButton name="tbCustomerNo1" DataSource="UI.StartNo_Customer">
- <Events>
- <Click>
- @temp = ShowSearchBox("CustomerSearch","INFOMATION",tbCustomerNo1.CValue);
- if( @temp == "" )
- return;
- tbCustomerNo1.CValue = @temp;
- </Click>
- <TextBoxButtonTextChanged>
- tbCustomerNo2.CValue = tbCustomerNo1.CValue;
- </TextBoxButtonTextChanged>
- </Events>
- </IKTextButton>
- <IKTextButton name="tbCustomerNo2" DataSource="UI.EndNo_Customer">
- <Events>
- <Click>
- @temp = ShowSearchBox("CustomerSearch","INFOMATION",tbCustomerNo2.CValue);
- if( @temp == "" )
- return;
- tbCustomerNo2.CValue = @temp;
- </Click>
- </Events>
- </IKTextButton>
- <IKCheckBox name="ikCheckCompany" DataSource="UI.Company_Flag">
- <Events>
- <CheckedChanged>
- ComboCompany.Enabled = !ComboCompany.Enabled;
- </CheckedChanged>
- </Events>
- </IKCheckBox>
- <IKComboBoxEx name="ComboCompany" DisplaySource="UI.Company_Name" DataSource="CompanyType" DisplayMember="Name_TypeDef" >
- <Events>
- <Reload>
- UpdateForm(false, "ComboCompany");
- Search("SearchCompany");
- UpdateForm(true, "ComboCompany");
- </Reload>
- </Events>
- </IKComboBoxEx>
- <IKButton name="btnView">
- <Events>
- <Click>
- UpdateForm(false,"");
- @Start_Year = DBNull();
- @Start_Month = 0;
- @StartNo_Customer = DBNull();
- @EndNo_Customer = DBNull();
- @Company_Name = "";
- if (comboYear.Text =="" )
- {
- MessageBox("清选泽起始年份!!");
- return;
- }
- else
- {
- @Start_Year = comboYear.Text;
- }
- if (comboFlag.Text == "" )
- {
- MessageBox("清选泽起始月份!!");
- return;
- }
- else
- {
- @Start_Month = comboFlag.Text;
- }
- if(tbCustomerNo1.CValue != "")
- @StartNo_Customer = tbCustomerNo1.CValue;
- if(tbCustomerNo2.CValue != "")
- @EndNo_Customer = tbCustomerNo2.CValue;
- if( ikCheckCompany.Checked ){
- if (ComboCompany.Text !=""){
- #UI.company_Name = ComboCompany.Text;
- @Company_Name = ComboCompany.Text;
- }else{
- MessageBox("请选泽所属公司!!");
- #UI.company_Name = "";
- @Company_Name = "";
- return;
- }
- } else {
- #UI.company_Name = "";
- @Company_Name = "";
- }
- Search("SearchReceivableStrikeStatistics",@Start_Year,@Start_Month,@StartNo_Customer,@EndNo_Customer,@Company_Name);
- if(RowCount("#FrmReceivableStrikeStatistics")==0)
- MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
- else
- PrintReport("UIFrmReceivableStrikeStatistics","UI","FrmReceivableStrikeStatistics");
- </Click>
- </Events>
- </IKButton>
- <IKButton name="btnExcel">
- <Events>
- <Click>
- UpdateForm(false,"");
- @Start_Year = DBNull();
- @Start_Month = 0;
- @StartNo_Customer = DBNull();
- @EndNo_Customer = DBNull();
- @Company_Name = "";
- if (comboYear.Text =="" )
- {
- MessageBox("清选泽起始年份!!");
- return;
- }
- else
- {
- @Start_Year = comboYear.Text;
- }
- if (comboFlag.Text == "" )
- {
- MessageBox("清选泽起始月份!!");
- return;
- }
- else
- {
- @Start_Month = comboFlag.Text;
- }
- if(tbCustomerNo1.CValue != "")
- @StartNo_Customer = tbCustomerNo1.CValue;
- if(tbCustomerNo2.CValue != "")
- @EndNo_Customer = tbCustomerNo2.CValue;
- if( ikCheckCompany.Checked ){
- if (ComboCompany.Text !=""){
- #UI.company_Name = ComboCompany.Text;
- @Company_Name = ComboCompany.Text;
- }else{
- MessageBox("请选泽所属公司!!");
- #UI.company_Name = "";
- @Company_Name = "";
- return;
- }
- } else {
- #UI.company_Name = "";
- @Company_Name = "";
- }
- Search("SearchReceivableStrikeStatistics",@Start_Year,@Start_Month,@StartNo_Customer,@EndNo_Customer,@Company_Name);
- if(RowCount("#FrmReceivableStrikeStatistics")==0)
- MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
- else
- ExportReport("Excel","UI","FrmReceivableStrikeStatistics");
- </Click>
- </Events>
- </IKButton>
- <IKButton name="btnWord">
- <Events>
- <Click>
- UpdateForm(false,"");
- @Start_Year = DBNull();
- @Start_Month = 0;
- @StartNo_Customer = DBNull();
- @EndNo_Customer = DBNull();
- @Company_Name = "";
- if (comboYear.Text =="" )
- {
- MessageBox("清选泽起始年份!!");
- return;
- }
- else
- {
- @Start_Year = comboYear.Text;
- }
- if (comboFlag.Text == "" )
- {
- MessageBox("清选泽起始月份!!");
- return;
- }
- else
- {
- @Start_Month = comboFlag.Text;
- }
- if(tbCustomerNo1.CValue != "")
- @StartNo_Customer = tbCustomerNo1.CValue;
- if(tbCustomerNo2.CValue != "")
- @EndNo_Customer = tbCustomerNo2.CValue;
- if( ikCheckCompany.Checked ){
- if (ComboCompany.Text !=""){
- #UI.company_Name = ComboCompany.Text;
- @Company_Name = ComboCompany.Text;
- }else{
- MessageBox("请选泽所属公司!!");
- #UI.company_Name = "";
- @Company_Name = "";
- return;
- }
- } else {
- #UI.company_Name = "";
- @Company_Name = "";
- }
- Search("SearchReceivableStrikeStatistics",@Start_Year,@Start_Month,@StartNo_Customer,@EndNo_Customer,@Company_Name);
- if(RowCount("#FrmReceivableStrikeStatistics")==0)
- MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
- else
- ExportReport("Word","UI","FrmReceivableStrikeStatistics");
- </Click>
- </Events>
- </IKButton>
- <IKButton name="btnPrint">
- <Events>
- <Click>
- UpdateForm(false,"");
- @Start_Year = DBNull();
- @Start_Month = 0;
- @StartNo_Customer = DBNull();
- @EndNo_Customer = DBNull();
- @Company_Name = "";
- if (comboYear.Text =="" )
- {
- MessageBox("清选泽起始年份!!");
- return;
- }
- else
- {
- @Start_Year = comboYear.Text;
- }
- if (comboFlag.Text == "" )
- {
- MessageBox("清选泽起始月份!!");
- return;
- }
- else
- {
- @Start_Month = comboFlag.Text;
- }
- if(tbCustomerNo1.CValue != "")
- @StartNo_Customer = tbCustomerNo1.CValue;
- if(tbCustomerNo2.CValue != "")
- @EndNo_Customer = tbCustomerNo2.CValue;
- if( ikCheckCompany.Checked ){
- if (ComboCompany.Text !=""){
- #UI.company_Name = ComboCompany.Text;
- @Company_Name = ComboCompany.Text;
- }else{
- MessageBox("请选泽所属公司!!");
- #UI.company_Name = "";
- @Company_Name = "";
- return;
- }
- } else {
- #UI.company_Name = "";
- @Company_Name = "";
- }
- Search("SearchReceivableStrikeStatistics",@Start_Year,@Start_Month,@StartNo_Customer,@EndNo_Customer,@Company_Name);
- if(RowCount("#FrmReceivableStrikeStatistics")==0)
- MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
- else
- ExportReport("PrintToPrinter","UIFrmReceivableStrikeStatistics","UI","FrmReceivableStrikeStatistics");
- </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"/>
- </ChildForm>
- </ChildForms>
- <FormatString>
- <Format name="SearchCustomerCondition">
- if(GetRight("客户基本资料","全权查看"))
- FormatString("");
- else
- FormatString(" Customer.ID_Creator='{0}' ",GetLoginUserID());
- </Format>
- </FormatString>
- </Client>
- <Server>
- <Tables>
- <Table name="UI" Type="Parent">
- <GetSchema CmdType="Text" CmdText="Select TOP 0 convert(nvarchar(12),'') As Start_Year
- ,convert(nvarchar(12),'') As Start_Month
- ,convert(nvarchar(64),'') As StartNo_Customer
- ,convert(nvarchar(64),'') As EndNo_Customer
- ,convert(nvarchar(64),'') As Company_Name
- ,convert(bit,'false') As Company_Flag"/>
- </Table>
- </Tables>
- <Search>
- <SearchAllCustomer CmdType="Text" CmdText="SELECT Customer.No_Customer,Customer.ShortName_Customer,Customer.Type_Customer,Customer.Level_Customer,Customer.IsGeneric_Customer,Customer.Note_Customer FROM Customer ">
- <Tables>
- <Table name="AllCustomer" />
- </Tables>
- </SearchAllCustomer>
- <SearchYearr CmdType="Text" CmdText="Select Convert(nvarchar(12),year(InvoiceDate_SaleInvoice)) as Bill_Year
- From SaleInvoice
- Group By year(InvoiceDate_SaleInvoice)
- order by Bill_Year
- ">
- <Tables>
- <Table name="BillYear"/>
- </Tables>
- </SearchYearr>
- <SearchHalfYear CmdType="Text" CmdText="CREATE TABLE dbo.Temp_HalfYear
- (
- Half_Year nvarchar(12) NULL
- ) ON [PRIMARY]
- Insert Into dbo.Temp_HalfYear (Half_Year)
- VALUES ('1')
- Insert Into dbo.Temp_HalfYear (Half_Year)
- VALUES ('2')
- Insert Into dbo.Temp_HalfYear (Half_Year)
- VALUES ('3')
- Insert Into dbo.Temp_HalfYear (Half_Year)
- VALUES ('4')
- Insert Into dbo.Temp_HalfYear (Half_Year)
- VALUES ('5')
- Insert Into dbo.Temp_HalfYear (Half_Year)
- VALUES ('6')
- Insert Into dbo.Temp_HalfYear (Half_Year)
- VALUES ('7')
- select * from dbo.Temp_HalfYear
- DROP TABLE dbo.Temp_HalfYear
- ">
- <Tables>
- <Table name="HalfYear"/>
- </Tables>
- </SearchHalfYear>
- <SearchCompany CmdType="Text" CmdText="SELECT * FROM TypeDef WHERE Type_TypeDef = 30">
- <Tables>
- <Table name="CompanyType"/>
- </Tables>
- </SearchCompany>
- <SearchReceivableStrikeStatistics CmdType="Text" CmdText="DECLARE @Cmd nvarchar(4000)
- ,@End_Month int
- ,@Count_Month int
- ,@Compare nvarchar(24)
-
- set @Cmd = ''
- set @End_Month = @Start_Month+5
- set @Count_Month = 0
- set @Compare = convert(nvarchar(12),@Start_Year)+'/'+convert(nvarchar(12),@Start_Month)+'/1'
-
- set @Count_Month = @Start_Month
-
- while @Count_Month <= @End_Month
- begin
- set @Cmd = @Cmd+N' CREATE TABLE [dbo].[Temp_'+convert(varchar(12),@Count_Month)+N']( '
- +N' [No_Customer] [nvarchar](24) NULL'
- +N' ,[ShortName_Customer] [nvarchar](24) NULL'
- +N' ,[Start_Year] [nvarchar](12) NULL'
- +N' ,[Start_Month] [nvarchar](12) NULL'
- +N' ,[Company_Customer] [nvarchar](24) NULL'
- +N' ,[Bill_'+convert(varchar(12),@Count_Month)+N'] [decimal](18, 4) NULL'
- +N' ,[BillMoney_'+convert(varchar(12),@Count_Month)+N'] [decimal](18, 4) NULL'
- +N' ,[ToGetMoney_'+convert(varchar(12),@Count_Month)+N'] [decimal](18, 4) NULL'
- +N' ) ON [PRIMARY] '
- +N' Insert Into Temp_'+convert(varchar(12),@Count_Month)
- +N' select No_Customer '
- +N' ,ShortName_Customer '
- +N' ,'+convert(nvarchar(12),@Start_Year)+N' as Start_Year'
- +N' ,'+convert(nvarchar(12),@Start_Month)+N' as Start_Month'
- +N' ,'''+convert(nvarchar(64),@Company_Name)+N''' as Company_Customer'
- +N' ,(case when (OpeningToGetBalance_Customer - OpeningPrepayBalance_Customer + IsNull(A.Big,0) - IsNull(D.Little,0)) = 0 then 0 '
- +N' else (OpeningToGetBalance_Customer - OpeningPrepayBalance_Customer + IsNull(A.Big,0) - IsNull(D.Little,0)) end ) '
- +N' as Bill_'+convert(varchar(12),@Start_Year)
- +N' ,IsNull(BillMoney,0) as BillMoney_'+convert(varchar(12),@Count_Month)
- +N' ,IsNull(ToGetMoney,0) as ToGetMoney_'+convert(varchar(12),@Count_Month)
- +N' from '
- +N'( '
- +N' Select ID_Customer '
- +N' ,No_Customer '
- +N' ,ShortName_Customer '
- +N' ,IsCustomersCustomer_Customer '
- +N' ,Company_Customer'
- +N' ,OpeningToGetBalance_Customer'
- +N' , OpeningPrepayBalance_Customer'
- +N' From Customer '
- +N' Where ID_Customer Is Not Null '
- +N' and IsCustomersCustomer_Customer = 0 '
- if(@StartNo_Customer Is Not Null)
- set @Cmd=@Cmd+N' And No_Customer >= '+nchar(39)+@StartNo_Customer+nchar(39)
- if(@EndNo_Customer Is Not Null)
- set @Cmd=@Cmd+N' And No_Customer <= '+nchar(39)+@EndNo_Customer+nchar(39)
- if(@Company_Name Is Not Null)
- if (@Company_Name!='')
- set @Cmd=@Cmd+N' And Company_Customer = '+nchar(39)+@Company_Name+nchar(39)
- set @Cmd=@Cmd+N' ) Pri '
- +N' Left Join '
- +N' ( '
- +N' Select ID_Customer,Sum(Amount_SaleInvoice) As Big '
- +N' From SaleInvoice '
- +N' Where SaleInvoice.ID_Assessor Is Not Null '
- +N' And DateDiff(day,'''+convert(nvarchar(24),@Compare)+N''',InvoiceDate_SaleInvoice) <0 '
- +N' And Disable_SaleInvoice = 0 '
- +N' Group By ID_Customer '
- +N' )A On A.ID_Customer =Pri.ID_Customer '
- +N' Left join '
- +N' ( '
- +N' Select ID_Customer '
- +N' ,sum( case when year([InvoiceDate_SaleInvoice])='+convert(nvarchar(12),@Start_Year)+N' then'
- +N' case when month([InvoiceDate_SaleInvoice])='+convert(varchar(12),@Count_Month)
- +N' then Amount_SaleInvoice '
- +N' else 0 end '
- +N' else 0 end '
- +N' ) '
- +N' as BillMoney '
- +N' From SaleInvoice '
- +N' Where SaleInvoice.ID_Assessor Is Not Null '
- +N' And Disable_SaleInvoice = 0 '
- +N' Group By ID_Customer '
- +N' ) B On B.ID_Customer = Pri.ID_Customer '
- +N' Left join '
- +N' ( '
- +N' Select ID_Customer '
- +N' ,sum( case when year([Date_PreGet])='+convert(nvarchar(12),@Start_Year)+N' then'
- +N' case when month([Date_PreGet])='+convert(varchar(12),@Count_Month)
- +N' then Amount_PreGet'
- +N' else 0 end '
- +N' else 0 end '
- +N' )'
- +N' as ToGetMoney '
- +N' From PreGet '
- +N' Where PreGet.ID_Assessor Is Not Null '
- +N' Group By ID_Customer'
- +N' ) C On C.ID_Customer = Pri.ID_Customer '
-
- +N' Left Join '
- +N' ( '
- +N' Select ID_Customer,Sum(Amount_Preget) As Little '
- +N' From Preget '
- +N' Where PreGet.ID_Assessor Is Not Null '
- +N' And DateDiff(day,'''+convert(nvarchar(24),@Compare)+N''',Date_PreGet) < 0 '
- +N' Group By ID_Customer '
- +N' ) D On D.ID_Customer = Pri.ID_Customer '
-
-
- +N' order by No_Customer'
- exec (@Cmd)
-
- set @Cmd=''
- set @Count_Month=@Count_Month+1
- end
- set @Cmd=''
- set @Count_Month = @Start_Month
- set @Cmd = @Cmd +N'select temp_'+convert(varchar(12),@Count_Month)+N'.No_Customer'
- +N',temp_'+convert(varchar(12),@Count_Month)+N'.ShortName_Customer'
- +N',temp_'+convert(varchar(12),@Count_Month)+N'.Start_Year'
- +N',temp_'+convert(varchar(12),@Count_Month)+N'.Start_Month'
- +N',temp_'+convert(varchar(64),@Count_Month)+N'.Company_Customer'
- +N',Bill_'+convert(varchar(12),@Count_Month)
- +N',BillMoney_'+convert(varchar(12),@Count_Month)
- +N',ToGetMoney_'+convert(varchar(12),@Count_Month)
- while @Count_Month <=@End_Month
- begin
- if(@Count_Month > @Start_Month)
- set @Cmd = @Cmd +N',BillMoney_'+convert(varchar(12),@Count_Month)
- +N',ToGetMoney_'+convert(varchar(12),@Count_Month)
- set @Count_Month=@Count_Month+1
- end
- set @Cmd = @Cmd+N' from temp_'+convert(varchar(12),@Start_Month)
- set @Count_Month = @Start_Month
- while @Count_Month <= @End_Month
- begin
- if(@Count_Month > @Start_Month)
- set @Cmd = @Cmd +N' left join temp_'+convert(varchar(12),@Count_Month)+N' on temp_'+convert(varchar(12),@Count_Month)+N'.No_Customer = temp_'+convert(varchar(12),@Start_Month)+N'.No_Customer'
- set @Count_Month=@Count_Month+1
- end
- exec (@Cmd)
- set @Count_Month = @Start_Month
- while @Count_Month <= @End_Month
- begin
- set @Cmd = ''
- set @Cmd = @Cmd+N' DROP TABLE [dbo].[Temp_'+convert(varchar(12),@Count_Month)+N']'
- exec (@Cmd)
- set @Count_Month=@Count_Month+1
- end
- ">
- <Params>
- <Param name="@Start_Year" type="SaleInvoice.No_SaleInvoice" Index="0" />
- <Param name="@Start_Month" type="SaleInvoice.No_SaleInvoice" Index="1" />
- <Param name="@StartNo_Customer" type="Customer.No_Customer" Index="2" />
- <Param name="@EndNo_Customer" type="Customer.No_Customer" Index="3" />
- <Param name="@Company_Name" type="Customer.No_Customer" Index="4" />
- </Params>
- <Tables>
- <Table name="FrmReceivableStrikeStatistics"/>
- </Tables>
- </SearchReceivableStrikeStatistics>
- </Search>
- </Server>
- </Form>
- </Forms>
|