The project I'm making provides specifications that have changing revision levels. What I'm attempting to do is force a warning for a week prior to expiring. Once expired, someone trying to use it will have to enter a code that confirms they have verified rev levels are current (that's what the week warning is for). I'd like this to occur on the same date ever year.
Currently, it asks for the passcode every time it's opened. For example, I did expect to be asked for the passcode today. I entered it then closed the program. When I opened it, it asked me for it again. I did not expect to be asked again until next 7, 1.
The passcode is not intended to keep anyone out of the software permanently. It's actually given within the message that appears. It's just a means to document the person confirming that rev levels are current.
Please don't ask why I've done something the way I did. I know just enough to be dangerous. If something is glaringly obvious to you, please tell me, or direct me to where I can find the information. I don't mind figuring things out on my own, but it's a matter of "not knowing what I don't know". All of you at some point asked questions and had to learn. I'm doing the same.
Thank you
What I have tried:
private void Expiry()
{
DateTime value1 = new DateTime(DateTime.Now.Year, 7, 1);
DateTime value2 = new DateTime(DateTime.Now.Year, 7, 6);
if ((DateTime.Now > value1) && (DateTime.Now < value2))
{
MessageBox.Show("Specs will expire on 07/07/. You will be asked to confirm rev levels are current.", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else
if (DateTime.Now > new DateTime(DateTime.Now.Year, 07, 08))
{
expire notice = new expire();
notice.ShowDialog();
}
else
if ((DateTime.Now < value1) || (DateTime.Now > value2))
{
}
}
This next code is for controlling the passcode messagebox.
private void btnExpired_Click(object sender, EventArgs e)
{
string password = txtPassword.Text;
if (txtPassword.Text == "1818")
{
MessageBox.Show("Unlocked", "Accepted", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.Hide();
}
else
{
MessageBox.Show("Software is not useable.","No Password Entered", MessageBoxButtons.OK, MessageBoxIcon.Stop);
Application.Exit();
}