Inserting row between different cell values - c#

I am attempting to write from a DataTable to Excel file and I want to insert a blank row in between each 'WO Base ID' I am not sure how to approach this. I am using C# with .NET, I am using the package EPPlus, I understand how to add a new row and all that with EPPlus but I cannot figure out how to split the 'WO Base IDs" up. Any help is appreciated.
Original Output
+---------------+------------+------------+-----------+-------------+-------------+
| Part # | Close Date | WO Base ID | WO Sub ID | Resource ID | Desired Qty |
+---------------+------------+------------+-----------+-------------+-------------+
| F-COM-95650-1 | 12-04-2001 | WO05837 | 0 | KITTING | 50 |
| F-COM-95650-1 | 12-04-2001 | WO05837 | 0 | PACKAGING | 50 |
| F-COM-95650-1 | 03-20-2002 | WO06008 | 0 | KITTING | 50 |
| F-COM-95650-1 | 03-20-2002 | WO06008 | 0 | PACKAGING | 50 |
| F-COM-95650-1 | 05-01-2002 | WO06231 | 0 | KITTING | 50 |
| F-COM-95650-1 | 05-01-2002 | WO06231 | 0 | PACKAGING | 50 |
| F-COM-95650-1 | 11-07-2002 | WO06994 | 0 | KITTING | 250 |
| F-COM-95650-1 | 11-07-2002 | WO06994 | 0 | PACKAGING | 250 |
+---------------+------------+------------+-----------+-------------+-------------+
Desired Output
+---------------+------------+------------+-----------+-------------+-------------+
| Part # | Close Date | WO Base ID | WO Sub ID | Resource ID | Desired Qty |
+---------------+------------+------------+-----------+-------------+-------------+
| F-COM-95650-1 | 12-04-2001 | WO05837 | 0 | KITTING | 50 |
| F-COM-95650-1 | 12-04-2001 | WO05837 | 0 | PACKAGING | 50 |
| F-COM-95650-1 | 03-20-2002 | WO06008 | 0 | KITTING | 50 |
| F-COM-95650-1 | 03-20-2002 | WO06008 | 0 | PACKAGING | 50 |
| F-COM-95650-1 | 05-01-2002 | WO06231 | 0 | KITTING | 50 |
| F-COM-95650-1 | 05-01-2002 | WO06231 | 0 | PACKAGING | 50 |
| F-COM-95650-1 | 11-07-2002 | WO06994 | 0 | KITTING | 250 |
| F-COM-95650-1 | 11-07-2002 | WO06994 | 0 | PACKAGING | 250 |
+---------------+------------+------------+-----------+-------------+-------------+

Related

How to list the products under each category in sql? side by side

I'm a bit of a beginner in sql and I need your help.
I'm sorry that I don't know if the question is correct.
now the code gives this;
+---------+----------+-------------+------------+
| id | CompanyId| DealId | price |
+---------+----------+-------------+------------+
| 1 | 1 | 1 | 100 |
| 2 | 1 | 2 | 50 |
| 3 | 1 | 3 | 25 |
| 4 | 2 | 1 | 1000 |
| 5 | 2 | 2 | 2000 |
| 6 | 2 | 3 | 2500 |
+---------+----------+-------------+------------+
but this is what i want;
+---------+----------+-------------+------------+------------+--+
| id | companyId| DealName1 | DealName2 | DealName3 | |
+---------+----------+-------------+------------+------------+--+
| 1 | 1 | 100 | 50 | 25 | |
| 2 | 2 | 1000 | 2000 | 2500 | |
| 3 | 3 | value | value | value | |
| 4 | 4 | value | value | value | |
+---------+----------+-------------+------------+------------+--+
select CompanyId
,[1] as DealName1
,[2] as DealName2
,[3] as DealName3
from (select CompanyId, DealId, price from t) t
pivot (sum(price) for DealId in([1],[2],[3])) p
CompanyId
DealName1
DealName2
DealName3
1
100
50
25
2
1000
2000
2500
Fiddle

WPF Datagrid or maybe something else that can have indents in the first column?

