怎么用C#.NET做一个QQ的登入界面
发布网友
发布时间:2022-04-19 12:18
我来回答
共4个回答
热心网友
时间:2022-05-18 21:34
public partial class LoginForm : Form
{
public LoginForm()
{
InitializeComponent();
}
private void label1_Click(object sender, EventArgs e)
{
this.Hide();
RegisterForm2 rg2 = new RegisterForm2();
rg2.Show();
}
private void cboId_Click(object sender, EventArgs e)
{
if (cboId.Text.Trim() == "<请输入帐号>")
{
cboId.Text = "";
}
} private void cboId_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(e.KeyChar >= '0' && e.KeyChar <= '9') && (int)e.KeyChar != 8)
{
e.Handled = true;
}
} private void 我在线上ToolStripMenuItem1_Click(object sender, EventArgs e)
{
toolStripStatusLabel1.Image=imageList1.Images[0];
UserHelp.state = "我在线上";
} private void q我吧ToolStripMenuItem1_Click(object sender, EventArgs e)
{
toolStripStatusLabel1.Image=imageList1.Images[3];
UserHelp.state = "Q我吧";
} private void 离开ToolStripMenuItem1_Click(object sender, EventArgs e)
{
toolStripStatusLabel1.Image=imageList1.Images[4];
UserHelp.state = "离开";
} private void 忙碌ToolStripMenuItem1_Click(object sender, EventArgs e)
{
toolStripStatusLabel1.Image=imageList1.Images[2];
UserHelp.state = "忙碌";
} private void 请勿打扰ToolStripMenuItem1_Click(object sender, EventArgs e)
{
toolStripStatusLabel1.Image=imageList1.Images[5];
UserHelp.state = "请勿打扰";
} private void 隐身ToolStripMenuItem_Click(object sender, EventArgs e)
{
toolStripStatusLabel1.Image=imageList1.Images[1];
UserHelp.state = "隐身";
}
private void LoginForm_Load(object sender, EventArgs e)
{
this.AcceptButton = this.button1;
}
#region 登录
public static SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=qq520;Integrated Security=True");
private void button1_Click(object sender, EventArgs e)
{
if (cboId.Text.Trim() == "<请输入帐号>")
{
cboId.Text = "";
}
string id = cboId.Text.Trim();
string pwd = txtPwd.Text.Trim();
if (id == "" || pwd == "")
{
MessageBox.Show("请输入QQ号及密码!", "登陆提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
string sql = string.Format("select loginPwd from users where id={0}", id);
try
{
object obj = DBHelper.GetFristCells(sql);
if (obj == null)
{
MessageBox.Show("该QQ号不存在,如果你还没有注册,请点申请号码!");
return;
}
if (obj.ToString().Equals(pwd))
{
UserHelp.loginId = Convert.ToInt32(id);
this.Hide();
LoginForm2 lf2 = new LoginForm2();
lf2.Show();
}
else
{
LoginForm1 lg1 = new LoginForm1();
lg1.Show();
}
if (toolStripStatusLabel1.Image != imageList1.Images[1])
{
string sql1 = string.Format("update users set userstate='在线' where id={0}", cboId.Text.Trim());
int a = DBHelper.ExecuteUpdate(sql1);
}
else
{
string sql2 = string.Format("update users set userState='隐身' where id={0}", UserHelp.loginId);
int a = DBHelper.ExecuteUpdate(sql2);
} }
catch (Exception)
{ throw;
}
}
#endregion
}
热心网友
时间:2022-05-18 22:52
如果你做的简单点,直接在程序里面放几个内置账户和密码..如果你这能让人申请的就得用到数据库了....然后验证用户要登录你就从数据库里面取得用户名和密码...验证为true就登录成功,false就登录失败...
热心网友
时间:2022-05-19 00:27
设计好界面+数据库+一些简单代码。