123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373 |
- <?xml version="1.0" encoding="utf-8" ?>
- <Forms>
- <Form Name="FrmCustomerAccountStatistics">
- <Client>
- <Events>
- <Load>
- <![CDATA[
- @Title="客户账款统计";
- GetSchema();
- txtCoNo.CValue=GetCurrentCompanyNo();
- txtCoName.CValue=GetCurrentCompanyShortName();
- Empty();
- NewInstance();
- #UI.StartDate = GetCurrentTime();
- #UI.EndDate = GetCurrentTime();
- ]]>
- </Load>
- <Closing>
- ;
- </Closing>
- <Closed>
- ;
- </Closed>
- </Events>
- <Mode>
- <Search>
- <Lable name="Search"/>
- </Search>
- </Mode>
- <Controls>
- <IKDateTimePicker name="dtStart" DataSource="UI.StartDate">
- <Events>
- <CheckedChanged>
- dtEnd.Checked = dtStart.Checked;
- </CheckedChanged>
- <ValueChanged>
- dtEnd.CValue = dtStart.CValue;
- </ValueChanged>
- </Events>
- </IKDateTimePicker>
- <IKDateTimePicker name="dtEnd" DataSource="UI.EndDate"/>
- <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>
- <IKButton name="btnView">
- <Events>
- <Click>
- UpdateForm(false,"");
- @StartDate=DBNull();
- @EndDate=DBNull();
- @StartNo_Customer = DBNull();
- @EndNo_Customer = DBNull();
-
- if(dtStart.Checked)
- @StartDate=dtStart.Value;
- else
- #UI.StartDate=DBNull();
- if(dtEnd.Checked)
- @EndDate=dtEnd.Value;
- else
- #UI.EndDate=DBNull();
- if(tbCustomerNo1.CValue != "")
- @StartNo_Customer = tbCustomerNo1.CValue;
- if(tbCustomerNo2.CValue != "")
- @EndNo_Customer = tbCustomerNo2.CValue;
-
- Search("SearchCustomerAccountStatistics",@StartDate,@EndDate,@StartNo_Customer,@EndNo_Customer);
- if(RowCount("#FrmCustomerAccountStatistics")==0)
- {
- MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
- }
- else
- {
- PrintReport("UIFrmCustomerAccountStatistics","UI","FrmCustomerAccountStatistics");
- }
- </Click>
- </Events>
- </IKButton>
- <IKButton name="btnExcel">
- <Events>
- <Click>
- UpdateForm(false,"");
- @StartDate=DBNull();
- @EndDate=DBNull();
- @StartNo_Customer = DBNull();
- @EndNo_Customer = DBNull();
-
- if(dtStart.Checked)
- @StartDate=dtStart.Value;
- else
- #UI.StartDate=DBNull();
- if(dtEnd.Checked)
- @EndDate=dtEnd.Value;
- else
- #UI.EndDate=DBNull();
- if(tbCustomerNo1.CValue != "")
- @StartNo_Customer = tbCustomerNo1.CValue;
- if(tbCustomerNo2.CValue != "")
- @EndNo_Customer = tbCustomerNo2.CValue;
-
- Search("SearchCustomerAccountStatistics",@StartDate,@EndDate,@StartNo_Customer,@EndNo_Customer);
- if(RowCount("#FrmCustomerAccountStatistics")==0)
- {
- MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
- }
- else
- {
- PrintReport("Excel","UIFrmCustomerAccountStatistics","UI","FrmCustomerAccountStatistics");
- }
- </Click>
- </Events>
- </IKButton>
- <IKButton name="btnWord">
- <Events>
- <Click>
- UpdateForm(false,"");
- @StartDate=DBNull();
- @EndDate=DBNull();
- @StartNo_Customer = DBNull();
- @EndNo_Customer = DBNull();
-
- if(dtStart.Checked)
- @StartDate=dtStart.Value;
- else
- #UI.StartDate=DBNull();
- if(dtEnd.Checked)
- @EndDate=dtEnd.Value;
- else
- #UI.EndDate=DBNull();
- if(tbCustomerNo1.CValue != "")
- @StartNo_Customer = tbCustomerNo1.CValue;
- if(tbCustomerNo2.CValue != "")
- @EndNo_Customer = tbCustomerNo2.CValue;
-
- Search("SearchCustomerAccountStatistics",@StartDate,@EndDate,@StartNo_Customer,@EndNo_Customer);
- if(RowCount("#FrmCustomerAccountStatistics")==0)
- {
- MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
- }
- else
- {
- PrintReport("Word","UIFrmCustomerAccountStatistics","UI","FrmCustomerAccountStatistics");
- }
- </Click>
- </Events>
- </IKButton>
- <IKButton name="btnPrint">
- <Events>
- <Click>
- UpdateForm(false,"");
- @StartDate=DBNull();
- @EndDate=DBNull();
- @StartNo_Customer = DBNull();
- @EndNo_Customer = DBNull();
-
- if(dtStart.Checked)
- @StartDate=dtStart.Value;
- else
- #UI.StartDate=DBNull();
- if(dtEnd.Checked)
- @EndDate=dtEnd.Value;
- else
- #UI.EndDate=DBNull();
- if(tbCustomerNo1.CValue != "")
- @StartNo_Customer = tbCustomerNo1.CValue;
- if(tbCustomerNo2.CValue != "")
- @EndNo_Customer = tbCustomerNo2.CValue;
-
- Search("SearchCustomerAccountStatistics",@StartDate,@EndDate,@StartNo_Customer,@EndNo_Customer);
- if(RowCount("#FrmCustomerAccountStatistics")==0)
- {
- MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
- }
- else
- {
- PrintReport("PrintToPrinter","UIFrmCustomerAccountStatistics","UI","FrmCustomerAccountStatistics");
- }
- </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>
- </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(datetime,0) As StartDate
- ,convert(datetime,0) As EndDate
- ,convert(nvarchar(64),'') As StartNo_Customer
- ,convert(nvarchar(64),'') As EndNo_Customer"/>
- </Table>
- </Tables>
- <Search>
- <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>
- <SearchCustomerAccountStatistics CmdType="Text" CmdText="declare @sqlCmd nvarchar(4000)
- set @sqlCmd=N' Select No_Customer'
- +N' ,ShortName_Customer'
- +N' ,'+nchar(39)+'期初'+nchar(39)+N' As BillType'
- +N' ,'+nchar(39)+''+nchar(39)+N' As BillNo'
- +N' ,'+nchar(39)+''+nchar(39)+N' As BillDate'
- +N' ,(OpeningPrePayBalance_Customer + IsNull(B.BiginBalance_PreGet,0)) As PrePayMoney'
- +N' ,(OpeningToGetBalance_Customer + IsNull(C.Amount_SaleBill,0) - IsNull(D.Amount_SaleRtnBill,0)) As ToGetMoney'
- +N' ,((OpeningPrePayBalance_Customer + IsNull(B.BiginBalance_PreGet,0)) - (OpeningToGetBalance_Customer + IsNull(C.Amount_SaleBill,0) - IsNull(D.Amount_SaleRtnBill,0))) As Balance'
- +N' From'
- +N' ('
- +N' Select ID_Customer'
- +N' ,No_Customer'
- +N' ,ShortName_Customer'
- +N' ,OpeningPrePayBalance_Customer'
- +N' ,OpeningToGetBalance_Customer'
- +N' From Customer'
- +N' Where ID_Customer Is Not Null'
- if(@StartNo_Customer Is Not Null)
- set @sqlCmd=@sqlCmd+N' And No_Customer >= '+nchar(39)+@StartNo_Customer+nchar(39)
- if(@EndNo_Customer Is Not Null)
- set @sqlCmd=@sqlCmd+N' And No_Customer <= '+nchar(39)+@EndNo_Customer+nchar(39)
- set @sqlCmd=@sqlCmd+N' ) A'
- +N' Left Join'
- +N' ('
- +N' Select ID_Customer'
- +N' ,Sum(Amount_PreGet) As BiginBalance_PreGet'
- +N' From PreGet'
- +N' Where PreGet.ID_Assessor Is Not Null'
- if (@StartDate Is Not Null)
- set @sqlCmd=@sqlCmd+N' And DateDiff(day,'+nchar(39)+convert(nvarchar(64),@StartDate)+nchar(39)+N',Date_PreGet) <=0 '
- set @sqlCmd=@sqlCmd+N' Group By ID_Customer'
- +N' )B On B.ID_Customer = A.ID_Customer'
- +N' Left Join'
- +N' ('
- +N' Select ID_Customer'
- +N' ,Sum(Amount_SaleBill) As Amount_SaleBill'
- +N' From SaleBill'
- +N' Where SaleBill.ID_Assessor Is Not Null'
- if (@StartDate Is Not Null)
- set @sqlCmd=@sqlCmd+N' And DateDiff(day,'+nchar(39)+convert(nvarchar(64),@StartDate)+nchar(39)+N',Date_SaleBill) <=0 '
- set @sqlCmd=@sqlCmd+N' Group By ID_Customer'
- +N' ) C On C.ID_Customer = A.ID_Customer'
- +N' Left Join'
- +N' ('
- +N' Select ID_Customer'
- +N' ,Sum(Amount_SaleRtnBill) As Amount_SaleRtnBill'
- +N' From SaleRtnBill'
- +N' Where SaleRtnBill.ID_Assessor Is Not Null'
- if (@StartDate Is Not Null)
- set @sqlCmd=@sqlCmd+N' And DateDiff(day,'+nchar(39)+convert(nvarchar(64),@StartDate)+nchar(39)+N',Date_SaleRtnBill) <=0 '
- set @sqlCmd=@sqlCmd+N' Group By ID_Customer'
- +N' ) D On D.ID_Customer = A.ID_Customer'
- +N' Union All'
- +N' Select No_Customer'
- +N' ,ShortName_Customer'
- +N' ,'+nchar(39)+'销货单'+nchar(39)+N' As BillType'
- +N' ,No_SaleBill As BillNo'
- +N' ,Date_SaleBill As BillDate'
- +N' ,0 As PrePayMoney'
- +N' ,Amount_SaleBill As ToGetMoney'
- +N' ,0 As Balance'
- +N' From SaleBill'
- +N' Left Join Customer On Customer.ID_Customer = SaleBill.ID_Customer'
- +N' Where SaleBill.ID_Assessor Is Not Null'
- if(@StartDate Is Not Null)
- set @sqlCmd=@sqlCmd+N' And DateDiff(day,'+nchar(39)+convert(nvarchar(64),@StartDate)+nchar(39)+N',Date_SaleBill) >=0 '
- if(@EndDate Is Not Null)
- set @sqlCmd=@sqlCmd+N' And DateDiff(day,'+nchar(39)+convert(nvarchar(64),@EndDate)+nchar(39)+N',Date_SaleBill) <=0 '
- if(@StartNo_Customer Is Not Null)
- set @sqlCmd=@sqlCmd+N' And No_Customer >= '+nchar(39)+@StartNo_Customer+nchar(39)
- if(@EndNo_Customer Is Not Null)
- set @sqlCmd=@sqlCmd+N' And No_Customer <= '+nchar(39)+@EndNo_Customer+nchar(39)
- set @sqlCmd=@sqlCmd+N' Union All'
- +N' Select No_Customer'
- +N' ,ShortName_Customer'
- +N' ,'+nchar(39)+'退货单'+nchar(39)+N' As BillType'
- +N' ,No_SaleRtnBill As BillNo'
- +N' ,Date_SaleRtnBill As BillDate'
- +N' ,0 As PrePayMoney'
- +N' ,Amount_SaleRtnBill As ToGetMoney'
- +N' ,0 As Balance'
- +N' From SaleRtnBill'
- +N' Left Join Customer On Customer.ID_Customer = SaleRtnBill.ID_Customer'
- +N' Where SaleRtnBill.ID_Assessor Is Not Null And IsPrevBill_SaleRtnBill = 0'
- if(@StartDate Is Not Null)
- set @sqlCmd=@sqlCmd+N' And DateDiff(day,'+nchar(39)+convert(nvarchar(64),@StartDate)+nchar(39)+N',Date_SaleRtnBill) >=0 '
- if(@EndDate Is Not Null)
- set @sqlCmd=@sqlCmd+N' And DateDiff(day,'+nchar(39)+convert(nvarchar(64),@EndDate)+nchar(39)+N',Date_SaleRtnBill) <=0 '
- if(@StartNo_Customer Is Not Null)
- set @sqlCmd=@sqlCmd+N' And No_Customer >= '+nchar(39)+@StartNo_Customer+nchar(39)
- if(@EndNo_Customer Is Not Null)
- set @sqlCmd=@sqlCmd+N' And No_Customer <= '+nchar(39)+@EndNo_Customer+nchar(39)
- set @sqlCmd=@sqlCmd+N' Union All'
- +N' Select No_Customer'
- +N' ,ShortName_Customer'
- +N' ,'+nchar(39)+'预收帐款'+nchar(39)+N' As BillType'
- +N' ,No_PreGet As BillNo'
- +N' ,Date_PreGet As BillDate'
- +N' ,Amount_PreGet As PrePayMoney'
- +N' ,0 As ToGetMoney'
- +N' ,0 As Balance'
- +N' From PreGet'
- +N' Left Join Customer On Customer.ID_Customer = PreGet.ID_Customer'
- +N' Where PreGet.ID_Assessor Is Not Null'
- if(@StartDate Is Not Null)
- set @sqlCmd=@sqlCmd+N' And DateDiff(day,'+nchar(39)+convert(nvarchar(64),@StartDate)+nchar(39)+N',Date_PreGet) >=0 '
- if(@EndDate Is Not Null)
- set @sqlCmd=@sqlCmd+N' And DateDiff(day,'+nchar(39)+convert(nvarchar(64),@EndDate)+nchar(39)+N',Date_PreGet) <=0 '
- if(@StartNo_Customer Is Not Null)
- set @sqlCmd=@sqlCmd+N' And No_Customer >= '+nchar(39)+@StartNo_Customer+nchar(39)
- if(@EndNo_Customer Is Not Null)
- set @sqlCmd=@sqlCmd+N' And No_Customer <= '+nchar(39)+@EndNo_Customer+nchar(39)
- set @sqlCmd=@sqlCmd+N' Order By No_Customer,BillNo,BillDate'
- EXECUTE sp_executesql @sqlCmd">
- <Params>
- <Param name="@StartDate" type="SaleBill.Date_SaleBill" Index="0" />
- <Param name="@EndDate" type="SaleBill.Date_SaleBill" Index="1" />
- <Param name="@StartNo_Customer" type="Customer.No_Customer" Index="2" />
- <Param name="@EndNo_Customer" type="Customer.No_Customer" Index="3" />
-
- </Params>
- <Tables>
- <Table name="FrmCustomerAccountStatistics"/>
- </Tables>
- </SearchCustomerAccountStatistics>
- </Search>
- </Server>
- </Form>
- </Forms>
|