예제 #1
0
        public void LoadReport()
        {
            string location = @"Report/Certificateofcanv.frx";

            rpt.Load(location);
            rpt.RegisterData(ds);
            rpt.RegisterData(ds1);
            rpt.RegisterData(ds2);
            rpt.RegisterData(ds3);
            rpt.RegisterData(ds4);
            rpt.RegisterData(ds5);
            rpt.RegisterData(ds6);
            rpt.RegisterData(ds7);
            rpt.RegisterData(ds8);
            rpt.RegisterData(ds9);
            rpt.GetDataSource("certificate_ofcanvass").Enabled  = true;
            rpt.GetDataSource("certificate_ofcanvass1").Enabled = true;
            rpt.GetDataSource("certificate_ofcanvass2").Enabled = true;
            rpt.GetDataSource("certificate_ofcanvass3").Enabled = true;
            rpt.GetDataSource("certificate_ofcanvass4").Enabled = true;
            rpt.GetDataSource("certificate_ofcanvass5").Enabled = true;
            rpt.GetDataSource("certificate_ofcanvass6").Enabled = true;
            rpt.GetDataSource("certificate_ofcanvass7").Enabled = true;
            rpt.GetDataSource("certificate_ofcanvass8").Enabled = true;
            rpt.GetDataSource("certificate_ofcanvass9").Enabled = true;
        }
예제 #2
0
        private void Table1_ManualBuild(object sender, EventArgs e)
        {
            // get the data source by its name
            DataSourceBase rowData = Report.GetDataSource("Oocytes");

            // init the data source
            rowData.Init();

            // print the first table row - it is a header
            Table1.PrintColumn(0);
            // each PrintRow call must be followed by either PrintColumn or PrintColumns call
            // to print cells on the row
            Table1.PrintRows();


            // now enumerate the data source and print the table body
            while (rowData.HasMoreRows)
            {
                // print the table body
                Table1.PrintColumn(1);
                Table1.PrintRows();

                // go next data source row
                rowData.Next();
            }
        }
        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>
예제 #4
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();
            }
        }
예제 #5
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();
            }
        }
        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>
예제 #7
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>
예제 #8
0
        public static void BuildParmsAndData(ReportRequestArgs e, FastReport.Report report, enBuildParmsAndDataActionType actionType)
        {
            if (actionType == enBuildParmsAndDataActionType.SetValue)  // 对模板已有参数赋值
            {
                foreach (FastReport.Data.Parameter parm in report.Parameters)
                {
                    // 参数值是从 fastParms.ReportParameters 中传入的
                    foreach (DataColumn dc in e.RecordDR.Table.Columns)
                    {
                        if (parm.Name.Equals(dc.ColumnName, StringComparison.CurrentCultureIgnoreCase))
                        {
                            parm.Value = e.RecordDR[dc.ColumnName];
                            break;
                        }
                    }
                }
            }
            else    // 添加新的参数至模板
            {
                if (e.RecordDR != null)
                {
                    report.Parameters.Clear();
                    foreach (DataColumn dc in e.RecordDR.Table.Columns)
                    {
                        FastReport.Data.Parameter parm = new FastReport.Data.Parameter(dc.ColumnName);
                        parm.DataType = dc.DataType;
                        parm.Value    = e.RecordDR[dc.ColumnName];
                        report.Parameters.Add(parm);
                    }
                }
            }

            if (e.DSDataSource != null)
            {
                for (int i = 0, j = e.DSDataSource.Tables.Count; i < j; i++)
                {
                    DataTable table = e.DSDataSource.Tables[i];
                    string    description;
                    string    strTableName = table.TableName;
                    report.RegisterData(table, strTableName);
                    //report.RegisterData(e.DSDataSource);
                    //report.ReportInfo.Description = table.TableName;
                    DataSourceBase dataSource = report.GetDataSource(strTableName);
                    dataSource.Enabled = true;
                }
            }
        }
