예제 #1
0
        /// <summary>
        /// todoComment
        /// </summary>
        public void FillTempPartnerTypesTable()
        {
            DataTable SelectedPartnerTypeTable;
            DataView  SelectedPartnerTypeTableDV;
            DataView  UnselectedPartnerTypeTableDV;
            DataRow   TheNewRow;
            Int16     RowCounter;
            String    TypeDescription;
            Int32     TypeDescriptionInCachePosition;

            // TODO 2 oChristianK cList Sorting : Sort both the checked and not checked List items so that invalid Types are sorted to the end of both lists, respectively.

            FPartnerTypesGridTable.Rows.Clear();
            FPartnerTypesGridTable.AcceptChanges();

            // Sort data
            SelectedPartnerTypeTable        = FMainDS.PPartnerType;
            SelectedPartnerTypeTableDV      = SelectedPartnerTypeTable.DefaultView;
            SelectedPartnerTypeTableDV.Sort = PTypeTable.GetTypeCodeDBName();

            UnselectedPartnerTypeTableDV      = FDataCache_PartnerTypeListTable.DefaultView;
            UnselectedPartnerTypeTableDV.Sort = PTypeTable.GetTypeCodeDBName();

            // first add Special Types which are already selected for partner
            for (RowCounter = 0; RowCounter <= SelectedPartnerTypeTableDV.Count - 1; RowCounter += 1)
            {
                #region Determine Type Description
                TypeDescriptionInCachePosition =
                    FDataCache_PartnerTypeListDV.Find(SelectedPartnerTypeTableDV[RowCounter][PTypeTable.GetTypeCodeDBName()]);

                if (TypeDescriptionInCachePosition != -1)
                {
                    TypeDescription = FDataCache_PartnerTypeListDV[TypeDescriptionInCachePosition][PTypeTable.GetTypeDescriptionDBName()].ToString();

                    // If this Type is inactive, show it.
                    if (!Convert.ToBoolean(FDataCache_PartnerTypeListDV[TypeDescriptionInCachePosition][PTypeTable.GetValidTypeDBName()]))
                    {
                        TypeDescription = TypeDescription + MCommonResourcestrings.StrGenericInactiveCode;
                    }
                }
                else
                {
                    TypeDescription = "";
                }

                #endregion

                TheNewRow                    = FPartnerTypesGridTable.NewRow();
                TheNewRow["Checked"]         = (System.Object)true;
                TheNewRow["TypeCode"]        = SelectedPartnerTypeTableDV[RowCounter][PTypeTable.GetTypeCodeDBName()];
                TheNewRow["TypeDescription"] = TypeDescription;
                FPartnerTypesGridTable.Rows.Add(TheNewRow);
            }

            // second add the rest of the Special Types in db
            for (RowCounter = 0; RowCounter <= UnselectedPartnerTypeTableDV.Count - 1; RowCounter += 1)
            {
                // only add row if it has not already been added as a checked row
                if (SelectedPartnerTypeTableDV.Find(
                        new object[] { UnselectedPartnerTypeTableDV[RowCounter][PTypeTable.GetTypeCodeDBName()] }) == -1)
                {
                    #region Determine Type Description
                    TypeDescription = UnselectedPartnerTypeTableDV[RowCounter][PTypeTable.GetTypeDescriptionDBName()].ToString();

                    // If this Type is inactive, show it.
                    if (!Convert.ToBoolean(UnselectedPartnerTypeTableDV[RowCounter][PTypeTable.GetValidTypeDBName()]))
                    {
                        TypeDescription = TypeDescription + MCommonResourcestrings.StrGenericInactiveCode;
                    }

                    #endregion

                    TheNewRow                    = FPartnerTypesGridTable.NewRow();
                    TheNewRow["Checked"]         = (System.Object)false;
                    TheNewRow["TypeCode"]        = UnselectedPartnerTypeTableDV[RowCounter][PTypeTable.GetTypeCodeDBName()];
                    TheNewRow["TypeDescription"] = TypeDescription;
                    FPartnerTypesGridTable.Rows.Add(TheNewRow);
                }
            }
        }