//select EntityID ,EntityCode ,EntityType,SysTableName  from pdmEntity
        public static PdmGridClrDto ConvertDataRowDto(DataRow row)
        {
            PdmGridClrDto aDto = new  PdmGridClrDto();

            aDto.GridId               = (System.Int32)row["GridID"];
            aDto.GridName             = (System.String)row["GridName"];
            aDto.InternalCode         = row["InternalCode"] as System.String;
            aDto.RowHight             = row["RowHight"]  as System.Int32 ? ;
            aDto.Description          = row["Description"] as System.String;
            aDto.IsFixedTableLayout   = row["IsFixedTableLayout"]  as System.Boolean ? ;
            aDto.NewRowViewPosition   = row["NewRowViewPosition"]  as System.Int32 ? ;
            aDto.GridType             = (System.Int32)row["GridType"];
            aDto.ShareSimpleDcuid     = row["ShareSimpleDCUID"]  as System.Int32 ? ;
            aDto.ShareTxRefType       = row["ShareTxRefType"]  as System.Int32 ? ;
            aDto.SubscribeSimpleDcuid = row["SubscribeSimpleDCUID"]  as System.Int32 ? ;
            aDto.FolderId             = row["FolderID"]  as System.Int32 ? ;
            aDto.SearchTemplateId     = row["SearchTemplateID"]  as System.Int32 ? ;
            aDto.IsNeedDefualtRow     = row["IsNeedDefualtRow"]  as System.Boolean ? ;
            aDto.IsAllowToDeleteRow   = row["IsAllowToDeleteRow"]  as System.Boolean ? ;
            aDto.IsAllowToEditRow     = row["IsAllowToEditRow"]  as System.Boolean ? ;
            aDto.IsAllowToAddNewRow   = row["IsAllowToAddNewRow"]  as System.Boolean ? ;
            aDto.IsAllowEmptyRow      = row["IsAllowEmptyRow"]  as System.Boolean ? ;
            aDto.ConceptualTemplateId = row["ConceptualTemplateID"]  as System.Int32 ? ;
            aDto.SystemTimeStamp      = (System.Byte[])row["SystemTimeStamp"];
            aDto.LinePlanningBlockId  = row["LinePlanningBlockID"]  as System.Int32 ? ;
            aDto.CreatedById          = row["CreatedByID"]  as System.Int32 ? ;
            aDto.ModifiedBy           = row["ModifiedBy"]  as System.Int32 ? ;
            aDto.ModifiedDate         = row["ModifiedDate"]  as System.DateTime ? ;
            aDto.CreatedDate          = row["CreatedDate"]  as System.DateTime ? ;
            return(aDto);
        }
        private static List <DataColumn> CollectiontGradingColumn(PdmGridClrDto aPdmGridClrDto, DataTable gridcolumnResultDataTable)
        {
            List <DataColumn> needConvertColumn = new List <DataColumn>();


            foreach (DataColumn column in gridcolumnResultDataTable.Columns)
            {
                int baseSizeColumnId = aPdmGridClrDto[GridRegister.GridSpecGrading.GradingBaseSize].GridColumnId;

                if (column.ColumnName.EndsWith("_" + baseSizeColumnId))
                {
                    needConvertColumn.Add(column);
                }

                int tolColumnId = aPdmGridClrDto[GridRegister.GridSpecGrading.Tolerance].GridColumnId;

                if (column.ColumnName.EndsWith("_" + tolColumnId))
                {
                    needConvertColumn.Add(column);
                }

                for (int i = 1; i <= 20; i++)
                {
                    int sizeColumnIdId = aPdmGridClrDto[GridRegister.GridSpecGrading.GradingSize + i.ToString()].GridColumnId;
                    if (column.ColumnName.EndsWith("_" + sizeColumnIdId))
                    {
                        needConvertColumn.Add(column);
                    }
                }
            }
            return(needConvertColumn);
        }
