Click here to Skip to main content
15,895,084 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
while i get char A or R from database , i needed replace to "Approved" or "Rejected" this word. but iziit using if else statement to retrieve output, or got other solution?

Please kindly advise, thanks alot.

public DataTable GetQuotationInfo(int QuotationId)
    {

        FADB db = new FADB();

        DataTable dt = new DataTable();
        dt.Columns.Add("QuotationId");
        dt.Columns.Add("ServiceOrderNo");
        dt.Columns.Add("Date");
        dt.Columns.Add("Name");
        dt.Columns.Add("OnwerAddress");
        dt.Columns.Add("QuotationNo");
        dt.Columns.Add("Premises");
        dt.Columns.Add("PayableTo");
        dt.Columns.Add("Status");

        dt = (from q in db.Csm_quotations
              join j in db.Csm_quotation_jobs on q.QuotationId equals j.QuotationId
              join c in db.Csm_complaints on q.ComplaintId equals c.ComplaintID
              join f in db.Fa_lots on c.UnitId equals f.UnitId
              join o in db.Sys_owners on f.OwnerId equals o.OwnerId

              group new { q,j,c,f,o } by new { q.QuotationId,c.ComplaintCode,q.QuotationDate,q.QuotationSubject,q.PayableTo,q.Status,f.OwnerAddress,f.Address,o.OwnerName }
              into grp
              where grp.Key.QuotationId == Convert.ToUInt16(QuotationId)
             select new
              {

            QuotationId = grp.Key.QuotationId,
            ServiceOrderNo = grp.Key.ComplaintCode,
            Date = grp.Key.QuotationDate.ToString("dd/MM/yyyy"),
            Name = grp.Key.OwnerName,
            OnwerAddress =grp.Key.OwnerAddress,
            QuotationNo = grp.Key.QuotationSubject,
            Premises = grp.Key.Address,
            PayableTo = grp.Key.PayableTo,
            Status =  select new { grp.Key.Status = 'A' ? "Approved" : grp.Key.Status = 'R' ? "Rejected"}; /// having problem on this issue


              }).ToDataTable();
        return dt;
Posted
Updated 1-Sep-13 22:57pm
v2
Comments
Maarten Kools 2-Sep-13 4:23am    
And the problem is....?
kangyi.lee 2-Sep-13 4:39am    
cant implicitly convert type 'char' to 'bool' error msg
Maarten Kools 2-Sep-13 4:46am    
If grp.Key.Status can be only A or R, then you can change it to grp.Key.Status == 'A' ? "Approved" : "Rejected" (note the == in the statement, that's what your error message is about). In case it can also be something else, you're still missing something in your statement. You'd have to do something like this: grp.Key.Status == 'A' ? "Approved" : grp.Key.Status == 'R' ? "Rejected" : "Unknown"
kangyi.lee 2-Sep-13 4:49am    
but is show cant convert 'char' to 'string' , that why i very blur now
Maarten Kools 2-Sep-13 4:50am    
Is grp.Key.Status a String or char? If it's a string, compare with "A", if it's a char, use 'A'.

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