public int i;
public int k;
public int f;
public int s;
private void button4_Click(object sender, EventArgs e)
{
f = dataGridView1.Rows.Count - 1;
s = dataGridView2.Rows.Count - 1;
i = (f >= s) ? f : s;
k = 0;
while (k < i)
{
PrintDocument doc = new PrintDocument();
doc.PrintPage += new PrintPageEventHandler(doc_PrintPage);
PrintDialog dlgSettings = new PrintDialog();
dlgSettings.Document = doc;
doc.Print();
}
}
void doc_PrintPage(object sender, PrintPageEventArgs e)
{
try
{
Font font1 = new Font("Arial", 15);
Font font = new Font("Arial", 10);
Font font3 = new Font("Arial", 8);
Font font4 = new Font("Arial", 9);
Font font2 = new Font("Arial", 13);
//float x = e.MarginBounds.Left;
//float lineSide=font.
float y = e.MarginBounds.Top;
float lineHeight = font.GetHeight(e.Graphics);
//Header
e.Graphics.DrawString("JAI MATA DI", font3, Brushes.Black, float.Parse("132"), float.Parse("1"));
e.Graphics.DrawString("HARI SWEETS", font2, Brushes.Black, float.Parse("100"), float.Parse("15"));
e.Graphics.DrawString("Arya Samaj Road, Jacubpura,Gurgaon-122001(Hr.)", font3, Brushes.Black, float.Parse("45"), float.Parse("35"));
e.Graphics.DrawString("Ph. 2332108, 4063808", font3, Brushes.Black, float.Parse("105"), float.Parse("49"));
e.Graphics.DrawString("Name " + textBox7.Text, font3, Brushes.Black, float.Parse("20"), float.Parse("70"));
e.Graphics.DrawString("S.No. " + textBox18.Text, font3, Brushes.Black, float.Parse("160"), float.Parse("70"));
e.Graphics.DrawString("Month " + comboBox2.Text, font3, Brushes.Black, float.Parse("230"), float.Parse("70"));
e.Graphics.DrawString(" .................................. ......... ...................", font3, Brushes.Black, float.Parse("20"), float.Parse("73"));
//e.Graphics.DrawString(textBox7.Text, font1, Brushes.Black, float.Parse("50"), float.Parse("0"));
//y += lineHeight;
//e.Graphics.DrawString("Date:- " + dateTimePicker1.Value.ToString("dd-MM-yyyy") + " To " + dateTimePicker2.Value.ToString("dd-MM-yyyy"), font, Brushes.Black, float.Parse("550"), float.Parse("10"));
//y += lineHeight;
//e.Graphics.DrawString("Sell", font, Brushes.Black, float.Parse("100"), float.Parse("30"));
//y += lineHeight;
//e.Graphics.DrawString("PAYMENT ", font, Brushes.Black, float.Parse("500"), float.Parse("30"));
//y += lineHeight;
e.Graphics.DrawString("-----------------------------------------------------------------" +
"-", font, Brushes.Black, float.Parse("14"), float.Parse("80"));
int ij = 86;
while (ij < 120)
{
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("14"), float.Parse(ij.ToString()));
y += lineHeight;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("80"), float.Parse(ij.ToString()));
y += lineHeight;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("150"), float.Parse(ij.ToString()));
y += lineHeight;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("230"), float.Parse(ij.ToString()));
y += lineHeight;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("320"), float.Parse(ij.ToString()));
y += lineHeight;
ij = ij + 10;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("14"), float.Parse(ij.ToString()));
y += lineHeight;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("80"), float.Parse(ij.ToString()));
y += lineHeight;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("150"), float.Parse(ij.ToString()));
y += lineHeight;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("230"), float.Parse(ij.ToString()));
y += lineHeight;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("320"), float.Parse(ij.ToString()));
y += lineHeight;
ij = ij + 10;
}
y += lineHeight;
//Header
e.Graphics.DrawString("Date", font3, Brushes.Black, float.Parse("20"), float.Parse("92"));
y += lineHeight;
e.Graphics.DrawString("Morning", font3, Brushes.Black, float.Parse("100"), float.Parse("92"));
y += lineHeight;
e.Graphics.DrawString("Evening", font3, Brushes.Black, float.Parse("180"), float.Parse("92"));
y += lineHeight;
e.Graphics.DrawString("Amount", font3, Brushes.Black, float.Parse("260"), float.Parse("92"));
y += lineHeight;
//e.Graphics.DrawString("AMOUNT", font3, Brushes.Black, float.Parse("680"), float.Parse("90"));
//y += lineHeight;
//HERE I NEED TO PUT DATA GRID VIEW WHICH MAY VERY NUMBER OF ROWS EVERY TIME
//Body
e.Graphics.DrawString("------------------------------------------------------------------ ", font, Brushes.Black, float.Parse("15"), float.Parse("100"));
y += lineHeight;
int j = 115;
for (int l = k; l < i; l++)
{
if (l < f)
{
//e.Graphics.DrawString(dataGridView1.Rows[l].Cells[0].Value.ToString(), font, Brushes.Black, float.Parse("40"), float.Parse(j.ToString()));
//y += lineHeight;
//e.Graphics.DrawString(Convert.ToDateTime(dataGridView1.Rows[l].Cells[1].Value).ToString(), font, Brushes.Black, float.Parse("40"), float.Parse(j.ToString()));
//y += lineHeight;
//e.Graphics.DrawString(dataGridView1.Rows[l].Cells[2].Value.ToString(), font, Brushes.Black, float.Parse("360"), float.Parse(j.ToString()));
//y += lineHeight;
//e.Graphics.DrawString(dataGridView1.Rows[l].Cells[3].Value.ToString(), font, Brushes.Black, float.Parse("520"), float.Parse(j.ToString()));
//y += lineHeight;
//e.Graphics.DrawString(dataGridView1.Rows[l].Cells[4].Value.ToString(), font, Brushes.Black, float.Parse("680"), float.Parse(j.ToString()));
//y += lineHeight;
//e.Graphics.DrawString(dataGridView1.Rows[l].Cells[2].Value.ToString(), font, Brushes.Black, float.Parse("360"), float.Parse(j.ToString()));
//y += lineHeight;
}
if (l < s)
{
//e.Graphics.DrawString(dataGridView2.Rows[l].Cells[0].Value.ToString(), font, Brushes.Black, float.Parse("40"), float.Parse(j.ToString()));
//y += lineHeight;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("14"), float.Parse(j.ToString()));
y += lineHeight;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("80"), float.Parse(j.ToString()));
y += lineHeight;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("150"), float.Parse(j.ToString()));
y += lineHeight;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("230"), float.Parse(j.ToString()));
y += lineHeight;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("320"), float.Parse(j.ToString()));
y += lineHeight;
j = j + 10;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("14"), float.Parse(j.ToString()));
y += lineHeight;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("80"), float.Parse(j.ToString()));
y += lineHeight;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("150"), float.Parse(j.ToString()));
y += lineHeight;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("230"), float.Parse(j.ToString()));
y += lineHeight;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("320"), float.Parse(j.ToString()));
y += lineHeight;
j = j - 10;
e.Graphics.DrawString(Convert.ToDateTime(dataGridView2.Rows[l].Cells[1].Value).ToString("dd-MM-yy"), font4, Brushes.Black, float.Parse("20"), float.Parse(j.ToString()));
y += lineHeight;
e.Graphics.DrawString(dataGridView2.Rows[l].Cells[2].Value.ToString(), font4, Brushes.Black, float.Parse("100"), float.Parse(j.ToString()));
y += lineHeight;
e.Graphics.DrawString(dataGridView2.Rows[l].Cells[3].Value.ToString(), font4, Brushes.Black, float.Parse("180"), float.Parse(j.ToString()));
y += lineHeight;
e.Graphics.DrawString(dataGridView2.Rows[l].Cells[4].Value.ToString(), font4, Brushes.Black, float.Parse("260"), float.Parse(j.ToString()));
y += lineHeight;
}
j = j + 20;
k++;
if (j > 1140)
{
break;
}
}
j = j + 10;
e.Graphics.DrawString("------------------------------------------------------------------ ", font, Brushes.Black, float.Parse("15"), float.Parse(j.ToString()));
y += lineHeight;
j = j - 7;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("14"), float.Parse(j.ToString()));
y += lineHeight;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("80"), float.Parse(j.ToString()));
y += lineHeight;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("150"), float.Parse(j.ToString()));
y += lineHeight;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("230"), float.Parse(j.ToString()));
y += lineHeight;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("320"), float.Parse(j.ToString()));
y += lineHeight;
j = j + 7;
j = j + 15;
e.Graphics.DrawString("Total Quantity : " + textBox8.Text, font4, Brushes.Black, float.Parse("20"), float.Parse(j.ToString()));
y += lineHeight;
e.Graphics.DrawString("Current Amount : " + textBox9.Text, font4, Brushes.Black, float.Parse("160"), float.Parse(j.ToString()));
y += lineHeight;
j = j + 20;
e.Graphics.DrawString("Last Amount : " + textBox17.Text, font4, Brushes.Black, float.Parse("20"), float.Parse(j.ToString()));
y += lineHeight;
e.Graphics.DrawString("Total Amount : " + textBox16.Text, font4, Brushes.Black, float.Parse("160"), float.Parse(j.ToString()));
y += lineHeight;
//e.Graphics.DrawString(, font, Brushes.Black, float.Parse("510"), float.Parse(j.ToString()));
//y += lineHeight;
//j = j + 30;
//e.Graphics.DrawString("BALANCE :- " + label11.Text, font, Brushes.Black, float.Parse("280"), float.Parse(j.ToString()));
//y += lineHeight;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
public int k;
public int f;
public int s;
private void button4_Click(object sender, EventArgs e)
{
f = dataGridView1.Rows.Count - 1;
s = dataGridView2.Rows.Count - 1;
i = (f >= s) ? f : s;
k = 0;
while (k < i)
{
PrintDocument doc = new PrintDocument();
doc.PrintPage += new PrintPageEventHandler(doc_PrintPage);
PrintDialog dlgSettings = new PrintDialog();
dlgSettings.Document = doc;
doc.Print();
}
}
void doc_PrintPage(object sender, PrintPageEventArgs e)
{
try
{
Font font1 = new Font("Arial", 15);
Font font = new Font("Arial", 10);
Font font3 = new Font("Arial", 8);
Font font4 = new Font("Arial", 9);
Font font2 = new Font("Arial", 13);
//float x = e.MarginBounds.Left;
//float lineSide=font.
float y = e.MarginBounds.Top;
float lineHeight = font.GetHeight(e.Graphics);
//Header
e.Graphics.DrawString("JAI MATA DI", font3, Brushes.Black, float.Parse("132"), float.Parse("1"));
e.Graphics.DrawString("HARI SWEETS", font2, Brushes.Black, float.Parse("100"), float.Parse("15"));
e.Graphics.DrawString("Arya Samaj Road, Jacubpura,Gurgaon-122001(Hr.)", font3, Brushes.Black, float.Parse("45"), float.Parse("35"));
e.Graphics.DrawString("Ph. 2332108, 4063808", font3, Brushes.Black, float.Parse("105"), float.Parse("49"));
e.Graphics.DrawString("Name " + textBox7.Text, font3, Brushes.Black, float.Parse("20"), float.Parse("70"));
e.Graphics.DrawString("S.No. " + textBox18.Text, font3, Brushes.Black, float.Parse("160"), float.Parse("70"));
e.Graphics.DrawString("Month " + comboBox2.Text, font3, Brushes.Black, float.Parse("230"), float.Parse("70"));
e.Graphics.DrawString(" .................................. ......... ...................", font3, Brushes.Black, float.Parse("20"), float.Parse("73"));
//e.Graphics.DrawString(textBox7.Text, font1, Brushes.Black, float.Parse("50"), float.Parse("0"));
//y += lineHeight;
//e.Graphics.DrawString("Date:- " + dateTimePicker1.Value.ToString("dd-MM-yyyy") + " To " + dateTimePicker2.Value.ToString("dd-MM-yyyy"), font, Brushes.Black, float.Parse("550"), float.Parse("10"));
//y += lineHeight;
//e.Graphics.DrawString("Sell", font, Brushes.Black, float.Parse("100"), float.Parse("30"));
//y += lineHeight;
//e.Graphics.DrawString("PAYMENT ", font, Brushes.Black, float.Parse("500"), float.Parse("30"));
//y += lineHeight;
e.Graphics.DrawString("-----------------------------------------------------------------" +
"-", font, Brushes.Black, float.Parse("14"), float.Parse("80"));
int ij = 86;
while (ij < 120)
{
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("14"), float.Parse(ij.ToString()));
y += lineHeight;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("80"), float.Parse(ij.ToString()));
y += lineHeight;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("150"), float.Parse(ij.ToString()));
y += lineHeight;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("230"), float.Parse(ij.ToString()));
y += lineHeight;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("320"), float.Parse(ij.ToString()));
y += lineHeight;
ij = ij + 10;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("14"), float.Parse(ij.ToString()));
y += lineHeight;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("80"), float.Parse(ij.ToString()));
y += lineHeight;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("150"), float.Parse(ij.ToString()));
y += lineHeight;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("230"), float.Parse(ij.ToString()));
y += lineHeight;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("320"), float.Parse(ij.ToString()));
y += lineHeight;
ij = ij + 10;
}
y += lineHeight;
//Header
e.Graphics.DrawString("Date", font3, Brushes.Black, float.Parse("20"), float.Parse("92"));
y += lineHeight;
e.Graphics.DrawString("Morning", font3, Brushes.Black, float.Parse("100"), float.Parse("92"));
y += lineHeight;
e.Graphics.DrawString("Evening", font3, Brushes.Black, float.Parse("180"), float.Parse("92"));
y += lineHeight;
e.Graphics.DrawString("Amount", font3, Brushes.Black, float.Parse("260"), float.Parse("92"));
y += lineHeight;
//e.Graphics.DrawString("AMOUNT", font3, Brushes.Black, float.Parse("680"), float.Parse("90"));
//y += lineHeight;
//HERE I NEED TO PUT DATA GRID VIEW WHICH MAY VERY NUMBER OF ROWS EVERY TIME
//Body
e.Graphics.DrawString("------------------------------------------------------------------ ", font, Brushes.Black, float.Parse("15"), float.Parse("100"));
y += lineHeight;
int j = 115;
for (int l = k; l < i; l++)
{
if (l < f)
{
//e.Graphics.DrawString(dataGridView1.Rows[l].Cells[0].Value.ToString(), font, Brushes.Black, float.Parse("40"), float.Parse(j.ToString()));
//y += lineHeight;
//e.Graphics.DrawString(Convert.ToDateTime(dataGridView1.Rows[l].Cells[1].Value).ToString(), font, Brushes.Black, float.Parse("40"), float.Parse(j.ToString()));
//y += lineHeight;
//e.Graphics.DrawString(dataGridView1.Rows[l].Cells[2].Value.ToString(), font, Brushes.Black, float.Parse("360"), float.Parse(j.ToString()));
//y += lineHeight;
//e.Graphics.DrawString(dataGridView1.Rows[l].Cells[3].Value.ToString(), font, Brushes.Black, float.Parse("520"), float.Parse(j.ToString()));
//y += lineHeight;
//e.Graphics.DrawString(dataGridView1.Rows[l].Cells[4].Value.ToString(), font, Brushes.Black, float.Parse("680"), float.Parse(j.ToString()));
//y += lineHeight;
//e.Graphics.DrawString(dataGridView1.Rows[l].Cells[2].Value.ToString(), font, Brushes.Black, float.Parse("360"), float.Parse(j.ToString()));
//y += lineHeight;
}
if (l < s)
{
//e.Graphics.DrawString(dataGridView2.Rows[l].Cells[0].Value.ToString(), font, Brushes.Black, float.Parse("40"), float.Parse(j.ToString()));
//y += lineHeight;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("14"), float.Parse(j.ToString()));
y += lineHeight;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("80"), float.Parse(j.ToString()));
y += lineHeight;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("150"), float.Parse(j.ToString()));
y += lineHeight;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("230"), float.Parse(j.ToString()));
y += lineHeight;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("320"), float.Parse(j.ToString()));
y += lineHeight;
j = j + 10;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("14"), float.Parse(j.ToString()));
y += lineHeight;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("80"), float.Parse(j.ToString()));
y += lineHeight;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("150"), float.Parse(j.ToString()));
y += lineHeight;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("230"), float.Parse(j.ToString()));
y += lineHeight;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("320"), float.Parse(j.ToString()));
y += lineHeight;
j = j - 10;
e.Graphics.DrawString(Convert.ToDateTime(dataGridView2.Rows[l].Cells[1].Value).ToString("dd-MM-yy"), font4, Brushes.Black, float.Parse("20"), float.Parse(j.ToString()));
y += lineHeight;
e.Graphics.DrawString(dataGridView2.Rows[l].Cells[2].Value.ToString(), font4, Brushes.Black, float.Parse("100"), float.Parse(j.ToString()));
y += lineHeight;
e.Graphics.DrawString(dataGridView2.Rows[l].Cells[3].Value.ToString(), font4, Brushes.Black, float.Parse("180"), float.Parse(j.ToString()));
y += lineHeight;
e.Graphics.DrawString(dataGridView2.Rows[l].Cells[4].Value.ToString(), font4, Brushes.Black, float.Parse("260"), float.Parse(j.ToString()));
y += lineHeight;
}
j = j + 20;
k++;
if (j > 1140)
{
break;
}
}
j = j + 10;
e.Graphics.DrawString("------------------------------------------------------------------ ", font, Brushes.Black, float.Parse("15"), float.Parse(j.ToString()));
y += lineHeight;
j = j - 7;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("14"), float.Parse(j.ToString()));
y += lineHeight;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("80"), float.Parse(j.ToString()));
y += lineHeight;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("150"), float.Parse(j.ToString()));
y += lineHeight;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("230"), float.Parse(j.ToString()));
y += lineHeight;
e.Graphics.DrawString("| ", font, Brushes.Black, float.Parse("320"), float.Parse(j.ToString()));
y += lineHeight;
j = j + 7;
j = j + 15;
e.Graphics.DrawString("Total Quantity : " + textBox8.Text, font4, Brushes.Black, float.Parse("20"), float.Parse(j.ToString()));
y += lineHeight;
e.Graphics.DrawString("Current Amount : " + textBox9.Text, font4, Brushes.Black, float.Parse("160"), float.Parse(j.ToString()));
y += lineHeight;
j = j + 20;
e.Graphics.DrawString("Last Amount : " + textBox17.Text, font4, Brushes.Black, float.Parse("20"), float.Parse(j.ToString()));
y += lineHeight;
e.Graphics.DrawString("Total Amount : " + textBox16.Text, font4, Brushes.Black, float.Parse("160"), float.Parse(j.ToString()));
y += lineHeight;
//e.Graphics.DrawString(, font, Brushes.Black, float.Parse("510"), float.Parse(j.ToString()));
//y += lineHeight;
//j = j + 30;
//e.Graphics.DrawString("BALANCE :- " + label11.Text, font, Brushes.Black, float.Parse("280"), float.Parse(j.ToString()));
//y += lineHeight;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
No comments:
Post a Comment