protected void btnDelete_Click(object sender, EventArgs e)
{
this.DeleteRecord(Convert.ToInt32(ViewState["ID"]));
// Insert Operation Logs
new UserLogs().InsertLog(Session["UserID"].ToString(), "User Deletion");
string messageType = "Success";
String message = "Successfully deleted...";
ScriptManager.RegisterStartupScript(this, this.GetType(), System.Guid.NewGuid().ToString(), "ShowMessage('" + message + "','" + messageType + "');", true);
}
or on Insert Login click
protected void btnLogin_Click(object sender, EventArgs e)
{
new UserLogs().InsertLog("Login", param);
}
UserLogs.cs will be find on below link:-
https://drive.google.com/file/d/1bq-OMZMfMbV1HEtGZ2MkK-G78xqDEvl0/view?usp=share_link
Stored Procedure Insert Log
ALTER proc [dbo].[InsertLog]
@UserID bigint,
@IP varchar(130),
@PageName varchar(800),
@RefererPage varchar(800),
@Operation varchar(800)
as
begin
insert into UserLogs(UserID,IP,PageName,RefererPage,Operation) values(@UserID,@IP,@PageName,@RefererPage,@Operation)
end
Table (UserLogs)
USE [PMS]
GO
/****** Object: Table [dbo].[UserLogs] Script Date: 24-11-2022 11:06:45 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[UserLogs](
[ID] [bigint] IDENTITY(1,1) NOT NULL,
[UserID] [bigint] NULL,
[IP] [varchar](130) NULL,
[PageName] [varchar](800) NULL,
[RefererPage] [varchar](800) NULL,
[Operation] [varchar](800) NULL,
[CurrentTime] [datetime] NULL,
PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[UserLogs] ADD CONSTRAINT [defaultDate] DEFAULT (getdate()) FOR [CurrentTime]
GO
No comments:
Post a Comment