使用Trigger将打印记录插入到SQL表中 [英] Inserting Print record into SQL table with Trigger

查看:89
本文介绍了使用Trigger将打印记录插入到SQL表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们,我需要为我的桌子([打印记录]表)触发..

当我打印一些数据时,这个触发器会激活,我需要得到这个人的名字打印,日期(现在)和时间,以及他打印的内容..



这里是我的一些打印代码:



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:

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);
    }
}



我想在我按下打印时将数据插入表中(不是每次按btn_Print_Click,因为我有机会中止打印)..


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)..

推荐答案

你为什么要一个触发器?触发器会触发数据库中的事件。您只想编写代码存储在数据库中,有人按下'print'。打印完成时可能会发生一个事件,否则,我不知道如何判断用户是否中止。
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.


这篇关于使用Trigger将打印记录插入到SQL表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