I have a table with a bunch of data this is a small sample:
Header - Object name
Waarde
ExportRoot.a80_02_00_01_Status.Settings.Off
0
ExportRoot.a80_02_00_01_Status.Standby
0
ExportRoot.a80_02_00_01_Status.Cooling
1
ExportRoot.a80_02_00_01_Status.Drying
0
ExportRoot.a80_02_00_01_Status.Heating
0
ExportRoot.a80_02_00_01_Status.PrepDrain
0
I wish to style this table in a way to where its more readable by removing the object parts and indenting the table like how it looks below.
| Header - Object name | Waarde |
|--------------------------|---------|
| ExportRoot | |
| | a80_02_00_01_Status | |
| | | Settings | |
| | | | Off | 0 |
| | | | Standby | 0 |
| | | | Cooling | 1 |
| | | | Drying | 0 |
| | | | Heating | 0 |
| | | | PrepDrain | 0 |
Is there a way of doing this and if so what should I be looking for all I've found so far are tables with sub tables and that not exactly what I'm looking for. If anyone has an idea let me know I'm super lost.
So basically you need a TreeListView:
There is one project on CodeProject that you can check:
WPF TreeListView Control
There is also commercial products, like DevExpress:
DevExpress TreeList View

Aggregate multiple columns in DataTable and put result to new DataTable

Hi i have a DataTable with following data formating. I am trying to aggregate in C# on condition. I am a Newbie to Linq.
Profile | Nr | Result|
------------------------
A | 1 | OK |
A | 2 | NOK |
A | 2 | OK |
A | 3 | OK |
A | 4 | OK |
A | 5 | OK |
BB | 1 | OK |
BB | 2 | NOK |
BB | 2 | NOK |
BB | 2 | OK |
BB | 3 | OK |
BB | 4 | OK |
BB | 5 | OK |
I Want to aggregate by first columnt (Profile) and count rows where the Result is OK.
The expected result should be a new DataTable and should look like this.
Profile | Count|
----------------
A | 5 |
BB | 5 |
How can i do this in C# ?

Running Totals of Commuter in Bus per stop at specified time using TSQL

I have a problem i needed to solve using sql server 2008. Below are the tables:
CommuterTrip_Details Table:
CREATE TABLE [dbo].[CommuterTrip_Details](
[TripID] [int] NOT NULL,
[TripStartStation] [varchar](20) NULL,
[TripStartTime] [time](7) NULL,
[TripEndStation] [varchar](20) NULL,
[TripEndTime] [time](7) NULL)
BusTrip_Times Table:
CREATE TABLE [dbo].[BusTrip_Times](
[BusID] [int] NOT NULL,
[StationID] [varchar](50) NULL,
[DepartTripTime] [time](7) NULL)
Below is the content of CommuterTrip_Details Table:
+------+----------------+------------------+---------------+------------------+
|TripID|TripStartStation| TripStartTime | TripEndStation| TripEndTime |
+------+----------------+------------------+---------------+------------------+
| 1 | Station_01 | 07:00:00.0000000 | Station_03 | 07:15:00.0000000 |
| 2 | Station_01 | 07:01:00.0000000 | Station_05 | 07:17:00.0000000 |
| 4 | Station_02 | 07:12:00.0000000 | Station_08 | 07:23:00.0000000 |
| 5 | Station_02 | 07:15:00.0000000 | Station_10 | 07:30:00.0000000 |
| 7 | Station_03 | 07:20:00.0000000 | Station_10 | 07:48:00.0000000 |
| 8 | Station_04 | 07:22:00.0000000 | Station_06 | 07:51:00.0000000 |
| 9 | Station_05 | 07:31:00.0000000 | Station_09 | 07:53:00.0000000 |
| 10 | Station_06 | 07:35:00.0000000 | Station_10 | 08:02:00.0000000 |
+------+----------------+------------------+---------------+------------------+
Below is the content of BusTrip_Times Table:
+-------+------------+------------------+
| BusID | StationID | DepartTripTime |
+-------+------------+------------------+
| 1 | Station_01 | 07:00:00.0000000 |
| 2 | Station_01 | 07:05:00.0000000 |
| 3 | Station_01 | 07:10:00.0000000 |
| 8 | Station_02 | 07:15:00.0000000 |
| 14 | Station_03 | 07:25:00.0000000 |
| 17 | Station_04 | 07:25:00.0000000 |
| 18 | Station_05 | 07:30:00.0000000 |
| 19 | Station_05 | 07:35:00.0000000 |
| 21 | Station_06 | 07:40:00.0000000 |
+-------+------------+------------------+
Desired Result:
enter image description here
Explanation:
BusID = 1, boarded 1 commuter in Station_01 then commuter alighted in Station_03. Same is true with BusID = 2.
BusID = 8, boarded 2 commuters in station_02, up till station_08, where 1 commuter alighted, and 1 remained till station_10
Rest of the bus has the same concept.
To count the boarded commuters, TripStartStation = StationID and TripStartTime <= DepartTripTime.
The TripStartTime must get the closest DepartTripTime. I manage to get this using ROW_NUMBER() OVER PARTITION.

