Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 43.72 KB | None | 0 0
  1. Imports System.Collections.ObjectModel
  2. Imports Telerik.Windows.Controls
  3. Imports Budget_SL.BudgetSvcRef
  4. Imports Telerik.Windows.Controls.GridView
  5. Imports Telerik.Windows.Controls.Charting
  6. Imports System.Math
  7. Imports System.Linq
  8.  
  9. Partial Public Class MainPage
  10. Inherits UserControl
  11.  
  12. Public Class AccumulativeUsage
  13. Dim _Usagetot As Decimal = 0
  14. Dim _usagelastmonth As Decimal = 0
  15. Dim _usagelast3Months As Decimal = 0
  16. Dim _scale As New List(Of Decimal)
  17. Public Sub New()
  18. For i As Integer = 0 To 10
  19. _scale.Add(i * 10000)
  20. Next
  21.  
  22. End Sub
  23.  
  24.  
  25. Public Property Total() As Decimal
  26. Get
  27. Return _Usagetot
  28. End Get
  29. Set(ByVal value As Decimal)
  30. _Usagetot = value
  31. End Set
  32. End Property
  33.  
  34.  
  35. Public Property Uusagelastmonth() As Decimal
  36. Get
  37. Return _usagelastmonth
  38. End Get
  39. Set(ByVal value As Decimal)
  40. _usagelastmonth = value
  41. End Set
  42. End Property
  43.  
  44. Public Property Usagelast3Months() As Decimal
  45. Get
  46. Return _usagelast3Months
  47. End Get
  48. Set(ByVal value As Decimal)
  49. _usagelast3Months = value
  50. End Set
  51. End Property
  52.  
  53. Public Property Scale() As List(Of Decimal)
  54. Get
  55. Return _scale
  56. End Get
  57. Set(ByVal value As List(Of Decimal))
  58. _scale = value
  59. End Set
  60. End Property
  61.  
  62.  
  63.  
  64.  
  65.  
  66. End Class
  67. Public Class MyCat
  68. Dim _cat As String = ""
  69. Dim _usageTot As Double = 0
  70. Dim _AvaToAlloc As Double = 0
  71. Dim _newAlloc As Double = 0
  72. Dim _newBudget As Double = 0
  73. Dim _usage As Double = 0
  74. Dim _budget As Double = 0
  75.  
  76. Public Property Category() As String
  77. Get
  78. Return _cat
  79. End Get
  80. Set(ByVal value As String)
  81. _cat = value
  82. End Set
  83. End Property
  84.  
  85. Public Property UsageTot() As Double
  86. Get
  87. Return _usageTot
  88. End Get
  89. Set(ByVal value As Double)
  90. _usageTot = value
  91. End Set
  92. End Property
  93. Public Property AvaToAlloc() As Double
  94. Get
  95. Return _AvaToAlloc
  96. End Get
  97. Set(ByVal value As Double)
  98. _AvaToAlloc = value
  99. End Set
  100. End Property
  101.  
  102. Public Property NewAlloc() As Double
  103. Get
  104. Return _newAlloc
  105. End Get
  106. Set(ByVal value As Double)
  107. _newAlloc = value
  108. End Set
  109. End Property
  110.  
  111. Public Property NewBudget() As Double
  112. Get
  113. Return _newBudget
  114. End Get
  115. Set(ByVal value As Double)
  116. _newBudget = value
  117. End Set
  118. End Property
  119.  
  120. Public Property Usage() As Double
  121. Get
  122. Return _usage
  123. End Get
  124. Set(ByVal value As Double)
  125. _usage = value
  126. End Set
  127. End Property
  128.  
  129. Public Property Budget() As Double
  130. Get
  131. Return _budget
  132. End Get
  133. Set(ByVal value As Double)
  134. _budget = value
  135. End Set
  136. End Property
  137.  
  138.  
  139. End Class
  140.  
  141. Private m_BatchGuid As Guid
  142. Private m_VisualizationBatchGuid As Guid
  143. Private m_Initializing As Boolean = True
  144. Private m_LoadingBudget As Boolean = False
  145.  
  146. Private m_Initialized As Boolean = False
  147.  
  148. Dim orgColor As System.Windows.Media.Brush = Nothing
  149. Private m_initParams As Dictionary(Of String, String)
  150. Public Sub New(ByVal initParams As Dictionary(Of String, String))
  151. InitializeComponent()
  152.  
  153. m_initParams = initParams
  154.  
  155. m_UserId = CInt(m_initParams("userId"))
  156. m_Username = m_initParams("username")
  157.  
  158. chart.DefaultView.ChartArea.AdditionalYAxes.Add(New AxisY())
  159. chart.DefaultView.ChartArea.AdditionalYAxes.Add(New AxisY())
  160. chart.DefaultView.ChartArea.AdditionalYAxes(0).AxisName = "MTD"
  161. chart.DefaultView.ChartArea.AdditionalYAxes(1).AxisName = "Monthly Avg"
  162.  
  163. 'chartSummary.DefaultView.ChartArea.AdditionalYAxes.Add(New AxisY())
  164. 'chartSummary.DefaultView.ChartArea.AdditionalYAxes.Add(New AxisY())
  165. 'chartSummary.DefaultView.ChartArea.AdditionalYAxes(0).AxisName = "Budget"
  166. 'chartSummary.DefaultView.ChartArea.AdditionalYAxes(1).AxisName = "Average"
  167.  
  168. Dim TheDate As New DateTime(2009, 1, 1)
  169. 'TODO: proc breaks on august data
  170. Dim LastMonth As DateTime = DateTime.Now.AddMonths(-2.0)
  171. While TheDate <= LastMonth
  172. Cb_FromDate.Items.Add(TheDate.ToString("MMMM yyyy"))
  173. Cb_ToDate.Items.Add(TheDate.ToString("MMMM yyyy"))
  174.  
  175. TheDate = TheDate.AddMonths(1.0)
  176. End While
  177.  
  178. Cb_FromDate.SelectedItem = "January 2010"
  179. Cb_ToDate.SelectedItem = LastMonth.ToString("MMMM yyyy")
  180.  
  181. 'Dim detailDefinition As New GridViewTableDefinition()
  182. 'detailDefinition.Relation = New Telerik.Windows.Data.PropertyRelation("Details")
  183. 'Grd_Data.TableDefinition.ChildTableDefinitions.Add(detailDefinition)
  184.  
  185. Btn_SaveChanges.IsEnabled = False
  186. Btn_Reset.IsEnabled = False
  187.  
  188. m_Initializing = False
  189. orgColor = Grd_Data.AlternateRowBackground
  190. End Sub
  191.  
  192. Private Function GetSelectedCustomer() As Budget_UserCustomers
  193. Return Cb_Customer.SelectedItem
  194. End Function
  195.  
  196. Private Function GetSelectedCustomerDatabase() As String
  197. Return ""
  198. End Function
  199.  
  200. Private Sub MyStageDataCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs)
  201. Dim BSC As New BudgetSvcClient
  202. BSC.GetSummariesAsync(m_BatchGuid, GetSelectedCustomerDatabase())
  203. AddHandler BSC.GetSummariesCompleted, AddressOf MyGetSummariesCompleted
  204. End Sub
  205.  
  206. Dim m_Summaries As ObservableCollection(Of Summary_Staging)
  207. Dim m_Details As ObservableCollection(Of Detail_Staging)
  208.  
  209. Private Sub MyGetSummariesCompleted(ByVal sender As Object, ByVal e As GetSummariesCompletedEventArgs)
  210. m_Summaries = e.Result
  211.  
  212. Dim BSC As New BudgetSvcClient
  213. BSC.GetDetailsAsync(m_BatchGuid, GetSelectedCustomerDatabase())
  214. AddHandler BSC.GetDetailsCompleted, AddressOf MyGetDetailsCompleted
  215. End Sub
  216.  
  217. Private Sub PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs)
  218. If e.PropertyName = "ToOrderQty" Then
  219. Dim item As Detail_Staging = sender
  220. UpdateDataForNewQty(item)
  221.  
  222. Btn_SaveChanges.IsEnabled = True
  223. Btn_Reset.IsEnabled = True
  224.  
  225. If Not Txt_LoadedBudget.Text.EndsWith("*") Then
  226. Txt_LoadedBudget.Text &= "*"
  227. End If
  228. End If
  229. End Sub
  230.  
  231. Private Sub MyGetDetailsCompleted(ByVal sender As Object, ByVal e As GetDetailsCompletedEventArgs)
  232. m_Details = e.Result
  233.  
  234. Dim Hash As New Dictionary(Of String, List(Of Detail_Staging))
  235.  
  236. For Each D As Detail_Staging In e.Result
  237. If Not Hash.ContainsKey(D.Category) Then
  238. Hash.Add(D.Category, New List(Of Detail_Staging))
  239. End If
  240.  
  241. Hash(D.Category).Add(D)
  242. Next
  243.  
  244. Dim HS As New ObservableCollection(Of SummaryObj)
  245. For Each S As Summary_Staging In m_Summaries
  246. Dim H As New SummaryObj
  247. H.Summary = S
  248. For Each D As Detail_Staging In Hash(S.Category)
  249. H.Details.Add(D)
  250. AddHandler D.PropertyChanged, AddressOf PropertyChanged
  251. Next
  252.  
  253. HS.Add(H)
  254. Next
  255.  
  256. FillChartAndGauges(HS)
  257.  
  258. Grd_Data.ItemsSource = HS
  259.  
  260. For Each D As Detail_Staging In m_Details
  261. UpdateDataForNewQty(D)
  262. Next
  263.  
  264. ShowBudgetName()
  265.  
  266. WarnAboutZeroPricedItems()
  267.  
  268. m_LoadingBudget = False
  269.  
  270. UpdateSuggestedReallocation()
  271.  
  272. Grd_Data.CalculateAggregates()
  273.  
  274. 'Me.LoadingPanel.Visibility = Windows.Visibility.Collapsed
  275. End Sub
  276.  
  277.  
  278.  
  279. Private Shared Function GenerateSeries(ByVal HS As ObservableCollection(Of SummaryObj), ByVal legendLabel As String, ByVal axisName As String, ByVal definition As ISeriesDefinition) As DataSeries
  280.  
  281.  
  282.  
  283. Dim series As New DataSeries()
  284.  
  285. series.Definition = definition
  286. series.LegendLabel = legendLabel
  287. series.Definition.AxisName = axisName
  288.  
  289. 'For i As Integer = 0 To 5
  290. If legendLabel = "Budget" Then
  291. For Each H As SummaryObj In HS
  292. series.Add(New DataPoint(H.Summary.Budget))
  293. 'chart.GroupingSettings.GroupDescriptors.Add(new ChartGroupDescriptor(descriptor.Member));
  294.  
  295. Next
  296. End If
  297. If legendLabel = "MTD" Then
  298. For Each H As SummaryObj In HS
  299. series.Add(New DataPoint(H.Summary.Expense))
  300. Next
  301. End If
  302. If legendLabel = "Available" Then
  303. For Each H As SummaryObj In HS
  304. series.Add(New DataPoint(H.Summary.Available))
  305. Next
  306. End If
  307. 'Next
  308.  
  309. Return series
  310. End Function
  311.  
  312. Private Shared Function GenerateSummarySeries(ByVal HS As ObservableCollection(Of SummaryObj), ByVal legendLabel As String, ByVal axisName As String, ByVal definition As ISeriesDefinition) As DataSeries
  313.  
  314. Dim series As New DataSeries()
  315.  
  316. series.Definition = definition
  317. 'series.LegendLabel = legendLabel
  318. series.Definition.AxisName = axisName
  319.  
  320.  
  321.  
  322. Dim usage = 0
  323. Dim budget = 0
  324. Dim avg = 0
  325. Dim i = 0
  326. For Each H As SummaryObj In HS
  327. usage = usage + H.Summary.Expense
  328. budget = budget + H.Summary.Budget
  329. avg = avg + H.Summary.Expense
  330. i = i + 1
  331. Next
  332.  
  333. series.Add(New DataPoint(usage))
  334. series.Add(New DataPoint(budget))
  335. series.Add(New DataPoint(avg \ i))
  336.  
  337.  
  338. Return series
  339.  
  340. End Function
  341. Private Sub FillChartAndGauges(ByVal HS As ObservableCollection(Of SummaryObj))
  342.  
  343. chart.DefaultView.ChartArea.DataSeries.Clear()
  344. chart.DefaultView.ChartArea.DataSeries.Add(GenerateSeries(HS, "Budget", String.Empty, New BarSeriesDefinition()))
  345. chart.DefaultView.ChartArea.DataSeries.Add(GenerateSeries(HS, "MTD", "Budget", New BarSeriesDefinition()))
  346. chart.DefaultView.ChartArea.DataSeries.Add(GenerateSeries(HS, "Available", "Average", New BarSeriesDefinition()))
  347. chart.DefaultView.ChartArea.AxisX.LabelRotationAngle = 90
  348. Dim i = 0
  349. For Each H As SummaryObj In HS
  350. chart.DefaultView.ChartArea.AxisX.TickPoints(i).Label = H.Summary.Category
  351. i = i + 1
  352. Next
  353.  
  354.  
  355. chartSummary.DefaultView.ChartLegend.Visibility = Windows.Visibility.Collapsed
  356. chartSummary.DefaultView.ChartArea.DataSeries.Clear()
  357. chartSummary.DefaultView.ChartArea.DataSeries.Add(GenerateSummarySeries(HS, "Usage", String.Empty, New BarSeriesDefinition()))
  358. chartSummary.DefaultView.ChartArea.AxisX.LabelRotationAngle = 90
  359. chartSummary.DefaultView.ChartArea.AxisX.TickPoints(0).Label = "Total Usage"
  360. chartSummary.DefaultView.ChartArea.AxisX.TickPoints(1).Label = "Total Budget"
  361. chartSummary.DefaultView.ChartArea.AxisX.TickPoints(2).Label = "Average Usage"
  362.  
  363.  
  364. Dim FromDate As DateTime = DateTime.ParseExact(Cb_FromDate.SelectedItem, "MMMM yyyy", System.Globalization.CultureInfo.InvariantCulture)
  365. Dim ToDate As DateTime = DateTime.ParseExact(Cb_ToDate.SelectedItem, "MMMM yyyy", System.Globalization.CultureInfo.InvariantCulture)
  366. ToDate = ToDate.AddMonths(1) 'till the end of the month
  367.  
  368. Dim ts = (ToDate - FromDate).TotalDays
  369.  
  370. 'want at least 4 months of data for guages
  371. If ts < 120 Then
  372. FromDate = ToDate.AddMonths(-3)
  373. End If
  374.  
  375.  
  376.  
  377. Dim BSC As New BudgetSvcClient
  378. m_VisualizationBatchGuid = Guid.NewGuid()
  379.  
  380. BSC.StageChartDataAsync(m_VisualizationBatchGuid, GetSelectedCustomer().CustomerId, FromDate, ToDate, m_LoadingBudget, _
  381. GetSelectedCustomerDatabase())
  382. AddHandler BSC.StageChartDataCompleted, AddressOf MyStageChartDataCompleted
  383. End Sub
  384.  
  385. Private Sub MyStageChartDataCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs)
  386. Dim ToDate As DateTime = DateTime.ParseExact(Cb_ToDate.SelectedItem, "MMMM yyyy", System.Globalization.CultureInfo.InvariantCulture)
  387. Dim BSC As New BudgetSvcClient
  388. BSC.GetSummariesForVisualizationsAsync(m_VisualizationBatchGuid, ToDate)
  389. AddHandler BSC.GetSummariesForVisualizationsCompleted, AddressOf MyGetSummariesForVisualizationsCompleted
  390. End Sub
  391. Private Sub MyGetSummariesForVisualizationsCompleted(ByVal sender As Object, ByVal e As GetSummariesForVisualizationsCompletedEventArgs)
  392. Dim summaries = e.Result
  393.  
  394.  
  395. Dim FromDate As DateTime = DateTime.ParseExact(Cb_FromDate.SelectedItem, "MMMM yyyy", System.Globalization.CultureInfo.InvariantCulture)
  396. Dim ToDate As DateTime = DateTime.ParseExact(Cb_ToDate.SelectedItem, "MMMM yyyy", System.Globalization.CultureInfo.InvariantCulture)
  397. ToDate = ToDate 'till the end of the month
  398.  
  399. Dim ts = (ToDate - FromDate).TotalDays
  400.  
  401. 'want at least 4 months of data for guages
  402. If ts < 120 Then
  403. FromDate = ToDate.AddMonths(-3)
  404. End If
  405.  
  406. Dim mtd = 0
  407. Dim prior1 = 0
  408. Dim prior2 = 0
  409. Dim prior3 = 0
  410. For Each B As Budget_SummaryForVisualizations In summaries
  411.  
  412. If B.DateCreated.Value = ToDate Then
  413. mtd = mtd + B.Expense.Value
  414. End If
  415. If B.DateCreated.Value = ToDate.AddMonths(-1) Then
  416. prior1 = prior1 + B.Expense.Value
  417. End If
  418. If B.DateCreated.Value = ToDate.AddMonths(-2) Then
  419. prior2 = prior2 + B.Expense.Value
  420. End If
  421. If B.DateCreated.Value = ToDate.AddMonths(-3) Then
  422. prior3 = prior3 + B.Expense.Value
  423. End If
  424. Next
  425. needle_1.Value = mtd
  426. 'GaugeLabel1.Content = ToDate.ToShortDateString()
  427. needle_2.Value = prior1
  428. GaugeLabel2.Text = ToDate.AddMonths(-1).ToString("MMM yyyy") '+ " (" + prior1.ToString() + ")"
  429. needle_3.Value = prior2
  430. GaugeLabel3.Text = ToDate.AddMonths(-2).ToString("MMM yyyy") ' + " (" + prior2.ToString() + ")"
  431. needle_4.Value = prior3
  432. GaugeLabel4.Text = ToDate.AddMonths(-3).ToString("MMM yyyy") ' + " (" + prior3.ToString() + ")"
  433.  
  434.  
  435.  
  436.  
  437. End Sub
  438.  
  439.  
  440. Private Sub ShowBudgetName()
  441. If Not IsNothing(m_LoadedBudget) Then
  442. Txt_LoadedBudget.Text = "Budget """ & m_LoadedBudget.Name & """"
  443. Txt_LoadedBudget.Visibility = Windows.Visibility.Visible
  444. Else
  445. Txt_LoadedBudget.Text = ""
  446. Txt_LoadedBudget.Visibility = Windows.Visibility.Collapsed
  447. End If
  448. End Sub
  449.  
  450. Private Sub LoadData(Optional ByVal BudgetID As Integer = 0)
  451. 'Me.LoadingPanel.Visibility = Windows.Visibility.Visible
  452. Btn_SaveChanges.IsEnabled = False
  453. Btn_Reset.IsEnabled = False
  454.  
  455. m_LoadingBudget = (BudgetID <> 0)
  456.  
  457. m_LoadedBudget = Nothing
  458. m_Summaries = Nothing
  459.  
  460. Dim BSC As New BudgetSvcClient
  461. m_BatchGuid = Guid.NewGuid()
  462. 'm_BatchGuid = New Guid("2C20C29D-4177-4DD0-A535-32478E4D4597")
  463.  
  464. Dim FromDate As DateTime = DateTime.ParseExact(Cb_FromDate.SelectedItem, "MMMM yyyy", System.Globalization.CultureInfo.InvariantCulture)
  465. Dim ToDate As DateTime = DateTime.ParseExact(Cb_ToDate.SelectedItem, "MMMM yyyy", System.Globalization.CultureInfo.InvariantCulture)
  466. 'here is to clear the details todo'
  467. BSC.StageDataAsync(m_BatchGuid, GetSelectedCustomer().CustomerId, FromDate, ToDate.AddMonths(1), BudgetID, _
  468. GetSelectedCustomerDatabase())
  469. AddHandler BSC.StageDataCompleted, AddressOf MyStageDataCompleted
  470. End Sub
  471.  
  472. Private Sub Btn_GetData_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
  473. LoadData()
  474. End Sub
  475.  
  476. Private Sub UpdateDataForNewQty(ByVal D As Detail_Staging)
  477. If m_LoadingBudget Then
  478. D.ToOrderQty = D.TotalQty - D.ToDateQty
  479. Else
  480. D.TotalQty = D.ToDateQty + D.ToOrderQty
  481. End If
  482.  
  483. D.ToOrderAmt = D.ToOrderQty * D.Price
  484. D.TotalAmt = D.ToDateAmt + D.ToOrderAmt
  485.  
  486. Dim NewCatTotal As Double = 0
  487. For Each D2 As Detail_Staging In m_Details
  488. If D2.Category = D.Category Then
  489. NewCatTotal += D2.ToOrderAmt
  490. End If
  491. Next
  492.  
  493. For Each S As Summary_Staging In m_Summaries
  494. If S.Category = D.Category Then
  495. S.Available = S.Budget - S.Expense - NewCatTotal
  496. Exit For
  497. End If
  498. Next
  499. End Sub
  500.  
  501. Private Sub RadGridView1_RowEditEnded(ByVal sender As System.Object, ByVal e As GridViewRowEditEndedEventArgs)
  502. Dim ND As Detail_Staging = e.NewData
  503. ND.ToOrderAmt = ND.ToOrderQty * ND.Price
  504.  
  505. ND.TotalQty = ND.ToDateQty + ND.ToOrderQty
  506. ND.TotalAmt = ND.ToDateAmt + ND.ToOrderAmt
  507.  
  508. Dim NewTotal As Double = 0
  509. For Each D As Detail_Staging In m_Details
  510. If D.Category = ND.Category Then
  511. NewTotal += D.ToOrderAmt
  512. End If
  513. Next
  514.  
  515. For Each S As Summary_Staging In m_Summaries
  516. If S.Category = ND.Category Then
  517. S.Available = S.Budget - S.Expense - NewTotal
  518. Exit For
  519. End If
  520. Next
  521.  
  522. Btn_SaveChanges.IsEnabled = True
  523. Btn_Reset.IsEnabled = True
  524.  
  525. If Not Txt_LoadedBudget.Text.EndsWith("*") Then
  526. Txt_LoadedBudget.Text &= "*"
  527. End If
  528.  
  529. UpdateSuggestedReallocation()
  530. Grd_Data.CalculateAggregates()
  531. End Sub
  532.  
  533. Private m_UserId As Integer = 1
  534. Private m_Username As String = "Jeff"
  535.  
  536. Private Sub UserControl_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
  537. m_Initialized = True
  538.  
  539. Me.ExternalPresenter.DetailsProvider = Me.Grd_Data.RowDetailsProvider
  540.  
  541. 'chart.SeriesMappings.Add(
  542. ' AddSeriesMapping(New Bar3DSeriesDefinition(), "Budget", "Budget"))
  543.  
  544. 'chart.SeriesMappings.Add(
  545. ' AddSeriesMapping(New Bar3DSeriesDefinition(), "MTD", "Expense"))
  546.  
  547. 'chart.SeriesMappings.Add(
  548. ' AddSeriesMapping(New Bar3DSeriesDefinition(), "Montly Average", "SuggestedReallocationOneMonth"))
  549.  
  550.  
  551.  
  552. Dim BSC As New BudgetSvcRef.BudgetSvcClient
  553. AddHandler BSC.GetCustomersForUserCompleted, AddressOf MyGetCustomersForUserCompleted
  554.  
  555. BSC.GetCustomersForUserAsync(m_UserId)
  556. End Sub
  557.  
  558. Private Sub MyGetCustomersForUserCompleted(ByVal sender As Object, ByVal e As GetCustomersForUserCompletedEventArgs)
  559. Cb_Customer.ItemsSource = e.Result
  560. Cb_Customer.DisplayMemberPath = "DecoratedCustomerName"
  561.  
  562. If Cb_Customer.Items.Count > 0 Then
  563. Cb_Customer.SelectedIndex = 0
  564. End If
  565.  
  566. ' Helen doesn't have access to this customer! :)
  567. 'Cb_Customer.SelectedItem = e.Result.Where(Function(x) x.DecoratedCustomerName = "Northern Manor Multicare Center (Medical)")(0)
  568. Btn_GetData_Click(Nothing, Nothing)
  569. End Sub
  570.  
  571. Private Sub Btn_SaveChanges_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
  572. Dim D As New BudgetSaveDlg(m_Username, GetSelectedCustomer().DecoratedCustomerName, m_LoadedBudget, _
  573. GetSelectedCustomerDatabase())
  574. AddHandler D.OnBudgetNameDlgOK, AddressOf OnBudgetNameDlgOK
  575. D.Show()
  576. End Sub
  577.  
  578. Private Sub OnBudgetNameDlgOK(ByVal Name As String, ByVal ExistingBudget As Saved_Budget)
  579. Dim BSC As New BudgetSvcRef.BudgetSvcClient
  580.  
  581. If Not IsNothing(ExistingBudget) Then
  582. BSC.ReplaceBudgetAsync(ExistingBudget, m_Details, m_Username, GetSelectedCustomerDatabase())
  583.  
  584. m_LoadedBudget = ExistingBudget
  585.  
  586. ShowBudgetName()
  587. Else
  588. BSC.SaveBudgetAsync(Name, m_Username, GetSelectedCustomer().DecoratedCustomerName, Cb_FromDate.SelectedItem, _
  589. Cb_ToDate.SelectedItem, m_Details, GetSelectedCustomerDatabase())
  590.  
  591. Txt_LoadedBudget.Text = "Budget """ & Name & """"
  592. End If
  593.  
  594. End Sub
  595.  
  596. Private Sub UpdateUI()
  597. Grd_Data.ItemsSource = Nothing
  598. Btn_SaveChanges.IsEnabled = False
  599. Btn_Reset.IsEnabled = False
  600. m_LoadedBudget = Nothing
  601. Txt_LoadedBudget.Text = ""
  602. Txt_LoadedBudget.Visibility = Windows.Visibility.Collapsed
  603. WarnAboutZeroPricedItems()
  604. End Sub
  605.  
  606. Private Sub WarnAboutZeroPricedItems()
  607. If Not IsNothing(m_Details) Then
  608. Txt_CallRep.Visibility = If(m_Details.Any(Function(x) x.Price <= 0), Windows.Visibility.Visible, Windows.Visibility.Collapsed)
  609. End If
  610. End Sub
  611.  
  612. Private Sub Cb_SelectionChanged(ByVal sender As System.Object, ByVal e As System.Windows.Controls.SelectionChangedEventArgs)
  613. If Not m_Initializing Then
  614. If sender Is Cb_FromDate Then
  615. Dim FromDate As DateTime = DateTime.ParseExact(Cb_FromDate.SelectedItem, "MMMM yyyy", System.Globalization.CultureInfo.InvariantCulture)
  616. Dim ToDate As DateTime = DateTime.ParseExact(Cb_ToDate.SelectedItem, "MMMM yyyy", System.Globalization.CultureInfo.InvariantCulture)
  617.  
  618. If FromDate > ToDate Then
  619. Cb_ToDate.SelectedItem = Cb_FromDate.SelectedItem
  620. End If
  621. ElseIf sender Is Cb_ToDate Then
  622. Dim FromDate As DateTime = DateTime.ParseExact(Cb_FromDate.SelectedItem, "MMMM yyyy", System.Globalization.CultureInfo.InvariantCulture)
  623. Dim ToDate As DateTime = DateTime.ParseExact(Cb_ToDate.SelectedItem, "MMMM yyyy", System.Globalization.CultureInfo.InvariantCulture)
  624.  
  625. If FromDate > ToDate Then
  626. Cb_FromDate.SelectedItem = Cb_ToDate.SelectedItem
  627. End If
  628. End If
  629. End If
  630. End Sub
  631.  
  632. Private Sub Btn_LoadBudget_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
  633. Dim D As New BudgetLoadDlg(m_Username, GetSelectedCustomer().DecoratedCustomerName, GetSelectedCustomerDatabase())
  634. AddHandler D.OnBudgetLoadDlgOK, AddressOf OnBudgetLoadDlgOK
  635. D.Show()
  636. End Sub
  637.  
  638. Private m_LoadedBudget As Saved_Budget
  639.  
  640. Private Sub OnBudgetLoadDlgOK(ByVal b As Saved_Budget)
  641. If Not IsNothing(b) Then
  642. Cb_FromDate.SelectedItem = b.FromMonth
  643. Cb_ToDate.SelectedItem = b.ToMonth
  644.  
  645. LoadData(b.ID)
  646.  
  647. m_LoadedBudget = b
  648. End If
  649. End Sub
  650.  
  651. Private Sub RadGridView1_CellValidating(ByVal sender As System.Object, ByVal e As Telerik.Windows.Controls.GridViewCellValidatingEventArgs)
  652. If Convert.ToDouble(e.NewValue) < 0.0 Then
  653. e.IsValid = False
  654. e.ErrorMessage = "New quantity must be greater than or equal to zero."
  655. End If
  656. End Sub
  657.  
  658. Private Sub RadSlider_ValueChanged(ByVal sender As System.Object, ByVal e As System.Windows.RoutedPropertyChangedEventArgs(Of System.Double))
  659. Try
  660. Dim rs As RadSlider = DirectCast(sender, RadSlider)
  661. If rs.Parent Is Nothing Then
  662. Return
  663. End If
  664. Dim tb As TextBlock = VisualTreeHelper.GetChild(rs.Parent, 3)
  665. tb.Text = " [" & CDbl(e.NewValue).ToString("0") & "%]"
  666.  
  667. Dim HadChange As Boolean = False
  668.  
  669. For Each D2 As Detail_Staging In m_Details
  670. If D2.Category = rs.Tag Then
  671. Dim NewQty As Integer = Math.Round(D2.AvgMonthQty * (rs.Value / 100.0), 0)
  672. If D2.ToOrderQty <> NewQty Then
  673. D2.ToOrderQty = NewQty
  674. UpdateDataForNewQty(D2)
  675.  
  676. HadChange = True
  677. End If
  678. End If
  679. Next
  680.  
  681. If HadChange Then
  682. UpdateSuggestedReallocation()
  683.  
  684. Grd_Data.CalculateAggregates()
  685.  
  686. Dim gvr As GridView.GridViewRow = rs.ParentOfType(Of GridView.GridViewRow)()
  687. Dim gv As RadGridView = gvr.ChildrenOfType(Of RadGridView).FirstOrDefault()
  688. gv.CalculateAggregates()
  689. End If
  690. Catch ex As Exception
  691. End Try
  692. End Sub
  693.  
  694. Private Sub Btn_Reset_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
  695. If Not IsNothing(m_LoadedBudget) Then
  696. LoadData(m_LoadedBudget.ID)
  697. Else
  698. LoadData()
  699. End If
  700. End Sub
  701.  
  702. Private Sub Btn_Export_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
  703. Dim Sfd As New SaveFileDialog
  704. Sfd.DefaultExt = ".csv"
  705. Sfd.Filter = "CSV (Comma delimited) (*.csv)|*.csv|Text (Tab delimited) (*.txt)|*.txt"
  706. Sfd.FilterIndex = 1
  707.  
  708. Dim result As Boolean? = Sfd.ShowDialog().Value
  709.  
  710. If result.HasValue AndAlso result.Value Then
  711. Try
  712. Using Out As New IO.StreamWriter(Sfd.OpenFile())
  713. Dim FFH As New FlatFileHelper(If(Sfd.FilterIndex = 1, FlatFileHelper.FlatFileFormat.Csv, _
  714. FlatFileHelper.FlatFileFormat.Tsv))
  715.  
  716. Dim Headers As String() = New String() {"CustomerID", "ItemNumber", "Quantity", _
  717. "CustomerName", "OrderDate", "DeliveryDate", _
  718. "OrderID", "VendorID", "Buyer", "UnitPrice", _
  719. "ShipTo", "UnitOfMeasure", "SpecialInstructions"}
  720.  
  721. Out.WriteLine(FFH.GetLineForFields(Headers))
  722.  
  723. Dim HS As ObservableCollection(Of SummaryObj) = Grd_Data.ItemsSource
  724. For Each H As SummaryObj In HS
  725. For Each D As Detail_Staging In H.Details
  726. If D.ToOrderQty > 0 Then
  727. Dim Fields As String() = New String() {GetSelectedCustomer().CustomerId, _
  728. D.ItemId, _
  729. D.ToOrderQty, _
  730. GetSelectedCustomer().CustomerName, _
  731. DateTime.Now.ToString("yyyy-MM-dd"), _
  732. "", _
  733. "", _
  734. "", _
  735. "", _
  736. D.Price.ToString("0.0000"), _
  737. "", _
  738. "", _
  739. ""}
  740.  
  741. Out.WriteLine(FFH.GetLineForFields(Fields))
  742. End If
  743. Next
  744. Next
  745. Out.Close()
  746. End Using
  747. Catch ex As UnauthorizedAccessException
  748. MessageBox.Show("Unable to save the data - access to the file """ & Sfd.SafeFileName & """ denied.", "Unable to Export Data", MessageBoxButton.OK)
  749. Catch ex As Exception
  750. MessageBox.Show("An error occurred while saving the data." & vbCrLf & vbCrLf & ex.Message, "Unable to Export Data", MessageBoxButton.OK)
  751. End Try
  752. End If
  753. End Sub
  754.  
  755. Private Sub Btn_AddNewItem_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
  756. Dim ItemSel As New ItemSelector(GetSelectedCustomer().CustomerName.Trim(), m_Details, _
  757. GetSelectedCustomerDatabase())
  758. AddHandler ItemSel.ItemSelector_AddItem, AddressOf ItemSelector_AddItem
  759. ItemSel.Show()
  760. End Sub
  761.  
  762. Private Sub ItemSelector_AddItem(ByVal I As Item)
  763. Dim BSC As New BudgetSvcClient
  764. AddHandler BSC.GetItemPriceCompleted, AddressOf MyGetItemPriceCompleted
  765. BSC.GetItemPriceAsync(I.ItemId, GetSelectedCustomer().CustomerId, _
  766. GetSelectedCustomerDatabase(), I)
  767. End Sub
  768.  
  769. Private Sub MyGetItemPriceCompleted(ByVal sender As Object, ByVal e As GetItemPriceCompletedEventArgs)
  770. Try
  771. Dim I As Item = e.UserState
  772. If m_Details.Where(Function(x) x.ItemId = I.ItemId).Count > 0 Then
  773. MessageBox.Show("This item is already present - and has not been readded to the grid.", "Already Present", MessageBoxButton.OK)
  774. Return
  775. End If
  776.  
  777. Dim HS As ObservableCollection(Of SummaryObj) = Grd_Data.ItemsSource
  778. For Each H As SummaryObj In HS
  779. If H.Summary.Category.Trim() = I.Category.Trim() Then
  780. Grd_Data.ItemsSource = HS
  781. Dim DS As New Detail_Staging
  782. DS.Guid = m_Details(0).Guid
  783. DS.Category = I.Category
  784. DS.ItemDescription = I.ItemName
  785. DS.ItemId = I.ItemId
  786. DS.Price = e.Result
  787. DS.AddedByUser = True
  788.  
  789. AddHandler DS.PropertyChanged, AddressOf PropertyChanged
  790.  
  791. H.Details.Add(DS)
  792. m_Details.Add(DS)
  793. End If
  794. Next
  795.  
  796. WarnAboutZeroPricedItems()
  797.  
  798. MessageBox.Show(String.Format("Item ""{0}"" has been added to category ""{1}"".", I.ItemName, I.Category), _
  799. "Item Added", MessageBoxButton.OK)
  800. Catch ex As Exception
  801. MessageBox.Show(ex.Message)
  802. End Try
  803. End Sub
  804.  
  805. Private Sub RemoveItemButton_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
  806. Try
  807. Dim btn As Button = sender
  808. Dim itemNumber As String = btn.Tag
  809.  
  810. Dim HS As ObservableCollection(Of SummaryObj) = Grd_Data.ItemsSource
  811. For Each H As SummaryObj In HS
  812. Dim items As IEnumerable(Of Detail_Staging) = H.Details.Where(Function(x) x.ItemId = itemNumber.Trim())
  813. If items.Count = 1 Then
  814. H.Details.Remove(items(0))
  815. End If
  816. Next
  817.  
  818. Dim items2 As IEnumerable(Of Detail_Staging) = m_Details.Where(Function(x) x.ItemId = itemNumber.Trim())
  819. If items2.Count = 1 Then
  820. m_Details.Remove(items2(0))
  821. End If
  822.  
  823. WarnAboutZeroPricedItems()
  824. Catch ex As Exception
  825. MessageBox.Show("Unable to remove item." & vbCrLf & vbCrLf & ex.Message, "Unable to Remove Item", MessageBoxButton.OK)
  826. End Try
  827. End Sub
  828.  
  829. Private Class CategoryInfo
  830. Public m_Category As String
  831. Public m_Budget As Decimal
  832. Public m_TotalAmt As Decimal
  833.  
  834. Public ReadOnly Property Surplus() As Decimal
  835. Get
  836. Return m_Budget - m_TotalAmt
  837. End Get
  838. End Property
  839. End Class
  840.  
  841. Private Sub UpdateSuggestedReallocation()
  842. Try
  843. Dim cis As New List(Of CategoryInfo)
  844. For Each cat As String In (From D In m_Details Select D.Category Distinct)
  845. Dim loopCat As String = cat
  846.  
  847. Dim ci As New CategoryInfo With {.m_Category = cat}
  848. cis.Add(ci)
  849.  
  850. ci.m_TotalAmt = m_Details.Where(Function(x) x.Category.Equals(loopCat, StringComparison.InvariantCultureIgnoreCase)).Sum(Function(d) d.TotalAmt)
  851. ci.m_Budget = m_Summaries.Where(Function(x) x.Category.Equals(loopCat, StringComparison.InvariantCultureIgnoreCase)).First.NextMonthBudget
  852. Next
  853.  
  854. ' Determine surplus - the amount that's able to be stolen from other budgets given the current spend.
  855. Dim surplus As Decimal = cis.Where(Function(x) x.Surplus > 0.0).Sum(Function(x) x.Surplus)
  856. ' Determine shortfall - the amount that we need to make up on budgets to meet the current spend.
  857. Dim shortfall As Decimal = -(cis.Where(Function(x) x.Surplus < 0.0).Sum(Function(x) x.Surplus))
  858. ' The amount to reallocate - we cannot reallocate any more than the surplus, and need not allocate any more
  859. ' than the shortfall, hence the Min.
  860. Dim toRealloc As Decimal = Math.Min(surplus, shortfall)
  861.  
  862. Dim tol As Double = txtTolerance.Text
  863. Dim cats As New List(Of MyCat)()
  864. For Each summ As Summary_Staging In m_Summaries
  865. Dim cat As New MyCat()
  866. cat.Budget = Round(summ.Budget.Value, 0)
  867. cat.Usage = Round(summ.Expense.Value, 0)
  868. cat.Category = summ.Category
  869. cat.UsageTot = Round(summ.Expense.Value * (1 + tol / 100), 0)
  870. If cat.UsageTot < summ.Budget Then
  871. cat.AvaToAlloc = summ.Budget - cat.UsageTot
  872. Else
  873. cat.AvaToAlloc = 0
  874. End If
  875.  
  876. cats.Add(cat)
  877. 'loopSummary.SuggestedReallocation = 'months * cis.Where(Function(x) x.m_Category.Equals(loopSummary.Category, StringComparison.InvariantCultureIgnoreCase)).First.m_Budget
  878. Next
  879. Dim totalAvaAlloc As Double = 0
  880. Dim totalUsage As Double = 0
  881. For Each cat As MyCat In cats
  882. totalAvaAlloc = totalAvaAlloc + cat.AvaToAlloc
  883. If cat.UsageTot > cat.Budget Then
  884. totalUsage = totalUsage + cat.Usage
  885. End If
  886.  
  887. Next
  888.  
  889. For Each cat As MyCat In cats
  890. If cat.UsageTot > cat.Budget Then
  891. cat.NewAlloc = Round(totalAvaAlloc * cat.Usage / totalUsage, 0)
  892. cat.NewBudget = cat.Budget + cat.NewAlloc
  893. Else
  894. cat.NewBudget = cat.Budget - cat.AvaToAlloc
  895.  
  896. End If
  897.  
  898. Next
  899.  
  900.  
  901. 'MessageBox.Show(surplus & " " & shortfall & " " & toRealloc)
  902. Dim stDate As Date = Cb_FromDate.SelectedItem
  903. Dim endDate As Date = Cb_ToDate.SelectedItem
  904. Dim months As Integer = DateDiff(DateInterval.Month, stDate, endDate) + 1
  905. If toRealloc = 0.0 Then
  906. ' No amount available to reallocate, or no reallocation required.
  907. For Each summ As Summary_Staging In m_Summaries
  908.  
  909.  
  910. Dim loopSummary As Summary_Staging = summ
  911. For Each cat As MyCat In cats
  912. If cat.Category = loopSummary.Category Then
  913. loopSummary.SuggestedReallocation = cat.NewBudget 'months * cis.Where(Function(x) x.m_Category.Equals(loopSummary.Category, StringComparison.InvariantCultureIgnoreCase)).First.m_Budget
  914. loopSummary.SuggestedReallocationOneMonth = cat.NewBudget / months
  915. Exit For
  916. End If
  917.  
  918.  
  919. Next
  920. Next
  921.  
  922. Return
  923. End If
  924.  
  925. ' For categories over-budget, allocate a percentage based on the size of their shortfall.
  926. For Each ci In cis.Where(Function(x) x.Surplus < 0.0)
  927. ci.m_Budget += toRealloc * (-ci.Surplus / shortfall)
  928. Next
  929.  
  930. ' For categories under-budget, steal a percentage based on the size of their surplus to compensate for
  931. ' the budget increases on other categories.
  932. For Each ci In cis.Where(Function(x) x.Surplus > 0.0)
  933. ci.m_Budget -= toRealloc * (ci.Surplus / surplus)
  934. Next
  935.  
  936. ' We cannot allow a category to have a budget < current month spend - or can we?
  937. For Each ci In cis.Where(Function(x) x.Surplus < 0.0)
  938. ci.m_Budget = Math.Max(ci.m_Budget, ci.m_TotalAmt)
  939. Next
  940.  
  941. ' Push the reallocations onto the summary items.
  942. For Each summ As Summary_Staging In m_Summaries
  943. Dim loopSummary As Summary_Staging = summ
  944. For Each cat As MyCat In cats
  945. If cat.Category = loopSummary.Category Then
  946. loopSummary.SuggestedReallocation = cat.NewBudget 'months * cis.Where(Function(x) x.m_Category.Equals(loopSummary.Category, StringComparison.InvariantCultureIgnoreCase)).First.m_Budget
  947. loopSummary.SuggestedReallocationOneMonth = cat.NewBudget / months
  948. Exit For
  949. End If
  950.  
  951.  
  952. Next
  953. 'loopSummary.SuggestedReallocation = months * cis.Where(Function(x) x.m_Category.Equals(loopSummary.Category, StringComparison.InvariantCultureIgnoreCase)).First.m_Budget
  954. 'loopSummary.SuggestedReallocationOneMonth = cis.Where(Function(x) x.m_Category.Equals(loopSummary.Category, StringComparison.InvariantCultureIgnoreCase)).First.m_Budget
  955. Next
  956. Catch ex As Exception
  957. MessageBox.Show(ex.StackTrace)
  958. End Try
  959. End Sub
  960.  
  961. Private Sub btnSuggest_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
  962. If Grd_Data.Columns(4).Width <> 1 Then
  963. btnSuggest.Content = "Show Suggest Budget with Tolerance %"
  964. Grd_Data.Columns(4).Width = 1
  965. Grd_Data.Columns(5).Width = 1
  966. LoadTolerance(True)
  967. Else
  968. btnSuggest.Content = "Hide Suggest Budget with Tolerance %"
  969. Grd_Data.Columns(4).Width = 90
  970. Grd_Data.Columns(5).Width = 90
  971. LoadTolerance(False)
  972. End If
  973. End Sub
  974.  
  975. Sub LoadTolerance(ByVal isOrg As Boolean)
  976.  
  977. Dim rows = Grd_Data.ChildrenOfType(Of GridViewRow)()
  978. 'If rows.Count - 1 = Grd_Data.Items.Count Then
  979.  
  980.  
  981. For i As Integer = 1 To rows.Count - 1
  982. ' If isOrg Then
  983. 'If i Mod 2 = 0 Then
  984. 'rows(i).Background = Nothing
  985. 'Else
  986.  
  987. 'Dim br As New System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 245, 245, 245))
  988. 'rows(i).Background = br
  989. 'End If
  990.  
  991.  
  992.  
  993. ' Else
  994. Dim summary As Summary_Staging = DirectCast(DirectCast(DirectCast(Grd_Data.Items(i - 1), System.Object), Budget_SL.SummaryObj), Budget_SL.SummaryObj).Summary
  995.  
  996. Dim per As Double = ((summary.Budget - summary.Expense) / summary.Budget) * 100
  997. Dim tol As Double = txtTolerance.Text
  998. If summary.Expense <= summary.Budget And per < tol Then
  999. 'If summary.Budget
  1000. Dim br As New System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 246, 143)) ' Yellow
  1001.  
  1002. rows(i).Background = br
  1003. ElseIf summary.Expense <= summary.Budget Then
  1004. Dim br As New System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 193, 255, 193)) 'Green
  1005.  
  1006. rows(i).Background = br
  1007. ElseIf summary.Expense > summary.Budget And per * -1 < tol Then
  1008. Dim br As New System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 228, 196)) ' Orange
  1009.  
  1010. rows(i).Background = br
  1011.  
  1012.  
  1013. ElseIf summary.Expense > summary.Budget Then
  1014. Dim br As New System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 240, 128, 128)) ' Red
  1015.  
  1016. rows(i).Background = br
  1017. Else
  1018. rows(i).Background = Nothing
  1019. End If
  1020. ' End If
  1021. Next
  1022. 'End If
  1023.  
  1024.  
  1025. End Sub
  1026.  
  1027.  
  1028.  
  1029.  
  1030.  
  1031. Private Sub Grd_Data_RowLoaded(ByVal sender As System.Object, ByVal e As Telerik.Windows.Controls.GridView.RowLoadedEventArgs)
  1032. Try
  1033. If Grd_Data.Columns(4).IsVisible Then
  1034. LoadTolerance(False)
  1035. Else
  1036. LoadTolerance(True)
  1037. End If
  1038.  
  1039. If TypeOf (e.Row) Is GridView.GridViewHeaderRow Then
  1040. Dim row As GridView.GridViewHeaderRow = e.Row
  1041. For Each cell As GridView.GridViewHeaderCell In row.Cells
  1042. Dim texts() As String = {"Category", "Usage to Date", "Total Budget for period", "Available = Total Budget for period - Usage to date", "Suggested Budget for period", "Suggested Budget (1 Month)", _
  1043. "Slider 'To Order' on Details", "Monthly Average", "Usage to Date", "To Order", "Grand Total"}
  1044. If cell.Column.DisplayIndex < texts.Length Then
  1045. cell.SetValue(ToolTipService.ToolTipProperty, texts(cell.Column.DisplayIndex))
  1046. End If
  1047. Next
  1048. End If
  1049.  
  1050. If TypeOf (e.Row) Is GridView.GridViewFooterRow Then
  1051. Dim row As GridView.GridViewFooterRow = e.Row
  1052. For Each cell As GridView.GridViewFooterCell In row.Cells
  1053.  
  1054. Dim test = cell.GetValue(ToolTipService.ToolTipProperty)
  1055. 'Dim utd As GridView.GridViewFooterCell = row.Cells(1) 'Usage to date
  1056. 'Dim budget As GridView.GridViewFooterCell = row.Cells(2) 'Budget
  1057. 'Dim available As GridView.GridViewFooterCell = row.Cells(3) 'Available
  1058. 'Dim test1 = utd.GetValue(ToolTipService.ToolTipProperty)
  1059. '' int id = (int)e.Row.DataContext.GetType().GetProperty("ID").GetValue(e.Row.DataContext, null);
  1060. 'Dim test = row.DataContext.GetType().GetProperty("Expense").GetValue(ToolTipService.ToolTipProperty, Nothing)
  1061.  
  1062. ''Me.needle_1.Value = utd.GetValue
  1063.  
  1064. Next
  1065. End If
  1066. Catch ex As Exception
  1067. MessageBox.Show(ex.Message)
  1068. End Try
  1069. End Sub
  1070.  
  1071. Private Sub RadGridView1_RowLoaded(ByVal sender As System.Object, ByVal e As Telerik.Windows.Controls.GridView.RowLoadedEventArgs)
  1072. If TypeOf (e.Row) Is GridView.GridViewHeaderRow Then
  1073. Dim row As GridView.GridViewHeaderRow = e.Row
  1074. For Each cell As GridView.GridViewHeaderCell In row.Cells
  1075. cell.SetValue(ToolTipService.ToolTipProperty, e.GridViewDataControl.Columns(cell.Column.DisplayIndex).Header)
  1076. Next
  1077. End If
  1078. End Sub
  1079.  
  1080.  
  1081.  
  1082.  
  1083.  
  1084.  
  1085.  
  1086. Private Sub btnchart_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
  1087.  
  1088. If chart.Visibility = Windows.Visibility.Collapsed Then
  1089. chart.Visibility = Windows.Visibility.Visible
  1090. btnchart.Content = "Hide chart"
  1091. Else
  1092. chart.Visibility = Windows.Visibility.Collapsed
  1093. btnchart.Content = "Show chart"
  1094. End If
  1095. End Sub
  1096. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement