private void toolPrintPreview_Click(object sender, EventArgs e)
        {
            if (dtWaterMeterList.Rows.Count == 0)
            {
                toolPrint.Enabled        = false;
                toolPrintPreview.Enabled = false;
                return;
            }

            DataSet   ds      = new DataSet();
            DataTable dtPrint = GetDgvToTable(dgList);

            dtPrint.TableName = "收费明细表";
            ds.Tables.Add(dtPrint);
            FastReport.Report report1 = new FastReport.Report();
            try
            {
                // load the existing report
                report1.Load(Application.StartupPath + @"\PRINTModel\收费明细表.frx");
                // register the dataset
                report1.RegisterData(ds);
                report1.GetDataSource("收费明细表").Enabled = true;
                // run the report
                report1.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                // free resources used by report
                report1.Dispose();
            }
        }/// <summary>
Beispiel #2
0
        private void toolPrintPreview_Click(object sender, EventArgs e)
        {
            DataSet ds = new DataSet();

            //DataTable dt = (DataTable)dgList.DataSource;
            DataTable dtPrint = GetDgvToTable(dgList);

            dtPrint.TableName = "水表情况表";
            ds.Tables.Add(dtPrint);
            FastReport.Report report1 = new FastReport.Report();
            try
            {
                // load the existing report
                report1.Load(Application.StartupPath + @"\PRINTModel\业扩模板\水表库存模板.frx");
                // register the dataset
                report1.RegisterData(ds);
                report1.GetDataSource("水表情况表").Enabled = true;
                // run the report
                report1.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                // free resources used by report
                report1.Dispose();
            }
        }
Beispiel #3
0
        private void toolPrint_Click(object sender, EventArgs e)
        {
            if (dtWaterMeterList.Rows.Count == 0)
            {
                toolPrint.Enabled        = false;
                toolPrintPreview.Enabled = false;
                return;
            }

            DataSet   ds           = new DataSet();
            DataTable dtRecordTemp = dtWaterMeterList.Clone();

            dtRecordTemp.Columns["readMeterRecordYearAndMonth"].DataType = typeof(string);
            foreach (DataRow dr in dtWaterMeterList.Rows)
            {
                dtRecordTemp.ImportRow(dr);
            }
            for (int i = 0; i < dtRecordTemp.Rows.Count; i++)
            {
                object obj = dtRecordTemp.Rows[i]["readMeterRecordYearAndMonth"];
                if (Information.IsDate(obj))
                {
                    dtRecordTemp.Rows[i]["readMeterRecordYearAndMonth"] = Convert.ToDateTime(obj).ToString("yyyy-MM");
                }
                //object objWaterMeterNO = dtRecord.Rows[i]["waterMeterNo"];
                //if (objWaterMeterNO != null && objWaterMeterNO != DBNull.Value)
                //    if (objWaterMeterNO.ToString().Length > 7)
                //        dtRecord.Rows[i]["waterMeterNo"] = objWaterMeterNO.ToString().Substring(6, 2);
            }

            DataTable dtPrint = dtRecordTemp.Copy();

            dtPrint.TableName = "收费明细表";
            ds.Tables.Add(dtPrint);
            FastReport.Report report1 = new FastReport.Report();
            try
            {
                // load the existing report
                report1.Load(Application.StartupPath + @"\PRINTModel\实收明细表.frx");
                // register the dataset
                report1.RegisterData(ds);
                report1.GetDataSource("收费明细表").Enabled = true;
                report1.PrintSettings.ShowDialog       = false;
                report1.Prepare();
                report1.Print();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                // free resources used by report
                report1.Dispose();
            }
        }
Beispiel #4
0
        /// <summary>
        /// 新增报表
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void tsmAddReport_Click(object sender, EventArgs e)
        {
            report = new FastReport.Report();
            RegReportData();
            frmReportDesign rp = new frmReportDesign(report, 0);

            rp.ReportGUID = rpGUID;
            rp.ShowDialog();
            report.Dispose();
            //ClearListData();
            CreateMenu();
        }
        private void toolPrintPreview_Click(object sender, EventArgs e)
        {
            if (dtWaterMeterList.Rows.Count == 0)
            {
                toolPrint.Enabled        = false;
                toolPrintPreview.Enabled = false;
                return;
            }

            DataSet   ds      = new DataSet();
            DataTable dtPrint = GetDgvToTable(dgList);

            for (int i = 0; i < dtPrint.Rows.Count; i++)
            {
                string strTelNO = "", strPhoneNO = "";
                object objWaterPhone = dtPrint.Rows[i]["waterUserTelphoneNO"];
                if (objWaterPhone != null && objWaterPhone != DBNull.Value)
                {
                    strTelNO = objWaterPhone.ToString();
                }
                objWaterPhone = dtPrint.Rows[i]["waterPhone"];
                if (objWaterPhone != null && objWaterPhone != DBNull.Value)
                {
                    strPhoneNO = objWaterPhone.ToString();
                }
                dtPrint.Rows[i]["waterPhone"] = strTelNO == "" ? strPhoneNO : strTelNO + " " + strPhoneNO;
            }

            dtPrint.TableName = "未抄水表明细表";
            ds.Tables.Add(dtPrint);
            FastReport.Report report1 = new FastReport.Report();
            try
            {
                // load the existing report
                report1.Load(Application.StartupPath + @"\PRINTModel\未抄水表明细表.frx");
                // register the dataset
                report1.RegisterData(ds);
                report1.GetDataSource("未抄水表明细表").Enabled = true;
                // run the report
                report1.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                // free resources used by report
                report1.Dispose();
            }
        }/// <summary>
Beispiel #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            FastReport.Report report1 = new FastReport.Report();
            try
            {
                // load the existing report
                // report1.Load("E:\\FsFile\\Untitled.frx");
                report1.Load("E:\\FsFile\\Test.frx");
                report1.SetParameterValue("aaa", "adbajdbjadbjadbabdadadad");
                report1.SetParameterValue("bbb", "uiyiyuiyy");
                report1.SetParameterValue("ccc", "1313131313");

                /*
                 * var lableTag = new LableTag();
                 * lableTag.ProdNo = "800-sdashd-a0-0";
                 * lableTag.Qty = "300";
                 * lableTags = new LableTag[] { lableTag };
                 *
                 *
                 *
                 * report1.RegisterData(lableTags, "lableTag");
                 * // report1.RegisterData("456", "two");
                 * //report.RegisterData(cdsPrints, "frCds_Print");
                 *
                 * //找到 DataBind  邦定数据  一定要先注册数据才可以邦定
                 *
                 * //DataBand data = report1.FindObject("Data1") as DataBand;
                 * // data.DataSource = report1.GetDataSource("one");
                 * // register the dataset
                 *
                 * // report1.RegisterData(FDataSet);
                 * // report1.GetDataSource("Items").Enabled = true;
                 * // run the report
                 * // report1.Show();
                 * //进行打印预览
                 */
                report1.Prepare();
                //report1.Variables.Add.Name:=' Yuan';
                report1.ShowPrepared();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                // free resources used by report
                report1.Dispose();
            }
        }
