/// <summary>
 /// 获取模版1的单据
 /// </summary>
 /// <param name="bnums">传递的单据编号的key名称</param>
 /// <param name="tabHead">返回的表头数据</param>
 /// <param name="tabContent">返回的表身数据</param>
 private void GetBillData(
     string bnums,
     DataSetSampleDeliveryBillMgr.v_delivery_bill_head_sample_join_custDataTable tabHead,
     DataSetSampleDeliveryBillMgr.t_delivery_bill_content_sampleDataTable tabContent
 )
 {
     //用户传入的样板送货单号
     var bnum = Request[bnums];
     if (bnum == null || bnum.Length == 0)
     {
         //Response.Write("未检测到传入的样板送货单号!");
         return;
     }
     var billNums = bnum.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
     if (billNums.Length <= 0)
     {
         //Response.Write("传入的样板送货单号不正确!");
         return;
     }
     //去重
     var lBillNum = new List<string>();
     foreach (var billNum in billNums)
     {
         if (!lBillNum.Contains(billNum))
         {
             lBillNum.Add(billNum);
         }
     }
     //排序
     lBillNum.Sort();
     //修改标题
     this.Title = "样板送货单预览";
     //数据适配器
     using (var da = new v_delivery_bill_head_sample_join_custTableAdapter())
     {
         //获取表头数据
         foreach (var billNum in lBillNum)
         {
             tabHead.Merge(da.GetDataByBillNum(billNum));
         }
         if (tabHead.Rows.Count <= 0)
         {
             //Response.Write("未找到样板送货单!");
             return;
         }
     }
     //数据适配器
     using (var da = new t_delivery_bill_content_sampleTableAdapter())
     {
         //获取内容数据
         foreach (var billNum in lBillNum)
         {
             tabContent.Merge(da.GetDataByBillNum(billNum));
         }
     }
 }
 /// <summary>
 /// 设置单据清单内容指定行的数据到控件
 /// </summary>
 /// <param name="row">送货单当前数据行</param>
 /// <param name="iRow">当前行的索引号</param>
 private void SetBillContent(DataSetSampleDeliveryBillMgr.t_delivery_bill_content_sampleRow row, int iRow)
 {
     //检测是否含有数据
     bool isEmpty = row == null;
     //当前数据所在的行和lot卡清单行
     var trContentRow = (TableRow)tabDataListSon.FindControl("trContentRow" + iRow);
     var trLotCardRow = (TableRow)tabDataListSon.FindControl("trLotCardRow" + iRow);
     //检测是否找到该行
     if (trContentRow == null || trLotCardRow == null)
     {
         return;
     }
     //各控件
     var txtOrderId = (TextBox)trContentRow.Cells[1].FindControl("txtOrderId" + iRow);
     var txtOrderNum = (TextBox)trContentRow.Cells[2].FindControl("txtOrderNum" + iRow);
     var txtProductNum = (TextBox)trContentRow.Cells[3].FindControl("txtProductNum" + iRow);
     var txtCustNum = (TextBox)trContentRow.Cells[4].FindControl("txtCustNum" + iRow);
     var txtPcsQty = (TextBox)trContentRow.Cells[5].FindControl("txtPcsQty" + iRow);
     var txtFocPcsQty = (TextBox)trContentRow.Cells[6].FindControl("txtFocPcsQty" + iRow);
     var txtRemark = (TextBox)trContentRow.Cells[7].FindControl("txtRemark" + iRow);
     var tcLotCardList = (TableCell)trLotCardRow.Cells[1].FindControl("tcLotCardList" + iRow);
     var hdLotCardList = (HtmlInputHidden)this.FindControl("hdLotCardList" + iRow);
     //写入数据
     txtOrderId.Text = isEmpty ? string.Empty : row.order_id;
     txtProductNum.Text = isEmpty ? string.Empty : row.product_num;
     txtCustNum.Text = isEmpty ? string.Empty : row.cust_num;
     txtPcsQty.Text = isEmpty ? string.Empty : row.pcs_qty.ToString();
     txtFocPcsQty.Text = isEmpty ? string.Empty : row.Isfoc_pcs_qtyNull() ? "" : row.foc_pcs_qty.ToString();
     txtRemark.Text = isEmpty ? string.Empty : row.IsremarkNull() ? "" : row.remark;
     tcLotCardList.Text = isEmpty ? string.Empty : row.lot_id_list;
     //将当前的值写入隐藏对象
     hdLotCardList.Value = isEmpty ? string.Empty : row.lot_id_list.Replace("<", "|l|").Replace(">", "|g|");
 }
 /// <summary>
 /// 添加获取到的数据到泛型变量
 /// </summary>
 /// <param name="tab">包含指定格式的数据表</param>
 /// <param name="dic">将数据填写到字典变量</param>
 /// <param name="strLotCard">之前已经存在的lot卡清单和数量</param>
 /// <param name="tabDeliveryLotCard">当前送货单</param>
 private void AddBalanceLotListItem(
     DataSetSampleDeliveryBillMgr.t_complete_lot_card_waitDataTable tab,
     ref Dictionary<string, LiItem> dic,
     string strLotCard,
     DataSetSampleDeliveryBillMgr.t_delivery_bill_lot_card_sampleDataTable tabDeliveryLotCard
 )
 {
     //检测是否含有之前的lot卡清单字典
     if (strLotCard != null)
     {
         //检测输入的内容
         string strReg = "[^>]+(?=</div>)";
         MatchCollection matchs = Regex.Matches(strLotCard, strReg);
         //取出匹配到的数据
         foreach (Match match in matchs)
         {
             //通过冒号分出lot卡号和数量
             string[] strs = match.Value.Split(new char[] { ':' }, 2, StringSplitOptions.RemoveEmptyEntries);
             //实例化项目类
             var itm = new LiItem();
             //设置实例的值
             //lot卡号
             itm.LotId = strs[0];
             //pcs参考数量
             itm.MaxPcsQty = int.Parse(strs[1]);
             //pcs数量
             itm.PcsQty = itm.MaxPcsQty;
             //将实例加入泛型变量
             dic.Add(itm.LotId, itm);
         }
     }
     //加入数据表中的内容
     foreach (DataSetSampleDeliveryBillMgr.t_complete_lot_card_waitRow row in tab.Rows)
     {
         //批量当前lot卡号
         string lotId = row.lot_id;
         //该lot卡在本章送货单之前已经提交的交货数
         bool isExist = false;
         foreach (var dicItm in dic)
         {
             //存在该lot卡就修改数量
             if (dicItm.Key == lotId)
             {
                 //该lot卡可以填写的总数量
                 int pcsQty = row.pcs_qty;
                 //查询之前该lot卡的交货数量
                 int pcsQty2 = (
                     from t in tabDeliveryLotCard
                     where t.lot_id == lotId
                     select t.pcs_qty
                 ).Sum();
                 //修改字典中的lot卡数量
                 dicItm.Value.MaxPcsQty = pcsQty + pcsQty2;
                 //设置为已经找到
                 isExist = true;
                 //退出循环
                 break;
             }
         }
         //不存在该lot卡就添加
         if (!isExist)
         {
             //实例化项目类
             var itm = new LiItem();
             //设置实例的值
             //lot卡号
             itm.LotId = lotId;
             //pcs参考数量
             itm.MaxPcsQty = row.pcs_qty;
             //将实例加入泛型变量
             dic.Add(itm.LotId, itm);
         }
     }
 }
 /// <summary>
 /// 设置单据清单内容指定行的数据到控件
 /// </summary>
 /// <param name="row">样板送货单当前数据行</param>
 /// <param name="iRow">当前行的索引号</param>
 private void SetBillContent(DataSetSampleDeliveryBillMgr.t_delivery_bill_content_sampleRow row, int iRow)
 {
     //检测是否含有数据
     bool isEmpty = row == null;
     //当前数据所在的行和批量卡清单行
     var trContentRow = (TableRow)tabDataListSon.FindControl("trContentRow" + iRow);
     var trLotCardRow = (TableRow)tabDataListSon.FindControl("trLotCardRow" + iRow);
     //检测是否找到该行
     if (trContentRow == null || trLotCardRow == null)
     {
         return;
     }
     //各控件
     var txtOrderId = (TextBox)trContentRow.FindControl("txtOrderId" + iRow);
     var txtMarketDept = (TextBox)trContentRow.FindControl("txtMarketDept" + iRow);
     var txtProductNum = (TextBox)trContentRow.FindControl("txtProductNum" + iRow);
     var txtOrderNum = (TextBox)trContentRow.FindControl("txtOrderNum" + iRow);
     var txtCustNum = (TextBox)trContentRow.FindControl("txtCustNum" + iRow);
     var txtSpecification = (TextBox)trContentRow.FindControl("txtSpecification" + iRow);
     var txtPcsQty = (TextBox)trContentRow.FindControl("txtPcsQty" + iRow);
     var txtFocPcsQty = (TextBox)trContentRow.FindControl("txtFocPcsQty" + iRow);
     var txtBatchNum = (TextBox)trContentRow.FindControl("txtBatchNum" + iRow);
     var txtProductDate = (TextBox)trContentRow.FindControl("txtProductDate" + iRow);
     var txtRemark = (TextBox)trContentRow.FindControl("txtRemark" + iRow);
     var tcLotCardList = (TableCell)trLotCardRow.FindControl("tcLotCardList" + iRow);
     var hdLotCardList = (HtmlInputHidden)this.FindControl("hdLotCardList" + iRow);
     //写入数据
     txtOrderId.Text = isEmpty ? string.Empty : row.order_id;
     txtMarketDept.Text = isEmpty ? string.Empty : row.market_dept;
     txtProductNum.Text = isEmpty ? string.Empty : row.product_num;
     txtOrderNum.Text = isEmpty ? string.Empty : row.order_num;
     txtCustNum.Text = isEmpty ? string.Empty : row.cust_num;
     txtSpecification.Text = isEmpty || row.IsspecificationNull() ? string.Empty : row.specification;
     txtPcsQty.Text = isEmpty ? string.Empty : row.pcs_qty.ToString();
     txtFocPcsQty.Text = isEmpty || row.Isfoc_pcs_qtyNull() ? string.Empty : row.foc_pcs_qty.ToString();
     txtBatchNum.Text = isEmpty || row.Isbatch_numNull() ? string.Empty : row.batch_num;
     txtProductDate.Text = isEmpty || row.Isproduct_dateNull() ? string.Empty : row.product_date.ToString("yyyy-MM-dd");
     txtRemark.Text = isEmpty || row.IsremarkNull() ? string.Empty : row.remark;
     tcLotCardList.Text = isEmpty ? string.Empty : row.lot_id_list;
     //将当前的值写入隐藏对象
     hdLotCardList.Value = isEmpty ? string.Empty : row.lot_id_list.Replace("<", "|l|").Replace(">", "|g|");
 }