Audit Trail using C#.Net - Winforms
-
13 Mei 2009 9:24Hi experts,
I would like to ask for some suggestions. I was tapped by my boss to create an audit trail program using C#.net - Winforms. I researched for some articles and samples on how to create, I found some interesting samples specifically in codeproject.com from the samples the author used a triggers. I would like to ask for some suggestions for e better and more effective way on creating an audit trail.
tatas move
Semua Balasan
-
15 Mei 2009 8:51Hi cerebralkink,
Would you please include the link in the codeproject you are referring to? So that I can know you better.
Best regards,
Bruce Zhou
Please mark the replies as answers if they help and unmark if they don't. -
18 Mei 2009 1:35
-
29 Juni 2010 6:56
To audit your winforms applications you have many options
1- use the binding source events to track your changes
2- use trigers in sql itselt
In following lines I will present the use fo BindingSource control as Aduit Helper
Assume you have One table with "ScreenName", "FieldName" , "OldValue" and "NewValue" fields;
you may use the BindingComplete event of your binding Source as follow:
a- Create Windows form
b- add BindingSource to designer
c- add BindingComplete event to your BindingSource
the over all code will be as follows
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}private void bindingSource_BindingComplete(object sender, BindingCompleteEventArgs e)
{
// reading from database
if (e.BindingCompleteContext == BindingCompleteContext.ControlUpdate && e.Binding.IsBinding)
{
object displayvalue = ReadDisplayValue(e.Binding.Control);
}if (e.BindingCompleteContext == BindingCompleteContext.DataSourceUpdate && e.Binding.IsBinding)
{
object NewValue = ReadDisplayValue(e.Binding.Control);
}// Create instance of your Auditing table
// Set ScreenName = this.textstring FieldName = e.Binding.BindingMemberInfo.BindingField;
// set Audit Filedname = FieldName;}
void Save()
{
//Save Your Audit instance
}object ReadDisplayValue(Control control)
{
if (control is TextBox)
return ((TextBox)control).Text;
if (control is ComboBox)
return ((ComboBox)control).Text;
if (control is CheckBox)
return ((CheckBox)control).Checked? "Yes" :"No";
return null;
}}
Any Questions are welcome
Abdelmawgoud
- Disarankan sebagai Jawaban oleh Mahmoud Sofy 30 Juni 2010 10:11