没有找到BL类和DAL类

本文关键字:类和 DAL BL | 更新日期: 2023-09-27 18:01:34

My DAL File is

public class dalEmployeeInformation
{
    public string MyProperty_EmployeeID { get; set; }
    public string MyProperty_EmpFirstName { get; set; }
    public string MyProperty_EmpLastName { get; set; }
    public string MyProperty_Exception { get; set; }
    private DataSet dsEmployee =  new DataSet();
    public DataSet MyProperty_dsEmployee 
    {
        get { return dsEmployee; }
        set { dsEmployee = value; }
    }
    private DataTable dtEmployee = new DataTable();
    public DataTable MyProperty_dtEmployee
    {
        get { return dtEmployee;}
        set { dtEmployee = value; } 
    }

}

我是这样保存

    public void AddEmployee(dalEmployeeInformation obj)
    {
        try
        {
            cmd.CommandText = "addEmployee";
            cmd.Parameters.AddWithValue("@EmpID", obj.MyProperty_EmployeeID);
            cmd.Parameters.AddWithValue("@FirstName", obj.MyProperty_EmpFirstName);
            cmd.Parameters.AddWithValue("@LastName", obj.MyProperty_EmpLastName);
            cmd.ExecuteNonQuery();
            cmd.Parameters.Clear();                               
        }
        catch (Exception ex)
        {
            obj.MyProperty_Exception = ex.Message;
        }
    }
这是我如何使用它来检索数据。
    public dalEmployeeInformation ViewSelectedEmployee(dalEmployeeInformation obj)
    {
        try
        {
            cmd.CommandText = "getSelectedEmployeeInfo";
            cmd.Parameters.AddWithValue("@EmpID", obj.MyProperty_EmployeeID);
            ada.Fill(obj.MyProperty_dsEmployee , "SelectedEmployee");
            ada.Fill(obj.MyProperty_dtEmployee );
            return obj;
        }
        catch (Exception ex)
        {
            obj.MyProperty_Exception = ex.Message;
            return obj;
        }
    }

的形式为。cs

    private void AddEmployee()
    {
        blEmployeeInformation bl = new blEmployeeInformation();
        dalEmployeeInformation dal = new dalEmployeeInformation();
        dal.MyProperty_Exception = "";
        dal.MyProperty_EmployeeID = txtEmployeeID.Text;
        dal.MyProperty_EmpFirstName = txtEmpFirstName.Text;
        dal.MyProperty_EmpLastName = txtEmpLastName.Text;
        bl.AddEmployee(dal);
        if (dal.MyProperty_Exception == "")
        {
            MessageBox.Show("Employee Added Successfully");
        }
        else
        {
            MessageBox.Show("Employee not Added");
        }
    }

但是当我试着调试的时候出现了这个错误信息

错误3类型或命名空间名称'dalEmployeeInformation'不能被发现(您是否缺少using指令或程序集引用?)

错误2类型或命名空间名称'blEmployeeInformation'不能被发现(您是否缺少using指令或程序集引用?)

没有找到BL类和DAL类

右键单击解决方案资源管理器中的"References"文件夹,然后单击"add References",然后引用BL和DAL文件夹(项目)。

然后将这两行添加到form.cs文件

using BL;
using DAL;