访问类库里边的类时,只能访问到属性,不能访问到方法,在线等!
我写的一个class Base :
using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
using System.Security.Cryptography;
using System.Text;
using Mis.DbBase;
namespace Mis.DbBase
{
public class User:Mis.DbBase.Base
{
private string m_Password;
private string emp_id;
public string Password
{
get{return m_Password;}
set{m_Password=value;}
}
public string Emp_Id
{
get{return emp_id;}
set{emp_id=value;}
}
public static void Add(string name,string password,string Emp_Id)
{
if(IsExist(Emp_Id))
{throw new Exception("This Name was registered");}
else
{
strSQL ="Insert into t_emp_info(emp_name,Password,emp_id) values("
+""+name+","
+""+password+","
+""+Emp_Id+")";
try
{ExecuteSql(strSQL);}
catch
{ throw new Exception("register failed");}
}
}
public static void Delete(int id)
{
strSQL="update t_emp_info set flag='0'where emp_id ="+id;
try
{ExecuteSql(strSQL);}
catch
{ throw new Exception("Register Failed");}
}
public static bool IsExist(string Emp_Id)
{
strSQL="select emp_id from t_emp_info where flag=1 and emp_id ='+id'";
try
{
ExecuteSql4Value(strSQL);
return true;}
catch
{
return false;
}
}
}
}
在引用这个类库时:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Mis.DbBase;
using DbBase;
namespace TheRest
{
/// <summary>
/// empFrm 的摘要说明。
/// </summary>
public class empFrm : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.TextBox TextBox2;
protected System.Web.UI.WebControls.Button Button1;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void Button1_Click(object sender, System.EventArgs e)
{
Mis.DbBase.User user=new Mis.DbBase.User();
user.ID=TextBox1.Text;
user.Name=TextBox2.Text;
}
}
}
当我试图访问user对象时,只能访问到user下边的属性ID和Name,却不能访问user的方法Add(string name,string password,string Emp_Id);也就是当我输入user.的时候,后边只提示我的属性ID和Name,却没有方法Add(string name,string password,string Emp_Id)的提示;
请问高手,我怎么解决这样的问题?