Ejemplo n.º 1
0
    /// <summary>
    /// 绑定报表
    /// </summary>
    private void Print()
    {
        UserInfoUtil UserInfo = (UserInfoUtil)SessionUtil.Session["UserInfo"];
        /*接受参数*/
        int    ID        = int.Parse(Request.QueryString["ID"].ToString());
        string CompanyCD = UserInfo.CompanyCD;
        string DeptID    = Convert.ToString(UserInfo.DeptID);
        /*读取数据*/
        DataTable dtp     = SubStorageBus.SubStorageIn(ID);
        DataTable Details = SubStorageBus.Details(ID, DeptID);

        /*绑定RPT*/
        if (dtp != null)
        {
            /*加载主报表*/
            rd.Load(Server.MapPath(@"~/PrinttingModel/SubStoreManager/PrintSubStorageInit.rpt"));
            CrystalReportViewer1.LogOnInfo.Add(ReportUtil.GetTableLogOnInfo("officedba.View_PrintSubStorageInit"));

            /*加载子报表*/
            ReportDocument rdDetail = rd.Subreports["PrintSubStorageInitDetail.rpt"];
            rdDetail.SetDataSource(Details);

            //绑定数据
            rd.SetDataSource(dtp);

            rd.Refresh();
            this.CrystalReportViewer1.ReportSource = rd;
            rd.SetParameterValue("Creator", UserInfo.UserName);
        }
    }
Ejemplo n.º 2
0
    protected void LoadPrintInfo()
    {
        PrintParameterSettingModel pModel = new PrintParameterSettingModel();

        pModel.CompanyCD     = UserInfo.CompanyCD;
        pModel.BillTypeFlag  = int.Parse(ConstUtil.BILL_TYPEFLAG_SUBSTORAGE);
        pModel.PrintTypeFlag = ConstUtil.PRINTBILL_TYPEFLAG_SUBSTORAGEIN;


        /*此处需注意在模板设置表里的字段和取基本信息的字段是否一致*/
        string[,] aBase =
        {
            { "{ExtField1}",  "ExtField1"      },
            { "{ExtField2}",  "ExtField2"      },
            { "{ExtField3}",  "ExtField3"      },
            { "{ExtField4}",  "ExtField4"      },
            { "{ExtField5}",  "ExtField5"      },
            { "{ExtField6}",  "ExtField6"      },
            { "{ExtField7}",  "ExtField7"      },
            { "{ExtField8}",  "ExtField8"      },
            { "{ExtField9}",  "ExtField9"      },
            { "{ExtField10}", "ExtField10"     },
            { "入库单编号",        "InNo"           },
            { "入库单主题",        "Title"          },
            { "分店名称",         "DeptName"       },
            { "制单人",          "CreatorName"    },
            { "制单日期",         "CreateDate"     },
            { "单据状态",         "BillStatusName" },
            { "确认人",          "ConfirmorName"  },
            { "确认日期",         "ConfirmDate"    },
            { "最后更新人",        "ModifiedUserID" },
            { "最后更新日期",       "ModifiedDate"   },
            { "备注",           "Remark"         },
        };

        string[,] aDetail =
        {
            { "序号",   "SortNo"      },
            { "物品编号", "ProductNo"   },
            { "物品名称", "ProductName" },
            { "批次",   "BatchNo"     },
            { "规格",   "standard"    },
            { "单位",   "UnitName"    },
            { "入库数量", "SendCount"   }
        };
        if (_isMoreUnit)
        {// 启用多计量单位
            aDetail = new string[, ]
            {
                { "序号", "SortNo" },
                { "物品编号", "ProductNo" },
                { "物品名称", "ProductName" },
                { "批次", "BatchNo" },
                { "规格", "standard" },
                { "基本单位", "UnitName" },
                { "基本数量", "SendCount" },
                { "单位", "UsedUnitName" },
                { "入库数量", "UsedUnitCount" }
            };
        }

        #region 扩展属性
        DataTable dtExtTable = TableExtFieldsBus.GetAllList(UserInfo.CompanyCD, "", "officedba.SubStorageIn");
        int       countExt   = 0;
        for (int i = 0; i < dtExtTable.Rows.Count; i++)
        {
            aBase[i, 0] = dtExtTable.Rows[i]["EFDesc"].ToString();
            countExt++;
        }
        #endregion

        DataTable dbPrint  = XBase.Business.Common.PrintParameterSettingBus.GetPrintParameterSettingInfo(pModel);
        DataTable dt       = SubStorageBus.SubStorageIn(intID);
        string    deptID   = UserInfo.DeptID.ToString();
        DataRow   dtDeptID = SubStorageDBHelper.GetSubDeptFromDeptID(UserInfo.DeptID.ToString());
        if (dtDeptID != null)
        {
            deptID = dtDeptID["ID"].ToString();
        }
        DataTable dtDetail = SubStorageBus.Details(intID, deptID);
        dtDetail.Columns.Add("SortNo", typeof(string));
        for (int i = 0; i < dtDetail.Rows.Count; i++)
        {
            dtDetail.Rows[i]["SortNo"] = i + 1;
        }
        string strBaseFields   = "";
        string strDetailFields = "";

        if (dbPrint.Rows.Count > 0)
        {
            isSeted.Value   = "1";
            strBaseFields   = dbPrint.Rows[0]["BaseFields"].ToString();
            strDetailFields = dbPrint.Rows[0]["DetailFields"].ToString();
        }
        else
        {
            isSeted.Value = "0";
            strBaseFields = GetDefaultFields(aBase);
            /*基本信息字段+扩展信息字段*/
            if (countExt > 0)
            {
                for (int i = 0; i < countExt; i++)
                {
                    strBaseFields += "|ExtField" + (i + 1);
                }
            }
            strDetailFields = GetDefaultFields(aDetail);
        }

        #region 主表信息
        if (!string.IsNullOrEmpty(strBaseFields))
        {
            tableBase.InnerHtml = WritePrintPageTable("分店期初库存", strBaseFields, strDetailFields, aBase, aDetail, dt, dtDetail, true);
        }
        #endregion

        #region 明细信息
        if (!string.IsNullOrEmpty(strDetailFields))
        {
            tableDetail.InnerHtml = WritePrintPageTable("分店期初库存", strBaseFields, strDetailFields, aBase, aDetail, dt, dtDetail, false);
        }
        #endregion
    }