Click here to Skip to main content
15,889,200 members
Home / Discussions / C#
   

C#

 
AnswerRe: Help to a new user please Pin
N a v a n e e t h29-Jan-09 5:29
N a v a n e e t h29-Jan-09 5:29 
AnswerRe: Help to a new user please Pin
Giorgi Dalakishvili29-Jan-09 5:29
mentorGiorgi Dalakishvili29-Jan-09 5:29 
GeneralRe: Help to a new user please Pin
sridhar88729-Jan-09 18:15
sridhar88729-Jan-09 18:15 
AnswerRe: Help to a new user please Pin
musefan29-Jan-09 5:31
musefan29-Jan-09 5:31 
GeneralRe: Help to a new user please Pin
J4amieC29-Jan-09 5:49
J4amieC29-Jan-09 5:49 
GeneralRe: Help to a new user please Pin
musefan29-Jan-09 6:04
musefan29-Jan-09 6:04 
GeneralRe: Help to a new user please Pin
sridhar88729-Jan-09 18:18
sridhar88729-Jan-09 18:18 
QuestionNew values and Old Values Pin
ziwez029-Jan-09 4:12
ziwez029-Jan-09 4:12 
For the past few months Ive had to design a way of keeping a log\ tracking changes to a web app.

Now as this was a urgent requirment, I just kinda got on and did it in the way I knew how to.
But im now at the point where im logging more data and obviously want to be more efficient in how i do this.

So this is what I currently do.

Example:

1.User wants to change a contact phone no, brings up the record, it reads "1234567" user enters "123456789"
presses update and the code will do the following

2.I will do a db look for that customer record (i passed a paramter of the customerid),
grab the contact no and store it in a string, close the connection.
// I question this bit as I all ready pulled out the value once to show to the user (1.)

3.Im now going to update my record with the new value, done.

4. Now i need to log the old value and the new value into my log class which is like

public class Log
{
private bool xLogRecordInserted;
ProfileCommon profile = HttpContext.Current.Profile as ProfileCommon;

ProfileBase pb;


public Log(string NewComments, string OldComments, int LogCategoryOID, int OID)
{
try
{

string strInsertLog = "INSERT INTO tbl_Log (UserOID, dtRasiedDate, Comments, Comments2, LogCategoryOID, RelatedRecordOID) VALUES (@UserOID_2, @dtRasiedDate_2, @Comments_2, @Comments2_2, @LogCategoryOID_2, @RelatedRecordOID_2)";
Connection c = new Connection("Connection_Log");
//--Connection


SqlConnection con = c.Connect();
//--Commands
SqlCommand cmd_InsertLog = new SqlCommand();
cmd_InsertLog.Parameters.AddWithValue("@UserOID_2",profile.UserID);
cmd_InsertLog.Parameters.AddWithValue("@dtRasiedDate_2", DateTime.Now);
cmd_InsertLog.Parameters.AddWithValue("@Comments_2", NewComments);
cmd_InsertLog.Parameters.AddWithValue("@Comments2_2", OldComments);
cmd_InsertLog.Parameters.AddWithValue("@LogCategoryOID_2", LogCategoryOID);
cmd_InsertLog.Parameters.AddWithValue("@RelatedRecordOID_2", OID);

//--Open Connection
cmd_InsertLog.Connection = con;
//--Command Types

cmd_InsertLog.CommandText = strInsertLog;
// Execute Query and count rows

int intAffectedRows = cmd_InsertLog.ExecuteNonQuery();

if (intAffectedRows > 0)
{
xLogRecordInserted = true;
}
else
{
xLogRecordInserted = false;
}

con.Close();
con.Dispose();
c.Disconnect();

}

catch (Exception ea)
{
xLogRecordInserted = false;
ErrorLog ErrorLogEntry = new ErrorLog("Log.CS", "Log", profile.UserName, ea.ToString(), "Class");
}


}

public bool LogRecordInserted
{
get {return xLogRecordInserted;}
}
}
AnswerRe: New values and Old Values Pin
musefan29-Jan-09 4:22
musefan29-Jan-09 4:22 
AnswerRe: New values and Old Values Pin
Rob Philpott29-Jan-09 5:11
Rob Philpott29-Jan-09 5:11 
AnswerRe: New values and Old Values Pin
N a v a n e e t h29-Jan-09 5:25
N a v a n e e t h29-Jan-09 5:25 
GeneralRe: New values and Old Values Pin
ziwez029-Jan-09 7:36
ziwez029-Jan-09 7:36 
QuestionA problem with DataBinding. [modified] Pin
AxiliuM29-Jan-09 4:09
AxiliuM29-Jan-09 4:09 
AnswerRe: A problem with DataBinding. Pin
MadArtSoft29-Jan-09 23:27
MadArtSoft29-Jan-09 23:27 
GeneralRe: A problem with DataBinding. Pin
AxiliuM30-Jan-09 20:03
AxiliuM30-Jan-09 20:03 
QuestionSend e-mail with .mht body from program Pin
collapo29-Jan-09 3:47
collapo29-Jan-09 3:47 
AnswerRe: Send e-mail with .mht body from program Pin
vaghelabhavesh29-Jan-09 13:36
vaghelabhavesh29-Jan-09 13:36 
GeneralRe: Send e-mail with .mht body from program Pin
collapo29-Jan-09 22:02
collapo29-Jan-09 22:02 
Questionaccessing database in SQL server 2005 through C# Pin
Deepali Khalkar29-Jan-09 2:35
Deepali Khalkar29-Jan-09 2:35 
AnswerRe: accessing database in SQL server 2005 through C# Pin
musefan29-Jan-09 2:45
musefan29-Jan-09 2:45 
AnswerRe: accessing database in SQL server 2005 through C# Pin
vaghelabhavesh29-Jan-09 13:28
vaghelabhavesh29-Jan-09 13:28 
QuestionDynamically Creating Treeview Nodes Question Pin
Rafone29-Jan-09 2:30
Rafone29-Jan-09 2:30 
AnswerRe: Dynamically Creating Treeview Nodes Question Pin
musefan29-Jan-09 2:44
musefan29-Jan-09 2:44 
GeneralRe: Dynamically Creating Treeview Nodes Question Pin
Rafone29-Jan-09 3:17
Rafone29-Jan-09 3:17 
AnswerRe: Dynamically Creating Treeview Nodes Question Pin
musefan29-Jan-09 3:32
musefan29-Jan-09 3:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.