1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
|
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.Data.OleDb
Imports Aspose.Slides
Imports Aspose.Slides.Pptx
Imports Aspose.Chart
Namespace Aspose.Slides.Northwind
Partial Public Class [Default]
Inherits System.Web.UI.Page
Private cn As OleDbConnection = Nothing
Private pres As Presentation = Nothing
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
If (Not Page.IsPostBack) Then
' Open the database connection
openDBConnection()
Dim selectString As String = "SELECT Distinct City FROM Employees"
' Create an OleDbCommand object
Dim cmd As New OleDbCommand(selectString, cn)
' Send the CommandText to the connection, and then build an OleDbDataReader
Dim reader As OleDbDataReader = cmd.ExecuteReader()
ddlEmployeeLocation.DataSource = reader
ddlEmployeeLocation.DataTextField = "City"
ddlEmployeeLocation.DataValueField = "City"
ddlEmployeeLocation.DataBind()
' Close the database connection
closeDBConnection()
End If
End Sub
Private Sub openDBConnection()
' Use a string variable to hold the ConnectionString
Dim connectString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & MapPath(".") & "\db\NorthWind.MDB"
' Create an OleDbConnection object,
cn = New OleDbConnection(connectString)
' Open the connection
cn.Open()
End Sub
Private Sub closeDBConnection()
' Close the connection
cn.Close()
End Sub
Private Function setupSlideMaster(ByVal pres As Presentation) As Presentation
' Get slide master
Dim slide As Slide = pres.Masters(0)
' Set slide master propertires
slide.Background.FillFormat.Type = FillType.Gradient
slide.Background.FillFormat.GradientColorType = GradientColorType.TwoColors
slide.Background.FillFormat.ForeColor = Color.Beige
slide.Background.FillFormat.BackColor = Color.DodgerBlue
Return pres
End Function
Protected Sub btnGenPres_Click(ByVal sender As Object, ByVal e As EventArgs)
' Open the database connection
openDBConnection()
' Set location of presentation file.
Dim fileName As String = MapPath(".") & "\template\demo.ppt"
' Create presentation object from presentation file
pres = New Presentation(fileName)
' Set SlideMaster Properties
pres = setupSlideMaster(pres)
' Get references to slides in presentation by position
Dim slide1 As Slide = pres.GetSlideByPosition(1)
Dim slide2 As Slide = pres.GetSlideByPosition(2)
' Create a clone of slide2 and place it into position 3
pres.CloneSlide(slide2, 3)
Dim slide3 As Slide = pres.GetSlideByPosition(3)
Dim slide4 As Slide = pres.GetSlideByPosition(4)
Dim slide5 As Slide = pres.GetSlideByPosition(5)
Dim slide6 As Slide = pres.GetSlideByPosition(6)
Dim slide7 As Slide = pres.GetSlideByPosition(7)
Dim slide8 As Slide = pres.GetSlideByPosition(8)
' I have created methods for each slide to help seprate out the code
slide1 = Me.Slide1(slide1)
slide2 = Me.Slide2(slide2)
slide3 = Me.Slide3(slide3)
slide4 = Me.Slide4(slide4)
slide5 = Me.Slide5(slide5)
slide6 = Me.Slide6(slide6)
slide7 = Me.Slide7(slide7)
slide8 = Me.Slide8(slide8)
pres.CloneSlide(slide1, 9)
Dim slide9 As Slide = pres.GetSlideByPosition(9)
slide9 = Me.Slide9(slide9)
' Close the database connection
closeDBConnection()
' Construct the response to be sent back to the web browser
If rblFileExportType.SelectedItem.Text = "PPT" Then
' Send the file
pres.Save("demoppt.ppt",Aspose.Slides.Export.SaveFormat.Ppt,Response,False)
Response.End()
ElseIf rblFileExportType.SelectedItem.Text = "PDF" Then
' Send the file
pres.Save("demopdf.pdf", Aspose.Slides.Export.SaveFormat.Pdf, Response, False)
Response.End()
End If
End Sub
'INSTANT VB NOTE: The parameter slide1 was renamed since Visual Basic will not allow parameters with the same name as their enclosing function or property:
Private Function Slide1(ByVal slide1_Renamed As Slide) As Slide
' Introduction
For j As Integer = 0 To slide1_Renamed.Shapes.Count - 1
Dim shape As Shape = slide1_Renamed.Shapes(j)
If shape.TextFrame IsNot Nothing Then
Dim tf As TextFrame = shape.TextFrame
Dim para As Paragraph = tf.Paragraphs(0)
If para.Text = "Presenter�s Name" Then
para.Alignment = TextAlignment.Center
For Each port As Portion In para.Portions
port.FontBold = False
port.FontColor = Color.Black
port.FontEmbossed = False
port.FontItalic = False
port.FontShadow = False
port.FontUnderline = False
port.FontHeight = 30
port.Text = "Presented By: " & txtPresenterName.Text
Next port
ElseIf para.Text = "HyperLink" Then
para.Alignment = TextAlignment.Left
For Each port As Portion In para.Portions
port.FontHeight = 20
port.Text = txtCompanyWebSite.Text
tf.Links.Clear()
Dim link As Link = tf.Links.AddLink()
link.SetInternalHyperlink(slide1_Renamed)
link.Begin = 0
link.End = tf.Text.Length
Next port
End If
End If
Next j
' Create Shape to Hold Business Info
Dim shape1 As Shape = slide1_Renamed.Shapes.AddRectangle(1550, 300, 2700, 1200)
' Set Shape Properties
shape1.FillFormat.Type = FillType.Solid
shape1.FillFormat.ForeColor = Color.BlanchedAlmond
shape1.LineFormat.ForeColor = Color.Black
shape1.LineFormat.Width = 3
shape1.FillFormat.Type = FillType.Texture
shape1.FillFormat.SetTextureStyle(TextureStyle.Newsprint)
' Add Transition Effects
shape1.AnimationSettings.EntryEffect = ShapeEntryEffect.StretchAcross
' Add A TextFrame to the Shape
shape1.AddTextFrame("Shape1")
If shape1.TextFrame IsNot Nothing Then
Dim tfsh1 As TextFrame = shape1.TextFrame
Dim parash1 As Paragraph = tfsh1.Paragraphs(0)
parash1.Alignment = TextAlignment.Center
For Each port As Portion In parash1.Portions
port.FontBold = False
port.FontColor = Color.DodgerBlue
port.FontEmbossed = False
port.FontItalic = False
port.FontShadow = True
port.FontUnderline = False
port.FontHeight = 30
port.Text = txtCompanyName.Text
Next port
' Add second paragraph to the shape
tfsh1.Paragraphs.Add(New Paragraph(tfsh1.Paragraphs(0)))
Dim para2sh1 As Paragraph = tfsh1.Paragraphs(1)
For Each port As Portion In para2sh1.Portions
port.FontBold = False
port.FontColor = Color.DodgerBlue
port.FontEmbossed = False
port.FontItalic = False
port.FontShadow = True
port.FontUnderline = False
port.FontHeight = 30
port.Text = txtCompanyAddress.Text
Next port
' Add third paragraph to the shape
tfsh1.Paragraphs.Add(New Paragraph(tfsh1.Paragraphs(0)))
Dim para3sh1 As Paragraph = tfsh1.Paragraphs(2)
For Each port As Portion In para3sh1.Portions
port.FontBold = False
port.FontColor = Color.DodgerBlue
port.FontEmbossed = False
port.FontItalic = False
port.FontShadow = True
port.FontUnderline = False
port.FontHeight = 30
port.Text = txtCompanyCity.Text & ", " & txtCompanyState.Text & " " & txtCompanyZip.Text
Next port
End If
' Add Slide Transition Effect
slide1_Renamed.SlideShowTransition.EntryEffect = SlideTransitionEffect.FadeSmoothly
Return slide1_Renamed
End Function
'INSTANT VB NOTE: The parameter slide2 was renamed since Visual Basic will not allow parameters with the same name as their enclosing function or property:
Private Function Slide2(ByVal slide2_Renamed As Slide) As Slide
' Employee Directory
For j As Integer = 0 To slide2_Renamed.Shapes.Count - 1
Dim shape As Shape = slide2_Renamed.Shapes(j)
If shape.TextFrame IsNot Nothing Then
Dim tf As TextFrame = shape.TextFrame
If tf.Paragraphs.Count <> 0 Then
Dim para As Paragraph = tf.Paragraphs(0)
If para.Text = "Subtitle" Then
para.Alignment = TextAlignment.Center
For Each port As Portion In para.Portions
port.FontBold = False
port.FontColor = Color.Black
port.FontEmbossed = False
port.FontItalic = False
port.FontShadow = False
port.FontUnderline = False
port.FontHeight = 30
port.Text = "Location: " & ddlEmployeeLocation.SelectedItem.ToString()
Next port
ElseIf para.Text = "CH1" Then
para.Alignment = TextAlignment.Center
For Each port As Portion In para.Portions
port.FontBold = True
port.FontColor = Color.Black
port.FontEmbossed = False
port.FontItalic = False
port.FontShadow = False
port.FontUnderline = False
port.FontHeight = 20
port.Text = "Name"
Next port
ElseIf para.Text = "CH2" Then
para.Alignment = TextAlignment.Center
For Each port As Portion In para.Portions
port.FontBold = True
port.FontColor = Color.Black
port.FontEmbossed = False
port.FontItalic = False
port.FontShadow = False
port.FontUnderline = False
port.FontHeight = 20
port.Text = "Phone Number"
Next port
End If
End If
End If
Next j
' Find table
Dim table As Table = Nothing
For i As Integer = 0 To slide2_Renamed.Shapes.Count - 1
If TypeOf slide2_Renamed.Shapes(i) Is Table Then
table = CType(slide2_Renamed.Shapes(i), Table)
Exit For
End If
Next i
If table IsNot Nothing Then
Dim selectString As String = "SELECT count(*) FROM Employees where City='" & ddlEmployeeLocation.SelectedItem.Text & "'"
' Create an OleDbCommand object
Dim cmd As New OleDbCommand(selectString, cn)
' Send the CommandText to the connection, and then build an OleDbDataReader
Dim reader As OleDbDataReader = cmd.ExecuteReader()
reader.Read()
Dim recordCount As Integer = CInt(Fix(reader.GetValue(0)))
reader.Close()
selectString = "SELECT top 7 LastName, FirstName,HomePhone FROM Employees where " & "City='" & ddlEmployeeLocation.SelectedItem.Text & "' order by LastName"
' Create an OleDbCommand object
cmd = New OleDbCommand(selectString, cn)
' Send the CommandText to the connection, and then build an OleDbDataReader
reader = cmd.ExecuteReader()
' Make table contain correct number of rows
If recordCount = 1 Then
table.DeleteRow(table.RowsNumber - 1)
Else
For i As Integer = 2 To recordCount - 1
table.AddRow()
Next i
End If
Dim count As Integer = 0
Do While reader.Read()
Dim tfName As TextFrame = table.GetCell(0, count).TextFrame
Dim tfPhoneNumber As TextFrame = table.GetCell(1, count).TextFrame
If tfName IsNot Nothing Then
tfName.Paragraphs(0).Portions(0).Text = reader("LastName").ToString() & ", " & reader("FirstName").ToString()
tfPhoneNumber.Paragraphs(0).Portions(0).Text = reader("HomePhone").ToString()
' Left justify first column
tfName.Paragraphs(0).Alignment = TextAlignment.Left
' Center justify second column
tfPhoneNumber.Paragraphs(0).Alignment = TextAlignment.Center
' Disable default bullets
tfName.Paragraphs(0).HasBullet = False
tfPhoneNumber.Paragraphs(0).HasBullet = False
' Set Font Color
tfName.Paragraphs(0).Portions(0).FontColor = Color.Crimson
tfPhoneNumber.Paragraphs(0).Portions(0).FontColor = Color.FromArgb(51, 153, 102)
End If
count += 1
Loop
reader.Close()
End If
' Add entry effect to the table
table.AnimationSettings.EntryEffect = ShapeEntryEffect.Spiral
' Add Slide Transition Effect
slide2_Renamed.SlideShowTransition.EntryEffect = SlideTransitionEffect.SplitVerticalOut
Return slide2_Renamed
End Function
'INSTANT VB NOTE: The parameter slide3 was renamed since Visual Basic will not allow parameters with the same name as their enclosing function or property:
Private Function Slide3(ByVal slide3_Renamed As Slide) As Slide
' Top 5 Employees for the year
For j As Integer = 0 To slide3_Renamed.Shapes.Count - 1
Dim holder As Placeholder = slide3_Renamed.Placeholders(j)
If TypeOf holder Is TextHolder Then
For Each para As Paragraph In (CType(holder, TextHolder)).Paragraphs
If para.Text = "Employee Directory" Then
para.Alignment = TextAlignment.Default
para.Depth = 0
para.HasBullet = False
For Each port As Portion In para.Portions
port.FontBold = False
port.FontColor = Color.Black
port.FontEmbossed = False
port.FontItalic = False
port.FontShadow = False
port.FontUnderline = False
port.Text = "Top 5 Employees for " & ddlReportingYear.SelectedItem.ToString()
Next port
End If
Next para
End If
Dim shape As Shape = slide3_Renamed.Shapes(j)
If shape.TextFrame IsNot Nothing Then
Dim tf As TextFrame = shape.TextFrame
If tf.Paragraphs.Count <> 0 Then
Dim para As Paragraph = tf.Paragraphs(0)
If para.Text = "Subtitle" Then
para.Alignment = TextAlignment.Center
For Each port As Portion In para.Portions
port.FontBold = False
port.FontColor = Color.Black
port.FontEmbossed = False
port.FontItalic = False
port.FontShadow = False
port.FontUnderline = False
port.FontHeight = 30
port.Text = "Ranked by Order Volume"
Next port
ElseIf para.Text = "CH1" Then
para.Alignment = TextAlignment.Center
For Each port As Portion In para.Portions
port.FontBold = True
port.FontColor = Color.Black
port.FontEmbossed = False
port.FontItalic = False
port.FontShadow = False
port.FontUnderline = False
port.FontHeight = 20
port.Text = "Name"
Next port
ElseIf para.Text = "CH2" Then
para.Alignment = TextAlignment.Center
For Each port As Portion In para.Portions
port.FontBold = True
port.FontColor = Color.Black
port.FontEmbossed = False
port.FontItalic = False
port.FontShadow = False
port.FontUnderline = False
port.FontHeight = 20
port.Text = "Order Volume"
Next port
End If
End If
End If
Next j
' Find table
Dim table As Table = Nothing
For i As Integer = 0 To slide3_Renamed.Shapes.Count - 1
If TypeOf slide3_Renamed.Shapes(i) Is Table Then
table = CType(slide3_Renamed.Shapes(i), Table)
Exit For
End If
Next i
If table IsNot Nothing Then
Dim selectString As String = "SELECT top 5 LastName, FirstName, count(Orders.OrderID) as numOrders " & "FROM Employees INNER JOIN Orders ON Employees.EmployeeID = Orders.EmployeeID " & "WHERE Orders.OrderDate > #01-01-" & ddlReportingYear.SelectedItem.ToString() & "# " & "and Orders.OrderDate < #12-31-" & ddlReportingYear.SelectedItem.ToString() & "# " & "Group by LastName, FirstName " & "order by count(Orders.OrderID) desc"
' Create an OleDbCommand object
Dim cmd As New OleDbCommand(selectString, cn)
' Send the CommandText to the connection, and then build an OleDbDataReader
Dim reader As OleDbDataReader = cmd.ExecuteReader()
' Make table contain correct number of rows
For i As Integer = 2 To 4
table.AddRow()
Next i
Dim count As Integer = 0
Do While reader.Read()
Dim tfName As TextFrame = table.GetCell(0, count).TextFrame
Dim tfPhoneNumber As TextFrame = table.GetCell(1, count).TextFrame
If tfName IsNot Nothing Then
tfName.Paragraphs(0).Portions(0).Text = reader("LastName").ToString() & ", " & reader("FirstName").ToString()
tfPhoneNumber.Paragraphs(0).Portions(0).Text = reader("numOrders").ToString()
' Left justify first column
tfName.Paragraphs(0).Alignment = TextAlignment.Left
' Center justify second column
tfPhoneNumber.Paragraphs(0).Alignment = TextAlignment.Center
' Disable default bullets
tfName.Paragraphs(0).HasBullet = False
tfPhoneNumber.Paragraphs(0).HasBullet = False
' Set Font Color
tfName.Paragraphs(0).Portions(0).FontColor = Color.Crimson
tfPhoneNumber.Paragraphs(0).Portions(0).FontColor = Color.FromArgb(51, 153, 102)
End If
count += 1
Loop
reader.Close()
' Add entry effect to the table
table.AnimationSettings.EntryEffect = ShapeEntryEffect.Spiral
End If
' Add Slide Transition Effect
slide3_Renamed.SlideShowTransition.EntryEffect = SlideTransitionEffect.WipeRight
Return slide3_Renamed
End Function
'INSTANT VB NOTE: The parameter slide4 was renamed since Visual Basic will not allow parameters with the same name as their enclosing function or property:
Private Function Slide4(ByVal slide4_Renamed As Slide) As Slide
' Employee of the Year
Dim selectString As String = "SELECT count(*) FROM Employees"
' Create an OleDbCommand object
Dim cmd As New OleDbCommand(selectString, cn)
' Send the CommandText to the connection, and then build an OleDbDataReader
Dim reader As OleDbDataReader = cmd.ExecuteReader()
reader.Read()
Dim recordCount As Integer = CInt(Fix(reader.GetValue(0)))
reader.Close()
selectString = "SELECT LastName, FirstName, Title, City FROM Employees"
' Create an OleDbCommand object
cmd = New OleDbCommand(selectString, cn)
' Send the CommandText to the connection, and then build an OleDbDataReader
reader = cmd.ExecuteReader()
Dim LastName As String = "", FirstName As String = "", Title As String = "", City As String = ""
Dim objRand As New Random()
' Get a random employee
Do While City = ""
Dim intRand As Integer = objRand.Next(0, recordCount - 1)
For i As Integer = 0 To intRand - 1
reader.Read()
LastName = reader("LastName").ToString()
FirstName = reader("FirstName").ToString()
Title = reader("Title").ToString()
City = reader("City").ToString()
Next i
Loop
reader.Close()
For j As Integer = 0 To slide4_Renamed.Shapes.Count - 1
Dim shape As Shape = slide4_Renamed.Shapes(j)
If shape.TextFrame IsNot Nothing Then
Dim tf As TextFrame = shape.TextFrame
If tf.Paragraphs.Count <> 0 Then
Dim para As Paragraph = tf.Paragraphs(0)
If para.Text = "Name" Then
para.Alignment = TextAlignment.Center
For Each port As Portion In para.Portions
port.FontBold = True
port.FontColor = Color.Black
port.FontEmbossed = False
port.FontItalic = False
port.FontShadow = False
port.FontUnderline = False
port.FontHeight = 40
port.Text = FirstName & " " & LastName
Next port
' Add Entry Effect for the Shape
shape.AnimationSettings.EntryEffect = ShapeEntryEffect.FlyFromLeft
ElseIf para.Text = "Title" Then
para.Alignment = TextAlignment.Center
For Each port As Portion In para.Portions
port.FontBold = False
port.FontColor = Color.Black
port.FontEmbossed = False
port.FontItalic = False
port.FontShadow = False
port.FontUnderline = False
port.FontHeight = 30
port.Text = Title
Next port
' Add Entry Effect for the Shape
shape.AnimationSettings.EntryEffect = ShapeEntryEffect.FlyFromRight
ElseIf para.Text = "Location" Then
para.Alignment = TextAlignment.Center
For Each port As Portion In para.Portions
port.FontBold = False
port.FontColor = Color.Black
port.FontEmbossed = False
port.FontItalic = False
port.FontShadow = False
port.FontUnderline = False
port.FontHeight = 30
port.Text = City
Next port
' Add Entry Effect for the Shape
shape.AnimationSettings.EntryEffect = ShapeEntryEffect.FlyFromLeft
End If
End If
End If
Next j
' Add Slide Transition Effect
slide4_Renamed.SlideShowTransition.EntryEffect = SlideTransitionEffect.Dissolve
Return slide4_Renamed
End Function
'INSTANT VB NOTE: The parameter slide5 was renamed since Visual Basic will not allow parameters with the same name as their enclosing function or property:
Private Function Slide5(ByVal slide5_Renamed As Slide) As Slide
' Item of the month
Dim selectString As String = "SELECT top 1 ProductName, count([Order Details].ProductID) as numOrders " & "FROM " & "Products INNER JOIN (Orders INNER JOIN [Order Details] " & "ON Orders.OrderID = [Order Details].OrderID) ON Products.ProductID = [Order Details].ProductID " & "WHERE " & "Orders.OrderDate >#" & ddlReportingMonth.SelectedItem.Value.ToString() & "-01-" & ddlReportingYear.SelectedItem.ToString() & "# " & "and Orders.OrderDate < #" & ddlReportingMonth.SelectedItem.Value.ToString() & "-" & DateTime.DaysInMonth(Convert.ToInt16(ddlReportingYear.SelectedItem.ToString()), Convert.ToInt16(ddlReportingMonth.SelectedItem.Value.ToString())).ToString() & "-" & ddlReportingYear.SelectedItem.ToString() & "# " & "and [Order Details].OrderID = Orders.OrderID " & "Group by " & "ProductName " & "order by count([Order Details].ProductID) desc"
' Create an OleDbCommand object
Dim cmd As New OleDbCommand(selectString, cn)
' Send the CommandText to the connection, and then build an OleDbDataReader
Dim reader As OleDbDataReader = cmd.ExecuteReader()
Dim ProductName As String = "", NumberOfOrders As String = ""
Do While reader.Read()
ProductName = reader("ProductName").ToString()
NumberOfOrders = reader("numOrders").ToString()
Loop
reader.Close()
For j As Integer = 0 To slide5_Renamed.Shapes.Count - 1
Dim shape As Shape = slide5_Renamed.Shapes(j)
If shape.TextFrame IsNot Nothing Then
Dim tf As TextFrame = shape.TextFrame
If tf.Paragraphs.Count <> 0 Then
Dim para As Paragraph = tf.Paragraphs(0)
If para.Text = "Subtitle" Then
para.Alignment = TextAlignment.Center
For Each port As Portion In para.Portions
port.FontBold = True
port.FontColor = Color.Black
port.FontEmbossed = False
port.FontItalic = False
port.FontShadow = False
port.FontUnderline = False
port.FontHeight = 30
port.Text = "Top Selling Item by Volume for " & ddlReportingMonth.SelectedItem.ToString() & " " & ddlReportingYear.SelectedItem.ToString()
Next port
ElseIf para.Text = "Body1" Then
para.Alignment = TextAlignment.Left
For Each port As Portion In para.Portions
port.FontBold = False
port.FontColor = Color.Black
port.FontEmbossed = False
port.FontItalic = False
port.FontShadow = False
port.FontUnderline = False
port.FontHeight = 25
If ProductName <> "" Then
port.Text = "Item Name: " & ProductName
Else
port.FontColor = Color.Red
port.Text = "No Sales Reported for this Time Period."
para.Alignment = TextAlignment.Center
End If
Next port
' Add Entry Effect for the Shape
shape.AnimationSettings.EntryEffect = ShapeEntryEffect.SplitHorizontalOut
ElseIf para.Text = "Body2" Then
para.Alignment = TextAlignment.Left
For Each port As Portion In para.Portions
port.FontBold = False
port.FontColor = Color.Black
port.FontEmbossed = False
port.FontItalic = False
port.FontShadow = False
port.FontUnderline = False
port.FontHeight = 25
If NumberOfOrders <> "" Then
port.Text = "Number of Sales for the Month: " & NumberOfOrders
Else
port.Text = ""
End If
' Add Entry Effect for the Shape
shape.AnimationSettings.EntryEffect = ShapeEntryEffect.SplitHorizontalIn
Next port
End If
End If
End If
Next j
' Add Slide Transition Effect
slide5_Renamed.SlideShowTransition.EntryEffect = SlideTransitionEffect.DiamondOut
Return slide5_Renamed
End Function
'INSTANT VB NOTE: The parameter slide6 was renamed since Visual Basic will not allow parameters with the same name as their enclosing function or property:
Private Function Slide6(ByVal slide6_Renamed As Slide) As Slide
' Item of the Year
Dim selectString As String = "SELECT top 1 ProductName, count([Order Details].ProductID) as numOrders " & "FROM " & "Products INNER JOIN (Orders INNER JOIN [Order Details] " & "ON Orders.OrderID = [Order Details].OrderID) ON Products.ProductID = [Order Details].ProductID " & "WHERE " & "Orders.OrderDate >#01-01-" & ddlReportingYear.SelectedItem.ToString() & "# " & "and Orders.OrderDate < #12-31-" & ddlReportingYear.SelectedItem.ToString() & "# " & "and [Order Details].OrderID = Orders.OrderID " & "Group by " & "ProductName " & "order by count([Order Details].ProductID) desc"
' Create an OleDbCommand object
Dim cmd As New OleDbCommand(selectString, cn)
' Send the CommandText to the connection, and then build an OleDbDataReader
Dim reader As OleDbDataReader = cmd.ExecuteReader()
Dim ProductName As String = "", NumberOfOrders As String = ""
Do While reader.Read()
ProductName = reader("ProductName").ToString()
NumberOfOrders = reader("numOrders").ToString()
Loop
reader.Close()
For j As Integer = 0 To slide6_Renamed.Shapes.Count - 1
Dim shape As Shape = slide6_Renamed.Shapes(j)
If shape.TextFrame IsNot Nothing Then
Dim tf As TextFrame = shape.TextFrame
If tf.Paragraphs.Count <> 0 Then
Dim para As Paragraph = tf.Paragraphs(0)
If para.Text = "Subtitle" Then
para.Alignment = TextAlignment.Center
For Each port As Portion In para.Portions
port.FontBold = True
port.FontColor = Color.Black
port.FontEmbossed = False
port.FontItalic = False
port.FontShadow = False
port.FontUnderline = False
port.FontHeight = 30
port.Text = "Top Selling Item by Volume for " & ddlReportingYear.SelectedItem.ToString()
Next port
ElseIf para.Text = "Body1" Then
para.Alignment = TextAlignment.Left
For Each port As Portion In para.Portions
port.FontBold = False
port.FontColor = Color.Black
port.FontEmbossed = False
port.FontItalic = False
port.FontShadow = False
port.FontUnderline = False
port.FontHeight = 25
If ProductName <> "" Then
port.Text = "Item Name: " & ProductName
End If
Next port
' Add Entry Effect for the Shape
shape.AnimationSettings.EntryEffect = ShapeEntryEffect.Swivel
ElseIf para.Text = "Body2" Then
para.Alignment = TextAlignment.Left
For Each port As Portion In para.Portions
port.FontBold = False
port.FontColor = Color.Black
port.FontEmbossed = False
port.FontItalic = False
port.FontShadow = False
port.FontUnderline = False
port.FontHeight = 25
If NumberOfOrders <> "" Then
port.Text = "Number of Sales for the Year: " & NumberOfOrders
End If
Next port
' Add Entry Effect for the Shape
shape.AnimationSettings.EntryEffect = ShapeEntryEffect.WipeUp
End If
End If
End If
Next j
' Add picture of item
Dim pic1 As Picture = Nothing
If ProductName = "Gnocchi di nonna Alice" Then
pic1 = New Picture(pres, MapPath(".") & "/images/Gnocchi.jpg")
ElseIf ProductName = "Konbu" Then
pic1 = New Picture(pres, MapPath(".") & "/images/konbu.jpg")
ElseIf ProductName = "Gorgonzola Telino" Then
pic1 = New Picture(pres, MapPath(".") & "/images/Gorgonzola.gif")
End If
Dim picid1 As Integer = pres.Pictures.Add(pic1)
Dim pictureWidth As Integer = pres.Pictures(picid1 - 1).Image.Width * 5
Dim pictureHeight As Integer = pres.Pictures(picid1 - 1).Image.Height * 5
Dim slideWidth As Integer = slide6_Renamed.Background.Width
Dim slideHeight As Integer = slide6_Renamed.Background.Height
Dim pictureFrameX As Integer = Convert.ToInt32(slideWidth \ 2 - pictureWidth \ 2)
Dim pictureFrameY As Integer = Convert.ToInt32(slideHeight \ 2 - pictureHeight \ 2 + 1000)
Dim pf As PictureFrame = slide6_Renamed.Shapes.AddPictureFrame(picid1, pictureFrameX, pictureFrameY, pictureWidth, pictureHeight)
pf.AnimationSettings.EntryEffect = ShapeEntryEffect.ZoomIn
' Add Slide Transition Effect
slide6_Renamed.SlideShowTransition.EntryEffect = SlideTransitionEffect.CircleOut
Return slide6_Renamed
End Function
'INSTANT VB NOTE: The parameter slide7 was renamed since Visual Basic will not allow parameters with the same name as their enclosing function or property:
Private Function Slide7(ByVal slide7_Renamed As Slide) As Slide
' Sales By Contry Chart for the year.
' Creat the Chart Image
createChart()
slide7_Renamed.FollowMasterBackground = False
slide7_Renamed.Background.FillFormat.BackColor = Color.White
Dim pic1 As New Picture(pres, MapPath(".") & "/images/chart.gif")
Dim picid1 As Integer = pres.Pictures.Add(pic1)
Dim slideWidth As Integer = slide7_Renamed.Background.Width
Dim slideHeight As Integer = slide7_Renamed.Background.Height
Dim pf As PictureFrame = slide7_Renamed.Shapes.AddPictureFrame(picid1, 0, 1400, slideWidth, slideHeight - 1400)
' Add Entry Effect for the Chart Image
pf.AnimationSettings.EntryEffect = ShapeEntryEffect.BoxOut
For j As Integer = 0 To slide7_Renamed.Shapes.Count - 1
Dim shape As Shape = slide7_Renamed.Shapes(j)
If shape.TextFrame IsNot Nothing Then
Dim tf As TextFrame = shape.TextFrame
If tf.Paragraphs.Count <> 0 Then
Dim para As Paragraph = tf.Paragraphs(0)
If para.Text = "Subtitle" Then
para.Alignment = TextAlignment.Center
For Each port As Portion In para.Portions
port.FontBold = True
port.FontColor = Color.Black
port.FontEmbossed = False
port.FontItalic = False
port.FontShadow = False
port.FontUnderline = False
port.FontHeight = 25
port.Text = "A Graphical Comparison of Sales between"
Next port
' Add second paragraph to the shape
tf.Paragraphs.Add(New Paragraph(tf.Paragraphs(0)))
Dim para2 As Paragraph = tf.Paragraphs(1)
For Each port As Portion In para2.Portions
port.FontBold = False
port.FontColor = Color.Black
port.FontEmbossed = False
port.FontItalic = False
port.FontShadow = True
port.FontUnderline = False
port.FontHeight = 25
port.Text = "the United States and Europe for " & ddlReportingYear.SelectedItem.ToString()
Next port
End If
End If
End If
Next j
' Add Slide Transition Effect
slide7_Renamed.SlideShowTransition.EntryEffect = SlideTransitionEffect.CutThroughBlack
Return slide7_Renamed
End Function
'INSTANT VB NOTE: The parameter slide8 was renamed since Visual Basic will not allow parameters with the same name as their enclosing function or property:
Private Function Slide8(ByVal slide8_Renamed As Slide) As Slide
' Company Picnic Promotion
slide8_Renamed.FollowMasterBackground = False
slide8_Renamed.Background.FillFormat.Type = FillType.Picture
Dim pic1 As New Picture(pres, MapPath(".") & "/images/picnic.jpg")
Dim picid As Integer = pres.Pictures.Add(pic1)
slide8_Renamed.Background.PictureId = picid
' Get date from Calendar or just set date 2 weeks into the future
Dim dtfi As New System.Globalization.DateTimeFormatInfo()
Dim month, day, year As String
If calPicnicDate.SelectedDate > DateTime.Now Then
month = dtfi.GetMonthName(calPicnicDate.SelectedDate.Month)
day = calPicnicDate.SelectedDate.Day.ToString()
year = calPicnicDate.SelectedDate.Year.ToString()
Else
Dim dt As DateTime = DateTime.Now.AddDays(21)
month = dtfi.GetMonthName(dt.Month)
day = dt.Day.ToString()
year = dt.Year.ToString()
End If
For k As Integer = 0 To slide8_Renamed.Placeholders.Count - 1
Dim holder As Placeholder = slide8_Renamed.Placeholders(k)
If TypeOf holder Is TextHolder Then
For Each para As Paragraph In (CType(holder, TextHolder)).Paragraphs
If para.Text = "Company Picnic Announcement" Then
For Each port As Portion In para.Portions
port.FontColor = Color.Red
Next port
End If
Next para
End If
Next k
For j As Integer = 0 To slide8_Renamed.Shapes.Count - 1
Dim shape As Shape = slide8_Renamed.Shapes(j)
If shape.TextFrame IsNot Nothing Then
Dim tf As TextFrame = shape.TextFrame
If tf.Paragraphs.Count <> 0 Then
Dim para As Paragraph = tf.Paragraphs(0)
If para.Text = "Subtitle" Then
para.Alignment = TextAlignment.Center
For Each port As Portion In para.Portions
port.FontBold = True
port.FontColor = Color.Red
port.FontEmbossed = False
port.FontItalic = False
port.FontShadow = False
port.FontUnderline = False
port.FontHeight = 25
port.Text = "The Company Picnic will be held "
Next port
' Add second paragraph to the shape
tf.Paragraphs.Add(New Paragraph(tf.Paragraphs(0)))
Dim para2 As Paragraph = tf.Paragraphs(1)
For Each port As Portion In para2.Portions
port.FontBold = True
port.FontColor = Color.Red
port.FontEmbossed = False
port.FontItalic = False
port.FontShadow = False
port.FontUnderline = False
port.FontHeight = 25
port.Text = month & " " & day & ", " & year & " at South Lake Shore Park"
Next port
End If
End If
End If
Next j
' Create 3 Shapes to hold text
Dim shape1 As Shape = slide8_Renamed.Shapes.AddRectangle(400, 1400, 2300, 800)
shape1.FillFormat.Type = FillType.Texture
shape1.FillFormat.SetTextureStyle(TextureStyle.PurpleMesh)
Dim shape2 As Shape = slide8_Renamed.Shapes.AddRectangle(3100, 2200, 2300, 800)
shape2.FillFormat.Type = FillType.Gradient
shape2.FillFormat.GradientColorType = GradientColorType.TwoColors
shape2.FillFormat.GradientFillAngle = 40
shape2.FillFormat.ForeColor = Color.LightSteelBlue
shape2.FillFormat.BackColor = Color.LightGreen
Dim shape3 As Shape = slide8_Renamed.Shapes.AddRectangle(400, 3000, 2300, 800)
shape3.FillFormat.Type = FillType.Solid
shape3.FillFormat.ForeColor = Color.Yellow
' Add a picture of a hotdog
Dim pic2 As New Picture(pres, MapPath(".") & "/images/hotdog.gif")
Dim picid1 As Integer = pres.Pictures.Add(pic2)
Dim pictureWidth As Integer = pres.Pictures(picid1 - 1).Image.Width * 12
Dim pictureHeight As Integer = pres.Pictures(picid1 - 1).Image.Height * 12
Dim slideWidth As Integer = slide8_Renamed.Background.Width
Dim slideHeight As Integer = slide8_Renamed.Background.Height
Dim pf As PictureFrame = slide8_Renamed.Shapes.AddPictureFrame(picid1, 3400, 3200, pictureWidth, pictureHeight)
shape1.AddTextFrame("Shape1")
' Add text to the shapes
If shape1.TextFrame IsNot Nothing Then
Dim tf As TextFrame = shape1.TextFrame
Dim para As Paragraph = tf.Paragraphs(0)
para.Alignment = TextAlignment.Center
For Each port As Portion In para.Portions
port.FontBold = False
port.FontColor = Color.Green
port.FontEmbossed = False
port.FontItalic = False
port.FontShadow = True
port.FontUnderline = False
port.FontHeight = 20
port.Text = "Fun for the Whole Family!"
Next port
End If
shape2.AddTextFrame("Shape2")
If shape2.TextFrame IsNot Nothing Then
Dim tf As TextFrame = shape2.TextFrame
Dim para As Paragraph = tf.Paragraphs(0)
para.Alignment = TextAlignment.Center
For Each port As Portion In para.Portions
port.FontBold = False
port.FontColor = Color.DodgerBlue
port.FontEmbossed = False
port.FontItalic = False
port.FontShadow = True
port.FontUnderline = False
port.FontHeight = 20
port.Text = "Live Entertainment!"
Next port
End If
shape3.AddTextFrame("Shape3")
If shape3.TextFrame IsNot Nothing Then
Dim tf As TextFrame = shape3.TextFrame
Dim para As Paragraph = tf.Paragraphs(0)
para.Alignment = TextAlignment.Center
For Each port As Portion In para.Portions
port.FontBold = False
port.FontColor = Color.Purple
port.FontEmbossed = False
port.FontItalic = False
port.FontShadow = True
port.FontUnderline = False
port.FontHeight = 20
port.Text = "Catered"
Next port
' Add second paragraph to the shape
tf.Paragraphs.Add(New Paragraph(tf.Paragraphs(0)))
Dim para2 As Paragraph = tf.Paragraphs(1)
For Each port As Portion In para2.Portions
port.FontBold = False
port.FontColor = Color.Purple
port.FontEmbossed = False
port.FontItalic = False
port.FontShadow = True
port.FontUnderline = False
port.FontHeight = 20
port.Text = "by"
Next port
' Add third paragraph to the shape
tf.Paragraphs.Add(New Paragraph(tf.Paragraphs(0)))
Dim para3 As Paragraph = tf.Paragraphs(2)
For Each port As Portion In para3.Portions
port.FontBold = False
port.FontColor = Color.Purple
port.FontEmbossed = False
port.FontItalic = False
port.FontShadow = True
port.FontUnderline = False
port.FontHeight = 20
port.Text = "Ed's Catfish Saloon!"
Next port
End If
' Set Entry Effects
slide8_Renamed.Background.AnimationSettings.EntryEffect = ShapeEntryEffect.StretchAcross
slide8_Renamed.Background.AnimationSettings.AnimationOrder = 1
shape1.AnimationSettings.EntryEffect = ShapeEntryEffect.Swivel
shape1.AnimationSettings.AnimationOrder = 2
shape2.AnimationSettings.EntryEffect = ShapeEntryEffect.Wedge
shape2.AnimationSettings.AnimationOrder = 3
shape3.AnimationSettings.EntryEffect = ShapeEntryEffect.Dissolve
shape3.AnimationSettings.AnimationOrder = 4
pf.AnimationSettings.EntryEffect = ShapeEntryEffect.Spiral
pf.AnimationSettings.AnimationOrder = 5
' Add Slide Transition Effect
slide8_Renamed.SlideShowTransition.EntryEffect = SlideTransitionEffect.Wedge
Return slide8_Renamed
End Function
'INSTANT VB NOTE: The parameter slide9 was renamed since Visual Basic will not allow parameters with the same name as their enclosing function or property:
Private Function Slide9(ByVal slide9_Renamed As Slide) As Slide
' Closeing Slide
' Clone of first slide
Return slide9_Renamed
End Function
Private Sub createChart()
' Create a new Chart
Dim Chart1 As New Chart.Chart()
' Determine if 3D Chart is selected
If ckb3DChart.Checked Then
Chart1.ChartArea.IsThreeD = True
Chart1.ChartArea.ThreeDDepth = 200
Else
Chart1.ChartArea.IsThreeD = False
End If
' Make Chart Area fully non-see though
Chart1.ChartArea.Transparence = 255
' Set background color for the Chart
Chart1.ChartArea.GradientType = GradientType.HorizontalCenter
Chart1.ChartArea.GradientBackColor = Color.PowderBlue
Chart1.ChartArea.AxisY.DefaultLabel.Format = "F0"
' Activate Legend Box
Chart1.ChartArea.LegendBox.LegendPositionType = LegendPositionType.Left
Chart1.ChartArea.LegendBox.IsVisible = True
' Format Axis Lables
Chart1.ChartArea.AxisX.IntervalType = IntervalType.DateTime
Chart1.ChartArea.AxisX.DefaultLabel.Format = "MM-yyyy"
Chart1.ChartArea.AxisX.DefaultLabel.FontAngle = -80
Chart1.ChartArea.AxisX.DefaultLabel.Color = Color.Blue
Chart1.ChartArea.AxisY.DefaultLabel.Color = Color.Blue
Dim selectString As String
Dim chartType As String = ddlTypeOfChart.SelectedItem.ToString()
' Get America's Data
Dim a As New Series()
a.DefaultDataPoint.BorderWidth = 3
a.ChartType = CType(System.Enum.Parse(GetType(ChartType), chartType, True), ChartType)
For i As Integer = 1 To 12
selectString = "SELECT count(Orders.OrderID) as OrderCount FROM Employees INNER JOIN Orders ON Employees.EmployeeID " & "= Orders.EmployeeID WHERE (((Employees.City)<>'London')) and (Orders.OrderDate) > #" & i.ToString() & "-1-" & ddlReportingYear.SelectedItem.Text & "# and " & "(Orders.OrderDate) < #" & i.ToString() & "-" & DateTime.DaysInMonth(Convert.ToInt16(ddlReportingYear.SelectedItem.Text), i).ToString() & "-" & ddlReportingYear.SelectedItem.Text & "#;"
' Create an OleDbCommand object
Dim cmd As New OleDbCommand(selectString, cn)
' Send the CommandText to the connection, and then build an OleDbDataReader
Dim reader As OleDbDataReader = cmd.ExecuteReader()
reader.Read()
' Add point to Chart
a.DataPoints.Add(New DataPoint(i.ToString(), New DateTime(Convert.ToInt16(ddlReportingYear.SelectedItem.Text), i, 1), CInt(Fix(reader.GetValue(0)))))
reader.Close()
Next i
Chart1.SeriesCollection.Add(a)
' Get Europe's Data
Dim l As New Series()
l.DefaultDataPoint.BorderWidth = 3
l.ChartType = CType(System.Enum.Parse(GetType(ChartType), chartType, True), ChartType)
For i As Integer = 1 To 12
selectString = "SELECT count(Orders.OrderID) as OrderCount FROM Employees INNER JOIN Orders ON Employees.EmployeeID " & "= Orders.EmployeeID WHERE (((Employees.City)='London')) and (Orders.OrderDate) > #" & i.ToString() & "-1-" & ddlReportingYear.SelectedItem.Text & "# and " & "(Orders.OrderDate) < #" & i.ToString() & "-" & DateTime.DaysInMonth(Convert.ToInt16(ddlReportingYear.SelectedItem.Text), i).ToString() & "-" & ddlReportingYear.SelectedItem.Text & "#;"
' Create an OleDbCommand object
Dim cmd As New OleDbCommand(selectString, cn)
' Send the CommandText to the connection, and then build an OleDbDataReader
Dim reader As OleDbDataReader = cmd.ExecuteReader()
reader.Read()
' Add point to Chart
l.DataPoints.Add(New DataPoint(i.ToString(), New DateTime(Convert.ToInt16(ddlReportingYear.SelectedItem.Text), i, 1), CInt(Fix(reader.GetValue(0)))))
reader.Close()
Next i
Chart1.SeriesCollection.Add(l)
' Assign Legend Box series names
Chart1.ChartArea.LegendBox.LegendItems(0).Name = "United States"
Chart1.ChartArea.LegendBox.LegendItems(1).Name = "Europe"
' Specifies image file name and path of the chart.
Dim imgPath As String = MapPath(".") & "\images"
' Save the Chart Image
Chart1.Save(imgPath & "\chart.gif", ImageFormat.Gif)
End Sub
End Class
End Namespace
|