|
地板
楼主 |
发表于 2014-10-1 10:32:38
|
只看该作者
- public static string GetPrintHtmlJS(List<int> ids)
- {
- var sb = new StringBuilder();
- sb.AppendLine(" function PrintTable() {");
- sb.AppendLine(" LODOP = getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM'));");
- sb.AppendLine(" LODOP.PRINT_INITA(0,0,378,186, "非生产用固定资产条");");
- sb.AppendLine(" LODOP.SET_PRINT_PAGESIZE(0,1000,500,"");");
- var fSumvalue = 0;
- var PrintTime = 1;
- //取到ids的批量值
- for (int i = 0; i < ids.Count; i++)
- {
- //从LIST里取值,并强制转化为int型
- int id = int.Parse(ids[i].ToString());
- //通过ID查询出值
- Non_FixedAssets current = DB.Non_FixedAssetss.Where(eq => eq.ID == id).FirstOrDefault();
- var strKacode = current.Non_KaCode;
- var strFixedCode = current.Non_FixedCode;
- var strName = current.Non_Name;
- var strSpecification = current.Non_Specification;
- var strDept = current.Non_Dept;
- var strUseTime = current.Non_UseTime;
- var strPlace = current.Non_Place;
- var strNumber = current.Non_Number;
- var strListStatus = current.Non_Status;
- var strListUnit = current.Non_Unit;
- var strUseUser = current.Non_UseUser;
- var strMoney = current.Non_Money;
- var strDes = current.Non_DES;
- fSumvalue = fSumvalue + int.Parse(strNumber);
- if (fSumvalue < 50)
- {
- for (int y = 1; y < int.Parse(strNumber)+1; y++)
- {
- //可以用NewPage函数直接强制在新一页的固定位置输出。
- sb.AppendLine(" LODOP.NewPage();");
- //以下都是设置
- sb.AppendLine(" LODOP.ADD_PRINT_TEXT(2,41,300,33,"非生产用固定资产条");");
- sb.AppendLine(" LODOP.SET_PRINT_STYLEA(0,"FontName","微软雅黑");");
- sb.AppendLine(" LODOP.SET_PRINT_STYLEA(0,"FontSize",16);");
- sb.AppendLine(" LODOP.SET_PRINT_STYLEA(0,"Alignment",2);");
- sb.AppendLine(" LODOP.ADD_PRINT_RECT(56,6,70,20,0,1);");
- sb.AppendLine(" LODOP.ADD_PRINT_RECT(56,75,298,20,0,1);");
- sb.AppendLine(" LODOP.ADD_PRINT_RECT(37,6,70,20,0,1);");
- sb.AppendLine(" LODOP.ADD_PRINT_RECT(37,75,298,20,0,1);");
- sb.AppendLine(" LODOP.ADD_PRINT_RECT(75,263,110,20,0,1);");
- sb.AppendLine(" LODOP.ADD_PRINT_RECT(75,194,70,20,0,1);");
- sb.AppendLine(" LODOP.ADD_PRINT_RECT(75,75,120,20,0,1);");
- sb.AppendLine(" LODOP.ADD_PRINT_RECT(75,6,70,20,0,1);");
- sb.AppendLine(" LODOP.ADD_PRINT_RECT(94,263,110,20,0,1);");
- sb.AppendLine(" LODOP.ADD_PRINT_RECT(94,194,70,20,0,1);");
- sb.AppendLine(" LODOP.ADD_PRINT_RECT(94,75,120,20,0,1);");
- sb.AppendLine(" LODOP.ADD_PRINT_RECT(94,6,70,20,0,1);");
- sb.AppendLine(" LODOP.ADD_PRINT_RECT(113,263,110,20,0,1);");
- sb.AppendLine(" LODOP.ADD_PRINT_RECT(113,194,70,20,0,1);");
- sb.AppendLine(" LODOP.ADD_PRINT_RECT(113,75,120,20,0,1);");
- sb.AppendLine(" LODOP.ADD_PRINT_RECT(113,6,70,20,0,1);");
- sb.AppendLine(" LODOP.ADD_PRINT_RECT(132,263,110,20,0,1);");
- sb.AppendLine(" LODOP.ADD_PRINT_RECT(132,194,70,20,0,1);");
- sb.AppendLine(" LODOP.ADD_PRINT_RECT(132,75,120,20,0,1);");
- sb.AppendLine(" LODOP.ADD_PRINT_RECT(132,6,70,20,0,1);");
- sb.AppendLine(" LODOP.ADD_PRINT_TEXT(152,8,65,17,"存放地点");");
- sb.AppendLine(" LODOP.ADD_PRINT_TEXT(39,9,65,17,"资产名称");");
- sb.AppendLine(" LODOP.ADD_PRINT_TEXT(77,9,65,17,"资产编码");");
- sb.AppendLine(" LODOP.ADD_PRINT_TEXT(96,9,65,17,"资产原值");");
- sb.AppendLine(" LODOP.ADD_PRINT_TEXT(115,9,65,17,"责任人");");
- sb.AppendLine(" LODOP.ADD_PRINT_TEXT(134,9,65,17,"数量");");
- sb.AppendLine(" LODOP.ADD_PRINT_TEXT(58,9,65,17,"规格型号");");
- sb.AppendLine(" LODOP.ADD_PRINT_TEXT(77,196,65,17,"卡片编码");");
- sb.AppendLine(" LODOP.ADD_PRINT_TEXT(96,196,65,17,"使用部门");");
- sb.AppendLine(" LODOP.ADD_PRINT_TEXT(115,197,65,17,"启用日期");");
- sb.AppendLine(" LODOP.ADD_PRINT_TEXT(134,196,65,17,"序号");");
- sb.AppendLine(" LODOP.ADD_PRINT_RECT(151,6,70,20,0,1);");
- sb.AppendLine(" LODOP.ADD_PRINT_RECT(151,75,298,20,0,1);");
- sb.AppendLine(" LODOP.ADD_PRINT_TEXT(76,79,115,17,'" + strFixedCode + "');");
- sb.AppendLine(" LODOP.ADD_PRINT_TEXT(39,79,291,17, '" + strName + "');");
- sb.AppendLine(" LODOP.ADD_PRINT_TEXT(115,79,115,17,'" + strUseUser + "');");
- sb.AppendLine(" LODOP.ADD_PRINT_TEXT(96,79,115,17,'" + strMoney + "');");
- sb.AppendLine(" LODOP.ADD_PRINT_TEXT(134,79,115,17,'" + strNumber + "');");
- sb.AppendLine(" LODOP.ADD_PRINT_TEXT(57,80,291,17,'" + strSpecification + "');");
- sb.AppendLine(" LODOP.ADD_PRINT_TEXT(78,266,105,17,'" + strKacode + "');");
- sb.AppendLine(" LODOP.ADD_PRINT_TEXT(97,265,105,17,'" + strDept + "');");
- sb.AppendLine(" LODOP.ADD_PRINT_TEXT(116,265,105,17,'" + strUseTime + "');");
- sb.AppendLine(" LODOP.ADD_PRINT_TEXT(153,78,292,17,'" + strPlace + "');");
- sb.AppendLine(" LODOP.ADD_PRINT_TEXT(133,265,105,17,'" + strNumber + "'+"-"+'"+y+"');");
- }
- }
- else {
- Alert.ShowInTop("大姐啊!你选择单条数据,数量已经达到:" + fSumvalue + ",所选择的数量大于50,暂时不会打印了!");
- }
- // Non_FixedAssets current1 = DB.Non_FixedAssetss.Where(eq => ids.Contains(eq.ID)).FirstOrDefault();
- //打印次数
- current.Non_PrintTimes += PrintTime;
- //更新打印次数
- DB.SaveChanges();
- }
- if (fSumvalue < 50) {
- //打印预览
- Alert.ShowInTop("你已经选择了:" + ids.Count + "条数量!会打印:" + fSumvalue + "次!");
- sb.AppendLine(" LODOP.PREVIEW();");
- }
- else
- {
- Alert.ShowInTop("大姐啊!你选择了:" + ids.Count + "条数据,但数量已经达到:" + fSumvalue + ",所选择的数量大于50,暂时不会打印了!");
- }
-
- sb.AppendLine(" };");
- sb.AppendFormat("window.setTimeout(function(){{PrintTable();}},100);", ids);
- return sb.ToString();
-
- }
- protected void btnPrint_Click(object sender, EventArgs e)
- {
-
- //从表格里得到LIST的值
- List<int> ids = GetSelectedDataKeyIDs(Grid1);
-
- PageContext.RegisterStartupScript(FixedAssets_non.GetPrintHtmlJS(ids));
-
-
- }
复制代码 |
|