登录框设计怎么做,测试用例及步骤分享?( 三 )

  
parName.Value = https://www.scwdwl.com/n/User;  
cmd.Parameters.Add(parName);  
cmd.ExecuteNonQuery();  
conn.Close();  
SqlDataAdapter da = new SqlDataAdapter();  
da.SelectCommand = cmd;  
DataSet ds = new DataSet();  
da.Fill(ds);  
int n;  
n = ds.Tables[0].Rows.Count;  
if(n > 0)  
return true;  
else  
return false;  
}  
}  
}  
在Form2中我设计了一个label ,让它接受从Form1传过来的UserName,这样我们在以后的设计中好判断用户的权限的大小 。  
Form2的代码:  
using System;  
using System.Drawing;  
using System.Collections;  
using System.ComponentModel;  
using System.Windows.Forms;  
using System.Data;  
using System.Data.SqlClient;  
namespace login  
{  
///  
/// Form2 的摘要说明 。  
/// public class Form2 : System.Windows.Forms.Form  
{  
private string UserName;  
private  
System.Windows.Forms.Label label1;  
///  
/// 必需的设计器变量 。  
/// private  
System.ComponentModel.Container components = null;  
public Form2()  
{  
//  
// Windows 窗体设计器支持所必需的  
//  
InitializeComponent();  
Form1 myForm = new Form1();  
myForm.ShowDialog(this);  
//  
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码  
//  
}  
///  
/// 清理所有正在使用的资源 。  
/// protected override void Dispose( bool disposing )  
{  
if( disposing )  
{  
if(components != null)  
{  
components.Dispose();  
}  
}  
base.Dispose( disposing );  
}  
#region Windows 窗体设计器生成的代码  
///  
/// 设计器支持所需的方法 – 不要使用代码编辑器修改  
/// 此方法的内容 。  
/// private void InitializeComponent()  
{  
this.label1 = new  
System.Windows.Forms.Label();  
this.SuspendLayout();  
//  
// label1  
//  
this.label1.Location = new System.Drawing.Point(128, 72);  
this.label1.Name = “label1”;  
this.label1.Size = new System.Drawing.Size(152, 40);  
this.label1.TabIndex = 0;  
//  
// Form2  
//  
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);  
this.ClientSize = new System.Drawing.Size(520, 357);  
this.Controls.Add(this.label1);  
this.Name = “Form2”;  
this.Text = “Form2”;  
this.Load += new System.EventHandler(this.Form2_Load);  
this.ResumeLayout(false);  
}  
#endregion  
[STAThread]  
static void Main()  
{  
Application.Run(new Form2());  
}  
private void Form2_Load(object sender, System.EventArgs e)  
{  
this.SetDesktopLocation(200,180);  
this.label1.Text = UserName;  
}  
public string getUserName  
{  
get  
{  
return UserName;  
}  
set  
{  
UserName = value;  
}  
}  
}  
}  
好了,这篇文章的内容金华号就和大家分享到这里,如果大家网络推广引流创业感兴趣,可以添加  


特别声明:本站内容均来自网友提供或互联网,仅供参考,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。