<%@ WebService Language="C#" Class="checkisnewmsg" %> using System; using System.Web; using System.Web.Services; using System.Web.Services.Protocols; using System.Data; [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] //若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。 [System.Web.Script.Services.ScriptService] public class checkisnewmsg : System.Web.Services.WebService { [WebMethod(EnableSession = true)] public int chckisnew() { int newcount = 0; int ts = 0; Maticsoft.Model.nr_z_yhzh user = (Maticsoft.Model.nr_z_yhzh)(Session["user"]); int juese = user.juese; int zhid = user.id; /*-------------------------订单提醒-----------------------------*/ //订单的提醒 if (DBHlper.GetPermission(juese, "订单管理", "nr_z_dd", "查看全部")) { //查看待提交条数 if (DBHlper.GetPermission(juese, "订单管理", "nr_z_dd", "提交个人") || DBHlper.GetPermission(juese, "订单管理", "nr_z_dd", "提交全部")) { ts = DBHlper.getcount("select count(*) from view_nr_z_dd where ddzt='草稿'"); if (ts > 0) { newcount += chckmsgdata(1, zhid, ts); } } //查看待审核条数 if (DBHlper.GetPermission(juese, "订单管理", "nr_z_dd", "审核")) { ts = DBHlper.getcount("select count(*) from view_nr_z_dd where ddzt='待审'"); if (ts > 0) { newcount += chckmsgdata(2, zhid, ts); } } } else if (DBHlper.GetPermission(juese, "订单管理", "nr_z_dd", "查看个人")) { //查看个人待提交条数 if (DBHlper.GetPermission(juese, "订单管理", "nr_z_dd", "提交个人") || DBHlper.GetPermission(juese, "订单管理", "nr_z_dd", "提交全部")) { ts = DBHlper.getcount("select count(*) from view_nr_z_dd where ddzt='草稿' where ywy='" + user.zhanghao + "'"); if (ts > 0) { newcount += chckmsgdata(1, zhid, ts); } } //查看个人待审核条数 if (DBHlper.GetPermission(juese, "订单管理", "nr_z_dd", "审核")) { ts = DBHlper.getcount("select count(*) from view_nr_z_dd where ddzt='待审' where ywy='" + user.zhanghao + "'"); if (ts > 0) { newcount += chckmsgdata(2, zhid, ts); } } } /*---------------------------------生成单提醒---------------------------------------*/ if (DBHlper.GetPermission(juese, "生产施工单", "nr_z_scd", "查看全部")) { ts = DBHlper.getcount("select count(*) from view_nr_z_scd where scdzt='未开工' "); if (ts > 0) { newcount += chckmsgdata(3, zhid, ts); } ts = DBHlper.getcount("select count(*) from view_nr_z_scd where scdzt='暂停' "); if (ts > 0) { newcount += chckmsgdata(4, zhid, ts); } } /*---------------------------------申购单提醒---------------------------------------*/ if (DBHlper.GetPermission(juese, "物料需求单", "nr_z_shengoudan", "查看全部")) { ts = DBHlper.getcount("select count(*) from view_nr_z_shengoudan where cgzt='待采购' and zt='审核通过'"); if (ts > 0) { newcount += chckmsgdata(6, zhid, ts); } } /*---------------------------------采购待入库提醒---------------------------------------*/ if (DBHlper.GetPermission(juese, "采购待入库", "view_nr_z_cgddrk", "查看全部")) { ts = DBHlper.getcount("select count(*) from view_nr_z_cgddrk"); if (ts > 0) { newcount += chckmsgdata(7, zhid, ts); } } /*---------------------------------最高库存提醒---------------------------------------*/ if (DBHlper.GetPermission(juese, "库存查询", "view_nr_z_kc", "查看全部")) { ts = DBHlper.getcount("select COUNT(*) from dbo.view_nr_z_kc where (zuidkucun>0 and zuidkucun>0) and kucun>zuigkucun"); if (ts > 0) { newcount += chckmsgdata(8, zhid, ts); } } /*---------------------------------最低库存提醒---------------------------------------*/ if (DBHlper.GetPermission(juese, "库存查询", "view_nr_z_kc", "查看全部")) { ts = DBHlper.getcount("select COUNT(*) from dbo.view_nr_z_kc where (zuidkucun>0 and zuidkucun>0)and kucun 0) { newcount += chckmsgdata(9, zhid, ts); } } /*---------------------------------订单到期收款提醒---------------------------------------*/ if (DBHlper.GetPermission(juese, "订单管理", "nr_z_dd", "查看全部")) { if (DBHlper.GetPermission(juese, "订单收款", "nr_z_dd_fysk", "查看个人")) { ts = DBHlper.getcount("select COUNT(*) from view_nr_z_dd as dd,view_nr_z_dd_wfkd as ddsk where dd.jzrq>='"+DateTime.Now.ToShortDateString()+"' and ddsk.wsje>0 and dd.bh=ddsk.bh and ddsk.ywy='"+user.zhanghao+"'"); } else if (DBHlper.GetPermission(juese, "订单收款", "nr_z_dd_fysk", "查看全部")) { ts = DBHlper.getcount("select COUNT(*) from view_nr_z_dd as dd,view_nr_z_dd_wfkd as ddsk where dd.jzrq>='" + DateTime.Now.ToShortDateString() + "' and ddsk.wsje>0 and dd.bh=ddsk.bh"); } if (ts > 0) { newcount += chckmsgdata(10, zhid, ts); } } else if (DBHlper.GetPermission(juese, "订单管理", "nr_z_dd", "查看个人")) { if (DBHlper.GetPermission(juese, "订单收款", "nr_z_dd_fysk", "查看个人")) { ts = DBHlper.getcount("select COUNT(*) from view_nr_z_dd as dd,view_nr_z_dd_wfkd as ddsk where dd.jzrq>='" + DateTime.Now.ToShortDateString() + "' and ddsk.wsje>0 and dd.bh=ddsk.bh and ddsk.ywy='" + user.zhanghao + "' and dd.ywy='" + user.zhanghao + "' "); } else if (DBHlper.GetPermission(juese, "订单收款", "nr_z_dd_fysk", "查看全部")) { ts = DBHlper.getcount("select COUNT(*) from view_nr_z_dd as dd,view_nr_z_dd_wfkd as ddsk where dd.jzrq>='" + DateTime.Now.ToShortDateString() + "' and ddsk.wsje>0 and dd.bh=ddsk.bh and dd.ywy='" + user.zhanghao + "' "); } if (ts > 0) { newcount += chckmsgdata(10, zhid, ts); } } int noviewcount= DBHlper.getcount("select count(*) from nr_z_sysmsg where msgval>0 and isview=0 and userid="+user.id); if (noviewcount > 0) { newcount++; } return newcount; } protected int chckmsgdata(int msgtype, int userid, int ts) { int newcount = 0; DataTable msgdt = new DataTable(); msgdt = DBHlper.Execute("select id,msgval from nr_z_sysmsg where msgtype=" + msgtype + " and userid=" + userid).Tables[0]; string msgtypestr = DBHlper.getfirstcolmn("select msgtype from nr_z_sysmsgtype where id=" + msgtype); string msgurl = DBHlper.getfirstcolmn("select url from nr_z_sysmsgtype where id=" + msgtype); if (msgdt.Rows.Count > 0) { int ddtjval = Convert.ToInt32(msgdt.Rows[0]["msgval"]); if (ts > ddtjval || ts 0) { state = dt.Rows[0]["formstate"].ToString() + "," + dt.Rows[0]["videostate"].ToString(); } string vdname= DBHlper.getfirstcolmn("select top 1 filename from nr_z_video where isqiyong=1"); state += "," + vdname; return state; } }