在Windows窗体中的多个用户 [英] Multiple users in Windows Forms

查看:134
本文介绍了在Windows窗体中的多个用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个项目,我需要一些implementention想法。到目前为止,我使用的窗口形式。该应用程序将在同一台PC使用不同的用户。我不是一个很好的相关者,所以我会给你一个情景:

I'm working on a project and i need some implementention ideas. So far i used windows forms. The application will be used by different users on the same pc. I'm not a good relater so i'm gonna give you a scenario:

1。
的应用程序通过显示登录表单开始。

1. The application starts by showing a login form.

2。
用户约翰进入应用程序,并通过形式使得在数据库中进行一些修改。

2. The user "John" enters the application and makes some modifications in the database through a form.

3。
约翰退出形式。在这一点上我要再次表明,登录表单,用户布拉德应该是能够登录。

3. "John" quits the form. At this point I want that login form to be shown again where user "Brad" should be able to log in.

4。
布拉德应该是能够看到由约翰所作的修改,它应该能够作出一些修改太

4. "Brad" should be able to see the modification made by "John" and it should be able to make some modifications too.

请帮我带一些例子

后来编辑:
我已经试过这样:

Later edit: I've tried this:

form_login login = new form_login();
DialogResult result = login.ShowDialog();

if (result == DialogResult.OK)
{
  Application.Run(new main_page());
}
else if (result == DialogResult.Yes)
{
  Application.Run(new admin_page());
}
else if (result == DialogResult.No) // Back button 
{
  Application.Run(new form_login());
}
else
{
  Application.Exit();
}



后来编辑:

Later edit:

当用户注销我的问题是。应用程序停止,但我要的是指向我登录表单。

The problem I have is when the user logs off . The application stops but what I want is to point me to login form.

推荐答案

您可以添加到您的主要出发点。基本上,你需要能够遍历进程再次一旦用户被传递的登录表单:

You can add this to your Main starting point. Basically, you need to be able to loop through the process again once the user gets passed the login form:

static void Main()
{
  Application.EnableVisualStyles();
  Application.SetCompatibleTextRenderingDefault(false);

  DialogResult running = DialogResult.OK;
  while (running == DialogResult.OK) {
    form_login login = new form_login();
    Application.Run(login);
    running = login.DialogResult;
    if (login.DialogResult == DialogResult.OK)
      Application.Run(new Form1());
      // or your other forms...
  }
}

这是假设您的登录表单有一个确定和取消按钮,设置这些对话的结果。

This is assuming your login form has an OK and a Cancel button that sets those dialog results.

如果登录的作品,然后启动主窗体Form1。当用户关闭Form1上,它再次开始登录表单。如果用户取消登录,应用程序退出。

If the login works, then it launches the main form, Form1. When the user closes Form1, it starts the Login form again. If the user cancels the login, the application is exited.

这篇关于在Windows窗体中的多个用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