/// <summary> /// 检测指定的lotid是否存在 /// </summary> /// <param name="lotId">样板lot卡号</param> /// <param name="tran">在指定事务中执行查询</param> /// <returns></returns> internal static bool IsExistSampleLotId(string strLotId, SqlTransaction tran) { //检测样板lot卡id号是否存在于sample所开的样板lot卡记录中 using (var da = new t_sample_lot_cardTableAdapter()) { if (tran != null) { //当前数据库连接 da.Connection = tran.Connection; //设置事务 da.Transaction = tran; } //获取数据 using (var tab = da.GetDataByLotId(strLotId)) { //lotid号存在提示错误 if (tab.Rows.Count > 0) { //报告失败 throw new Exception("待保存的样板lot卡号 " + strLotId + " 已经存在于样板lot卡记录中!"); } } } //检测样板lot卡id号是否存在于样板wip记录中 using (var da = new t_dept_lot_card_balanceTableAdapter()) { if (tran != null) { //当前数据库连接 da.Connection = tran.Connection; //设置事务 da.Transaction = tran; } //获取数据 using (var tab = da.GetFirstRowByLotId(strLotId)) { //lotid号存在提示错误 if (tab.Rows.Count > 0) { //报告失败 throw new Exception("待保存的样板lot卡号 " + strLotId + " 已经存在于样板wip记录中!"); } } } //返回不存在 return false; }
/// <summary> /// 保存多条lot卡开卡记录数据到数据库 /// </summary> /// <param name="e">传入的带有数据的事件参数</param> /// <returns></returns> private bool InsertData(FormViewInsertEventArgs e) { //当前用户输入的lot卡号 string strLotIdBegin = e.Values["lot_id"].ToString(); //正则表达式 string strReg = @"^[1-9]\d(0[1-9]|1[012])-[1-9]\d{0,4}"; //检测是否正确lot卡号 if (!Regex.IsMatch(strLotIdBegin, strReg)) { //非数字返回失败 throw new Exception("您输入了一个不合格的结束lot卡号 " + strLotIdBegin + " !"); } //数据适配器 //当前添加语句对象 //当前数据库连接 using (var da = new t_sample_lot_cardTableAdapter()) using (var daOrder = new t_sample_orderTableAdapter()) using (var daBalance = new t_dept_lot_card_balanceTableAdapter()) using (var conn = da.Connection) { //打开数据库连接 conn.Open(); //设置数据库连接 daOrder.Connection = daBalance.Connection = conn; //开启事务 using (var tran = conn.BeginTransaction()) { //设置事务 daOrder.Transaction = da.Transaction = daBalance.Transaction = tran; //试运行 try { //订单序号 string orderId = ((TextBox)fvSampleLotCardMgrAdd.FindControl("txtOrderId")).Text; //取得生产编号 string productNum = daOrder.GetProductNumByOrderId(orderId).ToString(); //lot卡中的年份月份和数字索引号 string strYearMonth = strLotIdBegin.Substring(0, 5); int iLotId = int.Parse(strLotIdBegin.Substring(5)); //每卡开多少pnl Int16 iEveryCardPnlQty = Int16.Parse(((TextBox)fvSampleLotCardMgrAdd.FindControl("txtEveryCardPnlQty")).Text); //是否补料单 bool isSupplement = Convert.ToBoolean(e.Values["is_supplement"]); //首部门 string firstDeptName = ((TextBox)fvSampleLotCardMgrAdd.FindControl("txtFirstDeptName")).Text; //备注 string remark = e.Values["remark"].ToString(); //录入员 string addPerson = e.Values["add_person"].ToString(); //录入时间 DateTime addTime = Convert.ToDateTime(e.Values["add_time"]); //录入时间 DateTime lastChangeTime = Convert.ToDateTime(e.Values["last_change_time"]); //遍历pnl数 foreach (var item in new string[] { "A", "B", "C", "D" }) { //pnl开料数 string pnlQty = ((TextBox)fvSampleLotCardMgrAdd.FindControl("txtPnlQty" + item)).Text; if (pnlQty.Length <= 0) { continue; } int iPnlQty = int.Parse(pnlQty); //pnl长 Int16 iPnlLength = Int16.Parse(((TextBox)fvSampleLotCardMgrAdd.FindControl("txtPnlLength" + item)).Text); //pnl宽 Int16 iPnlWidth = Int16.Parse(((TextBox)fvSampleLotCardMgrAdd.FindControl("txtPnlWidth" + item)).Text); //pnl含pcs数 Int16 iPnlCountPcs = Int16.Parse(((TextBox)fvSampleLotCardMgrAdd.FindControl("txtPnlCountPcs" + item)).Text); //开卡数 int iCountCard = iPnlQty / iEveryCardPnlQty; //尾卡数量太多,卡数+1 if (iPnlQty - iCountCard * iEveryCardPnlQty >= iEveryCardPnlQty * 0.5) { iCountCard++; } //开卡数至少一张 if (iCountCard <= 0) { iCountCard = 1; } //lot卡逐个往数据库填写 for (int i = iLotId; i < iLotId + iCountCard; i++) { //当前lot卡号 string lotId = strYearMonth + i; //当前卡开pnl数 Int16 iPnlQtyThis = i == iLotId + iCountCard - 1 ? (Int16)(iPnlQty - (iCountCard - 1) * iEveryCardPnlQty) : iEveryCardPnlQty; //写入当前lot卡 if (da.Insert( orderId, lotId, isSupplement, iPnlLength, iPnlWidth, iPnlCountPcs, iPnlQtyThis, firstDeptName, remark, addPerson, addTime, lastChangeTime ) <= 0) { //返回失败 throw new Exception(string.Format("插入lot卡 {0} 到数据库失败!", lotId)); } //写入部门结存 if (daBalance.Insert( "Sample", firstDeptName, lotId, productNum, iPnlQtyThis, 0, null, true, addPerson, addTime, lastChangeTime ) <= 0) { //返回失败 throw new Exception(string.Format("插入lot卡 {0} 到部门结存失败!", lotId)); } } //当前iLotId iLotId = iLotId + iCountCard; } //提交事务 tran.Commit(); //返回成功 return true; } catch (Exception ex) { //回滚事务 tran.Rollback(); //非数字返回失败 throw new Exception(ex.Message); } } } }
/// <summary> /// 根据输入的参数值来执行更新数据 /// </summary> /// <param name="e">传入的带有数据的事件参数</param> /// <returns></returns> private bool UpdateData(FormViewUpdateEventArgs e) { //数据适配器 //当前添加语句对象 //当前数据库连接 using (var da = new v_complete_lot_card_outTableAdapter()) using (var conn = da.Connection) { //打开数据库连接 conn.Open(); //开启事务 using (var tran = conn.BeginTransaction()) { //设置事务 da.Transaction = tran; //试运行 try { //部门名称 string deptName = e.OldValues["dept_name"].ToString(); //当前行单号 string billNum = Convert.ToString(e.Keys[0]); //获取数据 using (var tab = da.GetDataByBillNum(billNum)) { //检查是否获取到行 if (tab.Rows.Count == 0) { //显示失败 throw new Exception("当前记录已经被其他用户删除!"); } //数据适配器 using (var daHead = new t_complete_lot_card_out_headTableAdapter()) using (var daContent = new t_complete_lot_card_out_contentTableAdapter()) using (var daBalance = new t_complete_lot_card_balanceTableAdapter()) using (var daDept = new t_dept_lot_card_balanceTableAdapter()) { //设置数据库连接 daHead.Connection = daContent.Connection = daBalance.Connection = daDept.Connection = conn; //设置事务 daHead.Transaction = daContent.Transaction = daBalance.Transaction = daDept.Transaction = tran; //将之前的单据内容写回 foreach (DataSetCompleteOut.v_complete_lot_card_outRow row in tab.Rows) { //检测是否超过原下部门余数 if (ydOperateBalanceLotCrad.IsOutstripDeptBalance( tran, row.dept_name, row.next_dept_name, row.lot_id, row.pnl_qty, row.pcs_qty, true )) { return false; } //修改原下部门lot卡余数 if (!ydOperateBalanceLotCrad.UpdateBalanceAfterInsert( tran, row.dept_name, row.next_dept_name, row.lot_id, row.pnl_qty, row.pcs_qty, true )) { return false; } //执行插入到成品结存清单 daBalance.InsertData( row.prev_dept_name, row.dept_name, row.lot_id, row.product_num, row.pnl_qty, row.pcs_qty, "出库单写回" + (row.IsremarkNull() ? string.Empty : ":" + row.remark), Session["user_name"].ToString() ); } //从单据内容中删除 daContent.DeleteByBillNum(billNum); //从单据表头中删除 daHead.Delete(billNum); //日期 DateTime billDate = Convert.ToDateTime(e.NewValues["bill_date"]); //下部门 string nextDeptName = Convert.ToString(e.NewValues["next_dept_name"]); //单据备注 string billRemark = Convert.ToString(e.NewValues["remark"]); //录入员 string addPerson = e.NewValues["add_person"].ToString(); //录入时间 DateTime addTime = Convert.ToDateTime(e.NewValues["add_time"]); //最后修改时间 DateTime lastChangeTime = Convert.ToDateTime(e.NewValues["last_change_time"]); //保存表头 daHead.Insert( billDate, billNum, deptName, nextDeptName, billRemark, addPerson, addTime, lastChangeTime ); //遍历子表执行保存 for (int iRow = 0; iRow < 10; iRow++) { //子表各控件 var tr = tabDataListSon.Rows[iRow + 1]; var litRowId = (Literal)tr.Cells[0].Controls[0]; var txtPrevDeptName = (TextBox)tr.Cells[1].Controls[0]; var txtLotId = (TextBox)tr.Cells[2].Controls[0]; var txtProductNum = (TextBox)tr.Cells[3].Controls[0]; var txtPnlQty = (TextBox)tr.Cells[4].Controls[0]; var txtPcsQty = (TextBox)tr.Cells[5].Controls[0]; var txtRemark = (TextBox)tr.Cells[6].Controls[0]; //取得数据 byte rowId = Convert.ToByte(litRowId.Text); string prevDeptName = txtPrevDeptName.Text; string lotId = txtLotId.Text; string productNum = txtProductNum.Text; Int16 pnlQty = txtPnlQty.Text.Trim().Length <= 0 ? (Int16)0 : Int16.Parse(txtPnlQty.Text.Trim()); int pcsQty = txtPcsQty.Text.Trim().Length <= 0 ? 0 : int.Parse(txtPcsQty.Text.Trim()); string remark = txtRemark.Text; //存在数据才保存 if (lotId.Length > 0 && productNum.Length > 0 && pnlQty + pcsQty > 0) { //保存到单据内容清单 daContent.Insert( billNum, rowId, prevDeptName, lotId, productNum, pnlQty, pcsQty, remark ); //保存到部门lot卡结存清单 daDept.Insert( deptName, nextDeptName, lotId, productNum, pnlQty, pcsQty, "出库单写入" + (remark.Length > 0 ? ":" + remark : string.Empty), true, Session["user_name"].ToString(), DateTime.Now, DateTime.Now ); //从成品结存清单中扣除 if (!ydOperateCompleteLotCard.DecreaseCompleteBalance( daBalance, prevDeptName, lotId, pnlQty, pcsQty )) { return false; } } } } } //提交事务 tran.Commit(); //返回成功 return true; } catch (Exception ex) { //回滚事务 tran.Rollback(); //非数字返回失败 throw new Exception(ex.Message); } } } }
/// <summary> /// 将url中提供的id的待报废记录数据写入窗口中的文本框 /// </summary> private void SetWaitScrapRecordToForm() { //调用过程填写默认值 fvWaitScrapRecordAccept_ItemCreated(null, null); //获取传入的url中的id参数 string strId = Request["waitid"]; int id; if (!string.IsNullOrWhiteSpace(strId) && int.TryParse(strId, out id)) { //获取该条记录的数据写入文本框 using (var da = new t_dept_lot_card_balanceTableAdapter()) using (var tab = da.GetDataById(id)) { //检测是否取到数据 if (tab.Rows.Count > 0) { //首行 var row = (DataSetDeptLotCardMgr.t_dept_lot_card_balanceRow)tab.Rows[0]; //填写数据 //lot卡号 var tb = (TextBox)fvWaitScrapRecordAccept.FindControl("txtLotId"); if (tb != null) { //设置默认值 tb.Text = row.lot_id; } //生产编号 tb = (TextBox)fvWaitScrapRecordAccept.FindControl("txtProductNum"); if (tb != null) { //设置默认值 tb.Text = row.product_num; } //pcs数量 tb = (TextBox)fvWaitScrapRecordAccept.FindControl("txtPcsQty"); if (tb != null) { //设置默认值 tb.Text = row.pcs_qty.ToString(); } } } } }
/// <summary> /// 根据输入的LOT格式来保存多条数据到数据库 /// </summary> /// <param name="e">传入的带有数据的事件参数</param> /// <param name="deptName">当前部门名称</param> /// <returns></returns> private bool InsertData(FormViewInsertEventArgs e, string deptName) { //日期 DateTime billDate = Convert.ToDateTime(e.Values["bill_date"]); //单号 string billNum = Convert.ToString(e.Values["bill_num"]); //下部门 string nextDeptName = Convert.ToString(e.Values["next_dept_name"]); //单据备注 string billRemark = Convert.ToString(e.Values["remark"]); //录入员 string addPerson = e.Values["add_person"].ToString(); //录入时间 DateTime addTime = Convert.ToDateTime(e.Values["add_time"]); //最后修改时间 DateTime lastChangeTime = Convert.ToDateTime(e.Values["last_change_time"]); //数据适配器 //当前添加语句对象 //当前数据库连接 using (var daHead = new t_complete_lot_card_out_headTableAdapter()) using (var daContent = new t_complete_lot_card_out_contentTableAdapter()) using (var daBalance = new t_complete_lot_card_balanceTableAdapter()) using (var daDept = new t_dept_lot_card_balanceTableAdapter()) using (var conn = daHead.Connection) { //打开数据库连接 conn.Open(); //开启事务 using (var tran = conn.BeginTransaction()) { //设置数据库连接对象 daContent.Connection = daBalance.Connection = daDept.Connection = conn; //设置事务 daHead.Transaction = daContent.Transaction = daBalance.Transaction = daDept.Transaction = tran; //试运行 try { //保存表头 daHead.Insert( billDate, billNum, deptName, nextDeptName, billRemark, addPerson, addTime, lastChangeTime ); //遍历子表执行保存 for (int iRow = 0; iRow < 10; iRow++) { //子表各控件 var tr = tabDataListSon.Rows[iRow + 1]; var litRowId = (Literal)tr.Cells[0].Controls[0]; var txtPrevDeptName = (TextBox)tr.Cells[1].Controls[0]; var txtLotId = (TextBox)tr.Cells[2].Controls[0]; var txtProductNum = (TextBox)tr.Cells[3].Controls[0]; var txtPnlQty = (TextBox)tr.Cells[4].Controls[0]; var txtPcsQty = (TextBox)tr.Cells[5].Controls[0]; var txtRemark = (TextBox)tr.Cells[6].Controls[0]; //取得数据 byte rowId = Convert.ToByte(litRowId.Text); string prevDeptName = txtPrevDeptName.Text; string lotId = txtLotId.Text; string productNum = txtProductNum.Text; Int16 pnlQty = txtPnlQty.Text.Trim().Length <= 0 ? (Int16)0 : Int16.Parse(txtPnlQty.Text.Trim()); int pcsQty = txtPcsQty.Text.Trim().Length <= 0 ? 0 : int.Parse(txtPcsQty.Text.Trim()); string remark = txtRemark.Text; //存在数据才保存 if (lotId.Length > 0 && productNum.Length > 0 && pnlQty + pcsQty > 0) { //保存到单据内容清单 daContent.Insert( billNum, rowId, prevDeptName, lotId, productNum, pnlQty, pcsQty, remark ); //保存到清单部门lot卡结存清单 daDept.Insert( deptName, nextDeptName, lotId, productNum, pnlQty, pcsQty, "出库单写入" + (remark.Length > 0 ? ":" + remark : string.Empty), true, Session["user_name"].ToString(), DateTime.Now, DateTime.Now ); //从成品结存清单中扣除 if (!ydOperateCompleteLotCard.DecreaseCompleteBalance( daBalance, prevDeptName, lotId, pnlQty, pcsQty )) { return false; } } } //提交事务 tran.Commit(); //返回成功 return true; } catch (Exception ex) { //回滚事务 tran.Rollback(); //非数字返回失败 throw new Exception(ex.Message); } } } }
/// <summary> /// 添加一条部门未完成lot卡或者到成品仓 /// </summary> /// <param name="tran">当前事务</param> /// <param name="e">包含有数据列表值的事件参数</param> /// <param name="isUpdatedBalance">是否扣过部门结存</param> /// <returns></returns> internal static bool InsertOneRecordToLotCardBalance( SqlTransaction tran, FormViewUpdateEventArgs e, bool isUpdatedBalance ) { //当前数据库连接对象 var conn = tran.Connection; try { //要插入到的部门名称 string nextDeptName = e.NewValues["next_dept_name"].ToString(); //检测当前部门 if (nextDeptName == "成品仓") { //实例化数据适配器 using (var da = new t_complete_lot_card_waitTableAdapter()) using (var cmd = da.Adapter.InsertCommand) { //设置数据库连接 da.Connection = conn; //设置事务 da.Transaction = tran; //设置超时 cmd.CommandTimeout = 50; //设置参数值 cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@prev_dept_name", e.NewValues["dept_name"]); cmd.Parameters.AddWithValue("@dept_name", nextDeptName); cmd.Parameters.AddWithValue("@lot_id", e.NewValues["lot_id"]); cmd.Parameters.AddWithValue("@product_num", e.NewValues["product_num"]); cmd.Parameters.AddWithValue("@pnl_qty", e.NewValues["pnl_qty"]); cmd.Parameters.AddWithValue("@pcs_qty", e.NewValues["pcs_qty"]); cmd.Parameters.AddWithValue("@remark", DBNull.Value); cmd.Parameters.AddWithValue("@add_person", e.NewValues["add_person"]); cmd.Parameters.AddWithValue("@add_time", e.NewValues["add_time"]); cmd.Parameters.AddWithValue("@last_change_time", e.NewValues["last_change_time"]); //执行查询 if (cmd.ExecuteNonQuery() == 0) { //抛出错误 throw new Exception("添加数据到下部门结存lot卡失败!"); } } } else { //实例化数据适配器 using (var da = new t_dept_lot_card_balanceTableAdapter()) using (var cmd = da.Adapter.InsertCommand) { //设置数据库连接 da.Connection = conn; //设置事务 da.Transaction = tran; //设置超时 cmd.CommandTimeout = 50; //设置参数值 cmd.Parameters.Clear(); //当前部门 string deptName = HttpContext.Current.Session["dept_name"].ToString(); if (deptName == "MRB") { cmd.Parameters.AddWithValue("@prev_dept_name", "MRB"); cmd.Parameters.AddWithValue("@dept_name", e.NewValues["dept_name"]); } else { cmd.Parameters.AddWithValue("@prev_dept_name", e.NewValues["dept_name"]); cmd.Parameters.AddWithValue("@dept_name", nextDeptName); } cmd.Parameters.AddWithValue("@lot_id", e.NewValues["lot_id"]); cmd.Parameters.AddWithValue("@product_num", e.NewValues["product_num"]); cmd.Parameters.AddWithValue("@pnl_qty", e.NewValues["pnl_qty"]); cmd.Parameters.AddWithValue("@pcs_qty", e.NewValues["pcs_qty"]); cmd.Parameters.AddWithValue("@remark", DBNull.Value); cmd.Parameters.AddWithValue("@is_updated_balance", isUpdatedBalance); cmd.Parameters.AddWithValue("@add_person", e.NewValues["add_person"]); cmd.Parameters.AddWithValue("@add_time", e.NewValues["add_time"]); cmd.Parameters.AddWithValue("@last_change_time", e.NewValues["last_change_time"]); //执行查询 if (cmd.ExecuteNonQuery() == 0) { //抛出错误 throw new Exception("添加数据到下部门结存lot卡失败!"); } } } //返回成功 return true; } catch (Exception ex) { //抛出错误 throw ex; } }
/// <summary> /// 添加一条下部门未完成lot卡或者到成品仓记录 /// </summary> /// <param name="tran">当前事务</param> /// <param name="nextDeptName">部门名称</param> /// <param name="lotId">要保存的记录中保存的lot卡号</param> /// <param name="e">包含有数据列表值的事件参数</param> /// <param name="isUpdatedBalance">是否有扣部门结存</param> /// <returns></returns> private static bool InsertOneRecordToLotCardBalance( SqlTransaction tran, string nextDeptName, string lotId, FormViewInsertEventArgs e, bool isUpdatedBalance ) { //当前数据库连接对象 var conn = tran.Connection; try { //查询对象 SqlCommand cmd; //检测部门名称 if (nextDeptName == "成品仓") { //实例化数据适配器 var da = new t_complete_lot_card_waitTableAdapter(); //设置事务 da.Transaction = tran; //查询对象 cmd = da.Adapter.InsertCommand; } else { //实例化数据适配器 var da = new t_dept_lot_card_balanceTableAdapter(); //设置事务 da.Transaction = tran; //查询对象 cmd = da.Adapter.InsertCommand; } //设置数据库连接 cmd.Connection = conn; //设置参数和属性后保存 using (cmd) { //设置超时 cmd.CommandTimeout = 50; //设置参数值 cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@prev_dept_name", e.Values["dept_name"]); cmd.Parameters.AddWithValue("@dept_name", nextDeptName); cmd.Parameters.AddWithValue("@lot_id", lotId); cmd.Parameters.AddWithValue("@product_num", e.Values["product_num"]); cmd.Parameters.AddWithValue("@pnl_qty", e.Values["pnl_qty"]); cmd.Parameters.AddWithValue("@pcs_qty", e.Values["pcs_qty"]); cmd.Parameters.AddWithValue("@remark", DBNull.Value); cmd.Parameters.AddWithValue("@is_updated_balance", isUpdatedBalance); cmd.Parameters.AddWithValue("@add_person", e.Values["add_person"]); cmd.Parameters.AddWithValue("@add_time", e.Values["add_time"]); cmd.Parameters.AddWithValue("@last_change_time", e.Values["last_change_time"]); //执行查询 if (cmd.ExecuteNonQuery() == 0) { //抛出错误 throw new Exception("添加数据到下部门结存lot卡失败!"); } //返回成功 return true; } } catch (Exception ex) { //抛出错误 throw ex; } }
/// <summary> /// 检测是否存在指定的部门名称 /// </summary> /// <param name="tran">当前事务</param> /// <param name="deptName">部门名称</param> /// <param name="lotId">当前待报数的lot卡号</param> /// <returns></returns> internal static bool IsMinLotId(SqlTransaction tran, string deptName, string lotId) { //部门名称转大写 deptName = deptName.ToUpper(); //检测lot卡号 if (lotId.Length < 6) { throw new Exception("提供的lot卡号不正确!"); } //实例化数据适配器并获取数据 using (var da = new t_dept_lot_card_balanceTableAdapter()) { //当前数据库连接 da.Connection = tran.Connection; //设置事务 da.Transaction = tran; //获取 string minLotId; //检测是否样板 bool isSample = lotId.ToUpper().Contains("S"); //非样板使用生产订单和lot卡中的数据 if (!isSample) { minLotId = da.GetMinLotIdByDeptName(deptName, lotId).ToString(); } else { minLotId = da.GetMinSampleLotIdByDeptName(deptName, lotId).ToString(); } //检测是否获取到数据 if (minLotId != null && minLotId.ToString() == lotId) { //提供的是本部门结存中的最小lot卡号 return true; } else { //提供的不是本部门结存中的最小lot卡号 throw new Exception( string.Format( "当前lot卡 {0} 不是最小的lot卡号 {1}", lotId, minLotId ) ); } } }
//根据传入的参数处理事情 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); }