paixuselct=string.Format("select * from nr_lt_paixu where userid='{0}' and tblname='{1}' and isxianshi={2} order by shuixu ",zhanghao.id,"view_nr_z_wuliao",1);
}
else{
paixuselct=string.Format("select * from nr_lt_paixu where userid='{0}' and tblname='{1}' and lieming!='kh_bh' and isxianshi={2} order by shuixu ",zhanghao.id,"view_nr_z_wuliao",1);
stringwherecode=string.Format("select top {0} ",pageitem);
foreach(DataRowdtrindtselect.Rows)
{
wherecode+=dtr["lieming"]+",";
}
wherecode+="id";
wherecode+=string.Format(" from view_nr_z_wuliao where "+tiaojian+" id not in(select top ({0}*{1}) id from view_nr_z_wuliao "+" where "+tiaojian+" 1=1 "+paixu+")"+paixu,pg,pageitem);
stringcmdinsert=string.Format("insert into nr_lt_paixu values('{0}','{1}','{2}','{3}',{4},{5})",zhanghao.id,"view_nr_z_wuliao",liedr["ywlieming"],liedr["zwlieming"],lieshuixu,1);
DBHlper.excutecmd(cmdinsert);
}
return"";
}
}
#endregion
#region传入条数返回页数以便前台调用
[Ajax.AjaxMethod]
publicintmaxpage(intcount,stringtj)
{
intfanhuizhi=0;
stringcmd=string.Format("select count(*) from view_nr_z_wuliao "+tj);
stringcmdexits=string.Format("select id from nr_lt_paixu where userid='{0}' and tblname='{1}' and lieming='{2}'",yhzh.id,"view_nr_z_wuliao",codezu[2]);
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_wuliao",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_wuliao",1);
cmd=string.Format("select CONVERT(varchar(12),riqi,111) as 'riqi' from view_nr_z_wuliao where riqi>='{0}' and riqi<='{1}' ",yuechu,yuemo);
}
else{
cmd=string.Format("select CONVERT(varchar(12),riqi,111) as 'riqi' from view_nr_z_wuliao where riqi>='{0}' and riqi<='{1}' and kufang='"+option+"'",yuechu,yuemo);
DataTabledtcolmnname=DBHlper.Execute("select lieming,zhongwen from nr_lt_paixu where tblname='view_nr_z_wuliao' and isxianshi=1 and userid='"+((Maticsoft.Model.nr_z_yhzh)Session["user"]).id+"' order by shuixu").Tables[0];
stringtj=strwhere.Value;
stringselzt=drp_zt.SelectedItem.Value;
foreach(DataRowrindtcolmnname.Rows)
{
if(r["lieming"].ToString()=="kh_bh")
{
if(selzt=="客户纸库")
{
colmn+=r["lieming"].ToString()+',';
sList.Add(r["zhongwen"].ToString());
}
}
else
{
colmn+=r["lieming"].ToString()+',';
sList.Add(r["zhongwen"].ToString());
}
}
colmn=colmn.TrimEnd(',');
stringselectcode="";
if(selzt=="主料库")
{
selectcode="select "+colmn+" from view_nr_z_wuliao where zt='1' and kufang='主料库' ";
}
elseif(selzt=="辅料库")
{
selectcode="select "+colmn+" from view_nr_z_wuliao where zt='1' and kufang='辅料库' ";
}
elseif(selzt=="客户纸库")
{
selectcode="select "+colmn+" from view_nr_z_wuliao where zt='1' and kufang='客户纸库' ";
}
elseif(selzt==""){
selectcode="select "+colmn+" from view_nr_z_wuliao where zt='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];
OleDbDataAdaptermyDa=newOleDbDataAdapter("select * from [Sheet1$]",cnnxls);
DataSetmyDs=newDataSet();
myDa.Fill(myDs);
DataTabledt=myDs.Tables[0];
intdjcount=0;
foreach(DataColumndclmnindt.Columns)
{
if(dclmn.ColumnName=="单价")
{
djcount++;
}
}
if(djcount>0)
{
dt.Columns.Remove("单价");
}
stringerrortishi="";
inti=1;
List<string>listhead=newList<string>();
stringcolumnname="";
stringwhere="";
stringwherecode="insert into nr_z_wuliao (";
intwlbhindex=0;
intckindex=0;
intguigeindex=0;
intpinpaiindex=0;
for(intj=0;j<dt.Columns.Count;j++)
{
columnname=dt.Columns[j].ColumnName;
if(columnname=="物料编号")
{
listhead.Add("wlbh");
wherecode+="wlbh,";
wlbhindex=j;
}
elseif(columnname=="名称")
{
listhead.Add("mingcheng");
wherecode+="mingcheng,";
}
elseif(columnname=="种类")
{
listhead.Add("zhonglei");
wherecode+="zhonglei,";
}
elseif(columnname=="品牌")
{
listhead.Add("pinpai");
wherecode+="pinpai,";
pinpaiindex=j;
}
elseif(columnname=="长度")
{
listhead.Add("changdu");
wherecode+="changdu,";
}
elseif(columnname=="规格")
{
listhead.Add("guige");
wherecode+="guige,";
guigeindex=j;
}
elseif(columnname=="宽度")
{
listhead.Add("kuandu");
wherecode+="kuandu,";
}
elseif(columnname=="单位")
{
listhead.Add("danwei");
wherecode+="danwei,";
}
elseif(columnname=="仓库")
{
listhead.Add("kufang");
wherecode+="kufang,";
ckindex=j;
}
elseif(columnname=="客户编号")
{
listhead.Add("kh_bh");
wherecode+="kh_bh,";
}
elseif(columnname=="最低库存")
{
listhead.Add("zuidkucun");
wherecode+="zuidkucun,";
}
elseif(columnname=="最高库存")
{
listhead.Add("zuigkucun");
wherecode+="zuigkucun,";
}
elseif(columnname=="库存")
{
listhead.Add("kucun");
wherecode+="kucun,";
}
elseif(columnname=="报价")
{
listhead.Add("baojia");
wherecode+="baojia,";
}
elseif(columnname=="备注")
{
listhead.Add("beizhu");
wherecode+="beizhu,";
}
elseif(columnname=="日期")
{
listhead.Add("riqi");
wherecode+="riqi,";
}
elseif(columnname=="金额")
{
listhead.Add("jine");
wherecode+="jine,";
}
wherecode.TrimEnd(',');
}
wherecode=wherecode.TrimEnd(',');
wherecode+=") values(";
where=wherecode;
intwlcount=0;
foreach(DataRowdrindt.Rows)
{
wlcount=DBHlper.getcount(string.Format("select count(*) from view_nr_z_wuliao where wlbh='{0}' and kufang='{1}' and guige='{2}' and pinpai='{3}'",dr[wlbhindex],dr[ckindex],dr[guigeindex],dr[pinpaiindex]));
if(wlcount>0)
{
i++;
continue;
}
for(intt=0;t<listhead.Count;t++)
{
columnname=listhead[t];
if(columnname=="zhonglei")
{
testexits(dr[t].ToString());
if(zhonglei=="")
{
errortishi="第"+i+"行没有此种类";
gongjuzhankai(errortishi);
return;
}
else
{
wherecode+=zhonglei+",";
}
}
elseif(columnname=="changdu")
{
if(dr[t]isDBNull)
{
wherecode+=0+",";
}
elseif(IsNumeric(dr[t]))
{
wherecode+=dr[t]+",";
}
else
{
errortishi="第"+i+"行长度格式不正确";
gongjuzhankai(errortishi);
return;
}
}
elseif(columnname=="kuandu")
{
if(dr[t]isDBNull)
{
wherecode+=0+",";
}
elseif(IsNumeric(dr[t]))
{
wherecode+=dr[t]+",";
}
else
{
errortishi="第"+i+"行宽度格式不正确";
gongjuzhankai(errortishi);
return;
}
}
elseif(columnname=="danwei")
{
testexits(dr[t].ToString());
if(zhonglei=="")
{
errortishi="第"+i+"行没有此单位";
gongjuzhankai(errortishi);
return;
}
else
{
wherecode+=zhonglei+",";
}
}
//else if (columnname == "kufang")
//{
// testexits(dr[t].ToString());
// if (zhonglei == "")
// {
// errortishi = "第" + i + "行没有此库房";
// gongjuzhankai(errortishi);
// }
// else {
// wherecode += zhonglei + ",";
// }
//}
elseif(columnname=="zuidkucun")
{
if(dr[t]isDBNull)
{
wherecode+=0+",";
}
elseif(IsNumeric(dr[t]))
{
wherecode+=dr[t]+",";
}
else
{
errortishi="第"+i+"最低库存格式不正确";
gongjuzhankai(errortishi);
return;
}
}
elseif(columnname=="zuigkucun")
{
if(dr[t]isDBNull)
{
wherecode+=0+",";
}
elseif(IsNumeric(dr[t]))
{
wherecode+=dr[t]+",";
}
else
{
errortishi="第"+i+"最高库存格式不正确";
gongjuzhankai(errortishi);
return;
}
}
elseif(columnname=="kucun")
{
if(dr[t]isDBNull)
{
wherecode+=0+",";
}
elseif(IsNumeric(dr[t]))
{
wherecode+=dr[t]+",";
}
else
{
errortishi="第"+i+"库存格式不正确";
gongjuzhankai(errortishi);
return;
}
}
elseif(columnname=="baojia")
{
if(dr[t]isDBNull)
{
wherecode+=0+",";
}
elseif(IsNumeric(dr[t]))
{
wherecode+=dr[t]+",";
}
else
{
errortishi="第"+i+"报价格式不正确";
gongjuzhankai(errortishi);
return;
}
}
else
{
//if (!(dr[wlbhindex] is DBNull))
//{
// int count = DBHlper.getcount(string.Format("select count(*) from nr_z_wuliao where wlbh='{0}' and kufang='{1}'", dr[wlbhindex], dr[ckindex]));
paixuselct=string.Format("select * from nr_lt_paixu where userid='{0}' and tblname='{1}' and isxianshi={2} order by shuixu ",zhanghao.id,"view_nr_z_wuliao",1);
}
else
{
paixuselct=string.Format("select * from nr_lt_paixu where userid='{0}' and tblname='{1}' and lieming!='kh_bh' and isxianshi={2} order by shuixu ",zhanghao.id,"view_nr_z_wuliao",1);