//导出数据到Excel
 protected void lBtnToExcel_Click(object sender, EventArgs e)
 {
     //获取数据并填充到数据表
     using (var da = new v_ppc_lot_card_join_orderTableAdapter())
     {
         //检测session中保存的查询条件
         object obj = Session["lot_card_mgr_supplement_where_content"];
         string str = string.Empty;
         if (obj != null && obj.ToString().Length > 0)
         {
             str = obj.ToString();
         }
         //获取前1万行数据
         var tab = da.GetPagedData(0, 10000, str, "order by [id] desc", true);
         //设置列标题
         string[] titleCol =
             ("序号,批量卡序号,是补料单,订单序号,pnl数量,首部门,备注," +
             "录入员,录入时间,修改时间,状况,良率,生产编号,pnl长,pnl宽,pnl面积," +
             "客户名称,客户料号,批量卡编号,批量卡pcs数,批量卡pcs面积," +
             "开料pnl数,开料pnl面积,pnl含pcs数,开料pcs数,仓存pcs数" +
             "落单日期,需求日期,生产日期,已交货pcs数,已交货pcs面积," +
             "欠出货pcs数,欠出货pcs面积,事业部,销售单号,特殊流程,SMT备注,FPC单价,SMT单价," +
             "批次号,规格,备品数量,覆盖膜,投料率").Split(',');
         //设置表名称
         string titleTab = "补料批量卡清单";
         //临时文件名称
         string fileName = titleTab + DateTime.Now.ToString("yyMMddHHmmss") + ".xls";
         //执行导出数据到excel
         bool isSuccess = ydPublicMethod.DataTable2Excel(tab, titleCol, ref fileName, titleTab);
         //如果成功则跳转到指定页面
         if (isSuccess)
         {
             Response.Redirect(fileName);
             //停止加载后续内容
             Response.End();
         }
     }
 }
 //导出数据到Excel
 protected void lBtnToExcel_Click(object sender, EventArgs e)
 {
     //获取数据并填充到数据表
     using (var da = new v_ppc_lot_card_join_orderTableAdapter())
     {
         //检测session中保存的查询条件
         object obj = Session["lot_card_mgr_supplement_where_content"];
         string str = string.Empty;
         if (obj != null && obj.ToString().Length > 0)
         {
             str = obj.ToString();
         }
         //获取前1万行数据
         var tab = da.GetPagedData(0, 10000, str, "order by [id] desc", true);
         //设置列标题
         string[] titleCol =
             ("序号,订单序号,lot卡号,lot卡月份,lot卡序号,是补料单,pnl长,pnl宽,pnl含pcs数,pnl数," +
             "总pcs数,pnl面积,总pnl面积,首部门名称,备注,录入员,录入时间,修改时间," +
             "起始lot卡号,结束lot卡号,状态,良率,生产编号,pcs面积,客户名称,客户编号," +
             "订单编号,订单pcs数量,订单pcs面积,仓存pcs数,下单日期,需求日期,生产日期," +
             "已交pcs数,已交pcs面积,未交pcs数,未交pcs面积,订单备注").Split(',');
         //设置表名称
         string titleTab = "补料lot卡清单";
         //临时文件名称
         string fileName = titleTab + DateTime.Now.ToString("yyMMddHHmmss") + ".xls";
         //执行导出数据到excel
         bool isSuccess = ydPublicMethod.DataTable2Excel(tab, titleCol, ref fileName, titleTab);
         //如果成功则跳转到指定页面
         if (isSuccess)
         {
             Response.Redirect(fileName);
             //停止加载后续内容
             Response.End();
         }
     }
 }
