这样调用
CostClassInfo ccinfo = new CostClassInfo();
ccinfo.ClassName = txtClassNm.Text.Trim();
SingleMan.DALFactory.CostClass.Creat().Insert(ccinfo);
的时候报错"未将对象引用设置到对象实例"
BLL
public class CostClass
{
public void Insert(CostClassInfo costCL)
{
if (costCL.ClassName.Trim() == string.Empty)
return;
SingleMan.DALFactory.CostClass.Creat().Insert(costCL);
}
}
DALFactory
public class CostClass
{
public static SingleMan.IDAL.ICostClass Creat()
{
string a = ConfigurationSettings.AppSettings["WebDAL"];
string b = a + ".CostClass";
return (IDAL.ICostClass)Assembly.Load(a).CreateInstance(b, false);
}
}
IDAL
public interface ICostClass
{
void Insert(CostClassInfo CClassNm);
CostClassInfo GetClassByID(int ClassID);
}
Model
public class CostClassInfo
{
private int _classid;
private string _classname;
public CostClassInfo()
{
}
public CostClassInfo(string classname)
{
this._classname = classname;
}
public CostClassInfo(int classid,string classname)
{
this._classid = classid;
this._classname = classname;
}
public int ClassID
{
get
{
return _classid;
}
}
public string ClassName
{
get
{
return _classname;
}
}
}
web.config
<add key="WebDAL" value="SQLServerDAL"/>