public ActionResult SelectData() { string taskcode = ""; string linecode = ""; string bugtype = ""; string buglevel = ""; string time1 = ""; string time2 = ""; string time3 = ""; string time4 = ""; int pageindex = int.Parse(Request.Params["pageindex"]); int skip = (pageindex - 1) * 6; var user = (from u in medc.ps_user where u.id == int.Parse(Session["userid"].ToString()) select u).FirstOrDefault(); var role = (from r in medc.ps_role where r.id == user.roleId select r).FirstOrDefault(); string sql = ""; if (role.roleName == "系统管理员") { sql = "select a.inspectionTaskCode,b.lineCode,b.polecode,b.bugLevelName,b.bugTypeName,b.discovererName,b.discoverTime,a.issuedByName,a.issuedTime,b.intactRate,b.bugDesc from ps_inspectiontask_main a,ps_inspectiontask_detail b where a.id=b.taskid and b.isSolve=0 and b.isBug=1 and a.taskStatus=4 "; } else { sql = "select a.inspectionTaskCode,b.lineCode,b.polecode,b.bugLevelName,b.bugTypeName,b.discovererName,b.discoverTime,a.issuedByName,a.issuedTime,b.intactRate,b.bugDesc from ps_inspectiontask_main a inner join ps_inspectiontask_detail b on a.id=b.taskid inner join ps_inspector_detail c on a.id=c.taskid where b.isSolve=0 and b.isBug=1 and a.taskStatus=4 and c.inspectorCode='" + user.userCode + "' "; } if (Request.Params["taskcode"] != "") { taskcode = Request.Params["taskcode"]; sql += " and a.inspectionTaskCode like '%" + taskcode + "%' "; } if (Request.Params["linecode"] != "") { linecode = Request.Params["linecode"]; sql += " and b.linecode like '%" + linecode + "%'"; } if (Request.Params["buglevel"] != "") { buglevel = Request.Params["buglevel"]; sql += " and b.bugLevel=" + buglevel; } if (Request.Params["bugtype"] != "") { bugtype = Request.Params["bugtype"]; sql += " and b.bugType=" + bugtype; } if (Request.Params["ptime1"] != "") { time1 = Request.Params["ptime1"]; time2 = Request.Params["ptime2"]; sql += " and b.discoverTime>= '" + time1 + "' and b.discoverTime<='" + time2 + "'"; } if (Request.Params["ptime3"] != "") { time3 = Request.Params["ptime3"]; time4 = Request.Params["ptime4"]; sql += " and a.issuedTime>= '" + time3 + "' and a.issuedTime<='" + time4 + "'"; } SqlConnection con = new SqlConnection("server=.;database=MyElectrCheck_DB;Integrated Security=true;"); if (con.State != ConnectionState.Open) { con.Open(); } SqlCommand cmd = new SqlCommand(sql, con); SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); List <InspectorSelect> list = new List <InspectorSelect>(); while (dr.Read()) { InspectorSelect main = new InspectorSelect(); main.taskcode = dr["inspectionTaskCode"].ToString(); main.linecode = dr["lineCode"].ToString(); main.polecode = dr["polecode"].ToString(); main.bugtypename = dr["bugtypename"].ToString(); main.buglevelname = dr["buglevelname"].ToString(); main.discovername = dr["discoverername"].ToString(); main.discovertime = DateTime.Parse(dr["discovertime"].ToString()); main.issuedname = dr["issuedbyname"].ToString(); main.issuedtime = DateTime.Parse(dr["issuedTime"].ToString()); main.intactrate = int.Parse(dr["intactrate"].ToString()); main.bugdesc = dr["bugdesc"].ToString(); list.Add(main); } dr.Close(); con.Close(); DataSource ds = new DataSource(); ds.islist = list.Skip(skip).Take(6).ToList(); ds.pagecount = list.Count(); Session["buglist"] = ds.islist; string jsonstr = JsonConvert.SerializeObject(ds); return(Content(jsonstr)); }
public ActionResult GetData() { int pageindex = int.Parse(Request.Params["pageindex"]); var user = (from u in medc.ps_user where u.id == int.Parse(Session["userid"].ToString()) select u).FirstOrDefault(); var role = (from r in medc.ps_role where r.id == user.roleId select r).FirstOrDefault(); List <InspectorSelect> islist = new List <InspectorSelect>(); if (role.roleName == "系统管理员") { var flawlist = (from a in medc.ps_inspectiontask_main join b in medc.ps_inspectiontask_detail on a.id equals b.taskid where b.isSolve == 0 && b.isBug == 1 && a.taskStatus == 4 select new { taskcode = a.inspectionTaskCode, linecode = a.lineCode, polecode = b.poleCode, buglevelname = b.bugLevelName, bugtypename = b.bugTypeName, discovername = b.discovererName, discovertime = b.discoverTime, issuedname = a.issuedByName, issuedtime = a.issuedTime, intactrate = b.intactRate, bugdesc = b.bugDesc }).ToList(); if (flawlist.Count() > 0) { foreach (var v in flawlist) { InspectorSelect inspeselect = new InspectorSelect() { taskcode = v.taskcode, linecode = v.linecode, polecode = v.polecode, buglevelname = v.buglevelname, bugtypename = v.bugtypename, bugdesc = v.bugdesc, discovername = v.discovername, discovertime = v.discovertime, issuedname = v.issuedname, issuedtime = v.issuedtime, intactrate = v.intactrate }; islist.Add(inspeselect); } } } else { var flawlist = (from a in medc.ps_inspectiontask_main join b in medc.ps_inspectiontask_detail on a.id equals b.taskid join c in medc.ps_inspector_detail on a.id equals c.taskId where b.isSolve == 0 && b.isBug == 1 && a.taskStatus == 4 && c.inspectorCode == user.userCode select new { taskcode = a.inspectionTaskCode, linecode = a.lineCode, polecode = b.poleCode, buglevelname = b.bugLevelName, bugtypename = b.bugTypeName, discovername = b.discovererName, discovertime = b.discoverTime, issuedname = a.issuedByName, issuedtime = a.issuedTime, intactrate = b.intactRate, bugdesc = b.bugDesc }).ToList(); if (flawlist.Count() > 0) { foreach (var v in flawlist) { InspectorSelect inspeselect = new InspectorSelect() { taskcode = v.taskcode, linecode = v.linecode, polecode = v.polecode, buglevelname = v.buglevelname, bugtypename = v.bugtypename, bugdesc = v.bugdesc, discovername = v.discovername, discovertime = v.discovertime, issuedname = v.issuedname, issuedtime = v.issuedtime, intactrate = v.intactrate }; islist.Add(inspeselect); } } } //缺陷类型 var bugtype = (from b in medc.ps_systemconfig where b.configCode == "BUG_TYPE" select b).ToList(); //缺陷级别 var buglevel = (from b in medc.ps_systemconfig where b.configCode == "BUG_LEVEL" select b).ToList(); int skip = (pageindex - 1) * 6; DataSource ds = new DataSource(); if (islist.Count() > 0) { ds.islist = islist.Skip(skip).Take(6).ToList(); Session["buglist"] = ds.islist; ds.pagecount = islist.Count(); } ds.buglevellist = buglevel; ds.bugtypelist = bugtype; string jsonstr = JsonConvert.SerializeObject(ds); return(Content(jsonstr)); }