Пример #1
0
 /// <summary>
 /// widths�����dt������һ�У����һ���Զ������
 /// </summary>
 /// <param name="dt"></param>
 /// <param name="widths"></param>
 /// <param name="title"></param>
 public static AbstractPrinterContent BuildAbstractPrinterContent(DataTable dt, int[] widths, string title, bool isPrintColName)
 {
     DataTablePrinterContent content = new DataTablePrinterContent(dt, widths);
     content.IsPrintColName = isPrintColName;
     content.HeaderTitle = title;
     return content;
 }
Пример #2
0
        /// <summary>
        /// widths必须比dt的列少一列,最后一列自动计算的
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="widths"></param>
        /// <param name="title"></param>
        public static AbstractPrinterContent BuildAbstractPrinterContent(DataTable dt, int[] widths, string title, bool isPrintColName)
        {
            DataTablePrinterContent content = new DataTablePrinterContent(dt, widths);

            content.IsPrintColName = isPrintColName;
            content.HeaderTitle    = title;
            return(content);
        }
Пример #3
0
 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("没有可打印的数据!");
     }
 }
Пример #4
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);
     }
 }
Пример #5
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);
     }
 }