예제 #9
0
        void BindReport(DataTable dt)
        {
            FastReport.Report report = new FastReport.Report();
            //判断有报表数据,则注册数据
            if (dt != null && dt.Rows.Count > 0)
            {
                report.RegisterData(dt, "v_repair_vehicle_number_report");
            }
            else
            {
                return;
            }

            report.GetDataSource("v_repair_vehicle_number_report").Enabled = true;
            report.Load("Report/repair_vehicle_number_report.frx");
            report.Preview = pcReport;
            report.Prepare();
            report.ShowPrepared();
        }
        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();
            }
        }
예제 #11
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();
            }
        }
예제 #12
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 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>
예제 #14
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();
            }
        }
예제 #15
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();
            }
        }
예제 #16
0
        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"));
            }
        }
예제 #17
0
        /// <summary>
        /// 生成默认报表
        /// </summary>
        /// <returns></returns>
        public FastReport.Report DefaultReport()
        {
            FastReport.Report report = new FastReport.Report();
            //判断有报表数据,则注册数据
            if (dt != null && dt.Rows.Count > 0)
            {
                report.RegisterData(dt, styleObject);
            }
            else
            {
                return(null);
            }
            //查询报表设置
            DataTable dtReportSet = DBHelper.GetTable("", "tb_report_set", "*", string.Format("set_object='{0}' and set_user='******'", styleObject, GlobalStaticObj.UserID), "", "order by set_num");

            if (dtReportSet == null || dtReportSet.Rows.Count == 0)
            {
                return(null);
            }
            // enable the "Employees" table to use it in the report
            report.GetDataSource(styleObject).Enabled = true;

            // add report page
            ReportPage page = new ReportPage();

            if (paperSize != null)
            {
                page.PaperWidth  = paperSize.Width;
                page.PaperHeight = paperSize.Height;
            }
            report.Pages.Add(page);
            // always give names to objects you create. You can use CreateUniqueName method to do this;
            // call it after the object is added to a report.
            page.CreateUniqueName();

            // create title band
            page.ReportTitle = new ReportTitleBand();
            // native FastReport unit is screen pixel, use conversion
            page.ReportTitle.Height = Units.Centimeters * 1;
            page.ReportTitle.CreateUniqueName();

            // create title text
            TextObject titleText = new TextObject();

            titleText.Parent = page.ReportTitle;
            titleText.CreateUniqueName();
            //titleText.Bounds = new RectangleF(Units.Centimeters * 5, 0, Units.Centimeters * 10, Units.Centimeters * 1);
            titleText.Bounds    = new RectangleF(0, 0, Units.Millimeters * page.PaperWidth, Units.Centimeters * 1);
            titleText.Font      = new Font("Arial", 14, FontStyle.Bold);
            titleText.Text      = styleTitle;
            titleText.HorzAlign = HorzAlign.Center;
            titleText.VertAlign = VertAlign.Center;
            //内容行高
            float rowHeight = Units.Centimeters * 1F;
            //标题行高,如果有合并列,怎行高价高
            float rowHeaderHeight = rowHeight;

            if (dicSpanRows != null && dicSpanRows.Count > 0)
            {
                rowHeaderHeight = Units.Centimeters * 1.5f;
            }
            page.PageHeader        = new PageHeaderBand();
            page.PageHeader.Height = rowHeaderHeight;
            page.PageHeader.CreateUniqueName();
            #region 生成报表内容
            // create data band
            DataBand dataBand = new DataBand();
            page.Bands.Add(dataBand);
            dataBand.CreateUniqueName();
            dataBand.DataSource = report.GetDataSource(styleObject);
            dataBand.Height     = rowHeight;
            float x = 0F;//x坐标

            foreach (DataRow dr in dtReportSet.Rows)
            {
                //判断是否要打印
                if (CommonCtrl.IsNullToString(dr["is_print"]) != "1")
                {
                    continue;
                }
                //列宽
                float columnWidth = Units.Centimeters * 2;
                //标题
                string headerName = string.Empty;
                //获取设置的列宽和标题
                float.TryParse(dr["set_width"].ToString(), out columnWidth);
                //columnWidth = columnWidth * 0.9f;
                headerName = dr["set_name"].ToString();
                //生成标题
                TextObject txtHeader = new TextObject();
                txtHeader.Parent = page.PageHeader;
                txtHeader.CreateUniqueName();
                txtHeader.Text      = headerName;
                txtHeader.HorzAlign = HorzAlign.Center;
                txtHeader.VertAlign = VertAlign.Center;
                //生成标题竖线
                LineObject lineHeaderVer = new LineObject();
                lineHeaderVer.Parent = page.PageHeader;
                //生成标题横线
                LineObject lineHeaderHor = new LineObject();
                lineHeaderHor.Parent = page.PageHeader;
                lineHeaderHor.Bounds = new RectangleF(x, 0, columnWidth, 1f);

                //数据源列名称
                string dataName = dr["set_data_name"].ToString();
                string spanName = IsContainDataColumn(dataName);
                //判断列是否是合并列
                if (spanName.Length > 0)
                {
                    #region 合并列标题
                    txtHeader.Bounds     = new RectangleF(x, rowHeaderHeight / 2, columnWidth, rowHeaderHeight / 2);
                    lineHeaderVer.Bounds = new RectangleF(x, rowHeaderHeight / 2, 1F, rowHeaderHeight / 2);
                    //生成合并列的短竖线
                    LineObject lineHeaderHorSpan = new LineObject();
                    lineHeaderHorSpan.Parent = page.PageHeader;
                    lineHeaderHorSpan.Bounds = new RectangleF(x, rowHeaderHeight / 2, columnWidth, 1F);
                    //判断是否包含合并列头
                    if (dicSpanWidth.ContainsKey(spanName))
                    {
                        //增加合并列头的列宽
                        RectangleF rf = dicSpanWidth[spanName];
                        rf.Width += columnWidth;
                        dicSpanWidth[spanName] = rf;
                    }
                    else
                    {
                        //记录合并列头
                        RectangleF rf = new RectangleF();
                        rf.X      = x;
                        rf.Y      = 0;
                        rf.Width  = columnWidth;
                        rf.Height = rowHeaderHeight / 2;
                        dicSpanWidth.Add(spanName, rf);
                    }
                    #endregion
                }
                else
                {
                    lineHeaderVer.Bounds = new RectangleF(x, 0, 1F, rowHeaderHeight);
                    txtHeader.Bounds     = new RectangleF(x, 0, columnWidth, rowHeaderHeight);
                }
                // create two text objects with employee's name and birth date
                //生成内容
                TextObject empNameText = new TextObject();
                empNameText.Parent = dataBand;
                empNameText.CreateUniqueName();
                empNameText.Bounds = new RectangleF(x, 0, columnWidth, rowHeight);
                DataColumn dc = dt.Columns[dataName];
                empNameText.Text = string.Format("[{0}.{1}]", styleObject, dataName);
                //empNameText.HideZeros = true;
                if (dc != null && dc.DataType != typeof(string))
                {
                    empNameText.HorzAlign = HorzAlign.Right;
                }
                else
                {
                    empNameText.HorzAlign = HorzAlign.Center;
                }
                empNameText.VertAlign = VertAlign.Center;
                //生成内容列的竖线
                LineObject lineVertical = new LineObject();
                lineVertical.Parent = dataBand;
                lineVertical.Bounds = new RectangleF(x, 0, 1F, rowHeight);
                //生成内容列顶部的横线
                LineObject lineHorizontal = new LineObject();
                lineHorizontal.Parent = dataBand;
                lineHorizontal.Bounds = new RectangleF(x, 0, columnWidth, 1f);
                //生成内荣列底部的横线
                LineObject lineHorizontalD = new LineObject();
                lineHorizontalD.Parent = dataBand;
                lineHorizontalD.Bounds = new RectangleF(x, rowHeight, columnWidth, 1f);

                //x坐标增加当前列
                x += columnWidth;
            }

            //生成标题右边的竖线
            LineObject lineHeaderRightVer = new LineObject();
            lineHeaderRightVer.Parent = page.PageHeader;
            lineHeaderRightVer.Bounds = new RectangleF(x, 0, 1f, rowHeight);
            //生成内容右边的竖线
            LineObject lineRightVer = new LineObject();
            lineRightVer.Parent = dataBand;
            lineRightVer.Bounds = new RectangleF(x, 0, 1f, rowHeight);
            //生成合并列头
            foreach (string span in dicSpanWidth.Keys)
            {
                //合并列头
                TextObject txtSpan = new TextObject();
                txtSpan.Parent = page.PageHeader;
                txtSpan.CreateUniqueName();
                txtSpan.Bounds    = dicSpanWidth[span];
                txtSpan.Text      = span;
                txtSpan.HorzAlign = HorzAlign.Center;
                txtSpan.VertAlign = VertAlign.Center;
                //合并列头的竖线
                LineObject lineHeaderVer = new LineObject();
                lineHeaderVer.Parent = page.PageHeader;
                lineHeaderVer.Bounds = new RectangleF(txtSpan.Bounds.X, txtSpan.Bounds.Y, 1f, txtSpan.Bounds.Height);
            }
            #endregion
            return(report);
        }
