imports system.windows.forms
Imports System.ComponentModel
Imports System.Reflection
Imports System.IO
imports System.Drawing
Imports System.Resources
Imports nbfDB
namespace nbfSQLReportBrowserCtrls
<Serializable>Public Class SQLBrowseField
inherits System.Windows.Forms.Label
private pvSQLSource as string
private pvSQLColNumber as integer
public Property SQLSource as String
Get
return pvSQLSource
End Get
Set
pvSQLSource = Value
End Set
End Property
public Property SQLColNumber as integer
Get
return pvSQLColNumber
End Get
Set
pvSQLColNumber = Value
End Set
End Property
End Class
<Serializable>Public Class SQLBrowseTotal
inherits System.Windows.Forms.Label
private pvSQLSource as string
private pvSQLColNumber as integer
public Property SQLSource as String
Get
return pvSQLSource
End Get
Set
pvSQLSource = Value
End Set
End Property
public Property SQLColNumber as integer
Get
return pvSQLColNumber
End Get
Set
pvSQLColNumber = Value
End Set
End Property
End Class
<Serializable>Public Class SQLBrowseLabel
inherits System.Windows.Forms.Label
End Class
Public Class SQLBrowseGrid
Inherits odGridControls.nbfGrid
private pvSQLSource as string
private pvBrowseDataTable as nbfdb.BrowseDataTable
private pvBrowseDataView as DataView
private prvSQL as string = ""
public Property SQLSource as String
Get
return pvSQLSource
End Get
Set
pvSQLSource = Value
End Set
End Property
Public Sub SetDataBinding(ByVal HDB As HDBC, ByVal pvBrowseRep As nbfBrowseRep, ByVal SI As nbfStyleInfo.AppStyle, ByVal SqlSce As nbfSqlSource)
Try
pvSQLSource = SqlSce.BrowseTableName
Dim ci As nbfSqlColInfo
If Not SqlSce.SQLValidated Then
Exit Sub
End If
MyBase.HDBC = HDB
MyBase.SourceSQL = SqlSce.CurrentSQL
MyBase.ResetColumns()
'if SqlSce.LeftBorderLine and SqlSce.RightBorderLine then
' SI.GridBorderStyle = BorderStyle.FixedSingle
'Else
' SI.GridBorderStyle = BorderStyle.None
'End If
' If SqlSce.ColumnLines Then
' SI.GridLineStyle = DataGridLineStyle.Solid
'Else
'SI.GridLineStyle = DataGridLineStyle.None
'End If
GridCaptionVisible = SqlSce.BrowseCaptionVisible
RowHeadersVisible = SqlSce.BrowseRowHeaders
ColHeadersVisible = SqlSce.BrowseColHeaders
'Si.GridCaptionFont = pvBrowseRep.GetRepFont(SqlSce.RepMainHeadFont)
'Si.GridFont = pvBrowseRep.GetRepFont(SqlSce.RepNormalFont)
'Si.GridHeaderFont = pvBrowseRep.GetRepFont(SqlSce.RepColHeadFont)
RepSubHeadFont = pvBrowseRep.GetRepFont(SqlSce.RepSubHeadFont)
RepBreak1HeadFont = pvBrowseRep.GetRepFont(SqlSce.RepBreak1HeadFont)
RepBreak2HeadFont = pvBrowseRep.GetRepFont(SqlSce.RepBreak2HeadFont)
RepType = SqlSce.RepType
RepSpecType = SqlSce.RepSpecType
RepNoTotals = SqlSce.RepNoTotals
RepShowSubTotals = SqlSce.RepShowSubTotals
RepShowTotals = SqlSce.RepShowTotals
RepShowGrandTotals = SqlSce.RepShowGrandTotals
RepBreak1Cols = SqlSce.RepBreak1Cols
RepBreak2Cols = SqlSce.RepBreak2Cols
RepSubTitle = SqlSce.RepSubTitle
RepSubDes = SqlSce.RepSubDes
RepTotDes = SqlSce.RepTotDes
UseFieldSubValue = SqlSce.UseFieldSubValue
UseFieldTotValue = SqlSce.UseFieldTotValue
RepBreak1Cols = SqlSce.RepBreak1Cols
RepBreak2Cols = SqlSce.RepBreak2Cols
RepSubTitle = SqlSce.RepSubTitle
RepSubDes = SqlSce.RepSubDes
RepTotDes = SqlSce.RepTotDes
Dim cnum As Integer = 0
Dim ncd As odGridControls.nbfGridColumn
For Each ci In SqlSce.SqlColInfos
ncd = New odGridControls.nbfGridColumn
ncd.BoundColumn = True
cnum += 1
ncd.DataColNumber = cnum
Select Case ci.ColType
Case "I"
ncd.DataType = odGridControls.nbfColumnDataType.nbfDataTypeInteger
If ci.ColFormat <> "" Then
ncd.NumberFormat = ci.ColFormat
Else
ncd.NumberFormat = ci.ColType
End If
Case "D"
ncd.DataType = odGridControls.nbfColumnDataType.nbfDataTypeDate
ncd.DateFormat = ci.ColFormat
Case "Z", "X", "M", "N"
ncd.DataType = odGridControls.nbfColumnDataType.nbfDataTypeDecimal
If ci.ColFormat <> "" Then
ncd.NumberFormat = ci.ColFormat
Else
ncd.NumberFormat = ci.ColType
End If
Case Else
ncd.DataType = odGridControls.nbfColumnDataType.nbfDataTypeString
End Select
'if ci.ColHeader = "" then
' ncd.ColHeader = ci.ColName
'else
ncd.ColHeader = ci.ColHeader
'end if
ncd.Width = ci.ColWidth
Select Case ci.ColJust
Case "C"
ncd.TextAlign = ContentAlignment.TopCenter
Case "R"
ncd.TextAlign = ContentAlignment.TopRight
Case Else
ncd.TextAlign = ContentAlignment.TopLeft
End Select
If ci.ColHeadJust = "" Then
ci.ColHeadJust = ci.ColJust
End If
Select Case ci.ColHeadJust
Case "C"
ncd.HeaderTextAlign = ContentAlignment.TopCenter
Case "R"
ncd.HeaderTextAlign = ContentAlignment.TopRight
Case Else
ncd.HeaderTextAlign = ContentAlignment.TopLeft
End Select
Columns.Add(ncd)
Next
'Me.SI = SI
ReBind()
Catch ex As Exception
ShowMessage(HDB, ex.Message)
End Try
End Sub
Public Function FormatColString(ByVal ci As nbfSqlColInfo) As String
Dim fmtStr As String = ""
With ci
If .ColFormat <> "" Then
return .ColFormat
else
Select Case .ColType
Case "I"
Return "0"
Case "Z"
return "#,##0.00"
Case "X"
Return ""
Case "M"
return "#,##0.00"
Case "N"
return "#,##0.00"
Case Else
Return ""
End Select
end if
End With
End Function
friend sub TBDblCLick(sender As Object, e As EventArgs)
OnDoubleClick(e)
End Sub
End Class
Public Class DataGridSQLBrowseTextBoxColumn
Inherits DataGridTextBoxColumn
private pvFormatString as String
public sub New()
mybase.New
addhandler Me.textbox.DoubleClick, Addressof tbdblClickHandler
End Sub
public sub New(pd as PropertyDescriptor)
mybase.New(pd)
addhandler Me.textbox.DoubleClick, Addressof tbdblClickHandler
End Sub
public Event TBDblClick as TBDblClickEventHandler
Public Delegate Sub TBDblClickEventHandler(sender As Object, e As EventArgs)
public Sub SetFormatString(byval fstr as String)
pvFormatString = fstr
End Sub
Protected Overridable Sub OnTBDblClick(e As EventArgs)
'Invokes the delegates.
RaiseEvent TBDblClick(Me, e)
End Sub
private sub tbDblClickHandler(sender As Object, e As EventArgs)
OnTBDblClick(e)
end sub
Protected Overrides Function Commit (ByVal dataSource As CurrencyManager, ByVal rowNum As Integer) As Boolean
try
if rowNum <= (datasource.Count - 1) then
if dataSource.Position <> rowNum then
dataSource.Position = rowNum
End If
return mybase.Commit(datasource,RowNum)
end if
catch
end try
end function
Protected Overloads Overrides Sub Edit( _
ByVal [source] As CurrencyManager, _
ByVal rowNum As Integer, _
ByVal bounds As Rectangle, _
ByVal [readOnly] As Boolean)
Edit([source],rowNum,bounds,[readOnly],"",False)
end sub
Protected Overloads Overrides Sub Edit( _
ByVal [source] As CurrencyManager, _
ByVal rowNum As Integer, _
ByVal bounds As Rectangle, _
ByVal [readOnly] As Boolean,byval instantText as string)
Edit([source],rowNum,bounds,[readOnly],instantText,False)
end sub
Protected Overloads Overrides Sub Edit( _
ByVal [source] As CurrencyManager, _
ByVal rowNum As Integer, _
ByVal bounds As Rectangle, _
ByVal [readOnly] As Boolean, _
ByVal instantText As String, _
ByVal cellIsVisible As Boolean)
Try
if rowNum <= ([source].Count - 1) then
if [source].Position <> rowNum then
[source].Position = rowNum
End If
mybase.Edit([source],rowNum,bounds,[readOnly],instantText,cellIsVisible)
end if
catch
end try
End Sub
end class
public Class OLDDataGridSQLBrowseBoolColumn
inherits DataGridBoolColumn
PUBLIC SUB nEW()
mybase.New()
End Sub
PUBLIC SUB nEW(byval pd as propertydescriptor)
mybase.New(pd)
End Sub
Protected Overrides Function Commit (ByVal dataSource As CurrencyManager, ByVal rowNum As Integer) As Boolean
try
if rowNum <= (datasource.Count - 1) then
if dataSource.Position <> rowNum then
dataSource.Position = rowNum
End If
return mybase.Commit(datasource,RowNum)
end if
catch
end try
end function
Protected Overloads Overrides Sub Edit( _
ByVal [source] As CurrencyManager, _
ByVal rowNum As Integer, _
ByVal bounds As Rectangle, _
ByVal [readOnly] As Boolean)
Edit([source],rowNum,bounds,[readOnly],"",False)
end sub
Protected Overloads Overrides Sub Edit( _
ByVal [source] As CurrencyManager, _
ByVal rowNum As Integer, _
ByVal bounds As Rectangle, _
ByVal [readOnly] As Boolean,byval instantText as string)
Edit([source],rowNum,bounds,[readOnly],instantText,False)
end sub
Protected Overloads Overrides Sub Edit( _
ByVal [source] As CurrencyManager, _
ByVal rowNum As Integer, _
ByVal bounds As Rectangle, _
ByVal [readOnly] As Boolean, _
ByVal instantText As String, _
ByVal cellIsVisible As Boolean)
Try
if rowNum <= ([source].Count - 1) then
if [source].Position <> rowNum then
[source].Position = rowNum
End If
mybase.Edit([source],rowNum,bounds,[readOnly],instantText,cellIsVisible)
end if
catch
end try
End Sub
Protected Overrides Sub Abort(ByVal rowNum As Integer)
mybase.Abort(rowNum)
End Sub
Protected Overrides Function GetMinimumHeight() As Integer
return myBase.GetMinimumHeight()
End Function
Protected Overrides Function GetPreferredHeight(ByVal g As System.Drawing.Graphics, ByVal value As Object) As Integer
return myBase.GetPreferredHeight(g, value)
End Function
Protected Overrides Function GetPreferredSize(ByVal g As System.Drawing.Graphics, ByVal value As Object) As System.Drawing.Size
return mybase.GetPreferredSize(g,value)
End Function
Protected Overloads Overrides Sub Paint(ByVal g As System.Drawing.Graphics, ByVal bounds As System.Drawing.Rectangle, ByVal source As System.Windows.Forms.CurrencyManager, ByVal rowNum As Integer)
myBase.Paint(g, bounds, source, rowNum)
End Sub
Protected Overloads Overrides Sub Paint(ByVal g As System.Drawing.Graphics, ByVal bounds As System.Drawing.Rectangle, ByVal source As System.Windows.Forms.CurrencyManager, ByVal rowNum As Integer, ByVal alignToRight As Boolean)
myBase.Paint(g, bounds, source, rowNum, alignToRight)
End Sub
end Class
Public Class DataGridSQLBrowseBoolColumn 'nbfDataGridTestColumn 'xtBoxColumn
Inherits DataGridColumnStyle
Private textDrop As New CheckBox 'DateTimePicker()
private HandlerSet as boolean
private PreferredHeight as Integer = 8
private Img as Image
private bbr as Brush
' The isEditing field tracks whether or not the user is
' editing data with the hosted control.
private isEditing as boolean
public sub New()
mybase.New
textDrop.Visible = False
dim t as Type
if false then
t = Type.GetType("System.Drawing.Bitmap")
if t is nothing then
t = Type.GetType("Bitmap")
End If
'else
' dim bmp as Image = Image.FromFile("c:\a_net\nbfBrowseRep\nbfSqlReporter\tickmark.bmp")
' t = bmp.GetType()
end if
bbr = new SolidBrush(system.Drawing.Color.WhiteSmoke)
Dim myAssembly As System.Reflection.Assembly = System.Reflection.Assembly.GetExecutingAssembly()
Dim myStream As Stream = myAssembly.GetManifestResourceStream("nbfSqlReporter.tickmark.bmp")
Img = New Bitmap(myStream)
addhandler Me.textDrop.TextChanged, Addressof tbChangeHandler
End Sub
public sub New(pd as PropertyDescriptor)
mybase.New(pd)
textDrop.Visible = False
dim t as Type
if false then
t = Type.GetType("System.Drawing.Bitmap")
if t is nothing then
t = Type.GetType("Bitmap")
End If
'else
' dim bmp as Image = Image.FromFile("c:\a_net\nbfBrowseRep\nbfSqlReporter\tickmark.bmp")
' t = bmp.GetType()
end if
bbr = new SolidBrush(system.Drawing.Color.WhiteSmoke)
Dim myAssembly As System.Reflection.Assembly = System.Reflection.Assembly.GetExecutingAssembly()
Dim myStream As Stream = myAssembly.GetManifestResourceStream("nbfSqlReporter.tickmark.bmp")
Img = New Bitmap(myStream)
addhandler Me.textDrop.TextChanged, Addressof tbChangeHandler
End Sub
private sub tbChangeHandler(sender As Object, e As EventArgs)
console.writeline("TB Change " & Me.Textdrop.Text)
end sub
private Sub SetHandler()
if not HandlerSet then
AddHandler textDrop.CheckedChanged, AddressOf TextDropValueChanged
HandlerSet = true
End If
End Sub
private Sub DisableHandler()
if HandlerSet then
RemoveHandler textdrop.CheckedChanged, AddressOf TextDropValueChanged
HandlerSet = false
End If
End Sub
Protected Overrides Sub Abort(ByVal rowNum As Integer)
isEditing = False
textDrop.Visible = False
Console.Writeline("Aborting Row " & rowNum.ToString)
DisableHandler
Invalidate()
End Sub
Protected Overrides Function Commit _
(ByVal dataSource As CurrencyManager, ByVal rowNum As Integer) _
As Boolean
try
Console.Writeline("Commit Called " & cstr(rowNum))
textDrop.Bounds = Rectangle.Empty
SetHandler
'AddHandler textDrop.TextChanged, AddressOf TextDropValueChanged
'RemoveHandler textDrop.TextChanged, AddressOf TextDropValueChanged
If Not isEditing Then
Return True
End If
isEditing = False
Try
if rowNum <= (datasource.Count - 1) then
if dataSource.Position <> rowNum then
dataSource.Position = rowNum
End If
console.WriteLine(me.PropertyDescriptor.PropertyType.Name)
Dim value As boolean = textdrop.Checked
if me.PropertyDescriptor is nothing then
value = textdrop.text
SetColumnValueAtRow(dataSource, rowNum, value)
else
select case me.PropertyDescriptor.PropertyType.Name
case "Decimal"
Dim dvalue As decimal
if textdrop.checked then
dvalue = -1
else
dvalue = 0
End If
SetColumnValueAtRow(dataSource, rowNum, dvalue)
case "Int32","Integer"
Dim ivalue As integer
if textdrop.checked then
ivalue = -1
else
ivalue = 0
End If
SetColumnValueAtRow(dataSource, rowNum, ivalue)
case else
value = textdrop.checked
SetColumnValueAtRow(dataSource, rowNum, value)
End Select
end if
else
Console.Writeline("Attempt to set value at row " & rowNum.ToString & " when max count is " & cstr(datasource.Count -1))
end if
Catch
End Try
Invalidate()
Return True
catch ex as Exception
'debug.write(ex.Message)
end try
End Function
Protected Overloads Overrides Sub Edit( _
ByVal [source] As CurrencyManager, _
ByVal rowNum As Integer, _
ByVal bounds As Rectangle, _
ByVal [readOnly] As Boolean)
Edit([source],rowNum,bounds,[readOnly],"",False)
end sub
Protected Overloads Overrides Sub Edit( _
ByVal [source] As CurrencyManager, _
ByVal rowNum As Integer, _
ByVal bounds As Rectangle, _
ByVal [readOnly] As Boolean,byval instantText as string)
Edit([source],rowNum,bounds,[readOnly],instantText,False)
end sub
Protected Overloads Overrides Sub Edit( _
ByVal [source] As CurrencyManager, _
ByVal rowNum As Integer, _
ByVal bounds As Rectangle, _
ByVal [readOnly] As Boolean, _
ByVal instantText As String, _
ByVal cellIsVisible As Boolean)
Try
Dim value As boolean
Dim dvalue As Decimal
Dim ivalue As integer
Console.Writeline("Edit Getting " & Value & " at row " & rowNum.ToString)
if rowNum <= ([source].Count - 1) then
if [source].Position <> rowNum then
[source].Position = rowNum
End If
'value = CType(GetColumnValueAtRow([source], rowNum), string)
If true then 'cellIsVisible Then
Console.Writeline("Cell Visible")
textdrop.Bounds = New Rectangle _
(bounds.X + 2, bounds.Y + 2, bounds.Width - 4, _
bounds.Height - 4)
if me.PropertyDescriptor is nothing then
value = CType(GetColumnValueAtRow([source], rowNum), boolean)
textdrop.checked = value
else
select case me.PropertyDescriptor.PropertyType.Name
case "Decimal"
dvalue = CType(GetColumnValueAtRow([source], rowNum), decimal)
if dvalue = 0 then
textdrop.checked = false
else
textdrop.checked = true
end if
case "Int32","Integer"
ivalue = CType(GetColumnValueAtRow([source], rowNum), integer)
if ivalue = 0 then
textdrop.checked = false
else
textdrop.checked = true
end if
case else
value = CType(GetColumnValueAtRow([source], rowNum), boolean)
textdrop.checked = value
End Select
End If
textdrop.Visible = True
textdrop.BringToFront()
textdrop.Focus()
SetHandler
'AddHandler textdrop.textChanged, _
'AddressOf TextdropValueChanged
Else
Console.Writeline("Cell not Visible")
textdrop.checked = value
textdrop.Visible = False
End If
If textdrop.Visible Then
DataGridTableStyle.DataGrid.Invalidate(bounds)
End If
else
Console.Writeline("Attempt to get value at row " & rowNum.ToString & " when max count is " & cstr([source].Count - 1))
end if
catch ex as Exception
'debug.write(ex.Message)
end try
End Sub
Protected Overrides Sub ConcedeFocus()
' Hide the TextBox when conceding focus.
mybase.ConcedeFocus
disablehandler
textDrop.Visible = False
End Sub 'ConcedeFocus
Protected Overrides Function GetPreferredSize( _
ByVal g As Graphics, _
ByVal value As Object) As Size
Return New Size(100, PreferredHeight + 4)
End Function
Protected Overrides Function GetMinimumHeight() As Integer
Return PreferredHeight + 4
End Function
Protected Overrides Function GetPreferredHeight(ByVal g As Graphics, ByVal value As Object) As Integer
Return PreferredHeight + 4
End Function
Protected Overloads Overrides Sub Paint(ByVal g As Graphics, ByVal bounds As Rectangle, ByVal [source] As CurrencyManager, ByVal rowNum As Integer)
try
Paint(g, bounds, [source], rowNum, False)
catch
end try
End Sub
Protected Overloads Overrides Sub Paint(ByVal g As Graphics, ByVal bounds As Rectangle, ByVal [source] As CurrencyManager, ByVal rowNum As Integer, ByVal alignToRight As Boolean)
try
Paint(g, bounds, [source], rowNum, Brushes.Red, Brushes.Blue, alignToRight)
catch
end try
End Sub
Protected Overloads Overrides Sub Paint(ByVal g As Graphics, ByVal bounds As Rectangle, ByVal [source] As CurrencyManager, ByVal rowNum As Integer, ByVal backBrush As Brush, ByVal foreBrush As Brush, ByVal alignToRight As Boolean)
try
Dim [bv] As boolean = CType(GetColumnValueAtRow([source], rowNum), boolean)
dim [string] as String = ""
Dim rect As Rectangle = bounds
g.FillRectangle(backBrush, rect)
rect.Offset(0, 2)
rect.Height -= 2
if [bv] then
[string] = "X"
else
[string] = " "
End If
'g.DrawString([string], Me.DataGridTableStyle.DataGrid.Font, foreBrush, RectangleF.FromLTRB(rect.X, rect.Y, rect.Right, rect.Bottom))
'g.FillRectangle(bbr,RectangleF.FromLTRB(rect.X, rect.Y, rect.Right, rect.Bottom))
if [bv] then
rect.Width = cint(img.Width * (rect.Height / img.Height))
g.DrawImage(Img, rect) 'rect.Right, rect.Bottom))
'else
' g.FillRectangle(bbr,RectangleF.FromLTRB(rect.X, rect.Y, rect.Right, rect.Bottom))
end if
catch
end try
End Sub
Protected Overrides Sub SetDataGridInColumn(ByVal value As DataGrid)
try
MyBase.SetDataGridInColumn(value)
If Not (textdrop.Parent Is Nothing) Then
textdrop.Parent.Controls.Remove(textdrop)
End If
If Not (value Is Nothing) Then
value.Controls.Add(textdrop)
End If
catch
end try
End Sub
Private Sub TextDropValueChanged(ByVal sender As Object, ByVal e As eventargs) 'nbftextdropvaluechangedArgs)
Try
Console.Writeline("Grid TextDropValueChanged " & textDrop.text)
Me.isEditing = True
MyBase.ColumnStartedEditing(textDrop)
catch
end try
End Sub
End Class
<Serializable>Public Class SQLBrowseImage
inherits System.Windows.Forms.PictureBox
private pvSourceType as String
private pvSQlSource as String
private pvSQlColumn as Integer
private pvSourceFile as String
private pvImageType as string
Public Property SourceType as String
Get
return pvSourceType
End Get
Set
pvSourceType = Value
End Set
End Property
Public Property SQlSource as String
Get
return pvSQlSource
End Get
Set
pvSQlSource = Value
End Set
End Property
Public Property SQlColumn as Integer
Get
return pvSQlColumn
End Get
Set
pvSQlColumn = Value
End Set
End Property
Public Property SourceFile as String
Get
return pvSourceFile
End Get
Set
pvSourceFile = Value
End Set
End Property
public Property ImageType as String
Get
return pvImageType
End Get
Set
pvImageType = Value
End Set
End Property
public Sub SetImage()
if pvSourceFile <> "" then
Try
me.Image = Image.FromFile(pvSourceFile)
if Image.GetType.Name = "Bitmap" then
pvImageType = "B"
else
pvImageType = "V"
End If
'if pvImageType = "V" then
' me.Image = Image.FromFile(pvSourceFile)
'else
' Image = New Bitmap(pvSourceFile)
'End If
catch ex as Exception
ShowMessage(ex.Message)
end try
End If
End Sub
End Class
<Serializable>Public Class SQLBrowseAmalgum
inherits System.Windows.Forms.Label
End Class
<Serializable>Public Class SQLDrillDown
inherits System.Windows.Forms.Button
End Class
end namespace