コード例 #1
0
        public void Print()
        {
            try
            {
                PrintSettingController psc = new PrintSettingController(chartControl1);
                //页眉
                psc.PrintCompany = MainForm.Company;
                MainMenu mm = MainForm.AllMainMenuList.FirstOrDefault(o =>
                                                                      o.Name == MainMenuEnum.AnnualSalesSummaryByCustomerReport.ToString());
                if (mm != null)
                {
                    psc.PrintHeader = mm.Caption;
                }
                psc.PrintSubTitle = MainForm.Contacts.Replace("\\r\\n", "\r\n");
                //页脚
                //psc.PrintRightFooter = "打印日期:" + DateTime.Now.ToString();

                psc.IsBill = false;

                //横纵向
                //psc.LandScape = this.rbtnHorizon.Checked;
                psc.LandScape = true;
                //纸型
                psc.PaperKind = System.Drawing.Printing.PaperKind.A4;
                //加载页面设置信息
                psc.LoadPageSetting();

                psc.Preview();
            }
            catch (Exception ex)
            {
                CommonServices.ErrorTrace.SetErrorInfo(this.FindForm(), "没有可打印的数据。\r\n错误信息:" + ex.Message);
            }
            finally
            {
                this.Cursor = System.Windows.Forms.Cursors.Default;
            }
        }
コード例 #2
0
ファイル: AttWageBillPage.cs プロジェクト: xubinlee/WMS
        public void Print()
        {
            try
            {
                this.Cursor = System.Windows.Forms.Cursors.WaitCursor;
                foreach (DevExpress.XtraGrid.Columns.GridColumn col in ((GridView)gridControl.MainView).Columns)
                {
                    if (col == colCheckItem)
                    {
                        col.Visible = false;
                    }
                }
                PrintSettingController psc = new PrintSettingController(this.gridControl);

                //页眉
                if (hd != null)
                {
                    psc.PrintCompany    = MainForm.Company;
                    psc.PrintHeader     = "工资结算单";
                    psc.PrintSubTitle   = MainForm.Contacts.Replace("\\r\\n", "\r\n");
                    psc.PrintLeftHeader = "工资单号:" + hd.BillNo + "\r\n"
                                          + "工资年月:" + deYearMonth.Text;
                    psc.PrintRightHeader = "结算日期:" + deBillDate.Text;// +"\r\n"
                    //+ "联系人:" + txtContacts.EditValue;
                    //if (!string.IsNullOrEmpty(meRemark.Text))
                    //    psc.PrintRightHeader = "备注:" + meRemark.Text;

                    //页脚
                    psc.PrintLeftFooter = "制单人:" + lueMaker.Text + "  制单日期:" + deMakeDate.Text + "\r\n"
                                          + "审核人:" + lueAuditor.Text + "  审核日期:" + deAuditDate.Text;;
                    //psc.PrintFooter = "审核人:" + lueAuditor.Text + "  审核日期:" + deAuditDate.Text;

                    //获取明细列表界面数据(筛选后数据)
                    List <USPAttWageBillDtl> rDtl = new List <USPAttWageBillDtl>();
                    for (int i = 0; i < gridView.RowCount; i++)
                    {
                        if (gridView.GetRow(i) != null && Convert.ToBoolean(gridView.GetRowCellValue(i, colCheckItem)))
                        {
                            rDtl.Add((USPAttWageBillDtl)gridView.GetRow(i));
                        }
                    }
                    //金额转大写
                    //gridView.Columns["YearMonth"].Summary.Clear();
                    //gridView.Columns["YearMonth"].Summary.AddRange(new DevExpress.XtraGrid.GridSummaryItem[] {
                    //        new DevExpress.XtraGrid.GridColumnSummaryItem(DevExpress.Data.SummaryItemType.Sum, "金额", "合计金额:"+Rexlib.MoneyToUpper(rDtl.Sum(o=>o.AMT.Value)))});
                }
                //横纵向
                //psc.LandScape = this.rbtnHorizon.Checked;
                psc.LandScape = MainForm.IsLandScape;

                //纸型
                psc.PaperKind = MainForm.PrintPaperKind;
                psc.PaperSize = MainForm.PaperSize;
                //psc.PaperKind = System.Drawing.Printing.PaperKind.Custom;
                //psc.PaperSize.Width = 216;
                //psc.PaperSize.Height = 140;
                //psc.PaperSize = new System.Drawing.Size(216, 140);
                //加载页面设置信息
                psc.LoadPageSetting();

                psc.Preview();
            }
            catch (Exception ex)
            {
                CommonServices.ErrorTrace.SetErrorInfo(this.FindForm(), "没有可打印的数据。\r\n错误信息:" + ex.Message);
            }
            finally
            {
                foreach (DevExpress.XtraGrid.Columns.GridColumn col in ((GridView)gridControl.MainView).Columns)
                {
                    if (col == colCheckItem)
                    {
                        col.Visible = true;
                    }
                }
                this.Cursor = System.Windows.Forms.Cursors.Default;
            }
        }