hyperion查询代码实例

//将2009年06月02日,转换成20090602
function Fun_formatTimeNumber(Str1){
	// 分离出年份
	sYear1=eval(Str1.substr(0,4));

	// 分离出月份
	sMonth1=Str1.substr(5,2);

	// 分离出日期
	sDay1=Str1.substr(8,2);
	var newStr = sYear1+sMonth1+sDay1;
                   return  newStr
}
formatTimeNumber = Fun_formatTimeNumber

//知道某年某月,然后获得这个月有多少天
function Fun_DayNumOfMonth(Year,Month)
{
    Month--;
    var d = new Date(Year,Month,1);
    d.setDate(d.getDate()+32-d.getDate());
    return (32-d.getDate());
}
dayNumOfMonth = Fun_DayNumOfMonth;


//简单的实例代码
var str1=text_日1.Text
var str2=text_日2.Text
var str1Temp=str1
var str2Temp=str2
var searchValue=""
var quyu=select_区域.Item(select_区域.SelectedIndex)
//Application.Alert(quyu)  
var searchValue="日"

if(月查询.Checked==true){
	// 分离出年份
	sYear1=eval(str2.substr(0,4));
	// 分离出月份
	sMonth1=str2.substr(5,2);
	var daycount= dayNumOfMonth(sYear1,sMonth1)
	str1=str1+"-01";
	str2=str2+"-"+daycount;

	//用作校验
	str1Temp  = str1;
	str2Temp = str2;

	searchValue="月"
}

//Application.Alert(str1Temp  +"   "+str2Temp );

if(compareDate(str1Temp,str2Temp)>=0){
	var days=new Array();

	time1=formatTime(str1);
	time2=formatTime(str2);
	
	var starTime = formatTimeNumber(str1);
	var endTime = formatTimeNumber(str2);
		
	ActiveDocument.Sections["卷烟等级查询"].ResetCustomSQL();

                   var formStr = " FROM From.Fact_Tel_Sale_Aggr, From.Dim_Tel_Sale_Cigarette, From.Dim_Tel_Sale_Area ";
	
	ActiveDocument.Sections["卷烟等级查询"].CustomSQLFrom(formStr);

	var whereStr = " WHERE  Dim_Tel_Sale_Cigarette.Cig_Id=Fact_Tel_Sale_Aggr.Cig_Id AND Dim_Tel_Sale_Area.Area_Id=Fact_Tel_Sale_Aggr.Area_Id  and (Fact_Tel_Sale_Aggr.time_id between "+starTime+"  and "+endTime+")";
	
	if(select_区域.SelectedIndex!=1){
		whereStr+=" and (Dim_Tel_Sale_Area.area_name = '"+quyu+"') ";
	} 

	var groupStr = " GROUP  BY Dim_Tel_Sale_Area.AREA_NAME, Dim_Tel_Sale_Cigarette.GRADE,Fact_Tel_Sale_Aggr.time_id";
	ActiveDocument.Sections["卷烟等级查询"].CustomSQLWhere(whereStr+groupStr);

	ActiveDocument.Sections["卷烟等级查询"].Process();

	ActiveDocument.Sections["卷烟等级结果"].Columns.ModifyComputed("日期","\"\"");
	ActiveDocument.Sections["卷烟等级结果"].Columns.ModifyComputed("日期",searchValue);
	
	var rowcount  =  ActiveDocument.Sections["卷烟等级结果"].RowCount;
	if(rowcount==0){
		Application.Alert("没有数据,请更改搜索条件重新查询!");
	}
	
}

你可能感兴趣的:(js)