Solved

generics problem

Posted on 2013-01-09
6
255 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 75

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 75

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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

895 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

15 Experts available now in Live!

Get 1:1 Help Now