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

    Retreive Generic List class values

    I trying to pull out the values from a genericlist class. The values are being properly added to the list. I would like to interigate the values for verifying the required information has been entered prior to committing the the database.

    Here is my genericlist class:

    public class _QACertGenericList
    {

    public static string QACert_AssemblyRoushSerialNumber { get; set; }
    public static int QACert_AssemblyTypeUID { get; set; }
    public static string QACert_Description { get; set; }
    public static bool QACert_CheckedFlag { get; set; }
    public static bool QACert_IsCheckVerifyOnlyRequiredFlag { get; set; }
    public static string QACert_ScannedValue { get; set; }
    public static bool QACert_IsScanRequiredFlag { get; set; }
    public static string QACert_EmployeeID { get; set; }

    //********************************************************
    //* BuildQACertArray
    //********************************************************
    #region "BuildQACertArray"

    public static List<_QACertGenericList> BuildQACertArray(List<_QACertGenericList> QACertArray,
    String AssemblyRoushSerialNumber,
    int AssemblyTypeUID,
    String Description,
    bool CheckedFlag,
    bool IsCheckVerifyOnlyRequiredFlag,
    String ScannedValue,
    bool IsScanRequiredFlag,
    String EmployeeID)
    {
    _QACertGenericList _qaCertGenericList = new _QACertGenericList();
    // _QACert _qaCert = new _QACert();

    QACert_AssemblyRoushSerialNumber = AssemblyRoushSerialNumber;
    QACert_AssemblyTypeUID = AssemblyTypeUID;
    QACert_CheckedFlag = CheckedFlag;
    QACert_Description = Description;
    QACert_EmployeeID = EmployeeID;
    QACert_IsCheckVerifyOnlyRequiredFlag = IsCheckVerifyOnlyRequiredFlag;
    QACert_IsScanRequiredFlag = IsScanRequiredFlag;
    QACert_ScannedValue = ScannedValue;

    if (!(QACertArray == null))
    {
    QACertArray.Add(_qaCertGenericList);
    return QACertArray;
    }
    else
    {
    List<_QACertGenericList> QACertGenericList = new List<_QACertGenericList>();

    QACertGenericList.Add(_qaCertGenericList);

    return QACertGenericList;
    }
    }

    Here is the code that calls the generic list class:

    private void gvQAChecklist_CellEndEdit(object sender, DataGridViewCellEventArgs e)
    {
    int iCol = e.ColumnIndex;
    int iRow = e.RowIndex;

    //* QA Checklist
    CleanTechTraceabilityDS.ContentMGTQACheckListDataTable QACheckListDT =
    new CleanTechTraceabilityDS.ContentMGTQACheckListDataTable();

    _QAChecklistVerification _qaChecklistVerification = new _QAChecklistVerification();

    bool LoadQACheckListFlag = _qaChecklistVerification.LoadQAChecklist(4,
    ref QACheckListDT);

    if (!(LoadQACheckListFlag))
    {
    lblerrorMSG.Text = "Load QA Check list failed";
    return;
    }

    if (!(QACheckListDT.Count > 0))
    {
    lblerrorMSG.Text = "No QA checklist items found";
    return;
    }

    List<_QACertGenericList> QACertGenericList = new List<_QACertGenericList>();

    int i = 0;

    int VerificationNeedCount = this.gvQAChecklist.RowCount;
    //int VerifiedCount = 0;

    foreach (CleanTechTraceabilityDS.ContentMGTQACheckListRow QACheckListDR in QACheckListDT.Rows)
    {
    QACertGenericList = _QACertGenericList.BuildQACertArray(QACertGenericList,
    lblRoushSerialNo.Text,
    Convert.ToInt32(QACheckListDR["AssemblyType_UID"]),
    Convert.ToString(gvQAChecklist.Rows[i].Cells[0].Value),
    Convert.ToBoolean(gvQAChecklist.Rows[i].Cells[1].Value),
    Convert.ToBoolean(QACheckListDR["IsCheckVerifyRequiredFlag"]),
    Convert.ToString(gvQAChecklist.Rows[i].Cells[2].Value),
    Convert.ToBoolean(QACheckListDR["IsScanVerifyRequiredFlag"]),
    Convert.ToString(gvQAChecklist.Rows[i].Cells[3].Value));

    // THIS IS WHERE I WOULD LIKE TO INTERIGATE THE GENERIC LIST VALUES

    var theArray = QACertGenericList.ToArray();

    foreach (var item in theArray)
    {
    object inloop = item;
    }

    i++;

    };

    object test = QACertGenericList.ToArray();


    }

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Retreive Generic List class values

    Code:
    public class _QACertGenericList
    {
    
    public static string QACert_AssemblyRoushSerialNumber { get; set; }
    public static int QACert_AssemblyTypeUID { get; set; }
    public static string QACert_Description { get; set; }
    public static bool QACert_CheckedFlag { get; set; }
    public static bool QACert_IsCheckVerifyOnlyRequiredFlag { get; set; }
    public static string QACert_ScannedValue { get; set; }
    public static bool QACert_IsScanRequiredFlag { get; set; }
    public static string QACert_EmployeeID { get; set; }
    You're going to have trouble with this code if there is ever more than one instance of the _QACertGenericList class - in other words, the properties should probably not be static.

    Btw, naming your class with a leading '_' is a bit funky (although you have the right to name your classes however you want). Generally the naming convention for classes is PascalCasing (e.g. _QACertGenericList becomes QACertGenericList).

  3. #3
    Join Date
    Oct 2011
    Posts
    2

    Re: Retreive Generic List class values

    Driving home yesterday, after serveral hours struggling with this, I had the same thought about removing static. I also thought of a couple other options that would work, but did not like as much. It's working now... Thank you very much!

Tags for this Thread

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