c# Image PropertyItems (Metadate) How do you know which number is which property?

i know the Image.PropertyItems Array holds all the metadata Information about a loaded Image.
BUT
How do you know that the e.g. ID = 20736 is the value for e.g. GIF Time per Slide?
Is there a List of all known ID´s or something?
I haven´t found anything.
Best regards
Yes, there is a list in the documentation:
ID | Property tag
-------+-----------------
0x0000 | GpsVer
0x0001 | GpsLatitudeRef
0x0002 | GpsLatitude
0x0003 | GpsLongitudeRef
0x0004 | GpsLongitude
0x0005 | GpsAltitudeRef
0x0006 | GpsAltitude
0x0007 | GpsGpsTime
0x0008 | GpsGpsSatellites
0x0009 | GpsGpsStatus
0x000A | GpsGpsMeasureMode
0x000B | GpsGpsDop
0x000C | GpsSpeedRef
0x000D | GpsSpeed
0x000E | GpsTrackRef
0x000F | GpsTrack
0x0010 | GpsImgDirRef
0x0011 | GpsImgDir
0x0012 | GpsMapDatum
0x0013 | GpsDestLatRef
0x0014 | GpsDestLat
0x0015 | GpsDestLongRef
0x0016 | GpsDestLong
0x0017 | GpsDestBearRef
0x0018 | GpsDestBear
0x0019 | GpsDestDistRef
0x001A | GpsDestDist
0x00FE | NewSubfileType
0x00FF | SubfileType
0x0100 | ImageWidth
0x0101 | ImageHeight
0x0102 | BitsPerSample
0x0103 | Compression
0x0106 | PhotometricInterp
0x0107 | ThreshHolding
0x0108 | CellWidth
0x0109 | CellHeight
0x010A | FillOrder
0x010D | DocumentName
0x010E | ImageDescription
0x010F | EquipMake
0x0110 | EquipModel
0x0111 | StripOffsets
0x0112 | Orientation
0x0115 | SamplesPerPixel
0x0116 | RowsPerStrip
0x0117 | StripBytesCount
0x0118 | MinSampleValue
0x0119 | MaxSampleValue
0x011A | XResolution
0x011B | YResolution
0x011C | PlanarConfig
0x011D | PageName
0x011E | XPosition
0x011F | YPosition
0x0120 | FreeOffset
0x0121 | FreeByteCounts
0x0122 | GrayResponseUnit
0x0123 | GrayResponseCurve
0x0124 | T4Option
0x0125 | T6Option
0x0128 | ResolutionUnit
0x0129 | PageNumber
0x012D | TransferFunction
0x0131 | SoftwareUsed
0x0132 | DateTime
0x013B | Artist
0x013C | HostComputer
0x013D | Predictor
0x013E | WhitePoint
0x013F | PrimaryChromaticities
0x0140 | ColorMap
0x0141 | HalftoneHints
0x0142 | TileWidth
0x0143 | TileLength
0x0144 | TileOffset
0x0145 | TileByteCounts
0x014C | InkSet
0x014D | InkNames
0x014E | NumberOfInks
0x0150 | DotRange
0x0151 | TargetPrinter
0x0152 | ExtraSamples
0x0153 | SampleFormat
0x0154 | SMinSampleValue
0x0155 | SMaxSampleValue
0x0156 | TransferRange
0x0200 | JPEGProc
0x0201 | JPEGInterFormat
0x0202 | JPEGInterLength
0x0203 | JPEGRestartInterval
0x0205 | JPEGLosslessPredictors
0x0206 | JPEGPointTransforms
0x0207 | JPEGQTables
0x0208 | JPEGDCTables
0x0209 | JPEGACTables
0x0211 | YCbCrCoefficients
0x0212 | YCbCrSubsampling
0x0213 | YCbCrPositioning
0x0214 | REFBlackWhite
0x0301 | Gamma
0x0302 | ICCProfileDescriptor
0x0303 | SRGBRenderingIntent
0x0320 | ImageTitle
0x5001 | ResolutionXUnit
0x5002 | ResolutionYUnit
0x5003 | ResolutionXLengthUnit
0x5004 | ResolutionYLengthUnit
0x5005 | PrintFlags
0x5006 | PrintFlagsVersion
0x5007 | PrintFlagsCrop
0x5008 | PrintFlagsBleedWidth
0x5009 | PrintFlagsBleedWidthScale
0x500A | HalftoneLPI
0x500B | HalftoneLPIUnit
0x500C | HalftoneDegree
0x500D | HalftoneShape
0x500E | HalftoneMisc
0x500F | HalftoneScreen
0x5010 | JPEGQuality
0x5011 | GridSize
0x5012 | ThumbnailFormat
0x5013 | ThumbnailWidth
0x5014 | ThumbnailHeight
0x5015 | ThumbnailColorDepth
0x5016 | ThumbnailPlanes
0x5017 | ThumbnailRawBytes
0x5018 | ThumbnailSize
0x5019 | ThumbnailCompressedSize
0x501A | ColorTransferFunction
0x501B | ThumbnailData
0x5020 | ThumbnailImageWidth
0x5021 | ThumbnailImageHeight
0x5022 | ThumbnailBitsPerSample
0x5023 | ThumbnailCompression
0x5024 | ThumbnailPhotometricInterp
0x5025 | ThumbnailImageDescription
0x5026 | ThumbnailEquipMake
0x5027 | ThumbnailEquipModel
0x5028 | ThumbnailStripOffsets
0x5029 | ThumbnailOrientation
0x502A | ThumbnailSamplesPerPixel
0x502B | ThumbnailRowsPerStrip
0x502C | ThumbnailStripBytesCount
0x502D | ThumbnailResolutionX
0x502E | ThumbnailResolutionY
0x502F | ThumbnailPlanarConfig
0x5030 | ThumbnailResolutionUnit
0x5031 | ThumbnailTransferFunction
0x5032 | ThumbnailSoftwareUsed
0x5033 | ThumbnailDateTime
0x5034 | ThumbnailArtist
0x5035 | ThumbnailWhitePoint
0x5036 | ThumbnailPrimaryChromaticities
0x5037 | ThumbnailYCbCrCoefficients
0x5038 | ThumbnailYCbCrSubsampling
0x5039 | ThumbnailYCbCrPositioning
0x503A | ThumbnailRefBlackWhite
0x503B | ThumbnailCopyRight
0x5090 | LuminanceTable
0x5091 | ChrominanceTable
0x5100 | FrameDelay
0x5101 | LoopCount
0x5102 | GlobalPalette
0x5103 | IndexBackground
0x5104 | IndexTransparent
0x5110 | PixelUnit
0x5111 | PixelPerUnitX
0x5112 | PixelPerUnitY
0x5113 | PaletteHistogram
0x8298 | Copyright
0x829A | ExifExposureTime
0x829D | ExifFNumber
0x8769 | ExifIFD
0x8773 | ICCProfile
0x8822 | ExifExposureProg
0x8824 | ExifSpectralSense
0x8825 | GpsIFD
0x8827 | ExifISOSpeed
0x8828 | ExifOECF
0x9000 | ExifVer
0x9003 | ExifDTOrig
0x9004 | ExifDTDigitized
0x9101 | ExifCompConfig
0x9102 | ExifCompBPP
0x9201 | ExifShutterSpeed
0x9202 | ExifAperture
0x9203 | ExifBrightness
0x9204 | ExifExposureBias
0x9205 | ExifMaxAperture
0x9206 | ExifSubjectDist
0x9207 | ExifMeteringMode
0x9208 | ExifLightSource
0x9209 | ExifFlash
0x920A | ExifFocalLength
0x927C | ExifMakerNote
0x9286 | ExifUserComment
0x9290 | ExifDTSubsec
0x9291 | ExifDTOrigSS
0x9292 | ExifDTDigSS
0xA000 | ExifFPXVer
0xA001 | ExifColorSpace
0xA002 | ExifPixXDim
0xA003 | ExifPixYDim
0xA004 | ExifRelatedWav
0xA005 | ExifInterop
0xA20B | ExifFlashEnergy
0xA20C | ExifSpatialFR
0xA20E | ExifFocalXRes
0xA20F | ExifFocalYRes
0xA210 | ExifFocalResUnit
0xA214 | ExifSubjectLoc
0xA215 | ExifExposureIndex
0xA217 | ExifSensingMethod
0xA300 | ExifFileSource
0xA301 | ExifSceneType
0xA302 | ExifCfaPattern
Each of these tags is described in detail in the documentation, too: http://msdn.microsoft.com/de-de/library/ms534416.aspx
I think you are looking for that.
This is part of a larger Framework called Photo-Library-toolkit. You could base your code on this enum or maybe even use this Framework?

Categories