G
Guest
Hi, I am new to C#, that is why I am not sure what kind of problem it is: Is
VS files corrupted , or something else. that is the problems description:
I am working on a small database project. I am not using any data sources
Mysql, access etc. Instead I use binary formatter to store and read data. at
the beginning the program checks username/password. it does it in the
following way:
if(form2.initialized)
{
for(int i=0; i<database.users.Count;i++)
{
User user;
user=(User)database.users
s1=System.Text.ASCIIEncoding.ASCII.GetString (System.Convert.FromBase64String(user.username));
s2=System.Text.ASCIIEncoding.ASCII.GetString
(System.Convert.FromBase64String(user.password));
if(s1==form2.username.Text && s2==form2.password.Text)
{
accessmode=user.accessmode;
user.lastlogin=System.DateTime.Now;
SaveDatabase();
userlogged=true;
break;
}
}
}
if(!userlogged)
{
System.Windows.Forms.MessageBox.Show("Incorect
Username/Password.Access denied!");
Close(); //Code execution jumps here!!!
}
There is a strange problem: suppose user entered correct username/password,
that is, userogged=true, ok? surprisingly after break takes places code
execution jumps to Close() and form closes, even MessageBox.Show function
does not execute. The same occures in another code:
System.IO.Directory.CreateDirectory(df);
Form3 form3=new Form3();
form3.ShowDialog(this);
if(!form3.initialized)
{
System.Windows.Forms.MessageBox.Show("You must have at least one
administrator username and password. Try next time.");
Close();
}
execution jumps straight to Close() (not to MessageBox.Show(). if
form3.initialized==false, the program shows message box, in another case it
simply closes.
Can anyone clarify this point? May be VS files are corrupted, or there is an
error in code?
VS files corrupted , or something else. that is the problems description:
I am working on a small database project. I am not using any data sources
Mysql, access etc. Instead I use binary formatter to store and read data. at
the beginning the program checks username/password. it does it in the
following way:
if(form2.initialized)
{
for(int i=0; i<database.users.Count;i++)
{
User user;
user=(User)database.users
s1=System.Text.ASCIIEncoding.ASCII.GetString (System.Convert.FromBase64String(user.username));
s2=System.Text.ASCIIEncoding.ASCII.GetString
(System.Convert.FromBase64String(user.password));
if(s1==form2.username.Text && s2==form2.password.Text)
{
accessmode=user.accessmode;
user.lastlogin=System.DateTime.Now;
SaveDatabase();
userlogged=true;
break;
}
}
}
if(!userlogged)
{
System.Windows.Forms.MessageBox.Show("Incorect
Username/Password.Access denied!");
Close(); //Code execution jumps here!!!
}
There is a strange problem: suppose user entered correct username/password,
that is, userogged=true, ok? surprisingly after break takes places code
execution jumps to Close() and form closes, even MessageBox.Show function
does not execute. The same occures in another code:
System.IO.Directory.CreateDirectory(df);
Form3 form3=new Form3();
form3.ShowDialog(this);
if(!form3.initialized)
{
System.Windows.Forms.MessageBox.Show("You must have at least one
administrator username and password. Try next time.");
Close();
}
execution jumps straight to Close() (not to MessageBox.Show(). if
form3.initialized==false, the program shows message box, in another case it
simply closes.
Can anyone clarify this point? May be VS files are corrupted, or there is an
error in code?