Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6075505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:30:08+00:00 2026-05-23T10:30:08+00:00

I’ve passed in the whole sale object into this function. In that sale object,

  • 0

I’ve passed in the whole sale object into this function. In that sale object, there are many childs e.g. saleOrderItem, Payment, User…

sale.payment is an array

Question:
1) How do I get the CodeNo from the `sale.payment’ object? (as payment is an array)
2) How to get the sale.payment.CourseByTutor.TutorId (as payment is an array)

  public static object GetSalesDataBySaleOrderID(SaleOrder sale)
        {
            return sale.saleOrderItem
                       .Where(s => s != null)
                       .Select(s => new { 
                                          Id = s.Id,
                                          Username = sale.User.GetSingleUserById(s.UserId).Name,
                                          Amount = s.Amount,
                                          CodeNo = s.SaleOrder.payment.First().CodeNo,
                                          TutorName = sale.User.GetSingleUserById(s.SaleOrder.payment.FirstOrDefault().CourseByTutor.TutorId).Name,
                                        })
                       .ToList();
        }

Here is how i bind the value to the object

 private void SaveValueToObject()
    {
        saleOrder.UserId = UserInfo.Id;
        saleOrder.Date = DateTime.Now;            

        for (int i = 0; i < dgSale.Rows.Count; i++)
        {
            SaleOrderItem SaleItem = new SaleOrderItem();
            SaleItem.InventoryTypeId = Convert.ToInt32(dgSale.Rows[i].Cells["inventoryTypeId"].Value);
            SaleItem.InventoryOrCourseId = Convert.ToInt32(dgSale.Rows[i].Cells["inventoryId"].Value);
            SaleItem.Qty = Convert.ToInt32(dgSale.Rows[i].Cells["qty"].Value);
            SaleItem.Amount = Convert.ToDecimal(dgSale.Rows[i].Cells["total"].Value);
            SaleItem.UserId = Convert.ToInt32(dgSale.Rows[i].Cells["userId"].Value);
            SaleItem.Discount = Convert.ToDecimal(dgSale.Rows[i].Cells["discount"].Value);
            SaleItem.Remarks = (dgSale.Rows[i].Cells["remark"].Value == null) ? "" : dgSale.Rows[i].Cells["remark"].Value.ToString();
            SaleItem.Status = (int)SaleOrderStatus.Active;
            saleOrder.saleOrderItem[i] = SaleItem;                


            Payment p = new Payment();
            p.PayType = Convert.ToInt32(dgSale.Rows[i].Cells["payType"].Value);
            p.Code = (int)PaymentCode.RCT; // For Receipt prefix
            p.CodeNo = p.GetNewReceiptNo(p.Code); //Check if it is receipt, if yes, Get last Receipt No + 1
            p.UserId = (txtUserId.Text == string.Empty) ? 0 : Convert.ToInt32(txtUserId.Text);
            p.Amount = Convert.ToDecimal(dgSale.Rows[i].Cells["total"].Value);
            p.Remark = (dgSale.Rows[i].Cells["remark"].Value == null) ? "" : dgSale.Rows[i].Cells["remark"].Value.ToString();
            p.PaymentMethodId = saleOrder.PaymentMethodId;
            p.DateIssue = saleOrder.Date;

            p.CourseByTutor.TutorId = Convert.ToInt32(dgSale.Rows[i].Cells["tutorId"].Value);


            saleOrder.payment[i] = p;
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T10:30:08+00:00Added an answer on May 23, 2026 at 10:30 am

    I have a workaround and solved this question by adding the desired properties e.g. TutorId in the sale.saleOrderItem class. Thus making the direct access to the sale.SaleOrderItem.TutorId.
    This sound stupid but it works.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I need a function that will clean a strings' special characters. I do NOT
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.