0

I have an account table that contains a parent field that I want when adding a client in the client table, an account number is generated for it in the account table and the same time appears in the account tree

I want to help debug the following code or write a code that fetches the parent account and generates the account number of the child, which in this case is a client account

  public  Int64 GeneratetreeCode(double Parent_Code)
    {
         Parent_Code = 10202;
        DataTable dt = new DataTable();
        dt.Clear();
        SqlDataAdapter da = new SqlDataAdapter("Select Max(AccountCode)  from Accounts where AcountParent = " + Parent_Code + " ", ConClass.Connection);
        da.Fill(dt);
        Int64 CustomerCode = Convert.ToInt64(dt.Rows[0][0]);
        CustomerCode = Convert.ToInt64(dt.Rows[0][0]);
        if (CustomerCode == 1)
        {
            CustomerCode = int.Parse(Parent_Code.ToString() + "0".ToString() + "0".ToString() + "0".ToString() + 1);
        }
        else
        {
            CustomerCode = Convert.ToInt64(Parent_Code);
        }
        return CustomerCode;
    }

The code you wrote at execution returns with the value null The code you wrote at execution returns with the value null

0 Answers0