Exemple #3
0
        private static void ProcessUserDefineEntityColumn(PdmGridClrDto aPdmGridEntity, DataTable toReturnDcuTable, List <SimpleUserDefineEntityRow> listRow, int masterColumnId)
        {
            Dictionary <int, SimpleUserDefineEntityRow> dictRow = listRow.ToDictionary(o => o.RowId, o => o);

            foreach (DataRow dataRow in toReturnDcuTable.Rows)
            {
                string valueId = dataRow[masterColumnId.ToString()] as string;

                CLROutput.OutputDebug("masterColumnId value" + valueId);
                if (!string.IsNullOrEmpty(valueId))
                {
                    // int.Parse (
                    int intValueId = int.Parse(valueId);
                    if (dictRow.ContainsKey(intValueId))
                    {
                        var dtRow = dictRow[intValueId];
                        foreach (var dependentEntityColumn in aPdmGridEntity.MasterEntityDepdentColumn[masterColumnId])
                        {
                            int userDefineColumnId = int.Parse(dependentEntityColumn.InternalCode);

                            //  CLROutput.Output("userDefineColumnId" + userDefineColumnId);

                            object value = ControlTypeValueConverter.ConvertValueToObject(dtRow[userDefineColumnId], dependentEntityColumn.ColumnTypeId);
                            if (value != null)
                            {
                                dataRow[dependentEntityColumn.GridColumnId.ToString()] = value;
                            }
                        }
                    }
                }
            }
        }
        public static void CheckSpecialColumnToInchOrCM(PdmGridClrDto aPdmGridClrDto, DataTable gridcolumnResultDataTable, int referenceId)
        {
            List <DataColumn> needConvertColumn = null;

            if (string.IsNullOrEmpty(aPdmGridClrDto.InternalCode))
            {
                return;
            }



            if (aPdmGridClrDto.InternalCode == GridRegister.GridSpecGrading.SpecGradingGrid)
            {
                needConvertColumn = CollectiontGradingColumn(aPdmGridClrDto, gridcolumnResultDataTable);
            }
            else if (aPdmGridClrDto.InternalCode == GridRegister.GridSpecFit.SpecFitGrid)
            {
                needConvertColumn = CollectiontFitColumn(aPdmGridClrDto, gridcolumnResultDataTable);
            }

            else if (aPdmGridClrDto.InternalCode == GridRegister.GridSpecQC.SpecQCGrid)
            {
                needConvertColumn = CollectiontQcColumn(aPdmGridClrDto, gridcolumnResultDataTable);
            }

            else
            {
                return;
            }


            // need to get the bock size and unit of mesaure;
            //DefaultPOMUnitOfMeasure	1:INch, 2: Cm

            int?pomUnitOfmeasure = GetReferencePomOfUnitMeasure(referenceId);

            if (pomUnitOfmeasure.HasValue && pomUnitOfmeasure.Value == 1)
            {
                ConvertCMDatatableToInch(gridcolumnResultDataTable, needConvertColumn);
            }
            else // NO VALUE, NEED TO CHECK DEFAULT VALUE
            {
                if (PLMConstantString.DictPdmSetup["DefaultPOMUnitOfMeasure"].SetupValue == "1")
                {
                    ConvertCMDatatableToInch(gridcolumnResultDataTable, needConvertColumn);
                }
            }
        }
        public static void GetAllGridSpecailColumnIds(PdmGridClrDto blockPdmGridDto, List <int> allGridRefGridBlockIds, List <int> allGridRefGridColumnIds, List <int> allGridRefSimpleDcuIds)
        {
            // List<PdmGridMetaColumnClrDto> selectedBlockColumnListDto = blockPdmGridDto.PdmGridMetaColumnList;

            CollectOneGridSimpleDcuAndColumnBlockIdColumnId(blockPdmGridDto, allGridRefGridBlockIds, allGridRefGridColumnIds, allGridRefSimpleDcuIds);

            // need to add dependency  Grid key column !
            List <int> allDistinctGridids = PdmCacheManager.GetMutiplePdmGridMetaColumnEntityFromCache(allGridRefGridColumnIds).Select(o => o.GridId).Distinct().ToList();

            foreach (int gridId in allDistinctGridids)
            {
                PdmGridClrDto agridEntity = PdmCacheManager.DictGridCache[gridId];;

                // product grid key column
                foreach (var column in agridEntity.ProductGridForeignKeyColumns)
                {
                    allGridRefGridColumnIds.Add(column.GridColumnId);
                }

                // current ref grid column
                foreach (var column in agridEntity.CurrentRefRegularColumnKeyAndDynamicMatrixKeyDCUColumn)
                {
                    allGridRefGridColumnIds.Add(column.GridColumnId);
                }

                // current grid simple dcu
                foreach (var column in agridEntity.CurrentRefSimpleDCUColumns)
                {
                    allGridRefSimpleDcuIds.Add(column.Dcuid.Value);
                }

                foreach (var column in agridEntity.ProductGridSimpleDCUColumn)
                {
                    allGridRefSimpleDcuIds.Add(column.Dcuid.Value);
                }

                // need to add prodcut grid column and Display column as well

                allGridRefGridColumnIds.AddRange(agridEntity.KeyMetaColumns.Select(o => o.GridColumnId));

                List <int> productGridColumnAndAndDislayColumnIds = GetProductGridColumnAndAndDislayFields(agridEntity);
                allGridRefGridColumnIds.AddRange(productGridColumnAndAndDislayColumnIds);
            }
        }
        private static List <int> GetProductGridColumnAndAndDislayFields(PdmGridClrDto agridEntity)
        {
            List <int> allKeyDisplaySortedColumnIdList = new List <int>();

            if (agridEntity.GridType == (int)EmGridType.ProductBasedGrid)
            {
                allKeyDisplaySortedColumnIdList.Add(agridEntity.ProductGridProductReferenceColumn.GridColumnId);
            }

            var displyacolumnList = agridEntity.PdmGridMetaColumnList.Where(o => o.IsUsedToDisplayProductGridRowInfo.HasValue && o.IsUsedToDisplayProductGridRowInfo.Value).ToList();

            if (displyacolumnList.Count > 0)
            {
                var sortIdList = displyacolumnList.OrderBy(o => o.DisplayProductGridRowInforOrder).Select(o => o.GridColumnId).ToList();

                allKeyDisplaySortedColumnIdList.AddRange(sortIdList);
            }
            return(allKeyDisplaySortedColumnIdList);
        }
        private static void CollectOneGridSimpleDcuAndColumnBlockIdColumnId(PdmGridClrDto blockPdmGridDto, List <int> allGridRefGridBlockIds, List <int> allGridRefGridColumnIds, List <int> allGridRefSimpleDcuIds)
        {
            foreach (PdmGridMetaColumnClrDto column in blockPdmGridDto.PdmGridMetaColumnList)
            {
                // Grid Block Id and Grid column Id
                if (column.DcucolumnBlockId.HasValue)
                {
                    allGridRefGridBlockIds.Add(column.DcucolumnBlockId.Value);
                }

                if (column.DcucolumnId.HasValue)
                {
                    allGridRefGridColumnIds.Add(column.DcucolumnId.Value);
                    GetAllParentDcuBlockIdsAndDcuColumnIds(allGridRefGridBlockIds, allGridRefGridColumnIds, column);
                }

                // Simple DcuIDs
                if (column.Dcuid.HasValue)
                {
                    allGridRefSimpleDcuIds.Add(column.Dcuid.Value);
                }
            }
        }
