ALTER PROCEDURE [dbo].[360LMS_LogOutUser]
(
@UserID int
)
AS
declare @logid int
declare @Ttime int
declare @intime Datetime
set @logid=(Select Max(LogID) from [360LMS_UserLogs] where UserID=@UserID)
set @intime=(Select LoginDateTime from [360LMS_UserLogs] where UserID=@UserID and LogID=@logid)
set @Ttime=(Select Max(TotalTime) from [360LMS_UserLogs] where UserID=@UserID)
set @Ttime=(@Ttime + DATEDIFF(minute, @intime, getdate()))
Update [360LMS_UserLogs] set LogoutDateTime =getdate(),SessionTime=DATEDIFF(minute, @intime, getdate()) ,
TotalTime=@Ttime
where UserID=@UserID and
LogID=@logid;
UPDATE [360LMS_Users] SET LoginFlag='False' where UserID=@UserID
Update [360LMS_tblChatMassages] set IsOnline='False' where UserID=@UserID
Thursday, February 4, 2010
HOW TO USe temporary TABLE
set ANSI_NULLS OFF
set QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[360LMS_SearchUserPaymentDetail]
@username nvarchar(50)
AS
Declare @temppayment TABLE
(srno smallint IDENTITY Primary Key,
UserID int,
fullname nvarchar(50),
CollegeName nvarchar(50),
Faculty nvarchar(50),
CourseTitle nvarchar(50),
TotalAmountPaid int,
balance int,
duration nvarchar(100),
IsActive int,
RoleId int,
UserName nvarchar(50)
)
INSERT INTO @temppayment
SELECT ucp.UserID,
u.FirstName+' '+u.LastName as fullname,
u.CollegeName,
u.Faculty,
'Certified Course In Information Security' as CourseTitle,
ucp.TotalAmountPaid,
(12500 - ucp.TotalAmountPaid) as balance,
ucp.Duration,
u.IsActive,
u.RoleId,
u.UserName
FROM [360LMS_Users] as u,
[360LMS_UserCoursePayment] As ucp
WHERE
u.UserID=ucp.UserID and u.RoleId='3' and u.DeleteFlag <> 'True'
and (u.FirstName like '%'+@username+'%' or u.FirstName like '%'+@username+'%' )
and ucp.TotalAmountPaid = (SELECT MAX(TotalAmountPaid) FROM [360LMS_UserCoursePayment] WHERE UserID = ucp.UserID )
select * from @temppayment;
set QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[360LMS_SearchUserPaymentDetail]
@username nvarchar(50)
AS
Declare @temppayment TABLE
(srno smallint IDENTITY Primary Key,
UserID int,
fullname nvarchar(50),
CollegeName nvarchar(50),
Faculty nvarchar(50),
CourseTitle nvarchar(50),
TotalAmountPaid int,
balance int,
duration nvarchar(100),
IsActive int,
RoleId int,
UserName nvarchar(50)
)
INSERT INTO @temppayment
SELECT ucp.UserID,
u.FirstName+' '+u.LastName as fullname,
u.CollegeName,
u.Faculty,
'Certified Course In Information Security' as CourseTitle,
ucp.TotalAmountPaid,
(12500 - ucp.TotalAmountPaid) as balance,
ucp.Duration,
u.IsActive,
u.RoleId,
u.UserName
FROM [360LMS_Users] as u,
[360LMS_UserCoursePayment] As ucp
WHERE
u.UserID=ucp.UserID and u.RoleId='3' and u.DeleteFlag <> 'True'
and (u.FirstName like '%'+@username+'%' or u.FirstName like '%'+@username+'%' )
and ucp.TotalAmountPaid = (SELECT MAX(TotalAmountPaid) FROM [360LMS_UserCoursePayment] WHERE UserID = ucp.UserID )
select * from @temppayment;
HOW TO WRITE PROCEDURE FOR INSERT
set ANSI_NULLS ON
set QUOTED_IDENTIFIER OFF
GO
ALTER PROCEDURE [dbo].[360LMS_User_Registration]
(
@college_name nvarchar(50),
@user_name nvarchar(50),
@password nvarchar(50),
@rollnumber nvarchar(10),
@first_name nvarchar(50),
@middle_name nvarchar(50),
@last_name nvarchar(50),
@sex char(1),
@birth_date datetime,
@faculty nvarchar(50),
@qualification nvarchar(50),
@mobile_number nvarchar(15),
@email_id nvarchar(50),
@address nvarchar(50)
)
AS
INSERT INTO
[360LMS_Users](CollegeName,UserName,Password,RollNumber,FirstName,MiddleName,LastName,Sex,BirthDate,Faculty,Qualification,Mob
ileNumber,EmailID,Address,RegistrationDate)
VALUES(@college_name,@user_name,@password,@rollnumber,@first_name,@middle_name,@last_name,@sex,@birth_date,@faculty,@qualific
ation,@mobile_number,@email_id,@address,getdate())
FOR UPDATE
update [360LMS_Users] set
FirstName=@first_name,MiddleName=@middle_name,LastName=@last_name,CollegeName=@college_name,Sex=@sex,BirthDate=@birth_date,Fa
culty=@faculty,Qualification=@qualification,MobileNumber=@mobile_number,EmailID=@email_id,Address=@address where
UserID=@user_id
set QUOTED_IDENTIFIER OFF
GO
ALTER PROCEDURE [dbo].[360LMS_User_Registration]
(
@college_name nvarchar(50),
@user_name nvarchar(50),
@password nvarchar(50),
@rollnumber nvarchar(10),
@first_name nvarchar(50),
@middle_name nvarchar(50),
@last_name nvarchar(50),
@sex char(1),
@birth_date datetime,
@faculty nvarchar(50),
@qualification nvarchar(50),
@mobile_number nvarchar(15),
@email_id nvarchar(50),
@address nvarchar(50)
)
AS
INSERT INTO
[360LMS_Users](CollegeName,UserName,Password,RollNumber,FirstName,MiddleName,LastName,Sex,BirthDate,Faculty,Qualification,Mob
ileNumber,EmailID,Address,RegistrationDate)
VALUES(@college_name,@user_name,@password,@rollnumber,@first_name,@middle_name,@last_name,@sex,@birth_date,@faculty,@qualific
ation,@mobile_number,@email_id,@address,getdate())
FOR UPDATE
update [360LMS_Users] set
FirstName=@first_name,MiddleName=@middle_name,LastName=@last_name,CollegeName=@college_name,Sex=@sex,BirthDate=@birth_date,Fa
culty=@faculty,Qualification=@qualification,MobileNumber=@mobile_number,EmailID=@email_id,Address=@address where
UserID=@user_id
CHANGE DATA OF ROW AT VALUE BOUND
protected void grvUserThread_RowDataBound(object sender, GridViewRowEventArgs e)
{
try
{
Label lb = new Label();
lb = (Label)e.Row.FindControl("lblEdit");
string tuid = Convert.ToString(e.Row.Cells[3].Text);
if ((tuid != "UserID") && (lb != null))
{
int temp = Convert.ToInt32(tuid);
if (temp == Convert.ToInt16(Session["UserID"]))
{
lb.Visible = true;
}
}
}
catch(Exception ex)
{
String errorMessage;
errorMessage = "Error: ";
errorMessage = String.Concat(errorMessage, ex.Message);
errorMessage = String.Concat(errorMessage, " Line: ");
errorMessage = String.Concat(errorMessage, ex.Source);
LCE.Configuration.ErrorLog("Forum/ReplyToThreads.cs", errorMessage);
}
}
{
try
{
Label lb = new Label();
lb = (Label)e.Row.FindControl("lblEdit");
string tuid = Convert.ToString(e.Row.Cells[3].Text);
if ((tuid != "UserID") && (lb != null))
{
int temp = Convert.ToInt32(tuid);
if (temp == Convert.ToInt16(Session["UserID"]))
{
lb.Visible = true;
}
}
}
catch(Exception ex)
{
String errorMessage;
errorMessage = "Error: ";
errorMessage = String.Concat(errorMessage, ex.Message);
errorMessage = String.Concat(errorMessage, " Line: ");
errorMessage = String.Concat(errorMessage, ex.Source);
LCE.Configuration.ErrorLog("Forum/ReplyToThreads.cs", errorMessage);
}
}
HOW TO CUSTOMIZE DATAHEADER OF GRIDVIEW ?
protected void grvUserThread_RowCreated(object sender, GridViewRowEventArgs e)
{
try
{
if (e.Row.RowType == DataControlRowType.Header)
{
GridViewRow headerRow = e.Row;
Label lb = new Label();
lb = (Label)e.Row.FindControl("lblabc");
lb.Text = "Thread: " + Thread;
}
}
catch(Exception ex)
{
String errorMessage;
errorMessage = "Error: ";
errorMessage = String.Concat(errorMessage, ex.Message);
errorMessage = String.Concat(errorMessage, " Line: ");
errorMessage = String.Concat(errorMessage, ex.Source);
LCE.Configuration.ErrorLog("Forum/ReplyToThreads.cs", errorMessage);
}
}
{
try
{
if (e.Row.RowType == DataControlRowType.Header)
{
GridViewRow headerRow = e.Row;
Label lb = new Label();
lb = (Label)e.Row.FindControl("lblabc");
lb.Text = "Thread: " + Thread;
}
}
catch(Exception ex)
{
String errorMessage;
errorMessage = "Error: ";
errorMessage = String.Concat(errorMessage, ex.Message);
errorMessage = String.Concat(errorMessage, " Line: ");
errorMessage = String.Concat(errorMessage, ex.Source);
LCE.Configuration.ErrorLog("Forum/ReplyToThreads.cs", errorMessage);
}
}
HOW TO SEND ANY ID THROUGH QUERY STRING IN JS
function DeleteUser(UserId)
{
if(UserId > 0)
{
if(confirm("Do you want to delete this user ?"))
{
window.location="ListOfUsers.aspx?UserID="+UserId;
}
}
}
{
if(UserId > 0)
{
if(confirm("Do you want to delete this user ?"))
{
window.location="ListOfUsers.aspx?UserID="+UserId;
}
}
}
HOW TO GET QUERYSTRING VALUE
if(Request.QueryString["UserID"] != null)
{
userid = Convert.ToInt16(Request.QueryString["UserID"].ToString());
}
OR
if (!(Request.QueryString["Thread_ID"] == null))
{
threadid = Convert.ToInt32(Request.QueryString["Thread_ID"]);
}
{
userid = Convert.ToInt16(Request.QueryString["UserID"].ToString());
}
OR
if (!(Request.QueryString["Thread_ID"] == null))
{
threadid = Convert.ToInt32(Request.QueryString["Thread_ID"]);
}
Subscribe to:
Posts (Atom)
