hi all,
i have quite question.i have a small application.but there is a problem with it.i have a login form and main form(it is not an MDI form,just normal form).also i have got menu authentication with user who has got his own menu rights.if admin,he sees all menu rights.but if he is a user,he has rescricted rights not all of menu rights.
after i have loginned with correct username and password,i press OK button and close with Close() method and open main form and load menu rights with user.here is the problem:
When i call login form for a second time,i type username and password again and then press OK button,program doesnt load my main form for the new user rights and menu rights.after i pressed OK button on login form,it calls main form newly opened with new user and menu rights.BUT it doesnt?
i tried to call my login form from main form constructor or load event,but it doesnt work.
How could i do something like that? please help
thanks in advance.
Kerem
hi DavidKiryazi,Karthik. A,DaveAuld and all,
The codes that I tried to do this work.
I call main form from Program.cs
[STAThreadAttribute]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new frmMainForm());
}
I added the login form calling code into the main form constructor
public frmMainForm()
{
InitializeComponent();
frmUserLogin fUserLogin = new frmUserLogin();
fUserLogin.ShowDialog();
}
The login form OK button code that I added is below:
private void btnLogin_Click(object sender, EventArgs e)
{
if (sPassword == txtPassword.Text)
{
this.Close();
}
else
{
MessageBox.Show("Geçersiz şifre", CGlobalVars.FCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
txtPassword.Focus();
return;
}
if (GetPermissions() == false)
return;
}
}
and I added this code to my menuitem click event
private void tsmiChangeUsers_Click(object sender, EventArgs e)
{
frmUserLogin fUserLogin = new frmUserLogin();
fUserLogin.ShowDialog();
}
These are the my running steps for program.
1.run program
2.enter username and pasword on login form.
3.call mainform and give permissions for menuitems which username is used.(if admin,give all permissions,else restrict permissions menu items' visibility)
4.now i want to change user when my main form is still on the screen.I call login from menuitem click.
5.after i have pressed login button on login form,load main form with new users rights and menu items permissions.
Till 4th step,it is OK but i couldnt figure out the fifth.when i run 5th step,the permissions belong to previous user.
How could I do this scenario.
[modify the original post if you are providing more information...don't post it as an answer]