private void btnprint_Click(object sender, EventArgs e) { try{ PrintDialog pDialog = new PrintDialog(); pDialog.AllowSelection = true; pDialog.AllowSomePages = true; pDialog.AllowCurrentPage = true; Printing.pds = new System.Drawing.Printing.PrintDocument(); if (pDialog.ShowDialog() == DialogResult.OK) { Printing.pds.PrinterSettings = pDialog.PrinterSettings; for (int i = 0; i < tabControl1.TabPages.Count; i++) { if (pDialog.PrinterSettings.ToPage > 0) { if (i > pDialog.PrinterSettings.ToPage - 1 || i < pDialog.PrinterSettings.FromPage - 1) { continue; } } userSummary u = (userSummary)tabControl1.TabPages[i].Controls[0]; Printing._sourceFile = u.pictureBox1.ImageLocation; Printing.Print(); } } } catch (Exception ex) { } }
private void button1_Click(object sender, EventArgs e) { PrintDialog pDialog = new PrintDialog(); pDialog.AllowSelection = true; pDialog.AllowSomePages = true; pDialog.AllowCurrentPage = true; Printing.pds = new System.Drawing.Printing.PrintDocument(); if (pDialog.ShowDialog() == DialogResult.OK) { Printing.pds.PrinterSettings = pDialog.PrinterSettings; for (int i = 0; i < tabControl1.TabPages.Count; i++) { if (pDialog.PrinterSettings.ToPage > 0) { if (i > pDialog.PrinterSettings.ToPage - 1 || i < pDialog.PrinterSettings.FromPage - 1) { continue; } } userSummary u = (userSummary)tabControl1.TabPages[i].Controls[0]; //tabControl1.TabPages[i].Controls.Clear(); //u.Dispose(); Printing._sourceFile = u.pictureBox1.ImageLocation; Printing.Print(); ////userSummary.s = Printing._sourceFile; //userSummary u1 = new userSummary(); //tabControl1.TabPages[i].Controls.Add(u1); } } }
private void printsumarysheet_FormClosing(object sender, FormClosingEventArgs e) { for (int i = 0; i < tabControl1.TabPages.Count; i++) { userSummary u = (userSummary)tabControl1.TabPages[i].Controls[0]; // u.pictureBox1.Image = null; u.Dispose(); tabControl1.TabPages[i].Controls.Clear(); } tabControl1.TabPages.Clear(); base.Dispose(); }
private void btnlaod_Click(object sender, EventArgs e) { try{ tabControl1.TabPages.Clear(); DataSet ds = new DataSet(); ds = majordal.getsubject(txtmno.Text); System.Drawing.Font f = new System.Drawing.Font("Times New Roman", 14F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Regular))), System.Drawing.GraphicsUnit.Point, ((byte)(0))); System.Drawing.Font bullf = new System.Drawing.Font("Times New Roman", 26F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Regular))), System.Drawing.GraphicsUnit.Point, ((byte)(0))); Image img1 = createBlank(); Graphics g = null; g = Graphics.FromImage(img1); string path = Application.StartupPath + "\\Description\\"; path = path.Replace("\\bin\\Debug", ""); int K = 85; int rowht = 32; int rowstart = 312; int temp = 0; string billno = txtmno.Text; string plantno = ""; string billdate = ""; string billamount = ""; int amtflag = 0; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { if (temp % 19 == 0 && i != 0) { try { plantno = Convert.ToString(majordal.getPlantNo(txtmno.Text).Tables[0].Rows[0][0]); DataSet b = majordal.getbill(txtmno.Text); //billdate=Convert.ToString(b.Tables[0].Rows[0][1]).Replace("/","."); //billamount = Convert.ToString(b.Tables[0].Rows[0][2]); //billamount = amounInWord.mk_Currancy(billamount); } catch (Exception) { } g.DrawString(plantno, f, Brushes.Black, new PointF(200, 155)); g.DrawString(billno, f, Brushes.Black, new PointF(200, 187)); //g.DrawString(billdate, f, Brushes.Black, new PointF(200, 219)); if (amtflag == 0) { // g.DrawString(billamount, f, Brushes.Black, new PointF(200, 252)); amtflag = 1; g.DrawString("Continue..", f, Brushes.Black, new PointF(350, 1030)); } else { g.DrawString("Continue..", f, Brushes.Black, new PointF(350, 1030)); } img1.Save(path + (tabControl1.TabPages.Count + 1) + ".jpg"); userSummary.s = path + (tabControl1.TabPages.Count + 1) + ".jpg"; userSummary u1 = new userSummary(); u1.pictureBox1.ImageLocation = path + (tabControl1.TabPages.Count + 1) + ".jpg"; u1.pictureBox1.Image = Image.FromFile(path + (tabControl1.TabPages.Count + 1) + ".jpg"); tabControl1.TabPages.Add("Page" + (tabControl1.TabPages.Count + 1)); tabControl1.TabPages[tabControl1.TabPages.Count - 1].Controls.Add(u1); img1 = createBlank(); g = Graphics.FromImage(img1); temp = 0; } if (i == ds.Tables[0].Rows.Count - 1) { try { plantno = Convert.ToString(majordal.getPlantNo(txtmno.Text).Tables[0].Rows[0][0]); DataSet b = majordal.getbill(txtmno.Text); // billdate = Convert.ToString(b.Tables[0].Rows[0][1]).Replace("/", "."); //billamount = Convert.ToString(b.Tables[0].Rows[0][2]); //billamount = amounInWord.mk_Currancy(billamount); } catch (Exception) { } g.DrawString(plantno, f, Brushes.Black, new PointF(200, 155)); g.DrawString(billno, f, Brushes.Black, new PointF(200, 187)); //g.DrawString(billdate, f, Brushes.Black, new PointF(200, 219)); if (amtflag == 0) { //g.DrawString(billamount, f, Brushes.Black, new PointF(200, 252)); amtflag = 1; } string[] Final = breaklines(Convert.ToString(ds.Tables[0].Rows[i][0]), f, 620, g); g.DrawString("*", bullf, Brushes.Black, new PointF(75, rowstart - 3 + (temp * 32))); for (int l = 0; l < Final.Length; l++) { g.DrawString(Final[l], f, Brushes.Black, new PointF(100, rowstart + (temp * 32))); temp++; } img1.Save(path + (tabControl1.TabPages.Count + 1) + ".jpg"); userSummary.s = path + (tabControl1.TabPages.Count + 1) + ".jpg"; userSummary u1 = new userSummary(); u1.pictureBox1.ImageLocation = path + (tabControl1.TabPages.Count + 1) + ".jpg"; u1.pictureBox1.Image = Image.FromFile(path + (tabControl1.TabPages.Count + 1) + ".jpg"); tabControl1.TabPages.Add("Page" + (tabControl1.TabPages.Count + 1)); tabControl1.TabPages[tabControl1.TabPages.Count - 1].Controls.Add(u1); } string[] Final1 = breaklines(Convert.ToString(ds.Tables[0].Rows[i][0]), f, 620, g); g.DrawString("*", bullf, Brushes.Black, new PointF(75, rowstart - 3 + (temp * 32))); for (int l = 0; l < Final1.Length; l++) { g.DrawString(Final1[l], f, Brushes.Black, new PointF(100, rowstart + (temp * 32))); temp++; } } } catch (Exception ex) { } }