0

I am using a 3 tier architecture in my C# WinForms application. When I compile the application, I am thrown with the following error in my Presentation layer form1.cs

Code:

private void btnSave_Click(object sender, EventArgs e)
{
    BLL.clsBLL obj = new BLL.clsBLL();
    string firstname = txtClientFirstName.Text;
    string lastname = txtClientLastName.Text;
    string age = txtClientAge.Text;
    int Res = 0;
    try
    {
        Res = obj.Save_Client(Client_FirstName, Client_Lastname, Client_Age);
    }
        catch(SqlException ex)
    {
MessageBox.Show(ex.Message);
    }
    if(Res ==1)
    {
MessageBox.Show("Data Saved");
    }

    else
    {
        MessageBox.Show("Data Not Saved");
    }
}

Error:

'BLL.clsBLL' does not contain a definition for 'Save_Client' and no extension method 'Save_Client' accepting a first argument of type 'BLL.clsBLL' could be found (are you missing a using directive or an assembly reference?)

The code for the Save_Client in BLL layer in as follows:

Code:

public int Save_Client(string Client_FirstName, string Client_Lastname, string Client_Age)
{
    Boolean bopassed = true;

    bopassed = Check_Rules(Client_FirstName, Client_Lastname, Client_Age);
    DAL.clsDAL obj = new DAL.clsDAL();
    int Res = 0;
    try
    {
        if (bopassed == true)
        {
obj.Insert_Clients(Client_FirstName, Client_Lastname, Convert.ToInt32(Client_Age));
Res = 1;
        }
        else
        {
Res = 0;
        }
    }
    catch (SqlException)
    {
        throw;
    }
    return Res;
}

private Boolean  Check_Rules(Client_FirstName, Client_Lastname, Client_Age)
{
    Boolean bolres = true;
    if(Client_FirstName=="")
    {
        bolres=false;
    }
    if(Client_Lastname=="")
    {
        bolres=false;
    }
    if(Client_Age=="")
    {
        bolres=false;
    }

    return bolres;
}

Error:

"Identifier Expected"

in the method private Boolean Check_Rules(Client_FirstName, Client_Lastname, Client_Age)

I can't able to figure out the cause for the errors .

Can anybody tell me what the issue is?

nikola
  • 2,241
  • 4
  • 30
  • 42
user2059013
  • 117
  • 1
  • 1
  • 6

1 Answers1

1

You forgot to state the types of your parameters in the Check_Rules method. You need to change this line:

private Boolean Check_Rules(Client_FirstName, Client_Lastname, Client_Age)

to this:

private Boolean Check_Rules(string Client_FirstName, string Client_Lastname, string Client_Age)
Adi Lester
  • 24,731
  • 12
  • 95
  • 110
  • +1 for this anwser. also you might want to use the values from the textboxes, when you call the method. like this: `obj.Save_Client(firstname , lastname , age);` – Jens Kloster Feb 10 '13 at 15:41