基本信息
源码名称:winform 登录传值例子
源码大小:0.04M
文件格式:.rar
开发语言:C#
更新时间:2015-06-23
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication3
{
public partial class f_login : Form
{
public Boolean l=false;
public f_main f1; //窗体对象
public f_login()
{
InitializeComponent();
}
private void f_login_Load(object sender, EventArgs e)
{
txtuserpwd.Focus();
}
private void txtusername_KeyPress(object sender, KeyPressEventArgs e)
{
if ((int)e.KeyChar == 13)
{
txtuserpwd.Focus();
}
}
private Boolean login(string username,string userpwd) //登陆方法
{
if (username == "qq" && userpwd == "1")
{
l = true; //验证用户
f1.textBox1.Text = username; //将用户名返回给from1窗体中的textBoxt1
return true;
}
else
{
return false;
}
}
private void txtuserpwd_KeyPress(object sender, KeyPressEventArgs e)
{
if ((int)e.KeyChar == 13)
{
if (txtusername.Text != "" && txtuserpwd.Text != "")
{
if (login(txtusername.Text, txtuserpwd.Text))
{
this.Close(); //关闭登陆窗体
}
else
{
MessageBox.Show("登陆信息错误,请重新输入!");
}
}
}
}
private void btnlogin_Click(object sender, EventArgs e)
{
if (txtusername.Text != "" && txtuserpwd.Text != "")
{
if (login(txtusername.Text, txtuserpwd.Text))
{
this.Close();
}
else
{
MessageBox.Show("登陆信息错误,请重新输入!");
}
}
}
private void f_login_FormClosed(object sender, FormClosedEventArgs e)
{
if (!l)
{
//Application.Exit();
f1.Close();
}
}
private void btncancel_Click(object sender, EventArgs e)
{
this.Close();
//Application.Exit();
}
}
}