Exemple #1
0
 //打印当前页
 private void toolStripButton3_Click(object sender, EventArgs e)
 {
     try
     {
         if (this.dataGridView1.Rows.Count == 0)
         {
             MessageBoxHelper.Show("没有可打印的数据!");
         }
         else
         {
             DataTable dt = this.GetTableFromGrid();
             DataTablePrinterContent.Print(dt, this.GetDataGridViewWidth(), this.GetExportTitle());
         }
     }
     catch (Exception ex)
     {
         MessageBoxHelper.ShowPrinter("错误信息:" + ex.Message);
     }
 }
 private void btnPrint_Click(object sender, EventArgs e)
 {
     if (this.dataGridView1.Rows.Count > 0)
     {
         DataTable dt = this.GetTableFromGrid();
         try
         {
             DataTablePrinterContent.Print(dt, this.GetDataGridViewWidth(), this.GetTitle());
         }
         catch (Exception ex)
         {
             MessageBoxHelper.Show(ex.Message);
         }
     }
     else
     {
         MessageBoxHelper.Show("没有可打印的数据!");
     }
 }
Exemple #3
0
 /// <summary>
 /// 打印事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void toolStripButton2_Click(object sender, EventArgs e)
 {
     try
     {
         if (pager.Lists.Count == 0)
         {
             MessageBoxHelper.Show("没有可打印的数据!");
         }
         else
         {
             string printfield = this.GetPrintField();
             int[]  widths     = this.GetPrintWidths();
             if (printfield == string.Empty)
             {
                 MessageBoxHelper.Show("还没有实现打印该列表功能!");
                 return;
             }
             else if (widths == null)
             {
                 MessageBoxHelper.Show("请设定要打印的列宽!");
                 return;
             }
             else
             {
                 DataTable dt = DataAccessFactory.GetDataAccess().SelectDataTable(
                     "select " + this.GetPrintField() + " from " + FT.DAL.Orm.SimpleOrmCache.GetTableName(this.entityType) + " " + pager.Condition, "test");
                 if (dt.Columns.Count >= widths.Length + 1)
                 {
                     DataTablePrinterContent.Print(dt, widths, this.GetExportTitle());
                 }
                 else
                 {
                     MessageBoxHelper.Show("设定打印的列宽+1超出了待打印的列数!");
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBoxHelper.ShowPrinter("错误信息:" + ex.Message);
     }
 }