Beispiel #3
0
 //导出数据到Excel
 protected void lBtnToExcel_Click(object sender, EventArgs e)
 {
     //获取数据并填充到数据表
     using (var da = new v_ppc_lot_card_join_orderTableAdapter())
     {
         //检测session中保存的查询条件
         object obj = Session["lot_card_print_where_content"];
         string str = string.Empty;
         if (obj != null && obj.ToString().Length > 0)
         {
             str = obj.ToString();
         }
         //获取前1万行数据
         var tab = da.GetPagedData(0, 10000, str, "order by [id] desc", false);
         //设置列标题
         string[] titleCol =
             ("序号,批量卡序号,是补料单,订单序号,pnl数量,首部门,备注," +
             "录入员,录入时间,修改时间").Split(',');
         //设置表名称
         string titleTab = "待打印批量卡清单";
         //临时文件名称
         string fileName = titleTab + DateTime.Now.ToString("yyMMddHHmmss") + ".xls";
         //执行导出数据到excel
         bool isSuccess = ydPublicMethod.DataTable2Excel(tab, titleCol, ref fileName, titleTab);
         //如果成功则跳转到指定页面
         if (isSuccess)
         {
             Response.Redirect(fileName);
             //停止加载后续内容
             Response.End();
         }
     }
 }
