永发信息网

比较难的问题

答案:1  悬赏:0  手机版
解决时间 2021-05-07 08:50
我在PFC 中的datawindow的filter过滤服务,后台是用的sql server ,SQL SERVER 中没有date类型,我的日期都是用的datetime类型,但在我的datawindow中有二个是日期类型,格式是yyyy-mm-dd(计划日期),和yyyy-mm-dd hh:mm(实际时间)
现在我要忽略实际时间的具体时间,让计划日期和实际时间都可以按yyyy-mm-dd过滤。下面是我修改的两个函数一个是n_tr中的,一个是PFCfiltersimple中的,
现在可忽略了方yyyy-mm-dd中的时间但是还不能实现yyyy-mm-dd hh:mm中的过滤,请问怎么解决!

//////////////////////////////////////////////////////////////////////////////
// Public Function: of_DistinctValues
// Arguments: as_table: a SQL table name
// as_column: a database column name in passed SQL table
// as_values: string array, passed by reference to hold the returned values
// Returns: long - the SQLCode based on the SQL fetch
// Description: Get the distinct values from the database
//////////////////////////////////////////////////////////////////////////////
// Rev. History Version
// 5.0 Initial version
//////////////////////////////////////////////////////////////////////////////
// Copyright ?1996-1999 Sybase, Inc. and its subsidiaries. All rights reserved. Any distribution of the
// PowerBuilder Foundation Classes (PFC) source code by other than Sybase, Inc. and its subsidiaries is prohibited.
//////////////////////////////////////////////////////////////////////////////
long ll_rc
string ls_sqlstatement
string ls_value
string ls_name

// Build the SQL Select statement
ls_sqlstatement = "SELECT DISTINCT " + as_column + " FROM " + as_table

// If SQLSpy service is on, add to the history
if IsValid (gnv_app) then
if IsValid(gnv_app.inv_debug) then
if IsValid (gnv_app.inv_debug.inv_sqlspy) then
ls_name = this.is_Name
if Len (ls_name) = 0 then
ls_name = this.ClassName()
end if
gnv_app.inv_debug.inv_sqlspy.of_SQLSyntax &
("Dynamic SQL using " + ls_name, ls_sqlstatement)
end if
end if
end if

// Execute the SQL
prepare sqlsa from :ls_sqlstatement using this;
describe sqlsa into sqlda;
declare c_values_cursor dynamic cursor for sqlsa;
open dynamic c_values_cursor using descriptor sqlda;
fetch c_values_cursor using descriptor sqlda;
ll_rc = this.SQLCode

// Retrieve the distinct values and add them to the array
do while this.SQLCode = 0
choose case sqlda.OutParmType[1]
case TypeString!
ls_value = GetDynamicString (sqlda, 1)
case TypeDate!
ls_value = String (GetDynamicDate (sqlda, 1))
case TypeTime!
ls_value = String (GetDynamicTime (sqlda, 1))
case TypeDateTime!
//此处我更改了
ls_value = String (date(GetDynamicDateTime (sqlda, 1)))
case else
ls_value = String (GetDynamicNumber (sqlda, 1))
end choose

as_values[UpperBound(as_values)+1] = ls_value
fetch c_values_cursor using descriptor sqlda;
ll_rc = this.SQLCode
loop

close c_values_cursor;

return ll_rc


//////////////////////////////////////////////////////////////////////////////
//
// Function: of_BuildfilterString
//
// Access: Public
//
// Arguments: None
//
// Returns: String
// The new filter string.
// '!' if an error is encountered.
//
// Description: This function will build a valid datawindow filter string
// from the values entered in the filter selection datawindow.
//
//////////////////////////////////////////////////////////////////////////////
//
// Revision History
//
// Version
// 5.0 Initial version
// 5.0.03 Corrected to check/build for all column types.
// 7.0 Added "char" datatype to case statement
//
//////////////////////////////////////////////////////////////////////////////
//
// Copyright ?1996-1997 Sybase, Inc. and its subsidiaries. All rights reserved.
// Any distribution of the PowerBuilder Foundation Classes (PFC)
// source code by other than Sybase, Inc. and its subsidiaries is prohibited.
//
//////////////////////////////////////////////////////////////////////////////