예제 #18
0
        private void btnImprimirSugerido_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.dgvDatos.DataSource == null)
                    return;

                //(System.Collections.Generic.List<pauParteBusquedaEnTraspasos_Result>)
                var lista = new List<pauParteBusquedaEnTraspasos_Result>();
                foreach (DataGridViewRow fila in this.dgvDatos.Rows)
                {
                    var cb = (DataGridViewCheckBoxCell)fila.Cells["X"];
                    if (cb.Value != null)
                    {
                        if (Util.Logico(cb.Value))
                        {
                            var sugerido = new pauParteBusquedaEnTraspasos_Result()
                            {
                                ParteID = Util.Entero(fila.Cells["ParteID"].Value),
                                NumeroParte = Util.Cadena(fila.Cells["NumeroParte"].Value),
                                NombreParte = Util.Cadena(fila.Cells["NombreParte"].Value),
                                MarcaParteID = Util.Entero(fila.Cells["MarcaParteID"].Value),
                                LineaID = Util.Entero(fila.Cells["LineaID"].Value),
                                SistemaID = Util.Entero(fila.Cells["SistemaID"].Value),
                                SubsistemaID = Util.Entero(fila.Cells["SubsistemaID"].Value),
                                SucursalID = Util.Entero(fila.Cells["SucursalID"].Value),
                                Existencia = Util.Decimal(fila.Cells["Existencia"].Value),
                                Maximo = Util.Decimal(fila.Cells["Maximo"].Value),
                                Minimo = Util.Decimal(fila.Cells["Minimo"].Value),
                                SucursalDestinoID = Util.Entero(fila.Cells["SucursalDestinoID"].Value),
                                DestinoExistencia = Util.Decimal(fila.Cells["DestinoExistencia"].Value),
                                DestinoMaximo = Util.Decimal(fila.Cells["DestinoMaximo"].Value),
                                DestinoMinimo = Util.Decimal(fila.Cells["DestinoMinimo"].Value),
                                Sugerencia = Util.Decimal(fila.Cells["Sugerencia"].Value)
                            };
                            lista.Add(sugerido);
                        }
                    }
                }
                IEnumerable<pauParteBusquedaEnTraspasos_Result> listaE = lista;

                using (FastReport.Report report = new FastReport.Report())
                {
                    report.Load(string.Format("{0}{1}", GlobalClass.ConfiguracionGlobal.pathReportes, "ReporteSugeridoTraspaso.frx"));
                    report.SetParameterValue("Origen", this.cboUbicacionOrigen.Text);
                    report.SetParameterValue("Destino", this.cboUbicacionDestino.Text);
                    report.SetParameterValue("FechaHora", DateTime.Now);
                    report.RegisterData(listaE, "sugerido", 3);
                    report.GetDataSource("sugerido").Enabled = true;
                    report.Show(true);
                }
            }
            catch (Exception ex)
            {
                Util.MensajeError(ex.Message, GlobalClass.NombreApp);
            }
        }
        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);
        }
