private void CreateContents() { flowDoc.Blocks.Clear(); if (!CDRInfoValidate(out dt)) return; this.GetCDRInfo2(out dt); // CDR 데이터 가져오기 //if (chkout.IsChecked == true ? true : false) //{ // if (!valid) // { // // MessageBox.Show(string.Format("Room \"{0}\". You didin't checkout yet. You should chkeckout the first", extnum.Text.Trim())); // return; // } //} // create title Paragraph contents = new Paragraph() { Margin = new Thickness(0, 0, 0, 0), FontSize = 35.0d, TextAlignment = TextAlignment.Center }; string txt = "BILL"; Run titlerun = new Run(txt) { BaselineAlignment = BaselineAlignment.Baseline }; contents.Inlines.Add(new Bold(titlerun)); //flowDoc.Blocks.Clear(); flowDoc.Blocks.Add(contents); // create ext, date contents = new Paragraph() { Margin = new Thickness(20, 30, 0, 0), FontSize = 16.0d, TextAlignment = TextAlignment.Left }; txt = string.Format("Date : {0} - {1}\tExtention : {2}", ((DateTime)sdate.Value).ToShortDateString(), ((DateTime)edate.Value).ToShortDateString(), string.IsNullOrEmpty(_extnum) ? "ALL" : _extnum); contents.Inlines.Add(new Run(txt)); flowDoc.Blocks.Add(contents); // create 2nd table Table tbl2 = new Table() { Padding = new Thickness(0, 0, 0, 0), CellSpacing = 0.0d, Margin = new Thickness(10, 40, 0, 0) }; tbl2.Columns.Add(new TableColumn() { Width = new GridLength(50) }); tbl2.Columns.Add(new TableColumn() { Width = new GridLength(60) }); tbl2.Columns.Add(new TableColumn() { Width = new GridLength(160) }); tbl2.Columns.Add(new TableColumn() { Width = new GridLength(180) }); tbl2.Columns.Add(new TableColumn() { Width = new GridLength(180) }); tbl2.Columns.Add(new TableColumn() { Width = new GridLength(90) }); tbl2.Columns.Add(new TableColumn() { Width = new GridLength(70) }); tbl2.Columns.Add(new TableColumn() { Width = new GridLength(90) }); tbl2.Columns.Add(new TableColumn() { Width = new GridLength(120) }); docs.Document.PageWidth = 1050; // 1st row TableRow tblrow = new TableRow(); // 1st column cell Run run = new Run("Seq"); Paragraph paragraph = new Paragraph(run); TableCell tblcell = new TableCell(paragraph) { TextAlignment = TextAlignment.Center, BorderBrush = util.Str2Brush("#000000"), BorderThickness = new Thickness(2, 2, 2, 2), Padding = new Thickness(3, 3, 3, 3), Foreground = util.Str2Brush("#000000"), FontSize = 16.0d, LineHeight = 20.0d }; tblrow.Cells.Add(tblcell); run = new Run("Caller"); paragraph = new Paragraph(run); tblcell = new TableCell(paragraph) { TextAlignment = TextAlignment.Center, BorderBrush = util.Str2Brush("#000000"), BorderThickness = new Thickness(0, 2, 2, 2), Padding = new Thickness(3, 3, 3, 3), Foreground = util.Str2Brush("#000000"), FontSize = 16.0d, LineHeight = 20.0d }; tblrow.Cells.Add(tblcell); run = new Run("Callee"); paragraph = new Paragraph(run); tblcell = new TableCell(paragraph) { TextAlignment = TextAlignment.Center, BorderBrush = util.Str2Brush("#000000"), BorderThickness = new Thickness(0, 2, 2, 2), Padding = new Thickness(3, 3, 3, 3), Foreground = util.Str2Brush("#000000"), FontSize = 16.0d, LineHeight = 20.0d }; tblrow.Cells.Add(tblcell); run = new Run("Start Date"); paragraph = new Paragraph(run); tblcell = new TableCell(paragraph) { TextAlignment = TextAlignment.Center, BorderBrush = util.Str2Brush("#000000"), BorderThickness = new Thickness(0, 2, 2, 2), Padding = new Thickness(3, 3, 3, 3), Foreground = util.Str2Brush("#000000"), FontSize = 16.0d, LineHeight = 20.0d }; tblrow.Cells.Add(tblcell); run = new Run("End Date"); paragraph = new Paragraph(run); tblcell = new TableCell(paragraph) { TextAlignment = TextAlignment.Center, BorderBrush = util.Str2Brush("#000000"), BorderThickness = new Thickness(0, 2, 2, 2), Padding = new Thickness(3, 3, 3, 3), Foreground = util.Str2Brush("#000000"), FontSize = 16.0d, LineHeight = 20.0d }; tblrow.Cells.Add(tblcell); run = new Run("Used Time"); paragraph = new Paragraph(run); tblcell = new TableCell(paragraph) { TextAlignment = TextAlignment.Center, BorderBrush = util.Str2Brush("#000000"), BorderThickness = new Thickness(0, 2, 2, 2), Padding = new Thickness(3, 3, 3, 3), Foreground = util.Str2Brush("#000000"), FontSize = 16.0d, LineHeight = 20.0d }; tblrow.Cells.Add(tblcell); run = new Run("Result"); paragraph = new Paragraph(run); tblcell = new TableCell(paragraph) { TextAlignment = TextAlignment.Center, BorderBrush = util.Str2Brush("#000000"), BorderThickness = new Thickness(0, 2, 2, 2), Padding = new Thickness(3, 3, 3, 3), Foreground = util.Str2Brush("#000000"), FontSize = 16.0d, LineHeight = 20.0d }; tblrow.Cells.Add(tblcell); run = new Run("Rate"); paragraph = new Paragraph(run); tblcell = new TableCell(paragraph) { TextAlignment = TextAlignment.Center, BorderBrush = util.Str2Brush("#000000"), BorderThickness = new Thickness(0, 2, 2, 2), Padding = new Thickness(3, 3, 3, 3), Foreground = util.Str2Brush("#000000"), FontSize = 16.0d, LineHeight = 20.0d }; tblrow.Cells.Add(tblcell); run = new Run("Etc"); paragraph = new Paragraph(run); tblcell = new TableCell(paragraph) { TextAlignment = TextAlignment.Center, BorderBrush = util.Str2Brush("#000000"), BorderThickness = new Thickness(0, 2, 2, 2), Padding = new Thickness(3, 3, 3, 3), Foreground = util.Str2Brush("#000000"), FontSize = 16.0d, LineHeight = 20.0d }; tblrow.Cells.Add(tblcell); TableRowGroup rowgroup = new TableRowGroup() { Background = util.Str2Brush("#CCCCCC") }; rowgroup.Rows.Add(tblrow); tbl2.RowGroups.Add(rowgroup); // 2nd row ~ 끝 TOTALCALL _innercall = new TOTALCALL(); TOTALCALL _outercall = new TOTALCALL(); TOTALCALL _cellphonecall = new TOTALCALL(); TOTALCALL _internationalcall = new TOTALCALL(); TOTALCALL _totalcall = new TOTALCALL(); int evenchk = 0; foreach (DataRow row in dt.Rows) { tblrow = new TableRow(); // 1st column cell run = new Run(row[0].ToString()); paragraph = new Paragraph(run); tblcell = new TableCell(paragraph) { TextAlignment = TextAlignment.Center, BorderBrush = util.Str2Brush("#000000"), BorderThickness = new Thickness(2, 0, 2, 2), Padding = new Thickness(3, 3, 3, 3), Foreground = util.Str2Brush("#000000"), FontSize = 14.0d, LineHeight = 20.0d }; tblrow.Cells.Add(tblcell); run = new Run(row[1].ToString()); paragraph = new Paragraph(run); tblcell = new TableCell(paragraph) { TextAlignment = TextAlignment.Center, BorderBrush = util.Str2Brush("#000000"), BorderThickness = new Thickness(0, 0, 2, 2), Padding = new Thickness(3, 3, 3, 3), Foreground = util.Str2Brush("#000000"), FontSize = 14.0d, LineHeight = 20.0d }; tblrow.Cells.Add(tblcell); run = new Run(row[2].ToString()); paragraph = new Paragraph(run); tblcell = new TableCell(paragraph) { TextAlignment = TextAlignment.Center, BorderBrush = util.Str2Brush("#000000"), BorderThickness = new Thickness(0, 0, 2, 2), Padding = new Thickness(3, 3, 3, 3), Foreground = util.Str2Brush("#000000"), FontSize = 14.0d, LineHeight = 20.0d }; tblrow.Cells.Add(tblcell); DateTime _sdate = DateTime.Parse(row[3].ToString()); run = new Run(_sdate.ToString("MM/dd/yyyy HH:mm:ss")); paragraph = new Paragraph(run); tblcell = new TableCell(paragraph) { TextAlignment = TextAlignment.Center, BorderBrush = util.Str2Brush("#000000"), BorderThickness = new Thickness(0, 0, 2, 2), Padding = new Thickness(3, 3, 3, 3), Foreground = util.Str2Brush("#000000"), FontSize = 14.0d, LineHeight = 20.0d }; tblrow.Cells.Add(tblcell); DateTime _edate = DateTime.Parse(row[4].ToString()); run = new Run(_edate.ToString("MM/dd/yyyy HH:mm:ss")); paragraph = new Paragraph(run); tblcell = new TableCell(paragraph) { TextAlignment = TextAlignment.Center, BorderBrush = util.Str2Brush("#000000"), BorderThickness = new Thickness(0, 0, 2, 2), Padding = new Thickness(3, 3, 3, 3), Foreground = util.Str2Brush("#000000"), FontSize = 14.0d, LineHeight = 20.0d }; tblrow.Cells.Add(tblcell); TimeSpan ts = _edate - _sdate; run = new Run(ts.TotalSeconds.ToString()); paragraph = new Paragraph(run); tblcell = new TableCell(paragraph) { TextAlignment = TextAlignment.Center, BorderBrush = util.Str2Brush("#000000"), BorderThickness = new Thickness(0, 0, 2, 2), Padding = new Thickness(3, 3, 3, 3), Foreground = util.Str2Brush("#000000"), FontSize = 14.0d, LineHeight = 20.0d }; tblrow.Cells.Add(tblcell); run = new Run(row[5].ToString()); paragraph = new Paragraph(run); tblcell = new TableCell(paragraph) { TextAlignment = TextAlignment.Center, BorderBrush = util.Str2Brush("#000000"), BorderThickness = new Thickness(0, 0, 2, 2), Padding = new Thickness(3, 3, 3, 3), Foreground = util.Str2Brush("#000000"), FontSize = 14.0d, LineHeight = 20.0d }; tblrow.Cells.Add(tblcell); AMOUNTINFO _amt = this.GetAmounts(row, ts); run = new Run(_amt.fee.ToString()); paragraph = new Paragraph(run); tblcell = new TableCell(paragraph) { TextAlignment = TextAlignment.Center, BorderBrush = util.Str2Brush("#000000"), BorderThickness = new Thickness(0, 0, 2, 2), Padding = new Thickness(3, 3, 3, 3), Foreground = util.Str2Brush("#000000"), FontSize = 14.0d, LineHeight = 20.0d }; tblrow.Cells.Add(tblcell); run = new Run(_amt.natione); paragraph = new Paragraph(run); tblcell = new TableCell(paragraph) { TextAlignment = TextAlignment.Center, BorderBrush = util.Str2Brush("#000000"), BorderThickness = new Thickness(0, 0, 2, 2), Padding = new Thickness(3, 3, 3, 3), Foreground = util.Str2Brush("#000000"), FontSize = 14.0d, LineHeight = 20.0d }; tblrow.Cells.Add(tblcell); Brush _background = util.Str2Brush("#EEEEEE"); if (evenchk % 2 == 0) { _background = util.Str2Brush("#FFFFFF"); } rowgroup = new TableRowGroup() { Background = _background }; rowgroup.Rows.Add(tblrow); tbl2.RowGroups.Add(rowgroup); evenchk++; if (_amt.domestictype == "EXT") { // inner call _innercall.count++; _innercall.usedtime += ts.TotalSeconds; _innercall.rate = 0; } else if (_amt.domestictype == "O") { // outer call _outercall.count++; _outercall.usedtime += ts.TotalSeconds; _outercall.rate += _amt.fee; } else if (_amt.domestictype == "M") { // cellphone call _cellphonecall.count++; _cellphonecall.usedtime += ts.TotalSeconds; _cellphonecall.rate += _amt.fee; } else { if (string.IsNullOrEmpty(_amt.domestictype)) { // Internationalcall _internationalcall.count++; _internationalcall.usedtime += ts.TotalSeconds; _internationalcall.rate += _amt.fee; } } } flowDoc.Blocks.Add(tbl2); // create 1st table Table tbl1 = new Table() { Padding = new Thickness(0, 0, 0, 0), CellSpacing = 0.0d, Margin = new Thickness(10, 10, 0, 0) }; tbl1.Columns.Add(new TableColumn() { Width = new GridLength(130) }); tbl1.Columns.Add(new TableColumn() { Width = new GridLength(80) }); tbl1.Columns.Add(new TableColumn() { Width = new GridLength(230) }); tbl1.Columns.Add(new TableColumn() { Width = new GridLength(230) }); // 1st row tblrow = new TableRow(); // 1st column cell run = new Run(""); paragraph = new Paragraph(run); tblcell = new TableCell(paragraph) { TextAlignment = TextAlignment.Center, BorderBrush = util.Str2Brush("#000000"), BorderThickness = new Thickness(2, 2, 2, 2), Padding = new Thickness(3, 3, 3, 3), Foreground = util.Str2Brush("#000000"), FontSize = 16.0d, LineHeight = 20.0d }; tblrow.Cells.Add(tblcell); // 2nd column cell run = new Run("Count"); paragraph = new Paragraph(run); tblcell = new TableCell(paragraph) { TextAlignment = TextAlignment.Center, BorderBrush = util.Str2Brush("#000000"), BorderThickness = new Thickness(0, 2, 2, 2), Padding = new Thickness(3, 3, 3, 3), Foreground = util.Str2Brush("#000000"), FontSize = 16.0d, LineHeight = 20.0d }; tblrow.Cells.Add(tblcell); // 3rd column cell run = new Run("Used Time"); paragraph = new Paragraph(run); tblcell = new TableCell(paragraph) { TextAlignment = TextAlignment.Center, BorderBrush = util.Str2Brush("#000000"), BorderThickness = new Thickness(0, 2, 2, 2), Padding = new Thickness(3, 3, 3, 3), Foreground = util.Str2Brush("#000000"), FontSize = 16.0d, LineHeight = 20.0d }; tblrow.Cells.Add(tblcell); // 4th column cell run = new Run("Rate"); paragraph = new Paragraph(run); tblcell = new TableCell(paragraph) { TextAlignment = TextAlignment.Center, BorderBrush = util.Str2Brush("#000000"), BorderThickness = new Thickness(0, 2, 2, 2), Padding = new Thickness(3, 3, 3, 3), Foreground = util.Str2Brush("#000000"), FontSize = 16.0d, LineHeight = 20.0d }; tblrow.Cells.Add(tblcell); rowgroup = new TableRowGroup() { Background = util.Str2Brush("#CCCCCC") }; rowgroup.Rows.Add(tblrow); tbl1.RowGroups.Add(rowgroup); // 2nd row // 1st column cell tblrow = new TableRow(); run = new Run("Inner"); paragraph = new Paragraph(run); tblcell = new TableCell(paragraph) { TextAlignment = TextAlignment.Center, BorderBrush = util.Str2Brush("#000000"), BorderThickness = new Thickness(2, 0, 2, 2), Padding = new Thickness(3, 3, 3, 3), Foreground = util.Str2Brush("#000000"), FontSize = 14.0d, LineHeight = 20.0d }; tblrow.Cells.Add(tblcell); // 2nd column cell run = new Run(_innercall.count.ToString()); paragraph = new Paragraph(run); tblcell = new TableCell(paragraph) { TextAlignment = TextAlignment.Center, BorderBrush = util.Str2Brush("#000000"), BorderThickness = new Thickness(0, 0, 2, 2), Padding = new Thickness(3, 3, 3, 3), Foreground = util.Str2Brush("#000000"), FontSize = 14.0d, LineHeight = 20.0d }; tblrow.Cells.Add(tblcell); // 3rd column cell run = new Run(_innercall.usedtime.ToString()); paragraph = new Paragraph(run); tblcell = new TableCell(paragraph) { TextAlignment = TextAlignment.Center, BorderBrush = util.Str2Brush("#000000"), BorderThickness = new Thickness(0, 0, 2, 2), Padding = new Thickness(3, 3, 3, 3), Foreground = util.Str2Brush("#000000"), FontSize = 14.0d, LineHeight = 20.0d }; tblrow.Cells.Add(tblcell); // 4th column cell run = new Run(_innercall.rate.ToString()); paragraph = new Paragraph(run); tblcell = new TableCell(paragraph) { TextAlignment = TextAlignment.Center, BorderBrush = util.Str2Brush("#000000"), BorderThickness = new Thickness(0, 0, 2, 2), Padding = new Thickness(3, 3, 3, 3), Foreground = util.Str2Brush("#000000"), FontSize = 14.0d, LineHeight = 20.0d }; tblrow.Cells.Add(tblcell); rowgroup = new TableRowGroup() { Background = util.Str2Brush("#FFFFFF") }; rowgroup.Rows.Add(tblrow); tbl1.RowGroups.Add(rowgroup); // 3rd row // 1st column cell tblrow = new TableRow(); run = new Run("Outer"); paragraph = new Paragraph(run); tblcell = new TableCell(paragraph) { TextAlignment = TextAlignment.Center, BorderBrush = util.Str2Brush("#000000"), BorderThickness = new Thickness(2, 0, 2, 2), Padding = new Thickness(3, 3, 3, 3), Foreground = util.Str2Brush("#000000"), FontSize = 14.0d, LineHeight = 20.0d }; tblrow.Cells.Add(tblcell); // 2nd column cell run = new Run(_outercall.count.ToString()); paragraph = new Paragraph(run); tblcell = new TableCell(paragraph) { TextAlignment = TextAlignment.Center, BorderBrush = util.Str2Brush("#000000"), BorderThickness = new Thickness(0, 0, 2, 2), Padding = new Thickness(3, 3, 3, 3), Foreground = util.Str2Brush("#000000"), FontSize = 14.0d, LineHeight = 20.0d }; tblrow.Cells.Add(tblcell); // 3rd column cell run = new Run(_outercall.usedtime.ToString()); paragraph = new Paragraph(run); tblcell = new TableCell(paragraph) { TextAlignment = TextAlignment.Center, BorderBrush = util.Str2Brush("#000000"), BorderThickness = new Thickness(0, 0, 2, 2), Padding = new Thickness(3, 3, 3, 3), Foreground = util.Str2Brush("#000000"), FontSize = 14.0d, LineHeight = 20.0d }; tblrow.Cells.Add(tblcell); // 4th column cell run = new Run(_outercall.rate.ToString()); paragraph = new Paragraph(run); tblcell = new TableCell(paragraph) { TextAlignment = TextAlignment.Center, BorderBrush = util.Str2Brush("#000000"), BorderThickness = new Thickness(0, 0, 2, 2), Padding = new Thickness(3, 3, 3, 3), Foreground = util.Str2Brush("#000000"), FontSize = 14.0d, LineHeight = 20.0d }; tblrow.Cells.Add(tblcell); rowgroup = new TableRowGroup() { Background = util.Str2Brush("#EEEEEE") }; rowgroup.Rows.Add(tblrow); tbl1.RowGroups.Add(rowgroup); // 4th row // 1st column cell tblrow = new TableRow(); run = new Run("Cell Phone"); paragraph = new Paragraph(run); tblcell = new TableCell(paragraph) { TextAlignment = TextAlignment.Center, BorderBrush = util.Str2Brush("#000000"), BorderThickness = new Thickness(2, 0, 2, 2), Padding = new Thickness(3, 3, 3, 3), Foreground = util.Str2Brush("#000000"), FontSize = 14.0d, LineHeight = 20.0d }; tblrow.Cells.Add(tblcell); // 2nd column cell run = new Run(_cellphonecall.count.ToString()); paragraph = new Paragraph(run); tblcell = new TableCell(paragraph) { TextAlignment = TextAlignment.Center, BorderBrush = util.Str2Brush("#000000"), BorderThickness = new Thickness(0, 0, 2, 2), Padding = new Thickness(3, 3, 3, 3), Foreground = util.Str2Brush("#000000"), FontSize = 14.0d, LineHeight = 20.0d }; tblrow.Cells.Add(tblcell); // 3rd column cell run = new Run(_cellphonecall.usedtime.ToString()); paragraph = new Paragraph(run); tblcell = new TableCell(paragraph) { TextAlignment = TextAlignment.Center, BorderBrush = util.Str2Brush("#000000"), BorderThickness = new Thickness(0, 0, 2, 2), Padding = new Thickness(3, 3, 3, 3), Foreground = util.Str2Brush("#000000"), FontSize = 14.0d, LineHeight = 20.0d }; tblrow.Cells.Add(tblcell); // 4th column cell run = new Run(_cellphonecall.rate.ToString()); paragraph = new Paragraph(run); tblcell = new TableCell(paragraph) { TextAlignment = TextAlignment.Center, BorderBrush = util.Str2Brush("#000000"), BorderThickness = new Thickness(0, 0, 2, 2), Padding = new Thickness(3, 3, 3, 3), Foreground = util.Str2Brush("#000000"), FontSize = 14.0d, LineHeight = 20.0d }; tblrow.Cells.Add(tblcell); rowgroup = new TableRowGroup() { Background = util.Str2Brush("#FFFFFF") }; rowgroup.Rows.Add(tblrow); tbl1.RowGroups.Add(rowgroup); // 5th row // 1st column cell tblrow = new TableRow(); run = new Run("International"); paragraph = new Paragraph(run); tblcell = new TableCell(paragraph) { TextAlignment = TextAlignment.Center, BorderBrush = util.Str2Brush("#000000"), BorderThickness = new Thickness(2, 0, 2, 2), Padding = new Thickness(3, 3, 3, 3), Foreground = util.Str2Brush("#000000"), FontSize = 14.0d, LineHeight = 20.0d }; tblrow.Cells.Add(tblcell); // 2nd column cell run = new Run(_internationalcall.count.ToString()); paragraph = new Paragraph(run); tblcell = new TableCell(paragraph) { TextAlignment = TextAlignment.Center, BorderBrush = util.Str2Brush("#000000"), BorderThickness = new Thickness(0, 0, 2, 2), Padding = new Thickness(3, 3, 3, 3), Foreground = util.Str2Brush("#000000"), FontSize = 14.0d, LineHeight = 20.0d }; tblrow.Cells.Add(tblcell); // 3rd column cell run = new Run(_internationalcall.usedtime.ToString()); paragraph = new Paragraph(run); tblcell = new TableCell(paragraph) { TextAlignment = TextAlignment.Center, BorderBrush = util.Str2Brush("#000000"), BorderThickness = new Thickness(0, 0, 2, 2), Padding = new Thickness(3, 3, 3, 3), Foreground = util.Str2Brush("#000000"), FontSize = 14.0d, LineHeight = 20.0d }; tblrow.Cells.Add(tblcell); // 4th column cell run = new Run(_internationalcall.rate.ToString()); paragraph = new Paragraph(run); tblcell = new TableCell(paragraph) { TextAlignment = TextAlignment.Center, BorderBrush = util.Str2Brush("#000000"), BorderThickness = new Thickness(0, 0, 2, 2), Padding = new Thickness(3, 3, 3, 3), Foreground = util.Str2Brush("#000000"), FontSize = 14.0d, LineHeight = 20.0d }; tblrow.Cells.Add(tblcell); rowgroup = new TableRowGroup() { Background = util.Str2Brush("#EEEEEE") }; rowgroup.Rows.Add(tblrow); tbl1.RowGroups.Add(rowgroup); // 6th row // 1st column cell _totalcall.count = _innercall.count + _outercall.count + _cellphonecall.count + _internationalcall.count; _totalcall.usedtime = _innercall.usedtime + _outercall.usedtime + _cellphonecall.usedtime + _internationalcall.usedtime; _totalcall.rate = _innercall.rate + _outercall.rate + _cellphonecall.rate + _internationalcall.rate; tblrow = new TableRow(); run = new Run("Total"); paragraph = new Paragraph(run); tblcell = new TableCell(paragraph) { TextAlignment = TextAlignment.Center, BorderBrush = util.Str2Brush("#000000"), BorderThickness = new Thickness(2, 0, 2, 2), Padding = new Thickness(3, 3, 3, 3), Foreground = util.Str2Brush("#000000"), FontSize = 14.0d, LineHeight = 20.0d }; tblrow.Cells.Add(tblcell); // 2nd column cell run = new Run(_totalcall.count.ToString()); paragraph = new Paragraph(run); tblcell = new TableCell(paragraph) { TextAlignment = TextAlignment.Center, BorderBrush = util.Str2Brush("#000000"), BorderThickness = new Thickness(0, 0, 2, 2), Padding = new Thickness(3, 3, 3, 3), Foreground = util.Str2Brush("#000000"), FontSize = 14.0d, LineHeight = 20.0d }; tblrow.Cells.Add(tblcell); // 3rd column cell run = new Run(_totalcall.usedtime.ToString()); paragraph = new Paragraph(run); tblcell = new TableCell(paragraph) { TextAlignment = TextAlignment.Center, BorderBrush = util.Str2Brush("#000000"), BorderThickness = new Thickness(0, 0, 2, 2), Padding = new Thickness(3, 3, 3, 3), Foreground = util.Str2Brush("#000000"), FontSize = 14.0d, LineHeight = 20.0d }; tblrow.Cells.Add(tblcell); // 4th column cell run = new Run(_totalcall.rate.ToString()); paragraph = new Paragraph(run); tblcell = new TableCell(paragraph) { TextAlignment = TextAlignment.Center, BorderBrush = util.Str2Brush("#000000"), BorderThickness = new Thickness(0, 0, 2, 2), Padding = new Thickness(3, 3, 3, 3), Foreground = util.Str2Brush("#000000"), FontSize = 14.0d, LineHeight = 20.0d }; tblrow.Cells.Add(tblcell); rowgroup = new TableRowGroup() { Background = util.Str2Brush("#CCCCCC") }; rowgroup.Rows.Add(tblrow); tbl1.RowGroups.Add(rowgroup); flowDoc.Blocks.InsertBefore(tbl2, tbl1); }
private void cmdSave2Excel_Executed(object sender, ExecutedRoutedEventArgs e) { if (dt == null) return; System.Windows.Forms.SaveFileDialog saveDialog = new System.Windows.Forms.SaveFileDialog(); saveDialog.Filter = "Excel files (*.xls)|*.xls"; if (saveDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { DataSet _ds = new DataSet(); DataTable TOTAL = new DataTable(); TOTAL.TableName = "TOTAL"; TOTAL.Columns.Add("GUBUN", typeof(string)); TOTAL.Columns.Add("COUNT", typeof(string)); TOTAL.Columns.Add("USEDTIME", typeof(string)); TOTAL.Columns.Add("RATE", typeof(string)); DataTable DETAIL = new DataTable(); DETAIL.TableName = "DETAIL"; DETAIL.Columns.Add("Seq", typeof(string)); DETAIL.Columns.Add("Caller", typeof(string)); DETAIL.Columns.Add("Callee", typeof(string)); DETAIL.Columns.Add("Start Date", typeof(string)); DETAIL.Columns.Add("End Date", typeof(string)); DETAIL.Columns.Add("Used Time", typeof(string)); DETAIL.Columns.Add("Result", typeof(string)); DETAIL.Columns.Add("Rate", typeof(string)); DETAIL.Columns.Add("Etc", typeof(string)); DETAIL.Rows.Add("Seq", "Caller", "Callee", "Start Date", "End Date", "Used Time", "Result", "Rate", "Etc"); TOTALCALL _innercall = new TOTALCALL(); TOTALCALL _outercall = new TOTALCALL(); TOTALCALL _cellphonecall = new TOTALCALL(); TOTALCALL _internationalcall = new TOTALCALL(); TOTALCALL _totalcall = new TOTALCALL(); foreach (DataRow row in dt.Rows) { DateTime _sdate = DateTime.Parse(row[3].ToString()); DateTime _edate = DateTime.Parse(row[4].ToString()); TimeSpan ts = _edate - _sdate; AMOUNTINFO _amt = this.GetAmounts(row, ts); if (_amt.domestictype == "EXT") { // inner call _innercall.count++; _innercall.usedtime += ts.TotalSeconds; _innercall.rate = 0; } else if (_amt.domestictype == "O") { // outer call _outercall.count++; _outercall.usedtime += ts.TotalSeconds; _outercall.rate += _amt.fee; } else if (_amt.domestictype == "M") { // cellphone call _cellphonecall.count++; _cellphonecall.usedtime += ts.TotalSeconds; _cellphonecall.rate += _amt.fee; } else { if (string.IsNullOrEmpty(_amt.domestictype)) { // Internationalcall _internationalcall.count++; _internationalcall.usedtime += ts.TotalSeconds; _internationalcall.rate += _amt.fee; } } DETAIL.Rows.Add( row[0].ToString() , row[1].ToString() , row[2].ToString() , _sdate.ToString("MM-dd-yyyy HH:mm:ss") , _edate.ToString("MM-dd-yyyy HH:mm:ss") , ts.TotalSeconds.ToString() , row[5].ToString() , _amt.fee.ToString() , _amt.natione ); } TOTAL.Rows.Add("", "Count", "UsedTime", "Rate"); TOTAL.Rows.Add("Inner", _innercall.count.ToString(), _innercall.usedtime.ToString(), _innercall.rate.ToString()); TOTAL.Rows.Add("Outer", _outercall.count.ToString(), _outercall.usedtime.ToString(), _outercall.rate.ToString()); TOTAL.Rows.Add("Cell Phone", _cellphonecall.count.ToString(), _cellphonecall.usedtime.ToString(), _cellphonecall.rate.ToString()); TOTAL.Rows.Add("International", _internationalcall.count.ToString(), _internationalcall.usedtime.ToString(), _internationalcall.rate.ToString()); TOTAL.Rows.Add("Total" , (_innercall.count + _outercall.count + _cellphonecall.count + _internationalcall.count).ToString() , (_innercall.usedtime + _outercall.usedtime + _cellphonecall.usedtime + _internationalcall.usedtime).ToString() , (_innercall.rate + _outercall.rate + _cellphonecall.rate + _internationalcall.rate).ToString() ); _ds.Tables.Add(TOTAL); _ds.Tables.Add(DETAIL); //ExcelHelper.SaveExcelDB(saveDialog.FileName, _ds, true); CodentQ.excelconnect excel = new CodentQ.excelconnect(); excel.saveexcel(_ds, saveDialog.FileName); } // ExcelHelper.SaveExcelDB("d:\\111.xlsx", ds); }