Пример #1
0
 /// <summary>
 /// 打印rdlc文件
 /// </summary>
 /// <param name="report">本地报表</param>
 /// <param name="DocumentName">打印文件名称</param>
 /// <param name="DispalyPageSetupDialog">是否显示打印设置对话框</param>
 /// <param name="PageName">打印单据的名字</param>
 /// <param name="PageFw">打印单据的范围</param>
 public void Run(LocalReport report, string DocumentName, bool DispalyPageSetupDialog, string PageName, string PageFw)
 {
     //pw.StartThread();
     try
     {
         if (PageName != "")//取自定义纸张大小
         {
             xtBiz     xtbiz = new xtBiz();
             DataTable dt    = xtbiz.Get_Xt_ggdy(PageName);
             if (dt.Rows.Count == 1)
             {
                 PaperName    = dt.Rows[0]["PaperName"].ToString();
                 PageWidth    = dt.Rows[0]["PageWidth"].ToString();
                 PageHeight   = dt.Rows[0]["PageHeight"].ToString();
                 MarginTop    = dt.Rows[0]["MarginTop"].ToString();
                 MarginLeft   = dt.Rows[0]["MarginLeft"].ToString();
                 MarginRight  = dt.Rows[0]["MarginRight"].ToString();
                 MarginBottom = dt.Rows[0]["MarginBottom"].ToString();
                 PagePrinter  = dt.Rows[0]["PagePrinter"].ToString();
                 if (PageWidth == "")
                 {
                     PageWidth = "0cm";
                 }
                 if (PageHeight == "")
                 {
                     PageHeight = "0cm";
                 }
                 if (MarginTop == "")
                 {
                     MarginTop = "0cm";
                 }
                 if (MarginLeft == "")
                 {
                     MarginLeft = "0cm";
                 }
                 if (MarginRight == "")
                 {
                     MarginRight = "0cm";
                 }
                 if (MarginBottom == "")
                 {
                     MarginBottom = "0cm";
                 }
             }
             else
             {
                 MessageBox.Show("该单据纸张配置【" + PageName + "】没有设置,请联系管理员!", "提示",
                                 MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 return;
             }
         }
         Export(report, PageName);
         if (PageFw == "")
         {
             m_currentPageIndex = 0;
             Print(DocumentName, DispalyPageSetupDialog);
             //pw.StopThread();
         }
         else
         {
             string[] str_fw = PageFw.Split('-');
             int      begin  = 0;
             int      end    = 0;
             try
             {
                 if (str_fw.Length == 1)
                 {
                     begin = Convert.ToInt32(str_fw[0]);
                     end   = Convert.ToInt32(str_fw[0]);
                 }
                 else
                 {
                     begin = Convert.ToInt32(str_fw[0]);
                     end   = Convert.ToInt32(str_fw[1]);
                 }
                 if (begin > end)
                 {
                     MessageBox.Show("该单据自定义打印页数填写有误,请检查!", "提示",
                                     MessageBoxButtons.OK, MessageBoxIcon.Warning);
                     return;
                 }
             }
             catch
             {
                 MessageBox.Show("该单据自定义打印页数填写有误,请检查!", "提示",
                                 MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 return;
             }
             for (int i = begin; i <= end; i++)
             {
                 m_PageIndex        = i;
                 m_currentPageIndex = 0;
                 Print(DocumentName, DispalyPageSetupDialog);
                 //pw.StopThread();
             }
         }
     }
     catch
     {
     }
     finally
     {
         Dispose();
     }
 }
Пример #2
0
        //private PrintWaiting pw = new PrintWaiting();

        /// <summary>
        /// 打印rdlc文件
        /// </summary>
        /// <param name="report">本地报表</param>
        /// <param name="DocumentName">打印文件名称</param>
        /// <param name="DispalyPageSetupDialog">是否显示打印设置对话框</param>
        /// <param name="PageName">打印单据的名字</param>
        public void Run(LocalReport report, string DocumentName, bool DispalyPageSetupDialog, string PageName)
        {
            //pw.StartThread();
            try
            {
                if (PageName != "")//取自定义纸张大小
                {
                    xtBiz     xtbiz = new xtBiz();
                    DataTable dt    = xtbiz.Get_Xt_ggdy(PageName);
                    if (dt.Rows.Count == 1)
                    {
                        PaperName = dt.Rows[0]["PaperName"].ToString();
                        //PageWidth = dt.Rows[0]["PageWidth"].ToString();
                        //PageHeight = dt.Rows[0]["PageHeight"].ToString();
                        string w = PageWidth;
                        string h = PageHeight;
                        MarginTop    = dt.Rows[0]["MarginTop"].ToString();
                        MarginLeft   = dt.Rows[0]["MarginLeft"].ToString();
                        MarginRight  = dt.Rows[0]["MarginRight"].ToString();
                        MarginBottom = dt.Rows[0]["MarginBottom"].ToString();
                        PagePrinter  = dt.Rows[0]["PagePrinter"].ToString();
                        if (PageWidth == "")
                        {
                            PageWidth = "0cm";
                        }
                        if (PageHeight == "")
                        {
                            PageHeight = "0cm";
                        }
                        if (MarginTop == "")
                        {
                            MarginTop = "0cm";
                        }
                        if (MarginLeft == "")
                        {
                            MarginLeft = "0cm";
                        }
                        if (MarginRight == "")
                        {
                            MarginRight = "0cm";
                        }
                        if (MarginBottom == "")
                        {
                            MarginBottom = "0cm";
                        }
                    }
                    else
                    {
                        MessageBox.Show("该单据纸张配置【" + PageName + "】没有设置,请联系管理员!", "提示",
                                        MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                }
                Export(report, PageName);
                m_currentPageIndex = 0;
                Print(DocumentName, DispalyPageSetupDialog);
                //pw.StopThread();
            }
            catch
            { }
            finally
            {
                Dispose();
            }
        }