stringisexits=string.Format("select count(*) from nr_lt_paixu where userid='{0}' and tblname='{1}'",zhanghao.id,"view_nr_z_scjd");
intexitscount=DBHlper.getcount(isexits);
if(exitscount>0)
{
stringpaixuselct=string.Format("select * from nr_lt_paixu where userid='{0}' and tblname='{1}' and isxianshi={2} order by shuixu ",zhanghao.id,"view_nr_z_scjd",1);
wherecode+=string.Format(" from view_nr_z_scjd where "+tiaojian+" id not in(select top ({0}*{1}) id from view_nr_z_scjd "+" where "+tiaojian+" 1=1 "+paixu+")"+paixu,pg,pageitem);
DataSetgjds=DBHlper.Execute("select * from view_bianma where zhonglei='工序项目' and zt='1'");
if(gjds!=null&gjds.Tables[0].Rows.Count>0)
{
/*-----制模工序时候获取登记信息------*/
//需产总数量
stringxcsl=DBHlper.getfirstcolmn("select isnull(sum(xcmj),0) from nr_z_mjzld where scdbh='"+dt_paixu.Rows[i]["scbh"]+"' and xmid='"+dt_paixu.Rows[i]["id"]+"' and pm='"+dt_paixu.Rows[i]["cpmc"]+"'");
//已登记总数量
stringdjzsl=DBHlper.getfirstcolmn("select isnull(SUM(djsl),0) from nr_z_scdj_djjl where scxmid='"+dt_paixu.Rows[i]["id"]+"'and djgx='制模'");
//已下发总数量
stringyxfzsl=DBHlper.getfirstcolmn("select isnull(SUM(xfsl),0) from nr_z_scdj_xf where scxmid='"+dt_paixu.Rows[i]["id"]+"' and dqgx='制模' and xfgx=(select top 1 xfgx from nr_z_scdj_xf where dqgx='制模')");
//已报废总数量
stringybfzsl=DBHlper.getfirstcolmn("select isnull(SUM(bfsl),0) from nr_z_scdj_djjl where scxmid='"+dt_paixu.Rows[i]["id"]+"' and djgx='制模'");
xcsl=DBHlper.getfirstcolmn("select isnull(SUM(xfsl),0) from nr_z_scdj_xf where scxmid='"+dt_paixu.Rows[i]["id"]+"' and xfgx='"+dr["mingcheng"]+"'");
//已登记总数量
djzsl=DBHlper.getfirstcolmn("select isnull(SUM(djsl),0) from nr_z_scdj_djjl where scxmid='"+dt_paixu.Rows[i]["id"]+"'and djgx='"+dr["mingcheng"]+"'");
//已下发总数量
yxfzsl=DBHlper.getfirstcolmn("select isnull(SUM(xfsl),0) from nr_z_scdj_xf where scxmid='"+dt_paixu.Rows[i]["id"]+"' and dqgx='"+dr["mingcheng"]+"' and xfgx=(select top 1 xfgx from nr_z_scdj_xf where dqgx='"+dr["mingcheng"]+"')");
//已报废总数量
ybfzsl=DBHlper.getfirstcolmn("select isnull(SUM(bfsl),0) from nr_z_scdj_djjl where scxmid='"+dt_paixu.Rows[i]["id"]+"' and djgx='"+dr["mingcheng"]+"'");
stringcmdinsert=string.Format("insert into nr_lt_paixu values('{0}','{1}','{2}','{3}',{4},{5})",zhanghao.id,"view_nr_z_scjd",liedr["ywlieming"],liedr["zwlieming"],lieshuixu,1);
stringupdatepaixu=string.Format("update nr_lt_paixu set shuixu={0},isxianshi={1} where id={2}",codezu[0],codezu[3],idfanhui);
DBHlper.excutecmd(updatepaixu);
}
else
{
stringpaixuinsert=string.Format("insert into nr_paixu (userid,tblname,lieming,zhongwen,shuixu,isxianshi) values('{0}','{1}','{2}','{3}',{4},{5})",yhzh.id,"view_nr_z_scjd",codezu[2],codezu[1],codezu[0],codezu[3]);
stringpaixuselct=string.Format("select * from nr_lt_paixu where userid='{0}' and tblname='{1}' and isxianshi={2} order by shuixu ",zhanghao.id,"view_nr_z_scjd",1);
cmd=string.Format("select CONVERT(varchar(12),riqi,111) as 'riqi' from view_nr_z_scjd where riqi>='{0}' and riqi<='{1}' ",yuechu,yuemo);
}
else{
cmd=string.Format("select CONVERT(varchar(12),riqi,111) as 'riqi' from view_nr_z_scjd where riqi>='{0}' and riqi<='{1}' and zt='{2}' ",yuechu,yuemo,zt);
DataTabledtcolmnname=DBHlper.Execute("select lieming,zhongwen from nr_lt_paixu where tblname='view_nr_z_scjd' and userid='"+((Maticsoft.Model.nr_z_yhzh)Session["user"]).id+"' order by shuixu").Tables[0];
stringtj=strwhere.Value;
foreach(DataRowrindtcolmnname.Rows)
{
colmn+=r["lieming"].ToString()+',';
sList.Add(r["zhongwen"].ToString());
}
colmn=colmn.TrimEnd(',');
stringselectcode="";
if(drp_zt.SelectedItem.Value!="")
{
selectcode="select "+colmn+" from view_nr_z_scjd where zt='"+drp_zt.Text+"'";
}
else{
selectcode="select "+colmn+" from view_nr_z_scjd where 1=1 ";
}
if(tj!="")
{
selectcode+=tj.Replace("where","and");
}
if(selectid!="")
{
selectcode+=" and id in("+selectid.TrimEnd(',')+")";
}
DataTabledt=DBHlper.Execute(selectcode+" order by id desc").Tables[0];
stringpaixuselct=string.Format("select * from nr_lt_paixu where userid='{0}' and tblname='{1}' and isxianshi={2} order by shuixu ",zhanghao.id,"view_nr_z_scjd",1);