Exemplo n.º 1
0
        private void Report_Click(object sender, RoutedEventArgs e)
        {
            
                if (this.pathText.Text.Equals(""))
                {
                    JXMessageBox.Show(this, "文件名与保存路径不能为空!", MsgImage.Error);
                    return;
                }
                bool b=false;
                FileBean bean = new FileBean();
                if (this.reportWord.IsChecked == true)
                {
                    bean.FontSize = int.Parse(this.wordfont.Text);
                    bean.Color = this.wordColor.Background;
                    bean.Width = int.Parse(this.wordWidth.Text);
                    bean.Height = int.Parse(this.wordHeight.Text);
                }
                else if (this.reportExcel.IsChecked == true)
                {
                    //bean.FontSize = int.Parse(this.excelFont.Text);
                    //bean.Color = this.ExcelColor.Background;
                    //bean.Width = int.Parse(this.excelWidth.Text);
                    //bean.Height = int.Parse(this.excelHeight.Text);
                    string path=@""+this.pathText.Text;
                    RoomClass rc = new RoomClass();
                    DataSet dataSet = rc.queryHistoryAlarmList();
                    b=ExportFile.DataSetToExcel(path);
                   
                }
                else if (this.reportPdf.IsChecked == true)
                {
                    //bean.FontSize = int.Parse(this.pdfFont.Text);
                    float fontSize = float.Parse(this.pdfFont.Text);
                    //bean.Color = this.pdfColor.Background;
                    Brush color = this.pdfColor.Background;
                    //bean.Width = int.Parse(this.pdfWidh.Text);
                    //bean.Height = int.Parse(this.pdfheight.Text);
                    string title = "历史报警表";
                    string path = @"" + this.pathText.Text;
                   
                       // RoomClass rc = new RoomClass();
                    DataSet dataSet = MySqlHelper.GetDataSet(MySqlHelper.Conn, CommandType.Text, ExportFileSql.sql);
                    b= ExportFile.ConvertDataTableToPDF(dataSet.Tables[0], path, title,color, fontSize, null);
                }
                else if (this.reportHtml.IsChecked == true)
                {
                   //bean.FontSize = int.Parse(this.htmlFont.Text);
                   // bean.Color = this.htmlColor.Background;
                   // bean.Width = int.Parse(this.htmlWidth.Text);
                    //string fontColor = this.htmlColor.Background.ToString();
                    //System.Windows.MessageBox.Show(fontColor);
                    string path = @"" + this.pathText.Text;
                    //bean.Height = int.Parse(this.htmlHeight.Text);
                    //RoomClass rc = new RoomClass();
                    DataSet dataSet = MySqlHelper.GetDataSet(MySqlHelper.Conn, CommandType.Text, ExportFileSql.sql);
                    string title = "历史报警数据";
                    b = ExportFile.MakeHtml(path, dataSet, title, this.htmlColor.Background, int.Parse(this.htmlFont.Text));

                }
                if (b == true)
                {
                    JXMessageBox.Show(this, "文件成功导出!", MsgImage.Success);
                }
                else
                {
                    JXMessageBox.Show(this, "文件导出失败!", MsgImage.Error);
                }
            }
Exemplo n.º 2
0
        private void Report_Click(object sender, RoutedEventArgs e)
        {
            if (this.pathText.Text.Equals(""))
            {
                JXMessageBox.Show(this, "文件名与保存路径不能为空!", MsgImage.Error);
                return;
            }
            bool     b    = false;
            FileBean bean = new FileBean();

            if (this.reportWord.IsChecked == true)
            {
                bean.FontSize = int.Parse(this.wordfont.Text);
                bean.Color    = this.wordColor.Background;
                bean.Width    = int.Parse(this.wordWidth.Text);
                bean.Height   = int.Parse(this.wordHeight.Text);
            }
            else if (this.reportExcel.IsChecked == true)
            {
                //bean.FontSize = int.Parse(this.excelFont.Text);
                //bean.Color = this.ExcelColor.Background;
                //bean.Width = int.Parse(this.excelWidth.Text);
                //bean.Height = int.Parse(this.excelHeight.Text);
                string    path    = @"" + this.pathText.Text;
                RoomClass rc      = new RoomClass();
                DataSet   dataSet = rc.queryHistoryAlarmList();
                b = ExportFile.DataSetToExcel(path);
            }
            else if (this.reportPdf.IsChecked == true)
            {
                //bean.FontSize = int.Parse(this.pdfFont.Text);
                float fontSize = float.Parse(this.pdfFont.Text);
                //bean.Color = this.pdfColor.Background;
                Brush color = this.pdfColor.Background;
                //bean.Width = int.Parse(this.pdfWidh.Text);
                //bean.Height = int.Parse(this.pdfheight.Text);
                string title = "历史报警表";
                string path  = @"" + this.pathText.Text;

                // RoomClass rc = new RoomClass();
                DataSet dataSet = MySqlHelper.GetDataSet(MySqlHelper.Conn, CommandType.Text, ExportFileSql.sql);
                b = ExportFile.ConvertDataTableToPDF(dataSet.Tables[0], path, title, color, fontSize, null);
            }
            else if (this.reportHtml.IsChecked == true)
            {
                //bean.FontSize = int.Parse(this.htmlFont.Text);
                // bean.Color = this.htmlColor.Background;
                // bean.Width = int.Parse(this.htmlWidth.Text);
                //string fontColor = this.htmlColor.Background.ToString();
                //System.Windows.MessageBox.Show(fontColor);
                string path = @"" + this.pathText.Text;
                //bean.Height = int.Parse(this.htmlHeight.Text);
                //RoomClass rc = new RoomClass();
                DataSet dataSet = MySqlHelper.GetDataSet(MySqlHelper.Conn, CommandType.Text, ExportFileSql.sql);
                string  title   = "历史报警数据";
                b = ExportFile.MakeHtml(path, dataSet, title, this.htmlColor.Background, int.Parse(this.htmlFont.Text));
            }
            if (b == true)
            {
                JXMessageBox.Show(this, "文件成功导出!", MsgImage.Success);
            }
            else
            {
                JXMessageBox.Show(this, "文件导出失败!", MsgImage.Error);
            }
        }