C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Vb.Net Code for system shutdown,restart
WhatsApp
Viresh Rajput
15y
11.1
k
0
0
25
Blog
Public Class frmShutdown
Private Sub btnShutdown_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShutdown.Click
System.Diagnostics.Process.Start("shutdown", "-s -t 00")
'This will make the computer Shutdown
End Sub
Private Sub btnRestart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRestart.Click
System.Diagnostics.Process.Start("shutdown", "-r -t 00")
'This will make the computer Restart
End Sub
Private Sub btnLogOff_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogOff.Click
System.Diagnostics.Process.Start("shutdown", "-l -t 00")
'This will make the computer Log Off
End Sub
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
End
'This will make the program to terminate(end the program)
End Sub
End Class
Project Expiry
private
void
Check_Expiry()
{
DateTime
newDate =
new
DateTime
();
TimeSpan
RemainingDay =
new
TimeSpan
();
DateTime
TodayDate =
DateTime
.Today;
if
(cnn.State ==
ConnectionState
.Open)
{
cnn.Close();
}
try
{
string
strCom =
"Select ExpiryDate, FirstDay from Expiry where sr = 1"
;
cnn.ConnectionString = CnnStr;
cnn.Open();
OleDbCommand
Comm =
new
OleDbCommand
(strCom, cnn);
OleDbDataReader
dr = Comm.ExecuteReader();
while
(dr.Read())
{
if
(dr[0] ==
DBNull
.Value)
{
newDate =
DateTime
.Today;
Insert_Expiry_Date(newDate);
}
else
if
(
Convert
.ToDateTime(dr[1]) >
DateTime
.Today)
{
MessageBox
.Show(
"Please correct your System Date."
,
"SMS"
);
Application
.Exit();
}
else
if
(
Convert
.ToDateTime(dr[0]) <
DateTime
.Today)
{
MessageBox
.Show(
"Please correct your System Date."
,
"SMS"
);
Application
.Exit();
}
else
{
if
(
Convert
.ToDateTime(dr[0]) ==
DateTime
.Today)
{
MessageBox
.Show(
"Your trail period is expired. Please purchase this Software."
,
"SMS"
);
Application
.Exit();
}
else
{
newDate =
Convert
.ToDateTime(dr[0]);
RemainingDay = newDate.Subtract(TodayDate);
MessageBox
.Show(
"You have "
+ RemainingDay.Days +
" days Left."
,
"SMS"
);
}
}
}
dr.Dispose();
Comm.Dispose();
cnn.Close();
}
catch
(
Exception
ex)
{
MessageBox.Show(ex.Message, "SMS", MessageBoxButtons.OK);
}
}
private
void
Insert_Expiry_Date(
DateTime
date)
{
try
{
if
(cnn.State ==
ConnectionState
.Open)
{
cnn.Close();
}
string
strCom =
"update Expiry set ExpiryDate = #"
+ date.AddDays(10) +
"#, FirstDay = #"
+ date +
"# where sr = 1"
;
cnn.ConnectionString = CnnStr;
cnn.Open();
OleDbCommand
Comm =
new
OleDbCommand
(strCom, cnn);
Comm.ExecuteNonQuery();
MessageBox
.Show(
"You have 10 days left to use this Software."
,
"SMS"
);
Comm.Dispose();
cnn.Close();
}
catch
(
Exception
ex)
{
MessageBox
.Show(ex.Message,
"SMS"
,
MessageBoxButtons
.OK,
MessageBoxIcon
.Error);
}
}
People also reading
Membership not found