예제 #20
0
        /// <summary>
        /// 生成默认报表
        /// </summary>
        /// <returns></returns>
        public FastReport.Report DefaultReport()
        {

            FastReport.Report report = new FastReport.Report();
            //判断有报表数据,则注册数据
            if (dt != null && dt.Rows.Count > 0)
            {
                report.RegisterData(dt, styleObject);
            }
            else
            {
                return null;
            }
            //查询报表设置
            DataTable dtReportSet = DBHelper.GetTable("", "tb_report_set", "*", string.Format("set_object='{0}' and set_user='******'", styleObject, GlobalStaticObj.UserID), "", "order by set_num");
            if (dtReportSet == null || dtReportSet.Rows.Count == 0)
            {
                return null;
            }
            // enable the "Employees" table to use it in the report
            report.GetDataSource(styleObject).Enabled = true;

            // add report page
            ReportPage page = new ReportPage();
            if (paperSize != null)
            {
                page.PaperWidth = paperSize.Width;
                page.PaperHeight = paperSize.Height;
            }
            report.Pages.Add(page);
            // always give names to objects you create. You can use CreateUniqueName method to do this;
            // call it after the object is added to a report.
            page.CreateUniqueName();

            // create title band
            page.ReportTitle = new ReportTitleBand();
            // native FastReport unit is screen pixel, use conversion 
            page.ReportTitle.Height = Units.Centimeters * 1;
            page.ReportTitle.CreateUniqueName();

            // create title text
            TextObject titleText = new TextObject();
            titleText.Parent = page.ReportTitle;
            titleText.CreateUniqueName();
            //titleText.Bounds = new RectangleF(Units.Centimeters * 5, 0, Units.Centimeters * 10, Units.Centimeters * 1);
            titleText.Bounds = new RectangleF(0, 0, Units.Millimeters * page.PaperWidth, Units.Centimeters * 1);
            titleText.Font = new Font("Arial", 14, FontStyle.Bold);
            titleText.Text = styleTitle;
            titleText.HorzAlign = HorzAlign.Center;
            titleText.VertAlign = VertAlign.Center;
            //内容行高
            float rowHeight = Units.Centimeters * 1F;
            //标题行高,如果有合并列,怎行高价高
            float rowHeaderHeight = rowHeight;
            if (dicSpanRows != null && dicSpanRows.Count > 0)
            {
                rowHeaderHeight = Units.Centimeters * 1.5f;
            }
            page.PageHeader = new PageHeaderBand();
            page.PageHeader.Height = rowHeaderHeight;
            page.PageHeader.CreateUniqueName();
            #region 生成报表内容
            // create data band
            DataBand dataBand = new DataBand();
            page.Bands.Add(dataBand);
            dataBand.CreateUniqueName();
            dataBand.DataSource = report.GetDataSource(styleObject);
            dataBand.Height = rowHeight;
            float x = 0F;//x坐标

            foreach (DataRow dr in dtReportSet.Rows)
            {
                //判断是否要打印
                if (CommonCtrl.IsNullToString(dr["is_print"]) != "1")
                {
                    continue;
                }
                //列宽
                float columnWidth = Units.Centimeters * 2;
                //标题
                string headerName = string.Empty;
                //获取设置的列宽和标题
                float.TryParse(dr["set_width"].ToString(), out columnWidth);
                //columnWidth = columnWidth * 0.9f;
                headerName = dr["set_name"].ToString();
                //生成标题
                TextObject txtHeader = new TextObject();
                txtHeader.Parent = page.PageHeader;
                txtHeader.CreateUniqueName();
                txtHeader.Text = headerName;
                txtHeader.HorzAlign = HorzAlign.Center;
                txtHeader.VertAlign = VertAlign.Center;
                //生成标题竖线
                LineObject lineHeaderVer = new LineObject();
                lineHeaderVer.Parent = page.PageHeader;
                //生成标题横线
                LineObject lineHeaderHor = new LineObject();
                lineHeaderHor.Parent = page.PageHeader;
                lineHeaderHor.Bounds = new RectangleF(x, 0, columnWidth, 1f);

                //数据源列名称
                string dataName = dr["set_data_name"].ToString();
                string spanName = IsContainDataColumn(dataName);
                //判断列是否是合并列
                if (spanName.Length > 0)
                {
                    #region 合并列标题
                    txtHeader.Bounds = new RectangleF(x, rowHeaderHeight / 2, columnWidth, rowHeaderHeight / 2);
                    lineHeaderVer.Bounds = new RectangleF(x, rowHeaderHeight / 2, 1F, rowHeaderHeight / 2);
                    //生成合并列的短竖线
                    LineObject lineHeaderHorSpan = new LineObject();
                    lineHeaderHorSpan.Parent = page.PageHeader;
                    lineHeaderHorSpan.Bounds = new RectangleF(x, rowHeaderHeight / 2, columnWidth, 1F);
                    //判断是否包含合并列头
                    if (dicSpanWidth.ContainsKey(spanName))
                    {
                        //增加合并列头的列宽
                        RectangleF rf = dicSpanWidth[spanName];
                        rf.Width += columnWidth;
                        dicSpanWidth[spanName] = rf;
                    }
                    else
                    {
                        //记录合并列头
                        RectangleF rf = new RectangleF();
                        rf.X = x;
                        rf.Y = 0;
                        rf.Width = columnWidth;
                        rf.Height = rowHeaderHeight / 2;
                        dicSpanWidth.Add(spanName, rf);
                    }
                    #endregion
                }
                else
                {
                    lineHeaderVer.Bounds = new RectangleF(x, 0, 1F, rowHeaderHeight);
                    txtHeader.Bounds = new RectangleF(x, 0, columnWidth, rowHeaderHeight);
                }
                // create two text objects with employee's name and birth date
                //生成内容
                TextObject empNameText = new TextObject();
                empNameText.Parent = dataBand;
                empNameText.CreateUniqueName();
                empNameText.Bounds = new RectangleF(x, 0, columnWidth, rowHeight);
                DataColumn dc = dt.Columns[dataName];
                empNameText.Text = string.Format("[{0}.{1}]", styleObject, dataName);
                //empNameText.HideZeros = true;
                if (dc != null && dc.DataType != typeof(string))
                {
                    empNameText.HorzAlign = HorzAlign.Right;
                }
                else
                {
                    empNameText.HorzAlign = HorzAlign.Center;
                }
                empNameText.VertAlign = VertAlign.Center;
                //生成内容列的竖线
                LineObject lineVertical = new LineObject();
                lineVertical.Parent = dataBand;
                lineVertical.Bounds = new RectangleF(x, 0, 1F, rowHeight);
                //生成内容列顶部的横线
                LineObject lineHorizontal = new LineObject();
                lineHorizontal.Parent = dataBand;
                lineHorizontal.Bounds = new RectangleF(x, 0, columnWidth, 1f);
                //生成内荣列底部的横线
                LineObject lineHorizontalD = new LineObject();
                lineHorizontalD.Parent = dataBand;
                lineHorizontalD.Bounds = new RectangleF(x, rowHeight, columnWidth, 1f);

                //x坐标增加当前列
                x += columnWidth;
            }

            //生成标题右边的竖线
            LineObject lineHeaderRightVer = new LineObject();
            lineHeaderRightVer.Parent = page.PageHeader;
            lineHeaderRightVer.Bounds = new RectangleF(x, 0, 1f, rowHeight);
            //生成内容右边的竖线
            LineObject lineRightVer = new LineObject();
            lineRightVer.Parent = dataBand;
            lineRightVer.Bounds = new RectangleF(x, 0, 1f, rowHeight);
            //生成合并列头
            foreach (string span in dicSpanWidth.Keys)
            {
                //合并列头
                TextObject txtSpan = new TextObject();
                txtSpan.Parent = page.PageHeader;
                txtSpan.CreateUniqueName();
                txtSpan.Bounds = dicSpanWidth[span];
                txtSpan.Text = span;
                txtSpan.HorzAlign = HorzAlign.Center;
                txtSpan.VertAlign = VertAlign.Center;
                //合并列头的竖线
                LineObject lineHeaderVer = new LineObject();
                lineHeaderVer.Parent = page.PageHeader;
                lineHeaderVer.Bounds = new RectangleF(txtSpan.Bounds.X, txtSpan.Bounds.Y, 1f, txtSpan.Bounds.Height);
            }
            #endregion
            #region 生成页脚
            page.PageFooter = new PageFooterBand();
            page.PageFooter.Height = rowHeaderHeight;
            page.PageHeader.CreateUniqueName();
            TextObject txtPageN = new TextObject();
            txtPageN.Parent = page.PageFooter;
            txtPageN.CreateUniqueName();
            txtPageN.Text = "[PageNofM]";
            txtPageN.Bounds = new RectangleF(100, 0, 200, rowHeaderHeight);

            //TextObject txtTotalPages = new TextObject();
            //txtTotalPages.Parent = page.PageFooter;
            //txtTotalPages.CreateUniqueName();
            //txtTotalPages.Text = "[TotalPages]";
            //txtTotalPages.Bounds = new RectangleF(350, 0, 200, rowHeaderHeight);
            #endregion
            return report;

        }
