Dim sqlConn As SqlConnection = New SqlConnection(Connection)
Try
sqlConn.Open()
Dim sqlcomm AsNew SqlDataAdapter("salesRaptor_GetActivityPC", sqlConn)
sqlcomm.SelectCommand.CommandType = CommandType.StoredProcedure
Dim workParam As SqlParameter = New SqlParameter
workParam = sqlcomm.SelectCommand.Parameters.Add("@Rep", SqlDbType.VarChar, 25)
If chkAllReps.CheckState = CheckState.Checked Then
sqlcomm.SelectCommand.Parameters("@Rep").Value = Rep_ID.ToString
Else
sqlcomm.SelectCommand.Parameters("@Rep").Value = txRepID.Text
EndIf
workParam.Direction = ParameterDirection.Input
workParam = sqlcomm.SelectCommand.Parameters.Add("@Status", SqlDbType.VarChar, 25)
sqlcomm.SelectCommand.Parameters("@Status").Value = "P"
workParam.Direction = ParameterDirection.Input
Dim tempdate1 As DateTime = MthCalForm1.SelectionStart.Date + " 12:00:01 AM"
workParam = sqlcomm.SelectCommand.Parameters.Add("@DateLower", SqlDbType.SmallDateTime)
If actdelsw <> "DELINQUENT" Then sqlcomm.SelectCommand.Parameters("@DateLower").Value = tempdate1
workParam.Direction = ParameterDirection.Input
workParam = sqlcomm.SelectCommand.Parameters.Add("@DateUpper", SqlDbType.SmallDateTime)
If actdelsw = "DELINQUENT" Then
Dim tempdate2 AsDate = Now()
sqlcomm.SelectCommand.Parameters("@DateUpper").Value = tempdate2
Else
Dim tempdate2 AsDate = MthCalForm1.SelectionEnd.Date + " 11:59:59 PM"
sqlcomm.SelectCommand.Parameters("@DateUpper").Value = tempdate2
EndIf
workParam.Direction = ParameterDirection.Input
workParam = sqlcomm.SelectCommand.Parameters.Add("@Delinquent", SqlDbType.VarChar, 1)
If actdelsw = "DELINQUENT" Then
sqlcomm.SelectCommand.Parameters("@Delinquent").Value = "D"
Else
sqlcomm.SelectCommand.Parameters("@Delinquent").Value = "A"
EndIf
workParam.Direction = ParameterDirection.Input
workParam = sqlcomm.SelectCommand.Parameters.Add("@WholeTeam", SqlDbType.VarChar, 1)
If chkAllReps.CheckState = CheckState.Checked Then
sqlcomm.SelectCommand.Parameters("@WholeTeam").Value = "Y"
Else
sqlcomm.SelectCommand.Parameters("@WholeTeam").Value = "N"
EndIf
workParam.Direction = ParameterDirection.Input
workParam = sqlcomm.SelectCommand.Parameters.Add("@Include_Inactive", SqlDbType.VarChar, 1)
sqlcomm.SelectCommand.Parameters("@Include_Inactive").Value = "N"
workParam.Direction = ParameterDirection.Input
Dim ds AsNew DataSet
sqlcomm.Fill(ds, "ACTIVITYGRID") 'holds data from query
ds.Tables(0).Columns(17).ColumnMapping = MappingType.Hidden ' hide the record status field
Dim x = ds.Tables(0).Rows.Count()
Dim mydatatable As DataTable = ds.Tables(0) 'table name
Dim mydataview As DataView = mydatatable.DefaultView
mydataview.Sort = "Date / Time" 'sort table
dgForm1.DataSource = mydataview 'binds data to grid
Dim ts1 AsNew DataGridTableStyle ' change column widths
ts1.MappingName = "ACTIVITYGRID"
Try
dgForm1.TableStyles.Add(ts1)
ts1.GridColumnStyles(0).Width = 130 ' change width of date/time fld
ts1.GridColumnStyles(1).Width = 150 ' change width of prospect name
' date datetime fields to show time
Dim dgtbc As DataGridTextBoxColumn
dgtbc = CType(dgForm1.TableStyles(0).GridColumnStyles(0), DataGridTextBoxColumn)
IfNot dgtbc IsNothingThen
dgtbc.Format = "g"
EndIf
dgtbc = CType(dgForm1.TableStyles(0).GridColumnStyles(7), DataGridTextBoxColumn)
IfNot dgtbc IsNothingThen
dgtbc.Format = "g"
EndIf
Catch
EndTry
ts1.DataGrid.Refresh()
Try
ts1.DataGrid.Select(0)
Catch
EndTry
sqlConn.Close()
Catch tt As Exception
Errmsg = tt.ToString
EventSW = "Y"
errormsg() ' display error msg
sqlConn.Close()
Finally
sqlConn.Close()
EndTry
Dim numRows AsInteger = dgForm1.BindingContext(dgForm1.DataSource, dgForm1.DataMember).Count
txRecCount.Text = "Count: " + CStr(numRows.ToString)
If (dgForm1.CurrentRowIndex < numRows) And (dgForm1.CurrentRowIndex > -1) Then
Entityid = CStr(dgForm1(dgForm1.CurrentRowIndex, 13).ToString) 'store current entity id
Prospid = CStr(dgForm1(dgForm1.CurrentRowIndex, 12).ToString) 'store current prospect id
activityrepid = CStr(dgForm1(dgForm1.CurrentRowIndex, 17).ToString) 'store current activity rep id
Contactid = CStr(dgForm1(dgForm1.CurrentRowIndex, 15).ToString) 'store current contact id
ActContid = CStr(dgForm1(dgForm1.CurrentRowIndex, 14).ToString) 'store current activity id
activitypriority = CStr(dgForm1(dgForm1.CurrentRowIndex, 6).ToString) 'store current activity priority
ActivityNotes = CStr(dgForm1(dgForm1.CurrentRowIndex, 3).ToString) 'store current regarding
EndIf
validateEntityID()
getprospectinfo() ' get prospect information
getcontactinfo() ' get contact information
If tb1.Visible = TrueThen
showtabprospectinfo() ' display info on prospect tab
EndIf
If tb2.Visible = TrueThen
showtabcontactinfo() ' display info on contact tab
EndIf
If tb3.Visible = TrueThen
showtabspousechildreninfo() ' display info on spouse children tab
EndIf
If tb4.Visible = TrueThen
showtabhistoryinfo() ' display info on history tab
EndIf
If tb5.Visible = TrueThen
showtabmachinelisting() ' display info on machine listing tab
EndIf
If tb6.Visible = TrueThen
showtabnotes() ' display info on notes tab
EndIf
If tb7.Visible = TrueThen
showtabcompetitormachines() ' display info on competitor machine listing tab
EndIf
showinqbuttons() ' display inq tab