n Info",MessageBoxButtons.OK);
}
}
private void btnCancel_Click(object sender, System.EventArgs e)
{
OnCancel(e);
}
private void UserControl_Load(object sender, System.EventArgs e)
{
intLoginTime = 0;
}
}
public class EventLoginArgs:System.EventArgs
{
public string strUserID;
public string strUserName;
public string strUserPWD;
public bool bVaild;
public EventLoginArgs(string userID,string userName,string userPWD)
{
strUserID = userID;
strUserName = userName;
strUserPWD = userPWD;
}
}
它的客户
程序主要如下:
private void userControl1_SubmitLogin(object sender, Userlogin.EventLoginArgs e)
{
MessageBox.Show("This result is bLogin="+ userControl1.bLogin +" At "+userControl1.intLoginTime +" times \n
UserID="+e.strUserID+"\n UserName="+e.strUserName,"TestResult",MessageBoxButtons.OK);
}
private void Form1_Load(object sender, System.EventArgs e)
{
userControl1.Server = "localhost";
userControl1.DataBase="weiwen";
userControl1.TableSet = "TestUser";
userControl1.UserForDB="sa";
userControl1.PWDForDB = "sa";
}
这两个例子的完整代码可以点击这里
下载.
读者可以参考
学习,也可直接使用此组件,但使用时应当以Microsoft SQL Server 作为后台数据库,所用到的用户表格应有 UserID,UserName,UserPWD三列,同时在客户
程序中应对有关参数初始化,SubmitLogin事件返回值是尝试次数intLoginTime和验证是否成功bLogin,可参考扩展例子二。