begin sql1 := 'select isnull(a.ks_name,b.ks_name) as q,isnull(a.TotalZhichu,0) as w,isnull(b.TotalShouru,0) as e from ';
sql1 :=sql1+'(select ks_name,sum(zhichujine) as TotalZhichu from yz_qyzc where 1>0' +s1+ 'group by ks_name) a full join(select ks_name,sum(fyje) as TotalShouru from yz_qysr where 1>0 '+s1+' group by ks_name) b on a.ks_name=b.ks_name where 1>0 '; if (ComboBox1.Text <> '') and (ComboBox1.Text <> '全院科室') then
begin
sql1 := sql1+ ' and a.ks_name='+''''+trim(ComboBox1.Text)+'''';
end;
if RadioButton1.Checked = true then
begin
s1 := 'and fydate>= '+''''+datetostr(DateTimePicker1.Date)+'''' + 'and fydate<= '+''''+datetostr(DateTimePicker2.Date)+'''';
end;
if RadioButton4.Checked = true then
begin
if ComboBox10.Text <> '' then
begin s1 := ' and fydate like '+ ''''+'%'+trim(ComboBox10.Text)+'%'+'''';
end; end;
if RadioButton2.Checked = true then
begin
if (ComboBox4.Text <> '')and (ComboBox5.Text <> '')and(ComboBox6.Text <> '')and(ComboBox7.Text <> '')then
begin
MyDate1 := EncodeDate(StrToInt(ComboBox4.Text), StrToInt(ComboBox5.Text), 1);
if ComboBox7.Text <> '12' then
begin
MyDate2 := EncodeDate(StrToInt(ComboBox6.Text), (StrToInt(ComboBox7.Text)+1), 1) end else
begin
MyDate2 := EncodeDate(StrToInt(ComboBox6.Text), 12, 31);
end;
if MyDate1 <= MyDate2 then
begin
time1 := DateToStr(MyDate1);
time2 := DateToStr(MyDate2);
s1 := ' and fydate>= '+''''+time1 +'''' + 'and fydate<= '+''''+time2+'''' ;
end
else begin
MessageBox(Handle, PChar('查询日期范围不正确!'), PChar('提示'), MB_OK);
exit;
ComboBox4.SetFocus;
end; end;
end;
不好意思 代码有点长 我就是想加个按时间查询 但是“s1”这个字段执行的时候根本就没用上 不知道哪错了
sql1 :=sql1+'(select ks_name,sum(zhichujine) as TotalZhichu from yz_qyzc where 1>0' +s1+ 'group by ks_name) a full join(select ks_name,sum(fyje) as TotalShouru from yz_qysr where 1>0 '+s1+' group by ks_name) b on a.ks_name=b.ks_name where 1>0 '; if (ComboBox1.Text <> '') and (ComboBox1.Text <> '全院科室') then
begin
sql1 := sql1+ ' and a.ks_name='+''''+trim(ComboBox1.Text)+'''';
end;
if RadioButton1.Checked = true then
begin
s1 := 'and fydate>= '+''''+datetostr(DateTimePicker1.Date)+'''' + 'and fydate<= '+''''+datetostr(DateTimePicker2.Date)+'''';
end;
if RadioButton4.Checked = true then
begin
if ComboBox10.Text <> '' then
begin s1 := ' and fydate like '+ ''''+'%'+trim(ComboBox10.Text)+'%'+'''';
end; end;
if RadioButton2.Checked = true then
begin
if (ComboBox4.Text <> '')and (ComboBox5.Text <> '')and(ComboBox6.Text <> '')and(ComboBox7.Text <> '')then
begin
MyDate1 := EncodeDate(StrToInt(ComboBox4.Text), StrToInt(ComboBox5.Text), 1);
if ComboBox7.Text <> '12' then
begin
MyDate2 := EncodeDate(StrToInt(ComboBox6.Text), (StrToInt(ComboBox7.Text)+1), 1) end else
begin
MyDate2 := EncodeDate(StrToInt(ComboBox6.Text), 12, 31);
end;
if MyDate1 <= MyDate2 then
begin
time1 := DateToStr(MyDate1);
time2 := DateToStr(MyDate2);
s1 := ' and fydate>= '+''''+time1 +'''' + 'and fydate<= '+''''+time2+'''' ;
end
else begin
MessageBox(Handle, PChar('查询日期范围不正确!'), PChar('提示'), MB_OK);
exit;
ComboBox4.SetFocus;
end; end;
end;
不好意思 代码有点长 我就是想加个按时间查询 但是“s1”这个字段执行的时候根本就没用上 不知道哪错了
解决方案 »
- FastReport行的问题
- cxShellListView哪个属性是获取当前所显示文件列表数据?
- 修改窗体颜色的问题???????????????????
- 急:开发背单词软件, 给点意见,
- zytangzhou进来领分,呵呵!
- 怎样在第三方控件添加到delphi里面呀
- 高手請進.分不夠再加
- 高手请入:为什么不能用dbgrid1.column[0].color:=colorcombobox1.color这样来给column控制颜色?
- delphi6企业版的安装文件有多大?是135m吗
- isc组件中的TSSLHTTPCli进行post提交数据
- 问个算法设置软件的使用天数
- 求dsEditModes的用法
sql1 :=sql1+'(select ks_name,sum(zhichujine) as TotalZhichu from yz_qyzc where 1>0' +s1+ 'group by ks_name) a full join(select ks_name,sum(fyje) as TotalShouru from yz_qysr where 1>0 '+s1+' group by ks_name) b on a.ks_name=b.ks_name '; if RadioButton1.Checked = true then
begin
s1 := 'and fydate>= '+''''+datetostr(DateTimePicker1.Date)+'''' + 'and fydate<= '+''''+datetostr(DateTimePicker2.Date)+'''';
end;
看这段就行了
我只看出你多了个from