Exemplo n.º 1
0
        //select EntityID ,EntityCode ,EntityType,SysTableName  from pdmEntity
        public static PdmClrEntitySimpleStructureDto ConvertRowToPdmEntityDto(DataRow row)
        {
            PdmClrEntitySimpleStructureDto aPdmEntityDto = new PdmClrEntitySimpleStructureDto();

            aPdmEntityDto.EntityId     = (int)row["EntityID"];
            aPdmEntityDto.EntityCode   = (string)row["EntityCode"];
            aPdmEntityDto.EntityType   = row["EntityType"] as int?;
            aPdmEntityDto.SysTableName = row["SysTableName"] as string;

            return(aPdmEntityDto);
        }
Exemplo n.º 2
0
        //TODO
        public static void GenetateEntityDTOQuery(PdmClrEntitySimpleStructureDto aEntityDTO, SqlConnection conn)
        {
            List <PdmEntityColumnClrUserDefineDto> listColumnDto = aEntityDTO.Columns;

            if (listColumnDto.Count == 0)
            {
                aEntityDTO.SQLSelect = " invalid column (column no exist !)";
                return;
            }


            StringBuilder aUserDefineTableQuery = new StringBuilder();

            aUserDefineTableQuery.Append(" SELECT RowID as ValueID , SortOrder ,");

            string userDefineColumnIdInClause = string.Empty;

            //WHERE  UserDefineEntityColumnID in (4583,4584)
            foreach (var columnClrDto in listColumnDto)
            {
                //   columnClrDto.ColumnName = DataTableUtility.FilterSQLDBInvalidChar(columnClrDto.ColumnName + "_" + columnClrDto.UserDefineEntityColumnID);

                columnClrDto.ColumnName = DataTableUtility.FilterSQLDBInvalidChar(columnClrDto.ColumnName);
                string aUserDefineEntityColumnID = columnClrDto.UserDefineEntityColumnID.ToString();

                userDefineColumnIdInClause += aUserDefineEntityColumnID + ",";

                string aCaseQuery = string.Empty;
                if (columnClrDto.UicontrolType == (int)EmControlType.DDL || columnClrDto.UicontrolType == (int)EmControlType.Image)
                {
                    aCaseQuery = string.Format("  {0}   (dbo.Concatenate ( case  when    UserDefineEntityColumnID={1} then ValueText    end )) as '{2}'  ,", PLMConstantString.ConvertValueTextToInt, aUserDefineEntityColumnID, columnClrDto.ColumnName);
                }
                else if (columnClrDto.UicontrolType == (int)EmControlType.Date)
                {
                    aCaseQuery = string.Format("  {0}   (dbo.Concatenate ( case  when    UserDefineEntityColumnID={1} then ValueText    end )) as '{2}'  ,", PLMConstantString.ConvertValueTextToDateTime, aUserDefineEntityColumnID, columnClrDto.ColumnName);
                }

                else if (
                    columnClrDto.UicontrolType == (int)EmControlType.Numeric

                    )
                {
                    aCaseQuery = string.Format("  {0}   ( dbo.Concatenate ( case  when    UserDefineEntityColumnID={1} then ValueText    end )) as '{2}'  ,", PLMConstantString.ConvertValueTextToDecimal, aUserDefineEntityColumnID, columnClrDto.ColumnName);
                }
                else
                {
                    aCaseQuery = string.Format("   dbo.Concatenate ( case  when    UserDefineEntityColumnID={0} then ValueText    end ) as '{1}'  ,", aUserDefineEntityColumnID, columnClrDto.ColumnName);
                }

                aUserDefineTableQuery.Append(aCaseQuery);
            }

            aUserDefineTableQuery.Remove(aUserDefineTableQuery.Length - 1, 1);

            if (userDefineColumnIdInClause != string.Empty)
            {
                userDefineColumnIdInClause = userDefineColumnIdInClause.Substring(0, userDefineColumnIdInClause.Length - 1);
                userDefineColumnIdInClause = "  WHERE  UserDefineEntityColumnID in ( " + userDefineColumnIdInClause + " ) " + " and EntityID=" + aEntityDTO.EntityId;
                aUserDefineTableQuery.Append(@" FROM  " + PLMSEntityClrBL.PdmUserDefineEntityRowCellValueView + userDefineColumnIdInClause + "  group by RowID, SortOrder    ");

                aEntityDTO.SQLSelect = aUserDefineTableQuery.ToString();
            }
            else
            {
                aEntityDTO.SQLSelect = "invalid column ";
            }

            // return aEntityDTO;
        }