CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2008
    Posts
    13

    returning fields

    I am writing a method where a screen pops up and need to select two of the three fields to run a customer search(acct, name, ssn). Right now when I run the search it checks for the bill account and only one of the other fields. Can someone show me how to change this to any of the three fields instead of just bill account and one of the other fields. Let me know if you have additional questions I need to have answered as I am only sending the method...

    Code:
            private Message GetSadData(string acct, string inputSsn, string inputAcctName, string inputState,
                                        out string ssn, out string firstName, out string lastName, out string fullName)
            {
                ssn = string.Empty;
                firstName = string.Empty;
                lastName = string.Empty;
                fullName = string.Empty;
    
                Message message = new Message();
                message.Description = new List<string>();
                string errTxt = string.Empty;
                long billAcct = 0;
                long cssSsn = 0;
    
                //Kruep code changes
                if (billAcct != null && billAcct > 0) 
                {
                    if (!long.TryParse(acct, out billAcct))
                    {
                        message.Code = MessageStatusCodes.Error;
                        message.Description.Add(errTxt = "The account provided was not in the correct format.");
                        return message;
                    }
    
                    if (!EAPortalOracleManager.AccountExists(billAcct.ToString()))
                    {
                        message.Code = MessageStatusCodes.Error;
                        message.Description.Add(errTxt = "No client data found matching the entered criteria.");
                        return message;
                    }
                }
    
    
                //Need to change the check to be at least 2 of the inputs are populated
                if ((inputAcctName == null || inputAcctName == "") || (billAcct != null && billAcct > 0)  && !long.TryParse(inputSsn, out cssSsn))
                {
                    message.Code = MessageStatusCodes.Error;
                    message.Description.Add(errTxt = "The SSN provided was not in the correct format.");
                    return message;
                }
    
                if ((inputAcctName == null || inputAcctName == "") && (billAcct != null && billAcct > 0 || !long.TryParse(inputSsn, out cssSsn))
                {
                        message.Code = MessageStatusCodes.Error;
                        message.Description.Add(errTxt = "The account name provided does not match CSS.");
                        return message;
                }
    
                Message oracleSadMessage = new Message();
                
                oracleSadMessage = EAPortalOracleManager.GetSADData(acct, out ssn, out firstName, out lastName, out fullName);
                if (oracleSadMessage.Code == MessageStatusCodes.Error)
                {
                    message.Code = MessageStatusCodes.Error;
                    message.Description.Add(errTxt = "Error accessing data for account " + acct + ".");
                }
    
    
    
                if ((acct != null || inputAcctName != null && inputAcctName.Length > 1) && (cssSsn >= 1)) 
                {
                    if (string.IsNullOrEmpty(ssn) || cssSsn != Convert.ToInt64(ssn))
                    {
                        message.Code = MessageStatusCodes.Error;
                        message.Description.Add(errTxt = "The SSN provided does not match the records in CSS.");
                        return message;
                    }
                }
                else if ((inputAcctName != null && inputAcctName.Length > 1) && (acct != null || cssSsn >= 1))
                {  
                    string firLast = firstName.ToUpper() + " " + lastName.ToUpper();
                    string last = lastName.ToUpper();
    
                    if (inputAcctName.ToUpper() != firLast && inputAcctName.ToUpper() != lastName)
                    {
                        message.Code = MessageStatusCodes.Error;
                        message.Description.Add(errTxt = "The account name provided does not match CSS.");
                        return message;
                    }
                }
                else if ((acct != null) && (inputAcctName != null && inputAcctName.Length > 1) || (cssSsn >= 1))
                {
                    if (string.IsNullOrEmpty(acct))
                    {
                        message.Code = MessageStatusCodes.Error;
                        message.Description.Add(errTxt = "No client data found matching the entered criteria.");
                        return message;
                    }
                }
    
                if (inputState != "IL" && inputState != "MO")
                {
                    message.Code = MessageStatusCodes.Error;
                    message.Description.Add(errTxt = "Please provide a valid state.");
                    return message;
                }
                return message;
            }

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: returning fields

    Create a Boolean Flag, set it to True at the top (after //Need to...)
    Then, in each IF/Then, if it fails, set it to FALSE.
    After 3 searches, check the Flag, and then output the message
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured