private void BindApplyReason() { DataTable dt = PurchaseApplyDBHelper.GetApplyReason(); if (dt != null && dt.Rows.Count > 0) { ddlApplyReasonHidden.DataSource = dt; ddlApplyReasonHidden.DataTextField = "CodeName"; ddlApplyReasonHidden.DataValueField = "ID"; ddlApplyReasonHidden.DataBind(); } ddlApplyReasonHidden.Items.Insert(0, new ListItem("--请选择--", "")); }
/*构造HTML*/ protected string CreateHtml(DataTable dt, ref decimal TotalCount) { /*读取原因*/ DataTable dtReason = PurchaseApplyDBHelper.GetApplyReason(); StringBuilder sbHtml = new StringBuilder(); sbHtml.AppendLine(" <table width=\"99%\" border=\"0\" id=\"dg_Log\" align=\"center\" cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"#999999\">"); sbHtml.AppendLine(" <tr>"); sbHtml.AppendLine(" <td bgcolor=\"#E6E6E6\" class=\"Blue\" width=\"50\" align=\"center\"> <input type=\"checkbox\" name=\"checkall\" id=\"checkall\" onclick=\"SelectAll()\" title=\"全选\" style=\"cursor: hand\" /> </td>"); sbHtml.AppendLine(" <td align=\"center\" bgcolor=\"#E6E6E6\" class=\"ListTitle\" valign=\"middle\"> 序号</td>"); sbHtml.AppendLine(" <td align=\"center\" bgcolor=\"#E6E6E6\" class=\"ListTitle\" valign=\"middle\"> 物品编号<span class=\"redbold\">*</span> </td>"); sbHtml.AppendLine(" <td align=\"center\" bgcolor=\"#E6E6E6\" class=\"ListTitle\" valign=\"middle\">物品名称<span class=\"redbold\">*</span> </td>"); sbHtml.AppendLine(" <td align=\"center\" bgcolor=\"#E6E6E6\" class=\"ListTitle\" valign=\"middle\">规格 </td>"); sbHtml.AppendLine(" <td align=\"center\" bgcolor=\"#E6E6E6\" class=\"ListTitle\" valign=\"middle\">颜色 </td>"); sbHtml.AppendLine(" <td align=\"center\" bgcolor=\"#E6E6E6\" class=\"ListTitle\" valign=\"middle\"> <span id=\"spUnitID\">单位</span> <span class=\"redbold\">*</span> </td>"); sbHtml.AppendLine(" <td align=\"center\" bgcolor=\"#E6E6E6\" class=\"ListTitle\" valign=\"middle\" style=\"width:3%; display:none \" id=\"spUsedUnitID\">单位 </td>"); sbHtml.AppendLine(" <td align=\"center\" bgcolor=\"#E6E6E6\" class=\"ListTitle\" style=\"width:3%\"> <span id=\"SpProductCount\">需求数量</span><span class=\"redbold\" id=\"spCount\">*</span></td>"); sbHtml.AppendLine(" <td align=\"center\" bgcolor=\"#E6E6E6\" class=\"ListTitle\" valign=\"middle\" style=\"width:7%; display:none \" id=\"spUsedUnitCount\"> 需求数量 <span class=\"redbold\">*</span> </td>"); sbHtml.AppendLine(" <td align=\"center\" bgcolor=\"#E6E6E6\" class=\"ListTitle\" valign=\"middle\">需求日期<span class=\"redbold\">*</span></td>"); sbHtml.AppendLine(" <td align=\"center\" bgcolor=\"#E6E6E6\" class=\"ListTitle\" valign=\"middle\"> 申请原因 </td>"); sbHtml.AppendLine(" <td align=\"center\" bgcolor=\"#E6E6E6\" class=\"ListTitle\"> 源单编号 </td>"); sbHtml.AppendLine(" <td align=\"center\" bgcolor=\"#E6E6E6\" class=\"ListTitle\" > 源单序号</td>"); sbHtml.AppendLine(" </tr>"); txtTRLastIndex.Value = (Convert.ToInt32(txtTRLastIndex.Value) + dt.Rows.Count).ToString(); int i = 1; foreach (DataRow row in dt.Rows) { decimal ApplyCount1 = row["ApplyCount"] == null ? 0 : Convert.ToDecimal(row["ApplyCount"].ToString()); TotalCount += ApplyCount1; sbHtml.AppendLine("<tr id=\"Item_Row_" + i.ToString() + "\">"); sbHtml.AppendLine("<td class=\"cell\"><input name='chk' id='chk_Option_" + i.ToString() + "' value=\"0\" type='checkbox' onclick=\"ClearAllOption();\" /></td> "); sbHtml.AppendLine("<td class=\"cell\" ><input type=\"text\" id=\"TD_Text_SortNo_" + i.ToString() + "\" value=\"" + i.ToString() + " \" class=\"tdinput\" size=\"5\" disabled=\"disabled\" /></td>"); sbHtml.AppendLine("<td class=\"cell\" ><input type=\"text\" id=\"TD_Text_ProdNo_" + i.ToString() + "\" value=\"" + row["ProdNo"].ToString() + "\" class=\"tdinput\" size=\"8\" onclick=\"popTechObj.ShowList('" + i.ToString() + "');\" readonly=\"readonly\" /></td>"); sbHtml.AppendLine("<td class=\"cell\" ><input type=\"hidden\" id=\"Hidden_TD_Text_ProductID_" + i.ToString() + "\" value=\"" + row["ID"].ToString() + "\" /><input type=\"text\" id=\"TD_Text_ProductID_" + i.ToString() + "\" value=\"" + row["ProductName"].ToString() + "\" class=\"tdinput\" size=\"10\" onclick=\"popTechObj.ShowList('" + i.ToString() + "');\" readonly=\"readonly\" /></td>"); sbHtml.AppendLine("<td class=\"cell\" ><input type=\"text\" id=\"TD_Text_Specification_" + i.ToString() + "\" value=\"" + row["Specification"].ToString() + "\" class=\"tdinput\" size=\"8\" readonly=\"readonly\" /></td>"); sbHtml.AppendLine("<td class=\"cell\" ><input type=\"text\" id=\"DtlSColor" + i.ToString() + "\" value=\"" + row["ColorName"].ToString() + "\" class=\"tdinput\" size=\"8\" readonly=\"readonly\" /></td>"); if (!((UserInfoUtil)SessionUtil.Session["UserInfo"]).IsMoreUnit) { sbHtml.AppendLine("<td class=\"cell\" ><input type=\"hidden\" id='Hidden_TD_Text_UnitID_" + i.ToString() + "' value=\"" + row["UnitID"].ToString() + "\" /><input type=\"text\" id='TD_Text_UnitID_" + i.ToString() + "' value=\"" + row["CodeName"].ToString() + "\" class=\"tdinput\" size=\"6\" readonly=\"readonly\"/></td>"); decimal ApplyCount = decimal.Parse(row["ApplyCount"] == null ? "0" : row["ApplyCount"].ToString()); sbHtml.AppendLine("<td class=\"cell\" ><input type=\"text\" id='TD_Text_ProductCount_" + i.ToString() + "' class=\"tdinput\" size=\"10\" value=\"" + ApplyCount.ToString("F" + ((UserInfoUtil)SessionUtil.Session["UserInfo"]).SelPoint) + "\" onblur=\"fnCalculateTotal();\" /></td>"); } else { sbHtml.AppendLine("<td class=\"cell\" ><input type=\"hidden\" id='Hidden_TD_Text_UnitID_" + i.ToString() + "' value=\"" + row["UnitID"].ToString() + "\" /><input type=\"text\" id='TD_Text_UnitID_" + i.ToString() + "' value=\"" + row["CodeName"].ToString() + "\" class=\"tdinput\" size=\"6\" readonly=\"readonly\"/></td>"); string unitHtml = ""; decimal tmpExRate = 1;/*换算率*/ /*计量单位HTML*/ unitHtml = XBase.Business.Common.UnitGroup.GetUnitGroupByProductId(row["ID"].ToString(), "InUnit", "SignItem_TD_UnitID_Select" + i.ToString(), "ChangeUnit(this," + i.ToString() + ")", "", ref tmpExRate); decimal ApplyCount = decimal.Parse(row["ApplyCount"] == null ? "0" : row["ApplyCount"].ToString()); decimal usedCount = 0; if (tmpExRate != 0) { usedCount = ApplyCount * tmpExRate; } string us = usedCount.ToString("F" + ((UserInfoUtil)SessionUtil.Session["UserInfo"]).SelPoint); sbHtml.AppendLine("<td class=\"cell\"><div id=\"unitdiv" + i.ToString() + "\">" + unitHtml + "</div></td>"); sbHtml.AppendLine("<td class=\"cell\" ><input type=\"text\" id='TD_Text_ProductCount_" + i.ToString() + "' class=\"tdinput\" size=\"10\" value=\"" + us + "\" onblur=\"fnCalculateTotal();\" /></td>"); sbHtml.AppendLine("<td class=\"cell\" ><input id='UsedUnitCount" + i.ToString() + "' type='text' class=\"tdinput\" value=\"" + ApplyCount.ToString("F" + ((UserInfoUtil)SessionUtil.Session["UserInfo"]).SelPoint) + "\" style='width:90%;' onblur=\"Number_round(this," + ((UserInfoUtil)SessionUtil.Session["UserInfo"]).SelPoint + "); ChangeUnit(this.id," + i.ToString() + ")\" /></td>"); } sbHtml.AppendLine("<td class=\"cell\" ><input type=\"text\" id='TD_Text_StartDate_" + i.ToString() + "' value=\"" + row["ApplyDate"].ToString() + "\" class=\"tdinput\" onclick=\"WdatePicker({dateFmt:'yyyy-MM-dd',el:$dp.$('TD_Text_StartDate_" + i.ToString() + "')})\" size=\"10\" onpropertychange =\"fnCalculateTotal();\"/></td>"); sbHtml.AppendLine("<td class=\"cell\" >" + CreateSelectForReason(dtReason, i.ToString()) + " </td>"); sbHtml.AppendLine("<td class=\"cell\" ><input type=\"text\" id='TD_Text_FromBillNo_" + i.ToString() + "' value=\"\" class=\"tdinput\" size=\"10\" readonly=\"readonly\" disabled=\"disabled\" /><input type=\"hidden\" id='TD_Text_FromBillID_" + i.ToString() + "' value=\"0\" class=\"tdinput\" size=\"10\" /></td>"); sbHtml.AppendLine("<td class=\"cell\" ><input type=\"text\" id='TD_Text_FromLineNo_" + i.ToString() + "' value=\"\" class=\"tdinput\" size=\"5\" readonly=\"readonly\" disabled=\"disabled\" /></td>"); sbHtml.AppendLine("</tr>"); i++; } sbHtml.AppendLine(" </table> "); return(sbHtml.ToString()); }
/*构造HTML*/ protected string CreateHtml(DataTable dt, ref int TotalCount) { /*读取原因*/ DataTable dtReason = PurchaseApplyDBHelper.GetApplyReason(); StringBuilder sbHtml = new StringBuilder(); sbHtml.AppendLine("<table width=\"99%\" border=\"0\" id=\"DetailSTable\" align=\"center\" cellpadding=\"0\" cellspacing=\"1\" "); sbHtml.AppendLine("bgcolor=\"#999999\"> "); sbHtml.AppendLine("<tr> "); sbHtml.AppendLine(" <td bgcolor=\"#E6E6E6\" width=\"50\" align=\"center\"> "); sbHtml.AppendLine(" 全选<input type=\"checkbox\" id=\"checkall\" onclick=\"fnSelectAll();\" title=\"全选\" /> "); sbHtml.AppendLine(" </td> "); sbHtml.AppendLine(" <td align=\"center\" bgcolor=\"#E6E6E6\" class=\"ListTitle\" align=\"center\"> "); sbHtml.AppendLine(" 序号 "); sbHtml.AppendLine(" </td> "); sbHtml.AppendLine(" <td align=\"center\" bgcolor=\"#E6E6E6\" class=\"ListTitle\" valign=\"middle\"> "); sbHtml.AppendLine(" 商品编号<span class=\"redbold\">*</span> "); sbHtml.AppendLine(" <uc6:MaterialChoose ID=\"MaterialChoose1\" runat=\"server\" /> "); sbHtml.AppendLine(" </td> "); sbHtml.AppendLine(" <td align=\"center\" bgcolor=\"#E6E6E6\" class=\"ListTitle\" valign=\"middle\"> "); sbHtml.AppendLine(" 商品名称<span class=\"redbold\">*</span> "); sbHtml.AppendLine(" </td> "); sbHtml.AppendLine(" <td align=\"center\" bgcolor=\"#E6E6E6\" class=\"ListTitle\"> "); sbHtml.AppendLine(" 规格<span class=\"redbold\">*</span> "); sbHtml.AppendLine(" </td> "); sbHtml.AppendLine(" <td align=\"center\" bgcolor=\"#E6E6E6\" class=\"ListTitle\" valign=\"middle\"> "); sbHtml.AppendLine(" 单位<span class=\"redbold\">*</span> "); sbHtml.AppendLine(" </td> "); sbHtml.AppendLine(" <td align=\"center\" bgcolor=\"#E6E6E6\" class=\"ListTitle\"> "); sbHtml.AppendLine(" 需求数量<span class=\"redbold\">*</span> "); sbHtml.AppendLine(" </td> "); sbHtml.AppendLine(" <td align=\"center\" bgcolor=\"#E6E6E6\" class=\"ListTitle\"> "); sbHtml.AppendLine(" 需求日期<span class=\"redbold\">*</span> "); sbHtml.AppendLine(" </td> "); sbHtml.AppendLine(" <td align=\"center\" bgcolor=\"#E6E6E6\" class=\"ListTitle\" style=\"width: 7%\"> "); sbHtml.AppendLine(" 申请原因 "); sbHtml.AppendLine(" </td> "); sbHtml.AppendLine(" <td align=\"center\" bgcolor=\"#E6E6E6\" class=\"ListTitle\"> "); sbHtml.AppendLine(" 源单编号 "); sbHtml.AppendLine(" </td> "); sbHtml.AppendLine(" <td align=\"center\" bgcolor=\"#E6E6E6\" class=\"ListTitle\" > "); sbHtml.AppendLine(" 源单序号 "); sbHtml.AppendLine(" </td> "); sbHtml.AppendLine(" </tr> "); int i = 1; foreach (DataRow row in dt.Rows) { TotalCount += Convert.ToInt32(row["ApplyCount"].ToString()); sbHtml.AppendLine("<tr id=\"SignItem" + i.ToString() + "\">"); sbHtml.AppendLine("<td style=\"display:none;\"><input id='DtlSFromBillID" + i.ToString() + "' type='text' class=\"tdinput\" style='width:90%;' /><input id='DtlSFromLineNo" + i.ToString() + "' type='text' class=\"tdinput\" style='width:90%;' disabled/><input id='DtlSRemark" + i.ToString() + "' SpecialWorkCheck='明细来源备注' type='text' class=\"tdinput\" style='width:90%;' /></td>"); sbHtml.AppendLine("<td class=\"cell\"><input name='chk' id='chk" + i.ToString() + "' onclick=\"IfSelectAll('chk','checkall')\" value=" + i.ToString() + " type='checkbox' size='20' /></td><input id='DtlSProdID" + i.ToString() + "' type='hidden' class=\"tdinput\" style='width:90%;' value=\"" + row["ID"].ToString() + "\"/>"); sbHtml.AppendLine("<td class=\"cell\" id=\"DtlSSortNo" + i.ToString() + "\">" + i.ToString() + "</td>"); sbHtml.AppendLine("<td class=\"cell\"><input id='DtlSProdNo" + i.ToString() + "'readonly onclick=\"fnGetProduct(" + i.ToString() + ");\" type='text' class=\"tdinput\" style='width:90%;' value=\"" + row["ProdNo"].ToString() + "\"/></td>"); sbHtml.AppendLine("<td class=\"cell\"><input id='DtlSProdName" + i.ToString() + "'onclick=\"fnGetProduct(" + i.ToString() + ");\" value=\"" + row["ProductName"].ToString() + "\" type='text' class=\"tdinput\" style='width:90%;' disabled /></td>"); sbHtml.AppendLine("<td class=\"cell\"><input id='DtlSSpecification" + i.ToString() + "' type='text' class=\"tdinput\" value=\"" + row["Specification"].ToString() + "\" style='width:90%;' disabled /><input id='DtlSUnitID" + i.ToString() + "' type='hidden' style='width:90%;' value=\"" + row["UnitID"].ToString() + "\" /></td>"); sbHtml.AppendLine("<td class=\"cell\"><input id='DtlSUnitName" + i.ToString() + "' type='text' class=\"tdinput\" style='width:90%;' disabled value=\"" + row["CodeName"].ToString() + "\" /></td>"); sbHtml.AppendLine("<td class=\"cell\"><input id='DtlSPlanCount" + i.ToString() + "'onblur=\"Number_round(this,2);fnCalculateTotal();\" type='text' class=\"tdinput\" style='width:90%;' value=\"" + row["ApplyCount"].ToString() + "\" /></td>"); sbHtml.AppendLine("<td class=\"cell\"><input id='DtlSPlanTakeDate" + i.ToString() + "' onclick=\"WdatePicker()\" onchange=\"fnCalculateTotal();\" type='text' class=\"tdinput\" style='width:90%;' value=\"" + row["ApplyDate"].ToString() + "\" /><input id='DtlSFromBillID" + i.ToString() + "' type='hidden' class=\"tdinput\" style='width:90%;' /></td>"); sbHtml.AppendLine("<td class=\"cell\">" + CreateSelectForReason(dtReason, i.ToString()) + "</td>"); sbHtml.AppendLine("<td class=\"cell\"><input id='DtlSFromBillNO" + i.ToString() + "' type='text' class=\"tdinput\" style='width:90%;' disabled /></td>"); sbHtml.AppendLine("<td class=\"cell\"><input id='DtlSFromLineNo" + i.ToString() + "' type='text' class=\"tdinput\" style='width:90%;' disabled/></td>"); sbHtml.AppendLine("</tr>"); i++; } sbHtml.AppendLine(" </table> "); return(sbHtml.ToString()); }