예제 #21
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();
            }
        }
        /// <summary>
        /// 打印收条
        /// </summary>
        /// <param name="TaskID"></param>
        /// <param name="_LastPointSort"></param>
        private void PrintReceipt(string TaskID, string _LastPointSort)
        {
            //获取用户基本信息
            Hashtable ht = new SqlServerHelper().GetHashtableById("View_WorkBase", "TaskID", TaskID);

            if (ht.Contains("SD"))
            {
                string _waterUserId      = ht["WATERUSERID"].ToString();
                string _waterUserName    = ht["WATERUSERNAME"].ToString();
                string _SD               = ht["SD"].ToString();
                string _waterUserAddress = ht["WATERUSERADDRESS"].ToString();
                string _TotalFee_CH      = "";//合计大写

                //获取费用合计
                string sqlstr = @"SELECT * FROM 
(SELECT SUM(FEE) AS FEE,InvoiceType AS FEENAME,'0' AS SORT FROM 
(SELECT FEE,(SELECT InvoiceTitle FROM Meter_FeeItmes WHERE FeeID=MWF.FeeID) AS InvoiceType FROM Meter_WorkResolveFee MWF,Meter_WorkResolve MWR 
WHERE MWF.ResolveID=MWR.ResolveID AND MWF.[STATE]=1 
AND MWR.TaskID=@TaskID AND PointSort=@LastPoingSort
) T GROUP BY InvoiceType
UNION ALL
SELECT SUM(CONVERT(decimal,Fee)),'合计','1' FROM Meter_WorkResolveFee MWF,Meter_WorkResolve MWR 
WHERE MWF.ResolveID=MWR.ResolveID AND MWF.[STATE]=1
AND MWR.TaskID=@TaskID AND PointSort=@LastPoingSort) M WHERE FEE<>0";
                //FEE--收费金额
                //FEENAME--收费名称
                DataTable dt = new SqlServerHelper().GetDateTableBySql(sqlstr, new SqlParameter[] { new SqlParameter("@TaskID", TaskID), new SqlParameter("@LastPoingSort", _LastPointSort) });
                if (DataTableHelper.IsExistRows(dt))
                {
                    DataRow[] DR = dt.Select("SORT=1");
                    if (DR.Length.Equals(1))
                    {
                        _TotalFee_CH = RMBHelper.CmycurD(decimal.Parse(DR[0]["FEE"].ToString()));
                    }

                    //====================================打印
                    DataSet   ds     = new DataSet();
                    DataTable dtTemp = dt.Copy();
                    dtTemp.TableName = "收据模板";
                    ds.Tables.Add(dtTemp);
                    FastReport.Report report1 = new FastReport.Report();

                    try
                    {
                        // load the existing report
                        report1.Load(Application.StartupPath + @"\PRINTModel\业扩模板\业扩预算收据模板.frx");

                        (report1.FindObject("txtReceiptNO") as FastReport.TextObject).Text        = "NO." + RECEIPTNO.Text;
                        (report1.FindObject("txtWaterUserNO") as FastReport.TextObject).Text      = "用 户 号:" + _waterUserId;
                        (report1.FindObject("txtSD") as FastReport.TextObject).Text               = "受理编号:" + _SD;
                        (report1.FindObject("txtWaterUserName") as FastReport.TextObject).Text    = "用户名称:" + _waterUserName;
                        (report1.FindObject("txtWaterUserAddress") as FastReport.TextObject).Text = "地    址:" + _waterUserAddress;

                        (report1.FindObject("txtCapMoney") as FastReport.TextObject).Text = "金额大写:" + _TotalFee_CH;
                        (report1.FindObject("txtCasher") as FastReport.TextObject).Text   = "收 款 员:" + strRealName;

                        (report1.FindObject("txtReceiptNO1") as FastReport.TextObject).Text        = "NO." + RECEIPTNO.Text;
                        (report1.FindObject("txtWaterUserNO1") as FastReport.TextObject).Text      = "用 户 号:" + _waterUserId;
                        (report1.FindObject("txtSD1") as FastReport.TextObject).Text               = "受理编号:" + _SD;
                        (report1.FindObject("txtWaterUserName1") as FastReport.TextObject).Text    = "用户名称:" + _waterUserName;
                        (report1.FindObject("txtWaterUserAddress1") as FastReport.TextObject).Text = "地    址:" + _waterUserAddress;

                        (report1.FindObject("txtCapMoney1") as FastReport.TextObject).Text = "金额大写:" + _TotalFee_CH;
                        (report1.FindObject("txtCasher1") as FastReport.TextObject).Text   = "收 款 员:" + strRealName;

                        // register the dataset
                        report1.RegisterData(ds);
                        report1.GetDataSource("收据模板").Enabled = true;
                        //report1.Show();
                        report1.PrintSettings.ShowDialog = false;
                        report1.Prepare();
                        report1.Print();
                    }
                    catch (Exception ex)
                    {
                        mes.Show("收据打印失败:" + ex.Message);
                    }
                }
            }
        }
