110,536
社区成员
发帖
与我相关
我的任务
分享
string sql = @"
select tp.fname as 供应商名称,tm.fnumber as 物料编码,tre.fmodel as 规格型号,tre.fname as 物料名称,
pd.Fbillno as 单据编号,pd.FCheckDate as 审核日期 ,pd.fdate as 单据日期,
pod.Fdate as 交货日期,pod.FPrice as 单价,pod.fqty as 数量,
pod.FAmount as 总金额,pod.FTaxAmount as 税额,pod.FAllAmount as 价税合计,(case pd.FStatus when '0' then '保存'
when '1' then '审核' when '3' then '关闭' else null end)as 单据状态
from POOrderEntry pod left join
POOrder pd on pod.FInterID=pd.FInterID left join t_icitemcore tre on tre.fitemid=pod.fitemid
left join t_item tm on tm.fitemid=tre.fitemid left join t_user tu on tu.FuserID=pd.FBillerID
left join t_Supplier tp on tp.fitemid=pd.fsupplyid where 1=1 {0}
union all
select '合计','','','',
'',null,null, null,null,sum(pod.fqty)as 数量, sum(pod.FAmount) as 总金额,sum(pod.FTaxAmount) as 税额,
sum(pod.FAllAmount) as 价税合计,''from POOrderEntry pod left join
POOrder pd on pod.FInterID=pd.FInterID left join t_icitemcore tre on tre.fitemid=pod.fitemid
left join t_item tm on tm.fitemid=tre.fitemid left join t_user tu on tu.FuserID=pd.FBillerID
left join t_Supplier tp on tp.fitemid=pd.fsupplyid where 1=1 {1} "; //添加两个参数进去
String p = comboBox1.Text;
string whr = string.Empty ;
if (!string.IsNullOrEmpty(textBox1.Text))
{
var fstCondition = textBox1.Text.Trim();
if (fstCondition.Length > 0)
whr= whr+ "and tm.fnumber LIKE '%" + textBox1.Text + "%'";
}
......条件部分,你自己补充完整, 將sql 替换成 whr......
if (!string.IsNullOrEmpty(comboBox3.Text))
{
var secCondition10 = comboBox3.Text.Trim();
if (secCondition10.Length > 0)
whr= whr+ "and tp.fname LIKE '%" + comboBox3.Text + "%' ";
}
//添上这句
sql = string.Format(sql, whr, whr);
//调试时,可在上面这句设置断点,拷贝出SQL 语句,去查询分析器里面执行看是否正确。
dateClass del10 = new dateClass();
del10.BindDataGridView(dataGridView1, sql);