I would like to do a seperated class with a method which will return CustomerID (this will be a select query from db), based on the Costumer`s name which would come into this method (it will come from a form1`s method - from a textBox).
I am not sure how to do all these connections that the name will come from form1 to CustomerID method in class1.
And then when CustomerID if found it has to pass it back to Form1.

So, from form1 to Customer method in class1 goes the name, and back from method to from1 goes id.
Is this possible?

Yes, for example:

public class class1
        {
            public static int GetCustomerID(string lastname, string firstname)
            {
                int id = -1;
                // TODO: db query here...

                return id;
            }
        }
        public partial class Form1 : Form
        {
            TextBox textBox1 = new TextBox(); // I put here for reference only...
            TextBox textBox2 = new TextBox(); // I put here for reference only...
            //...

            private void GetCustomerID()
            {
                string lastname = textBox1.Text;
                string firstname = textBox2.Text;
                int customerId = class1.GetCustomerID(lastname, firstname);
            }
        }

Now, I suspect the answer you are looking for requires more information, but maybe not... Please elaborate if this is not a sufficient answer.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.