Exemple #8
0
        private static void ProcessSystemDefineEntityColumn(PdmGridClrDto aPdmGridEntity, DataTable toReturnDcuTable, DataTable aDtResult, int gridColumnId)
        {
            var dictRowId = aDtResult.AsDataRowEnumerable().ToDictionary(dtRow => (int)dtRow["Id"], dtRow => dtRow);

            foreach (DataRow dataRow in toReturnDcuTable.Rows)
            {
                string valueId = dataRow[gridColumnId.ToString()] as string;
                if (!string.IsNullOrEmpty(valueId))
                {
                    // int.Parse (
                    int intValueId = int.Parse(valueId);
                    if (dictRowId.ContainsKey(intValueId))
                    {
                        var dtRow = dictRowId[intValueId];
                        foreach (var dependentEntityColumn in aPdmGridEntity.MasterEntityDepdentColumn[gridColumnId])
                        {
                            foreach (DataColumn aDtcolumn in aDtResult.Columns)
                            {
                                if (aDtcolumn.ColumnName == dependentEntityColumn.InternalCode)
                                {
                                    // cannot pass DataTable column DataType to the silverlight, SL doesn't support Sql.client type data

                                    object value = ControlTypeValueConverter.ConvertValueToObject(dtRow[aDtcolumn], dependentEntityColumn.ColumnTypeId);
                                    if (value != null)
                                    {
                                        dataRow[dependentEntityColumn.GridColumnId.ToString()] = value;
                                    }

                                    //else
                                    //{}
                                }
                            }
                        }
                    }
                }
            }
        }
        public static Dictionary <int, Dictionary <int, List <SimpleGridProductRow> > > RetrieveBlocksReferencesGridColumnsRowList(int[] referenceIds, int[] blockIds, int[] columnIds)
        {
            if (referenceIds.Length == 0 || blockIds.Length == 0 || columnIds.Length == 0)
            {
                return(new Dictionary <int, Dictionary <int, List <SimpleGridProductRow> > >());
            }


            Dictionary <int, List <int> > dictBlockNeedColumnIds = new Dictionary <int, List <int> >();

            foreach (int blockId in blockIds)
            {
                PdmGridClrDto pdmGridClrDto = PdmCacheManager.DictBlockCache[blockId].BlockPdmGridDto;
                //  List<int> needcolumnIds = pdmGridClrDto.PdmGridMetaColumnList.Select(o => o.GridColumnId) .Intersect(columnIds).ToList();

                List <int> needcolumnIds = pdmGridClrDto.PdmGridMetaColumnList.Select(o => o.GridColumnId).ToList();
                dictBlockNeedColumnIds.Add(blockId, needcolumnIds);
            }



            // CLROutput.OutputDebug("Dictionary<int, Dictionary<int, List<SimpleGridProductRow>>> RetrieveBlocksReferencesGridColumnsRowList?? statr"  );
            DataTable dtReferenceGridValue = GetMutipleBlockGridCellValueTable(referenceIds, blockIds, columnIds);

            //   CLROutput.SendDataTable(dtReferenceGridValue);


            var gridColumnQuery = from row in dtReferenceGridValue.AsDataRowEnumerable()
                                  group row by new
            {
                BlockId            = (int)row[GridColumnConstantName.BlockID],
                ProductReferenceId = (int)row[GridColumnConstantName.ProductReferenceID],
                //  RowId = (int)row[GridColumnConstantName.RowID],
                RowValueGUID = row[GridColumnConstantName.RowValueGUID] as Guid?,
                Sort         = (int)row[GridColumnConstantName.Sort],
            } into grp

                select new
            {
                BlockId            = grp.Key.BlockId,
                ProductReferenceId = grp.Key.ProductReferenceId,
                //  RowId = grp.Key.RowId,
                Sort                 = grp.Key.Sort,
                RowValueGUID         = grp.Key.RowValueGUID,
                ColumnIDAndValueList = grp.Select(r => new { GridColumnId = (int)r[GridColumnConstantName.GridColumnID], ValueText = r[GridColumnConstantName.ValueText] }),
            };

            Dictionary <int, Dictionary <int, List <SimpleGridProductRow> > > dictAllBlockRefereRowColumn = new Dictionary <int, Dictionary <int, List <SimpleGridProductRow> > >();

            foreach (int blockId in gridColumnQuery.Select(o => o.BlockId).Distinct())
            {
                Dictionary <int, List <SimpleGridProductRow> > dictOneBlockReferencesRowColumn = new Dictionary <int, List <SimpleGridProductRow> >();

                dictAllBlockRefereRowColumn.Add(blockId, dictOneBlockReferencesRowColumn);

                var oneBlockReferenceList = gridColumnQuery.Where(o => o.BlockId == blockId).ToList();
                var refereceids           = oneBlockReferenceList.Select(o => o.ProductReferenceId).Distinct();

                foreach (var refId in refereceids)
                {
                    List <SimpleGridProductRow> listDto = new List <SimpleGridProductRow>();

                    dictOneBlockReferencesRowColumn.Add(refId, listDto);

                    var oneRefereRowList = oneBlockReferenceList.Where(o => o.ProductReferenceId == refId).ToList();

                    foreach (var gridRow in oneRefereRowList)
                    {
                        SimpleGridProductRow aGridProductRowDto = new SimpleGridProductRow();
                        listDto.Add(aGridProductRowDto);
                        aGridProductRowDto.ProductReferenceId = refId;
                        //  aGridProductRowDto.RowId = gridRow.RowId;
                        aGridProductRowDto.Sort         = gridRow.Sort;
                        aGridProductRowDto.RowValueGuId = gridRow.RowValueGUID;


                        //!!!
                        foreach (var cellValue in gridRow.ColumnIDAndValueList)
                        {
                            object value = cellValue.ValueText;

                            aGridProductRowDto.Add(cellValue.GridColumnId, value);
                        }



                        // if(aGridProductRowDto.ContainColumnId(
                    }


                    if (listDto.Count > 0)
                    {
                        //List<int> needColumnIds = dictBlockNeedColumnIds[blockId];
                        //var rowColumnIds = listDto[0].DictColumnCellValue.Keys;

                        //var listNotInRowColumns = needColumnIds.Except(rowColumnIds);

                        //foreach (SimpleGridProductRow simpleGridProductRow in listDto)
                        //{
                        //    foreach (int columnId in listNotInRowColumns)
                        //    {

                        //        simpleGridProductRow.Add(columnId, null);


                        //    }
                        //}


                        // need to add miss column value place holder

                        List <int> needColumnIds = dictBlockNeedColumnIds[blockId];


                        foreach (SimpleGridProductRow simpleGridProductRow in listDto)
                        {
                            var rowColumnIds = simpleGridProductRow.DictColumnCellValue.Keys;

                            var listNotInRowColumns = needColumnIds.Except(rowColumnIds);

                            foreach (int columnId in listNotInRowColumns)
                            {
                                simpleGridProductRow.Add(columnId, null);
                            }
                        }
                    }
                }
            }

            return(dictAllBlockRefereRowColumn);
        }
