Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to set flag value to true in data layer method and this flag value should return to calling method. cs file in C#

What I have tried:

In sql Datalayer.cs
C#
bool OrdInValid = false; int ordernum=0;
bool isValid = Int32.TryParse(dt.Rows[0].GetField<string>("Col1"), out int Coldata);
                        if (isPOValid)
                        {
                            ordernum= Convert.ToInt32(dt.Rows[0].GetField<string>("Col1"));
                            OrdInValid = false;
                        }
                        else
                        {
                            OrdInValid = true;
                        }

}


2. In Main window
property
C#
private int _Order;

        public int Order
        {
            get { return _Order; }
            set { _Order = value;
                if (ordernum==0)
                {
                    OrdInValid = true;

                }
                
            }
        }
Posted
Updated 30-May-22 4:51am
v2

1 solution

Either create a property to return the value (you know how to do that, it's in your main window code), or return a bool value from a method:
C#
public bool MyMethod(...)
   {
   bool itWorked = false;
   ... do something ...
   return itWorked;
   }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900