Solved

generics problem

Posted on 2013-01-09
6
254 Views
Last Modified: 2013-01-09
I am trying to fill a generic list the intellisence tells me everything is what it is asking for but it keeps giving me an error
System.Collections.Generic.List<PlmData.POLineData>.List(int)' has some invalid arguments
                int polinekey = Convert.ToInt32(e.Row.Cells["polinekey"].Value);
                PlmData.PO p = new PlmData.PO();
                List<PlmData.POLineData> dd = new List<PlmData.POLineData>(p.GetPODetails(polinekey));               try
                {
                    qcd.custname = dd[0].CustName;
                    qcd.factory = dd[0].Factory;

Open in new window

any help would be greatly appreciated
0
Comment
Question by:r3nder
  • 3
  • 2
6 Comments
 
LVL 74

Expert Comment

by:käµfm³d 👽
ID: 38758917
What type of object does "p.GetPODetails" return?
0
 
LVL 6

Author Comment

by:r3nder
ID: 38758997
       public PODetailsData GetPODetails(int poLineKey)
        {
            PODetailsData result = null;

            string sql = @"   select cast(cast(POnumber as int) as varchar)  as ponumber,Custid,poluid";
            sql += @" ,upper(Custid) as custid,upper(custname) as custname   ";
            sql += @",upper(vpo.custpo) as custpo,upper(Itemid) as itemid,Upper(description) as description ";
            sql += @",PODate, vpo.leadtime ,promisedate   ";
            sql += @",Upper(factory) as factory,companyid";
            sql += @",vpo.polinekey  ,Upper(vpo.Vendid) as vendid ";
            sql += @",vpo.pokey,purchamt ,fobid,NULLIF (QCBegDate, '01/01/1900') AS QCBegDate,NULLIF (QCEndDate, '01/01/1900') as QCEndDate ";
            sql += @",isNull(CuttingQuantity,0) as cuttingQty ";
            sql += @",	isNull(PaintedQuantity,0) PaintedQty ,	isnull(AssembledQuantity,0) assembledQty ";
            sql += @",	isnull(PackedOutQuantity,0) packedQty ";
            sql += @",	lvbl.saildate,lvbl.etaport eta,lvbl.etdport etd,isnull(lvbl.vbexists,0) as vbexists,isnull(pld.POLStatusID,0) POLStatusID  ";
            sql += @",	lvbl.cargoreturndt  ";
            sql += @"from vPOAllDetailswithCust vpo          ";
            sql += @" left outer join POLDetails pld on pld.polinekey = vpo.polinekey ";
            sql += @" left join vLatestVesselBooking lvbl on lvbl.polinekey = vpo.POLineKey";

            sql += @" Where vpo.polinekey=" + poLineKey;

            using (SqlConnection conn = new SqlConnection(DBConnectionString.Get(Database.TaskManager)))
            {
                SqlCommand cmd = new SqlCommand(sql, conn);
                cmd.CommandType = CommandType.Text;

                conn.Open();

                SqlDataReaderHelper reader = new SqlDataReaderHelper(cmd.ExecuteReader());
                if (reader != null && reader.IsValid)
                {
                    while (reader.Read())
                    {
                        result = new PODetailsData()
                        {
                            PONumber = reader.GetString("PONumber", ""),
                            //AcctMgrID = reader.GetString("AcctMgrID", ""),
                            CustID = reader.GetString("CustID", ""),
                            PolUID = reader.GetInt("PolUID", 0),
                            CustName = reader.GetString("CustName", ""),
                            CustPO = reader.GetString("CustPO", ""),
                            ItemID = reader.GetString("ItemID", ""),
                            Description = reader.GetString("Description", ""),
                            PODate = reader.GetNullableDateTime("PODate"),
                            LeadTime = reader.GetInt("LeadTime", 0),
                            PromiseDate = reader.GetNullableDateTime("PromiseDate"),
                            //ProdBoxArtDT = reader.GetNullableDateTime("ProdBoxArtDT"),
                            //ProdMcDT = reader.GetNullableDateTime("ProdMcDT"),
                            //ProdCustTestingDT = reader.GetNullableDateTime("ProdCustTestingDT"),
                            //ProdMTSInspectDT = reader.GetNullableDateTime("ProdMTSInspectDT"),
                            Factory = reader.GetString("Factory", ""),
                            CompanyID = reader.GetString("CompanyID", ""),
                            POLineKey = reader.GetInt("POLineKey", 0),
                            //IdeaUID = reader.GetInt("IdeaUID", 0),
                            VendID = reader.GetString("VendID", ""),
                            POKey = reader.GetInt("POKey", 0),
                            PurchAmt = reader.GetDecimal("PurchAmt", 0),
                            FobID = reader.GetString("FobID", ""),
                            QCBegDate = reader.GetNullableDateTime("QCBegDate"),
                            QCEndDate = reader.GetNullableDateTime("QCEndDate"),
                            CuttingQuantity = reader.GetInt("CuttingQty", 0),
                            PaintedQuantity = reader.GetInt("PaintedQty", 0),
                            AssembledQuantity = reader.GetInt("AssembledQty", 0),
                            PackedOutQuantity = reader.GetInt("PackedQty", 0),
                            SailDate = reader.GetNullableDateTime("SailDate"),
                            EtaPort = reader.GetNullableDateTime("Eta"),
                            EtdPort = reader.GetNullableDateTime("Etd"),
                            VBExists = reader.GetBool("VBExists", false),
                            POLStatusID = reader.GetInt("POLStatusID", 0),
                            cargoreturndt = reader.GetNullableDateTime("cargoreturndt")
                        };
                    }
                }

                conn.Close();
            }

            return result;
        }

Open in new window

0
 
LVL 74

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 38759079
Youre attempting to stick a PODetailsData object into a list that is expecting PlmData.POLineData objects. Also, the overload you are looking for takes in an array or another list of objects, not a single object, which is what your function returns.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 44

Expert Comment

by:AndyAinscow
ID: 38759233
I know you aren't going to be interested but here goes anyway.  I'd suggest you have a look about collections in the help files - specifically about how to use them.  (Obviously you didn't understand the advice given to you in your previous question after all).
0
 
LVL 6

Author Comment

by:r3nder
ID: 38759296
Got it
               int polinekey = Convert.ToInt32(e.Row.Cells["polinekey"].Value);
                PlmData.PO p = new PlmData.PO();
                PlmData.PODetailsData dd = new PlmData.PODetailsData();
                dd = p.GetPODetails(polinekey);
0
 
LVL 6

Author Closing Comment

by:r3nder
ID: 38760348
POBindingSource.DataSource = DataContext;
DataContext = _detailsData;
int polinekey = Convert.ToInt32(e.Row.Cells["polinekey"].Value);
                PlmData.PO p = new PlmData.PO();
                PlmData.PODetailsData dd = new PlmData.PODetailsData();
                dd = p.GetPODetails(DataContext,polinekey);
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

A short article about problems I had with the new location API and permissions in Marshmallow
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now