One way is this:
row.Constellation = arr[2].Trim().ToLower(); char[] ch = row.Constellation.ToCharArray(); ch[0] = char.ToUpper( row.Constellation[0] ); row.Constellation = new string( ch );
Microsoft AX 2012, X++, C#, SQL server, SSRS, Java, JavaFX, Oracle, PL/SQL, Delphi - codes examples, step-by-step tutorials, experiences.
row.Constellation = arr[2].Trim().ToLower(); char[] ch = row.Constellation.ToCharArray(); ch[0] = char.ToUpper( row.Constellation[0] ); row.Constellation = new string( ch );
declare @ra_min float = ( select min(x) from ( values ( @ra_from ), ( @ra_to ) ) as n(x) ); declare @ra_max float = ( select max(x) from ( values ( @ra_from ), ( @ra_to ) ) as n(x) );
select a.prodid, a.itemid, a.qtycalc from prodtable a where a.prodid in ( '19-047442', '19-047441' )Output:
prodid itemid qtycalc -------------------- ---------------------------------------- -------------------- 19-047441 5801-989-012_1138-00_lak 4.0000000000000000 19-047442 5801-989-012_1138-00_lak 12.0000000000000000 (2 row(s) affected)Now I want to make "exemplar query" - for every piece in PRODID to generate one row, so total 16 rows.
with cte as ( select row_number() over ( order by itemid ) AS rownum from inventtable ) select n.rownum, a.prodid, a.qtycalc from prodtable a cross join ( select * from cte where rownum < 999 ) n where a.prodid in ( '19-047442', '19-047441' ) and a.prodpoolid = 'SED_CES_ST' and a.prodstatus = 4 and n.rownum <= a.qtycalcOutput:
rownum prodid qtycalc -------------------- -------------------- --------------------- 1 19-047441 4.0000000000000000 2 19-047441 4.0000000000000000 3 19-047441 4.0000000000000000 4 19-047441 4.0000000000000000 1 19-047442 12.0000000000000000 2 19-047442 12.0000000000000000 3 19-047442 12.0000000000000000 4 19-047442 12.0000000000000000 5 19-047442 12.0000000000000000 6 19-047442 12.0000000000000000 7 19-047442 12.0000000000000000 8 19-047442 12.0000000000000000 9 19-047442 12.0000000000000000 10 19-047442 12.0000000000000000 11 19-047442 12.0000000000000000 12 19-047442 12.0000000000000000 (16 row(s) affected)
List<ObjectCoordinateBase> AllObjects; List<InfoStar> Rows;When I want copy objects from InfoStar class to ObjectCoordinate class, I can use List.AddRange() method.
Map.AllObjects.AddRange( import.GetAsObjectCoordinateBase() );
And here:public IEnumerable<ObjectCoordinateBase> GetAsObjectCoordinateBase() {
List<ObjectCoordinateBase> list = new List<ObjectCoordinateBase>();
this.Rows.ForEach( item => {
list.Add( new ObjectCoordinateBase( item ) );
} );
return list;
}
/* -- declare class */ public class Country { public string Name; public string ContinentName; public int Population; public Country( string _name, string _continentName, int _population ) { this.Name = _name; this.ContinentName = _continentName; this.Population = _population; } } /* -- init */ List<country> listCountry = new ListOutput:(); listCountry.Add( new Country( "czech", "europe", 10 ) ); listCountry.Add( new Country( "germany", "europe", 60 ) ); listCountry.Add( new Country( "france", "europe", 60 ) ); listCountry.Add( new Country( "usa", "america", 350 ) ); listCountry.Add( new Country( "china", "asia", 1200 ) ); /* -- join */ List listContinent = new List (); listContinent.Add( new Continent( "europe", 1 ) ); listContinent.Add( new Continent( "america", 2 ) ); listContinent.Add( new Continent( "asia", 3 ) ); var list = ( from rowCountry in listCountry join rowContinent in listContinent on rowCountry.ContinentName equals rowContinent.ContinentName where rowCountry.Population > 300 select new { Name = rowCountry.Name, RelationField = rowContinent.RelationField } ); foreach ( var row in list ) Console.WriteLine( string.Format( "ContinentName = {0} RelationField={1} ", row.Name, row.RelationField ) ); Console.WriteLine();
ContinentName = usa RelationField=2 ContinentName = china RelationField=3
/* -- declare class */ public class Country { public string Name; public string ContinentName; public int Population; public Country( string _name, string _continentName, int _population ) { this.Name = _name; this.ContinentName = _continentName; this.Population = _population; } } /* -- init */ List<country> listCountry = new ListOutput:(); listCountry.Add( new Country( "czech", "europe", 10 ) ); listCountry.Add( new Country( "germany", "europe", 60 ) ); listCountry.Add( new Country( "france", "europe", 60 ) ); listCountry.Add( new Country( "usa", "america", 350 ) ); listCountry.Add( new Country( "china", "asia", 1200 ) ); /* -- IEnumerable -> list of europe items */ IEnumerable<country> europeList = from row in listCountry where row.ContinentName == "europe" select row; foreach ( Country row in europeList ) Console.WriteLine( row.Name ); Console.WriteLine();
czech germany france
/* -- declare class */ public class Country { public string Name; public string ContinentName; public int Population; public Country( string _name, string _continentName, int _population ) { this.Name = _name; this.ContinentName = _continentName; this.Population = _population; } } /* -- init */ List<country> listCountry = new ListOutput:(); listCountry.Add( new Country( "czech", "europe", 10 ) ); listCountry.Add( new Country( "germany", "europe", 60 ) ); listCountry.Add( new Country( "france", "europe", 60 ) ); listCountry.Add( new Country( "usa", "america", 350 ) ); listCountry.Add( new Country( "china", "asia", 1200 ) ); double value; /* -- sum - query syntax variant */ value = ( from row in listCountry where row.ContinentName == "europe" select row.Population ).Sum(); Console.WriteLine( string.Format( "Sum of population, europe (variant 1) = {0}", value ) ); /* -- sum - fluent syntax variant */ value = listCountry.Where( w => w.ContinentName == "europe" ).Sum( x => x.Population ); Console.WriteLine( string.Format( "Sum of population, europe (variant 2) = {0}", value ) );
Sum of population, europe (variant 1) = 130 Sum of population, europe (variant 2) = 130
/* -- declare class */ public class Country { public string Name; public string ContinentName; public int Population; public Country( string _name, string _continentName, int _population ) { this.Name = _name; this.ContinentName = _continentName; this.Population = _population; } } /* -- init */ List<country> listCountry = new ListOutput:(); listCountry.Add( new Country( "czech", "europe", 10 ) ); listCountry.Add( new Country( "germany", "europe", 60 ) ); listCountry.Add( new Country( "france", "europe", 60 ) ); listCountry.Add( new Country( "usa", "america", 350 ) ); listCountry.Add( new Country( "china", "asia", 1200 ) ); double value; /* -- sum - query syntax variant */ value = ( from row in listCountry select row.Population ).Sum(); Console.WriteLine( string.Format( "Sum of population(variant 1) = {0}", value ) ); /* -- sum - fluent syntax variant */ value = listCountry.Sum( x => x.Population ); Console.WriteLine( string.Format( "Sum of population (variant 2) = {0}", value ) );
Sum of population(variant 1) = 1680 Sum of population (variant 2) = 1680
info( int2str( DateTimeUtil::hour( DateTimeUtil::getSystemDateTime() ) ) );
info( int2str( DateTimeUtil::hour(
DateTimeUtil::applyTimeZoneOffset( DateTimeUtil::getSystemDateTime(),
DateTimeUtil::getUserPreferredTimeZone() ) ) ) );
info( int2str( DateTimeUtil::hour(
DateTimeUtil::applyTimeZoneOffset( DateTimeUtil::getSystemDateTime(),
Timezone::GMTPLUS0100_AMSTERDAM_BERLIN_BERN_ROME ) ) ) );
Output: 7 9 9
=Format( Now(), "yyyyMM" )Output:
201907
@FXML LineChartOutput:Chart; ... /* when is TRUE, is problem with X axis labels */ Chart.setAnimated( false ); /* -- get axis */ CategoryAxis bottomAxis = (CategoryAxis) Chart.getXAxis(); Axis leftAxis = Chart.getYAxis(); /* -- set axis title */ bottomAxis.setLabel( "Bottom axis" ); leftAxis.setLabel( "Left axis" ); /* -- create series */ /* first */ Series serie = new XYChart.Series (); serie.setName( "First" ); serie.getData().add( new XYChart.Data( "Jan", 23 ) ); serie.getData().add( new XYChart.Data( "Feb", 32 ) ); serie.getData().add( new XYChart.Data( "Mar", 50 ) ); /* second */ Series serie2 = new XYChart.Series (); serie2.setName( "Second" ); serie2.getData().add( new XYChart.Data( "Jan", 100 ) ); serie2.getData().add( new XYChart.Data( "Feb", 72 ) ); serie2.getData().add( new XYChart.Data( "Mar", 20 ) ); /* remove point symbols */ Chart.setCreateSymbols(false); /* add series to chart */ Chart.getData().clear(); Chart.getData().add( serie ); Chart.getData().add( serie2 );
select eomonth( getdate(), -1 ) select eomonth( getdate() ) select eomonth( getdate(), 1 )Output:
---------- 2019-02-28 (1 row(s) affected) ---------- 2019-03-31 (1 row(s) affected) ---------- 2019-04-30 (1 row(s) affected)
var
iCount : integer;
pBookmark : TBookmark;
pDataSetSource : TDataSet;
begin
...
Screen.Cursor := crHourGlass;
iCount := 1;
pBookmark := pDatasetSource.GetBookmark;
pDatasetSource.DisableControls;
try
pDatasetSource.First;
while not pDatasetSource.Eof do
begin
try
{ action with record }
finally
inc( iCount );
pDatasetSource.Next;
end;
end;
finally
pDatasetSource.GotoBookmark( pBookmark );
pDatasetSource.EnableControls;
Screen.Cursor := crDefault;
end;
var
i : integer;
pColumn : TcxGridDBColumn;
begin
...
for i := 0 to pGridView.VisibleColumnCount - 1 do
begin
pColumn := TcxGridDBColumn( pGridView.VisibleColumns[i] );
ShowMessage( pColumn.DataBinding.FieldName + ' , ' +
GetEnumName( TypeInfo(TFieldType),
ord( pColumn.DataBinding.Field.DataType ) ) );
end;
...
Output:postJournal.menuItemName( menuitemActionStr( InventJournalPostMovement ) );
public class ParamWrapperInt {
public int value;
}
2) Use it:private boolean methodName( ParamWrapperInt _maxMinorDimension ) {
...
/* work with int */
_maxMinorDimension.value = ...
...
return true;
}
List list = new List( Types::String ); ListEnumerator listEnumerator; int iCounter; ... /* split field custVendExternalItem.Description */ list = strSplit( custVendExternalItem.Description, "/" ); listEnumerator = list.getEnumerator(); iCounter = 1; while ( listEnumerator.moveNext() ) { if ( iCounter == 1 ) tmpTable.PO_number = listEnumerator.current(); if ( iCounter == 2 ) tmpTable.revision = listEnumerator.current(); iCounter++; }
/* now() */ LocalDateTime dateNow = LocalDateTime.now(); System.out.println( dateNow ); System.out.println( dateNow.format( DateTimeFormatter.ofPattern( "dd.MM.yyyy H:m:s" ) ) ); /* defined datetime 1. Jan 2018 17:00 h */ LocalDateTime date = LocalDateTime.of( 2018, 1, 1, 17, 0, 0 ); System.out.println( date.format( DateTimeFormatter.ofPattern( "dd.MM.yyyy H:m:s" ) ) ); /* ..add 25 minutes to previous */ LocalDateTime dateend = date.plusMinutes( 25 ); System.out.println( dateend.format( DateTimeFormatter.ofPattern( "dd.MM.yyyy H:m:s" ) ) ); /* ..and check difference in minutes */ System.out.println( date.until( dateend, MINUTES ) );Output:
2018-11-28T09:50:58.724 28.11.2018 9:50:58 01.01.2018 17:0:0 01.01.2018 17:25:0 25
var
pMemTable : TFDMemTable;
pQuery : TFDQuery;
begin
...
pMemTable := TFDMemTable.Create( self );
pMemTable.CloneCursor( pQuery );
...
var
pMemTable : TFDMemTable;
pQuery : TFDQuery;
begin
...
pMemTable := TFDMemTable.Create( self );
pMemTable.FieldDefs.Add( 'key', ftString, 25 );
pMemTable.FieldDefs.Add( 'value', ftString, 25 );
pMemTable.CreateDataSet();
...
pMemTable.AppendRecord( [ 'firstkey', 'firstvalue' ] );
...
type
TEachRowProcedures = class
public
class procedure ExportAsHTML_Proc( ARowIndex: Integer; ARowInfo: TcxRowInfo );
end;
Call as:...
_pView.DataController.ForEachRow( true, TEachRowProcedures.ExportAsHTML_Proc );
=IIf(Fields!ID_week.Value=DATEPART(DateInterval.WeekOfYear, Today()), "LimeGreen","Tomato")