private System.Drawing.Size GetPageSize(string xml) { Helper.ReadXml r = new Helper.ReadXml(xml); int w = Convert.ToInt16(r.Read("Page/Width")); int h = Convert.ToInt16(r.Read("Page/Height")); return(new System.Drawing.Size(w, h)); }
void IBLL.IPrint.Print(string style_id, string xml, System.Data.DataTable tbmain, System.Data.DataTable tbdetail) { try { this.style_id = style_id; this.xml = xml; this.tbmain = tbmain; this.tbdetail = tbdetail; row_count = this.tbdetail.Rows.Count; if (this.tbdetail.Columns.Contains("行号") == true) { this.tbdetail.Columns.Remove("行号"); this.tbdetail.Columns.Add("行号"); this.tbdetail.Columns["行号"].SetOrdinal(0); } else { this.tbdetail.Columns.Add("行号"); this.tbdetail.Columns["行号"].SetOrdinal(0); } // Helper.ReadXml r = new Helper.ReadXml(xml); barHeight = Convert.ToInt16(r.Read("Page/BarHeight")); pageWidth = Convert.ToInt16(r.Read("Page/Width")); pageHeight = Convert.ToInt16(r.Read("Page/Height")); ah = Convert.ToInt16(r.Read("Page/AHeight")); bh = Convert.ToInt16(r.Read("Page/BHeight")); ch = Convert.ToInt16(r.Read("Page/CHeight")); dh = Convert.ToInt16(r.Read("Page/DHeight")); eh = Convert.ToInt16(r.Read("Page/EHeight")); AppendEmptyRow = Convert.ToInt16(r.Read("Page/AppendEmptyRow")); rowHeight = ch; smallTotal = SmallTotal(xml); FontConverter fc = new FontConverter(); gridFont = (Font)fc.ConvertFromString(r.Read("Page/GridFont")); gridLeft = Convert.ToInt16(r.Read("Page/GridLeft")); // tbstyle = new DataTable(); tbstyle.Columns.Add("display"); tbstyle.Columns.Add("colname"); tbstyle.Columns.Add("colbyname"); tbstyle.Columns.Add("width", typeof(int)); tbstyle.Columns.Add("align"); tbstyle.Columns.Add("format"); tbstyle.Columns.Add("smalltotal"); // foreach (Helper.ReadXml r2 in r.ReadList("Page/Column")) { var row = tbstyle.NewRow(); tbstyle.Rows.Add(row); row["display"] = r2.Read("Display"); row["colname"] = r2.Read("ColName"); row["colbyname"] = r2.Read("ColByname"); row["width"] = Convert.ToInt16(r2.Read("Width")); row["align"] = r2.Read("Align"); row["format"] = r2.Read("Format"); row["SmallTotal"] = r2.Read("SmallTotal"); } // this.ShowDialog(); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } }
public void Print(string xml, DataTable tbmain, DataTable tbdetail) { this.xml = xml; this.tbmain = tbmain; this.tbdetail = tbdetail; row_count = tbdetail.Rows.Count; if (this.tbdetail.Columns.Contains("行号") == true) { this.tbdetail.Columns.Remove("行号"); this.tbdetail.Columns.Add("行号"); } else { this.tbdetail.Columns.Add("行号"); } PageCount = this.GetPageCount(xml); PageSize = this.GetPageSize(xml); // if (tbdetail != null) { int index = 0; foreach (DataRow row in tbdetail.Rows) { index++; row["行号"] = index; } } // Helper.ReadXml r = new Helper.ReadXml(xml); barHeight = Convert.ToInt16(r.Read("Page/BarHeight")); pageWidth = Convert.ToInt16(r.Read("Page/Width")); pageHeight = Convert.ToInt16(r.Read("Page/Height")); ah = Convert.ToInt16(r.Read("Page/AHeight")); bh = Convert.ToInt16(r.Read("Page/BHeight")); ch = Convert.ToInt16(r.Read("Page/CHeight")); dh = Convert.ToInt16(r.Read("Page/DHeight")); eh = Convert.ToInt16(r.Read("Page/EHeight")); AppendEmptyRow = Convert.ToInt16(r.Read("Page/AppendEmptyRow")); rowHeight = ch; smallTotal = SmallTotal(xml); FontConverter fc = new FontConverter(); gridFont = (Font)fc.ConvertFromString(r.Read("Page/GridFont")); gridLeft = Convert.ToInt16(r.Read("Page/GridLeft")); // tbstyle = new DataTable(); tbstyle.Columns.Add("display"); tbstyle.Columns.Add("colname"); tbstyle.Columns.Add("colbyname"); tbstyle.Columns.Add("width"); tbstyle.Columns.Add("align"); tbstyle.Columns.Add("format"); tbstyle.Columns.Add("smalltotal"); // foreach (Helper.ReadXml r2 in r.ReadList("Page/Column")) { var row = tbstyle.NewRow(); tbstyle.Rows.Add(row); row["display"] = r2.Read("Display"); row["colname"] = r2.Read("ColName"); row["colbyname"] = r2.Read("ColByname"); row["width"] = Convert.ToInt16(r2.Read("Width")); row["align"] = r2.Read("Align"); row["format"] = r2.Read("Format"); row["SmallTotal"] = r2.Read("SmallTotal"); } // // pd = new System.Drawing.Printing.PrintDocument(); pd.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("printPage", PageSize.Width, PageSize.Height); pd.PrintPage += this.pd_pagePrint; PageIndex = 1; pd.Print(); }