Beispiel #7
0
        private void button2_Click(object sender, EventArgs e)
        {
            FastReport.Report report1 = new FastReport.Report();
            try
            {
                // load the existing report
                // report1.Load("E:\\FsFile\\Untitled.frx");
                report1.Load("E:\\FsFile\\Test.frx");

                /*
                 * //填充参数及对应的值
                 * Type typePrint = typeof(LableTag);
                 * System.Reflection.PropertyInfo[] pros = typePrint.GetProperties();
                 * foreach (System.Reflection.PropertyInfo pro in pros)
                 * {
                 *  object val = pro == null ? ""
                 *      : pro.GetValue(lableTags[0], null) == null ? ""
                 *      : pro.GetValue(lableTags[0], null).ToString();
                 *
                 *  if (val == null)
                 *  {
                 *      val = "";
                 *  }
                 *  string paraName = "lableTag." + pro.Name;
                 *  report1.SetParameterValue(paraName, val);
                 *
                 * }
                 * var lableTag = new LableTag();
                 * lableTag.ProdNo = "800-sdashd-a0-0";
                 * lableTag.Qty = "300";
                 * lableTags = new LableTag[] { lableTag };
                 *
                 * report1.RegisterData(lableTags, "lableTag");
                 */
                report1.SetParameterValue("aaa", "111");
                report1.SetParameterValue("bbb", "222");
                report1.SetParameterValue("ccc", "333");
                report1.Design();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                // free resources used by report
                report1.Dispose();
            }
        }
Beispiel #8
0
 /// <summary>
 /// 打印预览
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void tsmPreviewReport_Click(object sender, EventArgs e)
 {
     if (tsmChooseReport.HasDropDownItems)
     {
         report = new FastReport.Report();
         if (!report.IsRunning)
         {
             GetData(tsmChooseDetail[iDefaultChecked].Name);
             report.Load(new MemoryStream(bt));
             RegReportData();
         }
         frmReportPreview rp = new frmReportPreview(report);
         rp.ShowDialog();
         report.Dispose();
     }
 }
