Click here to Skip to main content
15,883,883 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Guys, i need to make a trigger for my table ([Print Record] table)..
This trigger will active when i print some data, and i need to get the people's name who print, date (now) , and time, and what he print..

here is some of my printing codes:

C#
private void PrintDocument1_PrintPage(System.Object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
    try
    {
        byte[] gambar = new byte[0];
        gambar = (byte[])(dgv_ProductData.CurrentRow.Cells[5].Value);   //image data
        MemoryStream ms = new MemoryStream(gambar);
        Bitmap bm = new Bitmap(ms);
        bm = ResizeBitmap(bm,225,300);
        e.Graphics.DrawImage(bm, 0,0);
    }
    catch(Exception ex)
    {
        MessageBox.Show(ex.Message);
    }

    
    try
    {
        byte[] gambarspec = new byte[0];

        gambarspec = (byte[])(dgv_ProductData.CurrentRow.Cells[6].Value);    //image data
        MemoryStream ms = new MemoryStream(gambarspec);
        Bitmap bms = new Bitmap(ms);
        bms = ResizeBitmap(bms,486,270);
        e.Graphics.DrawImage(bms, 275, 0);
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}
//Resizing image
private static Bitmap ResizeBitmap(Bitmap sourceBMP, int panjang, int lebar)
{
    Bitmap result = new Bitmap(panjang,lebar);   //input size
    using (Graphics g = Graphics.FromImage(result)) g.DrawImage(sourceBMP, 0, 0, panjang, lebar);
    return result;
}
//Print Click Event
private void btn_Print_Click(object sender, EventArgs e)
{
    try
    {
        printPreviewDialog1.Document = printDocument1;
        printPreviewDialog1.ShowDialog();
        //printDialog1.ShowDialog();
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}

and i want to make the data was inserted into the table when i already press Print (not everytime i press btn_Print_Click, because there is a chance i abort to print)..
Posted

1 solution

Why would you want a trigger ? A trigger fires on an event in your database. You just want to write code to store in your database that someone pressed 'print'. There may be an event when printing is done, otherwise, I'm not sure how you tell if a user aborted.
 
Share this answer
 
Comments
Sam Oryza Reyno 17-Jun-13 23:14pm    
What handler i should use?
do i give a handler to printPreviewDocument / printDialog?
Christian Graus 17-Jun-13 23:16pm    
this looks like your only possible option
Sam Oryza Reyno 17-Jun-13 23:29pm    
yea i guess,, thanks Christ..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900