Beispiel #4
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;
            }
            //用户传入的lot卡号
            string lotId = context.Request["lid"];
            //检测lot卡号
            if (lotId == null || lotId.Length < 6)
            {
                throw new Exception("未提供lot卡号参数或者lot卡号参数长度太短!");
            }
            //待输出到浏览器的数据
            string strResult = string.Empty;
            try
            {
                //根据lot卡号获取lot卡和订单信息
                using (var da = new v_ppc_lot_card_join_orderTableAdapter())
                using (var tab = da.GetDataByLotId(lotId))
                {
                    //检测获取到的数据数据
                    if (tab.Rows.Count <= 0)
                    {
                        strResult = "打印失败:PMC录入的lot卡不存在!";
                    }
                    else
                    {
                        //首行
                        var row = (DataSetPpcLotCardMgr.v_ppc_lot_card_join_orderRow)tab.Rows[0];
                        //取得生产编号
                        string productNum = row.product_num.Trim().ToUpper();
                        //检测生产编号的正确性
                        string strReg = @"^TY(?!Y)[A-Z]-[1-9]\d{0,7}[0A-Z][0-9]$";
                        if (!Regex.IsMatch(productNum, strReg))
                        {
                            strResult = string.Format("打印失败:{0}生产编号不符合规则,必须为 TYZ-100A0 格式!", productNum);
                        }
                        else
                        {
                            //生产编号中的层数起始字符索引
                            int iNumStart = productNum.IndexOf("-") + 1;
                            //抓取生产编号中的数字序号串和版本
                            int pNum = int.Parse(productNum.Substring(iNumStart, productNum.Length - iNumStart - 2));
                            string pVersion = productNum.Substring(productNum.Length - 2);
                            //根目录编号段
                            int iNumBegin = (pNum / 3000) * 3000 + 1;
                            int iNumEnd = iNumBegin + 3000 - 1;
                            //拼接文件夹路径
                            var sb = new StringBuilder("E:\\工程");
                            //确定顶级文件夹名称
                            sb.Append(iNumBegin.ToString("0000") + "-" + iNumEnd.ToString("0000"));
                            //确定次级文件夹名称
                            sb.Append("\\" + productNum + "\\" + productNum + ".xls");
                            //得到lot卡文件全路径
                            string lotCardFullPath = sb.ToString();

                            //检查文件是否存在
                            if (!File.Exists(lotCardFullPath))
                            {
                                strResult = "打印失败:工程lot卡不存在!路径为:" + lotCardFullPath;
                            }
                            else
                            {
                                //excel对象
                                var xlApp = new Excel.Application();
                                //打开该excel文件
                                xlApp.Visible = true;
                                xlApp.DisplayAlerts = false;
                                try
                                {
                                    //打开工作簿
                                    var xlBook = xlApp.Workbooks.Open(lotCardFullPath, ReadOnly: true);
                                    foreach (Excel.Worksheet item in xlBook.Worksheets)
                                    {
                                        if (item.Name != "normal")
                                        {
                                            item.Delete();
                                        }
                                    }
                                    var xlSheet = (Excel.Worksheet)xlBook.Worksheets[1];
                                    //设置为活动
                                    ((Excel._Worksheet)xlSheet).Select();
                                    //设置值
                                    //订单序号
                                    xlSheet.Range["S1"].Value = row.order_id;
                                    //LOT卡号
                                    xlSheet.Range["S2"].Value = row.lot_id;
                                    //客户名称
                                    xlSheet.Range["C3"].Value = row.Iscust_nameNull() ? string.Empty : row.cust_name;
                                    //下单日期
                                    xlSheet.Range["F3"].Value = row.Isorder_dateNull() ? string.Empty : row.order_date.ToString("yyyy-MM-dd");
                                    //需求日期
                                    xlSheet.Range["K3"].Value = row.Isneed_dateNull() ? string.Empty : row.need_date.ToString("yyyy-MM-dd");
                                    //生产日期
                                    xlSheet.Range["S3"].Value = row.Isproduct_dateNull() ? string.Empty : row.product_date.ToString("yyyy-MM-dd");
                                    //订单数量
                                    xlSheet.Range["C6"].Value = row.Isorder_pcs_qtyNull() ? string.Empty : row.order_pcs_qty.ToString();
                                    //投产数量
                                    using (var da2 = new t_ppc_lot_cardTableAdapter())
                                    {
                                        xlSheet.Range["F6"].Value = da2.SumPcsQtyByOrderId(row.order_id).ToString();
                                    }
                                    //当前开料lot卡pnl长宽
                                    var strPnlLength = row.pnl_length.ToString();
                                    var strPnlWidth = row.pnl_width.ToString();
                                    //当前工程lot卡pnl长宽A
                                    var strPnlLengthA = xlSheet.Range["I5"].Text.ToString();
                                    var strPnlWidthA = xlSheet.Range["L5"].Text.ToString();
                                    //当前工程lot卡pnl长宽B
                                    var strPnlLengthB = xlSheet.Range["I6"].Text.ToString();
                                    var strPnlWidthB = xlSheet.Range["L6"].Text.ToString();
                                    //检测使用的是哪种工程MI尺寸
                                    string strPnlSize = string.Empty;
                                    //检测是否符合工程MI中填写的pnl尺寸
                                    if ((strPnlLength == strPnlLengthA && strPnlWidth == strPnlWidthA) ||
                                         (strPnlLength == strPnlWidthA && strPnlWidth == strPnlLengthA))
                                    {
                                        strPnlSize = "A板";
                                    }
                                    else if ((strPnlLength == strPnlLengthB&& strPnlWidth == strPnlWidthB) ||
                                        (strPnlLength == strPnlWidthB && strPnlWidth == strPnlLengthB))
                                    {
                                        strPnlSize = "B板";
                                    }
                                    else
                                    {
                                        strPnlSize = "B板";
                                        xlSheet.Range["I6"].Value = strPnlLength;
                                        xlSheet.Range["L6"].Value = strPnlWidth;
                                        xlSheet.Range["N6"].Value = string.Empty;
                                        xlSheet.Range["Q6"].Value = string.Empty;
                                        xlSheet.Range["T6"].Value =  row.pnl_count_pcs;
                                    }
                                    //本卡数量
                                    xlSheet.Range["K7"].Value = strPnlSize + row.pnl_qty;
                                    //本卡面积
                                    xlSheet.Range["R7"].Value = row.total_pnl_area;
                                    //订单编号
                                    xlSheet.Range["C64"].Value = row.Isorder_numNull() ? string.Empty : row.order_num;
                                    //只打印为一页
                                    xlSheet.PageSetup.FitToPagesWide = 1;
                                    xlSheet.PageSetup.FitToPagesTall = 1;
                                    //打印lot卡
                                    xlSheet.PrintOut(From: 1, To: 1, Copies: 1, Collate: true);
                                    //关闭工作表
                                    xlBook.Close(SaveChanges: false);
                                    //待返回的状态结果
                                    strResult = "打印成功!";
                                    //注销excel相关对象
                                    xlSheet = null;
                                    xlBook = null;
                                }
                                catch (Exception exx)
                                {
                                    throw exx;
                                }
                                finally
                                {
                                    //关闭excel文档
                                    foreach (Excel.Workbook itm in xlApp.Workbooks)
                                    {
                                        itm.Close(SaveChanges: false);
                                    }
                                    xlApp.Quit();
                                    //关闭excel进程
                                    ydPublicMethod.KillExcel(xlApp);
                                    xlApp = null;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                strResult = "打印失败:" + ex.Message;
            }
            //写入数据到浏览器
            context.Response.Write(strResult);
        }
 //根据传入的参数处理事情
 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;
     }
     //用户传入的查询参数
     //lot卡号
     string lotId = context.Request["lid"];
     if (string.IsNullOrWhiteSpace(lotId))
     {
         return;
     }
     //生产编号
     string productNum = context.Request["pnum"];
     if (string.IsNullOrWhiteSpace(productNum))
     {
         //从数据库获取当前lot卡号的生产编号
         using (var da = new v_ppc_lot_card_join_orderTableAdapter())
         {
             //获取数据
             var tab = da.GetDataByLotId(lotId);
             //检测有无数据
             if (tab.Rows.Count <= 0)
             {
                 return;
             }
             //取得首行数据
             var row = (DataSetPpcLotCardMgr.v_ppc_lot_card_join_orderRow)tab.Rows[0];
             //取得生产编号
             productNum = row.product_num;
             if (string.IsNullOrWhiteSpace(productNum))
             {
                 return;
             }
         }
     }
     //待输出到浏览器的数据
     string strResult = string.Empty;
     //获取汇总内容
     using (var da = new t_product_record_chongxingTableAdapter())
     {
         //取得结果
         strResult = da.GetToolNumAndPnlPunchCount(lotId, productNum).ToString();
         //写入数据到浏览器
         context.Response.Write(strResult);
     }
 }
Beispiel #6
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;
            }
            //用户传入的批量卡序号
            string lotId = context.Request["lid"];
            //检测批量卡序号
            if (lotId == null || lotId.Length < 6)
            {
                throw new Exception("未提供批量卡序号参数或者批量卡号参数长度太短!");
            }
            //待输出到浏览器的数据
            string strResult = string.Empty;
            try
            {
                //根据批量卡序号获取批量卡和订单信息
                using (var da = new v_ppc_lot_card_join_orderTableAdapter())
                using (var tab = da.GetDataByLotId(lotId))
                {
                    //检测获取到的数据数据
                    if (tab.Rows.Count <= 0)
                    {
                        strResult = "打印失败:PMC录入的批量卡不存在!";
                    }
                    else
                    {
                        //首行
                        var row = (DataSetPpcLotCardMgr.v_ppc_lot_card_join_orderRow)tab.Rows[0];
                        //取得生产编号
                        string productNum = row.product_num.Trim().ToUpper();
                        //生产编号中的层数起始字符索引
                        int iLayerStart = 0;
                        //检测生产编号的正确性
                        string strReg = @"^L-H[DSM]\d{4,}[0A-Z][0-9]$";
                        if (!Regex.IsMatch(productNum, strReg))
                        {
                            strResult = string.Format("打印失败:{0}生产编号不符合规则!", productNum);
                        }
                        else
                        {
                            //第二个字符为减号则从第三个字符开始
                            if (productNum.Substring(2, 1) == "-")
                            {
                                iLayerStart += 2;
                            }
                            //抓取生产编号中的数字序号串和版本
                            string pNum = string.Empty;
                            for (int i = iLayerStart; i < productNum.Length; i++)
                            {
                                //层数截至位置
                                if (char.IsLetter(productNum, i))
                                {
                                    for (int j = i + 1; j < productNum.Length; j++)
                                    {
                                        //流程截至位置
                                        if (char.IsNumber(productNum, j))
                                        {
                                            //最后两位为版本号
                                            pNum = productNum.Substring(j, productNum.Length - j - 2);
                                            break;
                                        }
                                    }
                                    break;
                                }
                            }
                            string pVersion = productNum.Substring(productNum.Length - 2);
                            //生产编号转数字
                            int k = pNum.IndexOf("-");
                            int iNum, iNum2;
                            string strFileNameNum = string.Empty;
                            if (k > 0)
                            {
                                iNum = int.Parse(pNum.Substring(0, k));
                                iNum2 = int.Parse(pNum.Substring(k + 1));
                            }
                            else
                            {
                                iNum = int.Parse(pNum);
                                iNum2 = 0;
                            }
                            //当前生产编号数字或者生产编号数字段
                            strFileNameNum = iNum.ToString("0000");
                            if (iNum2 > 0)
                            {
                                strFileNameNum += "-" + iNum2.ToString("0000");
                            }
                            //根目录编号段
                            int iNumBegin = (iNum / 3000) * 3000 + 1;
                            int iNumEnd = iNumBegin + 3000 - 1;
                            //拼接文件夹路径
                            var sb = new StringBuilder("H:\\工程");
                            //确定顶级文件夹名称
                            sb.Append(iNumBegin.ToString("0000") + "-" + iNumEnd.ToString("0000"));
                            //确定次级文件夹名称
                            sb.Append("\\" + strFileNameNum);
                            //加入版本文件夹
                            sb.Append("\\" + pVersion);
                            //存储路径用来取得单体图路径
                            var sb2 = new StringBuilder(sb.ToString());
                            //批量卡末级文件夹名称
                            sb.Append("\\DOC");
                            //确认批量卡文件名称
                            sb.Append("\\" + strFileNameNum + pVersion + ".xls");
                            //得到批量卡文件全路径
                            string lotCardFullPath = sb.ToString();
                            //单体图末级文件夹名称
                            sb2.Append("\\DWG");
                            //确认单体图文件名称
                            sb2.Append("\\" + strFileNameNum + pVersion + "单体图.dwg");
                            //得到单体图文件全路径
                            string danTiTuFullPath = sb2.ToString();

                            //检查文件是否存在
                            if (!File.Exists(lotCardFullPath))
                            {
                                lotCardFullPath = lotCardFullPath.Replace("\\DOC\\", "\\D0C\\");
                            }
                            if (!File.Exists(lotCardFullPath))
                            {
                                lotCardFullPath = lotCardFullPath.Replace("\\D0C\\", "\\DOC\\");
                                strResult = "打印失败:工程批量卡不存在!路径为:" + lotCardFullPath;
                            }
                            else
                            {
                                //excel对象
                                var xlApp = new Excel.Application();
                                //打开该excel文件
                                xlApp.Visible = true;
                                xlApp.DisplayAlerts = false;
                                try
                                {
                                    //打开工作簿
                                    var xlBook = xlApp.Workbooks.Open(lotCardFullPath, ReadOnly: true);
                                    var xlSheet = (Excel.Worksheet)xlBook.Worksheets[1];
                                    //设置值
                                    //开料总数量
                                    xlSheet.Range["M3"].Value = row.total_pnl_qty.ToString() + " pnl";
                                    //开料本LOT数量
                                    xlSheet.Range["M7"].Value = row.pnl_qty.ToString() + " pnl";
                                    //订单数量
                                    xlSheet.Range["A4"].Value = "订单数量:  " + row.order_pcs_qty.ToString() + " pcs";
                                    //单据状态
                                    xlSheet.Range["I4"].Value = row.state;
                                    //LOT NO
                                    ((Excel.Range)xlSheet.Range["J3:M4"]).MergeCells = false;
                                    ((Excel.Range)xlSheet.Range["K4:M4"]).Merge();
                                    xlSheet.Range["K4"].HorizontalAlignment = Excel.Constants.xlCenter;
                                    xlSheet.Range["K4"].Value = row.lot_id;
                                    //设置字体加大加粗
                                    xlSheet.Range["M3,M7,A4,K4"].Font.Bold = true;
                                    xlSheet.Range["M3,M7,K4"].Font.Size = 18;
                                    xlSheet.Range["A4"].Characters[6].Font.Size = 18;
                                    //只打印为一页
                                    xlSheet.PageSetup.FitToPagesWide = 1;
                                    xlSheet.PageSetup.FitToPagesTall = 1;

                                    //检查文件是否存在
                                    if (!File.Exists(danTiTuFullPath))
                                    {
                                        strResult = "打印部分失败:单体图不存在!路径为:" + danTiTuFullPath;
                                    }
                                    else
                                    {
                                        //待打印成的图片文件的名称
                                        string imgName = context.Server.MapPath(
                                            string.Format(@"dwg2jpg-{0}.jpg", context.Session["user_name"])
                                        );
                                        imgName = (new FileInfo(imgName)).FullName;
                                        //待打印成的图片文件的名称
                                        imgName = (new FileInfo(imgName)).FullName;
                                        //删除之前的文件
                                        if (File.Exists(imgName))
                                        {
                                            File.Delete(imgName);
                                        }
                                        //执行打印单体图生成图片文件
                                        var p = new Process();
                                        p.StartInfo.UseShellExecute = false;
                                        //p.StartInfo.RedirectStandardInput = true;
                                        p.StartInfo.RedirectStandardOutput = true;
                                        //p.StartInfo.RedirectStandardError = true;
                                        p.StartInfo.CreateNoWindow = true;
                                        p.StartInfo.FileName = context.Server.MapPath(@"PrintLotCard\Dwg2Jpg.exe");
                                        p.StartInfo.Arguments = string.Format(@" {0} {1}", danTiTuFullPath, imgName);
                                        p.Start();
                                        string strOutPut = p.StandardOutput.ReadToEnd();
                                        //p.WaitForExit(60000);
                                        //检测文件是否存在
                                        if (strOutPut.Length > 0 || !File.Exists(imgName))
                                        {
                                            strResult = string.Format("打印单体图失败:{0}" + strOutPut, productNum);
                                        }
                                        else
                                        {
                                            //设置为活动
                                            ((Excel._Workbook)xlBook).Activate();
                                            ((Excel._Worksheet)xlSheet).Select();
                                            //在excel中插入该图片并设置分页
                                            string strError = string.Empty;
                                            if (InsertImageToExcelSheet(xlSheet, imgName, out strError))
                                            {
                                                //打印lot卡和单体图
                                                xlSheet.PrintOut(From: 1, To: 2, Copies: 1, Collate: true);
                                                //关闭工作表
                                                xlBook.Close(SaveChanges: false);
                                            }
                                            else
                                            {
                                                //抛出错误
                                                throw new Exception(strError);
                                            }
                                            //删除生成的图片文件
                                            if (File.Exists(imgName))
                                            {
                                                File.Delete(imgName);
                                            }
                                            //待返回的状态结果
                                            strResult = "打印成功!";
                                        }
                                    }
                                    //注销excel相关对象
                                    xlSheet = null;
                                    xlBook = null;
                                }
                                catch (Exception exx)
                                {
                                    throw exx;
                                }
                                finally
                                {
                                    //关闭excel文档
                                    foreach (Excel.Workbook itm in xlApp.Workbooks)
                                    {
                                        itm.Close(SaveChanges: false);
                                    }
                                    xlApp.Quit();
                                    //关闭excel进程
                                    ydPublicMethod.KillExcel(xlApp);
                                    xlApp = null;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                strResult = "打印失败:" + ex.Message;
            }
            //写入数据到浏览器
            context.Response.Write(strResult);
        }
Beispiel #7
0
 /// <summary>
 /// 检测是否存在指定的部门名称
 /// </summary>
 /// <param name="txtLotId">当前待报数的lot卡序文本框</param>
 /// <param name="source">当前验证控件</param>
 /// <param name="args">验证控件提供的验证事件参数对象</param>
 /// <returns></returns>
 internal static bool IsSameOrderProductNum(
     TextBox txtLotId,
     object source,
     ServerValidateEventArgs args
 )
 {
     //当前对象
     var cv = ((CustomValidator)source);
     cv.ToolTip = "只允许版本号与订单生产编号不相同";
     //是否找到lot卡号文本框
     if (txtLotId == null)
     {
         return false;
     }
     //获取用户输入的lot卡号
     string lotId = txtLotId.Text;
     cv.ToolTip = "提供的lot卡号不正确";
     //检测lot卡号
     if (!lotId.Contains("-") || lotId.Length < 6)
     {
         return false;
     }
     //检测是否样板
     bool isSample = lotId.ToUpper().Contains("S");
     //非样板使用生产订单和lot卡中的数据
     if (!isSample && !ydOperateLotCard.IsLotCardId(ref lotId))
     {
         return false;
     }
     else if (isSample && !ydOperateSampleLotCard.IsSampleLotCardId(ref lotId))
     {
         return false;
     }
     //非样板订单在生产订单中查询
     if (!isSample)
     {
         //通过lot卡号获取订单中生产编号
         using (var da = new v_ppc_lot_card_join_orderTableAdapter())
         {
             //获取
             object obj = da.GetProductNumByLotId(lotId);
             if (obj == null)
             {
                 cv.ToolTip = "在订单中未找到生产编号";
                 return false;
             }
             else
             {
                 //取得的订单生产编号
                 string orderProductNum = obj.ToString();
                 //取得的输入的生产编号
                 string userProductNum = args.Value;
                 //小于两个字符不检测
                 if (orderProductNum.Length < 2)
                 {
                     return true;
                 }
                 else if (userProductNum.Length >= 2)
                 {
                     cv.ToolTip = string.Format("只允许版本号与订单生产编号\"{0}\"不相同", orderProductNum);
                     //检测是否存在部门
                     return orderProductNum.Remove(orderProductNum.Length - 2)
                         == userProductNum.Remove(userProductNum.Length - 2);
                 }
                 else
                 {
                     return false;
                 }
             }
         }
     }
     //样板在样板订单中查询
     else
     {
         //通过样板lot卡号获取样板订单中生产编号
         using (var da = new v_sample_lot_card_join_orderTableAdapter())
         {
             //获取
             object obj = da.GetProductNumByLotId(lotId);
             if (obj == null)
             {
                 cv.ToolTip = "在样板订单中未找到生产编号";
                 return false;
             }
             else
             {
                 //取得的样板订单生产编号
                 string orderProductNum = obj.ToString();
                 //取得的输入的样板生产编号
                 string userProductNum = args.Value;
                 //小于两个字符不检测
                 if (orderProductNum.Length < 2)
                 {
                     return true;
                 }
                 else if (userProductNum.Length >= 2)
                 {
                     cv.ToolTip = string.Format("只允许版本号与样板订单生产编号\"{0}\"不相同", orderProductNum);
                     //检测是否存在部门
                     return orderProductNum.Remove(orderProductNum.Length - 2)
                         == userProductNum.Remove(userProductNum.Length - 2);
                 }
                 else
                 {
                     return false;
                 }
             }
         }
     }
 }
 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;
     }
     //用户传入的生产编号
     string productNum = context.Request["pnum"];
     //检测生产编号
     if (string.IsNullOrWhiteSpace(productNum))
     {
         return;
     }
     //检测是否取消版本查询
     string useLike = context.Request["like"];
     bool isLike = false;
     if (!string.IsNullOrWhiteSpace(useLike) && useLike == "1")
     {
         //使用模糊查询
         isLike = true;
         //修改参数值
         productNum = productNum + "%";
     }
     //待输出到浏览器的数据
     string strResult = string.Empty;
     //数据适配器
     using (var da = new v_ppc_lot_card_join_orderTableAdapter())
     {
         //获取数据
         DataSetPpcLotCardMgr.v_ppc_lot_card_join_orderDataTable tab;
         if (isLike)
         {
             tab = da.GetFirstDataLikeProductNum(productNum);
         }
         else
         {
             tab = da.GetFirstDataByProductNum(productNum);
         }
         //返回数据
         if (tab.Rows.Count <= 0)
         {
             return;
         }
         //首行数据
         var row = (DataSetPpcLotCardMgr.v_ppc_lot_card_join_orderRow)tab.Rows[0];
         //返回数据
         context.Response.Write(
             string.Format(
                 "{0}|{1}|{2}",
                 row.pnl_length,
                 row.pnl_width,
                 row.pnl_count_pcs
             )
         );
     }
 }