string ls_exp_left, ls_oper, ls_value, ls_colname, ls_filter, ls_and_or
string ls_coltype, ls_expression
integer li_i, li_rcount, li_foundrow
n_cst_string lnv_string

// Accept the latest changes.
If dw_filter.AcceptText() <> 1 Then Return '!'

// Get the values from the filter datawindow.
li_rcount = dw_filter.RowCount ( )
FOR li_i = 1 to li_rcount

// Construct the left side of the expression.
ls_exp_left = dw_filter.GetItemString ( li_i, "colname" )
IF IsNull(ls_exp_left) THEN ls_exp_left = ""
IF ls_exp_left <> "" AND li_i > 1 THEN
ls_filter = ls_filter + " " + ls_and_or
END IF

// Construct the operator.
ls_oper = dw_filter.GetItemString ( li_i, "oper" )
IF IsNull(ls_oper) THEN ls_oper = ""

// Get the value.
ls_value = dw_filter.GetItemString ( li_i, "colvalue" )
IF IsNull (ls_value) THEN ls_value = ""

// Construct the "AND" or "OR" for the expression.
ls_and_or = dw_filter.GetItemString (li_i, "and_or" )
IF IsNull(ls_and_or) THEN ls_and_or = ""

// Get the column name.
li_foundrow = idwc_cols.Find ('display_column = "' + ls_exp_left + '"', &
1, idwc_cols.RowCount ())
IF li_foundrow > 0 THEN
ls_colname = idwc_cols.GetItemString(li_foundrow, "columnname")
ELSE
ls_colname = ls_exp_left
END IF

// Get the column type.
ls_coltype = Left(inv_filterattrib.idw_dw.Describe ( ls_colname + ".ColType" ), 5)

// Determine the correct expression.
Choose Case ls_coltype
// CHARACTER DATATYPE
Case "char(", "char"
If Pos(ls_value, '~~~"') =0 And Pos(ls_value, "~~~'") =0 Then
// No special characters found.
If Pos(ls_value, "'") >0 Then
// Replace single quotes with special chars single quotes.
ls_value = lnv_string.of_GlobalReplace(ls_value, "'", "~~~'")
End If
End If
ls_expression = "'" + ls_value + "'"

// DATE DATATYPE
Case "date"
ls_expression = "Date('" + ls_value + "')"

// DATETIME DATATYPE
Case "datet"
// ls_expression = "DateTime('" + ls_value + "')"
//此处也更新了
ls_expression = "date('" + ls_value + "')"
// ls_expression = "date('" + string(Date(left(ls_value,len(ls_value)-8)), "yyyy-mm-dd") + "')"

// TIME DATATYPE
Case "time", "times"
ls_expression = "Time('" + ls_value + "')"

// NUMBER
Case Else
ls_expression = ls_value
End Choose

// Build the filter string.
ls_filter += " " + ls_colname + " " + ls_oper + " " + ls_expression
NEXT

Return Trim(ls_filter)
最佳答案
不好意思,这个我不太明白你说的是什么意思...
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
金山毒霸通行证到期了怎么办?
剑圣+屠夫拉锯什么装备最高攻最高防
蜱虫在什么季节最活跃?!咬到人什么感觉?咬
顺惠食品平价商行这个地址在什么地方,我要处
怀孕能吃溜吗?
宁陵县商丘宁陵县人民检察院反贪贿赂局哪位知
那些人值得自己好好去珍惜呢。
雪压青松松托雪,霜打红梅梅傲霜。 对下联
深圳龙岗区布吉风门幼工业区在哪?
请问:王心凌的原名是?
ps2有什么好玩得游戏啊~~~!
尼尔多塔神之王称号怎么来的?
QQ抢车位,别人车停你车场会对你有损失么
例:已知代数式9-6y-4y²的值是7,求代数
浜中桥地址在什么地方,想过去办事
推荐资讯
现在什么电视剧电影最好看?
什么是网络繁忙
abieu什么意思
我想要一只130代的企鹅
为什么我家电脑一玩飞车就蓝屏 上面有好多字
去哪看全运摔跤比赛?从全福立交桥做多少路车
数码相机哪种牌子的好?带音乐播放的。
VB ListView1写入ACCESS数据
bbox非洲鼓组成音中无气R做法?
卫生间的门正 对 着房门
怎么样让青春拥有阳光
这样的男人还有吗?
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?