From dc899e852b99d83241bd7ee95d96662a016eb154 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Thu, 14 Feb 2019 18:23:24 +0000 Subject: [PATCH] 3626 --- AyaNovaSolution.sln | 26 + .../AyaLib/GZTW.AyaNova.BLL/Workorder.cs | 5199 +++++++++-------- .../GZTW.AyaNova.BLL/WorkorderTypeFetcher.cs | 17 +- 3 files changed, 2642 insertions(+), 2600 deletions(-) diff --git a/AyaNovaSolution.sln b/AyaNovaSolution.sln index 241aaa5..11653f2 100644 --- a/AyaNovaSolution.sln +++ b/AyaNovaSolution.sln @@ -190,6 +190,7 @@ Global {50B807B6-FC35-4CC3-B54D-91C78426A943}.ReleaseX86AyaNova|x86.ActiveCfg = Release|Any CPU {82EA0692-8199-45D6-8726-CA49EE893299}.Debug|.NET.ActiveCfg = Debug|Any CPU {82EA0692-8199-45D6-8726-CA49EE893299}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {82EA0692-8199-45D6-8726-CA49EE893299}.Debug|Any CPU.Build.0 = Debug|Any CPU {82EA0692-8199-45D6-8726-CA49EE893299}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {82EA0692-8199-45D6-8726-CA49EE893299}.Debug|WBI.ActiveCfg = Debug|Any CPU {82EA0692-8199-45D6-8726-CA49EE893299}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -222,6 +223,7 @@ Global {82EA0692-8199-45D6-8726-CA49EE893299}.ReleaseX86AyaNova|x86.ActiveCfg = Debug|Any CPU {FE5614F3-E435-423C-A23D-E3372B7EAEAB}.Debug|.NET.ActiveCfg = Debug|Any CPU {FE5614F3-E435-423C-A23D-E3372B7EAEAB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FE5614F3-E435-423C-A23D-E3372B7EAEAB}.Debug|Any CPU.Build.0 = Debug|Any CPU {FE5614F3-E435-423C-A23D-E3372B7EAEAB}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {FE5614F3-E435-423C-A23D-E3372B7EAEAB}.Debug|WBI.ActiveCfg = Debug|Any CPU {FE5614F3-E435-423C-A23D-E3372B7EAEAB}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -258,6 +260,7 @@ Global {FE5614F3-E435-423C-A23D-E3372B7EAEAB}.ReleaseX86AyaNova|x86.ActiveCfg = Release|Any CPU {701893AA-C042-4FB2-8643-E139372C1117}.Debug|.NET.ActiveCfg = Debug|Any CPU {701893AA-C042-4FB2-8643-E139372C1117}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {701893AA-C042-4FB2-8643-E139372C1117}.Debug|Any CPU.Build.0 = Debug|Any CPU {701893AA-C042-4FB2-8643-E139372C1117}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {701893AA-C042-4FB2-8643-E139372C1117}.Debug|WBI.ActiveCfg = Debug|Any CPU {701893AA-C042-4FB2-8643-E139372C1117}.Debug|WBI.Build.0 = Debug|Any CPU @@ -296,6 +299,7 @@ Global {701893AA-C042-4FB2-8643-E139372C1117}.ReleaseX86AyaNova|x86.ActiveCfg = Release|Any CPU {EDE897E2-E2E6-441D-9F83-0B973AE09670}.Debug|.NET.ActiveCfg = Debug|Any CPU {EDE897E2-E2E6-441D-9F83-0B973AE09670}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EDE897E2-E2E6-441D-9F83-0B973AE09670}.Debug|Any CPU.Build.0 = Debug|Any CPU {EDE897E2-E2E6-441D-9F83-0B973AE09670}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {EDE897E2-E2E6-441D-9F83-0B973AE09670}.Debug|WBI.ActiveCfg = Debug|Any CPU {EDE897E2-E2E6-441D-9F83-0B973AE09670}.Debug|WBI.Build.0 = Debug|Any CPU @@ -334,6 +338,7 @@ Global {EDE897E2-E2E6-441D-9F83-0B973AE09670}.ReleaseX86AyaNova|x86.ActiveCfg = Release|Any CPU {1B9A38BB-461A-47A4-AD72-099C694138A0}.Debug|.NET.ActiveCfg = Debug|Any CPU {1B9A38BB-461A-47A4-AD72-099C694138A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1B9A38BB-461A-47A4-AD72-099C694138A0}.Debug|Any CPU.Build.0 = Debug|Any CPU {1B9A38BB-461A-47A4-AD72-099C694138A0}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {1B9A38BB-461A-47A4-AD72-099C694138A0}.Debug|WBI.ActiveCfg = Debug|Any CPU {1B9A38BB-461A-47A4-AD72-099C694138A0}.Debug|WBI.Build.0 = Debug|Any CPU @@ -372,6 +377,7 @@ Global {1B9A38BB-461A-47A4-AD72-099C694138A0}.ReleaseX86AyaNova|x86.ActiveCfg = Release|Any CPU {C2392355-12A9-4197-A1D3-603C390B1E62}.Debug|.NET.ActiveCfg = Debug|Any CPU {C2392355-12A9-4197-A1D3-603C390B1E62}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C2392355-12A9-4197-A1D3-603C390B1E62}.Debug|Any CPU.Build.0 = Debug|Any CPU {C2392355-12A9-4197-A1D3-603C390B1E62}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {C2392355-12A9-4197-A1D3-603C390B1E62}.Debug|WBI.ActiveCfg = Debug|Any CPU {C2392355-12A9-4197-A1D3-603C390B1E62}.Debug|WBI.Build.0 = Debug|Any CPU @@ -410,6 +416,7 @@ Global {C2392355-12A9-4197-A1D3-603C390B1E62}.ReleaseX86AyaNova|x86.ActiveCfg = Release|Any CPU {80828E2C-E9FB-4E73-A27C-7F9CDB96FCDE}.Debug|.NET.ActiveCfg = Debug|Any CPU {80828E2C-E9FB-4E73-A27C-7F9CDB96FCDE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {80828E2C-E9FB-4E73-A27C-7F9CDB96FCDE}.Debug|Any CPU.Build.0 = Debug|Any CPU {80828E2C-E9FB-4E73-A27C-7F9CDB96FCDE}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {80828E2C-E9FB-4E73-A27C-7F9CDB96FCDE}.Debug|WBI.ActiveCfg = Debug|Any CPU {80828E2C-E9FB-4E73-A27C-7F9CDB96FCDE}.Debug|WBI.Build.0 = Debug|Any CPU @@ -488,6 +495,7 @@ Global {3EF693E1-F60E-4D0F-929C-CBF8BEF96F12}.ReleaseX86AyaNova|x86.Build.0 = Release|x86 {3A426361-1480-49A3-B596-53ABB98087F9}.Debug|.NET.ActiveCfg = Debug|Any CPU {3A426361-1480-49A3-B596-53ABB98087F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3A426361-1480-49A3-B596-53ABB98087F9}.Debug|Any CPU.Build.0 = Debug|Any CPU {3A426361-1480-49A3-B596-53ABB98087F9}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {3A426361-1480-49A3-B596-53ABB98087F9}.Debug|WBI.ActiveCfg = Debug|Any CPU {3A426361-1480-49A3-B596-53ABB98087F9}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -521,6 +529,7 @@ Global {3A426361-1480-49A3-B596-53ABB98087F9}.ReleaseX86AyaNova|x86.ActiveCfg = Release|Any CPU {EF51C1E7-8944-471D-A7CC-FC36DA2C0360}.Debug|.NET.ActiveCfg = Debug|Any CPU {EF51C1E7-8944-471D-A7CC-FC36DA2C0360}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EF51C1E7-8944-471D-A7CC-FC36DA2C0360}.Debug|Any CPU.Build.0 = Debug|Any CPU {EF51C1E7-8944-471D-A7CC-FC36DA2C0360}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {EF51C1E7-8944-471D-A7CC-FC36DA2C0360}.Debug|WBI.ActiveCfg = Debug|Any CPU {EF51C1E7-8944-471D-A7CC-FC36DA2C0360}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -555,6 +564,7 @@ Global {EF51C1E7-8944-471D-A7CC-FC36DA2C0360}.ReleaseX86AyaNova|x86.ActiveCfg = Release|Any CPU {5083ED09-C394-48E7-B9DA-53A4CCA2D505}.Debug|.NET.ActiveCfg = Debug|Any CPU {5083ED09-C394-48E7-B9DA-53A4CCA2D505}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5083ED09-C394-48E7-B9DA-53A4CCA2D505}.Debug|Any CPU.Build.0 = Debug|Any CPU {5083ED09-C394-48E7-B9DA-53A4CCA2D505}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {5083ED09-C394-48E7-B9DA-53A4CCA2D505}.Debug|WBI.ActiveCfg = Debug|Any CPU {5083ED09-C394-48E7-B9DA-53A4CCA2D505}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -589,6 +599,7 @@ Global {5083ED09-C394-48E7-B9DA-53A4CCA2D505}.ReleaseX86AyaNova|x86.ActiveCfg = Release|Any CPU {6EF350F8-7676-416B-8CE9-6DB9B14CCB41}.Debug|.NET.ActiveCfg = Debug|Any CPU {6EF350F8-7676-416B-8CE9-6DB9B14CCB41}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6EF350F8-7676-416B-8CE9-6DB9B14CCB41}.Debug|Any CPU.Build.0 = Debug|Any CPU {6EF350F8-7676-416B-8CE9-6DB9B14CCB41}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {6EF350F8-7676-416B-8CE9-6DB9B14CCB41}.Debug|WBI.ActiveCfg = Debug|Any CPU {6EF350F8-7676-416B-8CE9-6DB9B14CCB41}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -620,6 +631,7 @@ Global {674BC3C9-4F74-4304-91ED-2EAFFFEB09A7}.Debug|.NET.ActiveCfg = Debug|Any CPU {674BC3C9-4F74-4304-91ED-2EAFFFEB09A7}.Debug|.NET.Build.0 = Debug|Any CPU {674BC3C9-4F74-4304-91ED-2EAFFFEB09A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {674BC3C9-4F74-4304-91ED-2EAFFFEB09A7}.Debug|Any CPU.Build.0 = Debug|Any CPU {674BC3C9-4F74-4304-91ED-2EAFFFEB09A7}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {674BC3C9-4F74-4304-91ED-2EAFFFEB09A7}.Debug|WBI.ActiveCfg = Debug|Any CPU {674BC3C9-4F74-4304-91ED-2EAFFFEB09A7}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -654,6 +666,7 @@ Global {674BC3C9-4F74-4304-91ED-2EAFFFEB09A7}.ReleaseX86AyaNova|x86.ActiveCfg = Release|Any CPU {F14E1944-51B4-4998-8D9B-BEAE2A756FE4}.Debug|.NET.ActiveCfg = Debug|Any CPU {F14E1944-51B4-4998-8D9B-BEAE2A756FE4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F14E1944-51B4-4998-8D9B-BEAE2A756FE4}.Debug|Any CPU.Build.0 = Debug|Any CPU {F14E1944-51B4-4998-8D9B-BEAE2A756FE4}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {F14E1944-51B4-4998-8D9B-BEAE2A756FE4}.Debug|WBI.ActiveCfg = Debug|Any CPU {F14E1944-51B4-4998-8D9B-BEAE2A756FE4}.Debug|x64.ActiveCfg = Debug|x64 @@ -688,6 +701,7 @@ Global {F14E1944-51B4-4998-8D9B-BEAE2A756FE4}.ReleaseX86AyaNova|x86.ActiveCfg = Release|Any CPU {AA1D8C90-D676-4438-8C68-DB9AA1783396}.Debug|.NET.ActiveCfg = Debug|Any CPU {AA1D8C90-D676-4438-8C68-DB9AA1783396}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AA1D8C90-D676-4438-8C68-DB9AA1783396}.Debug|Any CPU.Build.0 = Debug|Any CPU {AA1D8C90-D676-4438-8C68-DB9AA1783396}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {AA1D8C90-D676-4438-8C68-DB9AA1783396}.Debug|WBI.ActiveCfg = Debug|Any CPU {AA1D8C90-D676-4438-8C68-DB9AA1783396}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -720,6 +734,7 @@ Global {AA1D8C90-D676-4438-8C68-DB9AA1783396}.ReleaseX86AyaNova|x86.ActiveCfg = Release|Any CPU {0CD14576-A3D4-4CBD-A8E6-F8BD3EEAA4B7}.Debug|.NET.ActiveCfg = Debug|Any CPU {0CD14576-A3D4-4CBD-A8E6-F8BD3EEAA4B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0CD14576-A3D4-4CBD-A8E6-F8BD3EEAA4B7}.Debug|Any CPU.Build.0 = Debug|Any CPU {0CD14576-A3D4-4CBD-A8E6-F8BD3EEAA4B7}.Debug|Any CPU.Deploy.0 = Debug|Any CPU {0CD14576-A3D4-4CBD-A8E6-F8BD3EEAA4B7}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {0CD14576-A3D4-4CBD-A8E6-F8BD3EEAA4B7}.Debug|WBI.ActiveCfg = Debug|Any CPU @@ -753,6 +768,7 @@ Global {0CD14576-A3D4-4CBD-A8E6-F8BD3EEAA4B7}.ReleaseX86AyaNova|x86.ActiveCfg = Release|Any CPU {122B13D1-19DD-47AD-B030-A209167EF258}.Debug|.NET.ActiveCfg = Debug|Any CPU {122B13D1-19DD-47AD-B030-A209167EF258}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {122B13D1-19DD-47AD-B030-A209167EF258}.Debug|Any CPU.Build.0 = Debug|Any CPU {122B13D1-19DD-47AD-B030-A209167EF258}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {122B13D1-19DD-47AD-B030-A209167EF258}.Debug|WBI.ActiveCfg = Debug|Any CPU {122B13D1-19DD-47AD-B030-A209167EF258}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -785,6 +801,7 @@ Global {122B13D1-19DD-47AD-B030-A209167EF258}.ReleaseX86AyaNova|x86.ActiveCfg = Release|Any CPU {4C39FEAD-9F24-49BE-A36E-98990DE3FF3C}.Debug|.NET.ActiveCfg = Debug|Any CPU {4C39FEAD-9F24-49BE-A36E-98990DE3FF3C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4C39FEAD-9F24-49BE-A36E-98990DE3FF3C}.Debug|Any CPU.Build.0 = Debug|Any CPU {4C39FEAD-9F24-49BE-A36E-98990DE3FF3C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {4C39FEAD-9F24-49BE-A36E-98990DE3FF3C}.Debug|WBI.ActiveCfg = Debug|Any CPU {4C39FEAD-9F24-49BE-A36E-98990DE3FF3C}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -817,6 +834,7 @@ Global {4C39FEAD-9F24-49BE-A36E-98990DE3FF3C}.ReleaseX86AyaNova|x86.ActiveCfg = Release|Any CPU {19024613-F5C6-42A5-B02D-CECD8B20BF77}.Debug|.NET.ActiveCfg = Debug|Any CPU {19024613-F5C6-42A5-B02D-CECD8B20BF77}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {19024613-F5C6-42A5-B02D-CECD8B20BF77}.Debug|Any CPU.Build.0 = Debug|Any CPU {19024613-F5C6-42A5-B02D-CECD8B20BF77}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {19024613-F5C6-42A5-B02D-CECD8B20BF77}.Debug|WBI.ActiveCfg = Debug|Any CPU {19024613-F5C6-42A5-B02D-CECD8B20BF77}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -849,6 +867,7 @@ Global {19024613-F5C6-42A5-B02D-CECD8B20BF77}.ReleaseX86AyaNova|x86.ActiveCfg = Release|Any CPU {42EE07F1-2AD8-4717-A85B-7E2DB97A625E}.Debug|.NET.ActiveCfg = Debug|Any CPU {42EE07F1-2AD8-4717-A85B-7E2DB97A625E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {42EE07F1-2AD8-4717-A85B-7E2DB97A625E}.Debug|Any CPU.Build.0 = Debug|Any CPU {42EE07F1-2AD8-4717-A85B-7E2DB97A625E}.Debug|Any CPU.Deploy.0 = Debug|Any CPU {42EE07F1-2AD8-4717-A85B-7E2DB97A625E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {42EE07F1-2AD8-4717-A85B-7E2DB97A625E}.Debug|WBI.ActiveCfg = Debug|Any CPU @@ -882,6 +901,7 @@ Global {42EE07F1-2AD8-4717-A85B-7E2DB97A625E}.ReleaseX86AyaNova|x86.ActiveCfg = Release|Any CPU {F04AF6D0-FCEE-4709-ADC6-7274749C06E6}.Debug|.NET.ActiveCfg = Debug|Any CPU {F04AF6D0-FCEE-4709-ADC6-7274749C06E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F04AF6D0-FCEE-4709-ADC6-7274749C06E6}.Debug|Any CPU.Build.0 = Debug|Any CPU {F04AF6D0-FCEE-4709-ADC6-7274749C06E6}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {F04AF6D0-FCEE-4709-ADC6-7274749C06E6}.Debug|WBI.ActiveCfg = Debug|Any CPU {F04AF6D0-FCEE-4709-ADC6-7274749C06E6}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -914,6 +934,7 @@ Global {F04AF6D0-FCEE-4709-ADC6-7274749C06E6}.ReleaseX86AyaNova|x86.ActiveCfg = Release|Any CPU {0082F005-55A8-4C02-ACCD-111B1D8D1CBB}.Debug|.NET.ActiveCfg = Debug|Any CPU {0082F005-55A8-4C02-ACCD-111B1D8D1CBB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0082F005-55A8-4C02-ACCD-111B1D8D1CBB}.Debug|Any CPU.Build.0 = Debug|Any CPU {0082F005-55A8-4C02-ACCD-111B1D8D1CBB}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {0082F005-55A8-4C02-ACCD-111B1D8D1CBB}.Debug|WBI.ActiveCfg = Debug|Any CPU {0082F005-55A8-4C02-ACCD-111B1D8D1CBB}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -946,6 +967,7 @@ Global {0082F005-55A8-4C02-ACCD-111B1D8D1CBB}.ReleaseX86AyaNova|x86.ActiveCfg = Release|Any CPU {A9445D98-9E04-4A53-A6D7-441E97345975}.Debug|.NET.ActiveCfg = Debug|Any CPU {A9445D98-9E04-4A53-A6D7-441E97345975}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A9445D98-9E04-4A53-A6D7-441E97345975}.Debug|Any CPU.Build.0 = Debug|Any CPU {A9445D98-9E04-4A53-A6D7-441E97345975}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {A9445D98-9E04-4A53-A6D7-441E97345975}.Debug|WBI.ActiveCfg = Debug|Any CPU {A9445D98-9E04-4A53-A6D7-441E97345975}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -978,6 +1000,7 @@ Global {A9445D98-9E04-4A53-A6D7-441E97345975}.ReleaseX86AyaNova|x86.ActiveCfg = Release|Any CPU {A65F3152-E70D-47B6-8928-7AA52567BE8D}.Debug|.NET.ActiveCfg = Debug|x86 {A65F3152-E70D-47B6-8928-7AA52567BE8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A65F3152-E70D-47B6-8928-7AA52567BE8D}.Debug|Any CPU.Build.0 = Debug|Any CPU {A65F3152-E70D-47B6-8928-7AA52567BE8D}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {A65F3152-E70D-47B6-8928-7AA52567BE8D}.Debug|WBI.ActiveCfg = Debug|x86 {A65F3152-E70D-47B6-8928-7AA52567BE8D}.Debug|x64.ActiveCfg = Debug|x86 @@ -1010,6 +1033,7 @@ Global {A65F3152-E70D-47B6-8928-7AA52567BE8D}.ReleaseX86AyaNova|x86.Build.0 = Release|x86 {58F36D78-4BBA-4A70-8EAB-A6D414663233}.Debug|.NET.ActiveCfg = Debug|Any CPU {58F36D78-4BBA-4A70-8EAB-A6D414663233}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {58F36D78-4BBA-4A70-8EAB-A6D414663233}.Debug|Any CPU.Build.0 = Debug|Any CPU {58F36D78-4BBA-4A70-8EAB-A6D414663233}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {58F36D78-4BBA-4A70-8EAB-A6D414663233}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU {58F36D78-4BBA-4A70-8EAB-A6D414663233}.Debug|WBI.ActiveCfg = Debug|Any CPU @@ -1041,6 +1065,7 @@ Global {58F36D78-4BBA-4A70-8EAB-A6D414663233}.ReleaseX86AyaNova|x86.ActiveCfg = Release|Any CPU {CE73BA18-914D-4426-8888-1DA0F0FC4764}.Debug|.NET.ActiveCfg = Debug|x86 {CE73BA18-914D-4426-8888-1DA0F0FC4764}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CE73BA18-914D-4426-8888-1DA0F0FC4764}.Debug|Any CPU.Build.0 = Debug|Any CPU {CE73BA18-914D-4426-8888-1DA0F0FC4764}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 {CE73BA18-914D-4426-8888-1DA0F0FC4764}.Debug|Mixed Platforms.Build.0 = Debug|x86 {CE73BA18-914D-4426-8888-1DA0F0FC4764}.Debug|WBI.ActiveCfg = Debug|x86 @@ -1074,6 +1099,7 @@ Global {CE73BA18-914D-4426-8888-1DA0F0FC4764}.ReleaseX86AyaNova|x86.Build.0 = Release|x86 {5407E64B-951B-414D-B532-4AF2EDBDD9FD}.Debug|.NET.ActiveCfg = Debug|x86 {5407E64B-951B-414D-B532-4AF2EDBDD9FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5407E64B-951B-414D-B532-4AF2EDBDD9FD}.Debug|Any CPU.Build.0 = Debug|Any CPU {5407E64B-951B-414D-B532-4AF2EDBDD9FD}.Debug|Any CPU.Deploy.0 = Debug|Any CPU {5407E64B-951B-414D-B532-4AF2EDBDD9FD}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 {5407E64B-951B-414D-B532-4AF2EDBDD9FD}.Debug|Mixed Platforms.Build.0 = Debug|x86 diff --git a/source/bizobjects/AyaLib/GZTW.AyaNova.BLL/Workorder.cs b/source/bizobjects/AyaLib/GZTW.AyaNova.BLL/Workorder.cs index ff7bee9..ef479d7 100644 --- a/source/bizobjects/AyaLib/GZTW.AyaNova.BLL/Workorder.cs +++ b/source/bizobjects/AyaLib/GZTW.AyaNova.BLL/Workorder.cs @@ -17,60 +17,61 @@ using CSLA.Security; using System.ComponentModel; using System.Text; -namespace GZTW.AyaNova.BLL +namespace GZTW.AyaNova.BLL { - /// - /// Workorder object - the heart of AyaNova. + /// + /// Workorder object - the heart of AyaNova. /// This is the parent object of all forms of workorders including quotes, pm, service and template forms. - /// - [Serializable] - public class Workorder : BusinessBase { + /// + [Serializable] + public class Workorder : BusinessBase + { - #region Attributes + #region Attributes - private bool bReadOnly; - private Guid mID; - private SmartDate mCreated; - private SmartDate mModified; - private Guid mCreator; - private Guid mModifier; - private AssignedDocs mDocs; - - //Workorder properties - private Guid mClientID; - private Guid mProjectID; - private string mInternalReferenceNumber=""; - private string mCustomerReferenceNumber=""; - private bool mOnsite; - private string mCustomerContactName=""; + private bool bReadOnly; + private Guid mID; + private SmartDate mCreated; + private SmartDate mModified; + private Guid mCreator; + private Guid mModifier; + private AssignedDocs mDocs; + + //Workorder properties + private Guid mClientID; + private Guid mProjectID; + private string mInternalReferenceNumber = ""; + private string mCustomerReferenceNumber = ""; + private bool mOnsite; + private string mCustomerContactName = ""; //case 58 private Guid mRegionID; - private string mSummary=""; - private string mTemplateDescription=""; - private Guid mFormLayoutID; - private WorkorderTypes mWorkorderType; - //private bool mTemplate; - private Guid mWorkorderCategoryID; - - //Children - private WorkorderQuote mQuote; - private WorkorderService mService; - private WorkorderPreventiveMaintenance mWorkorderPreventiveMaintenance; - private WorkorderItems mWorkorderItems; + private string mSummary = ""; + private string mTemplateDescription = ""; + private Guid mFormLayoutID; + private WorkorderTypes mWorkorderType; + //private bool mTemplate; + private Guid mWorkorderCategoryID; - + //Children + private WorkorderQuote mQuote; + private WorkorderService mService; + private WorkorderPreventiveMaintenance mWorkorderPreventiveMaintenance; + private WorkorderItems mWorkorderItems; - private bool mUseInventory; - //applicable only if it's a service workorder - private bool mServiceCompleted; - private bool mClosed; - internal Guid mFromQuoteID; - internal Guid mFromPMID; + private bool mUseInventory; + + //applicable only if it's a service workorder + private bool mServiceCompleted; + private bool mClosed; + + internal Guid mFromQuoteID; + internal Guid mFromPMID; //case 1387 internal SecurityLevelTypes mRights; @@ -78,393 +79,393 @@ namespace GZTW.AyaNova.BLL //case 3132 private bool mTemplateFreshPrice; - #endregion + #endregion - #region Constructor + #region Constructor - /// - /// Private constructor to prevent direct instantiation - /// - private Workorder() - { - - //Set to read / write initially so that properties - //can be set - bReadOnly=false; + /// + /// Private constructor to prevent direct instantiation + /// + private Workorder() + { - //New ID - mID = Guid.NewGuid(); - - mWorkorderItems=WorkorderItems.NewItems(); + //Set to read / write initially so that properties + //can be set + bReadOnly = false; + + //New ID + mID = Guid.NewGuid(); + + mWorkorderItems = WorkorderItems.NewItems(); //Built-in "Default" region mRegionID = Region.DefaultRegionID;//case 58 - //Set record history to defaults - mCreated = new SmartDate(DBUtil.CurrentWorkingDateTime); - mModified=new SmartDate(); - mCreator=Guid.Empty; - mModifier=Guid.Empty; - mUseInventory=AyaBizUtils.GlobalSettings.UseInventory; - mClosed=false; - mServiceCompleted=false; - mDocs=AssignedDocs.NewItems(); - //Changed 15-March-2006 - mOnsite=true; + //Set record history to defaults + mCreated = new SmartDate(DBUtil.CurrentWorkingDateTime); + mModified = new SmartDate(); + mCreator = Guid.Empty; + mModifier = Guid.Empty; + mUseInventory = AyaBizUtils.GlobalSettings.UseInventory; + mClosed = false; + mServiceCompleted = false; + mDocs = AssignedDocs.NewItems(); + //Changed 15-March-2006 + mOnsite = true; //case 3132 mTemplateFreshPrice = false; - } + } - #endregion + #endregion - #region Business properties + #region Business properties - /// - /// Get internal id number Read only property because it's set internally, not - /// externally - /// - public Guid ID - { - get - { - return mID; - } - } + /// + /// Get internal id number Read only property because it's set internally, not + /// externally + /// + public Guid ID + { + get + { + return mID; + } + } - /// - /// Get created date - /// - /// - /// - public string Created - { - get - { - return mCreated.ToString(); - } - } + /// + /// Get created date + /// + /// + /// + public string Created + { + get + { + return mCreated.ToString(); + } + } - /// - /// Get modified date - /// - /// - /// - public string Modified - { - get - { - return mModified.ToString(); - } - } + /// + /// Get modified date + /// + /// + /// + public string Modified + { + get + { + return mModified.ToString(); + } + } + + /// + /// Get user record ID of person who created this record + /// + /// + /// + public Guid Creator + { + get + { + return mCreator; + } + } + + /// + /// Get user ID of person who modified this record + /// + /// + /// + public Guid Modifier + { + get + { + return mModifier; + } + } - /// - /// Get user record ID of person who created this record - /// - /// - /// - public Guid Creator - { - get - { - return mCreator; - } - } - /// - /// Get user ID of person who modified this record - /// - /// - /// - public Guid Modifier - { - get - { - return mModifier; - } - } - - /// /// object collection assigned to this workorder /// - public AssignedDocs Docs - { - get - { - return mDocs; - } - - } - + public AssignedDocs Docs + { + get + { + return mDocs; + } - /// - /// Category of workorder - /// - public Guid WorkorderCategoryID - { - get - { - return mWorkorderCategoryID; - } - set - { - if(bReadOnly) - ThrowSetError(); - else - { - if(mWorkorderCategoryID!=value) - { - mWorkorderCategoryID = value; - MarkDirty(); - - } - } - } - } - /// - /// Client this work order applies to - /// - public Guid ClientID - { - get - { - return mClientID; - } - set - { - if(bReadOnly) - ThrowSetError(); - else - { - if(mClientID!=value) - { - mClientID = value; - if(this.CustomerContactName=="") - { - Client c=Client.GetItemNoMRU(value); + } + + + /// + /// Category of workorder + /// + public Guid WorkorderCategoryID + { + get + { + return mWorkorderCategoryID; + } + set + { + if (bReadOnly) + ThrowSetError(); + else + { + if (mWorkorderCategoryID != value) + { + mWorkorderCategoryID = value; + MarkDirty(); + + } + } + } + } + /// + /// Client this work order applies to + /// + public Guid ClientID + { + get + { + return mClientID; + } + set + { + if (bReadOnly) + ThrowSetError(); + else + { + if (mClientID != value) + { + mClientID = value; + if (this.CustomerContactName == "") + { + Client c = Client.GetItemNoMRU(value); this.CustomerContactName = c.Contact; - - c=null; - } - MarkDirty(); - - } - } - } - } - /// - /// Brief description of the purpose of the workorder as a whole - /// displays on many reports and in various grids. Should be an overview - /// of what the service is about for the work order in general. - /// - public string Summary - { - get - { - return mSummary; - } - set - { - if(bReadOnly) - ThrowSetError(); - else - { - if(mSummary!=value) - { - mSummary = value; - MarkDirty(); - - } - } - } - } + c = null; + } + MarkDirty(); - /// - /// Need to flesh out a lot more as refers to a collection etc - /// - /// ID of the FormLayout which is object describing the field positions and field - /// titles of a workorder input form as designed by a user - /// - public Guid FormLayoutID - { - get - { - return mFormLayoutID; - } - set - { - if(bReadOnly) - ThrowSetError(); - else - { - if(mFormLayoutID!=value) - { - mFormLayoutID = value; - MarkDirty(); - - } - } - } - } + } + } + } + } - /// - /// GUID of project selected - /// - public Guid ProjectID - { - get - { - return mProjectID; - } - set - { - if(bReadOnly) - ThrowSetError(); - else - { - if(mProjectID!=value) - { - mProjectID = value; - MarkDirty(); - - } - } - } - } - + /// + /// Brief description of the purpose of the workorder as a whole + /// displays on many reports and in various grids. Should be an overview + /// of what the service is about for the work order in general. + /// + public string Summary + { + get + { + return mSummary; + } + set + { + if (bReadOnly) + ThrowSetError(); + else + { + if (mSummary != value) + { + mSummary = value; + MarkDirty(); - /// - /// In addition to Workorder number - may have letters in it, therefore used in - /// addition to numerial wo number - /// - public string InternalReferenceNumber - { - get - { - return mInternalReferenceNumber; - } - set - { - if(bReadOnly) - ThrowSetError(); - else - { - if(mInternalReferenceNumber!=value) - { - mInternalReferenceNumber = value; - MarkDirty(); - - } - } - } - } + } + } + } + } + + /// + /// Need to flesh out a lot more as refers to a collection etc + /// + /// ID of the FormLayout which is object describing the field positions and field + /// titles of a workorder input form as designed by a user + /// + public Guid FormLayoutID + { + get + { + return mFormLayoutID; + } + set + { + if (bReadOnly) + ThrowSetError(); + else + { + if (mFormLayoutID != value) + { + mFormLayoutID = value; + MarkDirty(); + + } + } + } + } + + /// + /// GUID of project selected + /// + public Guid ProjectID + { + get + { + return mProjectID; + } + set + { + if (bReadOnly) + ThrowSetError(); + else + { + if (mProjectID != value) + { + mProjectID = value; + MarkDirty(); + + } + } + } + } + + + /// + /// In addition to Workorder number - may have letters in it, therefore used in + /// addition to numerial wo number + /// + public string InternalReferenceNumber + { + get + { + return mInternalReferenceNumber; + } + set + { + if (bReadOnly) + ThrowSetError(); + else + { + if (mInternalReferenceNumber != value) + { + mInternalReferenceNumber = value; + MarkDirty(); + + } + } + } + } /// /// Client's reference number /// - public string CustomerReferenceNumber - { - get - { - return mCustomerReferenceNumber; - } - set - { - if(bReadOnly) - ThrowSetError(); - else - { - if(mCustomerReferenceNumber!=value) - { - mCustomerReferenceNumber = value; - MarkDirty(); - - } - } - } - } + public string CustomerReferenceNumber + { + get + { + return mCustomerReferenceNumber; + } + set + { + if (bReadOnly) + ThrowSetError(); + else + { + if (mCustomerReferenceNumber != value) + { + mCustomerReferenceNumber = value; + MarkDirty(); - /// - /// Onsite indicates at client site - /// Default is true - /// Can be set in regional settings - /// - public bool Onsite - { - get - { - return mOnsite; - } - set - { - if(bReadOnly) - ThrowSetError(); - else - { - if(mOnsite!=value) - { - mOnsite = value; - MarkDirty(); - - } - } - } - } + } + } + } + } - /// - /// Takes as default name in client contact list when client first selected, but - /// can be edited by user - /// - public string CustomerContactName - { - get - { - return mCustomerContactName; - } - set - { - if(bReadOnly) - ThrowSetError(); - else - { - if(mCustomerContactName!=value) - { - mCustomerContactName = value; - MarkDirty(); - - } - } - } - } - /// - /// Determines if a workorder is a template, a quote, a PM item, a workorder for a - /// client or an internal workorder - /// - public WorkorderTypes WorkorderType - { - get - { - return mWorkorderType; - } - set - { - if(bReadOnly) - ThrowSetError(); - else - { - if(mWorkorderType!=value) - { - mWorkorderType = value; - MarkDirty(); - - } - } - } - } + /// + /// Onsite indicates at client site + /// Default is true + /// Can be set in regional settings + /// + public bool Onsite + { + get + { + return mOnsite; + } + set + { + if (bReadOnly) + ThrowSetError(); + else + { + if (mOnsite != value) + { + mOnsite = value; + MarkDirty(); + + } + } + } + } + + /// + /// Takes as default name in client contact list when client first selected, but + /// can be edited by user + /// + public string CustomerContactName + { + get + { + return mCustomerContactName; + } + set + { + if (bReadOnly) + ThrowSetError(); + else + { + if (mCustomerContactName != value) + { + mCustomerContactName = value; + MarkDirty(); + + } + } + } + } + /// + /// Determines if a workorder is a template, a quote, a PM item, a workorder for a + /// client or an internal workorder + /// + public WorkorderTypes WorkorderType + { + get + { + return mWorkorderType; + } + set + { + if (bReadOnly) + ThrowSetError(); + else + { + if (mWorkorderType != value) + { + mWorkorderType = value; + MarkDirty(); + + } + } + } + } @@ -542,76 +543,76 @@ namespace GZTW.AyaNova.BLL - //Child objects + //Child objects - /// - /// If not a WorkorderPreventiveMaintenance, is null - /// If a WorkorderPreventiveMaintenance contains the WorkorderPreventiveMaintenance child object - /// - public WorkorderPreventiveMaintenance WorkorderPreventiveMaintenance - { - get - { - return mWorkorderPreventiveMaintenance; - } - } + /// + /// If not a WorkorderPreventiveMaintenance, is null + /// If a WorkorderPreventiveMaintenance contains the WorkorderPreventiveMaintenance child object + /// + public WorkorderPreventiveMaintenance WorkorderPreventiveMaintenance + { + get + { + return mWorkorderPreventiveMaintenance; + } + } - /// - /// If not a WorkorderService, is null - /// If a WorkorderService contains the WorkorderService child object - /// - public WorkorderService WorkorderService - { - get - { - return mService; - } - } + /// + /// If not a WorkorderService, is null + /// If a WorkorderService contains the WorkorderService child object + /// + public WorkorderService WorkorderService + { + get + { + return mService; + } + } - /// - /// Workorder items collection - /// - public WorkorderItems WorkorderItems - { - get - { - return mWorkorderItems; - } - } + /// + /// Workorder items collection + /// + public WorkorderItems WorkorderItems + { + get + { + return mWorkorderItems; + } + } - /// - /// If not a quote, is null - /// If a quote, contains the WorkorderQuote child object - /// - public WorkorderQuote WorkorderQuote - { - get - { - return mQuote; - } - } - - - + /// + /// If not a quote, is null + /// If a quote, contains the WorkorderQuote child object + /// + public WorkorderQuote WorkorderQuote + { + get + { + return mQuote; + } + } - //*************** CONTRACT / SERVICEBANK RELATED CODE ************************** - /// - /// Returns populated TypeAndID if the client or head office for this workorder is bankable - /// (If the unit is bankable that's handled separately) - /// - /// Returns null if not bankable - /// - public TypeAndID BankableResolved() - { + + + //*************** CONTRACT / SERVICEBANK RELATED CODE ************************** + + /// + /// Returns populated TypeAndID if the client or head office for this workorder is bankable + /// (If the unit is bankable that's handled separately) + /// + /// Returns null if not bankable + /// + public TypeAndID BankableResolved() + { if (AyaBizUtils.Lite) return null; - //internal service? - if(this.ClientID==Guid.Empty) return null; + //internal service? + if (this.ClientID == Guid.Empty) return null; //Case 576 return ServiceBankResolver.BankableObject(this.ClientID); @@ -628,8 +629,8 @@ namespace GZTW.AyaNova.BLL // return new TypeAndID(RootObjectTypes.HeadOffice, c.HeadOfficeID); //return null; - - } + + } /// /// Checks *all* possible bankable objects in this order: @@ -642,7 +643,7 @@ namespace GZTW.AyaNova.BLL /// it's place when there is a unit involved /// public TypeAndID BankableResolved(Guid WorkorderItemId) - { + { if (this.WorkorderItems[WorkorderItemId].HasUnit) { Unit u = Unit.GetItem(this.WorkorderItems[WorkorderItemId].UnitID); @@ -651,12 +652,12 @@ namespace GZTW.AyaNova.BLL return new TypeAndID(RootObjectTypes.Unit, u.ID); } } - + TypeAndID woTid = this.BankableResolved(); if (woTid == null) return new TypeAndID(RootObjectTypes.Nothing, Guid.Empty); else - return woTid; + return woTid; } @@ -668,21 +669,21 @@ namespace GZTW.AyaNova.BLL private Contract mResolvedContract = null; private bool mContractHasBeenResolved = false; - /// - /// Returns Contract that is most specific - /// or null if no contract - /// - /// - public Contract ContractResolved() - { + /// + /// Returns Contract that is most specific + /// or null if no contract + /// + /// + public Contract ContractResolved() + { //Added 28-Aug-2006 to speed up contract resolution for UI if (mContractHasBeenResolved) return mResolvedContract; - //internal service? + //internal service? if (this.ClientID == Guid.Empty) { mContractHasBeenResolved = true; - + return null; } @@ -699,7 +700,7 @@ namespace GZTW.AyaNova.BLL //{ // mContractHasBeenResolved = true; // mResolvedContract= Contract.GetItem(c.ContractID); - + // return mResolvedContract; //} @@ -725,7 +726,7 @@ namespace GZTW.AyaNova.BLL ////Resolved to be no contract applicable //mContractHasBeenResolved = true; //return null; - } + } //Added:17-Aug-2006 for wbi @@ -743,170 +744,170 @@ namespace GZTW.AyaNova.BLL return c.ID; } - //****************************************************************************** + //****************************************************************************** - /// - /// Mirror of global object's UseInventory setting - /// - public bool UseInventory - { - get - { - return mUseInventory; - } - - } + /// + /// Mirror of global object's UseInventory setting + /// + public bool UseInventory + { + get + { + return mUseInventory; + } + + } - - /// - /// Move workorderItem from current workorder to another - /// (Requires full rights and not a closed or read only workorder) - /// - /// - /// - public void MoveWorkorderItem(Guid ToWorkorderID, Guid WorkorderItemID) - { + + /// + /// Move workorderItem from current workorder to another + /// (Requires full rights and not a closed or read only workorder) + /// + /// + /// + public void MoveWorkorderItem(Guid ToWorkorderID, Guid WorkorderItemID) + { //case 1387 now checks rights to this object - if(this.mClosed || this.mServiceCompleted || Rights - /// Flag to indicate that service has been completed for this workorder - /// When true it means that all but workorder header items will become read only - /// this property can only be set from true to false by someone with full rights - /// to the workorder object - /// - public bool ServiceCompleted - { - get - { - return mServiceCompleted; - } - set - { - if(mWorkorderType!=WorkorderTypes.Service) - return; - //Attempting to service completed a workorder with broken rules? - //Can't allow because if we make it read only there is no - //way to fix the broken rules - if(!this.IsValid && value==true) - { - throw new System.ApplicationException - ( - LocalizedTextTable.GetLocalizedTextDirect("Workorder.Label.Error.NotCompleteableDueToErrors") - ); - } - if(bReadOnly) - ThrowSetError(); - else - { - if(mServiceCompleted!=value) - { - if(mServiceCompleted==true) - { - //User is attempting to set service to NOT completed, make sure they have rights... - + /// + /// Flag to indicate that service has been completed for this workorder + /// When true it means that all but workorder header items will become read only + /// this property can only be set from true to false by someone with full rights + /// to the workorder object + /// + public bool ServiceCompleted + { + get + { + return mServiceCompleted; + } + set + { + if (mWorkorderType != WorkorderTypes.Service) + return; + + //Attempting to service completed a workorder with broken rules? + //Can't allow because if we make it read only there is no + //way to fix the broken rules + if (!this.IsValid && value == true) + { + throw new System.ApplicationException + ( + LocalizedTextTable.GetLocalizedTextDirect("Workorder.Label.Error.NotCompleteableDueToErrors") + ); + + } + + if (bReadOnly) + ThrowSetError(); + else + { + if (mServiceCompleted != value) + { + if (mServiceCompleted == true) + { + //User is attempting to set service to NOT completed, make sure they have rights... + //case 413 changed rights check from > than read/write to > than readonly - if(Rights > SecurityLevelTypes.ReadOnly) - { - mServiceCompleted = value; - MarkDirty(); - //set all workorder items to correct status - this.mWorkorderItems.SetReadOnly(mServiceCompleted); - } - else - { - throw new System.Security.SecurityException - ( - string.Format - ( - LocalizedTextTable.GetLocalizedTextDirect("Error.Security.NotAuthorizedToChange"), - LocalizedTextTable.GetLocalizedTextDirect("O.WorkorderService") - ) - ); - } - } - else - { - mServiceCompleted = value; - MarkDirty(); - - //set all workorder items to correct status - this.mWorkorderItems.SetReadOnly(mServiceCompleted); - - } - - } - } - } - } + if (Rights > SecurityLevelTypes.ReadOnly) + { + mServiceCompleted = value; + MarkDirty(); + //set all workorder items to correct status + this.mWorkorderItems.SetReadOnly(mServiceCompleted); + } + else + { + throw new System.Security.SecurityException + ( + string.Format + ( + LocalizedTextTable.GetLocalizedTextDirect("Error.Security.NotAuthorizedToChange"), + LocalizedTextTable.GetLocalizedTextDirect("O.WorkorderService") + ) + ); + } + } + else + { + mServiceCompleted = value; + MarkDirty(); + + //set all workorder items to correct status + this.mWorkorderItems.SetReadOnly(mServiceCompleted); + + } + + } + } + } + } - /// - /// Used to close a workorder. - /// A closed workorder can never be re-opened, so this is a write once setting. - /// A closed workorder can no longer be edited in any manner permanently. + /// + /// Used to close a workorder. + /// A closed workorder can never be re-opened, so this is a write once setting. + /// A closed workorder can no longer be edited in any manner permanently. /// /// Closing a work order triggers a whost of tertiary methods that update related objects /// this process can not be reversed. - /// - public bool Closed - { - get - { - return mClosed; - } - set - { - if(mWorkorderType!=WorkorderTypes.Service) - return; + /// + public bool Closed + { + get + { + return mClosed; + } + set + { + if (mWorkorderType != WorkorderTypes.Service) + return; //case 986 ////Attempt to re-open a closed workorder? //if(mClosed==true && value==false) //{//unclose - + // throw new System.ApplicationException // ( // LocalizedTextTable.GetLocalizedTextDirect("Workorder.Label.Error.ClosedIsPermanent") @@ -956,17 +957,17 @@ namespace GZTW.AyaNova.BLL ); } } - - if(bReadOnly) - ThrowSetError(); - else - { - if(mClosed!=value) - { - mClosed = value; - MarkDirty(); - - } + + if (bReadOnly) + ThrowSetError(); + else + { + if (mClosed != value) + { + mClosed = value; + MarkDirty(); + + } if (mClosed) { @@ -987,9 +988,9 @@ namespace GZTW.AyaNova.BLL bReadOnly = false; this.mWorkorderItems.SetReadOnly(false); } - } - } - } + } + } + } //case 3132 /// @@ -1019,136 +1020,136 @@ namespace GZTW.AyaNova.BLL - /// - /// False if any outstanding parts (not set to "Used in service") - /// True if all parts are set to used in service. - /// - public bool AllPartsUsed - { - get - { - //If it's not a service invoice then always return true - if(mWorkorderType!=WorkorderTypes.Service) - return true; + /// + /// False if any outstanding parts (not set to "Used in service") + /// True if all parts are set to used in service. + /// + public bool AllPartsUsed + { + get + { + //If it's not a service invoice then always return true + if (mWorkorderType != WorkorderTypes.Service) + return true; - foreach(WorkorderItem wi in this.WorkorderItems) - { - foreach(WorkorderItemPart wip in wi.Parts) - { - if(wip.Used!=true) - return false; - } - } + foreach (WorkorderItem wi in this.WorkorderItems) + { + foreach (WorkorderItemPart wip in wi.Parts) + { + if (wip.Used != true) + return false; + } + } - return true; + return true; - } - } + } + } - /// - /// Sets all parts to used = true on entire workorder - /// - public void SetAllPartsUsed() - { - //If it's not a service invoice then nothing to set - if(mWorkorderType!=WorkorderTypes.Service) - return; + /// + /// Sets all parts to used = true on entire workorder + /// + public void SetAllPartsUsed() + { + //If it's not a service invoice then nothing to set + if (mWorkorderType != WorkorderTypes.Service) + return; - foreach(WorkorderItem wi in this.WorkorderItems) - { - foreach(WorkorderItemPart wip in wi.Parts) - { - - if(wip.Used!=true) - wip.Used=true; - } - } - } + foreach (WorkorderItem wi in this.WorkorderItems) + { + foreach (WorkorderItemPart wip in wi.Parts) + { - /// - /// Create a labor object from a scheduled user object to save entry time - /// - /// - /// - /// - public Guid CreateLaborFromScheduledUser(Guid SourceWorkorderItemID,Guid SourceWorkorderItemScheduledUserID) - { - if(this.bReadOnly) return Guid.Empty; - if(mWorkorderType!=WorkorderTypes.Service) return Guid.Empty; - if(mClosed||mServiceCompleted) return Guid.Empty; + if (wip.Used != true) + wip.Used = true; + } + } + } - foreach(WorkorderItem wi in this.WorkorderItems) - { - if(wi.ID==SourceWorkorderItemID) - { - foreach(WorkorderItemScheduledUser u in wi.ScheduledUsers) - { - if(u.ID==SourceWorkorderItemScheduledUserID) - { - WorkorderItemLabor wil=wi.Labors.Add(wi); - wil.UserID=u.UserID; - wil.ServiceStartDate=u.StartDate; - wil.ServiceStopDate=u.StopDate; - wil.ServiceRateID=u.ServiceRateID; - wil.ServiceRateQuantity=u.EstimatedQuantity; - return wil.ID; - } - } - } - } + /// + /// Create a labor object from a scheduled user object to save entry time + /// + /// + /// + /// + public Guid CreateLaborFromScheduledUser(Guid SourceWorkorderItemID, Guid SourceWorkorderItemScheduledUserID) + { + if (this.bReadOnly) return Guid.Empty; + if (mWorkorderType != WorkorderTypes.Service) return Guid.Empty; + if (mClosed || mServiceCompleted) return Guid.Empty; - //records not found - return Guid.Empty; + foreach (WorkorderItem wi in this.WorkorderItems) + { + if (wi.ID == SourceWorkorderItemID) + { + foreach (WorkorderItemScheduledUser u in wi.ScheduledUsers) + { + if (u.ID == SourceWorkorderItemScheduledUserID) + { + WorkorderItemLabor wil = wi.Labors.Add(wi); + wil.UserID = u.UserID; + wil.ServiceStartDate = u.StartDate; + wil.ServiceStopDate = u.StopDate; + wil.ServiceRateID = u.ServiceRateID; + wil.ServiceRateQuantity = u.EstimatedQuantity; + return wil.ID; + } + } + } + } - } + //records not found + return Guid.Empty; -/// -/// Find the workorder item ID that contains the object passed in -/// -/// Type of workorder item descendant object -/// ID of descendant of workorder item -/// - public Guid GetWorkorderItemIDFromDescendant(RootObjectTypes DescendantObjectType, Guid DescendantID) - { - foreach(WorkorderItem wi in this.WorkorderItems) - { - switch(DescendantObjectType) - { - case RootObjectTypes.WorkorderItemLabor: - { - foreach(WorkorderItemLabor d in wi.Labors) - {if(d.ID==DescendantID) return wi.ID;} - } - break; - case RootObjectTypes.WorkorderItemMiscExpense: - { - foreach(WorkorderItemMiscExpense d in wi.Expenses) - {if(d.ID==DescendantID) return wi.ID;} - } - break; - case RootObjectTypes.WorkorderItemOutsideService: - { - if(wi.OutsideService.ID==DescendantID) return wi.ID; - } - break; - case RootObjectTypes.WorkorderItemPart: - { - foreach(WorkorderItemPart d in wi.Parts) - {if(d.ID==DescendantID) return wi.ID;} - } - break; - case RootObjectTypes.WorkorderItemScheduledUser: - { - foreach(WorkorderItemScheduledUser d in wi.ScheduledUsers) - {if(d.ID==DescendantID) return wi.ID;} - } - break; - case RootObjectTypes.WorkorderItemTravel: - { - foreach(WorkorderItemTravel d in wi.Travels) - {if(d.ID==DescendantID) return wi.ID;} - } - break; + } + + /// + /// Find the workorder item ID that contains the object passed in + /// + /// Type of workorder item descendant object + /// ID of descendant of workorder item + /// + public Guid GetWorkorderItemIDFromDescendant(RootObjectTypes DescendantObjectType, Guid DescendantID) + { + foreach (WorkorderItem wi in this.WorkorderItems) + { + switch (DescendantObjectType) + { + case RootObjectTypes.WorkorderItemLabor: + { + foreach (WorkorderItemLabor d in wi.Labors) + { if (d.ID == DescendantID) return wi.ID; } + } + break; + case RootObjectTypes.WorkorderItemMiscExpense: + { + foreach (WorkorderItemMiscExpense d in wi.Expenses) + { if (d.ID == DescendantID) return wi.ID; } + } + break; + case RootObjectTypes.WorkorderItemOutsideService: + { + if (wi.OutsideService.ID == DescendantID) return wi.ID; + } + break; + case RootObjectTypes.WorkorderItemPart: + { + foreach (WorkorderItemPart d in wi.Parts) + { if (d.ID == DescendantID) return wi.ID; } + } + break; + case RootObjectTypes.WorkorderItemScheduledUser: + { + foreach (WorkorderItemScheduledUser d in wi.ScheduledUsers) + { if (d.ID == DescendantID) return wi.ID; } + } + break; + case RootObjectTypes.WorkorderItemTravel: + { + foreach (WorkorderItemTravel d in wi.Travels) + { if (d.ID == DescendantID) return wi.ID; } + } + break; case RootObjectTypes.WorkorderItemPartRequest://case 1086 { foreach (WorkorderItemPartRequest d in wi.PartRequests) @@ -1165,138 +1166,138 @@ namespace GZTW.AyaNova.BLL default: throw new System.NotSupportedException("Workorder->GetWorkorderItemIDFromDescendant Error - object type not supported: " + DescendantObjectType.ToString()); #endif - - - } - } - - //Not found - return Guid.Empty; - - } - /// - /// ID of quote that created this workorder - /// Set internally when the Quote workorder generates a service - /// workorder. - /// - public Guid FromQuoteID - { - get - { - return mFromQuoteID; - } - } + } + } - - /// - /// ID of PreventiveMaintenance that created this workorder - /// Set internally when the PM workorder generates a service - /// workorder. - /// - public Guid FromPMID - { - get - { - return mFromPMID; - } - } + //Not found + return Guid.Empty; + + } - /// - /// True if on a service workorder there are any parts with a reserved quantity > 0 - /// - /// Non service workorders (quotes / pm) always return false - /// - /// Used in Workorder form to determine whether to show the - /// reserved parts field or not. - /// - /// Reserved parts are only on workorders generated from P.M. or quotes - /// when inventory is being used. - /// - public bool HasReservedParts - { - get - { - //If it's not a service invoice then always return false - if(mWorkorderType!=WorkorderTypes.Service) - return false; - - foreach(WorkorderItem wi in this.WorkorderItems) - { - foreach(WorkorderItemPart wip in wi.Parts) - { - if(wip.QuantityReserved>0) - return true; - } - } - - return false; - - } - } - - /// - /// True means there are loan items not yet returned - /// - /// - /// - public bool HasOutstandingLoanItems - { - get - { - //If it's not a service invoice then always return false - if(mWorkorderType!=WorkorderTypes.Service) - return false; - - foreach(WorkorderItem wi in this.WorkorderItems) - { - foreach(WorkorderItemLoan w in wi.Loans) - { - if(w.ReturnDate==System.DBNull.Value) - return true; - } - } - - return false; - - } + /// + /// ID of quote that created this workorder + /// Set internally when the Quote workorder generates a service + /// workorder. + /// + public Guid FromQuoteID + { + get + { + return mFromQuoteID; + } + } - } + /// + /// ID of PreventiveMaintenance that created this workorder + /// Set internally when the PM workorder generates a service + /// workorder. + /// + public Guid FromPMID + { + get + { + return mFromPMID; + } + } - /// - /// True means there are WorkorderItemPartRequest items - /// still on order and not fully received - /// - /// Note: if GlobalSettings.UseInventory is set to false this will + + /// + /// True if on a service workorder there are any parts with a reserved quantity > 0 + /// + /// Non service workorders (quotes / pm) always return false + /// + /// Used in Workorder form to determine whether to show the + /// reserved parts field or not. + /// + /// Reserved parts are only on workorders generated from P.M. or quotes + /// when inventory is being used. + /// + public bool HasReservedParts + { + get + { + //If it's not a service invoice then always return false + if (mWorkorderType != WorkorderTypes.Service) + return false; + + foreach (WorkorderItem wi in this.WorkorderItems) + { + foreach (WorkorderItemPart wip in wi.Parts) + { + if (wip.QuantityReserved > 0) + return true; + } + } + + return false; + + } + } + + /// + /// True means there are loan items not yet returned + /// + /// + /// + public bool HasOutstandingLoanItems + { + get + { + //If it's not a service invoice then always return false + if (mWorkorderType != WorkorderTypes.Service) + return false; + + foreach (WorkorderItem wi in this.WorkorderItems) + { + foreach (WorkorderItemLoan w in wi.Loans) + { + if (w.ReturnDate == System.DBNull.Value) + return true; + } + } + + return false; + + } + + + } + + /// + /// True means there are WorkorderItemPartRequest items + /// still on order and not fully received + /// + /// Note: if GlobalSettings.UseInventory is set to false this will /// always return false - /// - public bool HasPartRequestsOnOrder - { - get - { - //If it's not a service invoice then always return false - if(mWorkorderType!=WorkorderTypes.Service) - return false; + /// + public bool HasPartRequestsOnOrder + { + get + { + //If it's not a service invoice then always return false + if (mWorkorderType != WorkorderTypes.Service) + return false; //case 932 if (!AyaBizUtils.GlobalSettings.UseInventory) return false; - - foreach(WorkorderItem wi in this.WorkorderItems) - { - if(wi.HasPartRequestsOnOrder) - return true; - } - return false; + foreach (WorkorderItem wi in this.WorkorderItems) + { + if (wi.HasPartRequestsOnOrder) + return true; + } - } + return false; + + } - } + } //Case 398 @@ -1333,26 +1334,26 @@ namespace GZTW.AyaNova.BLL } - //Added 25-April-2006 to ensure a serial number can't be selected twice - /// - /// Returns true if the serial number record is selected - /// anywhere in the workorder item parts collections - /// - /// ID of PartSerial record - /// - public bool HasSerialNumberSelected(Guid PartSerialID) - { - foreach(WorkorderItem wi in this.WorkorderItems) - { - foreach(WorkorderItemPart p in wi.Parts) - { - if(p.PartSerialID==PartSerialID) - return true; - } - } - return false; + //Added 25-April-2006 to ensure a serial number can't be selected twice + /// + /// Returns true if the serial number record is selected + /// anywhere in the workorder item parts collections + /// + /// ID of PartSerial record + /// + public bool HasSerialNumberSelected(Guid PartSerialID) + { + foreach (WorkorderItem wi in this.WorkorderItems) + { + foreach (WorkorderItemPart p in wi.Parts) + { + if (p.PartSerialID == PartSerialID) + return true; + } + } + return false; - } + } //Added:17-Aug-2006 for wbi @@ -1373,8 +1374,8 @@ namespace GZTW.AyaNova.BLL { if (!l.Contains(wl.ServiceRateID)) l.Add(wl.ServiceRateID); - - + + } } return l; @@ -1390,11 +1391,11 @@ namespace GZTW.AyaNova.BLL public System.Collections.Generic.List ListOfUnitsSelected() { System.Collections.Generic.List l = new System.Collections.Generic.List(); - + foreach (WorkorderItem wi in this.WorkorderItems) { if (wi.UnitID != Guid.Empty && !l.Contains(wi.UnitID)) - l.Add(wi.UnitID); + l.Add(wi.UnitID); } return l; } @@ -1455,7 +1456,7 @@ namespace GZTW.AyaNova.BLL public System.Collections.Generic.List ListOfTravelRatesSelected() { System.Collections.Generic.List l = new System.Collections.Generic.List(); - + foreach (WorkorderItem wi in this.WorkorderItems) { foreach (WorkorderItemTravel wl in wi.Travels) @@ -1479,7 +1480,7 @@ namespace GZTW.AyaNova.BLL public System.Collections.Generic.List ListOfPartsSelected() { System.Collections.Generic.List l = new System.Collections.Generic.List(); - + foreach (WorkorderItem wi in this.WorkorderItems) { foreach (WorkorderItemPart wl in wi.Parts) @@ -1550,7 +1551,7 @@ namespace GZTW.AyaNova.BLL public System.Collections.Generic.List ListOfScheduledUsersLaborRatesSelected() { System.Collections.Generic.List l = new System.Collections.Generic.List(); - + foreach (WorkorderItem wi in this.WorkorderItems) { foreach (WorkorderItemScheduledUser wl in wi.ScheduledUsers) @@ -1612,7 +1613,7 @@ namespace GZTW.AyaNova.BLL //Added:28-Sept-2006 for wbi - + /// /// A List of Guid's of serial numbers selected /// anywhere in this work order. @@ -1631,7 +1632,7 @@ namespace GZTW.AyaNova.BLL { foreach (WorkorderItemPart wl in wi.Parts) { - if (!l.Contains(wl.PartSerialID) && wl.PartSerialID!=excludeID) + if (!l.Contains(wl.PartSerialID) && wl.PartSerialID != excludeID) l.Add(wl.PartSerialID); @@ -1799,7 +1800,7 @@ namespace GZTW.AyaNova.BLL get { if (!IsEditable) return false; - if (AyaBizUtils.Right(RootObjectTypes.WorkorderItem) < (int)SecurityLevelTypes.ReadWrite) return false; + if (AyaBizUtils.Right(RootObjectTypes.WorkorderItem) < (int)SecurityLevelTypes.ReadWrite) return false; return true; } } @@ -1834,8 +1835,8 @@ namespace GZTW.AyaNova.BLL if (!IsWorkorderItemEditable) return false; if (AyaBizUtils.Right(WorkorderItemChildObjectType) < (int)SecurityLevelTypes.ReadWrite) return false; - return true; - + return true; + } /// @@ -1851,14 +1852,14 @@ namespace GZTW.AyaNova.BLL return true; } - - + + /// /// Quick check if workorder item child is viewable or not /// public bool IsWorkorderItemChildViewable(RootObjectTypes WorkorderItemChildObjectType)//case 1975 - { - return (AyaBizUtils.Right(WorkorderItemChildObjectType) > (int)SecurityLevelTypes.NoAccess); + { + return (AyaBizUtils.Right(WorkorderItemChildObjectType) > (int)SecurityLevelTypes.NoAccess); } /// @@ -1923,7 +1924,7 @@ namespace GZTW.AyaNova.BLL } } - + /// @@ -2026,7 +2027,7 @@ namespace GZTW.AyaNova.BLL } - + /// /// Returns true if sufficient rights to @@ -2045,7 +2046,7 @@ namespace GZTW.AyaNova.BLL } } - /// + /// /// Returns true if sufficient rights to /// outside service fields /// (Object.WorkorderItemOutsideService) @@ -2109,14 +2110,14 @@ namespace GZTW.AyaNova.BLL //Case 350 - rewrote this to work properly if (!this.Closed) - return false; + return false; if (!User.IsAdmin && !AyaBizUtils.Lite)//case 1172 return false; - - return true; + + return true; } } @@ -2134,22 +2135,22 @@ namespace GZTW.AyaNova.BLL { if (!IsDirty) return "Nothing"; System.Text.StringBuilder sb = new System.Text.StringBuilder(); - + sb.Append("Dirty (changed and unsaved) objects in workorder tree:\r\n"); - + if (base.IsDirty) sb.Append("WorkorderHeader\r\n"); if ((this.WorkorderType == WorkorderTypes.PreventiveMaintenance || this.WorkorderType == WorkorderTypes.TemplatePreventiveMaintenance) && mWorkorderPreventiveMaintenance.IsDirty) sb.Append("WorkorderPreventiveMaintenance\r\n"); - if ((this.WorkorderType == WorkorderTypes.Quote || this.WorkorderType== WorkorderTypes.TemplateQuote) && mQuote.IsDirty) + if ((this.WorkorderType == WorkorderTypes.Quote || this.WorkorderType == WorkorderTypes.TemplateQuote) && mQuote.IsDirty) sb.Append("WorkOrderQuote\r\n"); if ((this.WorkorderType == WorkorderTypes.Service || this.WorkorderType == WorkorderTypes.TemplateService) && mService.IsDirty) sb.Append("WorkorderService\r\n"); - if(mDocs.IsDirty) + if (mDocs.IsDirty) sb.Append("AssignedDocs\r\n"); if (mWorkorderItems.IsDirty) @@ -2159,7 +2160,7 @@ namespace GZTW.AyaNova.BLL { if (wi.IsDirty) { - sb.Append("Item: " + wi.TechNotes+"\r\n"); + sb.Append("Item: " + wi.TechNotes + "\r\n"); if (wi.Expenses.IsDirty) sb.Append("\tExpenses\r\n"); if (wi.Labors.IsDirty) @@ -2169,7 +2170,7 @@ namespace GZTW.AyaNova.BLL sb.Append("\tLoans\r\n"); if (wi.OutsideService.IsDirty) sb.Append("\tOutsideService\r\n"); - if ( wi.PartRequests.IsDirty) + if (wi.PartRequests.IsDirty) sb.Append("\tPartRequests\r\n"); if (wi.Parts.IsDirty) sb.Append("\tParts\r\n"); @@ -2198,105 +2199,105 @@ namespace GZTW.AyaNova.BLL { get { - if(IsValid) return "Nothing"; + if (IsValid) return "Nothing"; System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("Objects with broken rules in workorder tree:\r\n"); - if(!base.IsValid) + if (!base.IsValid) { sb.AppendLine("WorkorderHeader broken rules:"); sb.AppendLine(base.BrokenRulesText); } - if((this.WorkorderType == WorkorderTypes.PreventiveMaintenance || this.WorkorderType == WorkorderTypes.TemplatePreventiveMaintenance) && (!mWorkorderPreventiveMaintenance.IsValid)) + if ((this.WorkorderType == WorkorderTypes.PreventiveMaintenance || this.WorkorderType == WorkorderTypes.TemplatePreventiveMaintenance) && (!mWorkorderPreventiveMaintenance.IsValid)) sb.AppendLine("WorkorderPreventiveMaintenance\r\n" + mWorkorderPreventiveMaintenance.BrokenRulesText); - - if((this.WorkorderType == WorkorderTypes.Quote || this.WorkorderType == WorkorderTypes.TemplateQuote) && (!mQuote.IsValid)) - sb.AppendLine("WorkOrderQuote\r\n"+mQuote.BrokenRulesText); - - if((this.WorkorderType == WorkorderTypes.Service || this.WorkorderType == WorkorderTypes.TemplateService) && (!mService.IsValid)) + if ((this.WorkorderType == WorkorderTypes.Quote || this.WorkorderType == WorkorderTypes.TemplateQuote) && (!mQuote.IsValid)) + sb.AppendLine("WorkOrderQuote\r\n" + mQuote.BrokenRulesText); + + + if ((this.WorkorderType == WorkorderTypes.Service || this.WorkorderType == WorkorderTypes.TemplateService) && (!mService.IsValid)) sb.AppendLine("WorkorderService\r\n" + mService.BrokenRulesText); - - - - foreach(WorkorderItem wi in this.mWorkorderItems) + + + + foreach (WorkorderItem wi in this.mWorkorderItems) + { + if (!wi.IsValid) { - if(!wi.IsValid) + sb.AppendLine("WorkorderItem: " + wi.TechNotes); + if (!wi.Expenses.IsValid) { - sb.AppendLine("WorkorderItem: " + wi.TechNotes); - if(!wi.Expenses.IsValid) + foreach (WorkorderItemMiscExpense i in wi.Expenses) { - foreach(WorkorderItemMiscExpense i in wi.Expenses) - { - if(!i.IsValid) + if (!i.IsValid) sb.AppendLine("\tExpense (name) " + i.Name + "\r\n" + i.BrokenRulesText); - } } - - if(!wi.Labors.IsValid) - { - foreach(WorkorderItemLabor i in wi.Labors) - { - if(!i.IsValid) - sb.AppendLine("\tLabor (start date time)" + i.ServiceStartDate.ToString() + "\r\n" + i.BrokenRulesText); - } - } - - if(!wi.Loans.IsValid) - { - foreach(WorkorderItemLoan i in wi.Loans) - { - if(!i.IsValid) - sb.AppendLine("\tLoan (out date) " + i.OutDate.ToString() + "\r\n" + i.BrokenRulesText); - } - } - - - if(!wi.OutsideService.IsValid) - sb.AppendLine("\tOutsideService\r\n" + wi.OutsideService.BrokenRulesText); - - if(!wi.PartRequests.IsValid) - { - foreach(WorkorderItemPartRequest i in wi.PartRequests) - { - if(!i.IsValid) - sb.AppendLine("\tPartRequest (qty) " + i.Quantity.ToString() + "\r\n" + i.BrokenRulesText); - } - } - - if(!wi.Parts.IsValid) - { - foreach(WorkorderItemPart i in wi.Parts) - { - if(!i.IsValid) - sb.AppendLine("\tPart (price - qty) " + i.Price.ToString() + " - " + i.Quantity.ToString() + "\r\n" + i.BrokenRulesText); - } - } - - if(!wi.ScheduledUsers.IsValid) - { - foreach(WorkorderItemScheduledUser i in wi.ScheduledUsers) - { - if(!i.IsValid) - sb.AppendLine("\tScheduledUser (start date) " + i.StartDate.ToString() + "\r\n" + i.BrokenRulesText); - } - } - - if(!wi.Travels.IsValid) - { - foreach(WorkorderItemTravel i in wi.Travels) - { - if(!i.IsValid) - sb.AppendLine("\tTravel (start date time)" + i.TravelStartDate.ToString() + "\r\n" + i.BrokenRulesText); - } - } - } + + if (!wi.Labors.IsValid) + { + foreach (WorkorderItemLabor i in wi.Labors) + { + if (!i.IsValid) + sb.AppendLine("\tLabor (start date time)" + i.ServiceStartDate.ToString() + "\r\n" + i.BrokenRulesText); + } + } + + if (!wi.Loans.IsValid) + { + foreach (WorkorderItemLoan i in wi.Loans) + { + if (!i.IsValid) + sb.AppendLine("\tLoan (out date) " + i.OutDate.ToString() + "\r\n" + i.BrokenRulesText); + } + } + + + if (!wi.OutsideService.IsValid) + sb.AppendLine("\tOutsideService\r\n" + wi.OutsideService.BrokenRulesText); + + if (!wi.PartRequests.IsValid) + { + foreach (WorkorderItemPartRequest i in wi.PartRequests) + { + if (!i.IsValid) + sb.AppendLine("\tPartRequest (qty) " + i.Quantity.ToString() + "\r\n" + i.BrokenRulesText); + } + } + + if (!wi.Parts.IsValid) + { + foreach (WorkorderItemPart i in wi.Parts) + { + if (!i.IsValid) + sb.AppendLine("\tPart (price - qty) " + i.Price.ToString() + " - " + i.Quantity.ToString() + "\r\n" + i.BrokenRulesText); + } + } + + if (!wi.ScheduledUsers.IsValid) + { + foreach (WorkorderItemScheduledUser i in wi.ScheduledUsers) + { + if (!i.IsValid) + sb.AppendLine("\tScheduledUser (start date) " + i.StartDate.ToString() + "\r\n" + i.BrokenRulesText); + } + } + + if (!wi.Travels.IsValid) + { + foreach (WorkorderItemTravel i in wi.Travels) + { + if (!i.IsValid) + sb.AppendLine("\tTravel (start date time)" + i.TravelStartDate.ToString() + "\r\n" + i.BrokenRulesText); + } + } + } - + } + return sb.ToString(); @@ -2357,23 +2358,23 @@ namespace GZTW.AyaNova.BLL { get { - RootObjectTypes rotype=Workorder.RootObjectTypeFromWorkorderType(this.WorkorderType); + RootObjectTypes rotype = Workorder.RootObjectTypeFromWorkorderType(this.WorkorderType); switch (this.WorkorderType) { case WorkorderTypes.Quote: case WorkorderTypes.TemplateQuote: return new TypeAndID(rotype, mQuote.ID); - + case WorkorderTypes.Service: case WorkorderTypes.TemplateService: return new TypeAndID(RootObjectTypes.Workorder, mID); - + case WorkorderTypes.PreventiveMaintenance: case WorkorderTypes.TemplatePreventiveMaintenance: return new TypeAndID(rotype, this.mWorkorderPreventiveMaintenance.ID); default: return new TypeAndID(RootObjectTypes.Nothing, Guid.Empty); - + } } } @@ -2384,7 +2385,7 @@ namespace GZTW.AyaNova.BLL /// /// This is cached for the lifetime of this object /// - + public bool CanWiki//case 73 { get @@ -2399,7 +2400,7 @@ namespace GZTW.AyaNova.BLL private bool? bCanWiki = null; - + /// /// Flag - indicates if this object has a wikipage or not /// @@ -2408,11 +2409,11 @@ namespace GZTW.AyaNova.BLL { get { - return WikiPageExistanceChecker.WikiPageExists(mID); + return WikiPageExistanceChecker.WikiPageExists(mID); } } - + //case 941 /// @@ -2425,26 +2426,26 @@ namespace GZTW.AyaNova.BLL switch (mWorkorderType) { case WorkorderTypes.Service: - return RootObjectTypes.WorkorderService;//case 1387 - + return RootObjectTypes.WorkorderService;//case 1387 + case WorkorderTypes.Quote: - return RootObjectTypes.WorkorderQuote; - + return RootObjectTypes.WorkorderQuote; + case WorkorderTypes.PreventiveMaintenance: - return RootObjectTypes.WorkorderPreventiveMaintenance; - + return RootObjectTypes.WorkorderPreventiveMaintenance; + case WorkorderTypes.TemplateService: - return RootObjectTypes.WorkorderServiceTemplate; - + return RootObjectTypes.WorkorderServiceTemplate; + case WorkorderTypes.TemplateQuote: - return RootObjectTypes.WorkorderQuoteTemplate; - + return RootObjectTypes.WorkorderQuoteTemplate; + case WorkorderTypes.TemplatePreventiveMaintenance: - return RootObjectTypes.WorkorderPreventiveMaintenanceTemplate; - + return RootObjectTypes.WorkorderPreventiveMaintenanceTemplate; + default: return RootObjectTypes.Nothing; - + } } } @@ -2473,12 +2474,12 @@ namespace GZTW.AyaNova.BLL } if (src == null) throw new System.ApplicationException("GenerateUnitFromPart -> WorkorderItemPartID specified not found in Workorder"); - Part p=Part.GetItem(src.PartID); - Client c=Client.GetItem(mClientID); + Part p = Part.GetItem(src.PartID); + Client c = Client.GetItem(mClientID); string sSerial = DBUtil.CurrentWorkingDateTime.ToString(); - if(src.PartSerialID!=Guid.Empty) + if (src.PartSerialID != Guid.Empty) { - sSerial = PartSerial.GetSerialNumberFromPartSerialID(src.PartSerialID); + sSerial = PartSerial.GetSerialNumberFromPartSerialID(src.PartSerialID); } Unit u = Unit.NewItem(); u.Active = true; @@ -2488,11 +2489,11 @@ namespace GZTW.AyaNova.BLL Address.Copy(c.GoToAddress, u.GoToAddress); u.PurchasedDate = this.mService.ServiceDate; u.BoughtHere = true; - + return u; } - + //case 866 /// /// Check to see if current thread user has more than read only rights to Object.Unit @@ -2572,13 +2573,13 @@ namespace GZTW.AyaNova.BLL case WorkorderTypes.Service: case WorkorderTypes.TemplateService: { - if(mService.WorkorderStatusID==Guid.Empty) return "-"; + if (mService.WorkorderStatusID == Guid.Empty) return "-"; return NameFetcher.GetItem(RootObjectTypes.WorkorderStatus, mService.WorkorderStatusID, true).RecordName; } case WorkorderTypes.Quote: case WorkorderTypes.TemplateQuote: - { + { return EnumDescConverter.GetEnumDescription(mQuote.QuoteStatus); } @@ -2592,7 +2593,7 @@ namespace GZTW.AyaNova.BLL default: return "Workorder->uiDisplayHeaderStatus unsupported type:" + mWorkorderType.ToString(); - } + } } } @@ -2629,10 +2630,10 @@ namespace GZTW.AyaNova.BLL public Client uiClient { get - { + { //insurance if (mClientID == Guid.Empty) return null; - return Client.GetItemNoMRU(mClientID); + return Client.GetItemNoMRU(mClientID); } } @@ -2645,7 +2646,7 @@ namespace GZTW.AyaNova.BLL { get { - return ContractResolved() != null; + return ContractResolved() != null; } } @@ -2659,7 +2660,7 @@ namespace GZTW.AyaNova.BLL { get { - SecurityLevelTypes baseLevel=(SecurityLevelTypes)AyaBizUtils.Right(this.RootObjectType); + SecurityLevelTypes baseLevel = (SecurityLevelTypes)AyaBizUtils.Right(this.RootObjectType); //if they have limited rights in any case then just return them as they will be the most //limited of all rights if (baseLevel < SecurityLevelTypes.ReadWrite) @@ -2730,7 +2731,7 @@ namespace GZTW.AyaNova.BLL } } } - + /// @@ -2742,10 +2743,10 @@ namespace GZTW.AyaNova.BLL get { if (mWorkorderType != WorkorderTypes.Service) return false; - if (mClosed) return false; + if (mClosed) return false; if (mRights < SecurityLevelTypes.ReadWrite) return false; if (!mServiceCompleted) return false; - + return true; } } @@ -2759,189 +2760,189 @@ namespace GZTW.AyaNova.BLL get { if (mWorkorderType != WorkorderTypes.Service) return false; - return mService.Signature.HasSignature; + return mService.Signature.HasSignature; } } - - /// - /// Throw an error when a read only user - /// tries to set a property - /// (this should normally never be called unless someone is using the developer api since the UI - /// should prevent it from happening initially) - /// - private void ThrowSetError() - { - throw new System.Security.SecurityException - ( - string.Format - ( - LocalizedTextTable.GetLocalizedTextDirect("Error.Security.NotAuthorizedToChange"), - LocalizedTextTable.GetLocalizedTextDirect("O.Workorder") - ) - ); - } - #endregion + /// + /// Throw an error when a read only user + /// tries to set a property + /// (this should normally never be called unless someone is using the developer api since the UI + /// should prevent it from happening initially) + /// + private void ThrowSetError() + { + throw new System.Security.SecurityException + ( + string.Format + ( + LocalizedTextTable.GetLocalizedTextDirect("Error.Security.NotAuthorizedToChange"), + LocalizedTextTable.GetLocalizedTextDirect("O.Workorder") + ) + ); + } - #region System.object overrides + #endregion + + #region System.object overrides /// /// /// /// - public override string ToString() - { - return "WO Header" + mID.ToString(); - } + public override string ToString() + { + return "WO Header" + mID.ToString(); + } - /// - /// - /// - /// - /// - public override bool Equals(Object obj) - { - if ( obj == null || GetType ( ) != obj.GetType ( ) ) return false; - Workorder c=(Workorder)obj; - return mID==c.mID; - } + /// + /// + /// + /// + /// + public override bool Equals(Object obj) + { + if (obj == null || GetType() != obj.GetType()) return false; + Workorder c = (Workorder)obj; + return mID == c.mID; + } /// /// /// /// - public override int GetHashCode() - { - return ("WO Header"+mID.ToString()).GetHashCode(); - } - #endregion + public override int GetHashCode() + { + return ("WO Header" + mID.ToString()).GetHashCode(); + } + #endregion - #region Searching + #region Searching - /// - /// Returns a search result object based on search terms - /// for the ID specified - /// - /// - /// - /// - public static SearchResult GetSearchResult(Guid ID, string[]searchTerms) - { - SearchResult sr=new SearchResult(); + /// + /// Returns a search result object based on search terms + /// for the ID specified + /// + /// + /// + /// + public static SearchResult GetSearchResult(Guid ID, string[] searchTerms) + { + SearchResult sr = new SearchResult(); - System.Text.StringBuilder sb = new System.Text.StringBuilder(); - - SafeDataReader dr = null; - try - { - dr=DBUtil.GetReaderFromSQLString( + System.Text.StringBuilder sb = new System.Text.StringBuilder(); - "SELECT aWorkorder.aID, aWorkorder.aCreated, aWorkorder.aModified, " + - " aWorkorder.aModifier, aWorkorder.aCreator, aWorkorder.ATemplateDescription, " +//Case 670 - " aClient.aName, aClient.aRegionID AS ACLIENTREGION, aWorkorder.aInternalReferenceNumber, " + - " aWorkorder.aCustomerReferenceNumber, " + - " aWorkorder.aCustomerContactName, aWorkorder.aSummary, " + - " aWorkorder.aWorkorderType, aWorkorderQuote.aQuoteNumber, " + - " aWorkorderService.aServiceNumber, aWorkorderPreventiveMaintenance.aPreventiveMaintenanceNumber " + - "FROM aWorkorder LEFT OUTER JOIN aWorkorderPreventiveMaintenance " + - "ON aWorkorder.aID " + - "= aWorkorderPreventiveMaintenance.aWorkorderID " + - "LEFT OUTER JOIN aWorkorderService ON aWorkorder.aID " + - "= aWorkorderService.aWorkorderID LEFT OUTER " + - "JOIN aWorkorderQuote ON aWorkorder.aID = aWorkorderQuote.aWorkorderID " + - "LEFT OUTER JOIN aClient " + - "ON aWorkorder.aClientID = aClient.aID WHERE " + - "(aWorkorder.aID = @ID)" - ,ID); + SafeDataReader dr = null; + try + { + dr = DBUtil.GetReaderFromSQLString( - if (!dr.Read()) - return new SearchResult();//DBUtil.ThrowFetchError("SearchResult for WorkorderID: " + ID.ToString()); + "SELECT aWorkorder.aID, aWorkorder.aCreated, aWorkorder.aModified, " + + " aWorkorder.aModifier, aWorkorder.aCreator, aWorkorder.ATemplateDescription, " +//Case 670 + " aClient.aName, aClient.aRegionID AS ACLIENTREGION, aWorkorder.aInternalReferenceNumber, " + + " aWorkorder.aCustomerReferenceNumber, " + + " aWorkorder.aCustomerContactName, aWorkorder.aSummary, " + + " aWorkorder.aWorkorderType, aWorkorderQuote.aQuoteNumber, " + + " aWorkorderService.aServiceNumber, aWorkorderPreventiveMaintenance.aPreventiveMaintenanceNumber " + + "FROM aWorkorder LEFT OUTER JOIN aWorkorderPreventiveMaintenance " + + "ON aWorkorder.aID " + + "= aWorkorderPreventiveMaintenance.aWorkorderID " + + "LEFT OUTER JOIN aWorkorderService ON aWorkorder.aID " + + "= aWorkorderService.aWorkorderID LEFT OUTER " + + "JOIN aWorkorderQuote ON aWorkorder.aID = aWorkorderQuote.aWorkorderID " + + "LEFT OUTER JOIN aClient " + + "ON aWorkorder.aClientID = aClient.aID WHERE " + + "(aWorkorder.aID = @ID)" + , ID); - if (!AyaBizUtils.InYourRegion(dr.GetGuid("ACLIENTREGION"))) return new SearchResult();//case 58 + if (!dr.Read()) + return new SearchResult();//DBUtil.ThrowFetchError("SearchResult for WorkorderID: " + ID.ToString()); - WorkorderTypes wotype = (WorkorderTypes)dr.GetInt16("aWorkorderType"); + if (!AyaBizUtils.InYourRegion(dr.GetGuid("ACLIENTREGION"))) return new SearchResult();//case 58 - if ((SecurityLevelTypes)AyaBizUtils.Right(Workorder.RootObjectTypeFromWorkorderType(wotype)) < SecurityLevelTypes.ReadOnly) - return new SearchResult(); + WorkorderTypes wotype = (WorkorderTypes)dr.GetInt16("aWorkorderType"); + + if ((SecurityLevelTypes)AyaBizUtils.Right(Workorder.RootObjectTypeFromWorkorderType(wotype)) < SecurityLevelTypes.ReadOnly) + return new SearchResult(); - switch (wotype) - { - case WorkorderTypes.PreventiveMaintenance: - sr.Description = LocalizedTextTable.GetLocalizedTextDirect("O.PreventiveMaintenance") + " " + dr.GetInt32("aPreventiveMaintenanceNumber").ToString() + " " + dr.GetString("aName"); - break; - case WorkorderTypes.Quote: - sr.Description=LocalizedTextTable.GetLocalizedTextDirect("O.WorkorderQuote") + " " + dr.GetInt32("aQuoteNumber").ToString() + " " + dr.GetString("aName"); - break; - case WorkorderTypes.Service: - sr.Description=LocalizedTextTable.GetLocalizedTextDirect("O.Workorder") + " " + dr.GetInt32("aServiceNumber").ToString() + " " + dr.GetString("aName"); - break; - case WorkorderTypes.TemplatePreventiveMaintenance: - sr.Description = LocalizedTextTable.GetLocalizedTextDirect("O.PreventiveMaintenanceTemplate") + " " + dr.GetInt32("aPreventiveMaintenanceNumber").ToString() + " " + dr.GetString("aName"); - break; - case WorkorderTypes.TemplateQuote: - sr.Description = LocalizedTextTable.GetLocalizedTextDirect("O.WorkorderQuoteTemplate") + " " + dr.GetInt32("aQuoteNumber").ToString() + " " + dr.GetString("aName"); - break; - case WorkorderTypes.TemplateService: - sr.Description = LocalizedTextTable.GetLocalizedTextDirect("O.WorkorderServiceTemplate") + " " + dr.GetInt32("aServiceNumber").ToString() + " " + dr.GetString("aName"); - break; + switch (wotype) + { + case WorkorderTypes.PreventiveMaintenance: + sr.Description = LocalizedTextTable.GetLocalizedTextDirect("O.PreventiveMaintenance") + " " + dr.GetInt32("aPreventiveMaintenanceNumber").ToString() + " " + dr.GetString("aName"); + break; + case WorkorderTypes.Quote: + sr.Description = LocalizedTextTable.GetLocalizedTextDirect("O.WorkorderQuote") + " " + dr.GetInt32("aQuoteNumber").ToString() + " " + dr.GetString("aName"); + break; + case WorkorderTypes.Service: + sr.Description = LocalizedTextTable.GetLocalizedTextDirect("O.Workorder") + " " + dr.GetInt32("aServiceNumber").ToString() + " " + dr.GetString("aName"); + break; + case WorkorderTypes.TemplatePreventiveMaintenance: + sr.Description = LocalizedTextTable.GetLocalizedTextDirect("O.PreventiveMaintenanceTemplate") + " " + dr.GetInt32("aPreventiveMaintenanceNumber").ToString() + " " + dr.GetString("aName"); + break; + case WorkorderTypes.TemplateQuote: + sr.Description = LocalizedTextTable.GetLocalizedTextDirect("O.WorkorderQuoteTemplate") + " " + dr.GetInt32("aQuoteNumber").ToString() + " " + dr.GetString("aName"); + break; + case WorkorderTypes.TemplateService: + sr.Description = LocalizedTextTable.GetLocalizedTextDirect("O.WorkorderServiceTemplate") + " " + dr.GetInt32("aServiceNumber").ToString() + " " + dr.GetString("aName"); + break; - } - - - - sb.Append(sr.Description); - sb.Append(" "); + } - sb.Append(dr.GetString("aTemplateDescription")); - sb.Append(" "); - sb.Append(dr.GetString("aInternalReferenceNumber")); - sb.Append(" "); - sb.Append(dr.GetString("aCustomerReferenceNumber")); - sb.Append(" "); - sb.Append(dr.GetString("aCustomerContactName")); - sb.Append(" "); - sb.Append(dr.GetString("aSummary")); - sb.Append(" "); - - + sb.Append(sr.Description); + sb.Append(" "); - sr.Created=DBUtil.ToLocal(dr.GetSmartDate("aCreated")); - sr.Modified=DBUtil.ToLocal(dr.GetSmartDate("aModified")); - sr.Creator=dr.GetGuid("aCreator"); - sr.Modifier=dr.GetGuid("aModifier"); - - - + sb.Append(dr.GetString("aTemplateDescription")); + sb.Append(" "); - } - finally - { - if(dr!=null) dr.Close(); - } - + sb.Append(dr.GetString("aInternalReferenceNumber")); + sb.Append(" "); + sb.Append(dr.GetString("aCustomerReferenceNumber")); + sb.Append(" "); + sb.Append(dr.GetString("aCustomerContactName")); + sb.Append(" "); + sb.Append(dr.GetString("aSummary")); + sb.Append(" "); - - //Formulate results - ExtractAndRank er = new ExtractAndRank(); - er.Process(sb.ToString().Trim(),searchTerms); - sr.Extract=er.Extract; - sr.Rank=er.Ranking; - sr.AncestorRootObjectID=ID; - sr.AncestorRootObjectType=RootObjectTypes.Workorder; - - return sr; - } - #endregion - #region Static methods - - #region New item + sr.Created = DBUtil.ToLocal(dr.GetSmartDate("aCreated")); + sr.Modified = DBUtil.ToLocal(dr.GetSmartDate("aModified")); + sr.Creator = dr.GetGuid("aCreator"); + sr.Modifier = dr.GetGuid("aModifier"); + + + + + } + finally + { + if (dr != null) dr.Close(); + } + + + + //Formulate results + ExtractAndRank er = new ExtractAndRank(); + er.Process(sb.ToString().Trim(), searchTerms); + sr.Extract = er.Extract; + sr.Rank = er.Ranking; + sr.AncestorRootObjectID = ID; + sr.AncestorRootObjectType = RootObjectTypes.Workorder; + + return sr; + + } + + #endregion + + #region Static methods + + #region New item @@ -2965,7 +2966,7 @@ namespace GZTW.AyaNova.BLL { throw new System.ApplicationException("Workorder->NewItem(TemplateID): TemplateID not found or is not a template"); } - Workorder dest=null; + Workorder dest = null; switch (t.WorkorderType) { case WorkorderTypes.TemplatePreventiveMaintenance: @@ -2983,11 +2984,11 @@ namespace GZTW.AyaNova.BLL } dest.ClientID = ClientID; - + return CopyTemplateToWorkorder(t, dest); } - + /// /// Create a new workorder overload to accept a root object type rather than a enum /// @@ -3002,79 +3003,79 @@ namespace GZTW.AyaNova.BLL return NewItem(wt); } - /// - /// Create new Workorder - /// - /// Workorder - public static Workorder NewItem(WorkorderTypes WorkorderType) - { - - + /// + /// Create new Workorder + /// + /// Workorder + public static Workorder NewItem(WorkorderTypes WorkorderType) + { - Workorder c; - //set rights - //case 1387 + + + Workorder c; + //set rights + //case 1387 c = new Workorder(); - c.mRights= (SecurityLevelTypes) AyaBizUtils.Right(Workorder.RootObjectTypeFromWorkorderType(WorkorderType)); - + c.mRights = (SecurityLevelTypes)AyaBizUtils.Right(Workorder.RootObjectTypeFromWorkorderType(WorkorderType)); - if(AyaBizUtils.IsGenerator || c.mRights > SecurityLevelTypes.ReadOnly) - { + + if (AyaBizUtils.IsGenerator || c.mRights > SecurityLevelTypes.ReadOnly) + { //case 3646 removed this block ////Count the workorders if it's a trial, sb no more than 30 //if(AyaBizUtils.Trial) //{ - + // if(WorkorderCountFetcher.GetItem()>29) // throw new TrialException(LocalizedTextTable.GetLocalizedTextDirect("Error.Trial.Restricted")); //} - //c = new Workorder(); - c.WorkorderType=WorkorderType; - switch(WorkorderType) - { - case WorkorderTypes.PreventiveMaintenance: + //c = new Workorder(); + c.WorkorderType = WorkorderType; + switch (WorkorderType) + { + case WorkorderTypes.PreventiveMaintenance: case WorkorderTypes.TemplatePreventiveMaintenance: - c.mWorkorderPreventiveMaintenance=WorkorderPreventiveMaintenance.NewItem(c); - break; - case WorkorderTypes.Quote: + c.mWorkorderPreventiveMaintenance = WorkorderPreventiveMaintenance.NewItem(c); + break; + case WorkorderTypes.Quote: case WorkorderTypes.TemplateQuote: - c.mQuote=WorkorderQuote.NewItem(c); - break; - case WorkorderTypes.Service: + c.mQuote = WorkorderQuote.NewItem(c); + break; + case WorkorderTypes.Service: case WorkorderTypes.TemplateService: - c.mService=WorkorderService.NewItem(c); - break; + c.mService = WorkorderService.NewItem(c); + break; - } - //A new workorder *always* has at least one workorder item, - //so add it now... - c.WorkorderItems.Add(c); - return c; - } - else - throw new System.Security.SecurityException( - string.Format( - LocalizedTextTable.GetLocalizedTextDirect("Error.Security.NotAuthorizedToCreate"), - LocalizedTextTable.GetLocalizedTextDirect("O.Workorder"))); - + } + //A new workorder *always* has at least one workorder item, + //so add it now... + c.WorkorderItems.Add(c); + return c; + } + else + throw new System.Security.SecurityException( + string.Format( + LocalizedTextTable.GetLocalizedTextDirect("Error.Security.NotAuthorizedToCreate"), + LocalizedTextTable.GetLocalizedTextDirect("O.Workorder"))); - - } - #endregion - #region Get by various id's - /// - /// Fetch existing Workorder, track MRU - /// - /// Workorder - /// Workorder Guid - public static Workorder GetItem(Guid _ID) - { + + } + #endregion + + #region Get by various id's + /// + /// Fetch existing Workorder, track MRU + /// + /// Workorder + /// Workorder Guid + public static Workorder GetItem(Guid _ID) + { return GetItemMRU(_ID, true); - } + } /// /// Fetch existing Workorder, don't track in MRU list @@ -3083,7 +3084,7 @@ namespace GZTW.AyaNova.BLL /// Workorder Guid public static Workorder GetItemNoMRU(Guid _ID) { - return GetItemMRU(_ID, false); + return GetItemMRU(_ID, false); } /// @@ -3097,7 +3098,11 @@ namespace GZTW.AyaNova.BLL //case 2018 commented out try block so proper error is bubbled up instead of security exception //try //{ - return (SecurityLevelTypes)AyaBizUtils.Right(Workorder.RootObjectTypeFromWorkorderType(WorkorderTypeFetcher.GetItem(_ID))); + + //case 3626 + if (_ID == Guid.Empty) return SecurityLevelTypes.NoAccess; + + return (SecurityLevelTypes)AyaBizUtils.Right(Workorder.RootObjectTypeFromWorkorderType(WorkorderTypeFetcher.GetItem(_ID))); //} //catch { } @@ -3157,7 +3162,7 @@ namespace GZTW.AyaNova.BLL /// public static Workorder GetWorkorderByRelative(RootObjectTypes RootObject, Guid _ID) { - return GetWorkorderByRelativeMRU(RootObject, _ID, true); + return GetWorkorderByRelativeMRU(RootObject, _ID, true); } /// @@ -3200,49 +3205,49 @@ namespace GZTW.AyaNova.BLL /// Workorder w = Workorder.GetWorkorderByRelative(RootObjectTypes.WorkorderItemPart, WorkorderItemPartID); /// /// - public static Workorder GetWorkorderByRelativeMRU(RootObjectTypes RootObject, Guid _ID, bool TrackMRU) - { - switch(RootObject) - { - case RootObjectTypes.WorkorderItem: - break; - case RootObjectTypes.WorkorderItemLabor: - break; - case RootObjectTypes.WorkorderItemTravel: - break; - case RootObjectTypes.WorkorderItemScheduledUser: - break; - case RootObjectTypes.WorkorderItemOutsideService: - break; - case RootObjectTypes.WorkorderItemPartRequest: - break; - case RootObjectTypes.WorkorderItemPart: - break; - case RootObjectTypes.WorkorderPreventiveMaintenance: - break; - case RootObjectTypes.WorkorderQuote: - break; - case RootObjectTypes.WorkorderService: - break; - case RootObjectTypes.WorkorderItemLoan: - break; + public static Workorder GetWorkorderByRelativeMRU(RootObjectTypes RootObject, Guid _ID, bool TrackMRU) + { + switch (RootObject) + { + case RootObjectTypes.WorkorderItem: + break; + case RootObjectTypes.WorkorderItemLabor: + break; + case RootObjectTypes.WorkorderItemTravel: + break; + case RootObjectTypes.WorkorderItemScheduledUser: + break; + case RootObjectTypes.WorkorderItemOutsideService: + break; + case RootObjectTypes.WorkorderItemPartRequest: + break; + case RootObjectTypes.WorkorderItemPart: + break; + case RootObjectTypes.WorkorderPreventiveMaintenance: + break; + case RootObjectTypes.WorkorderQuote: + break; + case RootObjectTypes.WorkorderService: + break; + case RootObjectTypes.WorkorderItemLoan: + break; case RootObjectTypes.WorkorderItemMiscExpense: break; - default: - throw new System.NotSupportedException("GetWorkorderByDescendant(" + RootObject.ToString() + ") not supported"); - } + default: + throw new System.NotSupportedException("GetWorkorderByDescendant(" + RootObject.ToString() + ") not supported"); + } Guid gWorkorderID = WorkorderIDFetcher.GetWorkorderByRelative(RootObject, _ID); if (RightsToWorkorder(gWorkorderID) > SecurityLevelTypes.NoAccess) - { + { return (Workorder)DataPortal.Fetch(new Criteria(RootObjectTypes.Workorder, gWorkorderID, TrackMRU)); - } - else - throw new System.Security.SecurityException( - string.Format( - LocalizedTextTable.GetLocalizedTextDirect("Error.Security.NotAuthorizedToRetrieve"), - LocalizedTextTable.GetLocalizedTextDirect("O.Workorder"))); - } + } + else + throw new System.Security.SecurityException( + string.Format( + LocalizedTextTable.GetLocalizedTextDirect("Error.Security.NotAuthorizedToRetrieve"), + LocalizedTextTable.GetLocalizedTextDirect("O.Workorder"))); + } @@ -3276,7 +3281,7 @@ namespace GZTW.AyaNova.BLL /// WorkorderItemScheduledUser wis = Workorder.GetDescendant<WorkorderItemScheduledUser>(MyWoItemSchedUserObjectID); /// /// - public static T GetDescendant( Guid ID) + public static T GetDescendant(Guid ID) { T bizobject = default(T); RootObjectTypes objectType = RootObjectTypes.Nothing; @@ -3330,7 +3335,7 @@ namespace GZTW.AyaNova.BLL { objectType = RootObjectTypes.WorkorderItemMiscExpense; } - #endregion + #endregion #region Check if supported switch (objectType) @@ -3348,7 +3353,7 @@ namespace GZTW.AyaNova.BLL case RootObjectTypes.WorkorderItemPartRequest: break; case RootObjectTypes.WorkorderItemPart: - break; + break; case RootObjectTypes.WorkorderItemLoan: break; case RootObjectTypes.WorkorderItemMiscExpense: @@ -3356,19 +3361,19 @@ namespace GZTW.AyaNova.BLL default: throw new System.NotSupportedException("GetDescendant(" + typeof(T).ToString() + ") not supported"); } - #endregion + #endregion #region Fetch and return Workorder w = Workorder.GetWorkorderByRelativeNoMRU(objectType, ID); - + if (objectType == RootObjectTypes.WorkorderItem) return (T)(object)w.WorkorderItems[ID]; - WorkorderItem wi= w.WorkorderItems[w.GetWorkorderItemIDFromDescendant(objectType, ID)]; + WorkorderItem wi = w.WorkorderItems[w.GetWorkorderItemIDFromDescendant(objectType, ID)]; switch (objectType) { - + case RootObjectTypes.WorkorderItemLabor: return (T)(object)wi.Labors[ID.ToString()]; case RootObjectTypes.WorkorderItemTravel: @@ -3386,7 +3391,7 @@ namespace GZTW.AyaNova.BLL case RootObjectTypes.WorkorderItemMiscExpense: return (T)(object)wi.Expenses[ID.ToString()]; } - + #endregion @@ -3395,9 +3400,9 @@ namespace GZTW.AyaNova.BLL return bizobject; } - #endregion + #endregion - #region Reopen + #region Reopen /// /// Reopen closed Workorder /// has no effect on already open work orders @@ -3415,7 +3420,7 @@ namespace GZTW.AyaNova.BLL LocalizedTextTable.GetLocalizedTextDirect("O.Workorder"))); } - #endregion + #endregion #region Template copy-inator /// @@ -3428,14 +3433,14 @@ namespace GZTW.AyaNova.BLL { //get the empty workorderitem that is automatically //created on a new workorder so we can delete it later - Guid DummyWorkorderItemID=dest.WorkorderItems[0].ID; + Guid DummyWorkorderItemID = dest.WorkorderItems[0].ID; RatePickList rates = null; if (dest.ContractResolved() == null) rates = RatePickList.GetList(false); else rates = RatePickList.GetListWithContract(dest.ContractIDResolved()); - + //WORKORDER HEADER dest.CustomerContactName = t.CustomerContactName; @@ -3461,7 +3466,7 @@ namespace GZTW.AyaNova.BLL dest.WorkorderService.WorkorderStatusID = t.WorkorderService.WorkorderStatusID; destExactType = RootObjectTypes.WorkorderService; - + } break; case WorkorderTypes.TemplateQuote: @@ -3475,7 +3480,7 @@ namespace GZTW.AyaNova.BLL //dest.WorkorderQuote.ValidUntilDate = t.WorkorderQuote.ValidUntilDate; destExactType = RootObjectTypes.WorkorderQuote; - + } break; case WorkorderTypes.TemplatePreventiveMaintenance: @@ -3487,18 +3492,18 @@ namespace GZTW.AyaNova.BLL dest.WorkorderPreventiveMaintenance.GenerateSpanUnit = t.WorkorderPreventiveMaintenance.GenerateSpanUnit; //Case 590 //dest.WorkorderPreventiveMaintenance.NextServiceDate = t.WorkorderPreventiveMaintenance.NextServiceDate; - // dest.WorkorderPreventiveMaintenance.StopGeneratingDate = t.WorkorderPreventiveMaintenance.StopGeneratingDate; + // dest.WorkorderPreventiveMaintenance.StopGeneratingDate = t.WorkorderPreventiveMaintenance.StopGeneratingDate; dest.WorkorderPreventiveMaintenance.ThresholdSpan = t.WorkorderPreventiveMaintenance.ThresholdSpan; dest.WorkorderPreventiveMaintenance.ThresholdSpanUnit = t.WorkorderPreventiveMaintenance.ThresholdSpanUnit; dest.WorkorderPreventiveMaintenance.WorkorderStatusID = t.WorkorderPreventiveMaintenance.WorkorderStatusID; destExactType = RootObjectTypes.WorkorderPreventiveMaintenance; - + } break; } - + //WORKORDERITEMS foreach (WorkorderItem wisource in t.WorkorderItems) @@ -3530,19 +3535,19 @@ namespace GZTW.AyaNova.BLL PartPickList partList = null; if (t.mTemplateFreshPrice) partList = PartPickList.GetListFromIDList(t.ListOfPartsSelected()); - + //PARTS foreach (WorkorderItemPart partsource in wisource.Parts) { WorkorderItemPart partdest = widest.Parts.Add(widest); - + partdest.Description = partsource.Description; partdest.Discount = partsource.Discount; partdest.DiscountType = partsource.DiscountType; partdest.PartID = partsource.PartID; partdest.PartWarehouseID = partsource.PartWarehouseID; - + //case 3132: update prices here if the template says to do that if (t.mTemplateFreshPrice) @@ -3559,8 +3564,8 @@ namespace GZTW.AyaNova.BLL partdest.Price = partsource.Price; } - - + + if (AyaBizUtils.GlobalSettings.UseInventory) { //case 2076 @@ -3573,7 +3578,7 @@ namespace GZTW.AyaNova.BLL { partdest.Quantity = partsource.Quantity; } - + } else partdest.Quantity = partsource.Quantity; @@ -3639,9 +3644,9 @@ namespace GZTW.AyaNova.BLL exdest.TotalCost = e.TotalCost; exdest.UserID = e.UserID; //exdest.WorkorderItemID = e.WorkorderItemID; - - + + } } @@ -3687,12 +3692,12 @@ namespace GZTW.AyaNova.BLL }//foreach workorderitem loop - + ////Delete the auto-created dummy workorder item ////if there are more than it present if (dest.WorkorderItems.Count > 1) dest.WorkorderItems.RemoveAt(0); - + //case 3160 //copy wikipage from template to created wo if (t.HasWiki) @@ -3707,176 +3712,176 @@ namespace GZTW.AyaNova.BLL #region Generate service workorder from quote /// - /// Generates a service workorder from a Quote type Workorder - /// - /// ID of Quote - /// A new service workorder - public static Workorder NewServiceWorkorderFromQuote(Guid SourceWorkorderID) - { - - //revamped for case 1387 now calls the one single static newitem method - - //Fetch the source workorder and verify it's a quote - Workorder source=Workorder.GetItemNoMRU(SourceWorkorderID); - if(source.WorkorderType!=WorkorderTypes.Quote) - throw new NotSupportedException(LocalizedTextTable.GetLocalizedTextDirect("Workorder.Label.Error.SourceInvalidType")); + /// Generates a service workorder from a Quote type Workorder + /// + /// ID of Quote + /// A new service workorder + public static Workorder NewServiceWorkorderFromQuote(Guid SourceWorkorderID) + { + + //revamped for case 1387 now calls the one single static newitem method + + //Fetch the source workorder and verify it's a quote + Workorder source = Workorder.GetItemNoMRU(SourceWorkorderID); + if (source.WorkorderType != WorkorderTypes.Quote) + throw new NotSupportedException(LocalizedTextTable.GetLocalizedTextDirect("Workorder.Label.Error.SourceInvalidType")); + + //Ok, so far so goo, create the new one + bool bUseInventory = AyaBizUtils.GlobalSettings.UseInventory; + - //Ok, so far so goo, create the new one - bool bUseInventory=AyaBizUtils.GlobalSettings.UseInventory; - - //NOTE: THIS DOES *NOT* CALL THE SHARED NEWITEM METHOD IN WORKORDER //Workorder dest = new Workorder(); //dest.WorkorderType=WorkorderTypes.Service; //dest.mService=WorkorderService.NewItem(dest); Workorder dest = Workorder.NewItem(WorkorderTypes.Service); - + //get the empty workorderitem that is automatically - //created on a new workorder so we can delete it later - Guid DummyWorkorderItemID=dest.WorkorderItems[0].ID; - - //WORKORDER HEADER - dest.ClientID=source.ClientID; -// dest.Custom0=source.Custom0; -// dest.Custom1=source.Custom1; -// dest.Custom2=source.Custom2; -// dest.Custom3=source.Custom3; -// dest.Custom4=source.Custom4; -// dest.Custom5=source.Custom5; -// dest.Custom6=source.Custom6; -// dest.Custom7=source.Custom7; -// dest.Custom8=source.Custom8; -// dest.Custom9=source.Custom9; - dest.CustomerContactName=source.CustomerContactName; - dest.CustomerReferenceNumber=source.CustomerReferenceNumber; - dest.mFromQuoteID=source.WorkorderQuote.ID; - dest.InternalReferenceNumber=source.InternalReferenceNumber; - dest.Onsite=source.Onsite; - dest.ProjectID=source.ProjectID; - //dest.RegionID=source.RegionID; - dest.Summary=source.Summary; - dest.WorkorderCategoryID=source.WorkorderCategoryID; + //created on a new workorder so we can delete it later + Guid DummyWorkorderItemID = dest.WorkorderItems[0].ID; - //WORKORDERITEMS - foreach(WorkorderItem wisource in source.WorkorderItems) - { - WorkorderItem widest=dest.WorkorderItems.Add(dest); - widest.Custom0=wisource.Custom0; - widest.Custom1=wisource.Custom1; - widest.Custom2=wisource.Custom2; - widest.Custom3=wisource.Custom3; - widest.Custom4=wisource.Custom4; - widest.Custom5=wisource.Custom5; - widest.Custom6=wisource.Custom6; - widest.Custom7=wisource.Custom7; - widest.Custom8=wisource.Custom8; - widest.Custom9=wisource.Custom9; - widest.PriorityID=wisource.PriorityID; - widest.RequestDate=wisource.RequestDate; - widest.Summary=wisource.Summary; - widest.TechNotes=wisource.TechNotes; - widest.TypeID=wisource.TypeID; - widest.UnitID=wisource.UnitID; - widest.WarrantyService=wisource.WarrantyService; - widest.WorkorderItemUnitServiceTypeID=wisource.WorkorderItemUnitServiceTypeID; - widest.WorkorderStatusID=wisource.WorkorderStatusID; + //WORKORDER HEADER + dest.ClientID = source.ClientID; + // dest.Custom0=source.Custom0; + // dest.Custom1=source.Custom1; + // dest.Custom2=source.Custom2; + // dest.Custom3=source.Custom3; + // dest.Custom4=source.Custom4; + // dest.Custom5=source.Custom5; + // dest.Custom6=source.Custom6; + // dest.Custom7=source.Custom7; + // dest.Custom8=source.Custom8; + // dest.Custom9=source.Custom9; + dest.CustomerContactName = source.CustomerContactName; + dest.CustomerReferenceNumber = source.CustomerReferenceNumber; + dest.mFromQuoteID = source.WorkorderQuote.ID; + dest.InternalReferenceNumber = source.InternalReferenceNumber; + dest.Onsite = source.Onsite; + dest.ProjectID = source.ProjectID; + //dest.RegionID=source.RegionID; + dest.Summary = source.Summary; + dest.WorkorderCategoryID = source.WorkorderCategoryID; - //PARTS - foreach(WorkorderItemPart partsource in wisource.Parts) - { - WorkorderItemPart partdest=widest.Parts.Add(widest); - partdest.Cost=partsource.Cost; - partdest.Description=partsource.Description; - partdest.Discount=partsource.Discount; - partdest.DiscountType=partsource.DiscountType; - partdest.PartID=partsource.PartID; - partdest.PartWarehouseID=partsource.PartWarehouseID; - partdest.Price=partsource.Price; - if(bUseInventory) - { - partdest.QuantityReserved=partsource.Quantity; - partdest.Quantity=0; - } - else - partdest.Quantity=partsource.Quantity; - partdest.TaxPartSaleID=partsource.TaxPartSaleID; - + //WORKORDERITEMS + foreach (WorkorderItem wisource in source.WorkorderItems) + { + WorkorderItem widest = dest.WorkorderItems.Add(dest); + widest.Custom0 = wisource.Custom0; + widest.Custom1 = wisource.Custom1; + widest.Custom2 = wisource.Custom2; + widest.Custom3 = wisource.Custom3; + widest.Custom4 = wisource.Custom4; + widest.Custom5 = wisource.Custom5; + widest.Custom6 = wisource.Custom6; + widest.Custom7 = wisource.Custom7; + widest.Custom8 = wisource.Custom8; + widest.Custom9 = wisource.Custom9; + widest.PriorityID = wisource.PriorityID; + widest.RequestDate = wisource.RequestDate; + widest.Summary = wisource.Summary; + widest.TechNotes = wisource.TechNotes; + widest.TypeID = wisource.TypeID; + widest.UnitID = wisource.UnitID; + widest.WarrantyService = wisource.WarrantyService; + widest.WorkorderItemUnitServiceTypeID = wisource.WorkorderItemUnitServiceTypeID; + widest.WorkorderStatusID = wisource.WorkorderStatusID; - } - - //********************************************************** - //Part requests would be here if copying a service workorder - //********************************************************** - - //SCHEDULED USERS - foreach(WorkorderItemScheduledUser usersource in wisource.ScheduledUsers) - { - WorkorderItemScheduledUser userdest=widest.ScheduledUsers.Add(widest); - userdest.EstimatedQuantity=usersource.EstimatedQuantity; - userdest.ServiceRateID=usersource.ServiceRateID; - userdest.StartDate=usersource.StartDate; - userdest.StopDate=usersource.StopDate; - userdest.UserID=usersource.UserID; - - } - - //LABOR - foreach(WorkorderItemLabor laborsource in wisource.Labors) - { - WorkorderItemLabor labordest=widest.Labors.Add(widest); - labordest.NoChargeQuantity=laborsource.NoChargeQuantity; - labordest.ServiceDetails=laborsource.ServiceDetails; - labordest.ServiceRateID=laborsource.ServiceRateID; - labordest.ServiceRateQuantity=laborsource.ServiceRateQuantity; - labordest.ServiceStartDate=laborsource.ServiceStartDate; - labordest.ServiceStopDate=laborsource.ServiceStopDate; - labordest.TaxRateSaleID=laborsource.TaxRateSaleID; - labordest.UserID=laborsource.UserID; - - } - - //********************************************************** - //Expenses would be here if copying a service workorder - //********************************************************** + //PARTS + foreach (WorkorderItemPart partsource in wisource.Parts) + { + WorkorderItemPart partdest = widest.Parts.Add(widest); + partdest.Cost = partsource.Cost; + partdest.Description = partsource.Description; + partdest.Discount = partsource.Discount; + partdest.DiscountType = partsource.DiscountType; + partdest.PartID = partsource.PartID; + partdest.PartWarehouseID = partsource.PartWarehouseID; + partdest.Price = partsource.Price; + if (bUseInventory) + { + partdest.QuantityReserved = partsource.Quantity; + partdest.Quantity = 0; + } + else + partdest.Quantity = partsource.Quantity; + partdest.TaxPartSaleID = partsource.TaxPartSaleID; - //********************************************************** - //Loans would be here if copying a service workorder - //********************************************************** + } - //TRAVEL - foreach(WorkorderItemTravel travelsource in wisource.Travels) - { - WorkorderItemTravel traveldest=widest.Travels.Add(widest); - traveldest.TravelDetails=travelsource.TravelDetails; - traveldest.TravelRateID=travelsource.TravelRateID; - traveldest.TravelRateQuantity=travelsource.TravelRateQuantity; - traveldest.TravelStartDate=travelsource.TravelStartDate; - traveldest.TravelStopDate=travelsource.TravelStopDate; - traveldest.TaxRateSaleID=travelsource.TaxRateSaleID; - traveldest.UserID=travelsource.UserID; - traveldest.Distance=travelsource.Distance; - traveldest.Notes=travelsource.Notes; - traveldest.NoChargeQuantity=travelsource.NoChargeQuantity; - } + //********************************************************** + //Part requests would be here if copying a service workorder + //********************************************************** + + //SCHEDULED USERS + foreach (WorkorderItemScheduledUser usersource in wisource.ScheduledUsers) + { + WorkorderItemScheduledUser userdest = widest.ScheduledUsers.Add(widest); + userdest.EstimatedQuantity = usersource.EstimatedQuantity; + userdest.ServiceRateID = usersource.ServiceRateID; + userdest.StartDate = usersource.StartDate; + userdest.StopDate = usersource.StopDate; + userdest.UserID = usersource.UserID; + + } + + //LABOR + foreach (WorkorderItemLabor laborsource in wisource.Labors) + { + WorkorderItemLabor labordest = widest.Labors.Add(widest); + labordest.NoChargeQuantity = laborsource.NoChargeQuantity; + labordest.ServiceDetails = laborsource.ServiceDetails; + labordest.ServiceRateID = laborsource.ServiceRateID; + labordest.ServiceRateQuantity = laborsource.ServiceRateQuantity; + labordest.ServiceStartDate = laborsource.ServiceStartDate; + labordest.ServiceStopDate = laborsource.ServiceStopDate; + labordest.TaxRateSaleID = laborsource.TaxRateSaleID; + labordest.UserID = laborsource.UserID; + + } + + //********************************************************** + //Expenses would be here if copying a service workorder + //********************************************************** + + + //********************************************************** + //Loans would be here if copying a service workorder + //********************************************************** + + //TRAVEL + foreach (WorkorderItemTravel travelsource in wisource.Travels) + { + WorkorderItemTravel traveldest = widest.Travels.Add(widest); + traveldest.TravelDetails = travelsource.TravelDetails; + traveldest.TravelRateID = travelsource.TravelRateID; + traveldest.TravelRateQuantity = travelsource.TravelRateQuantity; + traveldest.TravelStartDate = travelsource.TravelStartDate; + traveldest.TravelStopDate = travelsource.TravelStopDate; + traveldest.TaxRateSaleID = travelsource.TaxRateSaleID; + traveldest.UserID = travelsource.UserID; + traveldest.Distance = travelsource.Distance; + traveldest.Notes = travelsource.Notes; + traveldest.NoChargeQuantity = travelsource.NoChargeQuantity; + } - //TASKS - foreach(WorkorderItemTask tasksource in wisource.Tasks) - { - WorkorderItemTask taskdest=widest.Tasks.Add(widest); - taskdest.TaskGroupID=tasksource.TaskGroupID; - taskdest.TaskID=tasksource.TaskID; - - } + //TASKS + foreach (WorkorderItemTask tasksource in wisource.Tasks) + { + WorkorderItemTask taskdest = widest.Tasks.Add(widest); + taskdest.TaskGroupID = tasksource.TaskGroupID; + taskdest.TaskID = tasksource.TaskID; - //********************************************************** - //Outside service would be here if copying a service workorder - //********************************************************** + } - }//foreach workorderitem loop + //********************************************************** + //Outside service would be here if copying a service workorder + //********************************************************** + + }//foreach workorderitem loop //case 1387 @@ -3900,45 +3905,45 @@ namespace GZTW.AyaNova.BLL } - return dest; - - - + return dest; - - } - #endregion - #region Generate service workorder from PM - /// - /// Generates a service workorder from a PM type Workorder - /// - /// ID of PM - /// A new service workorder - public static Workorder NewServiceWorkorderFromPM(Guid SourceWorkorderID) - { - //Fetch the source workorder and verify it's a PM - Workorder source=Workorder.GetItemNoMRU(SourceWorkorderID); - if(source.WorkorderType!=WorkorderTypes.PreventiveMaintenance) - throw new NotSupportedException(LocalizedTextTable.GetLocalizedTextDirect("Workorder.Label.Error.SourceInvalidType")); - //if it's inactive then there is nothing to Process - //this is a backstop, the list the pm is being generated off of - //should have already selected only active items that have not reached their - //expiry date - if(source.WorkorderPreventiveMaintenance.Active==false) - { - throw new System.ApplicationException("NewServiceWorkorderFromPM: source PM workorder is not active"); - } - if(source.WorkorderPreventiveMaintenance.StopGeneratingDate!=System.DBNull.Value && + + } + #endregion + + #region Generate service workorder from PM + /// + /// Generates a service workorder from a PM type Workorder + /// + /// ID of PM + /// A new service workorder + public static Workorder NewServiceWorkorderFromPM(Guid SourceWorkorderID) + { + //Fetch the source workorder and verify it's a PM + Workorder source = Workorder.GetItemNoMRU(SourceWorkorderID); + if (source.WorkorderType != WorkorderTypes.PreventiveMaintenance) + throw new NotSupportedException(LocalizedTextTable.GetLocalizedTextDirect("Workorder.Label.Error.SourceInvalidType")); + + //if it's inactive then there is nothing to Process + //this is a backstop, the list the pm is being generated off of + //should have already selected only active items that have not reached their + //expiry date + if (source.WorkorderPreventiveMaintenance.Active == false) + { + throw new System.ApplicationException("NewServiceWorkorderFromPM: source PM workorder is not active"); + } + + if (source.WorkorderPreventiveMaintenance.StopGeneratingDate != System.DBNull.Value && source.WorkorderPreventiveMaintenance.dtStopGeneratingDate < DBUtil.CurrentWorkingDateTime) - { - throw new System.ApplicationException("NewServiceWorkorderFromPM: source PM workorder is past StopGeneratingDate"); - } + { + throw new System.ApplicationException("NewServiceWorkorderFromPM: source PM workorder is past StopGeneratingDate"); + } - //Ok, so far so good, create the new one - bool bUseInventory=AyaBizUtils.GlobalSettings.UseInventory; + //Ok, so far so good, create the new one + bool bUseInventory = AyaBizUtils.GlobalSettings.UseInventory; //case 1387 Workorder dest = Workorder.NewItem(WorkorderTypes.Service); @@ -3948,146 +3953,146 @@ namespace GZTW.AyaNova.BLL //dest.WorkorderType=WorkorderTypes.Service; //dest.mService=WorkorderService.NewItem(dest); - #region copy workorder data - - //WORKORDER HEADER - dest.ClientID=source.ClientID; - dest.CustomerContactName=source.CustomerContactName; - dest.CustomerReferenceNumber=source.CustomerReferenceNumber; - dest.mFromPMID=source.WorkorderPreventiveMaintenance.ID; - dest.InternalReferenceNumber=source.InternalReferenceNumber; - dest.Onsite=source.Onsite; - dest.ProjectID=source.ProjectID; - //dest.RegionID=source.RegionID; - dest.Summary=source.Summary; - dest.WorkorderCategoryID=source.WorkorderCategoryID; + #region copy workorder data - //PM SPECIFIC - dest.WorkorderService.WorkorderStatusID=source.WorkorderPreventiveMaintenance.WorkorderStatusID; - //Date stuff (note that date is assumed to have been advanced the last time a workorder was - //generated off the pm (see bottom of this method for that)) - dest.WorkorderService.ServiceDate=source.WorkorderPreventiveMaintenance.NextServiceDate; + //WORKORDER HEADER + dest.ClientID = source.ClientID; + dest.CustomerContactName = source.CustomerContactName; + dest.CustomerReferenceNumber = source.CustomerReferenceNumber; + dest.mFromPMID = source.WorkorderPreventiveMaintenance.ID; + dest.InternalReferenceNumber = source.InternalReferenceNumber; + dest.Onsite = source.Onsite; + dest.ProjectID = source.ProjectID; + //dest.RegionID=source.RegionID; + dest.Summary = source.Summary; + dest.WorkorderCategoryID = source.WorkorderCategoryID; + + //PM SPECIFIC + dest.WorkorderService.WorkorderStatusID = source.WorkorderPreventiveMaintenance.WorkorderStatusID; + //Date stuff (note that date is assumed to have been advanced the last time a workorder was + //generated off the pm (see bottom of this method for that)) + dest.WorkorderService.ServiceDate = source.WorkorderPreventiveMaintenance.NextServiceDate; - //WORKORDERITEMS - foreach(WorkorderItem wisource in source.WorkorderItems) - { - WorkorderItem widest=dest.WorkorderItems.Add(dest); - widest.Custom0=wisource.Custom0; - widest.Custom1=wisource.Custom1; - widest.Custom2=wisource.Custom2; - widest.Custom3=wisource.Custom3; - widest.Custom4=wisource.Custom4; - widest.Custom5=wisource.Custom5; - widest.Custom6=wisource.Custom6; - widest.Custom7=wisource.Custom7; - widest.Custom8=wisource.Custom8; - widest.Custom9=wisource.Custom9; - widest.PriorityID=wisource.PriorityID; - widest.RequestDate=wisource.RequestDate; - widest.Summary=wisource.Summary; - widest.TechNotes=wisource.TechNotes; - widest.TypeID=wisource.TypeID; - widest.UnitID=wisource.UnitID; - widest.WarrantyService=wisource.WarrantyService; - widest.WorkorderItemUnitServiceTypeID=wisource.WorkorderItemUnitServiceTypeID; - widest.WorkorderStatusID=wisource.WorkorderStatusID; + //WORKORDERITEMS + foreach (WorkorderItem wisource in source.WorkorderItems) + { + WorkorderItem widest = dest.WorkorderItems.Add(dest); + widest.Custom0 = wisource.Custom0; + widest.Custom1 = wisource.Custom1; + widest.Custom2 = wisource.Custom2; + widest.Custom3 = wisource.Custom3; + widest.Custom4 = wisource.Custom4; + widest.Custom5 = wisource.Custom5; + widest.Custom6 = wisource.Custom6; + widest.Custom7 = wisource.Custom7; + widest.Custom8 = wisource.Custom8; + widest.Custom9 = wisource.Custom9; + widest.PriorityID = wisource.PriorityID; + widest.RequestDate = wisource.RequestDate; + widest.Summary = wisource.Summary; + widest.TechNotes = wisource.TechNotes; + widest.TypeID = wisource.TypeID; + widest.UnitID = wisource.UnitID; + widest.WarrantyService = wisource.WarrantyService; + widest.WorkorderItemUnitServiceTypeID = wisource.WorkorderItemUnitServiceTypeID; + widest.WorkorderStatusID = wisource.WorkorderStatusID; - //PARTS - foreach(WorkorderItemPart partsource in wisource.Parts) - { - WorkorderItemPart partdest=widest.Parts.Add(widest); - partdest.Cost=partsource.Cost; - partdest.Description=partsource.Description; - partdest.Discount=partsource.Discount; - partdest.DiscountType=partsource.DiscountType; - partdest.PartID=partsource.PartID; - partdest.PartWarehouseID=partsource.PartWarehouseID; - partdest.Price=partsource.Price; - if(bUseInventory) - { - partdest.QuantityReserved=partsource.Quantity; - partdest.Quantity=0; - } - else - partdest.Quantity=partsource.Quantity; - partdest.TaxPartSaleID=partsource.TaxPartSaleID; - - - } - - //********************************************************** - //Part requests would be here if copying a service workorder - //********************************************************** - - //SCHEDULED USERS - foreach(WorkorderItemScheduledUser usersource in wisource.ScheduledUsers) - { - WorkorderItemScheduledUser userdest=widest.ScheduledUsers.Add(widest); - userdest.EstimatedQuantity=usersource.EstimatedQuantity; - userdest.ServiceRateID=usersource.ServiceRateID; - userdest.StartDate=usersource.StartDate; - userdest.StopDate=usersource.StopDate; - userdest.UserID=usersource.UserID; - - } - - //LABOR - foreach(WorkorderItemLabor laborsource in wisource.Labors) - { - WorkorderItemLabor labordest=widest.Labors.Add(widest); - labordest.NoChargeQuantity=laborsource.NoChargeQuantity; - labordest.ServiceDetails=laborsource.ServiceDetails; - labordest.ServiceRateID=laborsource.ServiceRateID; - labordest.ServiceRateQuantity=laborsource.ServiceRateQuantity; - labordest.ServiceStartDate=laborsource.ServiceStartDate; - labordest.ServiceStopDate=laborsource.ServiceStopDate; - labordest.TaxRateSaleID=laborsource.TaxRateSaleID; - labordest.UserID=laborsource.UserID; - - } - - //********************************************************** - //Expenses would be here if copying a service workorder - //********************************************************** + //PARTS + foreach (WorkorderItemPart partsource in wisource.Parts) + { + WorkorderItemPart partdest = widest.Parts.Add(widest); + partdest.Cost = partsource.Cost; + partdest.Description = partsource.Description; + partdest.Discount = partsource.Discount; + partdest.DiscountType = partsource.DiscountType; + partdest.PartID = partsource.PartID; + partdest.PartWarehouseID = partsource.PartWarehouseID; + partdest.Price = partsource.Price; + if (bUseInventory) + { + partdest.QuantityReserved = partsource.Quantity; + partdest.Quantity = 0; + } + else + partdest.Quantity = partsource.Quantity; + partdest.TaxPartSaleID = partsource.TaxPartSaleID; - //********************************************************** - //Loans would be here if copying a service workorder - //********************************************************** + } - //TRAVEL - foreach(WorkorderItemTravel travelsource in wisource.Travels) - { - WorkorderItemTravel traveldest=widest.Travels.Add(widest); - traveldest.TravelDetails=travelsource.TravelDetails; - traveldest.TravelRateID=travelsource.TravelRateID; - traveldest.TravelRateQuantity=travelsource.TravelRateQuantity; - traveldest.TravelStartDate=travelsource.TravelStartDate; - traveldest.TravelStopDate=travelsource.TravelStopDate; - traveldest.TaxRateSaleID=travelsource.TaxRateSaleID; - traveldest.UserID=travelsource.UserID; - traveldest.Distance=travelsource.Distance; - traveldest.Notes=travelsource.Notes; - traveldest.NoChargeQuantity=travelsource.NoChargeQuantity; - } + //********************************************************** + //Part requests would be here if copying a service workorder + //********************************************************** + + //SCHEDULED USERS + foreach (WorkorderItemScheduledUser usersource in wisource.ScheduledUsers) + { + WorkorderItemScheduledUser userdest = widest.ScheduledUsers.Add(widest); + userdest.EstimatedQuantity = usersource.EstimatedQuantity; + userdest.ServiceRateID = usersource.ServiceRateID; + userdest.StartDate = usersource.StartDate; + userdest.StopDate = usersource.StopDate; + userdest.UserID = usersource.UserID; + + } + + //LABOR + foreach (WorkorderItemLabor laborsource in wisource.Labors) + { + WorkorderItemLabor labordest = widest.Labors.Add(widest); + labordest.NoChargeQuantity = laborsource.NoChargeQuantity; + labordest.ServiceDetails = laborsource.ServiceDetails; + labordest.ServiceRateID = laborsource.ServiceRateID; + labordest.ServiceRateQuantity = laborsource.ServiceRateQuantity; + labordest.ServiceStartDate = laborsource.ServiceStartDate; + labordest.ServiceStopDate = laborsource.ServiceStopDate; + labordest.TaxRateSaleID = laborsource.TaxRateSaleID; + labordest.UserID = laborsource.UserID; + + } + + //********************************************************** + //Expenses would be here if copying a service workorder + //********************************************************** + + + //********************************************************** + //Loans would be here if copying a service workorder + //********************************************************** + + //TRAVEL + foreach (WorkorderItemTravel travelsource in wisource.Travels) + { + WorkorderItemTravel traveldest = widest.Travels.Add(widest); + traveldest.TravelDetails = travelsource.TravelDetails; + traveldest.TravelRateID = travelsource.TravelRateID; + traveldest.TravelRateQuantity = travelsource.TravelRateQuantity; + traveldest.TravelStartDate = travelsource.TravelStartDate; + traveldest.TravelStopDate = travelsource.TravelStopDate; + traveldest.TaxRateSaleID = travelsource.TaxRateSaleID; + traveldest.UserID = travelsource.UserID; + traveldest.Distance = travelsource.Distance; + traveldest.Notes = travelsource.Notes; + traveldest.NoChargeQuantity = travelsource.NoChargeQuantity; + } - //TASKS - foreach(WorkorderItemTask tasksource in wisource.Tasks) - { - WorkorderItemTask taskdest=widest.Tasks.Add(widest); - taskdest.TaskGroupID=tasksource.TaskGroupID; - taskdest.TaskID=tasksource.TaskID; - - } + //TASKS + foreach (WorkorderItemTask tasksource in wisource.Tasks) + { + WorkorderItemTask taskdest = widest.Tasks.Add(widest); + taskdest.TaskGroupID = tasksource.TaskGroupID; + taskdest.TaskID = tasksource.TaskID; - //********************************************************** - //Outside service would be here if copying a service workorder - //********************************************************** + } - }//foreach workorderitem loop + //********************************************************** + //Outside service would be here if copying a service workorder + //********************************************************** + + }//foreach workorderitem loop //case 1387 @@ -4096,148 +4101,148 @@ namespace GZTW.AyaNova.BLL if (dest.WorkorderItems.Count > 1) dest.WorkorderItems.RemoveAt(0); - #endregion copy workorder data + #endregion copy workorder data + + //Now save it to ensure it was created properly so + //that we know it's now safe to advance the next service date and all others - //Now save it to ensure it was created properly so - //that we know it's now safe to advance the next service date and all others - //case 868 previously didn't set dest to result of save causing it to be a copy - dest=(Workorder)dest.Save(); - - + dest = (Workorder)dest.Save(); - #region Calculate reschedule dates - //Get the current next service date for calcs - DateTime dtNext=GetDateFromSpanAndUnit(source.WorkorderPreventiveMaintenance.dtNextServiceDate, - source.WorkorderPreventiveMaintenance.GenerateSpanUnit, - source.WorkorderPreventiveMaintenance.GenerateSpan); - - //Get to the desired day of the week if necessary... - if(source.mWorkorderPreventiveMaintenance.DayOfTheWeek != AyaDayOfWeek.AnyDayOfWeek) - { - DayOfWeek desired=AyaToSystemDayOfWeek(source.mWorkorderPreventiveMaintenance.DayOfTheWeek); - while(dtNext.DayOfWeek!=desired) - { - dtNext=dtNext.AddDays(1); - } - } - //Get the time span to add to all the other relevant dates on teh workorder to match - //the amount the next service date has been advanced - System.TimeSpan tsToNext=dtNext-source.WorkorderPreventiveMaintenance.dtNextServiceDate; - - + #region Calculate reschedule dates + //Get the current next service date for calcs + DateTime dtNext = GetDateFromSpanAndUnit(source.WorkorderPreventiveMaintenance.dtNextServiceDate, + source.WorkorderPreventiveMaintenance.GenerateSpanUnit, + source.WorkorderPreventiveMaintenance.GenerateSpan); - + //Get to the desired day of the week if necessary... + if (source.mWorkorderPreventiveMaintenance.DayOfTheWeek != AyaDayOfWeek.AnyDayOfWeek) + { + DayOfWeek desired = AyaToSystemDayOfWeek(source.mWorkorderPreventiveMaintenance.DayOfTheWeek); + while (dtNext.DayOfWeek != desired) + { + dtNext = dtNext.AddDays(1); + } - #endregion + } - //Will the next workorder service date fall after the - //stop generating date? - if(source.WorkorderPreventiveMaintenance.StopGeneratingDate!=System.DBNull.Value && - source.WorkorderPreventiveMaintenance.dtStopGeneratingDate < dtNext) - { - //Yes it will, so set it to inactive and bail out - source.WorkorderPreventiveMaintenance.Active=false; - source.Save(); - return dest; - } + //Get the time span to add to all the other relevant dates on teh workorder to match + //the amount the next service date has been advanced + System.TimeSpan tsToNext = dtNext - source.WorkorderPreventiveMaintenance.dtNextServiceDate; - #region Reschedule PM - - source.WorkorderPreventiveMaintenance.dtNextServiceDate=dtNext; - //Calcs the generate date (threshold date) - source.WorkorderPreventiveMaintenance.SetGenerateDate(); - //WORKORDERITEMS - foreach(WorkorderItem wisource in source.WorkorderItems) - { - - wisource.RequestDate=wisource.RequestDate; - - //PARTS - //no date changes required - - //SCHEDULED USERS - foreach(WorkorderItemScheduledUser usersource in wisource.ScheduledUsers) - { + + + #endregion + + //Will the next workorder service date fall after the + //stop generating date? + if (source.WorkorderPreventiveMaintenance.StopGeneratingDate != System.DBNull.Value && + source.WorkorderPreventiveMaintenance.dtStopGeneratingDate < dtNext) + { + //Yes it will, so set it to inactive and bail out + source.WorkorderPreventiveMaintenance.Active = false; + source.Save(); + return dest; + } + + #region Reschedule PM + + source.WorkorderPreventiveMaintenance.dtNextServiceDate = dtNext; + //Calcs the generate date (threshold date) + source.WorkorderPreventiveMaintenance.SetGenerateDate(); + //WORKORDERITEMS + foreach (WorkorderItem wisource in source.WorkorderItems) + { + + wisource.RequestDate = wisource.RequestDate; + + + //PARTS + //no date changes required + + + //SCHEDULED USERS + foreach (WorkorderItemScheduledUser usersource in wisource.ScheduledUsers) + { //Changed: 2-Oct-2006 //check to not add a date if the original date was empty - if(usersource.StartDate!=System.DBNull.Value) - usersource.dtStartDate=usersource.dtStartDate.Add(tsToNext); + if (usersource.StartDate != System.DBNull.Value) + usersource.dtStartDate = usersource.dtStartDate.Add(tsToNext); if (usersource.StopDate != System.DBNull.Value) - usersource.dtStopDate=usersource.dtStopDate.Add(tsToNext); - - - } + usersource.dtStopDate = usersource.dtStopDate.Add(tsToNext); - //LABOR - foreach(WorkorderItemLabor laborsource in wisource.Labors) - { + + } + + //LABOR + foreach (WorkorderItemLabor laborsource in wisource.Labors) + { //Changed: 2-Oct-2006 //check to not add a date if the original date was empty - if(laborsource.ServiceStartDate!=System.DBNull.Value) - laborsource.dtServiceStartDate=laborsource.dtServiceStartDate.Add(tsToNext); - + if (laborsource.ServiceStartDate != System.DBNull.Value) + laborsource.dtServiceStartDate = laborsource.dtServiceStartDate.Add(tsToNext); + if (laborsource.ServiceStopDate != System.DBNull.Value) - laborsource.dtServiceStopDate=laborsource.dtServiceStopDate.Add(tsToNext); - - } + laborsource.dtServiceStopDate = laborsource.dtServiceStopDate.Add(tsToNext); - //********************************************************** - //Expenses would be here if copying a service workorder - //********************************************************** + } + + //********************************************************** + //Expenses would be here if copying a service workorder + //********************************************************** - //********************************************************** - //Loans would be here if copying a service workorder - //********************************************************** + //********************************************************** + //Loans would be here if copying a service workorder + //********************************************************** - //TRAVEL - foreach(WorkorderItemTravel travelsource in wisource.Travels) - { + //TRAVEL + foreach (WorkorderItemTravel travelsource in wisource.Travels) + { //Changed: 2-Oct-2006 //check to not add a date if the original date was empty - if(travelsource.TravelStartDate!=DBNull.Value) - travelsource.dtTravelStartDate=travelsource.dtTravelStartDate.Add(tsToNext); - - if(travelsource.TravelStopDate!=DBNull.Value) - travelsource.dtTravelStopDate=travelsource.dtTravelStopDate.Add(tsToNext); - - } + if (travelsource.TravelStartDate != DBNull.Value) + travelsource.dtTravelStartDate = travelsource.dtTravelStartDate.Add(tsToNext); + + if (travelsource.TravelStopDate != DBNull.Value) + travelsource.dtTravelStopDate = travelsource.dtTravelStopDate.Add(tsToNext); + + } - //TASKS - + //TASKS - //********************************************************** - //Outside service would be here if copying a service workorder - //********************************************************** - }//foreach workorderitem loop - #endregion reschedule pm + //********************************************************** + //Outside service would be here if copying a service workorder + //********************************************************** - //Ok, Source PM is now rescheduled, save it + }//foreach workorderitem loop + #endregion reschedule pm + + //Ok, Source PM is now rescheduled, save it //case 1959 try catch block added to prevent infinite generation issue try { - source = (Workorder)source.Save(); + source = (Workorder)source.Save(); } - catch(Exception exx) + catch (Exception exx) { dest.Delete(); dest.Save(); //crack the exception - while(exx.InnerException!=null) - exx=exx.InnerException; + while (exx.InnerException != null) + exx = exx.InnerException; Memo mwarn = Memo.NewItem(); mwarn.ToID = User.AdministratorID; @@ -4255,7 +4260,7 @@ namespace GZTW.AyaNova.BLL sb.AppendLine("Exception saving source PM:"); sb.AppendLine(exx.Message); sb.AppendLine("================================="); - string sSourceErr=source.GetBrokenRulesString(); + string sSourceErr = source.GetBrokenRulesString(); if (!string.IsNullOrWhiteSpace(sSourceErr)) { sb.AppendLine("Broken business rules on PM object:"); @@ -4266,7 +4271,7 @@ namespace GZTW.AyaNova.BLL mwarn.Save(); throw new System.ApplicationException("Workorder->NewServiceWorkorderFromPM: Error during service workorder generation. Memo with details sent to Administrator account."); - + } @@ -4285,249 +4290,249 @@ namespace GZTW.AyaNova.BLL } - return dest; - - - - - - } - #endregion gen service wo from pm - - #region Copy workorder item from one workorder to another - - /// - /// Copy workorder item and all it's children - /// from current workorder to indicated destination workorder - /// - /// Destination workorder can not be closed and must be the same client - /// - /// If inventory is being tracked then all quantities from parts - /// are copied over as reserved quantities and need to be re-selected on destination - /// to control inventory / serial numbers etc - /// - /// Loans, Outside service, part requests and Expenses are NOT copied as they are - /// situation specific. - /// - /// - /// - /// - public static void CopyWorkorderItem(Guid ToWorkorderID, Guid SourceWorkorderID, Guid SourceWorkorderItemID) - { - - - //Do they have enough rights to do this? - if(RightsToWorkorder(ToWorkorderID) < SecurityLevelTypes.ReadWrite) - throw new System.Security.SecurityException( - string.Format( - LocalizedTextTable.GetLocalizedTextDirect("Error.Security.NotAuthorizedToCreate"), - LocalizedTextTable.GetLocalizedTextDirect("O.Workorder"))); - - - //Fetch the source workorder and verify it's got the source workorder item in it - Workorder source=Workorder.GetItemNoMRU(SourceWorkorderID); - if(!source.WorkorderItems.Contains(SourceWorkorderItemID)) - DBUtil.ThrowFetchError("WorkorderItemID: " + SourceWorkorderItemID.ToString()); - - //Ok, so far so good, create the new one - bool bUseInventory=AyaBizUtils.GlobalSettings.UseInventory; - Workorder dest = Workorder.GetItemNoMRU(ToWorkorderID); - if(dest.Closed==true || dest.ServiceCompleted==true) - throw new System.ApplicationException - ( - string.Format - ( - LocalizedTextTable.GetLocalizedTextDirect("Error.Security.NotAuthorizedToChange"), - LocalizedTextTable.GetLocalizedTextDirect("O.Workorder") - ) - ); - - //WORKORDERITEM - WorkorderItem wisource =source.WorkorderItems[SourceWorkorderItemID]; - - WorkorderItem widest=dest.WorkorderItems.Add(dest); - widest.Custom0=wisource.Custom0; - widest.Custom1=wisource.Custom1; - widest.Custom2=wisource.Custom2; - widest.Custom3=wisource.Custom3; - widest.Custom4=wisource.Custom4; - widest.Custom5=wisource.Custom5; - widest.Custom6=wisource.Custom6; - widest.Custom7=wisource.Custom7; - widest.Custom8=wisource.Custom8; - widest.Custom9=wisource.Custom9; - widest.PriorityID=wisource.PriorityID; - widest.RequestDate=wisource.RequestDate; - widest.Summary=wisource.Summary; - widest.TechNotes=wisource.TechNotes; - widest.TypeID=wisource.TypeID; - widest.UnitID=wisource.UnitID; - widest.WarrantyService=wisource.WarrantyService; - widest.WorkorderItemUnitServiceTypeID=wisource.WorkorderItemUnitServiceTypeID; - widest.WorkorderStatusID=wisource.WorkorderStatusID; - - //PARTS - foreach(WorkorderItemPart partsource in wisource.Parts) - { - WorkorderItemPart partdest=widest.Parts.Add(widest); - partdest.Cost=partsource.Cost; - partdest.Description=partsource.Description; - partdest.Discount=partsource.Discount; - partdest.DiscountType=partsource.DiscountType; - partdest.PartID=partsource.PartID; - partdest.PartWarehouseID=partsource.PartWarehouseID; - partdest.Price=partsource.Price; - if(bUseInventory) - { - partdest.QuantityReserved=partsource.Quantity; - partdest.Quantity=0; - } - else - partdest.Quantity=partsource.Quantity; - partdest.TaxPartSaleID=partsource.TaxPartSaleID; - - - } - - //********************************************************** - //Part requests would be here if copying a service workorder - //********************************************************** - - //SCHEDULED USERS - foreach(WorkorderItemScheduledUser usersource in wisource.ScheduledUsers) - { - WorkorderItemScheduledUser userdest=widest.ScheduledUsers.Add(widest); - userdest.EstimatedQuantity=usersource.EstimatedQuantity; - userdest.ServiceRateID=usersource.ServiceRateID; - userdest.StartDate=usersource.StartDate; - userdest.StopDate=usersource.StopDate; - userdest.UserID=usersource.UserID; - - } - - //LABOR - foreach(WorkorderItemLabor laborsource in wisource.Labors) - { - WorkorderItemLabor labordest=widest.Labors.Add(widest); - labordest.NoChargeQuantity=laborsource.NoChargeQuantity; - labordest.ServiceDetails=laborsource.ServiceDetails; - labordest.ServiceRateID=laborsource.ServiceRateID; - labordest.ServiceRateQuantity=laborsource.ServiceRateQuantity; - labordest.ServiceStartDate=laborsource.ServiceStartDate; - labordest.ServiceStopDate=laborsource.ServiceStopDate; - labordest.TaxRateSaleID=laborsource.TaxRateSaleID; - labordest.UserID=laborsource.UserID; - - } - - //********************************************************** - //Expenses would be here if copying a service workorder - //********************************************************** - - - //********************************************************** - //Loans would be here if copying a service workorder - //********************************************************** - - //TRAVEL - foreach(WorkorderItemTravel travelsource in wisource.Travels) - { - WorkorderItemTravel traveldest=widest.Travels.Add(widest); - traveldest.TravelDetails=travelsource.TravelDetails; - traveldest.TravelRateID=travelsource.TravelRateID; - traveldest.TravelRateQuantity=travelsource.TravelRateQuantity; - traveldest.TravelStartDate=travelsource.TravelStartDate; - traveldest.TravelStopDate=travelsource.TravelStopDate; - traveldest.TaxRateSaleID=travelsource.TaxRateSaleID; - traveldest.UserID=travelsource.UserID; - traveldest.Distance=travelsource.Distance; - traveldest.Notes=travelsource.Notes; - traveldest.NoChargeQuantity=travelsource.NoChargeQuantity; - } + return dest; - //TASKS - foreach(WorkorderItemTask tasksource in wisource.Tasks) - { - WorkorderItemTask taskdest=widest.Tasks.Add(widest); - taskdest.TaskGroupID=tasksource.TaskGroupID; - taskdest.TaskID=tasksource.TaskID; - - } - - //********************************************************** - //Outside service would be here if copying a service workorder - //********************************************************** - - dest.Save(); - } - #endregion - - #region Date time calcs helpers - //Takes an AyaNova day of week and returns - //a System.DayOfWeek - //Assumes that AyaDayOfWeek is NOT "AnyDay" - internal static System.DayOfWeek AyaToSystemDayOfWeek(AyaDayOfWeek day) - { - switch(day) - { - case AyaDayOfWeek.Monday: - return DayOfWeek.Monday; - case AyaDayOfWeek.Tuesday: - return DayOfWeek.Tuesday; - case AyaDayOfWeek.Wednesday: - return DayOfWeek.Wednesday; - case AyaDayOfWeek.Thursday: - return DayOfWeek.Thursday; - case AyaDayOfWeek.Friday: - return DayOfWeek.Friday; - case AyaDayOfWeek.Saturday: - return DayOfWeek.Saturday; - case AyaDayOfWeek.Sunday: - return DayOfWeek.Sunday; - - - - } - - throw new System.ArgumentOutOfRangeException("DayOfWeekConverter: AyaDayOfWeek.AnyDayOfWeek is not supported"); - } - internal static DateTime GetDateFromSpanAndUnit(DateTime StartDate,AyaUnitsOfTime unit,int multiple) - { - switch(unit) - { - case AyaUnitsOfTime.Seconds: - return StartDate.AddSeconds(multiple); + } + #endregion gen service wo from pm - case AyaUnitsOfTime.Minutes: - return StartDate.AddMinutes(multiple); + #region Copy workorder item from one workorder to another - case AyaUnitsOfTime.Hours: - return StartDate.AddHours(multiple); - - case AyaUnitsOfTime.Days: - return StartDate.AddDays(multiple); - - case AyaUnitsOfTime.Weeks: - throw new System.NotSupportedException("GetDateFromSpanAndUnit: Weeks not supported"); - - case AyaUnitsOfTime.Months: - return StartDate.AddMonths(multiple); - - case AyaUnitsOfTime.Years: - return StartDate.AddYears(multiple); + /// + /// Copy workorder item and all it's children + /// from current workorder to indicated destination workorder + /// + /// Destination workorder can not be closed and must be the same client + /// + /// If inventory is being tracked then all quantities from parts + /// are copied over as reserved quantities and need to be re-selected on destination + /// to control inventory / serial numbers etc + /// + /// Loans, Outside service, part requests and Expenses are NOT copied as they are + /// situation specific. + /// + /// + /// + /// + public static void CopyWorkorderItem(Guid ToWorkorderID, Guid SourceWorkorderID, Guid SourceWorkorderItemID) + { - } + //Do they have enough rights to do this? + if (RightsToWorkorder(ToWorkorderID) < SecurityLevelTypes.ReadWrite) + throw new System.Security.SecurityException( + string.Format( + LocalizedTextTable.GetLocalizedTextDirect("Error.Security.NotAuthorizedToCreate"), + LocalizedTextTable.GetLocalizedTextDirect("O.Workorder"))); - //fail safe: - return StartDate; - } - #endregion date time calcs helpers + //Fetch the source workorder and verify it's got the source workorder item in it + Workorder source = Workorder.GetItemNoMRU(SourceWorkorderID); + if (!source.WorkorderItems.Contains(SourceWorkorderItemID)) + DBUtil.ThrowFetchError("WorkorderItemID: " + SourceWorkorderItemID.ToString()); + + //Ok, so far so good, create the new one + bool bUseInventory = AyaBizUtils.GlobalSettings.UseInventory; + Workorder dest = Workorder.GetItemNoMRU(ToWorkorderID); + if (dest.Closed == true || dest.ServiceCompleted == true) + throw new System.ApplicationException + ( + string.Format + ( + LocalizedTextTable.GetLocalizedTextDirect("Error.Security.NotAuthorizedToChange"), + LocalizedTextTable.GetLocalizedTextDirect("O.Workorder") + ) + ); + + //WORKORDERITEM + WorkorderItem wisource = source.WorkorderItems[SourceWorkorderItemID]; + + WorkorderItem widest = dest.WorkorderItems.Add(dest); + widest.Custom0 = wisource.Custom0; + widest.Custom1 = wisource.Custom1; + widest.Custom2 = wisource.Custom2; + widest.Custom3 = wisource.Custom3; + widest.Custom4 = wisource.Custom4; + widest.Custom5 = wisource.Custom5; + widest.Custom6 = wisource.Custom6; + widest.Custom7 = wisource.Custom7; + widest.Custom8 = wisource.Custom8; + widest.Custom9 = wisource.Custom9; + widest.PriorityID = wisource.PriorityID; + widest.RequestDate = wisource.RequestDate; + widest.Summary = wisource.Summary; + widest.TechNotes = wisource.TechNotes; + widest.TypeID = wisource.TypeID; + widest.UnitID = wisource.UnitID; + widest.WarrantyService = wisource.WarrantyService; + widest.WorkorderItemUnitServiceTypeID = wisource.WorkorderItemUnitServiceTypeID; + widest.WorkorderStatusID = wisource.WorkorderStatusID; + + //PARTS + foreach (WorkorderItemPart partsource in wisource.Parts) + { + WorkorderItemPart partdest = widest.Parts.Add(widest); + partdest.Cost = partsource.Cost; + partdest.Description = partsource.Description; + partdest.Discount = partsource.Discount; + partdest.DiscountType = partsource.DiscountType; + partdest.PartID = partsource.PartID; + partdest.PartWarehouseID = partsource.PartWarehouseID; + partdest.Price = partsource.Price; + if (bUseInventory) + { + partdest.QuantityReserved = partsource.Quantity; + partdest.Quantity = 0; + } + else + partdest.Quantity = partsource.Quantity; + partdest.TaxPartSaleID = partsource.TaxPartSaleID; + + + } + + //********************************************************** + //Part requests would be here if copying a service workorder + //********************************************************** + + //SCHEDULED USERS + foreach (WorkorderItemScheduledUser usersource in wisource.ScheduledUsers) + { + WorkorderItemScheduledUser userdest = widest.ScheduledUsers.Add(widest); + userdest.EstimatedQuantity = usersource.EstimatedQuantity; + userdest.ServiceRateID = usersource.ServiceRateID; + userdest.StartDate = usersource.StartDate; + userdest.StopDate = usersource.StopDate; + userdest.UserID = usersource.UserID; + + } + + //LABOR + foreach (WorkorderItemLabor laborsource in wisource.Labors) + { + WorkorderItemLabor labordest = widest.Labors.Add(widest); + labordest.NoChargeQuantity = laborsource.NoChargeQuantity; + labordest.ServiceDetails = laborsource.ServiceDetails; + labordest.ServiceRateID = laborsource.ServiceRateID; + labordest.ServiceRateQuantity = laborsource.ServiceRateQuantity; + labordest.ServiceStartDate = laborsource.ServiceStartDate; + labordest.ServiceStopDate = laborsource.ServiceStopDate; + labordest.TaxRateSaleID = laborsource.TaxRateSaleID; + labordest.UserID = laborsource.UserID; + + } + + //********************************************************** + //Expenses would be here if copying a service workorder + //********************************************************** + + + //********************************************************** + //Loans would be here if copying a service workorder + //********************************************************** + + //TRAVEL + foreach (WorkorderItemTravel travelsource in wisource.Travels) + { + WorkorderItemTravel traveldest = widest.Travels.Add(widest); + traveldest.TravelDetails = travelsource.TravelDetails; + traveldest.TravelRateID = travelsource.TravelRateID; + traveldest.TravelRateQuantity = travelsource.TravelRateQuantity; + traveldest.TravelStartDate = travelsource.TravelStartDate; + traveldest.TravelStopDate = travelsource.TravelStopDate; + traveldest.TaxRateSaleID = travelsource.TaxRateSaleID; + traveldest.UserID = travelsource.UserID; + traveldest.Distance = travelsource.Distance; + traveldest.Notes = travelsource.Notes; + traveldest.NoChargeQuantity = travelsource.NoChargeQuantity; + } + + + + //TASKS + foreach (WorkorderItemTask tasksource in wisource.Tasks) + { + WorkorderItemTask taskdest = widest.Tasks.Add(widest); + taskdest.TaskGroupID = tasksource.TaskGroupID; + taskdest.TaskID = tasksource.TaskID; + + } + + //********************************************************** + //Outside service would be here if copying a service workorder + //********************************************************** + + dest.Save(); + } + #endregion + + #region Date time calcs helpers + //Takes an AyaNova day of week and returns + //a System.DayOfWeek + //Assumes that AyaDayOfWeek is NOT "AnyDay" + internal static System.DayOfWeek AyaToSystemDayOfWeek(AyaDayOfWeek day) + { + switch (day) + { + case AyaDayOfWeek.Monday: + return DayOfWeek.Monday; + case AyaDayOfWeek.Tuesday: + return DayOfWeek.Tuesday; + case AyaDayOfWeek.Wednesday: + return DayOfWeek.Wednesday; + case AyaDayOfWeek.Thursday: + return DayOfWeek.Thursday; + case AyaDayOfWeek.Friday: + return DayOfWeek.Friday; + case AyaDayOfWeek.Saturday: + return DayOfWeek.Saturday; + case AyaDayOfWeek.Sunday: + return DayOfWeek.Sunday; + + + + } + + throw new System.ArgumentOutOfRangeException("DayOfWeekConverter: AyaDayOfWeek.AnyDayOfWeek is not supported"); + } + + + internal static DateTime GetDateFromSpanAndUnit(DateTime StartDate, AyaUnitsOfTime unit, int multiple) + { + switch (unit) + { + case AyaUnitsOfTime.Seconds: + return StartDate.AddSeconds(multiple); + + case AyaUnitsOfTime.Minutes: + return StartDate.AddMinutes(multiple); + + case AyaUnitsOfTime.Hours: + return StartDate.AddHours(multiple); + + case AyaUnitsOfTime.Days: + return StartDate.AddDays(multiple); + + case AyaUnitsOfTime.Weeks: + throw new System.NotSupportedException("GetDateFromSpanAndUnit: Weeks not supported"); + + case AyaUnitsOfTime.Months: + return StartDate.AddMonths(multiple); + + case AyaUnitsOfTime.Years: + return StartDate.AddYears(multiple); + + + } + + //fail safe: + return StartDate; + } + + #endregion date time calcs helpers #region wotype <-> rootobject converters /// @@ -4541,25 +4546,25 @@ namespace GZTW.AyaNova.BLL { case RootObjectTypes.WorkorderService: return WorkorderTypes.Service; - + case RootObjectTypes.WorkorderQuote: - return WorkorderTypes.Quote; - + return WorkorderTypes.Quote; + case RootObjectTypes.WorkorderPreventiveMaintenance: return WorkorderTypes.PreventiveMaintenance; - + case RootObjectTypes.WorkorderServiceTemplate: return WorkorderTypes.TemplateService; - + case RootObjectTypes.WorkorderQuoteTemplate: return WorkorderTypes.TemplateQuote; - + case RootObjectTypes.WorkorderPreventiveMaintenanceTemplate: return WorkorderTypes.TemplatePreventiveMaintenance; - + default: return WorkorderTypes.Unknown; - + } } @@ -4573,24 +4578,24 @@ namespace GZTW.AyaNova.BLL { switch (wotype) { - + case WorkorderTypes.Service: - return RootObjectTypes.WorkorderService; + return RootObjectTypes.WorkorderService; case WorkorderTypes.Quote: - return RootObjectTypes.WorkorderQuote; - + return RootObjectTypes.WorkorderQuote; + case WorkorderTypes.PreventiveMaintenance: - return RootObjectTypes.WorkorderPreventiveMaintenance; - + return RootObjectTypes.WorkorderPreventiveMaintenance; + case WorkorderTypes.TemplateService: - return RootObjectTypes.WorkorderServiceTemplate; - + return RootObjectTypes.WorkorderServiceTemplate; + case WorkorderTypes.TemplateQuote: - return RootObjectTypes.WorkorderQuoteTemplate; - + return RootObjectTypes.WorkorderQuoteTemplate; + case WorkorderTypes.TemplatePreventiveMaintenance: return RootObjectTypes.WorkorderPreventiveMaintenanceTemplate; - + default: return RootObjectTypes.Nothing; @@ -4598,27 +4603,27 @@ namespace GZTW.AyaNova.BLL } } - #endregion converter + #endregion converter #endregion static methods #region Shared Notification Message Processor internal static NotifyMessage GetNotificationMessage(NotifyMessageRequestData d) - { + { //case 1555 - bool bSourceIsQuote = (d.EventType==(int)WorkorderEvent.QuoteUpdated); + bool bSourceIsQuote = (d.EventType == (int)WorkorderEvent.QuoteUpdated); if (bSourceIsQuote)//case 1555 { #region Quote workorder - WorkorderQuoteDescriptionFetcher wdf = WorkorderQuoteDescriptionFetcher.GetItem(d.RootObjectID); + WorkorderQuoteDescriptionFetcher wdf = WorkorderQuoteDescriptionFetcher.GetItem(d.RootObjectID); string sEventDescription = ""; string sExtraInfo = ""; switch (d.EventType) { - + case (int)WorkorderEvent.QuoteUpdated: sEventDescription = LocalizedTextTable.GetLocalizedTextDirect("Workorder.Label.Event.QuoteUpdated", d.Language); bSourceIsQuote = true; @@ -4710,53 +4715,53 @@ namespace GZTW.AyaNova.BLL return nm; #endregion service workorder } - } - #endregion + } + #endregion - #region DAL DATA ACCESS - - #region Fetch + #region DAL DATA ACCESS + + #region Fetch //case 53 - need to know if workorder was new before it was saved //for new workorder client notification processing private bool bWasNew = false; - /// - /// - protected override void DataPortal_Fetch(object Criteria) - { - - //set to false to load items initially - bReadOnly=false; + /// + /// + protected override void DataPortal_Fetch(object Criteria) + { - Criteria crit = (Criteria)Criteria; - SafeDataReader dr = null; - Guid WorkorderIDToFetch=crit.ID; - try - { + //set to false to load items initially + bReadOnly = false; - switch(crit.RootObjectType) - { - case RootObjectTypes.Workorder: - ;//Do nothing, we already have the workorder id in crit.ID - break; - case RootObjectTypes.WorkorderItem: - WorkorderIDToFetch=DBUtil.ToGuid(DBUtil.GetScalarFromSQLString( - "SELECT TOP 1 aWorkorderItem.aWorkorderID " + - "FROM aWorkorderItem WHERE (aWorkorderItem.aID = @ID)" - ,crit.ID)); - break; - case RootObjectTypes.WorkorderItemLabor: - WorkorderIDToFetch=DBUtil.ToGuid(DBUtil.GetScalarFromSQLString( - "SELECT TOP 1 aWorkorderItem.aWorkorderID " + - "FROM aWorkorderItem INNER JOIN aWorkorderItemLabor " + - "ON aWorkorderItem.aID = aWorkorderItemLabor.aWorkorderItemID " + - "WHERE (aWorkorderItemLabor.aID " + - "= @ID)" - ,crit.ID)); - break; - //Added: 2-Oct-2006 - //to support search results display + Criteria crit = (Criteria)Criteria; + SafeDataReader dr = null; + Guid WorkorderIDToFetch = crit.ID; + try + { + + switch (crit.RootObjectType) + { + case RootObjectTypes.Workorder: + ;//Do nothing, we already have the workorder id in crit.ID + break; + case RootObjectTypes.WorkorderItem: + WorkorderIDToFetch = DBUtil.ToGuid(DBUtil.GetScalarFromSQLString( + "SELECT TOP 1 aWorkorderItem.aWorkorderID " + + "FROM aWorkorderItem WHERE (aWorkorderItem.aID = @ID)" + , crit.ID)); + break; + case RootObjectTypes.WorkorderItemLabor: + WorkorderIDToFetch = DBUtil.ToGuid(DBUtil.GetScalarFromSQLString( + "SELECT TOP 1 aWorkorderItem.aWorkorderID " + + "FROM aWorkorderItem INNER JOIN aWorkorderItemLabor " + + "ON aWorkorderItem.aID = aWorkorderItemLabor.aWorkorderItemID " + + "WHERE (aWorkorderItemLabor.aID " + + "= @ID)" + , crit.ID)); + break; + //Added: 2-Oct-2006 + //to support search results display case RootObjectTypes.WorkorderItemMiscExpense: WorkorderIDToFetch = DBUtil.ToGuid(DBUtil.GetScalarFromSQLString( "SELECT TOP 1 aWorkorderItem.aWorkorderID " + @@ -4766,138 +4771,138 @@ namespace GZTW.AyaNova.BLL "= @ID)" , crit.ID)); break; - case RootObjectTypes.WorkorderItemTravel: - WorkorderIDToFetch=DBUtil.ToGuid(DBUtil.GetScalarFromSQLString( - "SELECT TOP 1 aWorkorderItem.aWorkorderID " + - "FROM aWorkorderItem INNER JOIN aWorkorderItemTravel " + - "ON aWorkorderItem.aID = aWorkorderItemTravel.aWorkorderItemID " + - "WHERE (aWorkorderItemTravel.aID " + - "= @ID)" - ,crit.ID)); - break; - case RootObjectTypes.WorkorderItemScheduledUser: - WorkorderIDToFetch=DBUtil.ToGuid(DBUtil.GetScalarFromSQLString( - "SELECT TOP 1 aWorkorderItem.aWorkorderID " + - "FROM aWorkorderItem INNER JOIN aWorkorderItemScheduledUser " + - "ON aWorkorderItem.aID = aWorkorderItemScheduledUser.aWorkorderItemID " + - "WHERE (aWorkorderItemScheduledUser.aID " + - "= @ID)" - ,crit.ID)); - break; - case RootObjectTypes.WorkorderItemOutsideService: - WorkorderIDToFetch=DBUtil.ToGuid(DBUtil.GetScalarFromSQLString( - "SELECT TOP 1 aWorkorderItem.aWorkorderID " + - "FROM aWorkorderItem INNER JOIN aWorkorderItemOutsideService " + - "ON aWorkorderItem.aID = aWorkorderItemOutsideService.aWorkorderItemID " + - "WHERE (aWorkorderItemOutsideService.aID " + - "= @ID)" - ,crit.ID)); - break; - case RootObjectTypes.WorkorderItemPartRequest: - WorkorderIDToFetch=DBUtil.ToGuid(DBUtil.GetScalarFromSQLString( - "SELECT TOP 1 aWorkorderItem.aWorkorderID " + - "FROM aWorkorderItem INNER JOIN aWorkorderItemPartRequest " + - "ON aWorkorderItem.aID = aWorkorderItemPartRequest.aWorkorderItemID " + - "WHERE (aWorkorderItemPartRequest.aID " + - "= @ID)" - ,crit.ID)); - break; - case RootObjectTypes.WorkorderItemPart: - WorkorderIDToFetch=DBUtil.ToGuid(DBUtil.GetScalarFromSQLString( - "SELECT TOP 1 aWorkorderItem.aWorkorderID " + - "FROM aWorkorderItem INNER JOIN aWorkorderItemPart " + - "ON aWorkorderItem.aID = aWorkorderItemPart.aWorkorderItemID " + - "WHERE (aWorkorderItemPart.aID " + - "= @ID)" - ,crit.ID)); - break; - case RootObjectTypes.WorkorderPreventiveMaintenance: - WorkorderIDToFetch=DBUtil.ToGuid(DBUtil.GetScalarFromSQLString( - "SELECT aWorkorderPreventiveMaintenance.aWorkorderID " + - "FROM aWorkorderPreventiveMaintenance " + - "WHERE (aWorkorderPreventiveMaintenance.aID " + - "= @ID)" - ,crit.ID)); - break; - case RootObjectTypes.WorkorderQuote: - WorkorderIDToFetch=DBUtil.ToGuid(DBUtil.GetScalarFromSQLString( - "SELECT aWorkorderQuote.aWorkorderID " + - "FROM aWorkorderQuote " + - "WHERE (aWorkorderQuote.aID " + - "= @ID)" - ,crit.ID)); - break; - case RootObjectTypes.WorkorderService: - WorkorderIDToFetch=DBUtil.ToGuid(DBUtil.GetScalarFromSQLString( - "SELECT aWorkorderService.aWorkorderID " + - "FROM aWorkorderService " + - "WHERE (aWorkorderService.aID " + - "= @ID)" - ,crit.ID)); - break; - case RootObjectTypes.WorkorderItemLoan: - WorkorderIDToFetch=DBUtil.ToGuid(DBUtil.GetScalarFromSQLString( - "SELECT TOP 1 aWorkorderItem.aWorkorderID " + - "FROM aWorkorderItem INNER JOIN aWorkorderItemLoan " + - "ON aWorkorderItem.aID = aWorkorderItemLoan.aWorkorderItemID " + - "WHERE (aWorkorderItemLoan.aID " + - "= @ID)" - ,crit.ID)); - break; - default: - throw new System.NotSupportedException("GetWorkorderByDescendant(" + crit.RootObjectType.ToString() + ") not supported"); - } + case RootObjectTypes.WorkorderItemTravel: + WorkorderIDToFetch = DBUtil.ToGuid(DBUtil.GetScalarFromSQLString( + "SELECT TOP 1 aWorkorderItem.aWorkorderID " + + "FROM aWorkorderItem INNER JOIN aWorkorderItemTravel " + + "ON aWorkorderItem.aID = aWorkorderItemTravel.aWorkorderItemID " + + "WHERE (aWorkorderItemTravel.aID " + + "= @ID)" + , crit.ID)); + break; + case RootObjectTypes.WorkorderItemScheduledUser: + WorkorderIDToFetch = DBUtil.ToGuid(DBUtil.GetScalarFromSQLString( + "SELECT TOP 1 aWorkorderItem.aWorkorderID " + + "FROM aWorkorderItem INNER JOIN aWorkorderItemScheduledUser " + + "ON aWorkorderItem.aID = aWorkorderItemScheduledUser.aWorkorderItemID " + + "WHERE (aWorkorderItemScheduledUser.aID " + + "= @ID)" + , crit.ID)); + break; + case RootObjectTypes.WorkorderItemOutsideService: + WorkorderIDToFetch = DBUtil.ToGuid(DBUtil.GetScalarFromSQLString( + "SELECT TOP 1 aWorkorderItem.aWorkorderID " + + "FROM aWorkorderItem INNER JOIN aWorkorderItemOutsideService " + + "ON aWorkorderItem.aID = aWorkorderItemOutsideService.aWorkorderItemID " + + "WHERE (aWorkorderItemOutsideService.aID " + + "= @ID)" + , crit.ID)); + break; + case RootObjectTypes.WorkorderItemPartRequest: + WorkorderIDToFetch = DBUtil.ToGuid(DBUtil.GetScalarFromSQLString( + "SELECT TOP 1 aWorkorderItem.aWorkorderID " + + "FROM aWorkorderItem INNER JOIN aWorkorderItemPartRequest " + + "ON aWorkorderItem.aID = aWorkorderItemPartRequest.aWorkorderItemID " + + "WHERE (aWorkorderItemPartRequest.aID " + + "= @ID)" + , crit.ID)); + break; + case RootObjectTypes.WorkorderItemPart: + WorkorderIDToFetch = DBUtil.ToGuid(DBUtil.GetScalarFromSQLString( + "SELECT TOP 1 aWorkorderItem.aWorkorderID " + + "FROM aWorkorderItem INNER JOIN aWorkorderItemPart " + + "ON aWorkorderItem.aID = aWorkorderItemPart.aWorkorderItemID " + + "WHERE (aWorkorderItemPart.aID " + + "= @ID)" + , crit.ID)); + break; + case RootObjectTypes.WorkorderPreventiveMaintenance: + WorkorderIDToFetch = DBUtil.ToGuid(DBUtil.GetScalarFromSQLString( + "SELECT aWorkorderPreventiveMaintenance.aWorkorderID " + + "FROM aWorkorderPreventiveMaintenance " + + "WHERE (aWorkorderPreventiveMaintenance.aID " + + "= @ID)" + , crit.ID)); + break; + case RootObjectTypes.WorkorderQuote: + WorkorderIDToFetch = DBUtil.ToGuid(DBUtil.GetScalarFromSQLString( + "SELECT aWorkorderQuote.aWorkorderID " + + "FROM aWorkorderQuote " + + "WHERE (aWorkorderQuote.aID " + + "= @ID)" + , crit.ID)); + break; + case RootObjectTypes.WorkorderService: + WorkorderIDToFetch = DBUtil.ToGuid(DBUtil.GetScalarFromSQLString( + "SELECT aWorkorderService.aWorkorderID " + + "FROM aWorkorderService " + + "WHERE (aWorkorderService.aID " + + "= @ID)" + , crit.ID)); + break; + case RootObjectTypes.WorkorderItemLoan: + WorkorderIDToFetch = DBUtil.ToGuid(DBUtil.GetScalarFromSQLString( + "SELECT TOP 1 aWorkorderItem.aWorkorderID " + + "FROM aWorkorderItem INNER JOIN aWorkorderItemLoan " + + "ON aWorkorderItem.aID = aWorkorderItemLoan.aWorkorderItemID " + + "WHERE (aWorkorderItemLoan.aID " + + "= @ID)" + , crit.ID)); + break; + default: + throw new System.NotSupportedException("GetWorkorderByDescendant(" + crit.RootObjectType.ToString() + ") not supported"); + } - - crit.ID=WorkorderIDToFetch; - //retrieve the workorder: - dr=DBUtil.GetReaderFromSQLString("SELECT * FROM aWorkorder WHERE aID=@ID;",crit.ID); - if(!dr.Read()) - DBUtil.ThrowFetchError("Workorder ID: " + crit.ID.ToString()); + crit.ID = WorkorderIDToFetch; + + //retrieve the workorder: + dr = DBUtil.GetReaderFromSQLString("SELECT * FROM aWorkorder WHERE aID=@ID;", crit.ID); + if (!dr.Read()) + DBUtil.ThrowFetchError("Workorder ID: " + crit.ID.ToString()); + + //Workorder fields + mClientID = dr.GetGuid("aClientID"); + mProjectID = dr.GetGuid("aProjectID"); + mInternalReferenceNumber = dr.GetString("aInternalReferenceNumber"); + mCustomerReferenceNumber = dr.GetString("aCustomerReferenceNumber"); + mOnsite = dr.GetBoolean("aOnsite"); + mCustomerContactName = dr.GetString("aCustomerContactName"); - //Workorder fields - mClientID=dr.GetGuid("aClientID"); - mProjectID=dr.GetGuid("aProjectID"); - mInternalReferenceNumber=dr.GetString("aInternalReferenceNumber"); - mCustomerReferenceNumber=dr.GetString("aCustomerReferenceNumber"); - mOnsite=dr.GetBoolean("aOnsite"); - mCustomerContactName=dr.GetString("aCustomerContactName"); - //Case 58 - mRegionID=dr.GetGuid("aRegionID"); + mRegionID = dr.GetGuid("aRegionID"); - mSummary=dr.GetString("aSummary"); - //mTemplateID=dr.GetGuid("aTemplateID"); - mFormLayoutID=dr.GetGuid("aFormLayoutID"); - mWorkorderType=(WorkorderTypes)dr.GetInt16("aWorkorderType"); + mSummary = dr.GetString("aSummary"); + //mTemplateID=dr.GetGuid("aTemplateID"); + mFormLayoutID = dr.GetGuid("aFormLayoutID"); + mWorkorderType = (WorkorderTypes)dr.GetInt16("aWorkorderType"); mRights = (SecurityLevelTypes)AyaBizUtils.Right(Workorder.RootObjectTypeFromWorkorderType(mWorkorderType)); - //mTemplate=dr.GetBoolean("aTemplate"); - mWorkorderCategoryID=dr.GetGuid("aWorkorderCategoryID"); - mServiceCompleted=dr.GetBoolean("aServiceCompleted"); - mClosed=dr.GetBoolean("aClosed"); - mFromQuoteID=dr.GetGuid("aFromQuoteID"); - mFromPMID=dr.GetGuid("aFromPMID"); + //mTemplate=dr.GetBoolean("aTemplate"); + mWorkorderCategoryID = dr.GetGuid("aWorkorderCategoryID"); + mServiceCompleted = dr.GetBoolean("aServiceCompleted"); + mClosed = dr.GetBoolean("aClosed"); + mFromQuoteID = dr.GetGuid("aFromQuoteID"); + mFromPMID = dr.GetGuid("aFromPMID"); mTemplateDescription = dr.GetString("aTemplateDescription"); mTemplateFreshPrice = dr.GetBoolean("ATEMPLATEFRESHPRICE");//case 3132 - //Standard fields - mID=dr.GetGuid("aID"); - mCreated=DBUtil.ToLocal(dr.GetSmartDate("aCreated")); - mModified=DBUtil.ToLocal(dr.GetSmartDate("aModified")); - mCreator=dr.GetGuid("aCreator"); - mModifier=dr.GetGuid("aModifier"); - - if(dr!=null) dr.Close(); + //Standard fields + mID = dr.GetGuid("aID"); + mCreated = DBUtil.ToLocal(dr.GetSmartDate("aCreated")); + mModified = DBUtil.ToLocal(dr.GetSmartDate("aModified")); + mCreator = dr.GetGuid("aCreator"); + mModifier = dr.GetGuid("aModifier"); - - //Child objects... - - //PM + if (dr != null) dr.Close(); + + + //Child objects... + + //PM if (this.mWorkorderType == WorkorderTypes.PreventiveMaintenance || this.mWorkorderType == WorkorderTypes.TemplatePreventiveMaintenance) { @@ -4920,7 +4925,7 @@ namespace GZTW.AyaNova.BLL //WorkorderService if (this.mWorkorderType == WorkorderTypes.Service || - this.mWorkorderType== WorkorderTypes.TemplateService) + this.mWorkorderType == WorkorderTypes.TemplateService) { dr = DBUtil.GetReaderFromSQLString("SELECT * FROM aWorkorderService WHERE aWorkorderID=@ID;", crit.ID); if (dr.Read())//single child objects need this @@ -4941,7 +4946,7 @@ namespace GZTW.AyaNova.BLL //WorkorderQuote if (this.mWorkorderType == WorkorderTypes.Quote || - this.mWorkorderType==WorkorderTypes.TemplateQuote) + this.mWorkorderType == WorkorderTypes.TemplateQuote) { dr = DBUtil.GetReaderFromSQLString("SELECT * FROM aWorkorderQuote WHERE aWorkorderID=@ID;", crit.ID); if (dr.Read())//single child objects need this @@ -4957,27 +4962,27 @@ namespace GZTW.AyaNova.BLL } if (dr != null) dr.Close(); - } - + } - //WorkorderItems collection - dr=DBUtil.GetReaderFromSQLString("SELECT * FROM aWorkorderItem WHERE aWorkorderID=@ID;",crit.ID); - //Child collection objects don't need to read first: they do it themselves - mWorkorderItems=WorkorderItems.GetItems(dr, this); - if(dr!=null) dr.Close(); - //Docs - dr=DBUtil.GetReaderFromSQLString("SELECT * FROM AASSIGNEDDOC WHERE (aRootObjectID=@ID and aRootObjectType=9);",crit.ID); - mDocs=AssignedDocs.GetItems(dr, RootObjectTypes.Workorder, this.RootObjectType); - if(dr!=null) dr.Close(); + //WorkorderItems collection + dr = DBUtil.GetReaderFromSQLString("SELECT * FROM aWorkorderItem WHERE aWorkorderID=@ID;", crit.ID); + //Child collection objects don't need to read first: they do it themselves + mWorkorderItems = WorkorderItems.GetItems(dr, this); + if (dr != null) dr.Close(); - } - finally - { - if(dr!=null) dr.Close(); - } - - MarkOld(); + //Docs + dr = DBUtil.GetReaderFromSQLString("SELECT * FROM AASSIGNEDDOC WHERE (aRootObjectID=@ID and aRootObjectType=9);", crit.ID); + mDocs = AssignedDocs.GetItems(dr, RootObjectTypes.Workorder, this.RootObjectType); + if (dr != null) dr.Close(); + + } + finally + { + if (dr != null) dr.Close(); + } + + MarkOld(); if (crit.TrackMRU) @@ -4985,92 +4990,92 @@ namespace GZTW.AyaNova.BLL switch (mWorkorderType) { case WorkorderTypes.Service: - if(AyaBizUtils.AllowAutomaticMRUOnUpdate) AyaBizUtils.MRU.Add(RootObjectTypes.Workorder, mID); + if (AyaBizUtils.AllowAutomaticMRUOnUpdate) AyaBizUtils.MRU.Add(RootObjectTypes.Workorder, mID); break; case WorkorderTypes.Quote: - if(AyaBizUtils.AllowAutomaticMRUOnUpdate) AyaBizUtils.MRU.Add(RootObjectTypes.WorkorderQuote, WorkorderQuote.ID); + if (AyaBizUtils.AllowAutomaticMRUOnUpdate) AyaBizUtils.MRU.Add(RootObjectTypes.WorkorderQuote, WorkorderQuote.ID); break; case WorkorderTypes.PreventiveMaintenance: - if(AyaBizUtils.AllowAutomaticMRUOnUpdate) AyaBizUtils.MRU.Add(RootObjectTypes.WorkorderPreventiveMaintenance, WorkorderPreventiveMaintenance.ID); + if (AyaBizUtils.AllowAutomaticMRUOnUpdate) AyaBizUtils.MRU.Add(RootObjectTypes.WorkorderPreventiveMaintenance, WorkorderPreventiveMaintenance.ID); break; case WorkorderTypes.TemplateService: - if(AyaBizUtils.AllowAutomaticMRUOnUpdate) AyaBizUtils.MRU.Add(RootObjectTypes.WorkorderServiceTemplate, mID); + if (AyaBizUtils.AllowAutomaticMRUOnUpdate) AyaBizUtils.MRU.Add(RootObjectTypes.WorkorderServiceTemplate, mID); break; case WorkorderTypes.TemplateQuote: - if(AyaBizUtils.AllowAutomaticMRUOnUpdate) AyaBizUtils.MRU.Add(RootObjectTypes.WorkorderQuoteTemplate, WorkorderQuote.ID); + if (AyaBizUtils.AllowAutomaticMRUOnUpdate) AyaBizUtils.MRU.Add(RootObjectTypes.WorkorderQuoteTemplate, WorkorderQuote.ID); break; case WorkorderTypes.TemplatePreventiveMaintenance: - if(AyaBizUtils.AllowAutomaticMRUOnUpdate) AyaBizUtils.MRU.Add(RootObjectTypes.WorkorderPreventiveMaintenanceTemplate, WorkorderPreventiveMaintenance.ID); + if (AyaBizUtils.AllowAutomaticMRUOnUpdate) AyaBizUtils.MRU.Add(RootObjectTypes.WorkorderPreventiveMaintenanceTemplate, WorkorderPreventiveMaintenance.ID); break; } } //Get access rights level - bReadOnly = mRights < SecurityLevelTypes.ReadWrite; - - //If not already read only see if workorder is closed because a closed - //workorder is *always* read only - if(!bReadOnly) - { - if(mWorkorderType==WorkorderTypes.Service) - { - if(mClosed) - { + bReadOnly = mRights < SecurityLevelTypes.ReadWrite; + + //If not already read only see if workorder is closed because a closed + //workorder is *always* read only + if (!bReadOnly) + { + if (mWorkorderType == WorkorderTypes.Service) + { + if (mClosed) + { //case 986 - //bReadOnly=true; - //set all workorder items to read only status - this.mWorkorderItems.SetReadOnly(true); - return;//no need to continue because the following only - //does the same thing anyway - } - } - } + //bReadOnly=true; + //set all workorder items to read only status + this.mWorkorderItems.SetReadOnly(true); + return;//no need to continue because the following only + //does the same thing anyway + } + } + } - //Check for service completed - if(mWorkorderType==WorkorderTypes.Service) - { - if(mServiceCompleted) - { - //set all workorder items to read only status - this.mWorkorderItems.SetReadOnly(true); - } - } + //Check for service completed + if (mWorkorderType == WorkorderTypes.Service) + { + if (mServiceCompleted) + { + //set all workorder items to read only status + this.mWorkorderItems.SetReadOnly(true); + } + } - - } - #endregion fetch - #region Update - - /// - /// Called by DataPortal to delete/add/update data into the database - /// - protected override void DataPortal_Update() - { - - // If not a new record, check if record was modified - //by another user since original retrieval: - if(!IsNew) - DBUtil.CheckSafeToUpdate(this.mModified.Date,this.mID,"aWorkorder"); - - #region Delete - if(IsDeleted) - { - if(this.HasPartRequestsOnOrder) - throw new System.ApplicationException - ( - - string.Format - ( - LocalizedTextTable.GetLocalizedTextDirect("Error.Object.NotDeleteable"), - LocalizedTextTable.GetLocalizedTextDirect("O.Workorder") - ) + " when it has part requests on order"//case 3599 - ); - if(!IsNew) - { - - //Delete pm, service, quote, woitems and workorder itself + } + #endregion fetch + + #region Update + + /// + /// Called by DataPortal to delete/add/update data into the database + /// + protected override void DataPortal_Update() + { + + // If not a new record, check if record was modified + //by another user since original retrieval: + if (!IsNew) + DBUtil.CheckSafeToUpdate(this.mModified.Date, this.mID, "aWorkorder"); + + #region Delete + if (IsDeleted) + { + if (this.HasPartRequestsOnOrder) + throw new System.ApplicationException + ( + + string.Format + ( + LocalizedTextTable.GetLocalizedTextDirect("Error.Object.NotDeleteable"), + LocalizedTextTable.GetLocalizedTextDirect("O.Workorder") + ) + " when it has part requests on order"//case 3599 + ); + if (!IsNew) + { + + //Delete pm, service, quote, woitems and workorder itself //case 3596 @@ -5081,359 +5086,359 @@ namespace GZTW.AyaNova.BLL DBCommandWrapper cmDeleteFromLastServiceUnit = DBUtil.GetCommandFromSQL("UPDATE AUNIT SET ALASTWORKORDERID = null, ALASTSERVICEDATE = null WHERE ALASTWORKORDERID = @WORKORDERID"); cmDeleteFromLastServiceUnit.AddInParameter("@WORKORDERID", DbType.Guid, this.mID); - DBCommandWrapper cmDeletePM = DBUtil.GetCommandFromSQL("DELETE FROM aWorkorderPreventiveMaintenance WHERE aWorkorderID = @ID;"); - cmDeletePM.AddInParameter("@ID",DbType.Guid,this.mID); + DBCommandWrapper cmDeletePM = DBUtil.GetCommandFromSQL("DELETE FROM aWorkorderPreventiveMaintenance WHERE aWorkorderID = @ID;"); + cmDeletePM.AddInParameter("@ID", DbType.Guid, this.mID); - DBCommandWrapper cmDeleteService = DBUtil.GetCommandFromSQL("DELETE FROM aWorkorderService WHERE aWorkorderID = @ID;"); - cmDeleteService.AddInParameter("@ID",DbType.Guid,this.mID); + DBCommandWrapper cmDeleteService = DBUtil.GetCommandFromSQL("DELETE FROM aWorkorderService WHERE aWorkorderID = @ID;"); + cmDeleteService.AddInParameter("@ID", DbType.Guid, this.mID); - DBCommandWrapper cmDeleteQuote = DBUtil.GetCommandFromSQL("DELETE FROM aWorkorderQuote WHERE aWorkorderID = @ID;"); - cmDeleteQuote.AddInParameter("@ID",DbType.Guid,this.mID); + DBCommandWrapper cmDeleteQuote = DBUtil.GetCommandFromSQL("DELETE FROM aWorkorderQuote WHERE aWorkorderID = @ID;"); + cmDeleteQuote.AddInParameter("@ID", DbType.Guid, this.mID); - DBCommandWrapper cmDeleteWO = DBUtil.GetCommandFromSQL("DELETE FROM aWorkorder WHERE aID = @ID;"); - cmDeleteWO.AddInParameter("@ID",DbType.Guid,this.mID); - - + DBCommandWrapper cmDeleteWO = DBUtil.GetCommandFromSQL("DELETE FROM aWorkorder WHERE aID = @ID;"); + cmDeleteWO.AddInParameter("@ID", DbType.Guid, this.mID); - using (IDbConnection connection = DBUtil.DB.GetConnection()) - { - connection.Open(); - //IDbTransaction transaction = connection.BeginTransaction(); - //Changed this to a high isolation level transaction because - //it can affect inventory etc - IDbTransaction transaction = connection.BeginTransaction(System.Data.IsolationLevel.Serializable); - try - { + + using (IDbConnection connection = DBUtil.DB.GetConnection()) + { + connection.Open(); + //IDbTransaction transaction = connection.BeginTransaction(); + //Changed this to a high isolation level transaction because + //it can affect inventory etc + IDbTransaction transaction = connection.BeginTransaction(System.Data.IsolationLevel.Serializable); + + try + { //case 3596 DBUtil.DB.ExecuteNonQuery(cmDeleteFromLastServiceClient, transaction); DBUtil.DB.ExecuteNonQuery(cmDeleteFromLastServiceUnit, transaction); - //This one method takes care of any and all workorder - //items that are children of this workorder - //It deletes all workorder item children and then all workorder items - //attached to this workorder - WorkorderItems.DeleteItems(this.mID,transaction); - DBUtil.DB.ExecuteNonQuery(cmDeletePM, transaction); - DBUtil.DB.ExecuteNonQuery(cmDeleteService, transaction); - DBUtil.DB.ExecuteNonQuery(cmDeleteQuote, transaction); - DBUtil.DB.ExecuteNonQuery(cmDeleteWO, transaction); - - DBUtil.RemoveKeywords(transaction,RootObjectTypes.Workorder,this.mID); - DBUtil.RemoveDocs(transaction,RootObjectTypes.Workorder,this.mID); + //This one method takes care of any and all workorder + //items that are children of this workorder + //It deletes all workorder item children and then all workorder items + //attached to this workorder + WorkorderItems.DeleteItems(this.mID, transaction); + DBUtil.DB.ExecuteNonQuery(cmDeletePM, transaction); + DBUtil.DB.ExecuteNonQuery(cmDeleteService, transaction); + DBUtil.DB.ExecuteNonQuery(cmDeleteQuote, transaction); + DBUtil.DB.ExecuteNonQuery(cmDeleteWO, transaction); - // Commit the transaction - transaction.Commit(); - - } - catch - { - // Rollback transaction - transaction.Rollback(); - throw; - } - finally - { - connection.Close(); - } - } - - //Remove any events for this object + DBUtil.RemoveKeywords(transaction, RootObjectTypes.Workorder, this.mID); + DBUtil.RemoveDocs(transaction, RootObjectTypes.Workorder, this.mID); + + // Commit the transaction + transaction.Commit(); + + } + catch + { + // Rollback transaction + transaction.Rollback(); + throw; + } + finally + { + connection.Close(); + } + } + + //Remove any events for this object if (AyaBizUtils.GlobalSettings.UseNotification)//Case 510 - { - NotifyEvent.RemoveAllEventsForObject(this.mID); - } - //----------------------------- - } - MarkNew(); - return; - } + { + NotifyEvent.RemoveAllEventsForObject(this.mID); + } + //----------------------------- + } + MarkNew(); + return; + } - #endregion + #endregion - #region Add / Update - - //get modification time temporarily, if update succeeds then - //set to this time - System.DateTime dtModified = DBUtil.CurrentWorkingDateTime; - - DBCommandWrapper cm = null; - if(IsNew)//Add or update? - cm=DBUtil.GetCommandFromSQL( - "INSERT INTO aWorkorder (aID, aClientID, aProjectID, " + - "aInternalReferenceNumber, aCustomerReferenceNumber, " + - "aOnsite, aCustomerContactName, aWorkorderType, " + - "aFormLayoutID, aSummary, aTemplateDescription, " + - "aWorkorderCategoryID, aCreated,aModified,aCreator,aModifier, " + + #region Add / Update + + //get modification time temporarily, if update succeeds then + //set to this time + System.DateTime dtModified = DBUtil.CurrentWorkingDateTime; + + DBCommandWrapper cm = null; + if (IsNew)//Add or update? + cm = DBUtil.GetCommandFromSQL( + "INSERT INTO aWorkorder (aID, aClientID, aProjectID, " + + "aInternalReferenceNumber, aCustomerReferenceNumber, " + + "aOnsite, aCustomerContactName, aWorkorderType, " + + "aFormLayoutID, aSummary, aTemplateDescription, " + + "aWorkorderCategoryID, aCreated,aModified,aCreator,aModifier, " + "aClosed, aServiceCompleted, aFromQuoteID, aFromPMID, aRegionID, ATEMPLATEFRESHPRICE) VALUES (@ID,@ClientID, " + - "@ProjectID,@InternalReferenceNumber,@CustomerReferenceNumber, " + - "@Onsite,@CustomerContactName, " + - "@WorkorderType,@FormLayoutID, " + - "@Summary, @TemplateDescription, @WorkorderCategoryID, " + - "@Created, @Modified,@CurrentUserID,@CurrentUserID, " + - "@Closed,@ServiceCompleted, @FromQuoteID, @FromPMID, @RegionID, @TEMPLATEFRESHPRICE)" - ); - else - cm=DBUtil.GetCommandFromSQL( - "UPDATE aWorkorder SET aID=@ID, aClientID=@ClientID, " + - "aProjectID=@ProjectID, aInternalReferenceNumber=@InternalReferenceNumber, " + - "aCustomerReferenceNumber=@CustomerReferenceNumber, " + - "aOnsite=@Onsite, aCustomerContactName=@CustomerContactName, " + - "aWorkOrderType=@WorkOrderType, aFormLayoutID=@FormLayoutID, " + - "aSummary=@Summary, aTemplateDescription=@TemplateDescription, aWorkorderCategoryID=@WorkorderCategoryID, " + - " aModifier=@CurrentUserID, " + - " aModified=@Modified, aClosed=@Closed, " + - "aServiceCompleted=@ServiceCompleted, aFromQuoteID=@FromQuoteID, aFromPMID=@FromPMID, aRegionID=@RegionID, " + + "@ProjectID,@InternalReferenceNumber,@CustomerReferenceNumber, " + + "@Onsite,@CustomerContactName, " + + "@WorkorderType,@FormLayoutID, " + + "@Summary, @TemplateDescription, @WorkorderCategoryID, " + + "@Created, @Modified,@CurrentUserID,@CurrentUserID, " + + "@Closed,@ServiceCompleted, @FromQuoteID, @FromPMID, @RegionID, @TEMPLATEFRESHPRICE)" + ); + else + cm = DBUtil.GetCommandFromSQL( + "UPDATE aWorkorder SET aID=@ID, aClientID=@ClientID, " + + "aProjectID=@ProjectID, aInternalReferenceNumber=@InternalReferenceNumber, " + + "aCustomerReferenceNumber=@CustomerReferenceNumber, " + + "aOnsite=@Onsite, aCustomerContactName=@CustomerContactName, " + + "aWorkOrderType=@WorkOrderType, aFormLayoutID=@FormLayoutID, " + + "aSummary=@Summary, aTemplateDescription=@TemplateDescription, aWorkorderCategoryID=@WorkorderCategoryID, " + + " aModifier=@CurrentUserID, " + + " aModified=@Modified, aClosed=@Closed, " + + "aServiceCompleted=@ServiceCompleted, aFromQuoteID=@FromQuoteID, aFromPMID=@FromPMID, aRegionID=@RegionID, " + "ATEMPLATEFRESHPRICE=@TEMPLATEFRESHPRICE " + //case 3132 - "WHERE aID=@ID" - ); + "WHERE aID=@ID" + ); - //Workorder fields - cm.AddInParameter("@ID",DbType.Guid,mID); - cm.AddInParameter("@ClientID",DbType.Guid, mClientID); - cm.AddInParameter("@ProjectID",DbType.Guid, mProjectID); - cm.AddInParameter("@InternalReferenceNumber",DbType.String,mInternalReferenceNumber); - cm.AddInParameter("@CustomerReferenceNumber",DbType.String,mCustomerReferenceNumber); - cm.AddInParameter("@Onsite",DbType.Boolean, mOnsite); - cm.AddInParameter("@CustomerContactName",DbType.String,mCustomerContactName); + //Workorder fields + cm.AddInParameter("@ID", DbType.Guid, mID); + cm.AddInParameter("@ClientID", DbType.Guid, mClientID); + cm.AddInParameter("@ProjectID", DbType.Guid, mProjectID); + cm.AddInParameter("@InternalReferenceNumber", DbType.String, mInternalReferenceNumber); + cm.AddInParameter("@CustomerReferenceNumber", DbType.String, mCustomerReferenceNumber); + cm.AddInParameter("@Onsite", DbType.Boolean, mOnsite); + cm.AddInParameter("@CustomerContactName", DbType.String, mCustomerContactName); //case 58 - cm.AddInParameter("@RegionID",DbType.Guid, mRegionID); - cm.AddInParameter("@Summary",DbType.String,mSummary); + cm.AddInParameter("@RegionID", DbType.Guid, mRegionID); + cm.AddInParameter("@Summary", DbType.String, mSummary); cm.AddInParameter("@TemplateDescription", DbType.String, mTemplateDescription); - cm.AddInParameter("@FormLayoutID",DbType.Guid, mFormLayoutID); - cm.AddInParameter("@WorkorderType",DbType.Int16,(int)mWorkorderType); - cm.AddInParameter("@WorkorderCategoryID",DbType.Guid, mWorkorderCategoryID); - cm.AddInParameter("@ServiceCompleted",DbType.Boolean, mServiceCompleted); - cm.AddInParameter("@Closed",DbType.Boolean, mClosed); - cm.AddInParameter("@FromQuoteID",DbType.Guid, mFromQuoteID); - cm.AddInParameter("@FromPMID",DbType.Guid, mFromPMID); + cm.AddInParameter("@FormLayoutID", DbType.Guid, mFormLayoutID); + cm.AddInParameter("@WorkorderType", DbType.Int16, (int)mWorkorderType); + cm.AddInParameter("@WorkorderCategoryID", DbType.Guid, mWorkorderCategoryID); + cm.AddInParameter("@ServiceCompleted", DbType.Boolean, mServiceCompleted); + cm.AddInParameter("@Closed", DbType.Boolean, mClosed); + cm.AddInParameter("@FromQuoteID", DbType.Guid, mFromQuoteID); + cm.AddInParameter("@FromPMID", DbType.Guid, mFromPMID); //case 3132 cm.AddInParameter("@TEMPLATEFRESHPRICE", DbType.Boolean, mTemplateFreshPrice); - - - //Standard fields - cm.AddInParameter("@CurrentUserID",DbType.Guid, CurrentUserID); - cm.AddInParameter("@Created",DbType.DateTime, DBUtil.ToUTC(mCreated).DBValue); - cm.AddInParameter("@Modified",DbType.DateTime, DBUtil.ToUTC(dtModified)); - - //Custom fields -// cm.AddLargeStringInParameter("@Custom1", mCustom1); -// cm.AddLargeStringInParameter("@Custom2", mCustom2); -// cm.AddLargeStringInParameter("@Custom3", mCustom3); -// cm.AddLargeStringInParameter("@Custom4", mCustom4); -// cm.AddLargeStringInParameter("@Custom5", mCustom5); -// cm.AddLargeStringInParameter("@Custom6", mCustom6); -// cm.AddLargeStringInParameter("@Custom7", mCustom7); -// cm.AddLargeStringInParameter("@Custom8", mCustom8); -// cm.AddLargeStringInParameter("@Custom9", mCustom9); -// cm.AddLargeStringInParameter("@Custom0", mCustom0); - + //Standard fields + cm.AddInParameter("@CurrentUserID", DbType.Guid, CurrentUserID); + cm.AddInParameter("@Created", DbType.DateTime, DBUtil.ToUTC(mCreated).DBValue); + cm.AddInParameter("@Modified", DbType.DateTime, DBUtil.ToUTC(dtModified)); - using (IDbConnection connection = DBUtil.DB.GetConnection()) - { - connection.Open(); - //IDbTransaction transaction = connection.BeginTransaction(); - //Changed to high isolation transaction because an update affects potentially inventory and - //service bank objects - IDbTransaction transaction = connection.BeginTransaction(System.Data.IsolationLevel.Serializable); + //Custom fields + // cm.AddLargeStringInParameter("@Custom1", mCustom1); + // cm.AddLargeStringInParameter("@Custom2", mCustom2); + // cm.AddLargeStringInParameter("@Custom3", mCustom3); + // cm.AddLargeStringInParameter("@Custom4", mCustom4); + // cm.AddLargeStringInParameter("@Custom5", mCustom5); + // cm.AddLargeStringInParameter("@Custom6", mCustom6); + // cm.AddLargeStringInParameter("@Custom7", mCustom7); + // cm.AddLargeStringInParameter("@Custom8", mCustom8); + // cm.AddLargeStringInParameter("@Custom9", mCustom9); + // cm.AddLargeStringInParameter("@Custom0", mCustom0); - try - { - - DBUtil.DB.ExecuteNonQuery(cm, transaction); - - /* - * Update child objects - */ - - switch(this.WorkorderType) - { - case WorkorderTypes.PreventiveMaintenance: + + + + using (IDbConnection connection = DBUtil.DB.GetConnection()) + { + connection.Open(); + //IDbTransaction transaction = connection.BeginTransaction(); + //Changed to high isolation transaction because an update affects potentially inventory and + //service bank objects + IDbTransaction transaction = connection.BeginTransaction(System.Data.IsolationLevel.Serializable); + + try + { + + DBUtil.DB.ExecuteNonQuery(cm, transaction); + + /* + * Update child objects + */ + + switch (this.WorkorderType) + { + case WorkorderTypes.PreventiveMaintenance: case WorkorderTypes.TemplatePreventiveMaintenance: - mWorkorderPreventiveMaintenance.Update(this,transaction); - break; - case WorkorderTypes.Quote: + mWorkorderPreventiveMaintenance.Update(this, transaction); + break; + case WorkorderTypes.Quote: case WorkorderTypes.TemplateQuote: - mQuote.Update(this,transaction); - - break; - case WorkorderTypes.Service: + mQuote.Update(this, transaction); + + break; + case WorkorderTypes.Service: case WorkorderTypes.TemplateService: - mService.Update(this,transaction); - - //Last service date / wo - //only set this if closed - //this prevents a situation where the workorder can not be deleted - //because of the foreign key link to the client lastworkorderid field - //because a closed workorder can not be deleted - if(this.mClosed) - {//unclose - DBCommandWrapper cmLastServiceClient = DBUtil.GetCommandFromSQL( - "UPDATE aClient SET aLastWorkorderID=@WorkorderID, " + - "aLastServiceDate=@LastServiceDate " + - "WHERE aID=@ClientID" - ); - cmLastServiceClient.AddInParameter("@ClientID",DbType.Guid, mClientID); - cmLastServiceClient.AddInParameter("@WorkorderID",DbType.Guid, this.mID); - cmLastServiceClient.AddInParameter("@LastServiceDate",DbType.DateTime, DBUtil.ToUTC(mService.sdServiceDate).DBValue); - DBUtil.DB.ExecuteNonQuery(cmLastServiceClient, transaction); + mService.Update(this, transaction); - foreach(WorkorderItem wi in this.mWorkorderItems) - { - if(wi.UnitID!=Guid.Empty) - {//unclose - DBCommandWrapper cmLastServiceUnit = DBUtil.GetCommandFromSQL( - "UPDATE aUnit SET aLastWorkorderID=@WorkorderID, " + - "aLastServiceDate=@LastServiceDate " + - "WHERE aID=@UnitID" - ); - cmLastServiceUnit.AddInParameter("@UnitID",DbType.Guid, wi.UnitID); - cmLastServiceUnit.AddInParameter("@WorkorderID",DbType.Guid, this.mID); - cmLastServiceUnit.AddInParameter("@LastServiceDate",DbType.DateTime, DBUtil.ToUTC(mService.sdServiceDate).DBValue); - DBUtil.DB.ExecuteNonQuery(cmLastServiceUnit, transaction); + //Last service date / wo + //only set this if closed + //this prevents a situation where the workorder can not be deleted + //because of the foreign key link to the client lastworkorderid field + //because a closed workorder can not be deleted + if (this.mClosed) + {//unclose + DBCommandWrapper cmLastServiceClient = DBUtil.GetCommandFromSQL( + "UPDATE aClient SET aLastWorkorderID=@WorkorderID, " + + "aLastServiceDate=@LastServiceDate " + + "WHERE aID=@ClientID" + ); + cmLastServiceClient.AddInParameter("@ClientID", DbType.Guid, mClientID); + cmLastServiceClient.AddInParameter("@WorkorderID", DbType.Guid, this.mID); + cmLastServiceClient.AddInParameter("@LastServiceDate", DbType.DateTime, DBUtil.ToUTC(mService.sdServiceDate).DBValue); + DBUtil.DB.ExecuteNonQuery(cmLastServiceClient, transaction); + + foreach (WorkorderItem wi in this.mWorkorderItems) + { + if (wi.UnitID != Guid.Empty) + {//unclose + DBCommandWrapper cmLastServiceUnit = DBUtil.GetCommandFromSQL( + "UPDATE aUnit SET aLastWorkorderID=@WorkorderID, " + + "aLastServiceDate=@LastServiceDate " + + "WHERE aID=@UnitID" + ); + cmLastServiceUnit.AddInParameter("@UnitID", DbType.Guid, wi.UnitID); + cmLastServiceUnit.AddInParameter("@WorkorderID", DbType.Guid, this.mID); + cmLastServiceUnit.AddInParameter("@LastServiceDate", DbType.DateTime, DBUtil.ToUTC(mService.sdServiceDate).DBValue); + DBUtil.DB.ExecuteNonQuery(cmLastServiceUnit, transaction); - } - } - } - break; + } + } + } + break; - } - - - //WorkorderItems collection - mWorkorderItems.Update(this,transaction); - - //Docs - mDocs.Update(transaction); + } - //Process keywords - DBUtil.ProcessKeywords(transaction,this.mID,RootObjectTypes.Workorder,IsNew,AyaBizUtils.Break(false, - mInternalReferenceNumber,mCustomerReferenceNumber,mCustomerContactName,mSummary,mTemplateDescription)); + + //WorkorderItems collection + mWorkorderItems.Update(this, transaction); + + //Docs + mDocs.Update(transaction); + + //Process keywords + DBUtil.ProcessKeywords(transaction, this.mID, RootObjectTypes.Workorder, IsNew, AyaBizUtils.Break(false, + mInternalReferenceNumber, mCustomerReferenceNumber, mCustomerContactName, mSummary, mTemplateDescription)); //case 53 bWasNew = IsNew; - MarkOld();//db is now synched with object + MarkOld();//db is now synched with object - // Commit the transaction - transaction.Commit(); + // Commit the transaction + transaction.Commit(); - - } - catch - { - // Rollback transaction - transaction.Rollback(); - throw ; - } - finally - { - connection.Close(); - } - //Successful update so - //change modification time to match + + } + catch + { + // Rollback transaction + transaction.Rollback(); + throw; + } + finally + { + connection.Close(); + } + //Successful update so + //change modification time to match this.mModified.Date = dtModified; switch (mWorkorderType) { case WorkorderTypes.Service: - if(AyaBizUtils.AllowAutomaticMRUOnUpdate) AyaBizUtils.MRU.Add(RootObjectTypes.Workorder, mID); + if (AyaBizUtils.AllowAutomaticMRUOnUpdate) AyaBizUtils.MRU.Add(RootObjectTypes.Workorder, mID); break; case WorkorderTypes.Quote: - if(AyaBizUtils.AllowAutomaticMRUOnUpdate) AyaBizUtils.MRU.Add(RootObjectTypes.WorkorderQuote, WorkorderQuote.ID); + if (AyaBizUtils.AllowAutomaticMRUOnUpdate) AyaBizUtils.MRU.Add(RootObjectTypes.WorkorderQuote, WorkorderQuote.ID); break; case WorkorderTypes.PreventiveMaintenance: - if(AyaBizUtils.AllowAutomaticMRUOnUpdate) AyaBizUtils.MRU.Add(RootObjectTypes.WorkorderPreventiveMaintenance, WorkorderPreventiveMaintenance.ID); + if (AyaBizUtils.AllowAutomaticMRUOnUpdate) AyaBizUtils.MRU.Add(RootObjectTypes.WorkorderPreventiveMaintenance, WorkorderPreventiveMaintenance.ID); break; case WorkorderTypes.TemplateService: - if(AyaBizUtils.AllowAutomaticMRUOnUpdate) AyaBizUtils.MRU.Add(RootObjectTypes.WorkorderServiceTemplate, ID); + if (AyaBizUtils.AllowAutomaticMRUOnUpdate) AyaBizUtils.MRU.Add(RootObjectTypes.WorkorderServiceTemplate, ID); break; case WorkorderTypes.TemplateQuote: - if(AyaBizUtils.AllowAutomaticMRUOnUpdate) AyaBizUtils.MRU.Add(RootObjectTypes.WorkorderQuoteTemplate, WorkorderQuote.ID); + if (AyaBizUtils.AllowAutomaticMRUOnUpdate) AyaBizUtils.MRU.Add(RootObjectTypes.WorkorderQuoteTemplate, WorkorderQuote.ID); break; case WorkorderTypes.TemplatePreventiveMaintenance: - if(AyaBizUtils.AllowAutomaticMRUOnUpdate) AyaBizUtils.MRU.Add(RootObjectTypes.WorkorderPreventiveMaintenanceTemplate, WorkorderPreventiveMaintenance.ID); + if (AyaBizUtils.AllowAutomaticMRUOnUpdate) AyaBizUtils.MRU.Add(RootObjectTypes.WorkorderPreventiveMaintenanceTemplate, WorkorderPreventiveMaintenance.ID); break; } if (this.Closed) ClientServiceRequest.CloseFlag(this.mID); - #region Process events - //Process events as necessary + #region Process events + //Process events as necessary if (AyaBizUtils.GlobalSettings.UseNotification)//Case 510 { #region Service type workorder notification events - if (mWorkorderType==WorkorderTypes.Service && this.mService!=null) - { - //there are three types of events that might be of interest + if (mWorkorderType == WorkorderTypes.Service && this.mService != null) + { + //there are three types of events that might be of interest //Case 53 new event of interest - workorder created if (bWasNew) { - ClientNotifyEvent.ProcessEvent(ClientNotifyEventType.NewWorkorder, mClientID, mService.WorkorderStatusID, + ClientNotifyEvent.ProcessEvent(ClientNotifyEventType.NewWorkorder, mClientID, mService.WorkorderStatusID, mService.ServiceNumber.ToString(), - mCustomerContactName,mCustomerReferenceNumber,"",mID,mSummary,""); + mCustomerContactName, mCustomerReferenceNumber, "", mID, mSummary, ""); } - //Has the status changed? - if(mService.mStatusSignificant) - { - NotifyEvent.AddOrUpdateEvent(RootObjectTypes.Workorder,this.mID,(int)WorkorderEvent.Status,Guid.Empty,new SmartDate(),mService.WorkorderStatusID); - - ClientNotifyEvent.ProcessEvent(ClientNotifyEventType.WorkorderStatusSet, mClientID, mService.WorkorderStatusID, + //Has the status changed? + if (mService.mStatusSignificant) + { + NotifyEvent.AddOrUpdateEvent(RootObjectTypes.Workorder, this.mID, (int)WorkorderEvent.Status, Guid.Empty, new SmartDate(), mService.WorkorderStatusID); + + ClientNotifyEvent.ProcessEvent(ClientNotifyEventType.WorkorderStatusSet, mClientID, mService.WorkorderStatusID, mService.ServiceNumber.ToString(), mCustomerContactName, mCustomerReferenceNumber, "", mID, mSummary, ""); //case 1879 - multiple events showing up on repeated save of same workorder edit session mService.mStatusSignificant = false; - } - - //Has it been closed? - if(Closed) - { - //Yes, so - //remove close by events if present - //This is ok even if it's passed and closed later - //because they would have got the notice about it being passed - //so in any case we want the event gone - NotifyEvent.RemoveSpecificEventForObject(mID,(int)WorkorderEvent.CloseByDatePassed); + } + + //Has it been closed? + if (Closed) + { + //Yes, so + //remove close by events if present + //This is ok even if it's passed and closed later + //because they would have got the notice about it being passed + //so in any case we want the event gone + NotifyEvent.RemoveSpecificEventForObject(mID, (int)WorkorderEvent.CloseByDatePassed); //Workorder is closed adn we're in the upate method so clearly it was open and has now just been closed and saved //since a closed workorder can not be updated //case 53 //unclose - ClientNotifyEvent.ProcessEvent(ClientNotifyEventType.WorkorderClosed, mClientID, mService.WorkorderStatusID, + ClientNotifyEvent.ProcessEvent(ClientNotifyEventType.WorkorderClosed, mClientID, mService.WorkorderStatusID, mService.ServiceNumber.ToString(), mCustomerContactName, mCustomerReferenceNumber, "", mID, mSummary, ""); - ClientNotifyEvent.ProcessEvent(ClientNotifyEventType.WorkorderFollowUp, mClientID, mService.WorkorderStatusID, + ClientNotifyEvent.ProcessEvent(ClientNotifyEventType.WorkorderFollowUp, mClientID, mService.WorkorderStatusID, mService.ServiceNumber.ToString(), mCustomerContactName, mCustomerReferenceNumber, "", mID, mSummary, ""); - - } - else - { - //Nope,so set the close by date event if significant (changed) - if(mService.mCloseByDateSignificant) - { - //Check if user set it to empty, - //in which case we don't want any event for this - if(mService.sdCloseByDate.IsEmpty) - NotifyEvent.RemoveSpecificEventForObject(mID,(int)WorkorderEvent.CloseByDatePassed); - else - NotifyEvent.AddOrUpdateEvent(RootObjectTypes.Workorder,this.mID,(int)WorkorderEvent.CloseByDatePassed,Guid.Empty,mService.sdCloseByDate,Guid.Empty); - } - } + } + else + { + //Nope,so set the close by date event if significant (changed) + if (mService.mCloseByDateSignificant) + { + //Check if user set it to empty, + //in which case we don't want any event for this + if (mService.sdCloseByDate.IsEmpty) + NotifyEvent.RemoveSpecificEventForObject(mID, (int)WorkorderEvent.CloseByDatePassed); + else + NotifyEvent.AddOrUpdateEvent(RootObjectTypes.Workorder, this.mID, (int)WorkorderEvent.CloseByDatePassed, Guid.Empty, mService.sdCloseByDate, Guid.Empty); + + } + } } @@ -5441,11 +5446,11 @@ namespace GZTW.AyaNova.BLL #region Quote type workorder notification events if (mWorkorderType == WorkorderTypes.Quote && this.mQuote != null) - { + { //Has the status changed? if (mQuote.mStatusSignificant) { - + ClientNotifyEvent.ProcessEvent(ClientNotifyEventType.QuoteStatusSet, mClientID, Guid.Empty, mQuote.QuoteNumber.ToString(), mCustomerContactName, mCustomerReferenceNumber, "", mID, mSummary, "", mQuote.QuoteStatus); } @@ -5454,7 +5459,7 @@ namespace GZTW.AyaNova.BLL //case 1555 //User quote updated notification NotifyEvent.AddOrUpdateEvent(RootObjectTypes.Workorder, this.mID, (int)WorkorderEvent.QuoteUpdated); - + //case 2090 to be added here:? //notification when quote is approved X days after @@ -5462,148 +5467,148 @@ namespace GZTW.AyaNova.BLL #endregion Quote workorder notification processor } - #endregion - } + #endregion + } - #endregion + #endregion - } - #endregion update - - #endregion + } + #endregion update - #region Override IsValid / IsDirty - //Override base class version if there are child objects - /// - /// - /// - public override bool IsValid - { - get - { - - switch(this.WorkorderType) - { - case WorkorderTypes.PreventiveMaintenance: - case WorkorderTypes.TemplatePreventiveMaintenance: - return base.IsValid && mWorkorderPreventiveMaintenance.IsValid && - mWorkorderItems.IsValid && mDocs.IsValid; - case WorkorderTypes.Quote: - case WorkorderTypes.TemplateQuote: - return base.IsValid && mQuote.IsValid && - mWorkorderItems.IsValid && mDocs.IsValid; - case WorkorderTypes.Service: - case WorkorderTypes.TemplateService: - return base.IsValid && mService.IsValid && - mWorkorderItems.IsValid && mDocs.IsValid; + #endregion - } - return false; - - } - } + #region Override IsValid / IsDirty + //Override base class version if there are child objects /// /// /// - public override bool IsDirty - { - get - { - switch(this.WorkorderType) - { - case WorkorderTypes.PreventiveMaintenance: - case WorkorderTypes.TemplatePreventiveMaintenance: - return base.IsDirty || - mWorkorderPreventiveMaintenance.IsDirty || - mWorkorderItems.IsDirty || mDocs.IsDirty; - case WorkorderTypes.Quote: - case WorkorderTypes.TemplateQuote: - return base.IsDirty || mQuote.IsDirty || - mWorkorderItems.IsDirty || mDocs.IsDirty; - case WorkorderTypes.Service: - case WorkorderTypes.TemplateService: - return base.IsDirty || mService.IsDirty || - mWorkorderItems.IsDirty || mDocs.IsDirty; + public override bool IsValid + { + get + { - } - return false; + switch (this.WorkorderType) + { + case WorkorderTypes.PreventiveMaintenance: + case WorkorderTypes.TemplatePreventiveMaintenance: + return base.IsValid && mWorkorderPreventiveMaintenance.IsValid && + mWorkorderItems.IsValid && mDocs.IsValid; + case WorkorderTypes.Quote: + case WorkorderTypes.TemplateQuote: + return base.IsValid && mQuote.IsValid && + mWorkorderItems.IsValid && mDocs.IsValid; + case WorkorderTypes.Service: + case WorkorderTypes.TemplateService: + return base.IsValid && mService.IsValid && + mWorkorderItems.IsValid && mDocs.IsValid; - - } - } - - #endregion + } + return false; - #region criteria - /// - /// Criteria for identifying existing object - /// - [Serializable] - private class Criteria - { - public bool TrackMRU; - public Guid ID; - public RootObjectTypes RootObjectType; - public Criteria(RootObjectTypes _RootObjectType, Guid _ID, bool _TrackMRU) - { - ID=_ID; - RootObjectType=_RootObjectType; + } + } + /// + /// + /// + public override bool IsDirty + { + get + { + switch (this.WorkorderType) + { + case WorkorderTypes.PreventiveMaintenance: + case WorkorderTypes.TemplatePreventiveMaintenance: + return base.IsDirty || + mWorkorderPreventiveMaintenance.IsDirty || + mWorkorderItems.IsDirty || mDocs.IsDirty; + case WorkorderTypes.Quote: + case WorkorderTypes.TemplateQuote: + return base.IsDirty || mQuote.IsDirty || + mWorkorderItems.IsDirty || mDocs.IsDirty; + case WorkorderTypes.Service: + case WorkorderTypes.TemplateService: + return base.IsDirty || mService.IsDirty || + mWorkorderItems.IsDirty || mDocs.IsDirty; + + } + return false; + + + } + } + + #endregion + + #region criteria + /// + /// Criteria for identifying existing object + /// + [Serializable] + private class Criteria + { + public bool TrackMRU; + public Guid ID; + public RootObjectTypes RootObjectType; + public Criteria(RootObjectTypes _RootObjectType, Guid _ID, bool _TrackMRU) + { + ID = _ID; + RootObjectType = _RootObjectType; TrackMRU = _TrackMRU; - } - - } - #endregion + } - #region Move WorkorderItem + } + #endregion + + #region Move WorkorderItem #pragma warning disable 1591 /// - /// Move a workorder item to a new workorder - /// - [Serializable, System.ComponentModel.Browsable(false)] - public class WorkorderItemMover//DO_NOT_OBFUSCATE - { - Guid _ToWorkorderID; - Guid _FromWorkorderID; - Guid _WorkorderItemID; + /// Move a workorder item to a new workorder + /// + [Serializable, System.ComponentModel.Browsable(false)] + public class WorkorderItemMover//DO_NOT_OBFUSCATE + { + Guid _ToWorkorderID; + Guid _FromWorkorderID; + Guid _WorkorderItemID; /// /// /// /// /// /// - public WorkorderItemMover(Guid FromWorkorderID, Guid ToWorkorderID, Guid WorkorderItemID) - { - _FromWorkorderID=FromWorkorderID; - _ToWorkorderID= ToWorkorderID; - _WorkorderItemID= WorkorderItemID; - } + public WorkorderItemMover(Guid FromWorkorderID, Guid ToWorkorderID, Guid WorkorderItemID) + { + _FromWorkorderID = FromWorkorderID; + _ToWorkorderID = ToWorkorderID; + _WorkorderItemID = WorkorderItemID; + } - public static void Move(Guid FromWorkorderID, Guid ToWorkorderID, Guid WorkorderItemID) - { - DataPortal.Update(new WorkorderItemMover( FromWorkorderID, ToWorkorderID, WorkorderItemID)); - } + public static void Move(Guid FromWorkorderID, Guid ToWorkorderID, Guid WorkorderItemID) + { + DataPortal.Update(new WorkorderItemMover(FromWorkorderID, ToWorkorderID, WorkorderItemID)); + } - public void DataPortal_Update() - { - DBCommandWrapper cm = null; - - cm=DBUtil.GetCommandFromSQL( - "UPDATE aWorkorderItem SET aWorkorderID=@ToWorkorderID " + - "WHERE aWorkorderID=@FromWorkorderID AND aID=@WorkorderItemID" - ); + public void DataPortal_Update() + { + DBCommandWrapper cm = null; - cm.AddInParameter("@FromWorkorderID",DbType.Guid,_FromWorkorderID); - cm.AddInParameter("@ToWorkorderID",DbType.Guid,_ToWorkorderID); - cm.AddInParameter("@WorkorderItemID",DbType.Guid,_WorkorderItemID); - - DBUtil.DB.ExecuteNonQuery(cm); + cm = DBUtil.GetCommandFromSQL( + "UPDATE aWorkorderItem SET aWorkorderID=@ToWorkorderID " + + "WHERE aWorkorderID=@FromWorkorderID AND aID=@WorkorderItemID" + ); - - } + cm.AddInParameter("@FromWorkorderID", DbType.Guid, _FromWorkorderID); + cm.AddInParameter("@ToWorkorderID", DbType.Guid, _ToWorkorderID); + cm.AddInParameter("@WorkorderItemID", DbType.Guid, _WorkorderItemID); - } - #endregion move workorder item + DBUtil.DB.ExecuteNonQuery(cm); + + + } + + } + #endregion move workorder item #region Re-open workorder /// @@ -5618,12 +5623,12 @@ namespace GZTW.AyaNova.BLL /// [Serializable, System.ComponentModel.Browsable(false)] public class WorkorderReopener//DO_NOT_OBFUSCATE - { - Guid _WorkorderID; + { + Guid _WorkorderID; public WorkorderReopener(Guid WorkorderID) { - _WorkorderID = WorkorderID; + _WorkorderID = WorkorderID; } public static void Open(Guid WorkorderID) @@ -5667,31 +5672,33 @@ namespace GZTW.AyaNova.BLL DBUtil.DB.ExecuteNonQuery(cm); NotifyEvent.RemoveAllEventsForObject(_WorkorderID); - + } } #endregion reopen workorder #pragma warning restore 1591 - }//end Workorder + }//end Workorder - #region Notification events + #region Notification events /// /// /// - public enum WorkorderEvent : int - { - /// - /// Status changed on service workorder - /// - [Description("LT:Workorder.Label.Event.Status")] Status=1, - //CloseByDatePassed *is* a dated event, but it's not user selectable - //so that's why the enumeration value is 2 instead of 256. + public enum WorkorderEvent : int + { + /// + /// Status changed on service workorder + /// + [Description("LT:Workorder.Label.Event.Status")] + Status = 1, + //CloseByDatePassed *is* a dated event, but it's not user selectable + //so that's why the enumeration value is 2 instead of 256. /// /// Close by date passed on service workorder /// - [Description("LT:Workorder.Label.Event.CloseByDatePassed")] CloseByDatePassed=2, + [Description("LT:Workorder.Label.Event.CloseByDatePassed")] + CloseByDatePassed = 2, /// /// Quote updated event /// @@ -5699,7 +5706,7 @@ namespace GZTW.AyaNova.BLL QuoteUpdated = 3 - } + } - #endregion + #endregion }//end namespace GZTW.AyaNova.BLL \ No newline at end of file diff --git a/source/bizobjects/AyaLib/GZTW.AyaNova.BLL/WorkorderTypeFetcher.cs b/source/bizobjects/AyaLib/GZTW.AyaNova.BLL/WorkorderTypeFetcher.cs index 327eed0..0f8487e 100644 --- a/source/bizobjects/AyaLib/GZTW.AyaNova.BLL/WorkorderTypeFetcher.cs +++ b/source/bizobjects/AyaLib/GZTW.AyaNova.BLL/WorkorderTypeFetcher.cs @@ -28,7 +28,7 @@ namespace GZTW.AyaNova.BLL { #region Attributes - private WorkorderTypes mType= WorkorderTypes.Unknown; + private WorkorderTypes mType = WorkorderTypes.Unknown; #endregion #region Constructor @@ -57,7 +57,7 @@ namespace GZTW.AyaNova.BLL return ((WorkorderTypeFetcher)DataPortal.Fetch(new Criteria(WorkorderID))).mType; } - + #endregion @@ -67,7 +67,16 @@ namespace GZTW.AyaNova.BLL /// protected override void DataPortal_Fetch(object Criteria) { + Criteria crit = (Criteria)Criteria; + + //case 3626 + if (crit.WorkorderID == Guid.Empty) + { + mType = WorkorderTypes.Unknown; + return; + } + SafeDataReader dr = null; dr = DBUtil.GetReaderFromSQLString( @@ -99,10 +108,10 @@ namespace GZTW.AyaNova.BLL { public Guid WorkorderID; - + public Criteria(Guid _WorkorderID) { - WorkorderID = _WorkorderID; + WorkorderID = _WorkorderID; } }