예제 #1
0
        public static void GetTabAndGridExternalColumnValue(int gridTabId, int currentGridBlockId, string referenceIds)
        {
            if (string.IsNullOrEmpty(referenceIds))
            {
                return;
            }

            PdmBlockClrDto dmBlockClrDto = PdmCacheManager.DictBlockCache[currentGridBlockId];

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

            bool IsGetAliasname = false;

            DataTable tabFieldResultDataTable = GetTabDataTable(gridTabId, referenceIds, false, false);
            // Get Grading Size will call PrepareGetGridDataTable and set
            DataTable gridcolumnResultDataTable = PLMSGetGridValueHeler.LoadVariousGridColumnValue(gridTabId, currentGridBlockId, referenceIds, false, dmBlockClrDto, false, false, IsGetAliasname);


            List <string> gridExternalMappingNameList = GetExternalNappingName(gridTabId, currentGridBlockId);


            string firstReferencecolumn = gridcolumnResultDataTable.Columns[0].ColumnName;

            gridExternalMappingNameList.Add(firstReferencecolumn);

            List <string> allCoumns = new List <string>();

            foreach (DataColumn column in gridcolumnResultDataTable.Columns)
            {
                allCoumns.Add(column.ColumnName);
            }

            var needTOremovecolumn = allCoumns.Except(gridExternalMappingNameList);

            foreach (string needToRemove in needTOremovecolumn)
            {
                gridcolumnResultDataTable.Columns.Remove(needToRemove);
            }

            DataTable mergeTable = null;

            if (gridcolumnResultDataTable.Rows.Count > 0)
            {
                mergeTable = DataTableUtility.Join(tabFieldResultDataTable, gridcolumnResultDataTable, tabFieldResultDataTable.Columns[0], gridcolumnResultDataTable.Columns[0]);
            }
            else

            {
                //mergeTable

                foreach (DataColumn gridColumn in gridcolumnResultDataTable.Columns)
                {
                    if (!tabFieldResultDataTable.Columns.Contains(gridColumn.ColumnName))
                    {
                        tabFieldResultDataTable.Columns.Add(gridColumn.ColumnName);
                    }
                }

                mergeTable = tabFieldResultDataTable;
            }



            CLROutput.SendDataTable(mergeTable);
        }
예제 #2
0
        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);
        }