Beispiel #9
0
        private void toolPrintPreview_Click(object sender, EventArgs e)
        {
            if (dgList.Rows.Count == 0)
            {
                toolPrint.Enabled        = false;
                toolPrintPreview.Enabled = false;
                return;
            }

            DataSet ds = new DataSet();

            //DataTable dt = (DataTable)dgList.DataSource;
            DataTable dt      = GetDgvToTable(dgList);
            DataTable dtPrint = dt.Copy();

            dtPrint.TableName = strStaticsName;
            ds.Tables.Add(dtPrint);
            FastReport.Report report1 = new FastReport.Report();
            try
            {
                // load the existing report
                report1.Load(Application.StartupPath + @"\PRINTModel\预存统计模板\" + strStaticsName + ".frx");

                if (strStaticsName == "预存统计(按收费员)")
                {
                    (report1.FindObject("txtTitle") as FastReport.TextObject).Text = "大厅收费统计(按收费员)";
                }
                else if (strStaticsName == "预存统计(按用户)")
                {
                    (report1.FindObject("txtTitle") as FastReport.TextObject).Text = "大厅收费统计(按用户)";
                }
                // register the dataset
                report1.RegisterData(ds);
                report1.GetDataSource(strStaticsName).Enabled = true;
                // run the report
                report1.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                // free resources used by report
                report1.Dispose();
            }
        }/// <summary>
Beispiel #10
0
 /// <summary>
 /// 打印
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void tsmPrintReport_Click(object sender, EventArgs e)
 {
     if (tsmChooseReport.HasDropDownItems)
     {
         report = new FastReport.Report();
         if (!report.IsPrinting)
         {
             GetData(tsmChooseDetail[iDefaultChecked].Name);
             report.Load(new MemoryStream(bt));
             RegReportData();
         }
         //是否显示打印机选择对话框
         report.PrintSettings.ShowDialog = ShowPrintDialog;
         report.Print();
         report.Dispose();
     }
 }
Beispiel #11
0
        public void Dispose()
        {
            RunFlag = false;
            ConstantMethod.Delay(100);
            //保存文件
            SaveFile();
            if (evokDevice != null)
            {
                evokDevice.DeviceShutDown();
            }
            printReport.Dispose();
            if (CutThread != null && CutThread.IsAlive)
            {
                CutThread.Join();
            }

            LogManager.WriteProgramLog(Constant.Quit);
        }
Beispiel #12
0
 /// <summary>
 /// 设计报表
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void tsmDesginReport_Click(object sender, EventArgs e)
 {
     if (tsmChooseReport.HasDropDownItems)
     {
         report = new FastReport.Report();
         if (!report.IsDesigning)
         {
             GetData(tsmChooseDetail[iDefaultChecked].Name);
             report.Load(new MemoryStream(bt));
             RegReportData();
         }
         frmReportDesign rp = new frmReportDesign(report, Convert.ToInt32(tsmChooseDetail[iDefaultChecked].Name));
         rp.ReportGUID = rpGUID;
         rp.ShowDialog();
         report.Dispose();
         //刷新菜单
         CreateMenu();
     }
 }
        private void toolPrint_Click(object sender, EventArgs e)
        {
            if (dtWaterUserList.Rows.Count == 0)
            {
                toolPrint.Enabled        = false;
                toolPrintPreview.Enabled = false;
                return;
            }

            DataSet ds = new DataSet();

            //DataTable dt = (DataTable)dgList.DataSource;
            DataTable dtPrint = dtWaterUserList.Copy();

            if (dtClone.Rows.Count > 0)
            {
                dtPrint.ImportRow(dtClone.Rows[0]);
            }
            dtPrint.TableName = "用户应收明细表";
            ds.Tables.Add(dtPrint);
            FastReport.Report report1 = new FastReport.Report();
            try
            {
                // load the existing report
                report1.Load(Application.StartupPath + @"\PRINTModel\用户应收明细表.frx");
                // register the dataset
                report1.RegisterData(ds);
                report1.GetDataSource("用户应收明细表").Enabled = true;
                report1.Prepare();
                report1.Print();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                // free resources used by report
                report1.Dispose();
            }
        }
Beispiel #14
0
        private void toolPrintPreview_Click(object sender, EventArgs e)
        {
            if (dgList.Rows.Count == 0)
            {
                toolPrint.Enabled        = false;
                toolPrintPreview.Enabled = false;
                return;
            }

            DataSet ds = new DataSet();

            //DataTable dt = (DataTable)dgList.DataSource;
            DataTable dt = GetDgvToTable(dgList);
            //DataTable dtPrint = dt.Copy();
            DataTable dtPrint = dt.DefaultView.ToTable(true, "CHARGEID", "CANCELWORKERNAME", "CANCELDATETIME", "CANCELMEMO", "WATERTOTALCHARGECHARGE",
                                                       "EXTRATOTALCHARGECHARGE", "OVERDUEMONEYCHARGE", "TOTALCHARGECHARGE", "CHARGEBCYS", "CHARGEBCSS", "CHARGEDATETIME", "CHARGEWORKERNAME", "waterUserNO",
                                                       "waterUserName", "waterPhone", "waterUserAddress", "INVOICEBATCHNAME", "INVOICENO");

            dtPrint.TableName = "收费冲减明细表";
            ds.Tables.Add(dtPrint);
            FastReport.Report report1 = new FastReport.Report();
            try
            {
                // load the existing report
                report1.Load(Application.StartupPath + @"\PRINTModel\收费冲减明细表.frx");
                // register the dataset
                report1.RegisterData(ds);
                report1.GetDataSource("收费冲减明细表").Enabled = true;
                // run the report
                report1.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                // free resources used by report
                report1.Dispose();
            }
        }
        private void toolPrintPreview_Click(object sender, EventArgs e)
        {
            if (dtList.Rows.Count == 0)
            {
                toolPrint.Enabled        = false;
                toolPrintPreview.Enabled = false;
                return;
            }
            DataSet   ds      = new DataSet();
            DataTable dtPrint = dtList.Copy();

            if (dtClone.Rows.Count > 0)
            {
                dtPrint.ImportRow(dtClone.Rows[0]);
            }
            dtPrint.TableName = "异常用水明细表";
            ds.Tables.Add(dtPrint);
            FastReport.Report report1 = new FastReport.Report();
            try
            {
                // load the existing report
                report1.Load(Application.StartupPath + @"\PRINTModel\异常用水明细表.frx");
                // register the dataset
                report1.RegisterData(ds);
                report1.GetDataSource("异常用水明细表").Enabled = true;
                // run the report
                report1.Show();
            }
            catch (Exception ex)
            {
                mes.Show(ex.Message);
                log.Write(ex.ToString(), MsgType.Error);
            }
            finally
            {
                // free resources used by report
                report1.Dispose();
            }
        }/// <summary>
Beispiel #16
0
        private void toolPrint_Click(object sender, EventArgs e)
        {
            if (dtWaterMeterList.Rows.Count == 0)
            {
                toolPrint.Enabled        = false;
                toolPrintPreview.Enabled = false;
                return;
            }

            DataSet   ds      = new DataSet();
            DataTable dtPrint = GetDgvToTable(dgList);

            dtPrint.TableName = "收费明细表";
            ds.Tables.Add(dtPrint);
            FastReport.Report report1 = new FastReport.Report();
            try
            {
                // load the existing report
                report1.Load(Application.StartupPath + @"\PRINTModel\一户式查询打印.frx");
                (report1.FindObject("txtWaterUserNO") as FastReport.TextObject).Text      = "用户号:" + strWaterUserID;
                (report1.FindObject("txtWaterUserName") as FastReport.TextObject).Text    = "用户名:" + strWaterUserName;
                (report1.FindObject("txtWaterUserAddress") as FastReport.TextObject).Text = "地  址:" + strWaterUserAddress;
                // register the dataset
                report1.RegisterData(ds);
                report1.GetDataSource("收费明细表").Enabled = true;
                report1.PrintSettings.ShowDialog       = false;
                report1.Prepare();
                report1.Print();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                // free resources used by report
                report1.Dispose();
            }
        }
Beispiel #17
0
        /// <summary>
        /// 添加新报表
        /// </summary>
        /// <param name="e"></param>
        /// <param name="strReportTemplateName"></param>
        /// <returns></returns>
        public static string AddNewReport(ReportRequestArgs e, string strReportTemplateName)
        {
            string strReportPath = "";

            using (FastReport.Report report = new FastReport.Report())
            {
                BuildParmsAndData(e, report, enBuildParmsAndDataActionType.AddNew);

                string strReportFullName = Path.Combine(ReportHelper.ReportPath, strReportTemplateName + ".frx");
                report.Save(strReportFullName);

                strReportPath = strReportFullName;

                //Form frm = new Form();
                //frm.Icon = FastReport.Utils.Config.PreviewSettings.Icon;
                //frm.Show();
                //report.Design();
                report.Dispose();
                //frm.Close();
            }
            return(strReportPath);
        }
Beispiel #18
0
        //public static void BuildReportParmsAndData(FastReport.Report report, ReportArgs reportArgs)
        //{
        //    report.Parameters.Clear();
        //    List<FastReport.Data.Parameter> lstParm = new List<FastReport.Data.Parameter>();

        //    if (reportArgs.RecordDR != null)
        //    {
        //        foreach (DataColumn dc in reportArgs.RecordDR.Table.Columns)
        //        {
        //            FastReport.Data.Parameter parm = new FastReport.Data.Parameter(dc.ColumnName);
        //            parm.DataType = dc.DataType;
        //            parm.Value = reportArgs.RecordDR[dc.ColumnName];
        //            lstParm.Add(parm);
        //        }
        //    }


        //    if (reportArgs.DSDataSource != null)
        //    {
        //        foreach (DataTable dtSource in reportArgs.DSDataSource.Tables)
        //        {
        //            report.RegisterData(dtSource, dtSource.TableName);
        //            report.GetDataSource(dtSource.TableName).Enabled = true;
        //        }
        //    }
        //}

        /// <summary>
        /// 打开报表设计器
        /// </summary>
        /// <param name="lReportTemplateID"></param>
        /// <param name="reportArgs"></param>
        public static void OpenReportDesign(ReportRequestArgs reportArgs)
        {
            string strReportFileName;
            bool   bolExists = RefleshClientReport(reportArgs.ReportTemplateID, out strReportFileName);

            if (bolExists)
            {
                using (FastReport.Report report = new FastReport.Report())
                {
                    BuildParmsAndData(reportArgs, report, enBuildParmsAndDataActionType.AddNew);

                    report.Load(strReportFileName);

                    Form frm = new Form();
                    frm.Icon = FastReport.Utils.Config.PreviewSettings.Icon;
                    frm.Show();
                    report.Design();
                    report.Dispose();
                    frm.Close();
                }
            }
        }
Beispiel #19
0
        private void toolPrintPreview_Click(object sender, EventArgs e)
        {
            if (dtList.Rows.Count == 0)
            {
                toolPrint.Enabled        = false;
                toolPrintPreview.Enabled = false;
                return;
            }

            DataSet   ds      = new DataSet();
            DataTable dtPrint = dtList.Copy();

            if (dtClone.Rows.Count > 0)
            {
                dtPrint.ImportRow(dtClone.Rows[0]);
            }
            dtPrint.TableName = strStaticsName;
            ds.Tables.Add(dtPrint);
            FastReport.Report report1 = new FastReport.Report();
            try
            {
                // load the existing report
                report1.Load(Application.StartupPath + @"\PRINTModel\期数未收统计模板\" + strStaticsName + ".frx");
                // register the dataset
                report1.RegisterData(ds);
                report1.GetDataSource(strStaticsName).Enabled = true;
                // run the report
                report1.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                // free resources used by report
                report1.Dispose();
            }
        }/// <summary>
 private void btPrint_Click(object sender, EventArgs e)
 {
     if (txtReason.Text == "")
     {
         if (mes.ShowQ("原因为空,确定要打印吗?") != DialogResult.OK)
         {
             return;
         }
     }
     #region
     FastReport.Report report1 = new FastReport.Report();
     try
     {
         // load the existing report
         report1.Load(Application.StartupPath + @"\PRINTModel\变更审批表模板.frx");
         (report1.FindObject("txtName") as FastReport.TextObject).Text    = txtName.Text;
         (report1.FindObject("txtNO") as FastReport.TextObject).Text      = txtNO.Text;
         (report1.FindObject("txtAddress") as FastReport.TextObject).Text = txtAddress.Text;
         (report1.FindObject("txtReason") as FastReport.TextObject).Text  = "变更原因:" + txtReason.Text;
         //report1.Show();
         report1.PrintSettings.ShowDialog = false;
         report1.Prepare();
         report1.Print();
     }
     catch (Exception exx)
     {
         mes.Show(exx.Message);
         return;
     }
     finally
     {
         // free resources used by report
         report1.Dispose();
     }
     #endregion
 }
Beispiel #21
0
        private void toolPrint_Click(object sender, EventArgs e)
        {
            if (dgJieZhangYS.Rows.Count == 0)
            {
                toolPrint.Enabled        = false;
                toolPrintPreview.Enabled = false;
                return;
            }
            decimal   decSum  = 0;
            DataSet   ds      = new DataSet();
            DataTable dtPrint = GetDgvToTable(dgJieZhangYS);

            dtPrint.TableName = "水费应收统计表(按用水性质)";
            ds.Tables.Add(dtPrint);
            FastReport.Report report1 = new FastReport.Report();
            try
            {
                // load the existing report
                report1.Load(Application.StartupPath + @"\PRINTModel\应收水费统计模板\应收水费统计(结账报表).frx");
                (report1.FindObject("txtMonth") as FastReport.TextObject).Text = "应收月份:" + dtpStartSearch.Value.ToString("yyyy-MM");
                report1.RegisterData(ds);
                report1.GetDataSource("水费应收统计表(按用水性质)").Enabled = true;
                report1.PrintSettings.ShowDialog = false;
                report1.Prepare();
                report1.Print();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                // free resources used by report
                report1.Dispose();
            }
        }
Beispiel #22
0
 /// <summary>
 /// 设计报表
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void tsmDesginReport_Click(object sender, EventArgs e)
 {
     if (tsmChooseReport.HasDropDownItems)
     {
         report = new FastReport.Report();
         if (!report.IsDesigning)
         {
             GetData(tsmChooseDetail[iDefaultChecked].Name);
             report.Load(new MemoryStream(bt));
             RegReportData();
         }
         frmReportDesign rp = new frmReportDesign(report, Convert.ToInt32(tsmChooseDetail[iDefaultChecked].Name));
         rp.ReportGUID = rpGUID;
         rp.ShowDialog();
         report.Dispose();
         //刷新菜单
         CreateMenu();
     }
 }
Beispiel #23
0
        private static void ShowReport(enRequestReportActionType eActionType, ReportRequestArgs e)
        {
            // FastReport 配置
            Config.DesignerSettings.ShowInTaskbar = true;
            Config.DesignerSettings.DefaultFont   = new System.Drawing.Font(Config.DesignerSettings.DefaultFont.FontFamily, 10f);
            //Config.DesignerSettings.Icon = TS.Win.Styles.Sheet.AppIcon;
            Config.DesignerSettings.Text = "报表设计器";
            //Config.PreviewSettings.Buttons = PreviewButtons.Print;
            Config.PreviewSettings.ShowInTaskbar = true;
            //Config.PreviewSettings.Icon = TS.Win.Styles.Sheet.AppIcon;

            long lReportTemplateID = Convert.ToInt64(e.ReportTemplateConfig["ReportTemplateID"]);

            byte[]   reportTempleData         = (byte[])e.ReportTemplateConfig["TemplateData"];
            DateTime dtTemplateFileTime       = DateTime.Parse(e.ReportTemplateConfig["TemplateFileTime"].ToString());
            string   strReportTemplateName    = e.ReportTemplateConfig["ReportTemplateName"].ToString().Trim();
            string   strReportTemplateNameExt = e.ReportTemplateConfig["ReportTemplateNameExt"].ToString().Trim();
            //检测本地是否存在报表文件,如果不存在或者与服务器比本地文件新时更新本地文件
            string strFileFullName = WriteReportWithCheck(lReportTemplateID, strReportTemplateName, dtTemplateFileTime, reportTempleData, strReportTemplateNameExt);

            ProcessStep.AddStep("WriteReportWithCheck_End", DateTime.Now.ToString("MMdd HH:mm:ss ") + DateTime.Now.Millisecond);

            // 加载模板
            FastReport.Report report = null;

            //Form frm = null;
            try
            {
                //frm = new Form();
                report = new FastReport.Report();

                ProcessStep.AddStep("Report_New", DateTime.Now.ToString("MMdd HH:mm:ss ") + DateTime.Now.Millisecond);
                report.FinishReport += Report_FinishReport;
                report.Load(strFileFullName);
                ProcessStep.AddStep("Report_Load", DateTime.Now.ToString("MMdd HH:mm:ss ") + DateTime.Now.Millisecond);
                // 纸张设置
                //SetPaperAuto(report, iReportTemplateID);

                BuildParmsAndData(e, report, enBuildParmsAndDataActionType.SetValue);
                ProcessStep.AddStep("BuildParmsAndData", DateTime.Now.ToString("MMdd HH:mm:ss ") + DateTime.Now.Millisecond);
                //ReportPreviewer previewer = new Report.ReportPreviewer(report);

                SetPrintSettings(report, lReportTemplateID);
                ProcessStep.AddStep("SetPrintSettings", DateTime.Now.ToString("MMdd HH:mm:ss ") + DateTime.Now.Millisecond);
                if (eActionType == enRequestReportActionType.Preview)//预览
                {
                    //frm.FormBorderStyle = FormBorderStyle.None;
                    //frm.Text = "报表预览[" + strReportTemplateName + "]";
                    //frm.TransparencyKey = frm.BackColor;
                    //frm.Show();

                    //report.Show(true, frm);
                    //LBShowForm.ShowDialog(previewer);
                    report.Show(true);
                }
                else if (eActionType == enRequestReportActionType.DirectPrint)//直接打印
                {
                    report.PrintSettings.ShowDialog = false;
                    report.Print();
                    //string strPrinterStatus =PrinterHelper.GetPrinterStatus(report.PrintSettings.Printer);
                    ProcessStep.AddStep("Print", DateTime.Now.ToString("MMdd HH:mm:ss ") + DateTime.Now.Millisecond);
                }
            }
            finally
            {
                try
                {
                    if (report != null)
                    {
                        report.Dispose();
                        //if (frm != null)
                        //{
                        //    frm.Close();
                        //}
                    }
                }
                catch
                {
                }
            }
        }
Beispiel #24
0
        private void toolPrintPreview_Click(object sender, EventArgs e)
        {
            FastReport.Report report1 = new FastReport.Report();
            try
            {
                // load the existing report
                report1.Load(Application.StartupPath + @"\PRINTModel\用水情况一览表.frx");
                (report1.FindObject("Cell3") as FastReport.TextObject).Text   = labYCHS.Text;
                (report1.FindObject("Cell8") as FastReport.TextObject).Text   = labXSHS.Text;
                (report1.FindObject("Cell13") as FastReport.TextObject).Text  = labXHHS.Text;
                (report1.FindObject("Cell148") as FastReport.TextObject).Text = labYMHS.Text;

                (report1.FindObject("Cell33") as FastReport.TextObject).Text = labYSZJ.Text;
                (report1.FindObject("Cell43") as FastReport.TextObject).Text = labFSYSHS.Text;
                (report1.FindObject("Cell48") as FastReport.TextObject).Text = labYSYSL.Text;
                (report1.FindObject("Cell38") as FastReport.TextObject).Text = labYSSF.Text;
                (report1.FindObject("Cell58") as FastReport.TextObject).Text = labYSWSSF.Text;
                (report1.FindObject("Cell63") as FastReport.TextObject).Text = labYSFJF.Text;

                (report1.FindObject("Cell68") as FastReport.TextObject).Text  = labSSZJ.Text;
                (report1.FindObject("Cell108") as FastReport.TextObject).Text = labSSSL.Text;
                (report1.FindObject("Cell103") as FastReport.TextObject).Text = labSSHS.Text;
                (report1.FindObject("Cell53") as FastReport.TextObject).Text  = labSSSF.Text;
                (report1.FindObject("Cell28") as FastReport.TextObject).Text  = labSSWSCLF.Text;
                (report1.FindObject("Cell18") as FastReport.TextObject).Text  = labSSFJF.Text;
                (report1.FindObject("Cell113") as FastReport.TextObject).Text = labOverDue.Text;

                (report1.FindObject("Cell73") as FastReport.TextObject).Text = labWQZJ.Text;
                (report1.FindObject("Cell98") as FastReport.TextObject).Text = labWQSL.Text;
                (report1.FindObject("Cell93") as FastReport.TextObject).Text = labWQHS.Text;
                (report1.FindObject("Cell88") as FastReport.TextObject).Text = labWQSF.Text;
                (report1.FindObject("Cell83") as FastReport.TextObject).Text = labWQWSCLF.Text;
                (report1.FindObject("Cell78") as FastReport.TextObject).Text = labWQFJF.Text;

                (report1.FindObject("Cell118") as FastReport.TextObject).Text = labLJQFZJ.Text;
                (report1.FindObject("Cell123") as FastReport.TextObject).Text = labLJQFHS.Text;
                (report1.FindObject("Cell128") as FastReport.TextObject).Text = labLJQFSL.Text;
                (report1.FindObject("Cell133") as FastReport.TextObject).Text = labLJQFSF.Text;
                (report1.FindObject("Cell138") as FastReport.TextObject).Text = labLJQFWSCLF.Text;
                (report1.FindObject("Cell143") as FastReport.TextObject).Text = labLJQFFJF.Text;

                //(report1.FindObject("Cell28") as FastReport.TextObject).Text = labSQZMJE.Text;
                //(report1.FindObject("Cell18") as FastReport.TextObject).Text = labBQZJ.Text;
                //(report1.FindObject("Cell23") as FastReport.TextObject).Text = labBQZMJE.Text;

                if (GetMonth(dtpStartSearch.Value, dtpEndSearch.Value) > 1)
                {
                    (report1.FindObject("txtTitle") as FastReport.TextObject).Text = dtpStartSearch.Value.ToString("yyyy-MM") + "至" + dtpEndSearch.Value.ToString("yyyy-MM") + "月份用水情况一览表";
                }
                else
                {
                    (report1.FindObject("txtTitle") as FastReport.TextObject).Text = strMonth[dtpEndSearch.Value.Month - 1] + "月份用水情况一览表";
                }

                // run the report
                report1.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                // free resources used by report
                report1.Dispose();
            }
        }
Beispiel #25
0
 /// <summary>
 /// 打印
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void tsmPrintReport_Click(object sender, EventArgs e)
 {
     if (tsmChooseReport.HasDropDownItems)
     {
         report = new FastReport.Report();
         if (!report.IsPrinting)
         {
             GetData(tsmChooseDetail[iDefaultChecked].Name);
             report.Load(new MemoryStream(bt));
             RegReportData();
         }
         //是否显示打印机选择对话框
         report.PrintSettings.ShowDialog = ShowPrintDialog;
         report.Print();
         report.Dispose();
     }
 }
        public FileResult CekSenetYazdir(string ID = "")
        {
            FastReport.Utils.Config.WebMode = true;
            FastReport.Report report1 = new FastReport.Report();

            report1.Prepare(true);

            try
            {
                report1.Load(Path.Combine(Server.MapPath("~/REPORTS/" + Session["FirmaID"].ToString()), "Cek.frx"));
            }
            catch
            {
                report1.Load(Path.Combine(Server.MapPath("~/REPORTS/Default"), "Cek.frx"));
            }

            using (SqlConnection conp = new SqlConnection(AyarMetot.strcon))
            {
                if (conp.State == ConnectionState.Closed)
                {
                    conp.Open();
                }
                using (SqlCommand getir = new SqlCommand("Select CariID  From CASH_PAY where ID='" + ID + "'", conp))
                {
                    using (SqlDataReader dr = getir.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            using (DataTable Teklifler = GetDataTable("set dateformat dmy;SELECT * ,(Select Adi+' '+Soyadi from Personel where ID=PersonelID) as PersonelAdi From CASH_PAY where ID = '" + ID + "'"))
                            {
                                report1.RegisterData(Teklifler.DefaultView.ToTable(), "NakitHavale");
                                report1.GetDataSource("NakitHavale").Enabled = true;
                            }

                            report1.RegisterData(AyarMetot.CariBil(Convert.ToInt32(dr["CariID"]), "Tümü", "", "Tümü", "Tümü"), "CariBilgileri");
                            report1.RegisterData(AyarMetot.FirmaBil(), "FirmaBilgileri");


                            report1.GetDataSource("CariBilgileri").Enabled  = true;
                            report1.GetDataSource("FirmaBilgileri").Enabled = true;
                        }
                    }
                }
            }

            using (FastReport.Export.Pdf.PDFExport pdf = new FastReport.Export.Pdf.PDFExport())
            {
                byte[] dosya;
                try
                {
                    dosya =
                        System.IO.File.ReadAllBytes(Path.Combine(Server.MapPath("~/REPORTS/" + Session["FirmaID"].ToString()),
                                                                 "Cek.pdf"));
                }
                catch
                {
                    dosya =
                        System.IO.File.ReadAllBytes(Path.Combine(Server.MapPath("~/REPORTS/Defaut"),
                                                                 "Cek.pdf"));
                }



                try
                {
                    report1.Prepare(true);

                    try
                    {
                        report1.Export(pdf, Path.Combine(Server.MapPath("~/REPORTS/" + Session["FirmaID"].ToString()), "Cek.pdf"));
                    }
                    catch
                    {
                        report1.Export(pdf, Path.Combine(Server.MapPath("~/REPORTS/Default"), "Cek.pdf"));
                    }

                    System.IO.MemoryStream ms = new System.IO.MemoryStream();
                    //report1.Save(Path.Combine(Server.MapPath("~/REPORTS/ATTACHMENT"),"b.frx"));
                    report1.Dispose();

                    return(File(dosya, "application/pdf"));
                }
                catch (Exception e)
                {
                    return(File(dosya, "application/pdf"));
                }
            }
        }
Beispiel #27
0
 /// <summary>
 /// 新增报表
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void tsmAddReport_Click(object sender, EventArgs e)
 {
     report = new FastReport.Report();
     RegReportData();
     frmReportDesign rp = new frmReportDesign(report,0);
     rp.ReportGUID = rpGUID;
     rp.ShowDialog();
     report.Dispose();
     //ClearListData();
     CreateMenu();
 }
        public FileResult IadeYazdir(string ID = "")
        {
            try
            {
                FastReport.Utils.Config.WebMode = true;
                FastReport.Report report1 = new FastReport.Report();

                report1.Prepare(true);
                DataTable dtDetay = new DataTable();

                try {
                    report1.Load(Path.Combine(Server.MapPath("~//REPORTS/" + Session["FirmaID"].ToString()), "Iade.frx"));
                }
                catch
                {
                    report1.Load(Path.Combine(Server.MapPath("~//REPORTS/Default"), "Iade.frx"));
                }
                using (SqlConnection bag = new SqlConnection(AyarMetot.strcon))
                {
                    if (bag.State == ConnectionState.Closed)
                    {
                        bag.Open();
                    }
                    using (SqlCommand servisgetir = new SqlCommand("Select * From INVOICE where ID='" + ID + "'", bag))
                    {
                        using (SqlDataReader dt = servisgetir.ExecuteReader())
                        {
                            while (dt.Read())
                            {
                                string KDVdh = "Dahil";

                                dtDetay = AyarMetot.FaturaDetayBil(ID, KDVdh, Convert.ToDecimal(dt["FKuru"]));

                                if (dt["KdvDH"].ToString() != "D")
                                {
                                    KDVdh = "Hariç";
                                }
                                report1.RegisterData(AyarMetot.FaturaBil(ID), "FaturaBilgileri");
                                report1.RegisterData(dtDetay, "UrunBilgileri");
                                report1.RegisterData(AyarMetot.CariBil(Convert.ToInt32(dt["CariID"]), "Tümü", "Tümü", "Tümü", "Tümü"), "CariBilgileri");
                                report1.RegisterData(AyarMetot.FirmaBil(), "FirmaBilgileri");

                                report1.GetDataSource("FaturaBilgileri").Enabled = true;
                                report1.GetDataSource("UrunBilgileri").Enabled   = true;
                                report1.GetDataSource("CariBilgileri").Enabled   = true;
                                report1.GetDataSource("FirmaBilgileri").Enabled  = true;
                            }
                        }
                    }
                }



                using (FastReport.Export.Pdf.PDFExport pdf = new FastReport.Export.Pdf.PDFExport())
                {
                    ReportPage page1 = report1.Pages[0] as ReportPage;
                    page1.PaperHeight = page1.PaperHeight + (dtDetay.Rows.Count * ((float)5));

                    report1.Prepare(true);

                    try {
                        report1.Export(pdf, Path.Combine(Server.MapPath("~//REPORTS/" + Session["FirmaID"].ToString()), "Iade.pdf"));
                    }
                    catch
                    {
                        report1.Export(pdf, Path.Combine(Server.MapPath("~//REPORTS/Default"), "Iade.pdf"));
                    }
                    dtDetay.Dispose();
                    System.IO.MemoryStream ms = new System.IO.MemoryStream();
                    //report1.Save(Path.Combine(Server.MapPath("~/REPORTS/ATTACHMENT"),"Irs.frx"));
                    // page1.Dispose();
                    report1.Dispose();
                    byte[] dosya;
                    try {
                        dosya = System.IO.File.ReadAllBytes(Path.Combine(Server.MapPath("~/REPORTS/" + Session["FirmaID"].ToString()), "Iade.pdf"));
                    }
                    catch
                    {
                        dosya = System.IO.File.ReadAllBytes(Path.Combine(Server.MapPath("~/REPORTS/Default"), "Iade.pdf"));
                    }
                    return(File(dosya, "application/pdf"));
                }
            }
            catch (Exception e1)
            {
                try {
                    System.IO.File.WriteAllText(Path.Combine(@"C:\Users\ilhan\AppData\Local\Sayazilim", "sonuç.xml"), e1.ToString());
                }
                catch
                {
                }
                byte[] dosya = null;
                return(File(dosya, "application/pdf"));
            }
        }
        private bool CreateReport()
        {
            bool functionReturnValue = false;

            // ERROR: Not supported in C#: OnErrorStatement


            functionReturnValue = false;

            // create report instance
            FastReport.Report MainReport  = new FastReport.Report();
            FastReport.Report StyleReport = default(FastReport.Report);

            // register the dataset
            MainReport.RegisterData(this.FDataSet);

            MainReport.GetDataSource("TableData").Enabled = true;
            if (StyleRowsEven == null)
            {
                if (System.IO.File.Exists(Application.StartupPath + "\\Report\\Pattern.frx"))
                {
                    StyleReport = new FastReport.Report();
                    StyleReport.Load(Application.StartupPath + "\\Report\\Pattern.frx");
                    StyleRowsEven = StyleReport.Styles[0];
                    if (StyleRowsEven != null)
                    {
                        MainReport.Styles.Add(StyleRowsEven);
                    }
                }
            }

            ReportPage page = new ReportPage();

            page.Width = 33 * Units.Centimeters;

            MainReport.Pages.Add(page);

            page.CreateUniqueName();

            DataBand dataBand = new DataBand();

            page.Bands.Add(dataBand);
            dataBand.CreateUniqueName();
            dataBand.DataSource = MainReport.GetDataSource("TableData");
            dataBand.Height     = (Units.Centimeters * 0.5f);

            if (StyleRowsEven != null)
            {
                MainReport.Styles.Add(StyleRowsEven);
                if (!ChkWithoutColorTextReport.Checked)
                {
                    dataBand.EvenStyle = StyleRowsEven.Name;
                }
                else
                {
                    dataBand.EvenStyle = "";
                }
            }

            page.ReportTitle        = new ReportTitleBand();
            page.ReportTitle.Height = (Units.Centimeters * 4f);
            page.ReportTitle.CreateUniqueName();

            if (ChkWithoutColorHeader.CheckState == CheckState.Checked)
            {
                colorHeader     = Color.Transparent;
                backgroundColor = Color.Transparent;
            }

            HeaderAllReport(page, cboLayers.SelectedItem.ToString());
            double higthHeader = double.Parse(txtWidthHeader.Text);
            double higthBody   = double.Parse(txtWidthBody.Text);
            double WidthReport = 19;
            double widthColumn = (double)19 / columnNames.Count;

            for (int i = 0; i < columnNames.Count; i++)
            {
                WidthReport -= (widthColumn - 0.005);
                if (WidthReport < 0)
                {
                    break;
                }

                TextObject titleText = new TextObject();
                titleText.Parent = page.ReportTitle;
                titleText.CreateUniqueName();
                titleText.Bounds      = new RectangleF(Convert.ToSingle((Units.Centimeters * WidthReport)), (Units.Centimeters * 3f), (Units.Centimeters * (float)widthColumn), (Units.Centimeters * (float)higthHeader));
                titleText.Font        = FontDialog_Topic.Font;
                titleText.Text        = columnNames[i];
                titleText.VertAlign   = VertAlign.Center;
                titleText.HorzAlign   = HorzAlign.Center;
                titleText.Fill        = new LinearGradientFill(backgroundColor, colorHeader, 90, Convert.ToSingle(higthHeader), 1f);
                titleText.RightToLeft = true;


                TextObject ReportText = new TextObject();
                ReportText.Parent = dataBand;
                ReportText.CreateUniqueName();
                ReportText.Bounds      = new RectangleF(Convert.ToSingle((Units.Centimeters * WidthReport)), 0f, (Units.Centimeters * (float)widthColumn), (Units.Centimeters * (float)higthBody));
                ReportText.Text        = "[TableData." + FDataSet.Tables[0].Columns[i].ColumnName + "]";
                ReportText.Font        = FontDialog_TextReport.Font;
                ReportText.HorzAlign   = HorzAlign.Center;
                ReportText.VertAlign   = VertAlign.Center;
                ReportText.RightToLeft = true;

                // ReportText.Border.Lines = BorderLines.All;
                //ReportText.Border.BottomLine.Color = Color.Black;
                //ReportText.Border.BottomLine.Width = 0.5f;
                //ReportText.Border.TopLine .Color = Color.Black;
                //ReportText.Border.TopLine.Width = 0.5f;
            }

            if (WidthReport < 19)
            {
                TextObject RemaintitleText = new TextObject();
                RemaintitleText.Parent = page.ReportTitle;
                RemaintitleText.CreateUniqueName();
                RemaintitleText.Bounds    = new RectangleF(0.0f, (Units.Centimeters * 3f), Convert.ToSingle((Units.Centimeters * WidthReport)), (Units.Centimeters * (float)higthHeader));
                RemaintitleText.Text      = "";
                RemaintitleText.VertAlign = VertAlign.Center;
                RemaintitleText.HorzAlign = HorzAlign.Center;
                RemaintitleText.Fill      = new LinearGradientFill(backgroundColor, colorHeader, 90, Convert.ToSingle(higthHeader), 1f);
            }

            MainReport.Save(Application.StartupPath + "\\Report\\Report_TableResult.frx");
            MainReport.Dispose();

            functionReturnValue = true;
            return(functionReturnValue);

Err:
            return(functionReturnValue);
        }
Beispiel #30
0
        private void toolPrintPreview_Click(object sender, EventArgs e)
        {
            if (dgList.Rows.Count == 0)
            {
                toolPrint.Enabled        = false;
                toolPrintPreview.Enabled = false;
                return;
            }

            DataSet ds = new DataSet();

            //DataTable dt = (DataTable)dgList.DataSource;
            DataTable  dt      = GetDgvToTable(dgList);
            DataTable  dtPrint = dt.Copy();
            DataColumn dc1     = new DataColumn("totalChargeOld", typeof(decimal));

            dtPrint.Columns.Add(dc1);
            //dtPrint.Columns["totalChargeOld"].Expression = "OVERDUEGET + totalCharge";


            DataColumn dc2 = new DataColumn("REMITSUM", typeof(decimal));

            dtPrint.Columns.Add(dc2);

            for (int i = 0; i < dtPrint.Rows.Count - 1; i++)
            {
                dtPrint.Rows[i]["totalChargeOld"] = (Information.IsNumeric(dtPrint.Rows[i]["totalCharge"]) ? Convert.ToDecimal(dtPrint.Rows[i]["totalCharge"]) : 0) +
                                                    (Information.IsNumeric(dtPrint.Rows[i]["OVERDUEGET"]) ? Convert.ToDecimal(dtPrint.Rows[i]["OVERDUEGET"]) : 0);

                dtPrint.Rows[i]["REMITSUM"] = (Information.IsNumeric(dtPrint.Rows[i]["REMITWATERFEE"]) ? Convert.ToDecimal(dtPrint.Rows[i]["REMITWATERFEE"]) : 0) +
                                              (Information.IsNumeric(dtPrint.Rows[i]["REMITEXTRAFEE"]) ? Convert.ToDecimal(dtPrint.Rows[i]["REMITEXTRAFEE"]) : 0) +
                                              (Information.IsNumeric(dtPrint.Rows[i]["REMITOVERDUE"]) ? Convert.ToDecimal(dtPrint.Rows[i]["REMITOVERDUE"]) : 0);
            }

            //统计未减免总水费小计
            object objSumToltalCharge = dtPrint.Compute("SUM(totalChargeOld)", "");

            if (Information.IsNumeric(objSumToltalCharge))
            {
                dtPrint.Rows[dtPrint.Rows.Count - 1]["totalChargeOld"] = Convert.ToDecimal(objSumToltalCharge).ToString("F2");
            }

            //统计减免总水费小计
            object objSumRemit = dtPrint.Compute("SUM(REMITSUM)", "");

            if (Information.IsNumeric(objSumRemit))
            {
                dtPrint.Rows[dtPrint.Rows.Count - 1]["REMITSUM"] = Convert.ToDecimal(objSumRemit).ToString("F2");
            }

            dtPrint.TableName = "水费减免明细模板";
            ds.Tables.Add(dtPrint);
            FastReport.Report report1 = new FastReport.Report();
            try
            {
                // load the existing report
                report1.Load(Application.StartupPath + @"\PRINTModel\水费减免明细模板.frx");
                // register the dataset
                report1.RegisterData(ds);
                report1.GetDataSource("水费减免明细模板").Enabled = true;
                // run the report
                report1.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                // free resources used by report
                report1.Dispose();
            }
        }
Beispiel #31
0
 /// <summary>
 /// 打印预览
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void tsmPreviewReport_Click(object sender, EventArgs e)
 {
     if (tsmChooseReport.HasDropDownItems)
     {
         report = new FastReport.Report();
         if (!report.IsRunning)
         {
             GetData(tsmChooseDetail[iDefaultChecked].Name);
             report.Load(new MemoryStream(bt));
             RegReportData();
         }
         frmReportPreview rp = new frmReportPreview(report);
         rp.ShowDialog();
         report.Dispose();
     }
 }
        public FileResult DepoIslemYazdir(string ID = "")
        {
            FastReport.Utils.Config.WebMode = true;
            FastReport.Report report1 = new FastReport.Report();

            report1.Prepare(true);
            DataTable dtDetay = new DataTable();

            try
            {
                report1.Load(Path.Combine(Server.MapPath("~/REPORTS/" + Session["FirmaID"].ToString()), "depo.frx"));
            }
            catch {
                report1.Load(Path.Combine(Server.MapPath("~/REPORTS/Default"), "depo.frx"));
            }

            using (SqlConnection bag = new SqlConnection(AyarMetot.strcon))
            {
                if (bag.State == ConnectionState.Closed)
                {
                    bag.Open();
                }
                using (SqlCommand servisgetir = new SqlCommand("Select * From STORE_PROCESS where ID='" + ID + "'", bag))
                {
                    using (SqlDataReader dt = servisgetir.ExecuteReader())
                    {
                        while (dt.Read())
                        {
                            dtDetay = AyarMetot.DepoIslemDetayBil(ID);


                            report1.RegisterData(AyarMetot.DepoIslemBil(ID), "Depo_İşlem");
                            report1.RegisterData(dtDetay, "Depo_İşlem_Detay");
                            report1.RegisterData(AyarMetot.FirmaBil(), "FirmaBilgileri");

                            report1.GetDataSource("Depo_İşlem").Enabled       = true;
                            report1.GetDataSource("Depo_İşlem_Detay").Enabled = true;
                            report1.GetDataSource("FirmaBilgileri").Enabled   = true;
                        }
                    }
                }
            }

            using (FastReport.Export.Pdf.PDFExport pdf = new FastReport.Export.Pdf.PDFExport())
            {
                try
                {
                    ReportPage page1 = report1.Pages[0] as ReportPage;
                    page1.PaperHeight = page1.PaperHeight + (dtDetay.Rows.Count * ((float)6.5));
                }
                catch { }

                report1.Prepare(true);
                try {
                    report1.Export(pdf, Path.Combine(Server.MapPath("~/REPORTS/" + Session["FirmaID"].ToString()), "depo.pdf"));
                }
                catch
                {
                    report1.Export(pdf, Path.Combine(Server.MapPath("~/REPORTS/Default"), "depo.pdf"));
                }
                dtDetay.Dispose();

                //System.IO.MemoryStream ms = new System.IO.MemoryStream();
                //report1.Save(Path.Combine(Server.MapPath("~/REPORTS/ATTACHMENT"), "depoyeni.frx"));

                byte[] dosya;
                report1.Dispose();
                try {
                    dosya = System.IO.File.ReadAllBytes(Path.Combine(Server.MapPath("~/REPORTS/" + Session["FirmaID"].ToString()), "depo.pdf"));
                }
                catch
                {
                    dosya = System.IO.File.ReadAllBytes(Path.Combine(Server.MapPath("~/REPORTS/Default"), "depo.pdf"));
                }
                return(File(dosya, "application/pdf"));
            }
        }