110,533
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace SnKsxs
{
public partial class FormLogin : Form
{
public FormLogin()
{
InitializeComponent();
}
private void btnLogin_Click(object sender, EventArgs e)
{
if (txtUserName.Text=="aaa"&txtPassword.Text=="bbb")//举例的,没有使用数据库
{
ValueClass.LoginUserName = txtUserName.Text;
this.DialogResult = DialogResult.OK;
}
else
{
MessageBox.Show("用户名或密码错误!", "出错啦~~", MessageBoxButtons.OK, MessageBoxIcon.Information);
txtPassword.Focus();
return;
}
return;
}
private void btnCancel_Click(object sender, EventArgs e)
{
Application.ExitThread();
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace SnKsxs
{
public partial class FormMain : Form
{
public FormMain()
{
InitializeComponent();
}
private void FormMain_Load(object sender, EventArgs e)
{
FormLogin fr = new FormLogin();
fr.ShowDialog();
label1.Text = ValueClass.LoginUserName;
}
}
}
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace SnKsxs
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FormMain());
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace SnKsxs
{
class ValueClass
{
public static string LoginUserName = string.Empty;
}
}