예제 #23
0
        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"));
                }
            }
        }
예제 #24
0
        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"));
            }
        }
예제 #25
-1
        void BindReport(DataTable dt)
        {
            FastReport.Report report = new FastReport.Report();
            //判断有报表数据,则注册数据
            if (dt != null && dt.Rows.Count > 0)
            {
                report.RegisterData(dt, "v_repair_vehicle_number_report");
            }
            else
            {
                return;
            }

            report.GetDataSource("v_repair_vehicle_number_report").Enabled = true;
            report.Load("Report/repair_vehicle_number_report.frx");
            report.Preview = pcReport;
            report.Prepare();
            report.ShowPrepared();
        }
예제 #26
-1
        private void btnImprimirRpt_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.dgvReporteVentas.DataSource == null)
                    return;

                var lista = (System.Collections.Generic.List<pauVentasCancelaciones_Result>)this.dgvReporteVentas.DataSource;
                IEnumerable<pauVentasCancelaciones_Result> listaE = lista;

                using (FastReport.Report report = new FastReport.Report())
                {
                    report.Load(string.Format("{0}{1}", GlobalClass.ConfiguracionGlobal.pathReportes, "ReporteVentasCancelaciones.frx"));
                    report.SetParameterValue("Origen", this.cboSucursalRpt.Text);
                    report.SetParameterValue("Desde", this.dtpDesdeRpt.Value);
                    report.SetParameterValue("Hasta", this.dtpHastaRpt.Value);
                    report.RegisterData(listaE, "ventasCancelaciones", 3);
                    report.GetDataSource("ventasCancelaciones").Enabled = true;
                    report.Show(true);
                }
            }
            catch (Exception ex)
            {
                Util.MensajeError(ex.Message, GlobalClass.NombreApp);
            }
        }