Пример #1
0
        //根据传入的参数处理事情
        public void ProcessRequest(HttpContext context)
        {
            //清空之前数据
            context.Response.Clear();
            //检测是否含有session
            if (context.Session.Count < 5)
            {
                //跳转
                context.Response.Redirect("/Account/Login", true);
                //停止加载后续内容
                context.Response.End();
                //直接返回
                return;
            }
            //执行基类的方法
            if (!base.CheckIsLogin(context))
            {
                return;
            }
            //当前使用的查询参数类型
            var parField = ParameterField.None;
            //用户传入的lot卡号
            string lotId = context.Request["lnum"];
            string productNum = string.Empty;
            //检测lot卡编号
            if (lotId != null && lotId.Length > 0)
            {
                //查询字段类型为生产编号
                parField = ParameterField.LotNum;
                //去掉空格
                lotId = lotId.Trim();
                //检测lot卡号重新设置参数值
                if (!lotId.Contains("-"))
                {
                    //添加减号
                    lotId = "-" + lotId;
                }
                //使用模糊查询
                lotId = "%" + lotId + "%";
            }
            else
            {
                //用户传入的生产编号
                productNum = context.Request["pnum"];
                if (productNum != null && productNum.Length > 0)
                {
                    //查询字段类型为生产编号
                    parField = ParameterField.ProductNum;
                    //设置参数值
                    productNum = "%" + productNum.Trim().ToUpper() + "%";
                }
            }
            //当前未使用特定的三种字段类型之一进行查询则不输出值直接退出
            if (parField == ParameterField.None)
            {
                return;
            }
            //用户传入的部门名称
            string deptName = context.Request["dept"];//检测lot卡编号
            if (string.IsNullOrWhiteSpace(deptName))
            {
                //当前用户所在部门名称
                deptName = context.Session["dept_name"].ToString();
            }
            //将查询到的结果保存到泛型变量中
            var l = new List<LiItem>();
            //数据适配器
            using (var da = new t_dept_lot_card_balanceTableAdapter())
            {
                //lot卡结存表
                DataSetDeptLotCardMgr.t_dept_lot_card_balanceDataTable tab;
                //使用lot卡编号进行查询
                if (parField == ParameterField.LotNum)
                {
                    //获取数据
                    tab = da.GetDataLikeDeptNameAndLotId(deptName, lotId);
                }
                else
                {
                    //获取数据
                    tab = da.GetDataLikeDeptNameAndProductNum(deptName, productNum);
                }
                //获取单据数据
                AddBalanceLotListItem(tab, ref l);
            }
            //待输出到浏览器的数据
            string strResult = string.Empty;
            //如果在客户清单中查询到数据
            if (l.Count > 0)
            {
                //将泛型变量各项目放入数组
                var itms = new LiItem[l.Count];
                //复制泛型变量的内容到数组
                l.CopyTo(itms);
                //循环重新设置单只数
                foreach (var itm in itms)
                {
                    //将实例加入li
                    strResult += itm.ToString();
                }
            }

            //加入ul头尾
            strResult = "<ul>\n" + strResult + "</ul>\n";
            //写入数据
            context.Response.Write(strResult);
        }