Exemple #10
0
        internal static void SetDepdentMasterEntityColumn(PdmGridClrDto aPdmGridEntity, DataTable toReturnDcuTable)
        {
            //var dictSysDefineMasterEntityColumnIdEntityIds = aPdmGridEntity.MasterEntityColumn.Where(col => col.EntityId.HasValue && col.EntityId.Value < 3000).ToDictionary(col => col.GridColumnId, col => col.EntityId.Value);

            Dictionary <int, int> dictUserDefineMasterEntityColumnIdEntityIds = new Dictionary <int, int>();

            foreach (var column in aPdmGridEntity.MasterEntityColumn)
            {
                if (column.EntityId.HasValue)
                {
                    int entityId       = column.EntityId.Value;
                    int masterColumnId = column.GridColumnId;

                    PdmEntityBlClrDto aPdmEntityBlClrDto = PdmCacheManager.DictPdmEntityBlEntity[entityId];
                    if (aPdmEntityBlClrDto.EntityType == (int)EmEntityType.SystemDefineTable)
                    {
                        // int entityId = columnIdEntity.Value;

                        List <string> columnNames = new List <string>();
                        if (aPdmGridEntity.MasterEntityDepdentColumn.ContainsKey(masterColumnId))
                        {
                            columnNames = aPdmGridEntity.MasterEntityDepdentColumn[masterColumnId].Where(o => !string.IsNullOrEmpty(o.InternalCode)).Select(o => o.InternalCode).ToList();
                            DataTable aDtResult = PLMSEntityClrBL.GetMutipleSysDefineEntityRowValue(entityId, columnNames);
                            ProcessSystemDefineEntityColumn(aPdmGridEntity, toReturnDcuTable, aDtResult, masterColumnId);
                        }
                    }
                    else if (aPdmEntityBlClrDto.EntityType == (int)EmEntityType.UserDefineTable)
                    {
                        dictUserDefineMasterEntityColumnIdEntityIds.Add(masterColumnId, entityId);
                    }
                }
            }

            List <int> userDefineColumnIds = new List <int>();

            foreach (var columnIdEntity in dictUserDefineMasterEntityColumnIdEntityIds)
            {
                int masterColumnId = columnIdEntity.Key;
                int entityId       = columnIdEntity.Value;

                var pdmUserDefineEntity = PdmCacheManager.DictPdmEntityBlEntity[entityId];

                if (aPdmGridEntity.MasterEntityDepdentColumn.ContainsKey(masterColumnId))
                {
                    // if (aDtcolumn.UserDefineEntityColumnId.ToString() == dependentEntityColumn.InternalCode)
                    var columnids = aPdmGridEntity.MasterEntityDepdentColumn[masterColumnId]
                                    .Where(o => !string.IsNullOrEmpty(o.InternalCode))
                                    .Select(o => int.Parse(o.InternalCode.Trim()));

                    userDefineColumnIds.AddRange(columnids);
                }
            }
            if (userDefineColumnIds.Count > 0)
            {
                // Key: EntityId, vlaue
                Dictionary <int, List <SimpleUserDefineEntityRow> > result = PLMSEntityClrBL.GetDictEntityUserDefineRows(dictUserDefineMasterEntityColumnIdEntityIds.Values.ToList(), userDefineColumnIds);

                foreach (var columnIdEntity in dictUserDefineMasterEntityColumnIdEntityIds)
                {
                    int masterColumnId = columnIdEntity.Key;
                    int entityId       = columnIdEntity.Value;
                    if (result.ContainsKey(entityId))
                    {
                        List <SimpleUserDefineEntityRow> listRow = result[entityId];

                        CLROutput.OutputDebug("masterColumnId =" + masterColumnId);

                        ProcessUserDefineEntityColumn(aPdmGridEntity, toReturnDcuTable, listRow, masterColumnId);
                    }
                }
            }
        }
        private static List <DataColumn> CollectiontFitColumn(PdmGridClrDto aPdmGridClrDto, DataTable gridcolumnResultDataTable)
        {
            List <DataColumn> needConvertColumn = new List <DataColumn>();


            foreach (DataColumn column in gridcolumnResultDataTable.Columns)
            {
                int initialSpecColumnId = aPdmGridClrDto[GridRegister.GridSpecFit.InitiaSpec].GridColumnId;

                if (column.ColumnName.EndsWith("_" + initialSpecColumnId))
                {
                    needConvertColumn.Add(column);
                }


                int initialSampleSpecColumnId = aPdmGridClrDto[GridRegister.GridSpecFit.SampleInitiaSpec].GridColumnId;

                if (column.ColumnName.EndsWith("_" + initialSampleSpecColumnId))
                {
                    needConvertColumn.Add(column);
                }



                int finalSpecColumnId = aPdmGridClrDto[GridRegister.GridSpecFit.FinalSpec].GridColumnId;

                if (column.ColumnName.EndsWith("_" + finalSpecColumnId))
                {
                    needConvertColumn.Add(column);
                }



                int tolColumnId = aPdmGridClrDto[GridRegister.GridSpecFit.Tolerance].GridColumnId;

                if (column.ColumnName.EndsWith("_" + tolColumnId))
                {
                    needConvertColumn.Add(column);
                }

                for (int i = 1; i <= 6; i++)
                {
                    int revisedColumnId = aPdmGridClrDto[GridRegister.GridSpecFit.Revise + i.ToString()].GridColumnId;
                    if (column.ColumnName.EndsWith("_" + revisedColumnId))
                    {
                        needConvertColumn.Add(column);
                    }

                    int sampleColumnId = aPdmGridClrDto[GridRegister.GridSpecFit.Sample + i.ToString()].GridColumnId;
                    if (column.ColumnName.EndsWith("_" + sampleColumnId))
                    {
                        needConvertColumn.Add(column);
                    }

                    int samplesampleColumnId = aPdmGridClrDto[GridRegister.GridSpecFit.Sample + i.ToString() + i.ToString()].GridColumnId;
                    if (column.ColumnName.EndsWith("_" + samplesampleColumnId))
                    {
                        needConvertColumn.Add(column);
                    }


                    int diffColumnId = aPdmGridClrDto[GridRegister.GridSpecFit.Difference + i.ToString()].GridColumnId;
                    if (column.ColumnName.EndsWith("_" + diffColumnId))
                    {
                        needConvertColumn.Add(column);
                    }

                    int diffdiffColumnId = aPdmGridClrDto[GridRegister.GridSpecFit.Difference + i.ToString() + i.ToString()].GridColumnId;
                    if (column.ColumnName.EndsWith("_" + diffdiffColumnId))
                    {
                        needConvertColumn.Add(column);
                    }



                    //int diffSampleColumnId = aPdmGridClrDto[GridRegister.GridSpecFit.DiffSample + i.ToString()].GridColumnId;
                    //if (column.ColumnName.EndsWith("_" + diffSampleColumnId))
                    //{
                    //    needConvertColumn.Add(column);
                    //}
                }
            }
            return(needConvertColumn);
        }
        //blockPdmGridDto, gridcolumnResultDataTable


        public static void SetupBodypartName(PdmGridClrDto aPdmGridClrDto, DataTable gridcolumnResultDataTable)
        {
            if (string.IsNullOrEmpty(aPdmGridClrDto.InternalCode))
            {
                return;
            }

            // get all colunName



            if (!(
                    aPdmGridClrDto.InternalCode == GridRegister.GridSpecGrading.SpecGradingGrid ||
                    aPdmGridClrDto.InternalCode == GridRegister.GridSpecFit.SpecFitGrid ||
                    aPdmGridClrDto.InternalCode == GridRegister.GridSpecQC.SpecQCGrid

                    ))
            {
                return;
            }


            string PomSketchIDColumnName = "PomSketchID";

            gridcolumnResultDataTable.Columns.Add(PomSketchIDColumnName);

            DataColumn bodypartIdColumn    = null;
            DataColumn bodypartCodeColumn  = null;
            DataColumn bodypartNameColumn  = null;
            DataColumn bodypartDescColumn  = null;
            DataColumn bodypartHowToColumn = null;



            foreach (DataColumn column in gridcolumnResultDataTable.Columns)
            {
                int idColumnId = aPdmGridClrDto[GridRegister.GridSpecFit.BodyPartDetailIDWDimDetailID].GridColumnId;

                if (column.ColumnName.EndsWith("_" + idColumnId))
                {
                    bodypartIdColumn = column;
                }



                int codeColumnId = aPdmGridClrDto[GridRegister.GridSpecFit.BodyPartCustomerCode].GridColumnId;

                if (column.ColumnName.EndsWith("_" + codeColumnId))
                {
                    bodypartCodeColumn = column;
                }



                int nameColumnId = aPdmGridClrDto[GridRegister.GridSpecFit.BodyPartName].GridColumnId;

                if (column.ColumnName.EndsWith("_" + nameColumnId))
                {
                    bodypartNameColumn = column;
                }


                int descColumnId = aPdmGridClrDto[GridRegister.GridSpecFit.BodyPartDesc].GridColumnId;

                if (column.ColumnName.EndsWith("_" + descColumnId))
                {
                    bodypartDescColumn = column;
                }


                int howtoColumnId = aPdmGridClrDto[GridRegister.GridSpecFit.HowToMeasure].GridColumnId;

                if (column.ColumnName.EndsWith("_" + howtoColumnId))
                {
                    bodypartHowToColumn = column;
                }
            }

            // gridcolumnResultDataTable.AsDataRowEnumerable ().Select (o=>o

            Dictionary <DataRow, int> dictRowAndBodypartIdForColumnResultDataTable = new Dictionary <DataRow, int>();
            List <int> bodypartIds = new List <int> ();

            foreach (DataRow aRow in gridcolumnResultDataTable.Rows)
            {
                int?bodyparid = ControlTypeValueConverter.ConvertValueToInt(aRow[bodypartIdColumn]);
                if (bodyparid.HasValue)
                {
                    bodypartIds.Add(bodyparid.Value);
                    dictRowAndBodypartIdForColumnResultDataTable.Add(aRow, bodyparid.Value);
                }
            }

            if (bodypartIds.Count > 0)
            {
                string query    = @" select BodyPartID , Code , BodyPartName ,Description ,MeasureInstruction,SketchID from pdmV2kBodyPart ";
                string inclause = DataAcessHelper.GenerateColumnInClauseWithAndCondition(bodypartIds.Distinct(), "BodyPartID", false);
                query = query + " where " + inclause;

                DataTable bodypartDataTable = null;
                using (SqlConnection conn = new SqlConnection(PLMConstantString.PLM_APP_ConnectionString))
                {
                    conn.Open();
                    bodypartDataTable = DataAcessHelper.GetDataTableQueryResult(conn, query);
                }

                Dictionary <int, DataRow> dictbodyRowAndId = new Dictionary <int, DataRow>();
                foreach (DataRow aDataRow in bodypartDataTable.Rows)
                {
                    dictbodyRowAndId.Add((int)aDataRow["BodyPartID"], aDataRow);
                }


//           EnablePomCodeSynchonizeWithProduct
//EnablePomNameSynchonizeWithProduct
//EnablePomDescriptionSynchonizeWithProduct
//EnablePomMeasureInstrcutionSynchonizeWithProduct

                bool isEnableCode    = PLMConstantString.DictPdmSetup["EnablePomCodeSynchonizeWithProduct"].SetupValue.ToLower() == "true";
                bool isEnableName    = PLMConstantString.DictPdmSetup["EnablePomNameSynchonizeWithProduct"].SetupValue.ToLower() == "true";
                bool isEnableDesc    = PLMConstantString.DictPdmSetup["EnablePomDescriptionSynchonizeWithProduct"].SetupValue.ToLower() == "true";
                bool isEnableMeasure = PLMConstantString.DictPdmSetup["EnablePomMeasureInstrcutionSynchonizeWithProduct"].SetupValue.ToLower() == "true";


                foreach (DataRow gridRow in dictRowAndBodypartIdForColumnResultDataTable.Keys)
                {
                    int bodyId = dictRowAndBodypartIdForColumnResultDataTable[gridRow];
                    if (dictbodyRowAndId.ContainsKey(bodyId))
                    {
                        DataRow bodyparRow = dictbodyRowAndId[bodyId];
                        if (isEnableCode)
                        {
                            gridRow[bodypartCodeColumn] = bodyparRow["Code"] as string;
                        }

                        if (isEnableName)
                        {
                            gridRow[bodypartNameColumn] = bodyparRow["BodyPartName"] as string;
                        }

                        if (isEnableDesc)
                        {
                            gridRow[bodypartDescColumn] = bodyparRow["Description"] as string;
                        }

                        if (isEnableMeasure)
                        {
                            gridRow[bodypartHowToColumn] = bodyparRow["MeasureInstruction"] as string;
                        }


                        gridRow[PomSketchIDColumnName] = bodyparRow["SketchID"] as int?;
                    }
                }
            }
        }
        public static void GetGradingSizeValue(int tabId, int currentGridBlockId, int referenceId)
        {
            //if (string.IsNullOrEmpty(referenceId))
            //    return;

            PdmBlockClrDto dmBlockClrDto = PdmCacheManager.DictBlockCache[currentGridBlockId];

            if (dmBlockClrDto.BlockPdmGridDto == null)
            {
                return;
            }

            bool      IsGetAliasname            = true;
            DataTable gridcolumnResultDataTable = PLMSGetGridValueHeler.LoadVariousGridColumnValue(tabId, currentGridBlockId, referenceId.ToString(), true, dmBlockClrDto, false, true, IsGetAliasname);

            int baseSizeIndexFromZero = 0;
            int totalSizeNumber       = 0;



            using (SqlConnection conn = new SqlConnection(PLMConstantString.PLM_APP_ConnectionString))
            {
                //SqlContext.
                conn.Open();
                DataAcessHelper.ExecuteReadUnCommmited(conn);
                PLMSpecGradingHelper.GetSpecSizeRunTable(referenceId, conn, out baseSizeIndexFromZero, out totalSizeNumber);
                CLROutput.OutputDebug("baseSizeIndexFromZero" + baseSizeIndexFromZero.ToString() + "totalSizeNumber" + totalSizeNumber.ToString());

                DataAcessHelper.ExecuteReadCommmited(conn);
            }

            PdmGridClrDto aPdmGridClrDto = dmBlockClrDto.BlockPdmGridDto;

            int baseSizeColumnId = aPdmGridClrDto[GridRegister.GridSpecGrading.GradingBaseSize].GridColumnId;

            List <DataColumn> gradingSizeNameList = new List <DataColumn>();
            DataColumn        baseSizeColumn      = null;

            foreach (DataColumn column in gridcolumnResultDataTable.Columns)
            {
                if (column.ColumnName.StartsWith(GridRegister.GridSpecGrading.GradingSize))
                {
                    gradingSizeNameList.Add(column);
                }
                if (column.ColumnName.EndsWith("_" + baseSizeColumnId))
                {
                    baseSizeColumn = column;
                }
            }


            //GridRegister.GridSpecGrading.


            foreach (DataRow dataRow in gridcolumnResultDataTable.Rows)
            {
                List <double> gradingValue = new List <double>();
                List <String> columnName   = new List <string>();
                double        basesize     = ControlTypeValueConverter.ConvertValueToDoubleWithDefautZero(dataRow[baseSizeColumn.ColumnName]);

                for (int i = 1; i <= totalSizeNumber; i++)
                {
                    foreach (DataColumn sizecolumn in gradingSizeNameList)
                    {
                        string baseSizeColumnName = GridRegister.GridSpecGrading.GradingSize + i.ToString() + "_";
                        if (sizecolumn.ColumnName.StartsWith(baseSizeColumnName))
                        {
                            double value = ControlTypeValueConverter.ConvertValueToDoubleWithDefautZero(dataRow[sizecolumn.ColumnName]);

                            gradingValue.Add(value);
                            columnName.Add(sizecolumn.ColumnName);
                        }
                    }
                }

                List <double> newValueList = PLMSpecGradingHelper.CaculateSizeValueWithGradingValue(gradingValue, basesize, baseSizeIndexFromZero);
                for (int i = 0; i < totalSizeNumber; i++)
                {
                    string columnNmae = columnName[i];
                    string value      = newValueList[i].ToString();

                    dataRow[columnNmae] = value;
                }
            }


            List <DataColumn> needConvertColumn = new List <DataColumn>();


            foreach (DataColumn column in gridcolumnResultDataTable.Columns)
            {
                int baseSizeId = aPdmGridClrDto[GridRegister.GridSpecGrading.GradingBaseSize].GridColumnId;

                if (column.ColumnName.EndsWith("_" + baseSizeColumnId))
                {
                    needConvertColumn.Add(column);
                }

                int tolColumnId = aPdmGridClrDto[GridRegister.GridSpecGrading.Tolerance].GridColumnId;

                if (column.ColumnName.EndsWith("_" + tolColumnId))
                {
                    needConvertColumn.Add(column);
                }

                for (int i = 1; i <= 20; i++)
                {
                    int sizeColumnIdId = aPdmGridClrDto[GridRegister.GridSpecGrading.GradingSize + i.ToString()].GridColumnId;
                    if (column.ColumnName.EndsWith("_" + sizeColumnIdId))
                    {
                        needConvertColumn.Add(column);
                    }
                }
            }


            // need to get the bock size and unit of mesaure;
            //DefaultPOMUnitOfMeasure	1:INch, 2: Cm

            int?pomUnitOfmeasure = GetReferencePomOfUnitMeasure(referenceId);

            if (pomUnitOfmeasure.HasValue && pomUnitOfmeasure.Value == 1)
            {
                ConvertCMDatatableToInch(gridcolumnResultDataTable, needConvertColumn);
            }
            else // NO VALUE, NEED TO CHECK DEFAULT VALUE
            {
                if (PLMConstantString.DictPdmSetup["DefaultPOMUnitOfMeasure"].SetupValue == "1")
                {
                    ConvertCMDatatableToInch(gridcolumnResultDataTable, needConvertColumn);
                }
            }



            CLROutput.SendDataTable(gridcolumnResultDataTable);
        }